PageSourceSearch

https://truvios.ai/assets/index-CIfFlbgM.js

js truvios.ai collected 2026-10-05 16:08:46 UTC 3,724,865 bytes, 587 lines download raw bytes

vendor: 5,538 bytes, line 1
1function Loe(e,s){for(var r=0;r<s.length;r++){const n=s[r];if(typeof n!="string"&&!Array.isArray(n)){for(const a in n)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(n,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>n[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(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"&&n(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 n(a){if(a.ep)return;a.ep=!0;const i=r(a);fetch(a.href,i)}})();var XN=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ei(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var z2={exports:{}},dw={},H2={exports:{}},Jn={};var WL;function $oe(){if(WL)return Jn;WL=1;var e=Symbol.for("react.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.iterator;function g(Q){return Q===null||typeof Q!="object"?null:(Q=p&&Q[p]||Q["@@iterator"],typeof Q=="function"?Q:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,y={};function w(Q,Y,oe){this.props=Q,this.context=Y,this.refs=y,this.updater=oe||v}w.prototype.isReactComponent={},w.prototype.setState=function(Q,Y){if(typeof Q!="object"&&typeof Q!="function"&&Q!=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,Q,Y,"setState")},w.prototype.forceUpdate=function(Q){this.updater.enqueueForceUpdate(this,Q,"forceUpdate")};function j(){}j.prototype=w.prototype;function x(Q,Y,oe){this.props=Q,this.context=Y,this.refs=y,this.updater=oe||v}var C=x.prototype=new j;C.constructor=x,b(C,w.prototype),C.isPureReactComponent=!0;var k=Array.isArray,S=Object.prototype.hasOwnProperty,_={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function T(Q,Y,oe){var he,je={},pe=null,le=null;if(Y!=null)for(he in Y.ref!==void 0&&(le=Y.ref),Y.key!==void 0&&(pe=""+Y.key),Y)S.call(Y,he)&&!A.hasOwnProperty(he)&&(je[he]=Y[he]);var ue=arguments.length-2;if(ue===1)je.children=oe;else if(1<ue){for(var fe=Array(ue),H=0;H<ue;H++)fe[H]=arguments[H+2];je.children=fe}if(Q&&Q.defaultProps)for(he in ue=Q.defaultProps,ue)je[he]===void 0&&(je[he]=ue[he]);return{$$typeof:e,type:Q,key:pe,ref:le,props:je,_owner:_.current}}function M(Q,Y){return{$$typeof:e,type:Q.type,key:Y,ref:Q.ref,props:Q.props,_owner:Q._owner}}function R(Q){return typeof Q=="object"&&Q!==null&&Q.$$typeof===e}function D(Q){var Y={"=":"=0",":":"=2"};return"$"+Q.replace(/[=:]/g,function(oe){return Y[oe]})}var $=/\/+/g;function O(Q,Y){return typeof Q=="object"&&Q!==null&&Q.key!=null?D(""+Q.key):Y.toString(36)}function q(Q,Y,oe,he,je){var pe=typeof Q;(pe==="undefined"||pe==="boolean")&&(Q=null);var le=!1;if(Q===null)le=!0;else switch(pe){case"string":case"number":le=!0;break;case"object":switch(Q.$$typeof){case e:case s:le=!0}}if(le)return le=Q,je=je(le),Q=he===""?"."+O(le,0):he,k(je)?(oe="",Q!=null&&(oe=Q.replace($,"$&/")+"/"),q(je,Y,oe,"",function(H){return H})):je!=null&&(R(je)&&(je=M(je,oe+(!je.key||le&&le.key===je.key?"":(""+je.key).replace($,"$&/")+"/")+Q)),Y.push(je)),1;if(le=0,he=he===""?".":he+":",k(Q))for(var ue=0;ue<Q.length;ue++){pe=Q[ue];var fe=he+O(pe,ue);le+=q(pe,Y,oe,fe,je)}else if(fe=g(Q),typeof fe=="function")for(Q=fe.call(Q),ue=0;!(pe=Q.next()).done;)pe=pe.value,fe=he+O(pe,ue++),le+=q(pe,Y,oe,fe,je);else if(pe==="object")throw Y=String(Q),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(Q).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return le}function V(Q,Y,oe){if(Q==null)return Q;var he=[],je=0;return q(Q,he,"","",function(pe){return Y.call(oe,pe,je++)}),he}function K(Q){if(Q._status===-1){var Y=Q._result;Y=Y(),Y.then(function(oe){(Q._status===0||Q._status===-1)&&(Q._status=1,Q._result=oe)},function(oe){(Q._status===0||Q._status===-1)&&(Q._status=2,Q._result=oe)}),Q._status===-1&&(Q._status=0,Q._result=Y)}if(Q._status===1)return Q._result.default;throw Q._result}var G={current:null},z={transition:null},Z={ReactCurrentDispatcher:G,ReactCurrentBatchConfig:z,ReactCurrentOwner:_};function ee(){throw Error("act(...) is not supported in production builds of React.")}return Jn.Children={map:V,forEach:function(Q,Y,oe){V(Q,function(){Y.apply(this,arguments)},oe)},count:function(Q){var Y=0;return V(Q,function(){Y++}),Y},toArray:function(Q){return V(Q,function(Y){return Y})||[]},only:function(Q){if(!R(Q))throw Error("React.Children.only expected to receive a single React element child.");return Q}}
vendor: 7,254 bytes, line 1
1,Jn.Component=w,Jn.Fragment=r,Jn.Profiler=a,Jn.PureComponent=x,Jn.StrictMode=n,Jn.Suspense=c,Jn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Z,Jn.act=ee,Jn.cloneElement=function(Q,Y,oe){if(Q==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+Q+".");var he=b({},Q.props),je=Q.key,pe=Q.ref,le=Q._owner;if(Y!=null){if(Y.ref!==void 0&&(pe=Y.ref,le=_.current),Y.key!==void 0&&(je=""+Y.key),Q.type&&Q.type.defaultProps)var ue=Q.type.defaultProps;for(fe in Y)S.call(Y,fe)&&!A.hasOwnProperty(fe)&&(he[fe]=Y[fe]===void 0&&ue!==void 0?ue[fe]:Y[fe])}var fe=arguments.length-2;if(fe===1)he.children=oe;else if(1<fe){ue=Array(fe);for(var H=0;H<fe;H++)ue[H]=arguments[H+2];he.children=ue}return{$$typeof:e,type:Q.type,key:je,ref:pe,props:he,_owner:le}},Jn.createContext=function(Q){return Q={$$typeof:o,_currentValue:Q,_currentValue2:Q,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},Q.Provider={$$typeof:i,_context:Q},Q.Consumer=Q},Jn.createElement=T,Jn.createFactory=function(Q){var Y=T.bind(null,Q);return Y.type=Q,Y},Jn.createRef=function(){return{current:null}},Jn.forwardRef=function(Q){return{$$typeof:l,render:Q}},Jn.isValidElement=R,Jn.lazy=function(Q){return{$$typeof:h,_payload:{_status:-1,_result:Q},_init:K}},Jn.memo=function(Q,Y){return{$$typeof:d,type:Q,compare:Y===void 0?null:Y}},Jn.startTransition=function(Q){var Y=z.transition;z.transition={};try{Q()}finally{z.transition=Y}},Jn.unstable_act=ee,Jn.useCallback=function(Q,Y){return G.current.useCallback(Q,Y)},Jn.useContext=function(Q){return G.current.useContext(Q)},Jn.useDebugValue=function(){},Jn.useDeferredValue=function(Q){return G.current.useDeferredValue(Q)},Jn.useEffect=function(Q,Y){return G.current.useEffect(Q,Y)},Jn.useId=function(){return G.current.useId()},Jn.useImperativeHandle=function(Q,Y,oe){return G.current.useImperativeHandle(Q,Y,oe)},Jn.useInsertionEffect=function(Q,Y){return G.current.useInsertionEffect(Q,Y)},Jn.useLayoutEffect=function(Q,Y){return G.current.useLayoutEffect(Q,Y)},Jn.useMemo=function(Q,Y){return G.current.useMemo(Q,Y)},Jn.useReducer=function(Q,Y,oe){return G.current.useReducer(Q,Y,oe)},Jn.useRef=function(Q){return G.current.useRef(Q)},Jn.useState=function(Q){return G.current.useState(Q)},Jn.useSyncExternalStore=function(Q,Y,oe){return G.current.useSyncExternalStore(Q,Y,oe)},Jn.useTransition=function(){return G.current.useTransition()},Jn.version="18.3.1",Jn}var KL;function Pk(){return KL||(KL=1,H2.exports=$oe()),H2.exports}var GL;function Foe(){if(GL)return dw;GL=1;var e=Pk(),s=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,a=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,c,d){var h,p={},g=null,v=null;d!==void 0&&(g=""+d),c.key!==void 0&&(g=""+c.key),c.ref!==void 0&&(v=c.ref);for(h in c)n.call(c,h)&&!i.hasOwnProperty(h)&&(p[h]=c[h]);if(l&&l.defaultProps)for(h in c=l.defaultProps,c)p[h]===void 0&&(p[h]=c[h]);return{$$typeof:s,type:l,key:g,ref:v,props:p,_owner:a.current}}return dw.Fragment=r,dw.jsx=o,dw.jsxs=o,dw}var YL;function Boe(){return YL||(YL=1,z2.exports=Foe()),z2.exports}var t=Boe(),ZN={},q2={exports:{}},uu={},V2={exports:{}},W2={};var QL;function Uoe(){return QL||(QL=1,(function(e){function s(z,Z){var ee=z.length;z.push(Z);e:for(;0<ee;){var Q=ee-1>>>1,Y=z[Q];if(0<a(Y,Z))z[Q]=Z,z[ee]=Y,ee=Q;else break e}}function r(z){return z.length===0?null:z[0]}function n(z){if(z.length===0)return null;var Z=z[0],ee=z.pop();if(ee!==Z){z[0]=ee;e:for(var Q=0,Y=z.length,oe=Y>>>1;Q<oe;){var he=2*(Q+1)-1,je=z[he],pe=he+1,le=z[pe];if(0>a(je,ee))pe<Y&&0>a(le,je)?(z[Q]=le,z[pe]=ee,Q=pe):(z[Q]=je,z[he]=ee,Q=he);else if(pe<Y&&0>a(le,ee))z[Q]=le,z[pe]=ee,Q=pe;else break e}}return Z}function a(z,Z){var ee=z.sortIndex-Z.sortIndex;return ee!==0?ee:z.id-Z.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=[],h=1,p=null,g=3,v=!1,b=!1,y=!1,w=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,x=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(z){for(var Z=r(d);Z!==null;){if(Z.callback===null)n(d);else if(Z.startTime<=z)n(d),Z.sortIndex=Z.expirationTime,s(c,Z);else break;Z=r(d)}}function k(z){if(y=!1,C(z),!b)if(r(c)!==null)b=!0,K(S);else{var Z=r(d);Z!==null&&G(k,Z.startTime-z)}}function S(z,Z){b=!1,y&&(y=!1,j(T),T=-1),v=!0;var ee=g;try{for(C(Z),p=r(c);p!==null&&(!(p.expirationTime>Z)||z&&!D());){var Q=p.callback;if(typeof Q=="function"){p.callback=null,g=p.priorityLevel;var Y=Q(p.expirationTime<=Z);Z=e.unstable_now(),typeof Y=="function"?p.callback=Y:p===r(c)&&n(c),C(Z)}else n(c);p=r(c)}if(p!==null)var oe=!0;else{var he=r(d);he!==null&&G(k,he.startTime-Z),oe=!1}return oe}finally{p=null,g=ee,v=!1}}var _=!1,A=null,T=-1,M=5,R=-1;function D(){return!(e.unstable_now()-R<M)}function $(){if(A!==null){var z=e.unstable_now();R=z;var Z=!0;try{Z=A(!0,z)}finally{Z?O():(_=!1,A=null)}}else _=!1}var O;if(typeof x=="function")O=function(){x($)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,V=q.port2;q.port1.onmessage=$,O=function(){V.postMessage(null)}}else O=function(){w($,0)};function K(z){A=z,_||(_=!0,O())}function G(z,Z){T=w(function(){z(e.unstable_now())},Z)}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(z){z.callback=null},e.unstable_continueExecution=function(){b||v||(b=!0,K(S))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return r(c)},e.unstable_next=function(z){switch(g){case 1:case 2:case 3:var Z=3;break;default:Z=g}var ee=g;g=Z;try{return z()}finally{g=ee}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,Z){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var ee=g;g=z;try{return Z()}finally{g=ee}},e.unstable_scheduleCallback=function(z,Z,ee){var Q=e.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?Q+ee:Q):ee=Q,z){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=ee+Y,z={id:h++,callback:Z,priorityLevel:z,startTime:ee,expirationTime:Y,sortIndex:-1},ee>Q?(z.sortIndex=ee,s(d,z),r(c)===null&&z===r(d)&&(y?(j(T),T=-1):y=!0,G(k,ee-Q))):(z.sortIndex=Y,s(c,z),b||v||(b=!0,K(S))),z},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(z){var Z=g;return function(){var ee=g;g=Z;try{return z.apply(this,arguments)}finally{g=ee}}}})(W2)),W2}var XL;function zoe(){return XL||(XL=1,V2.exports=Uoe()),V2.exports}var ZL;
vendor: 48,348 bytes, lines 1-6
1function Hoe(){if(ZL)return uu;ZL=1;var e=Pk(),s=zoe();function r(m){for(var f="https://reactjs.org/docs/error-decoder.html?invariant="+m,N=1;N<arguments.length;N++)f+="&args[]="+encodeURIComponent(arguments[N]);return"Minified React error #"+m+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var n=new Set,a={};function i(m,f){o(m,f),o(m+"Capture",f)}function o(m,f){for(a[m]=f,m=0;m<f.length;m++)n.add(f[m])}var l=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),c=Object.prototype.hasOwnProperty,d=/^[: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]*$/,h={},p={};function g(m){return c.call(p,m)?!0:c.call(h,m)?!1:d.test(m)?p[m]=!0:(h[m]=!0,!1)}function v(m,f,N,E){if(N!==null&&N.type===0)return!1;switch(typeof f){case"function":case"symbol":return!0;case"boolean":return E?!1:N!==null?!N.acceptsBooleans:(m=m.toLowerCase().slice(0,5),m!=="data-"&&m!=="aria-");default:return!1}}function b(m,f,N,E){if(f===null||typeof f>"u"||v(m,f,N,E))return!0;if(E)return!1;if(N!==null)switch(N.type){case 3:return!f;case 4:return f===!1;case 5:return isNaN(f);case 6:return isNaN(f)||1>f}return!1}function y(m,f,N,E,B,W,de){this.acceptsBooleans=f===2||f===3||f===4,this.attributeName=E,this.attributeNamespace=B,this.mustUseProperty=N,this.propertyName=m,this.type=f,this.sanitizeURL=W,this.removeEmptyString=de}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(m){w[m]=new y(m,0,!1,m,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(m){var f=m[0];w[f]=new y(f,1,!1,m[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(m){w[m]=new y(m,2,!1,m.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(m){w[m]=new y(m,2,!1,m,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(m){w[m]=new y(m,3,!1,m.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(m){w[m]=new y(m,3,!0,m,null,!1,!1)}),["capture","download"].forEach(function(m){w[m]=new y(m,4,!1,m,null,!1,!1)}),["cols","rows","size","span"].forEach(function(m){w[m]=new y(m,6,!1,m,null,!1,!1)}),["rowSpan","start"].forEach(function(m){w[m]=new y(m,5,!1,m.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function x(m){return m[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(m){var f=m.replace(j,x);w[f]=new y(f,1,!1,m,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(m){var f=m.replace(j,x);w[f]=new y(f,1,!1,m,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(m){var f=m.replace(j,x);w[f]=new y(f,1,!1,m,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(m){w[m]=new y(m,1,!1,m.toLowerCase(),null,!1,!1)}),w.xlinkHref=new y("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(m){w[m]=new y(m,1,!1,m.toLowerCase(),null,!0,!0)});function C(m,f,N,E){var B=w.hasOwnProperty(f)?w[f]:null;(B!==null?B.type!==0:E||!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(b(f,N,B,E)&&(N=null),E||B===null?g(f)&&(N===null?m.removeAttribute(f):m.setAttribute(f,""+N)):B.mustUseProperty?m[B.propertyName]=N===null?B.type===3?!1:"":N:(f=B.attributeName,E=B.attributeNamespace,N===null?m.removeAttribute(f):(B=B.type,N=B===3||B===4&&N===!0?"":""+N,E?m.setAttributeNS(E,f,N):m.setAttribute(f,N))))}var k=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,S=Symbol.for("react.element"),_=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),R=Symbol.for("react.provider"),D=Symbol.for("react.context"),$=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),G=Symbol.for("react.offscreen"),z=Symbol.iterator;function Z(m){return m===null||typeof m!="object"?null:(m=z&&m[z]||m["@@iterator"],typeof m=="function"?m:null)}var ee=Object.assign,Q;function Y(m){if(Q===void 0)try{throw Error()}catch(N){var f=N.stack.trim().match(/\n( *(at )?)/);Q=f&&f[1]||""}return`
2`+Q+m}var oe=!1;function he(m,f){if(!m||oe)return"";oe=!0;var N=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(f)if(f=function(){throw Error()},Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(Pt){var E=Pt}Reflect.construct(m,[],f)}else{try{f.call()}catch(Pt){E=Pt}m.call(f.prototype)}else{try{throw Error()}catch(Pt){E=Pt}m()}}catch(Pt){if(Pt&&E&&typeof Pt.stack=="string"){for(var B=Pt.stack.split(`
3`),W=E.stack.split(`
4`),de=B.length-1,Ie=W.length-1;1<=de&&0<=Ie&&B[de]!==W[Ie];)Ie--;for(;1<=de&&0<=Ie;de--,Ie--)if(B[de]!==W[Ie]){if(de!==1||Ie!==1)do if(de--,Ie--,0>Ie||B[de]!==W[Ie]){var Xe=`
5`+B[de].replace(" at new "," at ");return m.displayName&&Xe.includes("<anonymous>")&&(Xe=Xe.replace("<anonymous>",m.displayName)),Xe}while(1<=de&&0<=Ie);break}}}finally{oe=!1,Error.prepareStackTrace=N}return(m=m?m.displayName||m.name:"")?Y(m):""}function je(m){switch(m.tag){case 5:return Y(m.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("SuspenseList");case 0:case 2:case 15:return m=he(m.type,!1),m;case 11:return m=he(m.type.render,!1),m;case 1:return m=he(m.type,!0),m;default:return""}}function pe(m){if(m==null)return null;if(typeof m=="function")return m.displayName||m.name||null;if(typeof m=="string")return m;switch(m){case A:return"Fragment";case _:return"Portal";case M:return"Profiler";case T:return"StrictMode";case O:return"Suspense";case q:return"SuspenseList"}if(typeof m=="object")switch(m.$$typeof){case D:return(m.displayName||"Context")+".Consumer";case R:return(m._context.displayName||"Context")+".Provider";case $:var f=m.render;return m=m.displayName,m||(m=f.displayName||f.name||"",m=m!==""?"ForwardRef("+m+")":"ForwardRef"),m;case V:return f=m.displayName||null,f!==null?f:pe(m.type)||"Memo";case K:f=m._payload,m=m._init;try{return pe(m(f))}catch{}}return null}function le(m){var f=m.type;switch(m.tag){case 24:return"Cache";case 9:return(f.displayName||"Context")+".Consumer";case 10:return(f._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return m=f.render,m=m.displayName||m.name||"",f.displayName||(m!==""?"ForwardRef("+m+")":"ForwardRef");case 7:return"Fragment";case 5:return f;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return pe(f);case 8:return f===T?"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 f=="function")return f.displayName||f.name||null;if(typeof f=="string")return f}return null}function ue(m){switch(typeof m){case"boolean":case"number":case"string":case"undefined":return m;case"object":return m;default:return""}}function fe(m){var f=m.type;return(m=m.nodeName)&&m.toLowerCase()==="input"&&(f==="checkbox"||f==="radio")}function H(m){var f=fe(m)?"checked":"value",N=Object.getOwnPropertyDescriptor(m.constructor.prototype,f),E=""+m[f];if(!m.hasOwnProperty(f)&&typeof N<"u"&&typeof N.get=="function"&&typeof N.set=="function"){var B=N.get,W=N.set;return Object.defineProperty(m,f,{configurable:!0,get:function(){return B.call(this)},set:function(de){E=""+de,W.call(this,de)}}),Object.defineProperty(m,f,{enumerable:N.enumerable}),{getValue:function(){return E},setValue:function(de){E=""+de},stopTracking:function(){m._valueTracker=null,delete m[f]}}}}function se(m){m._valueTracker||(m._valueTracker=H(m))}function me(m){if(!m)return!1;var f=m._valueTracker;if(!f)return!0;var N=f.getValue(),E="";return m&&(E=fe(m)?m.checked?"true":"false":m.value),m=E,m!==N?(f.setValue(m),!0):!1}function ge(m){if(m=m||(typeof document<"u"?document:void 0),typeof m>"u")return null;try{return m.activeElement||m.body}catch{return m.body}}function be(m,f){var N=f.checked;return ee({},f,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:N??m._wrapperState.initialChecked})}function ce(m,f){var N=f.defaultValue==null?"":f.defaultValue,E=f.checked!=null?f.checked:f.defaultChecked;N=ue(f.value!=null?f.value:N),m._wrapperState={initialChecked:E,initialValue:N,controlled:f.type==="checkbox"||f.type==="radio"?f.checked!=null:f.value!=null}}function Pe(m,f){f=f.checked,f!=null&&C(m,"checked",f,!1)}function et(m,f){Pe(m,f);var N=ue(f.value),E=f.type;if(N!=null)E==="number"?(N===0&&m.value===""||m.value!=N)&&(m.value=""+N):m.value!==""+N&&(m.value=""+N);else if(E==="submit"||E==="reset"){m.removeAttribute("value");return}f.hasOwnProperty("value")?bt(m,f.type,N):f.hasOwnProperty("defaultValue")&&bt(m,f.type,ue(f.defaultValue)),f.checked==null&&f.defaultChecked!=null&&(m.defaultChecked=!!f.defaultChecked)}function $e(m,f,N){if(f.hasOwnProperty("value")||f.hasOwnProperty("defaultValue")){var E=f.type;if(!(E!=="submit"&&E!=="reset"||f.value!==void 0&&f.value!==null))return;f=""+m._wrapperState.initialValue,N||f===m.value||(m.value=f),m.defaultValue=f}N=m.name,N!==""&&(m.name=""),m.defaultChecked=!!m._wrapperState.initialChecked,N!==""&&(m.name=N)}function bt(m,f,N){(f!=="number"||ge(m.ownerDocument)!==m)&&(N==null?m.defaultValue=""+m._wrapperState.initialValue:m.defaultValue!==""+N&&(m.defaultValue=""+N))}var Ae=Array.isArray;function Be(m,f,N,E){if(m=m.options,f){f={};for(var B=0;B<N.length;B++)f["$"+N[B]]=!0;for(N=0;N<m.length;N++)B=f.hasOwnProperty("$"+m[N].value),m[N].selected!==B&&(m[N].selected=B),B&&E&&(m[N].defaultSelected=!0)}else{for(N=""+ue(N),f=null,B=0;B<m.length;B++){if(m[B].value===N){m[B].selected=!0,E&&(m[B].defaultSelected=!0);return}f!==null||m[B].disabled||(f=m[B])}f!==null&&(f.selected=!0)}}function J(m,f){if(f.dangerouslySetInnerHTML!=null)throw Error(r(91));return ee({},f,{value:void 0,defaultValue:void 0,children:""+m._wrapperState.initialValue})}function ae(m,f){var N=f.value;if(N==null){if(N=f.children,f=f.defaultValue,N!=null){if(f!=null)throw Error(r(92));if(Ae(N)){if(1<N.length)throw Error(r(93));N=N[0]}f=N}f==null&&(f=""),N=f}m._wrapperState={initialValue:ue(N)}}function we(m,f){var N=ue(f.value),E=ue(f.defaultValue);N!=null&&(N=""+N,N!==m.value&&(m.value=N),f.defaultValue==null&&m.defaultValue!==N&&(m.defaultValue=N)),E!=null&&(m.defaultValue=""+E)}function Qe(m){var f=m.textContent;f===m._wrapperState.initialValue&&f!==""&&f!==null&&(m.value=f)}function ye(m){switch(m){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 te(m,f){return m==null||m==="http://www.w3.org/1999/xhtml"?ye(f):m==="http://www.w3.org/2000/svg"&&f==="foreignObject"?"http://www.w3.org/1999/xhtml":m}var Ue,We=(function(m){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(f,N,E,B){MSApp.execUnsafeLocalFunction(function(){return m(f,N,E,B)})}:m})(function(m,f){if(m.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in m)m.innerHTML=f;else{for(Ue=Ue||document.createElement("div"),Ue.innerHTML="<svg>"+f.valueOf().toString()+"</svg>",f=Ue.firstChild;m.firstChild;)m.removeChild(m.firstChild);for(;f.firstChild;)m.appendChild(f.firstChild)}});function St(m,f){if(f){var N=m.firstChild;if(N&&N===m.lastChild&&N.nodeType===3){N.nodeValue=f;return}}m.textContent=f}var It={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},ns=["Webkit","ms","Moz","O"];Object.keys(It).forEach(function(m){ns.forEach(function(f){f=f+m.charAt(0).toUpperCase()+m.substring(1),It[f]=It[m]})});function dt(m,f,N){return f==null||typeof f=="boolean"||f===""?"":N||typeof f!="number"||f===0||It.hasOwnProperty(m)&&It[m]?(""+f).trim():f+"px"}function Qt(m,f){m=m.style;for(var N in f)if(f.hasOwnProperty(N)){var E=N.indexOf("--")===0,B=dt(N,f[N],E);N==="float"&&(N="cssFloat"),E?m.setProperty(N,B):m[N]=B}}var Re=ee({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 pt(m,f){if(f){if(Re[m]&&(f.children!=null||f.dangerouslySetInnerHTML!=null))throw Error(r(137,m));if(f.dangerouslySetInnerHTML!=null){if(f.children!=null)throw Error(r(60));if(typeof f.dangerouslySetInnerHTML!="object"||!("__html"in f.dangerouslySetInnerHTML))throw Error(r(61))}if(f.style!=null&&typeof f.style!="object")throw Error(r(62))}}function Ft(m,f){if(m.indexOf("-")===-1)return typeof f.is=="string";switch(m){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 Es=null;function Ge(m){return m=m.target||m.srcElement||window,m.correspondingUseElement&&(m=m.correspondingUseElement),m.nodeType===3?m.parentNode:m}var ft=null,He=null,zt=null;function fs(m){if(m=Lc(m)){if(typeof ft!="function")throw Error(r(280));var f=m.stateNode;f&&(f=Ou(f),ft(m.stateNode,m.type,f))}}function Ce(m){He?zt?zt.push(m):zt=[m]:He=m}function Dt(){if(He){var m=He,f=zt;if(zt=He=null,fs(m),f)for(m=0;m<f.length;m++)fs(f[m])}}function ne(m,f){return m(f)}function Oe(){}var De=!1;function jt(m,f,N){if(De)return m(f,N);De=!0;try{return ne(m,f,N)}finally{De=!1,(He!==null||zt!==null)&&(Oe(),Dt())}}function Ct(m,f){var N=m.stateNode;if(N===null)return null;var E=Ou(N);if(E===null)return null;N=E[f];e:switch(f){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(E=!E.disabled)||(m=m.type,E=!(m==="button"||m==="input"||m==="select"||m==="textarea")),m=!E;break e;default:m=!1}if(m)return null;if(N&&typeof N!="function")throw Error(r(231,f,typeof N));return N}var Lt=!1;if(l)try{var xr={};Object.defineProperty(xr,"passive",{get:function(){Lt=!0}}),window.addEventListener("test",xr,xr),window.removeEventListener("test",xr,xr)}catch{Lt=!1}function qe(m,f,N,E,B,W,de,Ie,Xe){var Pt=Array.prototype.slice.call(arguments,3);try{f.apply(N,Pt)}catch(as){this.onError(as)}}var Xt=!1,Ut=null,gt=!1,es=null,br={onError:function(m){Xt=!0,Ut=m}};function fr(m,f,N,E,B,W,de,Ie,Xe){Xt=!1,Ut=null,qe.apply(br,arguments)}function xn(m,f,N,E,B,W,de,Ie,Xe){if(fr.apply(this,arguments),Xt){if(Xt){var Pt=Ut;Xt=!1,Ut=null}else throw Error(r(198));gt||(gt=!0,es=Pt)}}function Br(m){var f=m,N=m;if(m.alternate)for(;f.return;)f=f.return;else{m=f;do f=m,(f.flags&4098)!==0&&(N=f.return),m=f.return;while(m)}return f.tag===3?N:null}function Pi(m){if(m.tag===13){var f=m.memoizedState;if(f===null&&(m=m.alternate,m!==null&&(f=m.memoizedState)),f!==null)return f.dehydrated}return null}function Qn(m){if(Br(m)!==m)throw Error(r(188))}function ii(m){var f=m.alternate;if(!f){if(f=Br(m),f===null)throw Error(r(188));return f!==m?null:m}for(var N=m,E=f;;){var B=N.return;if(B===null)break;var W=B.alternate;if(W===null){if(E=B.return,E!==null){N=E;continue}break}if(B.child===W.child){for(W=B.child;W;){if(W===N)return Qn(B),m;if(W===E)return Qn(B),f;W=W.sibling}throw Error(r(188))}if(N.return!==E.return)N=B,E=W;else{for(var de=!1,Ie=B.child;Ie;){if(Ie===N){de=!0,N=B,E=W;break}if(Ie===E){de=!0,E=B,N=W;break}Ie=Ie.sibling}if(!de){for(Ie=W.child;Ie;){if(Ie===N){de=!0,N=W,E=B;break}if(Ie===E){de=!0,E=W,N=B;break}Ie=Ie.sibling}if(!de)throw Error(r(189))}}if(N.alternate!==E)throw Error(r(190))}if(N.tag!==3)throw Error(r(188));return N.stateNode.current===N?m:f}function ua(m){return m=ii(m),m!==null?Ua(m):null}function Ua(m){if(m.tag===5||m.tag===6)return m;for(m=m.child;m!==null;){var f=Ua(m);if(f!==null)return f;m=m.sibling}return null}var Ln=s.unstable_scheduleCallback,Ir=s.unstable_cancelCallback,Hr=s.unstable_shouldYield,lt=s.unstable_requestPaint,Rt=s.unstable_now,At=s.unstable_getCurrentPriorityLevel,Ht=s.unstable_ImmediatePriority,vr=s.unstable_UserBlockingPriority,mn=s.unstable_NormalPriority,hr=s.unstable_LowPriority,Sn=s.unstable_IdlePriority,Sr=null,Os=null;function ur(m){if(Os&&typeof Os.onCommitFiberRoot=="function")try{Os.onCommitFiberRoot(Sr,m,void 0,(m.current.flags&128)===128)}catch{}}var nr=Math.clz32?Math.clz32:Xn,qr=Math.log,So=Math.LN2;function Xn(m){return m>>>=0,m===0?32:31-(qr(m)/So|0)|0}var Jr=64,vn=4194304;function Mn(m){switch(m&-m){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 m&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return m&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return m}}function Dr(m,f){var N=m.pendingLanes;if(N===0)return 0;var E=0,B=m.suspendedLanes,W=m.pingedLanes,de=N&268435455;if(de!==0){var Ie=de&~B;Ie!==0?E=Mn(Ie):(W&=de,W!==0&&(E=Mn(W)))}else de=N&~B,de!==0?E=Mn(de):W!==0&&(E=Mn(W));if(E===0)return 0;if(f!==0&&f!==E&&(f&B)===0&&(B=E&-E,W=f&-f,B>=W||B===16&&(W&4194240)!==0))return f;if((E&4)!==0&&(E|=N&16),f=m.entangledLanes,f!==0)for(m=m.entanglements,f&=E;0<f;)N=31-nr(f),B=1<<N,E|=m[N],f&=~B;return E}function en(m,f){switch(m){case 1:case 2:case 4:return f+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 f+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 Co(m,f){for(var N=m.suspendedLanes,E=m.pingedLanes,B=m.expirationTimes,W=m.pendingLanes;0<W;){var de=31-nr(W),Ie=1<<de,Xe=B[de];Xe===-1?((Ie&N)===0||(Ie&E)!==0)&&(B[de]=en(Ie,f)):Xe<=f&&(m.expiredLanes|=Ie),W&=~Ie}}function Oa(m){return m=m.pendingLanes&-1073741825,m!==0?m:m&1073741824?1073741824:0}function ku(){var m=Jr;return Jr<<=1,(Jr&4194240)===0&&(Jr=64),m}function ma(m){for(var f=[],N=0;31>N;N++)f.push(m);return f}function lo(m,f,N){m.pendingLanes|=f,f!==536870912&&(m.suspendedLanes=0,m.pingedLanes=0),m=m.eventTimes,f=31-nr(f),m[f]=N}function Cn(m,f){var N=m.pendingLanes&~f;m.pendingLanes=f,m.suspendedLanes=0,m.pingedLanes=0,m.expiredLanes&=f,m.mutableReadLanes&=f,m.entangledLanes&=f,f=m.entanglements;var E=m.eventTimes;for(m=m.expirationTimes;0<N;){var B=31-nr(N),W=1<<B;f[B]=0,E[B]=-1,m[B]=-1,N&=~W}}function Lr(m,f){var N=m.entangledLanes|=f;for(m=m.entanglements;N;){var E=31-nr(N),B=1<<E;B&f|m[E]&f&&(m[E]|=f),N&=~B}}var Vr=0;function Nc(m){return m&=-m,1<m?4<m?(m&268435455)!==0?16:536870912:4:1}var Ds,nl,co,fn,bi,Sc=!1,ra=[],za=null,Xl=null,Ei=null,na=new Map,Ur=new Map,Da=[],Xc="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 oi(m,f){switch(m){case"focusin":case"focusout":za=null;break;case"dragenter":case"dragleave":Xl=null;break;case"mouseover":case"mouseout":Ei=null;break;case"pointerover":case"pointerout":na.delete(f.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ur.delete(f.pointerId)}}function Zl(m,f,N,E,B,W){return m===null||m.nativeEvent!==W?(m={blockedOn:f,domEventName:N,eventSystemFlags:E,nativeEvent:W,targetContainers:[B]},f!==null&&(f=Lc(f),f!==null&&nl(f)),m):(m.eventSystemFlags|=E,f=m.targetContainers,B!==null&&f.indexOf(B)===-1&&f.push(B),m)}function al(m,f,N,E,B){switch(f){case"focusin":return za=Zl(za,m,f,N,E,B),!0;case"dragenter":return Xl=Zl(Xl,m,f,N,E,B),!0;case"mouseover":return Ei=Zl(Ei,m,f,N,E,B),!0;case"pointerover":var W=B.pointerId;return na.set(W,Zl(na.get(W)||null,m,f,N,E,B)),!0;case"gotpointercapture":return W=B.pointerId,Ur.set(W,Zl(Ur.get(W)||null,m,f,N,E,B)),!0}return!1}function Zc(m){var f=Dc(m.target);if(f!==null){var N=Br(f);if(N!==null){if(f=N.tag,f===13){if(f=Pi(N),f!==null){m.blockedOn=f,bi(m.priority,function(){co(N)});return}}else if(f===3&&N.stateNode.current.memoizedState.isDehydrated){m.blockedOn=N.tag===3?N.stateNode.containerInfo:null;return}}}m.blockedOn=null}function il(m){if(m.blockedOn!==null)return!1;for(var f=m.targetContainers;0<f.length;){var N=ol(m.domEventName,m.eventSystemFlags,f[0],m.nativeEvent);if(N===null){N=m.nativeEvent;var E=new N.constructor(N.type,N);Es=E,N.target.dispatchEvent(E),Es=null}else return f=Lc(N),f!==null&&nl(f),m.blockedOn=N,!1;f.shift()}return!0}function Jl(m,f,N){il(m)&&N.delete(f)}function Uo(){Sc=!1,za!==null&&il(za)&&(za=null),Xl!==null&&il(Xl)&&(Xl=null),Ei!==null&&il(Ei)&&(Ei=null),na.forEach(Jl),Ur.forEach(Jl)}function Cc(m,f){m.blockedOn===f&&(m.blockedOn=null,Sc||(Sc=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Uo)))}function Ti(m){function f(B){return Cc(B,m)}if(0<ra.length){Cc(ra[0],m);for(var N=1;N<ra.length;N++){var E=ra[N];E.blockedOn===m&&(E.blockedOn=null)}}for(za!==null&&Cc(za,m),Xl!==null&&Cc(Xl,m),Ei!==null&&Cc(Ei,m),na.forEach(f),Ur.forEach(f),N=0;N<Da.length;N++)E=Da[N],E.blockedOn===m&&(E.blockedOn=null);for(;0<Da.length&&(N=Da[0],N.blockedOn===null);)Zc(N),N.blockedOn===null&&Da.shift()}var oa=k.ReactCurrentBatchConfig,ja=!0;function Tr(m,f,N,E){var B=Vr,W=oa.transition;oa.transition=null;try{Vr=1,ha(m,f,N,E)}finally{Vr=B,oa.transition=W}}function zo(m,f,N,E){var B=Vr,W=oa.transition;oa.transition=null;try{Vr=4,ha(m,f,N,E)}finally{Vr=B,oa.transition=W}}function ha(m,f,N,E){if(ja){var B=ol(m,f,N,E);if(B===null)Ni(m,f,E,Jc,N),oi(m,E);else if(al(B,m,f,N,E))E.stopPropagation();else if(oi(m,E),f&4&&-1<Xc.indexOf(m)){for(;B!==null;){var W=Lc(B);if(W!==null&&Ds(W),W=ol(m,f,N,E),W===null&&Ni(m,f,E,Jc,N),W===B)break;B=W}B!==null&&E.stopPropagation()}else Ni(m,f,E,null,N)}}var Jc=null;function ol(m,f,N,E){if(Jc=null,m=Ge(E),m=Dc(m),m!==null)if(f=Br(m),f===null)m=null;else if(N=f.tag,N===13){if(m=Pi(f),m!==null)return m;m=null}else if(N===3){if(f.stateNode.current.memoizedState.isDehydrated)return f.tag===3?f.stateNode.containerInfo:null;m=null}else f!==m&&(m=null);return Jc=m,null}function zn(m){switch(m){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(At()){case Ht:return 1;case vr:return 4;case mn:case hr:return 16;case Sn:return 536870912;default:return 16}default:return 16}}var ll=null,yn=null,cl=null;function ko(){if(cl)return cl;var m,f=yn,N=f.length,E,B="value"in ll?ll.value:ll.textContent,W=B.length;for(m=0;m<N&&f[m]===B[m];m++);var de=N-m;for(E=1;E<=de&&f[N-E]===B[W-E];E++);return cl=B.slice(m,1<E?1-E:void 0)}function dl(m){var f=m.keyCode;return"charCode"in m?(m=m.charCode,m===0&&f===13&&(m=13)):m=f,m===10&&(m=13),32<=m||m===13?m:0}function Cl(){return!0}function Ho(){return!1}function Ha(m){function f(N,E,B,W,de){this._reactName=N,this._targetInst=B,this.type=E,this.nativeEvent=W,this.target=de,this.currentTarget=null;for(var Ie in m)m.hasOwnProperty(Ie)&&(N=m[Ie],this[Ie]=N?N(W):W[Ie]);return this.isDefaultPrevented=(W.defaultPrevented!=null?W.defaultPrevented:W.returnValue===!1)?Cl:Ho,this.isPropagationStopped=Ho,this}return ee(f.prototype,{preventDefault:function(){this.defaultPrevented=!0;var N=this.nativeEvent;N&&(N.preventDefault?N.preventDefault():typeof N.returnValue!="unknown"&&(N.returnValue=!1),this.isDefaultPrevented=Cl)},stopPropagation:function(){var N=this.nativeEvent;N&&(N.stopPropagation?N.stopPropagation():typeof N.cancelBubble!="unknown"&&(N.cancelBubble=!0),this.isPropagationStopped=Cl)},persist:function(){},isPersistent:Cl}),f}var Ai={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(m){return m.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bs=Ha(Ai),ti=ee({},Ai,{view:0,detail:0}),ec=Ha(ti),uo,Na,La,kc=ee({},ti,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Tc,button:0,buttons:0,relatedTarget:function(m){return m.relatedTarget===void 0?m.fromElement===m.srcElement?m.toElement:m.fromElement:m.relatedTarget},movementX:function(m){return"movementX"in m?m.movementX:(m!==La&&(La&&m.type==="mousemove"?(uo=m.screenX-La.screenX,Na=m.screenY-La.screenY):Na=uo=0,La=m),uo)},movementY:function(m){return"movementY"in m?m.movementY:Na}}),_c=Ha(kc),tn=ee({},kc,{dataTransfer:0}),qo=Ha(tn),Hn=ee({},ti,{relatedTarget:0}),mo=Ha(Hn),qn=ee({},Ai,{animationName:0,elapsedTime:0,pseudoElement:0}),_o=Ha(qn),tm=ee({},Ai,{clipboardData:function(m){return"clipboardData"in m?m.clipboardData:window.clipboardData}}),Pd=Ha(tm),wi=ee({},Ai,{data:0}),tc=Ha(wi),ul={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Pc={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"},_u={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ec(m){var f=this.nativeEvent;return f.getModifierState?f.getModifierState(m):(m=_u[m])?!!f[m]:!1}function Tc(){return Ec}var Ea=ee({},ti,{key:function(m){if(m.key){var f=ul[m.key]||m.key;if(f!=="Unidentified")return f}return m.type==="keypress"?(m=dl(m),m===13?"Enter":String.fromCharCode(m)):m.type==="keydown"||m.type==="keyup"?Pc[m.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Tc,charCode:function(m){return m.type==="keypress"?dl(m):0},keyCode:function(m){return m.type==="keydown"||m.type==="keyup"?m.keyCode:0},which:function(m){return m.type==="keypress"?dl(m):m.type==="keydown"||m.type==="keyup"?m.keyCode:0}}),Ac=Ha(Ea),Ed=ee({},kc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ed=Ha(Ed),Ah=ee({},ti,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Tc}),td=Ha(Ah),Vo=ee({},Ai,{propertyName:0,elapsedTime:0,pseudoElement:0}),nn=Ha(Vo),Um=ee({},kc,{deltaX:function(m){return"deltaX"in m?m.deltaX:"wheelDeltaX"in m?-m.wheelDeltaX:0},deltaY:function(m){return"deltaY"in m?m.deltaY:"wheelDeltaY"in m?-m.wheelDeltaY:"wheelDelta"in m?-m.wheelDelta:0},deltaZ:0,deltaMode:0}),Pu=Ha(Um),sd=[9,13,27,32],sc=l&&"CompositionEvent"in window,Wo=null;l&&"documentMode"in document&&(Wo=document.documentMode);var Mh=l&&"TextEvent"in window&&!Wo,Td=l&&(!sc||Wo&&8<Wo&&11>=Wo),qa=" ",Qs=!1;function rc(m,f){switch(m){case"keyup":return sd.indexOf(f.keyCode)!==-1;case"keydown":return f.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Eu(m){return m=m.detail,typeof m=="object"&&"data"in m?m.data:null}var Po=!1;function la(m,f){switch(m){case"compositionend":return Eu(f);case"keypress":return f.which!==32?null:(Qs=!0,qa);case"textInput":return m=f.data,m===qa&&Qs?null:m;default:return null}}function Rh(m,f){if(Po)return m==="compositionend"||!sc&&rc(m,f)?(m=ko(),cl=yn=ll=null,Po=!1,m):null;switch(m){case"paste":return null;case"keypress":if(!(f.ctrlKey||f.altKey||f.metaKey)||f.ctrlKey&&f.altKey){if(f.char&&1<f.char.length)return f.char;if(f.which)return String.fromCharCode(f.which)}return null;case"compositionend":return Td&&f.locale!=="ko"?null:f.data;default:return null}}var ml={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 rd(m){var f=m&&m.nodeName&&m.nodeName.toLowerCase();return f==="input"?!!ml[m.type]:f==="textarea"}function Mc(m,f,N,E){Ce(E),f=Ko(f,"onChange"),0<f.length&&(N=new Bs("onChange","change",null,N,E),m.push({event:N,listeners:f}))}var Mi=null,nc=null;function kl(m){tu(m,0)}function Ri(m){var f=Iu(m);if(me(f))return m}function ho(m,f){if(m==="change")return f}var ac=!1;if(l){var tr;if(l){var _l="oninput"in document;if(!_l){var nd=document.createElement("div");nd.setAttribute("oninput","return;"),_l=typeof nd.oninput=="function"}tr=_l}else tr=!1;ac=tr&&(!document.documentMode||9<document.documentMode)}function hl(){Mi&&(Mi.detachEvent("onpropertychange",Rc),nc=Mi=null)}function Rc(m){if(m.propertyName==="value"&&Ri(nc)){var f=[];Mc(f,nc,m,Ge(m)),jt(kl,f)}}function sm(m,f,N){m==="focusin"?(hl(),Mi=f,nc=N,Mi.attachEvent("onpropertychange",Rc)):m==="focusout"&&hl()}function Eo(m){if(m==="selectionchange"||m==="keyup"||m==="keydown")return Ri(nc)}function pl(m,f){if(m==="click")return Ri(f)}function U(m,f){if(m==="input"||m==="change")return Ri(f)}function _e(m,f){return m===f&&(m!==0||1/m===1/f)||m!==m&&f!==f}var qt=typeof Object.is=="function"?Object.is:_e;function Zt(m,f){if(qt(m,f))return!0;if(typeof m!="object"||m===null||typeof f!="object"||f===null)return!1;var N=Object.keys(m),E=Object.keys(f);if(N.length!==E.length)return!1;for(E=0;E<N.length;E++){var B=N[E];if(!c.call(f,B)||!qt(m[B],f[B]))return!1}return!0}function Rs(m){for(;m&&m.firstChild;)m=m.firstChild;return m}function ir(m,f){var N=Rs(m);m=0;for(var E;N;){if(N.nodeType===3){if(E=m+N.textContent.length,m<=f&&E>=f)return{node:N,offset:f-m};m=E}e:{for(;N;){if(N.nextSibling){N=N.nextSibling;break e}N=N.parentNode}N=void 0}N=Rs(N)}}function Vn(m,f){return m&&f?m===f?!0:m&&m.nodeType===3?!1:f&&f.nodeType===3?Vn(m,f.parentNode):"contains"in m?m.contains(f):m.compareDocumentPosition?!!(m.compareDocumentPosition(f)&16):!1:!1}function Ns(){for(var m=window,f=ge();f instanceof m.HTMLIFrameElement;){try{var N=typeof f.contentWindow.location.href=="string"}catch{N=!1}if(N)m=f.contentWindow;else break;f=ge(m.document)}return f}function or(m){var f=m&&m.nodeName&&m.nodeName.toLowerCase();return f&&(f==="input"&&(m.type==="text"||m.type==="search"||m.type==="tel"||m.type==="url"||m.type==="password")||f==="textarea"||m.contentEditable==="true")}function os(m){var f=Ns(),N=m.focusedElem,E=m.selectionRange;if(f!==N&&N&&N.ownerDocument&&Vn(N.ownerDocument.documentElement,N)){if(E!==null&&or(N)){if(f=E.start,m=E.end,m===void 0&&(m=f),"selectionStart"in N)N.selectionStart=f,N.selectionEnd=Math.min(m,N.value.length);else if(m=(f=N.ownerDocument||document)&&f.defaultView||window,m.getSelection){m=m.getSelection();var B=N.textContent.length,W=Math.min(E.start,B);E=E.end===void 0?W:Math.min(E.end,B),!m.extend&&W>E&&(B=E,E=W,W=B),B=ir(N,W);var de=ir(N,E);B&&de&&(m.rangeCount!==1||m.anchorNode!==B.node||m.anchorOffset!==B.offset||m.focusNode!==de.node||m.focusOffset!==de.offset)&&(f=f.createRange(),f.setStart(B.node,B.offset),m.removeAllRanges(),W>E?(m.addRange(f),m.extend(de.node,de.offset)):(f.setEnd(de.node,de.offset),m.addRange(f)))}}for(f=[],m=N;m=m.parentNode;)m.nodeType===1&&f.push({element:m,left:m.scrollLeft,top:m.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<f.length;N++)m=f[N],m.element.scrollLeft=m.left,m.element.scrollTop=m.top}}var nt=l&&"documentMode"in document&&11>=document.documentMode,tt=null,$t=null,kr=null,Wn=!1;function zr(m,f,N){var E=N.window===N?N.document:N.nodeType===9?N:N.ownerDocument;Wn||tt==null||tt!==ge(E)||(E=tt,"selectionStart"in E&&or(E)?E={start:E.selectionStart,end:E.selectionEnd}:(E=(E.ownerDocument&&E.ownerDocument.defaultView||window).getSelection(),E={anchorNode:E.anchorNode,anchorOffset:E.anchorOffset,focusNode:E.focusNode,focusOffset:E.focusOffset}),kr&&Zt(kr,E)||(kr=E,E=Ko($t,"onSelect"),0<E.length&&(f=new Bs("onSelect","select",null,f,N),m.push({event:f,listeners:E}),f.target=tt)))}function $n(m,f){var N={};return N[m.toLowerCase()]=f.toLowerCase(),N["Webkit"+m]="webkit"+f,N["Moz"+m]="moz"+f,N}var Va={animationend:$n("Animation","AnimationEnd"),animationiteration:$n("Animation","AnimationIteration"),animationstart:$n("Animation","AnimationStart"),transitionend:$n("Transition","TransitionEnd")},Yi={},Ii={};l&&(Ii=document.createElement("div").style,"AnimationEvent"in window||(delete Va.animationend.animation,delete Va.animationiteration.animation,delete Va.animationstart.animation),"TransitionEvent"in window||delete Va.transitionend.transition);function To(m){if(Yi[m])return Yi[m];if(!Va[m])return m;var f=Va[m],N;for(N in f)if(f.hasOwnProperty(N)&&N in Ii)return Yi[m]=f[N];return m}var Qi=To("animationend"),Ls=To("animationiteration"),Or=To("animationstart"),Pl=To("transitionend"),Oi=new Map,ad="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 ji(m,f){Oi.set(m,f),i(f,[m])}for(var Wa=0;Wa<ad.length;Wa++){var Ic=ad[Wa],Tu=Ic.toLowerCase(),id=Ic[0].toUpperCase()+Ic.slice(1);ji(Tu,"on"+id)}ji(Qi,"onAnimationEnd"),ji(Ls,"onAnimationIteration"),ji(Or,"onAnimationStart"),ji("dblclick","onDoubleClick"),ji("focusin","onFocus"),ji("focusout","onBlur"),ji(Pl,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var El="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(" "),Di=new Set("cancel close invalid load scroll toggle".split(" ").concat(El));function Xi(m,f,N){var E=m.type||"unknown-event";m.currentTarget=N,xn(E,f,void 0,m),m.currentTarget=null}function tu(m,f){f=(f&4)!==0;for(var N=0;N<m.length;N++){var E=m[N],B=E.event;E=E.listeners;e:{var W=void 0;if(f)for(var de=E.length-1;0<=de;de--){var Ie=E[de],Xe=Ie.instance,Pt=Ie.currentTarget;if(Ie=Ie.listener,Xe!==W&&B.isPropagationStopped())break e;Xi(B,Ie,Pt),W=Xe}else for(de=0;de<E.length;de++){if(Ie=E[de],Xe=Ie.instance,Pt=Ie.currentTarget,Ie=Ie.listener,Xe!==W&&B.isPropagationStopped())break e;Xi(B,Ie,Pt),W=Xe}}}if(gt)throw m=es,gt=!1,es=null,m}function bn(m,f){var N=f[Ol];N===void 0&&(N=f[Ol]=new Set);var E=m+"__bubble";N.has(E)||(Al(f,m,2,!1),N.add(E))}function Tl(m,f,N){var E=0;f&&(E|=4),Al(N,m,E,f)}var od="_reactListening"+Math.random().toString(36).slice(2);function ld(m){if(!m[od]){m[od]=!0,n.forEach(function(N){N!=="selectionchange"&&(Di.has(N)||Tl(N,!1,m),Tl(N,!0,m))});var f=m.nodeType===9?m:m.ownerDocument;f===null||f[od]||(f[od]=!0,Tl("selectionchange",!1,f))}}function Al(m,f,N,E){switch(zn(f)){case 1:var B=Tr;break;case 4:B=zo;break;default:B=ha}N=B.bind(null,f,N,m),B=void 0,!Lt||f!=="touchstart"&&f!=="touchmove"&&f!=="wheel"||(B=!0),E?B!==void 0?m.addEventListener(f,N,{capture:!0,passive:B}):m.addEventListener(f,N,!0):B!==void 0?m.addEventListener(f,N,{passive:B}):m.addEventListener(f,N,!1)}function Ni(m,f,N,E,B){var W=E;if((f&1)===0&&(f&2)===0&&E!==null)e:for(;;){if(E===null)return;var de=E.tag;if(de===3||de===4){var Ie=E.stateNode.containerInfo;if(Ie===B||Ie.nodeType===8&&Ie.parentNode===B)break;if(de===4)for(de=E.return;de!==null;){var Xe=de.tag;if((Xe===3||Xe===4)&&(Xe=de.stateNode.containerInfo,Xe===B||Xe.nodeType===8&&Xe.parentNode===B))return;de=de.return}for(;Ie!==null;){if(de=Dc(Ie),de===null)return;if(Xe=de.tag,Xe===5||Xe===6){E=W=de;continue e}Ie=Ie.parentNode}}E=E.return}jt(function(){var Pt=W,as=Ge(N),cs=[];e:{var ss=Oi.get(m);if(ss!==void 0){var er=Bs,pr=m;switch(m){case"keypress":if(dl(N)===0)break e;case"keydown":case"keyup":er=Ac;break;case"focusin":pr="focus",er=mo;break;case"focusout":pr="blur",er=mo;break;case"beforeblur":case"afterblur":er=mo;break;case"click":if(N.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":er=_c;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":er=qo;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":er=td;break;case Qi:case Ls:case Or:er=_o;break;case Pl:er=nn;break;case"scroll":er=ec;break;case"wheel":er=Pu;break;case"copy":case"cut":case"paste":er=Pd;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":er=ed}var yr=(f&4)!==0,Qo=!yr&&m==="scroll",xt=yr?ss!==null?ss+"Capture":null:ss;yr=[];for(var at=Pt,wt;at!==null;){wt=at;var ws=wt.stateNode;if(wt.tag===5&&ws!==null&&(wt=ws,xt!==null&&(ws=Ct(at,xt),ws!=null&&yr.push(rm(at,ws,wt)))),Qo)break;at=at.return}0<yr.length&&(ss=new er(ss,pr,null,N,as),cs.push({event:ss,listeners:yr}))}}if((f&7)===0){e:{if(ss=m==="mouseover"||m==="pointerover",er=m==="mouseout"||m==="pointerout",ss&&N!==Es&&(pr=N.relatedTarget||N.fromElement)&&(Dc(pr)||pr[fl]))break e;if((er||ss)&&(ss=as.window===as?as:(ss=as.ownerDocument)?ss.defaultView||ss.parentWindow:window,er?(pr=N.relatedTarget||N.toElement,er=Pt,pr=pr?Dc(pr):null,pr!==null&&(Qo=Br(pr),pr!==Qo||pr.tag!==5&&pr.tag!==6)&&(pr=null)):(er=null,pr=Pt),er!==pr)){if(yr=_c,ws="onMouseLeave",xt="onMouseEnter",at="mouse",(m==="pointerout"||m==="pointerover")&&(yr=ed,ws="onPointerLeave",xt="onPointerEnter",at="pointer"),Qo=er==null?ss:Iu(er),wt=pr==null?ss:Iu(pr),ss=new yr(ws,at+"leave",er,N,as),ss.target=Qo,ss.relatedTarget=wt,ws=null,Dc(as)===Pt&&(yr=new yr(xt,at+"enter",pr,N,as),yr.target=wt,yr.relatedTarget=Qo,ws=yr),Qo=ws,er&&pr)t:{for(yr=er,xt=pr,at=0,wt=yr;wt;wt=Ad(wt))at++;for(wt=0,ws=xt;ws;ws=Ad(ws))wt++;for(;0<at-wt;)yr=Ad(yr),at--;for(;0<wt-at;)xt=Ad(xt),wt--;for(;at--;){if(yr===xt||xt!==null&&yr===xt.alternate)break t;yr=Ad(yr),xt=Ad(xt)}yr=null}else yr=null;er!==null&&Ml(cs,ss,er,yr,!1),pr!==null&&Qo!==null&&Ml(cs,Qo,pr,yr,!0)}}e:{if(ss=Pt?Iu(Pt):window,er=ss.nodeName&&ss.nodeName.toLowerCase(),er==="select"||er==="input"&&ss.type==="file")var jr=ho;else if(rd(ss))if(ac)jr=U;else{jr=Eo;var $r=sm}else(er=ss.nodeName)&&er.toLowerCase()==="input"&&(ss.type==="checkbox"||ss.type==="radio")&&(jr=pl);if(jr&&(jr=jr(m,Pt))){Mc(cs,jr,N,as);break e}$r&&$r(m,ss,Pt),m==="focusout"&&($r=ss._wrapperState)&&$r.controlled&&ss.type==="number"&&bt(ss,"number",ss.value)}switch($r=Pt?Iu(Pt):window,m){case"focusin":(rd($r)||$r.contentEditable==="true")&&(tt=$r,$t=Pt,kr=null);break;case"focusout":kr=$t=tt=null;break;case"mousedown":Wn=!0;break;case"contextmenu":case"mouseup":case"dragend":Wn=!1,zr(cs,N,as);break;case"selectionchange":if(nt)break;case"keydown":case"keyup":zr(cs,N,as)}var Fr;if(sc)e:{switch(m){case"compositionstart":var on="onCompositionStart";break e;case"compositionend":on="onCompositionEnd";break e;case"compositionupdate":on="onCompositionUpdate";break e}on=void 0}else Po?rc(m,N)&&(on="onCompositionEnd"):m==="keydown"&&N.keyCode===229&&(on="onCompositionStart");on&&(Td&&N.locale!=="ko"&&(Po||on!=="onCompositionStart"?on==="onCompositionEnd"&&Po&&(Fr=ko()):(ll=as,yn="value"in ll?ll.value:ll.textContent,Po=!0)),$r=Ko(Pt,on),0<$r.length&&(on=new tc(on,m,null,N,as),cs.push({event:on,listeners:$r}),Fr?on.data=Fr:(Fr=Eu(N),Fr!==null&&(on.data=Fr)))),(Fr=Mh?la(m,N):Rh(m,N))&&(Pt=Ko(Pt,"onBeforeInput"),0<Pt.length&&(as=new tc("onBeforeInput","beforeinput",null,N,as),cs.push({event:as,listeners:Pt}),as.data=Fr))}tu(cs,f)})}function rm(m,f,N){return{instance:m,listener:f,currentTarget:N}}function Ko(m,f){for(var N=f+"Capture",E=[];m!==null;){var B=m,W=B.stateNode;B.tag===5&&W!==null&&(B=W,W=Ct(m,N),W!=null&&E.unshift(rm(m,W,B)),W=Ct(m,f),W!=null&&E.push(rm(m,W,B))),m=m.return}return E}function Ad(m){if(m===null)return null;do m=m.return;while(m&&m.tag!==5);return m||null}function Ml(m,f,N,E,B){for(var W=f._reactName,de=[];N!==null&&N!==E;){var Ie=N,Xe=Ie.alternate,Pt=Ie.stateNode;if(Xe!==null&&Xe===E)break;Ie.tag===5&&Pt!==null&&(Ie=Pt,B?(Xe=Ct(N,W),Xe!=null&&de.unshift(rm(N,Xe,Ie))):B||(Xe=Ct(N,W),Xe!=null&&de.push(rm(N,Xe,Ie)))),N=N.return}de.length!==0&&m.push({event:f,listeners:de})}var qg=/\r\n?/g,zm=/\u0000|\uFFFD/g;function Au(m){return(typeof m=="string"?m:""+m).replace(qg,`
6`).replace(zm,"")}function Ih(m,f,N){if(f=Au(f),Au(m)!==f&&N)throw Error(r(425))}function cd(){}var Oh=null,Zi=null;function Hm(m,f){return m==="textarea"||m==="noscript"||typeof f.children=="string"||typeof f.children=="number"||typeof f.dangerouslySetInnerHTML=="object"&&f.dangerouslySetInnerHTML!==null&&f.dangerouslySetInnerHTML.__html!=null}var Mu=typeof setTimeout=="function"?setTimeout:void 0,Oc=typeof clearTimeout=="function"?clearTimeout:void 0,nm=typeof Promise=="function"?Promise:void 0,yp=typeof queueMicrotask=="function"?queueMicrotask:typeof nm<"u"?function(m){return nm.resolve(null).then(m).catch(Ru)}:Mu;function Ru(m){setTimeout(function(){throw m})}function su(m,f){var N=f,E=0;do{var B=N.nextSibling;if(m.removeChild(N),B&&B.nodeType===8)if(N=B.data,N==="/$"){if(E===0){m.removeChild(B),Ti(f);return}E--}else N!=="$"&&N!=="$?"&&N!=="$!"||E++;N=B}while(N);Ti(f)}function po(m){for(;m!=null;m=m.nextSibling){var f=m.nodeType;if(f===1||f===3)break;if(f===8){if(f=m.data,f==="$"||f==="$!"||f==="$?")break;if(f==="/$")return null}}return m}function Dh(m){m=m.previousSibling;for(var f=0;m;){if(m.nodeType===8){var N=m.data;if(N==="$"||N==="$!"||N==="$?"){if(f===0)return m;f--}else N==="/$"&&f++}m=m.previousSibling}return null}var Rl=Math.random().toString(36).slice(2),Il="__reactFiber$"+Rl,Go="__reactProps$"+Rl,fl="__reactContainer$"+Rl,Ol="__reactEvents$"+Rl,Af="__reactListeners$"+Rl,gl="__reactHandles$"+Rl;function Dc(m){var f=m[Il];if(f)return f;for(var N=m.parentNode;N;){if(f=N[fl]||N[Il]){if(N=f.alternate,f.child!==null||N!==null&&N.child!==null)for(m=Dh(m);m!==null;){if(N=m[Il])return N;m=Dh(m)}return f}m=N,N=m.parentNode}return null}function Lc(m){return m=m[Il]||m[fl],!m||m.tag!==5&&m.tag!==6&&m.tag!==13&&m.tag!==3?null:m}function Iu(m){if(m.tag===5||m.tag===6)return m.stateNode;throw Error(r(33))}function Ou(m){return m[Go]||null}var Ta=[],$c=-1;function fo(m){return{current:m}}function Zn(m){0>$c||(m.current=Ta[$c],Ta[$c]=null,$c--)}function hn(m,f){$c++,Ta[$c]=m.current,m.current=f}var Ao={},Sa=fo(Ao),Aa=fo(!1),dd=Ao;function Dl(m,f){var N=m.type.contextTypes;if(!N)return Ao;var E=m.stateNode;if(E&&E.__reactInternalMemoizedUnmaskedChildContext===f)return E.__reactInternalMemoizedMaskedChildContext;var B={},W;for(W in N)B[W]=f[W];return E&&(m=m.stateNode,m.__reactInternalMemoizedUnmaskedChildContext=f,m.__reactInternalMemoizedMaskedChildContext=B),B}function li(m){return m=m.childContextTypes,m!=null}function Fc(){Zn(Aa),Zn(Sa)}function F(m,f,N){if(Sa.current!==Ao)throw Error(r(168));hn(Sa,f),hn(Aa,N)}function ve(m,f,N){var E=m.stateNode;if(f=f.childContextTypes,typeof E.getChildContext!="function")return N;E=E.getChildContext();for(var B in E)if(!(B in f))throw Error(r(108,le(m)||"Unknown",B));return ee({},N,E)}function Te(m){return m=(m=m.stateNode)&&m.__reactInternalMemoizedMergedChildContext||Ao,dd=Sa.current,hn(Sa,m),hn(Aa,Aa.current),!0}function ht(m,f,N){var E=m.stateNode;if(!E)throw Error(r(169));N?(m=ve(m,f,dd),E.__reactInternalMemoizedMergedChildContext=m,Zn(Aa),Zn(Sa),hn(Sa,m)):Zn(Aa),hn(Aa,N)}var kt=null,us=!1,ts=!1;function is(m){kt===null?kt=[m]:kt.push(m)}function js(m){us=!0,is(m)}function ms(){if(!ts&&kt!==null){ts=!0;var m=0,f=Vr;try{var N=kt;for(Vr=1;m<N.length;m++){var E=N[m];do E=E(!0);while(E!==null)}kt=null,us=!1}catch(B){throw kt!==null&&(kt=kt.slice(m+1)),Ln(Ht,ms),B}finally{Vr=f,ts=!1}}return null}var gs=[],Ar=0,si=null,Ka=0,Wr=[],dn=0,Yo=null,Ji=1,pi="";function Pr(m,f){gs[Ar++]=Ka,gs[Ar++]=si,si=m,Ka=f}function am(m,f,N){Wr[dn++]=Ji,Wr[dn++]=pi,Wr[dn++]=Yo,Yo=m;var E=Ji;m=pi;var B=32-nr(E)-1;
vendor: 5,188 bytes, line 6
6E&=~(1<<B),N+=1;var W=32-nr(f)+B;if(30<W){var de=B-B%5;W=(E&(1<<de)-1).toString(32),E>>=de,B-=de,Ji=1<<32-nr(f)+B|N<<B|E,pi=W+m}else Ji=1<<W|N<<B|E,pi=m}function Md(m){m.return!==null&&(Pr(m,1),am(m,1,0))}function wn(m){for(;m===si;)si=gs[--Ar],gs[Ar]=null,Ka=gs[--Ar],gs[Ar]=null;for(;m===Yo;)Yo=Wr[--dn],Wr[dn]=null,pi=Wr[--dn],Wr[dn]=null,Ji=Wr[--dn],Wr[dn]=null}var Li=null,fi=null,aa=!1,eo=null;function Bc(m,f){var N=mm(5,null,null,0);N.elementType="DELETED",N.stateNode=f,N.return=m,f=m.deletions,f===null?(m.deletions=[N],m.flags|=16):f.push(N)}function Vg(m,f){switch(m.tag){case 5:var N=m.type;return f=f.nodeType!==1||N.toLowerCase()!==f.nodeName.toLowerCase()?null:f,f!==null?(m.stateNode=f,Li=m,fi=po(f.firstChild),!0):!1;case 6:return f=m.pendingProps===""||f.nodeType!==3?null:f,f!==null?(m.stateNode=f,Li=m,fi=null,!0):!1;case 13:return f=f.nodeType!==8?null:f,f!==null?(N=Yo!==null?{id:Ji,overflow:pi}:null,m.memoizedState={dehydrated:f,treeContext:N,retryLane:1073741824},N=mm(18,null,null,0),N.stateNode=f,N.return=m,m.child=N,Li=m,fi=null,!0):!1;default:return!1}}function Lh(m){return(m.mode&1)!==0&&(m.flags&128)===0}function ru(m){if(aa){var f=fi;if(f){var N=f;if(!Vg(m,f)){if(Lh(m))throw Error(r(418));f=po(N.nextSibling);var E=Li;f&&Vg(m,f)?Bc(E,N):(m.flags=m.flags&-4097|2,aa=!1,Li=m)}}else{if(Lh(m))throw Error(r(418));m.flags=m.flags&-4097|2,aa=!1,Li=m}}}function Wg(m){for(m=m.return;m!==null&&m.tag!==5&&m.tag!==3&&m.tag!==13;)m=m.return;Li=m}function Uc(m){if(m!==Li)return!1;if(!aa)return Wg(m),aa=!0,!1;var f;if((f=m.tag!==3)&&!(f=m.tag!==5)&&(f=m.type,f=f!=="head"&&f!=="body"&&!Hm(m.type,m.memoizedProps)),f&&(f=fi)){if(Lh(m))throw yv(),Error(r(418));for(;f;)Bc(m,f),f=po(f.nextSibling)}if(Wg(m),m.tag===13){if(m=m.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));e:{for(m=m.nextSibling,f=0;m;){if(m.nodeType===8){var N=m.data;if(N==="/$"){if(f===0){fi=po(m.nextSibling);break e}f--}else N!=="$"&&N!=="$!"&&N!=="$?"||f++}m=m.nextSibling}fi=null}}else fi=Li?po(m.stateNode.nextSibling):null;return!0}function yv(){for(var m=fi;m;)m=po(m.nextSibling)}function qm(){fi=Li=null,aa=!1}function Mf(m){eo===null?eo=[m]:eo.push(m)}var Kg=k.ReactCurrentBatchConfig;function im(m,f,N){if(m=N.ref,m!==null&&typeof m!="function"&&typeof m!="object"){if(N._owner){if(N=N._owner,N){if(N.tag!==1)throw Error(r(309));var E=N.stateNode}if(!E)throw Error(r(147,m));var B=E,W=""+m;return f!==null&&f.ref!==null&&typeof f.ref=="function"&&f.ref._stringRef===W?f.ref:(f=function(de){var Ie=B.refs;de===null?delete Ie[W]:Ie[W]=de},f._stringRef=W,f)}if(typeof m!="string")throw Error(r(284));if(!N._owner)throw Error(r(290,m))}return m}function bp(m,f){throw m=Object.prototype.toString.call(f),Error(r(31,m==="[object Object]"?"object with keys {"+Object.keys(f).join(", ")+"}":m))}function Gg(m){var f=m._init;return f(m._payload)}function Rf(m){function f(xt,at){if(m){var wt=xt.deletions;wt===null?(xt.deletions=[at],xt.flags|=16):wt.push(at)}}function N(xt,at){if(!m)return null;for(;at!==null;)f(xt,at),at=at.sibling;return null}function E(xt,at){for(xt=new Map;at!==null;)at.key!==null?xt.set(at.key,at):xt.set(at.index,at),at=at.sibling;return xt}function B(xt,at){return xt=Wf(xt,at),xt.index=0,xt.sibling=null,xt}function W(xt,at,wt){return xt.index=wt,m?(wt=xt.alternate,wt!==null?(wt=wt.index,wt<at?(xt.flags|=2,at):wt):(xt.flags|=2,at)):(xt.flags|=1048576,at)}function de(xt){return m&&xt.alternate===null&&(xt.flags|=2),xt}function Ie(xt,at,wt,ws){return at===null||at.tag!==6?(at=D2(wt,xt.mode,ws),at.return=xt,at):(at=B(at,wt),at.return=xt,at)}function Xe(xt,at,wt,ws){var jr=wt.type;return jr===A?as(xt,at,wt.props.children,ws,wt.key):at!==null&&(at.elementType===jr||typeof jr=="object"&&jr!==null&&jr.$$typeof===K&&Gg(jr)===at.type)?(ws=B(at,wt.props),ws.ref=im(xt,at,wt),ws.return=xt,ws):(ws=HN(wt.type,wt.key,wt.props,null,xt.mode,ws),ws.ref=im(xt,at,wt),ws.return=xt,ws)}function Pt(xt,at,wt,ws){return at===null||at.tag!==4||at.stateNode.containerInfo!==wt.containerInfo||at.stateNode.implementation!==wt.implementation?(at=L2(wt,xt.mode,ws),at.return=xt,at):(at=B(at,wt.children||[]),at.return=xt,at)}function as(xt,at,wt,ws,jr){return at===null||at.tag!==7?(at=lx(wt,xt.mode,ws,jr),at.return=xt,at):(at=B(at,wt),at.return=xt,at)}function cs(xt,at,wt){if(typeof at=="string"&&at!==""||typeof at=="number")return at=D2(""+at,xt.mode,wt),at.return=xt,at;if(typeof at=="object"&&at!==null){switch(at.$$typeof){case S:return wt=HN(at.type,at.key,at.props,null,xt.mode,wt),wt.ref=im(xt,null,at),wt.return=xt,wt;case _:return at=L2(at,xt.mode,wt),at.return=xt,at;case K:var ws=at._init;return cs(xt,ws(at._payload),wt)}if(Ae(at)||Z(at))return at=lx(at,xt.mode,wt,null),at.return=xt,at;bp(xt,at)}return null}function ss(xt,at,wt,ws){var jr=at!==null?at.key:null;if(typeof wt=="string"&&wt!==""||typeof wt=="number")return jr!==null?null:Ie(xt,at,""+wt,ws);if(typeof wt=="object"&&wt!==null){switch(wt.$$typeof){case S:return wt.key===jr?Xe(xt,at,wt,ws):null;case _:return wt.key===jr?Pt(xt,at,wt,ws):null;case K:return jr=wt._init,ss(xt,at,jr(wt._payload),ws)}if(Ae(wt)||Z(wt))return jr!==null?null:as(xt,at,wt,ws,null);bp(xt,wt)}return null}
vendor: 23,238 bytes, lines 6-8
6function er(xt,at,wt,ws,jr){if(typeof ws=="string"&&ws!==""||typeof ws=="number")return xt=xt.get(wt)||null,Ie(at,xt,""+ws,jr);if(typeof ws=="object"&&ws!==null){switch(ws.$$typeof){case S:return xt=xt.get(ws.key===null?wt:ws.key)||null,Xe(at,xt,ws,jr);case _:return xt=xt.get(ws.key===null?wt:ws.key)||null,Pt(at,xt,ws,jr);case K:var $r=ws._init;return er(xt,at,wt,$r(ws._payload),jr)}if(Ae(ws)||Z(ws))return xt=xt.get(wt)||null,as(at,xt,ws,jr,null);bp(at,ws)}return null}function pr(xt,at,wt,ws){for(var jr=null,$r=null,Fr=at,on=at=0,cc=null;Fr!==null&&on<wt.length;on++){Fr.index>on?(cc=Fr,Fr=null):cc=Fr.sibling;var Ma=ss(xt,Fr,wt[on],ws);if(Ma===null){Fr===null&&(Fr=cc);break}m&&Fr&&Ma.alternate===null&&f(xt,Fr),at=W(Ma,at,on),$r===null?jr=Ma:$r.sibling=Ma,$r=Ma,Fr=cc}if(on===wt.length)return N(xt,Fr),aa&&Pr(xt,on),jr;if(Fr===null){for(;on<wt.length;on++)Fr=cs(xt,wt[on],ws),Fr!==null&&(at=W(Fr,at,on),$r===null?jr=Fr:$r.sibling=Fr,$r=Fr);return aa&&Pr(xt,on),jr}for(Fr=E(xt,Fr);on<wt.length;on++)cc=er(Fr,xt,on,wt[on],ws),cc!==null&&(m&&cc.alternate!==null&&Fr.delete(cc.key===null?on:cc.key),at=W(cc,at,on),$r===null?jr=cc:$r.sibling=cc,$r=cc);return m&&Fr.forEach(function(Kf){return f(xt,Kf)}),aa&&Pr(xt,on),jr}function yr(xt,at,wt,ws){var jr=Z(wt);if(typeof jr!="function")throw Error(r(150));if(wt=jr.call(wt),wt==null)throw Error(r(151));for(var $r=jr=null,Fr=at,on=at=0,cc=null,Ma=wt.next();Fr!==null&&!Ma.done;on++,Ma=wt.next()){Fr.index>on?(cc=Fr,Fr=null):cc=Fr.sibling;var Kf=ss(xt,Fr,Ma.value,ws);if(Kf===null){Fr===null&&(Fr=cc);break}m&&Fr&&Kf.alternate===null&&f(xt,Fr),at=W(Kf,at,on),$r===null?jr=Kf:$r.sibling=Kf,$r=Kf,Fr=cc}if(Ma.done)return N(xt,Fr),aa&&Pr(xt,on),jr;if(Fr===null){for(;!Ma.done;on++,Ma=wt.next())Ma=cs(xt,Ma.value,ws),Ma!==null&&(at=W(Ma,at,on),$r===null?jr=Ma:$r.sibling=Ma,$r=Ma);return aa&&Pr(xt,on),jr}for(Fr=E(xt,Fr);!Ma.done;on++,Ma=wt.next())Ma=er(Fr,xt,on,Ma.value,ws),Ma!==null&&(m&&Ma.alternate!==null&&Fr.delete(Ma.key===null?on:Ma.key),at=W(Ma,at,on),$r===null?jr=Ma:$r.sibling=Ma,$r=Ma);return m&&Fr.forEach(function(Doe){return f(xt,Doe)}),aa&&Pr(xt,on),jr}function Qo(xt,at,wt,ws){if(typeof wt=="object"&&wt!==null&&wt.type===A&&wt.key===null&&(wt=wt.props.children),typeof wt=="object"&&wt!==null){switch(wt.$$typeof){case S:e:{for(var jr=wt.key,$r=at;$r!==null;){if($r.key===jr){if(jr=wt.type,jr===A){if($r.tag===7){N(xt,$r.sibling),at=B($r,wt.props.children),at.return=xt,xt=at;break e}}else if($r.elementType===jr||typeof jr=="object"&&jr!==null&&jr.$$typeof===K&&Gg(jr)===$r.type){N(xt,$r.sibling),at=B($r,wt.props),at.ref=im(xt,$r,wt),at.return=xt,xt=at;break e}N(xt,$r);break}else f(xt,$r);$r=$r.sibling}wt.type===A?(at=lx(wt.props.children,xt.mode,ws,wt.key),at.return=xt,xt=at):(ws=HN(wt.type,wt.key,wt.props,null,xt.mode,ws),ws.ref=im(xt,at,wt),ws.return=xt,xt=ws)}return de(xt);case _:e:{for($r=wt.key;at!==null;){if(at.key===$r)if(at.tag===4&&at.stateNode.containerInfo===wt.containerInfo&&at.stateNode.implementation===wt.implementation){N(xt,at.sibling),at=B(at,wt.children||[]),at.return=xt,xt=at;break e}else{N(xt,at);break}else f(xt,at);at=at.sibling}at=L2(wt,xt.mode,ws),at.return=xt,xt=at}return de(xt);case K:return $r=wt._init,Qo(xt,at,$r(wt._payload),ws)}if(Ae(wt))return pr(xt,at,wt,ws);if(Z(wt))return yr(xt,at,wt,ws);bp(xt,wt)}return typeof wt=="string"&&wt!==""||typeof wt=="number"?(wt=""+wt,at!==null&&at.tag===6?(N(xt,at.sibling),at=B(at,wt),at.return=xt,xt=at):(N(xt,at),at=D2(wt,xt.mode,ws),at.return=xt,xt=at),de(xt)):N(xt,at)}return Qo}var Vm=Rf(!0),bv=Rf(!1),Wm=fo(null),Du=null,Km=null,If=null;function Yg(){If=Km=Du=null}function Of(m){var f=Wm.current;Zn(Wm),m._currentValue=f}function wp(m,f,N){for(;m!==null;){var E=m.alternate;if((m.childLanes&f)!==f?(m.childLanes|=f,E!==null&&(E.childLanes|=f)):E!==null&&(E.childLanes&f)!==f&&(E.childLanes|=f),m===N)break;m=m.return}}function Gm(m,f){Du=m,If=Km=null,m=m.dependencies,m!==null&&m.firstContext!==null&&((m.lanes&f)!==0&&(vl=!0),m.firstContext=null)}function ic(m){var f=m._currentValue;if(If!==m)if(m={context:m,memoizedValue:f,next:null},Km===null){if(Du===null)throw Error(r(308));Km=m,Du.dependencies={lanes:0,firstContext:m}}else Km=Km.next=m;return f}var om=null;function jp(m){om===null?om=[m]:om.push(m)}function Qg(m,f,N,E){var B=f.interleaved;return B===null?(N.next=N,jp(f)):(N.next=B.next,B.next=N),f.interleaved=N,nu(m,E)}function nu(m,f){m.lanes|=f;var N=m.alternate;for(N!==null&&(N.lanes|=f),N=m,m=m.return;m!==null;)m.childLanes|=f,N=m.alternate,N!==null&&(N.childLanes|=f),N=m,m=m.return;return N.tag===3?N.stateNode:null}var gi=!1;function Np(m){m.updateQueue={baseState:m.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xg(m,f){m=m.updateQueue,f.updateQueue===m&&(f.updateQueue={baseState:m.baseState,firstBaseUpdate:m.firstBaseUpdate,lastBaseUpdate:m.lastBaseUpdate,shared:m.shared,effects:m.effects})}function Lu(m,f){return{eventTime:m,lane:f,tag:0,payload:null,callback:null,next:null}}function $u(m,f,N){var E=m.updateQueue;if(E===null)return null;if(E=E.shared,(Ca&2)!==0){var B=E.pending;return B===null?f.next=f:(f.next=B.next,B.next=f),E.pending=f,nu(m,N)}return B=E.interleaved,B===null?(f.next=f,jp(E)):(f.next=B.next,B.next=f),E.interleaved=f,nu(m,N)}function Sp(m,f,N){if(f=f.updateQueue,f!==null&&(f=f.shared,(N&4194240)!==0)){var E=f.lanes;E&=m.pendingLanes,N|=E,f.lanes=N,Lr(m,N)}}function lm(m,f){var N=m.updateQueue,E=m.alternate;if(E!==null&&(E=E.updateQueue,N===E)){var B=null,W=null;if(N=N.firstBaseUpdate,N!==null){do{var de={eventTime:N.eventTime,lane:N.lane,tag:N.tag,payload:N.payload,callback:N.callback,next:null};W===null?B=W=de:W=W.next=de,N=N.next}while(N!==null);W===null?B=W=f:W=W.next=f}else B=W=f;N={baseState:E.baseState,firstBaseUpdate:B,lastBaseUpdate:W,shared:E.shared,effects:E.effects},m.updateQueue=N;return}m=N.lastBaseUpdate,m===null?N.firstBaseUpdate=f:m.next=f,N.lastBaseUpdate=f}function Ym(m,f,N,E){var B=m.updateQueue;gi=!1;var W=B.firstBaseUpdate,de=B.lastBaseUpdate,Ie=B.shared.pending;if(Ie!==null){B.shared.pending=null;var Xe=Ie,Pt=Xe.next;Xe.next=null,de===null?W=Pt:de.next=Pt,de=Xe;var as=m.alternate;as!==null&&(as=as.updateQueue,Ie=as.lastBaseUpdate,Ie!==de&&(Ie===null?as.firstBaseUpdate=Pt:Ie.next=Pt,as.lastBaseUpdate=Xe))}if(W!==null){var cs=B.baseState;de=0,as=Pt=Xe=null,Ie=W;do{var ss=Ie.lane,er=Ie.eventTime;if((E&ss)===ss){as!==null&&(as=as.next={eventTime:er,lane:0,tag:Ie.tag,payload:Ie.payload,callback:Ie.callback,next:null});e:{var pr=m,yr=Ie;switch(ss=f,er=N,yr.tag){case 1:if(pr=yr.payload,typeof pr=="function"){cs=pr.call(er,cs,ss);break e}cs=pr;break e;case 3:pr.flags=pr.flags&-65537|128;case 0:if(pr=yr.payload,ss=typeof pr=="function"?pr.call(er,cs,ss):pr,ss==null)break e;cs=ee({},cs,ss);break e;case 2:gi=!0}}Ie.callback!==null&&Ie.lane!==0&&(m.flags|=64,ss=B.effects,ss===null?B.effects=[Ie]:ss.push(Ie))}else er={eventTime:er,lane:ss,tag:Ie.tag,payload:Ie.payload,callback:Ie.callback,next:null},as===null?(Pt=as=er,Xe=cs):as=as.next=er,de|=ss;if(Ie=Ie.next,Ie===null){if(Ie=B.shared.pending,Ie===null)break;ss=Ie,Ie=ss.next,ss.next=null,B.lastBaseUpdate=ss,B.shared.pending=null}}while(!0);if(as===null&&(Xe=cs),B.baseState=Xe,B.firstBaseUpdate=Pt,B.lastBaseUpdate=as,f=B.shared.interleaved,f!==null){B=f;do de|=B.lane,B=B.next;while(B!==f)}else W===null&&(B.shared.lanes=0);nx|=de,m.lanes=de,m.memoizedState=cs}}function Cp(m,f,N){if(m=f.effects,f.effects=null,m!==null)for(f=0;f<m.length;f++){var E=m[f],B=E.callback;if(B!==null){if(E.callback=null,E=N,typeof B!="function")throw Error(r(191,B));B.call(E)}}}var au={},Rd=fo(au),Qm=fo(au),cm=fo(au);function iu(m){if(m===au)throw Error(r(174));return m}function oc(m,f){switch(hn(cm,f),hn(Qm,m),hn(Rd,au),m=f.nodeType,m){case 9:case 11:f=(f=f.documentElement)?f.namespaceURI:te(null,"");break;default:m=m===8?f.parentNode:f,f=m.namespaceURI||null,m=m.tagName,f=te(f,m)}Zn(Rd),hn(Rd,f)}function kp(){Zn(Rd),Zn(Qm),Zn(cm)}function ud(m){iu(cm.current);var f=iu(Rd.current),N=te(f,m.type);f!==N&&(hn(Qm,m),hn(Rd,N))}function Df(m){Qm.current===m&&(Zn(Rd),Zn(Qm))}var ci=fo(0);function _p(m){for(var f=m;f!==null;){if(f.tag===13){var N=f.memoizedState;if(N!==null&&(N=N.dehydrated,N===null||N.data==="$?"||N.data==="$!"))return f}else if(f.tag===19&&f.memoizedProps.revealOrder!==void 0){if((f.flags&128)!==0)return f}else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===m)break;for(;f.sibling===null;){if(f.return===null||f.return===m)return null;f=f.return}f.sibling.return=f.return,f=f.sibling}return null}var Pp=[];function Mo(){for(var m=0;m<Pp.length;m++)Pp[m]._workInProgressVersionPrimary=null;Pp.length=0}var ou=k.ReactCurrentDispatcher,Ll=k.ReactCurrentBatchConfig,$h=0,ca=null,to=null,$i=null,Lf=!1,I=!1,ie=0,Le=0;function Ye(){throw Error(r(321))}function Mt(m,f){if(f===null)return!1;for(var N=0;N<f.length&&N<m.length;N++)if(!qt(m[N],f[N]))return!1;return!0}function _s(m,f,N,E,B,W){if($h=W,ca=f,f.memoizedState=null,f.updateQueue=null,f.lanes=0,ou.current=m===null||m.memoizedState===null?xe:Ee,m=N(E,B),I){W=0;do{if(I=!1,ie=0,25<=W)throw Error(r(301));W+=1,$i=to=null,f.updateQueue=null,ou.current=_t,m=N(E,B)}while(I)}if(ou.current=X,f=to!==null&&to.next!==null,$h=0,$i=to=ca=null,Lf=!1,f)throw Error(r(300));return m}function ks(){var m=ie!==0;return ie=0,m}function Ts(){var m={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $i===null?ca.memoizedState=$i=m:$i=$i.next=m,$i}function ls(){if(to===null){var m=ca.alternate;m=m!==null?m.memoizedState:null}else m=to.next;var f=$i===null?ca.memoizedState:$i.next;if(f!==null)$i=f,to=m;else{if(m===null)throw Error(r(310));to=m,m={memoizedState:to.memoizedState,baseState:to.baseState,baseQueue:to.baseQueue,queue:to.queue,next:null},$i===null?ca.memoizedState=$i=m:$i=$i.next=m}return $i}function ps(m,f){return typeof f=="function"?f(m):f}function Kr(m){var f=ls(),N=f.queue;if(N===null)throw Error(r(311));N.lastRenderedReducer=m;var E=to,B=E.baseQueue,W=N.pending;if(W!==null){if(B!==null){var de=B.next;B.next=W.next,W.next=de}E.baseQueue=B=W,N.pending=null}if(B!==null){W=B.next,E=E.baseState;var Ie=de=null,Xe=null,Pt=W;do{var as=Pt.lane;if(($h&as)===as)Xe!==null&&(Xe=Xe.next={lane:0,action:Pt.action,hasEagerState:Pt.hasEagerState,eagerState:Pt.eagerState,next:null}),E=Pt.hasEagerState?Pt.eagerState:m(E,Pt.action);else{var cs={lane:as,action:Pt.action,hasEagerState:Pt.hasEagerState,eagerState:Pt.eagerState,next:null};Xe===null?(Ie=Xe=cs,de=E):Xe=Xe.next=cs,ca.lanes|=as,nx|=as}Pt=Pt.next}while(Pt!==null&&Pt!==W);Xe===null?de=E:Xe.next=Ie,qt(E,f.memoizedState)||(vl=!0),f.memoizedState=E,f.baseState=de,f.baseQueue=Xe,N.lastRenderedState=E}if(m=N.interleaved,m!==null){B=m;do W=B.lane,ca.lanes|=W,nx|=W,B=B.next;while(B!==m)}else B===null&&(N.lanes=0);return[f.memoizedState,N.dispatch]}function Is(m){var f=ls(),N=f.queue;if(N===null)throw Error(r(311));N.lastRenderedReducer=m;var E=N.dispatch,B=N.pending,W=f.memoizedState;if(B!==null){N.pending=null;var de=B=B.next;do W=m(W,de.action),de=de.next;while(de!==B);qt(W,f.memoizedState)||(vl=!0),f.memoizedState=W,f.baseQueue===null&&(f.baseState=W),N.lastRenderedState=W}return[W,E]}function kn(){}function an(m,f){var N=ca,E=ls(),B=f(),W=!qt(E.memoizedState,B);if(W&&(E.memoizedState=B,vl=!0),E=E.queue,tx(Zg.bind(null,N,E,m),[m]),E.getSnapshot!==f||W||$i!==null&&$i.memoizedState.tag&1){if(N.flags|=2048,Bf(9,Id.bind(null,N,E,B,f),void 0,null),lc===null)throw Error(r(349));($h&30)!==0||ri(N,f,B)}return B}function ri(m,f,N){m.flags|=16384,m={getSnapshot:f,value:N},f=ca.updateQueue,f===null?(f={lastEffect:null,stores:null},ca.updateQueue=f,f.stores=[m]):(N=f.stores,N===null?f.stores=[m]:N.push(m))}function Id(m,f,N,E){f.value=N,f.getSnapshot=E,Ep(f)&&$f(m)}function Zg(m,f,N){return N(function(){Ep(f)&&$f(m)})}function Ep(m){var f=m.getSnapshot;m=m.value;try{var N=f();return!qt(m,N)}catch{return!0}}function $f(m){var f=nu(m,1);f!==null&&rh(f,m,1,-1)}function Ff(m){var f=Ts();return typeof m=="function"&&(m=m()),f.memoizedState=f.baseState=m,m={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:m},f.queue=m,m=m.dispatch=f2.bind(null,ca,m),[f.memoizedState,m]}function Bf(m,f,N,E){return m={tag:m,create:f,destroy:N,deps:E,next:null},f=ca.updateQueue,f===null?(f={lastEffect:null,stores:null},ca.updateQueue=f,f.lastEffect=m.next=m):(N=f.lastEffect,N===null?f.lastEffect=m.next=m:(E=N.next,N.next=m,m.next=E,f.lastEffect=m)),m}function Jg(){return ls().memoizedState}function wv(m,f,N,E){var B=Ts();ca.flags|=m,B.memoizedState=Bf(1|f,N,void 0,E===void 0?null:E)}function ex(m,f,N,E){var B=ls();E=E===void 0?null:E;var W=void 0;if(to!==null){var de=to.memoizedState;if(W=de.destroy,E!==null&&Mt(E,de.deps)){B.memoizedState=Bf(f,N,W,E);return}}ca.flags|=m,B.memoizedState=Bf(1|f,N,W,E)}function Xb(m,f){return wv(8390656,8,m,f)}function tx(m,f){return ex(2048,8,m,f)}function CN(m,f){return ex(4,2,m,f)}function kN(m,f){return ex(4,4,m,f)}function _N(m,f){if(typeof f=="function")return m=m(),f(m),function(){f(null)};if(f!=null)return m=m(),f.current=m,function(){f.current=null}}function Zb(m,f,N){return N=N!=null?N.concat([m]):null,ex(4,4,_N.bind(null,f,m),N)}function Jb(){}function ew(m,f){var N=ls();f=f===void 0?null:f;var E=N.memoizedState;return E!==null&&f!==null&&Mt(f,E[1])?E[0]:(N.memoizedState=[m,f],m)}function PN(m,f){var N=ls();f=f===void 0?null:f;var E=N.memoizedState;return E!==null&&f!==null&&Mt(f,E[1])?E[0]:(m=m(),N.memoizedState=[m,f],m)}function tw(m,f,N){return($h&21)===0?(m.baseState&&(m.baseState=!1,vl=!0),m.memoizedState=N):(qt(N,f)||(N=ku(),ca.lanes|=N,nx|=N,m.baseState=!0),f)}function EN(m,f){var N=Vr;Vr=N!==0&&4>N?N:4,m(!0);var E=Ll.transition;Ll.transition={};try{m(!1),f()}finally{Vr=N,Ll.transition=E}}function sw(){return ls().memoizedState}function p2(m,f,N){var E=qf(m);if(N={lane:E,action:N,hasEagerState:!1,eagerState:null,next:null},Xm(m))TN(f,N);else if(N=Qg(m,f,N,E),N!==null){var B=Dd();rh(N,m,E,B),P(N,f,E)}}function f2(m,f,N){var E=qf(m),B={lane:E,action:N,hasEagerState:!1,eagerState:null,next:null};if(Xm(m))TN(f,B);else{var W=m.alternate;if(m.lanes===0&&(W===null||W.lanes===0)&&(W=f.lastRenderedReducer,W!==null))try{var de=f.lastRenderedState,Ie=W(de,N);if(B.hasEagerState=!0,B.eagerState=Ie,qt(Ie,de)){var Xe=f.interleaved;Xe===null?(B.next=B,jp(f)):(B.next=Xe.next,Xe.next=B),f.interleaved=B;return}}catch{}N=Qg(m,f,B,E),N!==null&&(B=Dd(),rh(N,m,E,B),P(N,f,E))}}function Xm(m){var f=m.alternate;return m===ca||f!==null&&f===ca}function TN(m,f){I=Lf=!0;var N=m.pending;N===null?f.next=f:(f.next=N.next,N.next=f),m.pending=f}function P(m,f,N){if((N&4194240)!==0){var E=f.lanes;E&=m.pendingLanes,N|=E,f.lanes=N,Lr(m,N)}}var X={readContext:ic,useCallback:Ye,useContext:Ye,useEffect:Ye,useImperativeHandle:Ye,useInsertionEffect:Ye,useLayoutEffect:Ye,useMemo:Ye,useReducer:Ye,useRef:Ye,useState:Ye,useDebugValue:Ye,useDeferredValue:Ye,useTransition:Ye,useMutableSource:Ye,useSyncExternalStore:Ye,useId:Ye,unstable_isNewReconciler:!1},xe={readContext:ic,useCallback:function(m,f){return Ts().memoizedState=[m,f===void 0?null:f],m},useContext:ic,useEffect:Xb,useImperativeHandle:function(m,f,N){return N=N!=null?N.concat([m]):null,wv(4194308,4,_N.bind(null,f,m),N)},useLayoutEffect:function(m,f){return wv(4194308,4,m,f)},useInsertionEffect:function(m,f){return wv(4,2,m,f)},useMemo:function(m,f){var N=Ts();return f=f===void 0?null:f,m=m(),N.memoizedState=[m,f],m},useReducer:function(m,f,N){var E=Ts();return f=N!==void 0?N(f):f,E.memoizedState=E.baseState=f,m={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:m,lastRenderedState:f},E.queue=m,m=m.dispatch=p2.bind(null,ca,m),[E.memoizedState,m]},useRef:function(m){var f=Ts();return m={current:m},f.memoizedState=m},useState:Ff,useDebugValue:Jb,useDeferredValue:function(m){return Ts().memoizedState=m},useTransition:function(){var m=Ff(!1),f=m[0];return m=EN.bind(null,m[1]),Ts().memoizedState=m,[f,m]},useMutableSource:function(){},useSyncExternalStore:function(m,f,N){var E=ca,B=Ts();if(aa){if(N===void 0)throw Error(r(407));N=N()}else{if(N=f(),lc===null)throw Error(r(349));($h&30)!==0||ri(E,f,N)}B.memoizedState=N;var W={value:N,getSnapshot:f};return B.queue=W,Xb(Zg.bind(null,E,W,m),[m]),E.flags|=2048,Bf(9,Id.bind(null,E,W,N,f),void 0,null),N},useId:function(){var m=Ts(),f=lc.identifierPrefix;if(aa){var N=pi,E=Ji;N=(E&~(1<<32-nr(E)-1)).toString(32)+N,f=":"+f+"R"+N,N=ie++,0<N&&(f+="H"+N.toString(32)),f+=":"}else N=Le++,f=":"+f+"r"+N.toString(32)+":";return m.memoizedState=f},unstable_isNewReconciler:!1},Ee={readContext:ic,useCallback:ew,useContext:ic,useEffect:tx,useImperativeHandle:Zb,useInsertionEffect:CN,useLayoutEffect:kN,useMemo:PN,useReducer:Kr,useRef:Jg,useState:function(){return Kr(ps)},useDebugValue:Jb,useDeferredValue:function(m){var f=ls();return tw(f,to.memoizedState,m)},useTransition:function(){var m=Kr(ps)[0],f=ls().memoizedState;return[m,f]},useMutableSource:kn,useSyncExternalStore:an,useId:sw,unstable_isNewReconciler:!1},_t={readContext:ic,useCallback:ew,useContext:ic,useEffect:tx,useImperativeHandle:Zb,useInsertionEffect:CN,useLayoutEffect:kN,useMemo:PN,useReducer:Is,useRef:Jg,useState:function(){return Is(ps)},useDebugValue:Jb,useDeferredValue:function(m){var f=ls();return to===null?f.memoizedState=m:tw(f,to.memoizedState,m)},useTransition:function(){var m=Is(ps)[0],f=ls().memoizedState;return[m,f]},useMutableSource:kn,useSyncExternalStore:an,useId:sw,unstable_isNewReconciler:!1};function Me(m,f){if(m&&m.defaultProps){f=ee({},f),m=m.defaultProps;for(var N in m)f[N]===void 0&&(f[N]=m[N]);return f}return f}function st(m,f,N,E){f=m.memoizedState,N=N(E,f),N=N==null?f:ee({},f,N),m.memoizedState=N,m.lanes===0&&(m.updateQueue.baseState=N)}var ot={isMounted:function(m){return(m=m._reactInternals)?Br(m)===m:!1},enqueueSetState:function(m,f,N){m=m._reactInternals;var E=Dd(),B=qf(m),W=Lu(E,B);W.payload=f,N!=null&&(W.callback=N),f=$u(m,W,B),f!==null&&(rh(f,m,B,E),Sp(f,m,B))},enqueueReplaceState:function(m,f,N){m=m._reactInternals;var E=Dd(),B=qf(m),W=Lu(E,B);W.tag=1,W.payload=f,N!=null&&(W.callback=N),f=$u(m,W,B),f!==null&&(rh(f,m,B,E),Sp(f,m,B))},enqueueForceUpdate:function(m,f){m=m._reactInternals;var N=Dd(),E=qf(m),B=Lu(N,E);B.tag=2,f!=null&&(B.callback=f),f=$u(m,B,E),f!==null&&(rh(f,m,E,N),Sp(f,m,E))}};function Nt(m,f,N,E,B,W,de){return m=m.stateNode,typeof m.shouldComponentUpdate=="function"?m.shouldComponentUpdate(E,W,de):f.prototype&&f.prototype.isPureReactComponent?!Zt(N,E)||!Zt(B,W):!0}function Gt(m,f,N){var E=!1,B=Ao,W=f.contextType;return typeof W=="object"&&W!==null?W=ic(W):(B=li(f)?dd:Sa.current,E=f.contextTypes,W=(E=E!=null)?Dl(m,B):Ao),f=new f(N,W),m.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,f.updater=ot,m.stateNode=f,f._reactInternals=m,E&&(m=m.stateNode,m.__reactInternalMemoizedUnmaskedChildContext=B,m.__reactInternalMemoizedMaskedChildContext=W),f}function yt(m,f,N,E){m=f.state,typeof f.componentWillReceiveProps=="function"&&f.componentWillReceiveProps(N,E),typeof f.UNSAFE_componentWillReceiveProps=="function"&&f.UNSAFE_componentWillReceiveProps(N,E),f.state!==m&&ot.enqueueReplaceState(f,f.state,null)}function hs(m,f,N,E){var B=m.stateNode;B.props=N,B.state=m.memoizedState,B.refs={},Np(m);var W=f.contextType;typeof W=="object"&&W!==null?B.context=ic(W):(W=li(f)?dd:Sa.current,B.context=Dl(m,W)),B.state=m.memoizedState,W=f.getDerivedStateFromProps,typeof W=="function"&&(st(m,f,W,N),B.state=m.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof B.getSnapshotBeforeUpdate=="function"||typeof B.UNSAFE_componentWillMount!="function"&&typeof B.componentWillMount!="function"||(f=B.state,typeof B.componentWillMount=="function"&&B.componentWillMount(),typeof B.UNSAFE_componentWillMount=="function"&&B.UNSAFE_componentWillMount(),f!==B.state&&ot.enqueueReplaceState(B,B.state,null),Ym(m,N,B,E),B.state=m.memoizedState),typeof B.componentDidMount=="function"&&(m.flags|=4194308)}function jn(m,f){try{var N="",E=f;do N+=je(E),E=E.return;while(E);var B=N}catch(W){B=`
7Error generating stack: `+W.message+`
8`+W.stack}return{value:m,source:f,stack:B,digest:null}}function so(m,f,N){return{value:m,source:null,stack:N??null,digest:f??null}}function Zm(m,f){try{console.error(f.value)}catch(N){setTimeout(function(){throw N})}}var go=typeof WeakMap=="function"?WeakMap:Map;function xl(m,f,N){N=Lu(-1,N),N.tag=3,N.payload={element:null};var E=f.value;return N.callback=function(){LN||(LN=!0,P2=E),Zm(m,f)},N}function lu(m,f,N){N=Lu(-1,N),N.tag=3;var E=m.type.getDerivedStateFromError;if(typeof E=="function"){var B=f.value;N.payload=function(){return E(B)},N.callback=function(){Zm(m,f)}}var W=m.stateNode;return W!==null&&typeof W.componentDidCatch=="function"&&(N.callback=function(){Zm(m,f),typeof E!="function"&&(zf===null?zf=new Set([this]):zf.add(this));var de=f.stack;this.componentDidCatch(f.value,{componentStack:de!==null?de:""})}),N}function dm(m,f,N){var E=m.pingCache;if(E===null){E=m.pingCache=new go;var B=new Set;E.set(f,B)}else B=E.get(f),B===void 0&&(B=new Set,E.set(f,B));B.has(N)||(B.add(N),m=Coe.bind(null,m,f,N),f.then(m,m))}function Od(m){do{var f;if((f=m.tag===13)&&(f=m.memoizedState,f=f!==null?f.dehydrated!==null:!0),f)return m;m=m.return}while(m!==null);return null}function Jm(m,f,N,E,B){return(m.mode&1)===0?(m===f?m.flags|=65536:(m.flags|=128,N.flags|=131072,N.flags&=-52805,N.tag===1&&(N.alternate===null?N.tag=17:(f=Lu(-1,1),f.tag=2,$u(N,f,1))),N.lanes|=1),m):(m.flags|=65536,m.lanes=B,m)}var eh=k.ReactCurrentOwner,vl=!1;function xo(m,f,N,E){f.child=m===null?bv(f,null,N,E):Vm(f,m.child,N,E)}function Tp(m,f,N,E,B){N=N.render;var W=f.ref;return Gm(f,B),E=_s(m,f,N,E,W,B),N=ks(),m!==null&&!vl?(f.updateQueue=m.updateQueue,f.flags&=-2053,m.lanes&=~B,Ap(m,f,B)):(aa&&N&&Md(f),f.flags|=1,xo(m,f,E,B),f.child)}function Fh(m,f,N,E,B){if(m===null){var W=N.type;return typeof W=="function"&&!O2(W)&&W.defaultProps===void 0&&N.compare===null&&N.defaultProps===void 0?(f.tag=15,f.type=W,sx(m,f,W,E,B)):(m=HN(N.type,null,E,f,f.mode,B),m.ref=f.ref,m.return=f,f.child=m)}if(W=m.child,(m.lanes&B)===0){var de=W.memoizedProps;if(N=N.compare,N=N!==null?N:Zt,N(de,E)&&m.ref===f.ref)return Ap(m,f,B)}return f.flags|=1,m=Wf(W,E),m.ref=f.ref,m.return=f,f.child=m}function sx(m,f,N,E,B){if(m!==null){var W=m.memoizedProps;if(Zt(W,E)&&m.ref===f.ref)if(vl=!1,f.pendingProps=E=W,(m.lanes&B)!==0)(m.flags&131072)!==0&&(vl=!0);else return f.lanes=m.lanes,Ap(m,f,B)}return rw(m,f,N,E,B)}function jv(m,f,N){var E=f.pendingProps,B=E.children,W=m!==null?m.memoizedState:null;if(E.mode==="hidden")if((f.mode&1)===0)f.memoizedState={baseLanes:0,cachePool:null,transitions:null},hn(Cv,Fu),Fu|=N;else{if((N&1073741824)===0)return m=W!==null?W.baseLanes|N:N,f.lanes=f.childLanes=1073741824,f.memoizedState={baseLanes:m,cachePool:null,transitions:null},f.updateQueue=null,hn(Cv,Fu),Fu|=m,null;f.memoizedState={baseLanes:0,cachePool:null,transitions:null},E=W!==null?W.baseLanes:N,hn(Cv,Fu),Fu|=E}else W!==null?(E=W.baseLanes|N,f.memoizedState=null):E=N,hn(Cv,Fu),Fu|=E;return xo(m,f,B,N),f.child}function rx(m,f){var N=f.ref;(m===null&&N!==null||m!==null&&m.ref!==N)&&(f.flags|=512,f.flags|=2097152)}
vendor: 6,556 bytes, line 8
8function rw(m,f,N,E,B){var W=li(N)?dd:Sa.current;return W=Dl(f,W),Gm(f,B),N=_s(m,f,N,E,W,B),E=ks(),m!==null&&!vl?(f.updateQueue=m.updateQueue,f.flags&=-2053,m.lanes&=~B,Ap(m,f,B)):(aa&&E&&Md(f),f.flags|=1,xo(m,f,N,B),f.child)}function Fi(m,f,N,E,B){if(li(N)){var W=!0;Te(f)}else W=!1;if(Gm(f,B),f.stateNode===null)MN(m,f),Gt(f,N,E),hs(f,N,E,B),E=!0;else if(m===null){var de=f.stateNode,Ie=f.memoizedProps;de.props=Ie;var Xe=de.context,Pt=N.contextType;typeof Pt=="object"&&Pt!==null?Pt=ic(Pt):(Pt=li(N)?dd:Sa.current,Pt=Dl(f,Pt));var as=N.getDerivedStateFromProps,cs=typeof as=="function"||typeof de.getSnapshotBeforeUpdate=="function";cs||typeof de.UNSAFE_componentWillReceiveProps!="function"&&typeof de.componentWillReceiveProps!="function"||(Ie!==E||Xe!==Pt)&&yt(f,de,E,Pt),gi=!1;var ss=f.memoizedState;de.state=ss,Ym(f,E,de,B),Xe=f.memoizedState,Ie!==E||ss!==Xe||Aa.current||gi?(typeof as=="function"&&(st(f,N,as,E),Xe=f.memoizedState),(Ie=gi||Nt(f,N,Ie,E,ss,Xe,Pt))?(cs||typeof de.UNSAFE_componentWillMount!="function"&&typeof de.componentWillMount!="function"||(typeof de.componentWillMount=="function"&&de.componentWillMount(),typeof de.UNSAFE_componentWillMount=="function"&&de.UNSAFE_componentWillMount()),typeof de.componentDidMount=="function"&&(f.flags|=4194308)):(typeof de.componentDidMount=="function"&&(f.flags|=4194308),f.memoizedProps=E,f.memoizedState=Xe),de.props=E,de.state=Xe,de.context=Pt,E=Ie):(typeof de.componentDidMount=="function"&&(f.flags|=4194308),E=!1)}else{de=f.stateNode,Xg(m,f),Ie=f.memoizedProps,Pt=f.type===f.elementType?Ie:Me(f.type,Ie),de.props=Pt,cs=f.pendingProps,ss=de.context,Xe=N.contextType,typeof Xe=="object"&&Xe!==null?Xe=ic(Xe):(Xe=li(N)?dd:Sa.current,Xe=Dl(f,Xe));var er=N.getDerivedStateFromProps;(as=typeof er=="function"||typeof de.getSnapshotBeforeUpdate=="function")||typeof de.UNSAFE_componentWillReceiveProps!="function"&&typeof de.componentWillReceiveProps!="function"||(Ie!==cs||ss!==Xe)&&yt(f,de,E,Xe),gi=!1,ss=f.memoizedState,de.state=ss,Ym(f,E,de,B);var pr=f.memoizedState;Ie!==cs||ss!==pr||Aa.current||gi?(typeof er=="function"&&(st(f,N,er,E),pr=f.memoizedState),(Pt=gi||Nt(f,N,Pt,E,ss,pr,Xe)||!1)?(as||typeof de.UNSAFE_componentWillUpdate!="function"&&typeof de.componentWillUpdate!="function"||(typeof de.componentWillUpdate=="function"&&de.componentWillUpdate(E,pr,Xe),typeof de.UNSAFE_componentWillUpdate=="function"&&de.UNSAFE_componentWillUpdate(E,pr,Xe)),typeof de.componentDidUpdate=="function"&&(f.flags|=4),typeof de.getSnapshotBeforeUpdate=="function"&&(f.flags|=1024)):(typeof de.componentDidUpdate!="function"||Ie===m.memoizedProps&&ss===m.memoizedState||(f.flags|=4),typeof de.getSnapshotBeforeUpdate!="function"||Ie===m.memoizedProps&&ss===m.memoizedState||(f.flags|=1024),f.memoizedProps=E,f.memoizedState=pr),de.props=E,de.state=pr,de.context=Xe,E=Pt):(typeof de.componentDidUpdate!="function"||Ie===m.memoizedProps&&ss===m.memoizedState||(f.flags|=4),typeof de.getSnapshotBeforeUpdate!="function"||Ie===m.memoizedProps&&ss===m.memoizedState||(f.flags|=1024),E=!1)}return Nv(m,f,N,E,W,B)}function Nv(m,f,N,E,B,W){rx(m,f);var de=(f.flags&128)!==0;if(!E&&!de)return B&&ht(f,N,!1),Ap(m,f,W);E=f.stateNode,eh.current=f;var Ie=de&&typeof N.getDerivedStateFromError!="function"?null:E.render();return f.flags|=1,m!==null&&de?(f.child=Vm(f,m.child,null,W),f.child=Vm(f,null,Ie,W)):xo(m,f,Ie,W),f.memoizedState=E.state,B&&ht(f,N,!0),f.child}function mL(m){var f=m.stateNode;f.pendingContext?F(m,f.pendingContext,f.pendingContext!==f.context):f.context&&F(m,f.context,!1),oc(m,f.containerInfo)}function hL(m,f,N,E,B){return qm(),Mf(B),f.flags|=256,xo(m,f,N,E),f.child}var g2={dehydrated:null,treeContext:null,retryLane:0};function x2(m){return{baseLanes:m,cachePool:null,transitions:null}}function pL(m,f,N){var E=f.pendingProps,B=ci.current,W=!1,de=(f.flags&128)!==0,Ie;if((Ie=de)||(Ie=m!==null&&m.memoizedState===null?!1:(B&2)!==0),Ie?(W=!0,f.flags&=-129):(m===null||m.memoizedState!==null)&&(B|=1),hn(ci,B&1),m===null)return ru(f),m=f.memoizedState,m!==null&&(m=m.dehydrated,m!==null)?((f.mode&1)===0?f.lanes=1:m.data==="$!"?f.lanes=8:f.lanes=1073741824,null):(de=E.children,m=E.fallback,W?(E=f.mode,W=f.child,de={mode:"hidden",children:de},(E&1)===0&&W!==null?(W.childLanes=0,W.pendingProps=de):W=qN(de,E,0,null),m=lx(m,E,N,null),W.return=f,m.return=f,W.sibling=m,f.child=W,f.child.memoizedState=x2(N),f.memoizedState=g2,m):v2(f,de));if(B=m.memoizedState,B!==null&&(Ie=B.dehydrated,Ie!==null))return hoe(m,f,de,E,Ie,B,N);if(W){W=E.fallback,de=f.mode,B=m.child,Ie=B.sibling;var Xe={mode:"hidden",children:E.children};return(de&1)===0&&f.child!==B?(E=f.child,E.childLanes=0,E.pendingProps=Xe,f.deletions=null):(E=Wf(B,Xe),E.subtreeFlags=B.subtreeFlags&14680064),Ie!==null?W=Wf(Ie,W):(W=lx(W,de,N,null),W.flags|=2),W.return=f,E.return=f,E.sibling=W,f.child=E,E=W,W=f.child,de=m.child.memoizedState,de=de===null?x2(N):{baseLanes:de.baseLanes|N,cachePool:null,transitions:de.transitions},W.memoizedState=de,W.childLanes=m.childLanes&~N,f.memoizedState=g2,E}return W=m.child,m=W.sibling,E=Wf(W,{mode:"visible",children:E.children}),(f.mode&1)===0&&(E.lanes=N),E.return=f,E.sibling=null,m!==null&&(N=f.deletions,N===null?(f.deletions=[m],f.flags|=16):N.push(m)),f.child=E,f.memoizedState=null,E}function v2(m,f){return f=qN({mode:"visible",children:f},m.mode,0,null),f.return=m,m.child=f}function AN(m,f,N,E){return E!==null&&Mf(E),Vm(f,m.child,null,N),m=v2(f,f.pendingProps.children),m.flags|=2,f.memoizedState=null,m}function hoe(m,f,N,E,B,W,de){if(N)return f.flags&256?(f.flags&=-257,E=so(Error(r(422))),AN(m,f,de,E)):f.memoizedState!==null?(f.child=m.child,f.flags|=128,null):(W=E.fallback,B=f.mode,E=qN({mode:"visible",children:E.children},B,0,null),W=lx(W,B,de,null),W.flags|=2,E.return=f,W.return=f,E.sibling=W,f.child=E,(f.mode&1)!==0&&Vm(f,m.child,null,de),f.child.memoizedState=x2(de),f.memoizedState=g2,W);if((f.mode&1)===0)return AN(m,f,de,null);if(B.data==="$!"){if(E=B.nextSibling&&B.nextSibling.dataset,E)var Ie=E.dgst;return E=Ie,W=Error(r(419)),E=so(W,E,void 0),AN(m,f,de,E)}if(Ie=(de&m.childLanes)!==0,vl||Ie){if(E=lc,E!==null){switch(de&-de){case 4:B=2;break;case 16:B=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:B=32;break;case 536870912:B=268435456;break;default:B=0}B=(B&(E.suspendedLanes|de))!==0?0:B,B!==0&&B!==W.retryLane&&(W.retryLane=B,nu(m,B),rh(E,m,B,-1))}
vendor: 4,762 bytes, line 8
8return I2(),E=so(Error(r(421))),AN(m,f,de,E)}return B.data==="$?"?(f.flags|=128,f.child=m.child,f=koe.bind(null,m),B._reactRetry=f,null):(m=W.treeContext,fi=po(B.nextSibling),Li=f,aa=!0,eo=null,m!==null&&(Wr[dn++]=Ji,Wr[dn++]=pi,Wr[dn++]=Yo,Ji=m.id,pi=m.overflow,Yo=f),f=v2(f,E.children),f.flags|=4096,f)}function fL(m,f,N){m.lanes|=f;var E=m.alternate;E!==null&&(E.lanes|=f),wp(m.return,f,N)}function y2(m,f,N,E,B){var W=m.memoizedState;W===null?m.memoizedState={isBackwards:f,rendering:null,renderingStartTime:0,last:E,tail:N,tailMode:B}:(W.isBackwards=f,W.rendering=null,W.renderingStartTime=0,W.last=E,W.tail=N,W.tailMode=B)}function gL(m,f,N){var E=f.pendingProps,B=E.revealOrder,W=E.tail;if(xo(m,f,E.children,N),E=ci.current,(E&2)!==0)E=E&1|2,f.flags|=128;else{if(m!==null&&(m.flags&128)!==0)e:for(m=f.child;m!==null;){if(m.tag===13)m.memoizedState!==null&&fL(m,N,f);else if(m.tag===19)fL(m,N,f);else if(m.child!==null){m.child.return=m,m=m.child;continue}if(m===f)break e;for(;m.sibling===null;){if(m.return===null||m.return===f)break e;m=m.return}m.sibling.return=m.return,m=m.sibling}E&=1}if(hn(ci,E),(f.mode&1)===0)f.memoizedState=null;else switch(B){case"forwards":for(N=f.child,B=null;N!==null;)m=N.alternate,m!==null&&_p(m)===null&&(B=N),N=N.sibling;N=B,N===null?(B=f.child,f.child=null):(B=N.sibling,N.sibling=null),y2(f,!1,B,N,W);break;case"backwards":for(N=null,B=f.child,f.child=null;B!==null;){if(m=B.alternate,m!==null&&_p(m)===null){f.child=B;break}m=B.sibling,B.sibling=N,N=B,B=m}y2(f,!0,N,null,W);break;case"together":y2(f,!1,null,null,void 0);break;default:f.memoizedState=null}return f.child}function MN(m,f){(f.mode&1)===0&&m!==null&&(m.alternate=null,f.alternate=null,f.flags|=2)}function Ap(m,f,N){if(m!==null&&(f.dependencies=m.dependencies),nx|=f.lanes,(N&f.childLanes)===0)return null;if(m!==null&&f.child!==m.child)throw Error(r(153));if(f.child!==null){for(m=f.child,N=Wf(m,m.pendingProps),f.child=N,N.return=f;m.sibling!==null;)m=m.sibling,N=N.sibling=Wf(m,m.pendingProps),N.return=f;N.sibling=null}return f.child}function poe(m,f,N){switch(f.tag){case 3:mL(f),qm();break;case 5:ud(f);break;case 1:li(f.type)&&Te(f);break;case 4:oc(f,f.stateNode.containerInfo);break;case 10:var E=f.type._context,B=f.memoizedProps.value;hn(Wm,E._currentValue),E._currentValue=B;break;case 13:if(E=f.memoizedState,E!==null)return E.dehydrated!==null?(hn(ci,ci.current&1),f.flags|=128,null):(N&f.child.childLanes)!==0?pL(m,f,N):(hn(ci,ci.current&1),m=Ap(m,f,N),m!==null?m.sibling:null);hn(ci,ci.current&1);break;case 19:if(E=(N&f.childLanes)!==0,(m.flags&128)!==0){if(E)return gL(m,f,N);f.flags|=128}if(B=f.memoizedState,B!==null&&(B.rendering=null,B.tail=null,B.lastEffect=null),hn(ci,ci.current),E)break;return null;case 22:case 23:return f.lanes=0,jv(m,f,N)}return Ap(m,f,N)}var xL,b2,vL,yL;xL=function(m,f){for(var N=f.child;N!==null;){if(N.tag===5||N.tag===6)m.appendChild(N.stateNode);else if(N.tag!==4&&N.child!==null){N.child.return=N,N=N.child;continue}if(N===f)break;for(;N.sibling===null;){if(N.return===null||N.return===f)return;N=N.return}N.sibling.return=N.return,N=N.sibling}},b2=function(){},vL=function(m,f,N,E){var B=m.memoizedProps;if(B!==E){m=f.stateNode,iu(Rd.current);var W=null;switch(N){case"input":B=be(m,B),E=be(m,E),W=[];break;case"select":B=ee({},B,{value:void 0}),E=ee({},E,{value:void 0}),W=[];break;case"textarea":B=J(m,B),E=J(m,E),W=[];break;default:typeof B.onClick!="function"&&typeof E.onClick=="function"&&(m.onclick=cd)}pt(N,E);var de;N=null;for(Pt in B)if(!E.hasOwnProperty(Pt)&&B.hasOwnProperty(Pt)&&B[Pt]!=null)if(Pt==="style"){var Ie=B[Pt];for(de in Ie)Ie.hasOwnProperty(de)&&(N||(N={}),N[de]="")}else Pt!=="dangerouslySetInnerHTML"&&Pt!=="children"&&Pt!=="suppressContentEditableWarning"&&Pt!=="suppressHydrationWarning"&&Pt!=="autoFocus"&&(a.hasOwnProperty(Pt)?W||(W=[]):(W=W||[]).push(Pt,null));for(Pt in E){var Xe=E[Pt];if(Ie=B?.[Pt],E.hasOwnProperty(Pt)&&Xe!==Ie&&(Xe!=null||Ie!=null))if(Pt==="style")if(Ie){for(de in Ie)!Ie.hasOwnProperty(de)||Xe&&Xe.hasOwnProperty(de)||(N||(N={}),N[de]="");for(de in Xe)Xe.hasOwnProperty(de)&&Ie[de]!==Xe[de]&&(N||(N={}),N[de]=Xe[de])}else N||(W||(W=[]),W.push(Pt,N)),N=Xe;else Pt==="dangerouslySetInnerHTML"?(Xe=Xe?Xe.__html:void 0,Ie=Ie?Ie.__html:void 0,Xe!=null&&Ie!==Xe&&(W=W||[]).push(Pt,Xe)):Pt==="children"?typeof Xe!="string"&&typeof Xe!="number"||(W=W||[]).push(Pt,""+Xe):Pt!=="suppressContentEditableWarning"&&Pt!=="suppressHydrationWarning"&&(a.hasOwnProperty(Pt)?(Xe!=null&&Pt==="onScroll"&&bn("scroll",m),W||Ie===Xe||(W=[])):(W=W||[]).push(Pt,Xe))}N&&(W=W||[]).push("style",N);var Pt=W;(f.updateQueue=Pt)&&(f.flags|=4)}},yL=function(m,f,N,E){N!==E&&(f.flags|=4)};function nw(m,f){if(!aa)switch(m.tailMode){case"hidden":f=m.tail;for(var N=null;f!==null;
vendor: 9,792 bytes, line 8
8)f.alternate!==null&&(N=f),f=f.sibling;N===null?m.tail=null:N.sibling=null;break;case"collapsed":N=m.tail;for(var E=null;N!==null;)N.alternate!==null&&(E=N),N=N.sibling;E===null?f||m.tail===null?m.tail=null:m.tail.sibling=null:E.sibling=null}}function md(m){var f=m.alternate!==null&&m.alternate.child===m.child,N=0,E=0;if(f)for(var B=m.child;B!==null;)N|=B.lanes|B.childLanes,E|=B.subtreeFlags&14680064,E|=B.flags&14680064,B.return=m,B=B.sibling;else for(B=m.child;B!==null;)N|=B.lanes|B.childLanes,E|=B.subtreeFlags,E|=B.flags,B.return=m,B=B.sibling;return m.subtreeFlags|=E,m.childLanes=N,f}function foe(m,f,N){var E=f.pendingProps;switch(wn(f),f.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return md(f),null;case 1:return li(f.type)&&Fc(),md(f),null;case 3:return E=f.stateNode,kp(),Zn(Aa),Zn(Sa),Mo(),E.pendingContext&&(E.context=E.pendingContext,E.pendingContext=null),(m===null||m.child===null)&&(Uc(f)?f.flags|=4:m===null||m.memoizedState.isDehydrated&&(f.flags&256)===0||(f.flags|=1024,eo!==null&&(A2(eo),eo=null))),b2(m,f),md(f),null;case 5:Df(f);var B=iu(cm.current);if(N=f.type,m!==null&&f.stateNode!=null)vL(m,f,N,E,B),m.ref!==f.ref&&(f.flags|=512,f.flags|=2097152);else{if(!E){if(f.stateNode===null)throw Error(r(166));return md(f),null}if(m=iu(Rd.current),Uc(f)){E=f.stateNode,N=f.type;var W=f.memoizedProps;switch(E[Il]=f,E[Go]=W,m=(f.mode&1)!==0,N){case"dialog":bn("cancel",E),bn("close",E);break;case"iframe":case"object":case"embed":bn("load",E);break;case"video":case"audio":for(B=0;B<El.length;B++)bn(El[B],E);break;case"source":bn("error",E);break;case"img":case"image":case"link":bn("error",E),bn("load",E);break;case"details":bn("toggle",E);break;case"input":ce(E,W),bn("invalid",E);break;case"select":E._wrapperState={wasMultiple:!!W.multiple},bn("invalid",E);break;case"textarea":ae(E,W),bn("invalid",E)}pt(N,W),B=null;for(var de in W)if(W.hasOwnProperty(de)){var Ie=W[de];de==="children"?typeof Ie=="string"?E.textContent!==Ie&&(W.suppressHydrationWarning!==!0&&Ih(E.textContent,Ie,m),B=["children",Ie]):typeof Ie=="number"&&E.textContent!==""+Ie&&(W.suppressHydrationWarning!==!0&&Ih(E.textContent,Ie,m),B=["children",""+Ie]):a.hasOwnProperty(de)&&Ie!=null&&de==="onScroll"&&bn("scroll",E)}switch(N){case"input":se(E),$e(E,W,!0);break;case"textarea":se(E),Qe(E);break;case"select":case"option":break;default:typeof W.onClick=="function"&&(E.onclick=cd)}E=B,f.updateQueue=E,E!==null&&(f.flags|=4)}else{de=B.nodeType===9?B:B.ownerDocument,m==="http://www.w3.org/1999/xhtml"&&(m=ye(N)),m==="http://www.w3.org/1999/xhtml"?N==="script"?(m=de.createElement("div"),m.innerHTML="<script><\/script>",m=m.removeChild(m.firstChild)):typeof E.is=="string"?m=de.createElement(N,{is:E.is}):(m=de.createElement(N),N==="select"&&(de=m,E.multiple?de.multiple=!0:E.size&&(de.size=E.size))):m=de.createElementNS(m,N),m[Il]=f,m[Go]=E,xL(m,f,!1,!1),f.stateNode=m;e:{switch(de=Ft(N,E),N){case"dialog":bn("cancel",m),bn("close",m),B=E;break;case"iframe":case"object":case"embed":bn("load",m),B=E;break;case"video":case"audio":for(B=0;B<El.length;B++)bn(El[B],m);B=E;break;case"source":bn("error",m),B=E;break;case"img":case"image":case"link":bn("error",m),bn("load",m),B=E;break;case"details":bn("toggle",m),B=E;break;case"input":ce(m,E),B=be(m,E),bn("invalid",m);break;case"option":B=E;break;case"select":m._wrapperState={wasMultiple:!!E.multiple},B=ee({},E,{value:void 0}),bn("invalid",m);break;case"textarea":ae(m,E),B=J(m,E),bn("invalid",m);break;default:B=E}pt(N,B),Ie=B;for(W in Ie)if(Ie.hasOwnProperty(W)){var Xe=Ie[W];W==="style"?Qt(m,Xe):W==="dangerouslySetInnerHTML"?(Xe=Xe?Xe.__html:void 0,Xe!=null&&We(m,Xe)):W==="children"?typeof Xe=="string"?(N!=="textarea"||Xe!=="")&&St(m,Xe):typeof Xe=="number"&&St(m,""+Xe):W!=="suppressContentEditableWarning"&&W!=="suppressHydrationWarning"&&W!=="autoFocus"&&(a.hasOwnProperty(W)?Xe!=null&&W==="onScroll"&&bn("scroll",m):Xe!=null&&C(m,W,Xe,de))}switch(N){case"input":se(m),$e(m,E,!1);break;case"textarea":se(m),Qe(m);break;case"option":E.value!=null&&m.setAttribute("value",""+ue(E.value));break;case"select":m.multiple=!!E.multiple,W=E.value,W!=null?Be(m,!!E.multiple,W,!1):E.defaultValue!=null&&Be(m,!!E.multiple,E.defaultValue,!0);break;default:typeof B.onClick=="function"&&(m.onclick=cd)}switch(N){case"button":case"input":case"select":case"textarea":E=!!E.autoFocus;break e;case"img":E=!0;break e;default:E=!1}}E&&(f.flags|=4)}f.ref!==null&&(f.flags|=512,f.flags|=2097152)}return md(f),null;case 6:if(m&&f.stateNode!=null)yL(m,f,m.memoizedProps,E);else{if(typeof E!="string"&&f.stateNode===null)throw Error(r(166));if(N=iu(cm.current),iu(Rd.current),Uc(f)){if(E=f.stateNode,N=f.memoizedProps,E[Il]=f,(W=E.nodeValue!==N)&&(m=Li,m!==null))switch(m.tag){case 3:Ih(E.nodeValue,N,(m.mode&1)!==0);break;case 5:m.memoizedProps.suppressHydrationWarning!==!0&&Ih(E.nodeValue,N,(m.mode&1)!==0)}W&&(f.flags|=4)}else E=(N.nodeType===9?N:N.ownerDocument).createTextNode(E),E[Il]=f,f.stateNode=E}return md(f),null;case 13:if(Zn(ci),E=f.memoizedState,m===null||m.memoizedState!==null&&m.memoizedState.dehydrated!==null){if(aa&&fi!==null&&(f.mode&1)!==0&&(f.flags&128)===0)yv(),qm(),f.flags|=98560,W=!1;else if(W=Uc(f),E!==null&&E.dehydrated!==null){if(m===null){if(!W)throw Error(r(318));if(W=f.memoizedState,W=W!==null?W.dehydrated:null,!W)throw Error(r(317));W[Il]=f}else qm(),(f.flags&128)===0&&(f.memoizedState=null),f.flags|=4;md(f),W=!1}else eo!==null&&(A2(eo),eo=null),W=!0;if(!W)return f.flags&65536?f:null}return(f.flags&128)!==0?(f.lanes=N,f):(E=E!==null,E!==(m!==null&&m.memoizedState!==null)&&E&&(f.child.flags|=8192,(f.mode&1)!==0&&(m===null||(ci.current&1)!==0?$l===0&&($l=3):I2())),f.updateQueue!==null&&(f.flags|=4),md(f),null);case 4:return kp(),b2(m,f),m===null&&ld(f.stateNode.containerInfo),md(f),null;case 10:return Of(f.type._context),md(f),null;case 17:return li(f.type)&&Fc(),md(f),null;case 19:if(Zn(ci),W=f.memoizedState,W===null)return md(f),null;if(E=(f.flags&128)!==0,de=W.rendering,de===null)if(E)nw(W,!1);else{if($l!==0||m!==null&&(m.flags&128)!==0)for(m=f.child;m!==null;){if(de=_p(m),de!==null){for(f.flags|=128,nw(W,!1),E=de.updateQueue,E!==null&&(f.updateQueue=E,f.flags|=4),f.subtreeFlags=0,E=N,N=f.child;N!==null;)W=N,m=E,W.flags&=14680066,de=W.alternate,de===null?(W.childLanes=0,W.lanes=m,W.child=null,W.subtreeFlags=0,W.memoizedProps=null,W.memoizedState=null,W.updateQueue=null,W.dependencies=null,W.stateNode=null):(W.childLanes=de.childLanes,W.lanes=de.lanes,W.child=de.child,W.subtreeFlags=0,W.deletions=null,W.memoizedProps=de.memoizedProps,W.memoizedState=de.memoizedState,W.updateQueue=de.updateQueue,W.type=de.type,m=de.dependencies,W.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext}),N=N.sibling;return hn(ci,ci.current&1|2),f.child}m=m.sibling}W.tail!==null&&Rt()>kv&&(f.flags|=128,E=!0,nw(W,!1),f.lanes=4194304)}else{if(!E)if(m=_p(de),m!==null){if(f.flags|=128,E=!0,N=m.updateQueue,N!==null&&(f.updateQueue=N,f.flags|=4),nw(W,!0),W.tail===null&&W.tailMode==="hidden"&&!de.alternate&&!aa)return md(f),null}else 2*Rt()-W.renderingStartTime>kv&&N!==1073741824&&(f.flags|=128,E=!0,nw(W,!1),f.lanes=4194304);W.isBackwards?(de.sibling=f.child,f.child=de):(N=W.last,N!==null?N.sibling=de:f.child=de,W.last=de)}return W.tail!==null?(f=W.tail,W.rendering=f,W.tail=f.sibling,W.renderingStartTime=Rt(),f.sibling=null,N=ci.current,hn(ci,E?N&1|2:N&1),f):(md(f),null);case 22:case 23:return R2(),E=f.memoizedState!==null,m!==null&&m.memoizedState!==null!==E&&(f.flags|=8192),E&&(f.mode&1)!==0?(Fu&1073741824)!==0&&(md(f),f.subtreeFlags&6&&(f.flags|=8192)):md(f),null;case 24:return null;case 25:return null}throw Error(r(156,f.tag))}function goe(m,f){switch(wn(f),f.tag){case 1:return li(f.type)&&Fc(),m=f.flags,m&65536?(f.flags=m&-65537|128,f):null;case 3:return kp(),Zn(Aa),Zn(Sa),Mo(),m=f.flags,(m&65536)!==0&&(m&128)===0?(f.flags=m&-65537|128,f):null;case 5:return Df(f),null;case 13:if(Zn(ci),m=f.memoizedState,m!==null&&m.dehydrated!==null){if(f.alternate===null)throw Error(r(340));qm()}return m=f.flags,m&65536?(f.flags=m&-65537|128,f):null;case 19:return Zn(ci),null;case 4:return kp(),null;case 10:return Of(f.type._context),null;case 22:case 23:return R2(),null;case 24:return null;default:return null}}var RN=!1,hd=!1,xoe=typeof WeakSet=="function"?WeakSet:Set,lr=null;function Sv(m,f){var N=m.ref;if(N!==null)if(typeof N=="function")try{N(null)}catch(E){Ro(m,f,E)}else N.current=null}function w2(m,f,N){try{N()}catch(E){Ro(m,f,E)}}var bL=!1;function voe(m,f){if(Oh=ja,m=Ns(),or(m)){if("selectionStart"in m)var N={start:m.selectionStart,end:m.selectionEnd};else e:{N=(N=m.ownerDocument)&&N.defaultView||window;var E=N.getSelection&&N.getSelection();if(E&&E.rangeCount!==0){N=E.anchorNode;var B=E.anchorOffset,W=E.focusNode;E=E.focusOffset;try{N.nodeType,W.nodeType}catch{N=null;break e}var de=0,Ie=-1,Xe=-1,Pt=0,as=0,cs=m,ss=null;t:for(;;){for(var er;cs!==N||B!==0&&cs.nodeType!==3||(Ie=de+B),cs!==W||E!==0&&cs.nodeType!==3||(Xe=de+E),cs.nodeType===3&&(de+=cs.nodeValue.length),(er=cs.firstChild)!==null;)ss=cs,cs=er;for(;;){if(cs===m)break t;if(ss===N&&++Pt===B&&(Ie=de),ss===W&&++as===E&&(Xe=de),(er=cs.nextSibling)!==null)break;cs=ss,ss=cs.parentNode}cs=er}N=Ie===-1||Xe===-1?null:{start:Ie,end:Xe}}else N=null}N=N||{start:0,end:0}}else N=null;for(Zi={focusedElem:m,selectionRange:N},ja=!1,lr=f;lr!==null;)if(f=lr,m=f.child,(f.subtreeFlags&1028)!==0&&m!==null)m.return=f,lr=m;else for(;lr!==null;){f=lr;try{var pr=f.alternate;if((f.flags&1024)!==0)switch(f.tag){case 0:case 11:case 15:break;case 1:if(pr!==null){var yr=pr.memoizedProps,Qo=pr.memoizedState,xt=f.stateNode,at=xt.getSnapshotBeforeUpdate(f.elementType===f.type?yr:Me(f.type,yr),Qo);xt.__reactInternalSnapshotBeforeUpdate=at}break;case 3:var wt=f.stateNode.containerInfo;
vendor: 10,369 bytes, line 8
8wt.nodeType===1?wt.textContent="":wt.nodeType===9&&wt.documentElement&&wt.removeChild(wt.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(ws){Ro(f,f.return,ws)}if(m=f.sibling,m!==null){m.return=f.return,lr=m;break}lr=f.return}return pr=bL,bL=!1,pr}function aw(m,f,N){var E=f.updateQueue;if(E=E!==null?E.lastEffect:null,E!==null){var B=E=E.next;do{if((B.tag&m)===m){var W=B.destroy;B.destroy=void 0,W!==void 0&&w2(f,N,W)}B=B.next}while(B!==E)}}function IN(m,f){if(f=f.updateQueue,f=f!==null?f.lastEffect:null,f!==null){var N=f=f.next;do{if((N.tag&m)===m){var E=N.create;N.destroy=E()}N=N.next}while(N!==f)}}function j2(m){var f=m.ref;if(f!==null){var N=m.stateNode;m.tag,m=N,typeof f=="function"?f(m):f.current=m}}function wL(m){var f=m.alternate;f!==null&&(m.alternate=null,wL(f)),m.child=null,m.deletions=null,m.sibling=null,m.tag===5&&(f=m.stateNode,f!==null&&(delete f[Il],delete f[Go],delete f[Ol],delete f[Af],delete f[gl])),m.stateNode=null,m.return=null,m.dependencies=null,m.memoizedProps=null,m.memoizedState=null,m.pendingProps=null,m.stateNode=null,m.updateQueue=null}function jL(m){return m.tag===5||m.tag===3||m.tag===4}function NL(m){e:for(;;){for(;m.sibling===null;){if(m.return===null||jL(m.return))return null;m=m.return}for(m.sibling.return=m.return,m=m.sibling;m.tag!==5&&m.tag!==6&&m.tag!==18;){if(m.flags&2||m.child===null||m.tag===4)continue e;m.child.return=m,m=m.child}if(!(m.flags&2))return m.stateNode}}function N2(m,f,N){var E=m.tag;if(E===5||E===6)m=m.stateNode,f?N.nodeType===8?N.parentNode.insertBefore(m,f):N.insertBefore(m,f):(N.nodeType===8?(f=N.parentNode,f.insertBefore(m,N)):(f=N,f.appendChild(m)),N=N._reactRootContainer,N!=null||f.onclick!==null||(f.onclick=cd));else if(E!==4&&(m=m.child,m!==null))for(N2(m,f,N),m=m.sibling;m!==null;)N2(m,f,N),m=m.sibling}function S2(m,f,N){var E=m.tag;if(E===5||E===6)m=m.stateNode,f?N.insertBefore(m,f):N.appendChild(m);else if(E!==4&&(m=m.child,m!==null))for(S2(m,f,N),m=m.sibling;m!==null;)S2(m,f,N),m=m.sibling}var zc=null,th=!1;function Uf(m,f,N){for(N=N.child;N!==null;)SL(m,f,N),N=N.sibling}function SL(m,f,N){if(Os&&typeof Os.onCommitFiberUnmount=="function")try{Os.onCommitFiberUnmount(Sr,N)}catch{}switch(N.tag){case 5:hd||Sv(N,f);case 6:var E=zc,B=th;zc=null,Uf(m,f,N),zc=E,th=B,zc!==null&&(th?(m=zc,N=N.stateNode,m.nodeType===8?m.parentNode.removeChild(N):m.removeChild(N)):zc.removeChild(N.stateNode));break;case 18:zc!==null&&(th?(m=zc,N=N.stateNode,m.nodeType===8?su(m.parentNode,N):m.nodeType===1&&su(m,N),Ti(m)):su(zc,N.stateNode));break;case 4:E=zc,B=th,zc=N.stateNode.containerInfo,th=!0,Uf(m,f,N),zc=E,th=B;break;case 0:case 11:case 14:case 15:if(!hd&&(E=N.updateQueue,E!==null&&(E=E.lastEffect,E!==null))){B=E=E.next;do{var W=B,de=W.destroy;W=W.tag,de!==void 0&&((W&2)!==0||(W&4)!==0)&&w2(N,f,de),B=B.next}while(B!==E)}Uf(m,f,N);break;case 1:if(!hd&&(Sv(N,f),E=N.stateNode,typeof E.componentWillUnmount=="function"))try{E.props=N.memoizedProps,E.state=N.memoizedState,E.componentWillUnmount()}catch(Ie){Ro(N,f,Ie)}Uf(m,f,N);break;case 21:Uf(m,f,N);break;case 22:N.mode&1?(hd=(E=hd)||N.memoizedState!==null,Uf(m,f,N),hd=E):Uf(m,f,N);break;default:Uf(m,f,N)}}function CL(m){var f=m.updateQueue;if(f!==null){m.updateQueue=null;var N=m.stateNode;N===null&&(N=m.stateNode=new xoe),f.forEach(function(E){var B=_oe.bind(null,m,E);N.has(E)||(N.add(E),E.then(B,B))})}}function sh(m,f){var N=f.deletions;if(N!==null)for(var E=0;E<N.length;E++){var B=N[E];try{var W=m,de=f,Ie=de;e:for(;Ie!==null;){switch(Ie.tag){case 5:zc=Ie.stateNode,th=!1;break e;case 3:zc=Ie.stateNode.containerInfo,th=!0;break e;case 4:zc=Ie.stateNode.containerInfo,th=!0;break e}Ie=Ie.return}if(zc===null)throw Error(r(160));SL(W,de,B),zc=null,th=!1;var Xe=B.alternate;Xe!==null&&(Xe.return=null),B.return=null}catch(Pt){Ro(B,f,Pt)}}if(f.subtreeFlags&12854)for(f=f.child;f!==null;)kL(f,m),f=f.sibling}function kL(m,f){var N=m.alternate,E=m.flags;switch(m.tag){case 0:case 11:case 14:case 15:if(sh(f,m),Bh(m),E&4){try{aw(3,m,m.return),IN(3,m)}catch(yr){Ro(m,m.return,yr)}try{aw(5,m,m.return)}catch(yr){Ro(m,m.return,yr)}}break;case 1:sh(f,m),Bh(m),E&512&&N!==null&&Sv(N,N.return);break;case 5:if(sh(f,m),Bh(m),E&512&&N!==null&&Sv(N,N.return),m.flags&32){var B=m.stateNode;try{St(B,"")}catch(yr){Ro(m,m.return,yr)}}if(E&4&&(B=m.stateNode,B!=null)){var W=m.memoizedProps,de=N!==null?N.memoizedProps:W,Ie=m.type,Xe=m.updateQueue;if(m.updateQueue=null,Xe!==null)try{Ie==="input"&&W.type==="radio"&&W.name!=null&&Pe(B,W),Ft(Ie,de);var Pt=Ft(Ie,W);for(de=0;de<Xe.length;de+=2){var as=Xe[de],cs=Xe[de+1];as==="style"?Qt(B,cs):as==="dangerouslySetInnerHTML"?We(B,cs):as==="children"?St(B,cs):C(B,as,cs,Pt)}switch(Ie){case"input":et(B,W);break;case"textarea":we(B,W);break;case"select":var ss=B._wrapperState.wasMultiple;B._wrapperState.wasMultiple=!!W.multiple;var er=W.value;er!=null?Be(B,!!W.multiple,er,!1):ss!==!!W.multiple&&(W.defaultValue!=null?Be(B,!!W.multiple,W.defaultValue,!0):Be(B,!!W.multiple,W.multiple?[]:"",!1))}B[Go]=W}catch(yr){Ro(m,m.return,yr)}}break;case 6:if(sh(f,m),Bh(m),E&4){if(m.stateNode===null)throw Error(r(162));B=m.stateNode,W=m.memoizedProps;try{B.nodeValue=W}catch(yr){Ro(m,m.return,yr)}}break;case 3:if(sh(f,m),Bh(m),E&4&&N!==null&&N.memoizedState.isDehydrated)try{Ti(f.containerInfo)}catch(yr){Ro(m,m.return,yr)}break;case 4:sh(f,m),Bh(m);break;case 13:sh(f,m),Bh(m),B=m.child,B.flags&8192&&(W=B.memoizedState!==null,B.stateNode.isHidden=W,!W||B.alternate!==null&&B.alternate.memoizedState!==null||(_2=Rt())),E&4&&CL(m);break;case 22:if(as=N!==null&&N.memoizedState!==null,m.mode&1?(hd=(Pt=hd)||as,sh(f,m),hd=Pt):sh(f,m),Bh(m),E&8192){if(Pt=m.memoizedState!==null,(m.stateNode.isHidden=Pt)&&!as&&(m.mode&1)!==0)for(lr=m,as=m.child;as!==null;){for(cs=lr=as;lr!==null;){switch(ss=lr,er=ss.child,ss.tag){case 0:case 11:case 14:case 15:aw(4,ss,ss.return);break;case 1:Sv(ss,ss.return);var pr=ss.stateNode;if(typeof pr.componentWillUnmount=="function"){E=ss,N=ss.return;try{f=E,pr.props=f.memoizedProps,pr.state=f.memoizedState,pr.componentWillUnmount()}catch(yr){Ro(E,N,yr)}}break;case 5:Sv(ss,ss.return);break;case 22:if(ss.memoizedState!==null){EL(cs);continue}}er!==null?(er.return=ss,lr=er):EL(cs)}as=as.sibling}e:for(as=null,cs=m;;){if(cs.tag===5){if(as===null){as=cs;try{B=cs.stateNode,Pt?(W=B.style,typeof W.setProperty=="function"?W.setProperty("display","none","important"):W.display="none"):(Ie=cs.stateNode,Xe=cs.memoizedProps.style,de=Xe!=null&&Xe.hasOwnProperty("display")?Xe.display:null,Ie.style.display=dt("display",de))}catch(yr){Ro(m,m.return,yr)}}}else if(cs.tag===6){if(as===null)try{cs.stateNode.nodeValue=Pt?"":cs.memoizedProps}catch(yr){Ro(m,m.return,yr)}}else if((cs.tag!==22&&cs.tag!==23||cs.memoizedState===null||cs===m)&&cs.child!==null){cs.child.return=cs,cs=cs.child;continue}if(cs===m)break e;for(;cs.sibling===null;){if(cs.return===null||cs.return===m)break e;as===cs&&(as=null),cs=cs.return}as===cs&&(as=null),cs.sibling.return=cs.return,cs=cs.sibling}}break;case 19:sh(f,m),Bh(m),E&4&&CL(m);break;case 21:break;default:sh(f,m),Bh(m)}}function Bh(m){var f=m.flags;if(f&2){try{e:{for(var N=m.return;N!==null;){if(jL(N)){var E=N;break e}N=N.return}throw Error(r(160))}switch(E.tag){case 5:var B=E.stateNode;E.flags&32&&(St(B,""),E.flags&=-33);var W=NL(m);S2(m,W,B);break;case 3:case 4:var de=E.stateNode.containerInfo,Ie=NL(m);N2(m,Ie,de);break;default:throw Error(r(161))}}catch(Xe){Ro(m,m.return,Xe)}m.flags&=-3}f&4096&&(m.flags&=-4097)}function yoe(m,f,N){lr=m,_L(m)}function _L(m,f,N){for(var E=(m.mode&1)!==0;lr!==null;){var B=lr,W=B.child;if(B.tag===22&&E){var de=B.memoizedState!==null||RN;if(!de){var Ie=B.alternate,Xe=Ie!==null&&Ie.memoizedState!==null||hd;Ie=RN;var Pt=hd;if(RN=de,(hd=Xe)&&!Pt)for(lr=B;lr!==null;)de=lr,Xe=de.child,de.tag===22&&de.memoizedState!==null?TL(B):Xe!==null?(Xe.return=de,lr=Xe):TL(B);for(;W!==null;)lr=W,_L(W),W=W.sibling;lr=B,RN=Ie,hd=Pt}PL(m)}else(B.subtreeFlags&8772)!==0&&W!==null?(W.return=B,lr=W):PL(m)}}function PL(m){for(;lr!==null;){var f=lr;if((f.flags&8772)!==0){var N=f.alternate;try{if((f.flags&8772)!==0)switch(f.tag){case 0:case 11:case 15:hd||IN(5,f);break;case 1:var E=f.stateNode;if(f.flags&4&&!hd)if(N===null)E.componentDidMount();else{var B=f.elementType===f.type?N.memoizedProps:Me(f.type,N.memoizedProps);E.componentDidUpdate(B,N.memoizedState,E.__reactInternalSnapshotBeforeUpdate)}var W=f.updateQueue;W!==null&&Cp(f,W,E);break;case 3:var de=f.updateQueue;if(de!==null){if(N=null,f.child!==null)switch(f.child.tag){case 5:N=f.child.stateNode;break;case 1:N=f.child.stateNode}Cp(f,de,N)}break;case 5:var Ie=f.stateNode;if(N===null&&f.flags&4){N=Ie;var Xe=f.memoizedProps;switch(f.type){case"button":case"input":case"select":case"textarea":Xe.autoFocus&&N.focus();break;case"img":Xe.src&&(N.src=Xe.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(f.memoizedState===null){var Pt=f.alternate;if(Pt!==null){var as=Pt.memoizedState;if(as!==null){var cs=as.dehydrated;cs!==null&&Ti(cs)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}hd||f.flags&512&&j2(f)}catch(ss){Ro(f,f.return,ss)}}if(f===m){lr=null;break}if(N=f.sibling,N!==null){N.return=f.return,lr=N;break}lr=f.return}}function EL(m){for(;lr!==null;){var f=lr;if(f===m){lr=null;break}var N=f.sibling;if(N!==null){N.return=f.return,lr=N;break}lr=f.return}}function TL(m){for(;lr!==null;){var f=lr;try{switch(f.tag){case 0:case 11:case 15:var N=f.return;try{IN(4,f)}catch(Xe){Ro(f,N,Xe)}break;case 1:var E=f.stateNode;if(typeof E.componentDidMount=="function"){var B=f.return;try{E.componentDidMount()}catch(Xe){Ro(f,B,Xe)}}var W=f.return;try{j2(f)}catch(Xe){Ro(f,W,Xe)}break;case 5:var de=f.return;try{j2(f)}catch(Xe){Ro(f,de,Xe)}}}catch(Xe){Ro(f,f.return,Xe)}if(f===m){lr=null;break}var Ie=f.sibling;if(Ie!==null){Ie.return=f.return,lr=Ie;break}lr=f.return}}var boe=Math.ceil,ON=k.ReactCurrentDispatcher,C2=k.ReactCurrentOwner,um=k.ReactCurrentBatchConfig,Ca=0,lc=null,yl=null,Hc=0,Fu=0,Cv=fo(0),$l=0,iw=null,nx=0,DN=0,k2=0,ow=null,cu=null,_2=0,kv=1/0,Mp=null,LN=!1,P2=null,zf=null,$N=!1,Hf=null,FN=0,lw=0,E2=null,BN=-1,UN=0;function Dd(){return(Ca&6)!==0?Rt():BN!==-1?BN:BN=Rt()}function qf(m){return(m.mode&1)===0?1:(Ca&2)!==0&&Hc!==0?Hc&-Hc:Kg.transition!==null?(UN===0&&(UN=ku()),UN):(m=Vr,m!==0||(m=window.event,m=m===void 0?16:zn(m.type)),m)}
vendor: 8,754 bytes, line 8
8function rh(m,f,N,E){if(50<lw)throw lw=0,E2=null,Error(r(185));lo(m,N,E),((Ca&2)===0||m!==lc)&&(m===lc&&((Ca&2)===0&&(DN|=N),$l===4&&Vf(m,Hc)),du(m,E),N===1&&Ca===0&&(f.mode&1)===0&&(kv=Rt()+500,us&&ms()))}function du(m,f){var N=m.callbackNode;Co(m,f);var E=Dr(m,m===lc?Hc:0);if(E===0)N!==null&&Ir(N),m.callbackNode=null,m.callbackPriority=0;else if(f=E&-E,m.callbackPriority!==f){if(N!=null&&Ir(N),f===1)m.tag===0?js(ML.bind(null,m)):is(ML.bind(null,m)),yp(function(){(Ca&6)===0&&ms()}),N=null;else{switch(Nc(E)){case 1:N=Ht;break;case 4:N=vr;break;case 16:N=mn;break;case 536870912:N=Sn;break;default:N=mn}N=BL(N,AL.bind(null,m))}m.callbackPriority=f,m.callbackNode=N}}function AL(m,f){if(BN=-1,UN=0,(Ca&6)!==0)throw Error(r(327));var N=m.callbackNode;if(_v()&&m.callbackNode!==N)return null;var E=Dr(m,m===lc?Hc:0);if(E===0)return null;if((E&30)!==0||(E&m.expiredLanes)!==0||f)f=zN(m,E);else{f=E;var B=Ca;Ca|=2;var W=IL();(lc!==m||Hc!==f)&&(Mp=null,kv=Rt()+500,ix(m,f));do try{Noe();break}catch(Ie){RL(m,Ie)}while(!0);Yg(),ON.current=W,Ca=B,yl!==null?f=0:(lc=null,Hc=0,f=$l)}if(f!==0){if(f===2&&(B=Oa(m),B!==0&&(E=B,f=T2(m,B))),f===1)throw N=iw,ix(m,0),Vf(m,E),du(m,Rt()),N;if(f===6)Vf(m,E);else{if(B=m.current.alternate,(E&30)===0&&!woe(B)&&(f=zN(m,E),f===2&&(W=Oa(m),W!==0&&(E=W,f=T2(m,W))),f===1))throw N=iw,ix(m,0),Vf(m,E),du(m,Rt()),N;switch(m.finishedWork=B,m.finishedLanes=E,f){case 0:case 1:throw Error(r(345));case 2:ox(m,cu,Mp);break;case 3:if(Vf(m,E),(E&130023424)===E&&(f=_2+500-Rt(),10<f)){if(Dr(m,0)!==0)break;if(B=m.suspendedLanes,(B&E)!==E){Dd(),m.pingedLanes|=m.suspendedLanes&B;break}m.timeoutHandle=Mu(ox.bind(null,m,cu,Mp),f);break}ox(m,cu,Mp);break;case 4:if(Vf(m,E),(E&4194240)===E)break;for(f=m.eventTimes,B=-1;0<E;){var de=31-nr(E);W=1<<de,de=f[de],de>B&&(B=de),E&=~W}if(E=B,E=Rt()-E,E=(120>E?120:480>E?480:1080>E?1080:1920>E?1920:3e3>E?3e3:4320>E?4320:1960*boe(E/1960))-E,10<E){m.timeoutHandle=Mu(ox.bind(null,m,cu,Mp),E);break}ox(m,cu,Mp);break;case 5:ox(m,cu,Mp);break;default:throw Error(r(329))}}}return du(m,Rt()),m.callbackNode===N?AL.bind(null,m):null}function T2(m,f){var N=ow;return m.current.memoizedState.isDehydrated&&(ix(m,f).flags|=256),m=zN(m,f),m!==2&&(f=cu,cu=N,f!==null&&A2(f)),m}function A2(m){cu===null?cu=m:cu.push.apply(cu,m)}function woe(m){for(var f=m;;){if(f.flags&16384){var N=f.updateQueue;if(N!==null&&(N=N.stores,N!==null))for(var E=0;E<N.length;E++){var B=N[E],W=B.getSnapshot;B=B.value;try{if(!qt(W(),B))return!1}catch{return!1}}}if(N=f.child,f.subtreeFlags&16384&&N!==null)N.return=f,f=N;else{if(f===m)break;for(;f.sibling===null;){if(f.return===null||f.return===m)return!0;f=f.return}f.sibling.return=f.return,f=f.sibling}}return!0}function Vf(m,f){for(f&=~k2,f&=~DN,m.suspendedLanes|=f,m.pingedLanes&=~f,m=m.expirationTimes;0<f;){var N=31-nr(f),E=1<<N;m[N]=-1,f&=~E}}function ML(m){if((Ca&6)!==0)throw Error(r(327));_v();var f=Dr(m,0);if((f&1)===0)return du(m,Rt()),null;var N=zN(m,f);if(m.tag!==0&&N===2){var E=Oa(m);E!==0&&(f=E,N=T2(m,E))}if(N===1)throw N=iw,ix(m,0),Vf(m,f),du(m,Rt()),N;if(N===6)throw Error(r(345));return m.finishedWork=m.current.alternate,m.finishedLanes=f,ox(m,cu,Mp),du(m,Rt()),null}function M2(m,f){var N=Ca;Ca|=1;try{return m(f)}finally{Ca=N,Ca===0&&(kv=Rt()+500,us&&ms())}}function ax(m){Hf!==null&&Hf.tag===0&&(Ca&6)===0&&_v();var f=Ca;Ca|=1;var N=um.transition,E=Vr;try{if(um.transition=null,Vr=1,m)return m()}finally{Vr=E,um.transition=N,Ca=f,(Ca&6)===0&&ms()}}function R2(){Fu=Cv.current,Zn(Cv)}function ix(m,f){m.finishedWork=null,m.finishedLanes=0;var N=m.timeoutHandle;if(N!==-1&&(m.timeoutHandle=-1,Oc(N)),yl!==null)for(N=yl.return;N!==null;){var E=N;switch(wn(E),E.tag){case 1:E=E.type.childContextTypes,E!=null&&Fc();break;case 3:kp(),Zn(Aa),Zn(Sa),Mo();break;case 5:Df(E);break;case 4:kp();break;case 13:Zn(ci);break;case 19:Zn(ci);break;case 10:Of(E.type._context);break;case 22:case 23:R2()}N=N.return}if(lc=m,yl=m=Wf(m.current,null),Hc=Fu=f,$l=0,iw=null,k2=DN=nx=0,cu=ow=null,om!==null){for(f=0;f<om.length;f++)if(N=om[f],E=N.interleaved,E!==null){N.interleaved=null;var B=E.next,W=N.pending;if(W!==null){var de=W.next;W.next=B,E.next=de}N.pending=E}om=null}return m}function RL(m,f){do{var N=yl;try{if(Yg(),ou.current=X,Lf){for(var E=ca.memoizedState;E!==null;){var B=E.queue;B!==null&&(B.pending=null),E=E.next}Lf=!1}if($h=0,$i=to=ca=null,I=!1,ie=0,C2.current=null,N===null||N.return===null){$l=1,iw=f,yl=null;break}e:{var W=m,de=N.return,Ie=N,Xe=f;if(f=Hc,Ie.flags|=32768,Xe!==null&&typeof Xe=="object"&&typeof Xe.then=="function"){var Pt=Xe,as=Ie,cs=as.tag;if((as.mode&1)===0&&(cs===0||cs===11||cs===15)){var ss=as.alternate;ss?(as.updateQueue=ss.updateQueue,as.memoizedState=ss.memoizedState,as.lanes=ss.lanes):(as.updateQueue=null,as.memoizedState=null)}var er=Od(de);if(er!==null){er.flags&=-257,Jm(er,de,Ie,W,f),er.mode&1&&dm(W,Pt,f),f=er,Xe=Pt;var pr=f.updateQueue;if(pr===null){var yr=new Set;yr.add(Xe),f.updateQueue=yr}else pr.add(Xe);break e}else{if((f&1)===0){dm(W,Pt,f),I2();break e}Xe=Error(r(426))}}else if(aa&&Ie.mode&1){var Qo=Od(de);if(Qo!==null){(Qo.flags&65536)===0&&(Qo.flags|=256),Jm(Qo,de,Ie,W,f),Mf(jn(Xe,Ie));break e}}W=Xe=jn(Xe,Ie),$l!==4&&($l=2),ow===null?ow=[W]:ow.push(W),W=de;do{switch(W.tag){case 3:W.flags|=65536,f&=-f,W.lanes|=f;var xt=xl(W,Xe,f);lm(W,xt);break e;case 1:Ie=Xe;var at=W.type,wt=W.stateNode;if((W.flags&128)===0&&(typeof at.getDerivedStateFromError=="function"||wt!==null&&typeof wt.componentDidCatch=="function"&&(zf===null||!zf.has(wt)))){W.flags|=65536,f&=-f,W.lanes|=f;var ws=lu(W,Ie,f);lm(W,ws);break e}}W=W.return}while(W!==null)}DL(N)}catch(jr){f=jr,yl===N&&N!==null&&(yl=N=N.return);continue}break}while(!0)}function IL(){var m=ON.current;return ON.current=X,m===null?X:m}function I2(){($l===0||$l===3||$l===2)&&($l=4),lc===null||(nx&268435455)===0&&(DN&268435455)===0||Vf(lc,Hc)}function zN(m,f){var N=Ca;Ca|=2;var E=IL();(lc!==m||Hc!==f)&&(Mp=null,ix(m,f));do try{joe();break}catch(B){RL(m,B)}while(!0);if(Yg(),Ca=N,ON.current=E,yl!==null)throw Error(r(261));return lc=null,Hc=0,$l}function joe(){for(;yl!==null;)OL(yl)}function Noe(){for(;yl!==null&&!Hr();)OL(yl)}function OL(m){var f=FL(m.alternate,m,Fu);m.memoizedProps=m.pendingProps,f===null?DL(m):yl=f,C2.current=null}function DL(m){var f=m;do{var N=f.alternate;if(m=f.return,(f.flags&32768)===0){if(N=foe(N,f,Fu),N!==null){yl=N;return}}else{if(N=goe(N,f),N!==null){N.flags&=32767,yl=N;return}if(m!==null)m.flags|=32768,m.subtreeFlags=0,m.deletions=null;else{$l=6,yl=null;return}}if(f=f.sibling,f!==null){yl=f;return}yl=f=m}while(f!==null);$l===0&&($l=5)}function ox(m,f,N){var E=Vr,B=um.transition;try{um.transition=null,Vr=1,Soe(m,f,N,E)}finally{um.transition=B,Vr=E}return null}function Soe(m,f,N,E){do _v();while(Hf!==null);if((Ca&6)!==0)throw Error(r(327));N=m.finishedWork;var B=m.finishedLanes;if(N===null)return null;if(m.finishedWork=null,m.finishedLanes=0,N===m.current)throw Error(r(177));m.callbackNode=null,m.callbackPriority=0;var W=N.lanes|N.childLanes;if(Cn(m,W),m===lc&&(yl=lc=null,Hc=0),(N.subtreeFlags&2064)===0&&(N.flags&2064)===0||$N||($N=!0,BL(mn,function(){return _v(),null})),W=(N.flags&15990)!==0,(N.subtreeFlags&15990)!==0||W){W=um.transition,um.transition=null;var de=Vr;Vr=1;var Ie=Ca;Ca|=4,C2.current=null,voe(m,N),kL(N,m),os(Zi),ja=!!Oh,Zi=Oh=null,m.current=N,yoe(N),lt(),Ca=Ie,Vr=de,um.transition=W}else m.current=N;if($N&&($N=!1,Hf=m,FN=B),W=m.pendingLanes,W===0&&(zf=null),ur(N.stateNode),du(m,Rt()),f!==null)for(E=m.onRecoverableError,N=0;N<f.length;N++)B=f[N],E(B.value,{componentStack:B.stack,digest:B.digest});if(LN)throw LN=!1,m=P2,P2=null,m;return(FN&1)!==0&&m.tag!==0&&_v(),W=m.pendingLanes,(W&1)!==0?m===E2?lw++:(lw=0,E2=m):lw=0,ms(),null}function _v(){if(Hf!==null){var m=Nc(FN),f=um.transition,N=Vr;try{if(um.transition=null,Vr=16>m?16:m,Hf===null)var E=!1;else{if(m=Hf,Hf=null,FN=0,(Ca&6)!==0)throw Error(r(331));var B=Ca;for(Ca|=4,lr=m.current;lr!==null;){var W=lr,de=W.child;if((lr.flags&16)!==0){var Ie=W.deletions;if(Ie!==null){for(var Xe=0;Xe<Ie.length;Xe++){var Pt=Ie[Xe];for(lr=Pt;lr!==null;){var as=lr;switch(as.tag){case 0:case 11:case 15:aw(8,as,W)}var cs=as.child;if(cs!==null)cs.return=as,lr=cs;else for(;lr!==null;){as=lr;var ss=as.sibling,er=as.return;if(wL(as),as===Pt){lr=null;break}if(ss!==null){ss.return=er,lr=ss;break}lr=er}}}var pr=W.alternate;if(pr!==null){var yr=pr.child;if(yr!==null){pr.child=null;do{var Qo=yr.sibling;yr.sibling=null,yr=Qo}while(yr!==null)}}lr=W}}if((W.subtreeFlags&2064)!==0&&de!==null)de.return=W,lr=de;else e:for(;lr!==null;){if(W=lr,(W.flags&2048)!==0)switch(W.tag){case 0:case 11:case 15:aw(9,W,W.return)}var xt=W.sibling;if(xt!==null){xt.return=W.return,lr=xt;break e}lr=W.return}}var at=m.current;for(lr=at;lr!==null;){de=lr;var wt=de.child;
vendor: 4,183 bytes, line 8
8if((de.subtreeFlags&2064)!==0&&wt!==null)wt.return=de,lr=wt;else e:for(de=at;lr!==null;){if(Ie=lr,(Ie.flags&2048)!==0)try{switch(Ie.tag){case 0:case 11:case 15:IN(9,Ie)}}catch(jr){Ro(Ie,Ie.return,jr)}if(Ie===de){lr=null;break e}var ws=Ie.sibling;if(ws!==null){ws.return=Ie.return,lr=ws;break e}lr=Ie.return}}if(Ca=B,ms(),Os&&typeof Os.onPostCommitFiberRoot=="function")try{Os.onPostCommitFiberRoot(Sr,m)}catch{}E=!0}return E}finally{Vr=N,um.transition=f}}return!1}function LL(m,f,N){f=jn(N,f),f=xl(m,f,1),m=$u(m,f,1),f=Dd(),m!==null&&(lo(m,1,f),du(m,f))}function Ro(m,f,N){if(m.tag===3)LL(m,m,N);else for(;f!==null;){if(f.tag===3){LL(f,m,N);break}else if(f.tag===1){var E=f.stateNode;if(typeof f.type.getDerivedStateFromError=="function"||typeof E.componentDidCatch=="function"&&(zf===null||!zf.has(E))){m=jn(N,m),m=lu(f,m,1),f=$u(f,m,1),m=Dd(),f!==null&&(lo(f,1,m),du(f,m));break}}f=f.return}}function Coe(m,f,N){var E=m.pingCache;E!==null&&E.delete(f),f=Dd(),m.pingedLanes|=m.suspendedLanes&N,lc===m&&(Hc&N)===N&&($l===4||$l===3&&(Hc&130023424)===Hc&&500>Rt()-_2?ix(m,0):k2|=N),du(m,f)}function $L(m,f){f===0&&((m.mode&1)===0?f=1:(f=vn,vn<<=1,(vn&130023424)===0&&(vn=4194304)));var N=Dd();m=nu(m,f),m!==null&&(lo(m,f,N),du(m,N))}function koe(m){var f=m.memoizedState,N=0;f!==null&&(N=f.retryLane),$L(m,N)}function _oe(m,f){var N=0;switch(m.tag){case 13:var E=m.stateNode,B=m.memoizedState;B!==null&&(N=B.retryLane);break;case 19:E=m.stateNode;break;default:throw Error(r(314))}E!==null&&E.delete(f),$L(m,N)}var FL;FL=function(m,f,N){if(m!==null)if(m.memoizedProps!==f.pendingProps||Aa.current)vl=!0;else{if((m.lanes&N)===0&&(f.flags&128)===0)return vl=!1,poe(m,f,N);vl=(m.flags&131072)!==0}else vl=!1,aa&&(f.flags&1048576)!==0&&am(f,Ka,f.index);switch(f.lanes=0,f.tag){case 2:var E=f.type;MN(m,f),m=f.pendingProps;var B=Dl(f,Sa.current);Gm(f,N),B=_s(null,f,E,m,B,N);var W=ks();return f.flags|=1,typeof B=="object"&&B!==null&&typeof B.render=="function"&&B.$$typeof===void 0?(f.tag=1,f.memoizedState=null,f.updateQueue=null,li(E)?(W=!0,Te(f)):W=!1,f.memoizedState=B.state!==null&&B.state!==void 0?B.state:null,Np(f),B.updater=ot,f.stateNode=B,B._reactInternals=f,hs(f,E,m,N),f=Nv(null,f,E,!0,W,N)):(f.tag=0,aa&&W&&Md(f),xo(null,f,B,N),f=f.child),f;case 16:E=f.elementType;e:{switch(MN(m,f),m=f.pendingProps,B=E._init,E=B(E._payload),f.type=E,B=f.tag=Eoe(E),m=Me(E,m),B){case 0:f=rw(null,f,E,m,N);break e;case 1:f=Fi(null,f,E,m,N);break e;case 11:f=Tp(null,f,E,m,N);break e;case 14:f=Fh(null,f,E,Me(E.type,m),N);break e}throw Error(r(306,E,""))}return f;case 0:return E=f.type,B=f.pendingProps,B=f.elementType===E?B:Me(E,B),rw(m,f,E,B,N);case 1:return E=f.type,B=f.pendingProps,B=f.elementType===E?B:Me(E,B),Fi(m,f,E,B,N);case 3:e:{if(mL(f),m===null)throw Error(r(387));E=f.pendingProps,W=f.memoizedState,B=W.element,Xg(m,f),Ym(f,E,null,N);var de=f.memoizedState;if(E=de.element,W.isDehydrated)if(W={element:E,isDehydrated:!1,cache:de.cache,pendingSuspenseBoundaries:de.pendingSuspenseBoundaries,transitions:de.transitions},f.updateQueue.baseState=W,f.memoizedState=W,f.flags&256){B=jn(Error(r(423)),f),f=hL(m,f,E,N,B);break e}else if(E!==B){B=jn(Error(r(424)),f),f=hL(m,f,E,N,B);break e}else for(fi=po(f.stateNode.containerInfo.firstChild),Li=f,aa=!0,eo=null,N=bv(f,null,E,N),f.child=N;N;)N.flags=N.flags&-3|4096,N=N.sibling;else{if(qm(),E===B){f=Ap(m,f,N);break e}xo(m,f,E,N)}f=f.child}return f;case 5:return ud(f),m===null&&ru(f),E=f.type,B=f.pendingProps,W=m!==null?m.memoizedProps:null,de=B.children,Hm(E,B)?de=null:W!==null&&Hm(E,W)&&(f.flags|=32),rx(m,f),xo(m,f,de,N),f.child;case 6:return m===null&&ru(f),null;case 13:return pL(m,f,N);case 4:return oc(f,f.stateNode.containerInfo),E=f.pendingProps,m===null?f.child=Vm(f,null,E,N):xo(m,f,E,N),f.child;case 11:return E=f.type,B=f.pendingProps,B=f.elementType===E?B:Me(E,B),Tp(m,f,E,B,N);case 7:return xo(m,f,f.pendingProps,N),f.child;case 8:return xo(m,f,f.pendingProps.children,N),f.child;case 12:return xo(m,f,f.pendingProps.children,N),f.child;case 10:e:{if(E=f.type._context,B=f.pendingProps,W=f.memoizedProps,de=B.value,hn(Wm,E._currentValue),E._currentValue=de,W!==null)if(qt(W.value,de)){if(W.children===B.children&&!Aa.
vendor: 2,386 bytes, line 8
8current){f=Ap(m,f,N);break e}}else for(W=f.child,W!==null&&(W.return=f);W!==null;){var Ie=W.dependencies;if(Ie!==null){de=W.child;for(var Xe=Ie.firstContext;Xe!==null;){if(Xe.context===E){if(W.tag===1){Xe=Lu(-1,N&-N),Xe.tag=2;var Pt=W.updateQueue;if(Pt!==null){Pt=Pt.shared;var as=Pt.pending;as===null?Xe.next=Xe:(Xe.next=as.next,as.next=Xe),Pt.pending=Xe}}W.lanes|=N,Xe=W.alternate,Xe!==null&&(Xe.lanes|=N),wp(W.return,N,f),Ie.lanes|=N;break}Xe=Xe.next}}else if(W.tag===10)de=W.type===f.type?null:W.child;else if(W.tag===18){if(de=W.return,de===null)throw Error(r(341));de.lanes|=N,Ie=de.alternate,Ie!==null&&(Ie.lanes|=N),wp(de,N,f),de=W.sibling}else de=W.child;if(de!==null)de.return=W;else for(de=W;de!==null;){if(de===f){de=null;break}if(W=de.sibling,W!==null){W.return=de.return,de=W;break}de=de.return}W=de}xo(m,f,B.children,N),f=f.child}return f;case 9:return B=f.type,E=f.pendingProps.children,Gm(f,N),B=ic(B),E=E(B),f.flags|=1,xo(m,f,E,N),f.child;case 14:return E=f.type,B=Me(E,f.pendingProps),B=Me(E.type,B),Fh(m,f,E,B,N);case 15:return sx(m,f,f.type,f.pendingProps,N);case 17:return E=f.type,B=f.pendingProps,B=f.elementType===E?B:Me(E,B),MN(m,f),f.tag=1,li(E)?(m=!0,Te(f)):m=!1,Gm(f,N),Gt(f,E,B),hs(f,E,B,N),Nv(null,f,E,!0,m,N);case 19:return gL(m,f,N);case 22:return jv(m,f,N)}throw Error(r(156,f.tag))};function BL(m,f){return Ln(m,f)}function Poe(m,f,N,E){this.tag=m,this.key=N,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=f,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=E,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mm(m,f,N,E){return new Poe(m,f,N,E)}function O2(m){return m=m.prototype,!(!m||!m.isReactComponent)}function Eoe(m){if(typeof m=="function")return O2(m)?1:0;if(m!=null){if(m=m.$$typeof,m===$)return 11;if(m===V)return 14}return 2}function Wf(m,f){var N=m.alternate;return N===null?(N=mm(m.tag,f,m.key,m.mode),N.elementType=m.elementType,N.type=m.type,N.stateNode=m.stateNode,N.alternate=m,m.alternate=N):(N.pendingProps=f,N.type=m.type,N.flags=0,N.subtreeFlags=0,N.deletions=null),N.flags=m.flags&14680064,N.childLanes=m.childLanes,N.lanes=m.lanes,N.child=m.child,N.memoizedProps=m.memoizedProps,N.memoizedState=m.memoizedState,N.updateQueue=m.updateQueue,f=m.depen
vendor: 6,625 bytes, line 8
8dencies,N.dependencies=f===null?null:{lanes:f.lanes,firstContext:f.firstContext},N.sibling=m.sibling,N.index=m.index,N.ref=m.ref,N}function HN(m,f,N,E,B,W){var de=2;if(E=m,typeof m=="function")O2(m)&&(de=1);else if(typeof m=="string")de=5;else e:switch(m){case A:return lx(N.children,B,W,f);case T:de=8,B|=8;break;case M:return m=mm(12,N,f,B|2),m.elementType=M,m.lanes=W,m;case O:return m=mm(13,N,f,B),m.elementType=O,m.lanes=W,m;case q:return m=mm(19,N,f,B),m.elementType=q,m.lanes=W,m;case G:return qN(N,B,W,f);default:if(typeof m=="object"&&m!==null)switch(m.$$typeof){case R:de=10;break e;case D:de=9;break e;case $:de=11;break e;case V:de=14;break e;case K:de=16,E=null;break e}throw Error(r(130,m==null?m:typeof m,""))}return f=mm(de,N,f,B),f.elementType=m,f.type=E,f.lanes=W,f}function lx(m,f,N,E){return m=mm(7,m,E,f),m.lanes=N,m}function qN(m,f,N,E){return m=mm(22,m,E,f),m.elementType=G,m.lanes=N,m.stateNode={isHidden:!1},m}function D2(m,f,N){return m=mm(6,m,null,f),m.lanes=N,m}function L2(m,f,N){return f=mm(4,m.children!==null?m.children:[],m.key,f),f.lanes=N,f.stateNode={containerInfo:m.containerInfo,pendingChildren:null,implementation:m.implementation},f}function Toe(m,f,N,E,B){this.tag=f,this.containerInfo=m,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ma(0),this.expirationTimes=ma(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ma(0),this.identifierPrefix=E,this.onRecoverableError=B,this.mutableSourceEagerHydrationData=null}function $2(m,f,N,E,B,W,de,Ie,Xe){return m=new Toe(m,f,N,Ie,Xe),f===1?(f=1,W===!0&&(f|=8)):f=0,W=mm(3,null,null,f),m.current=W,W.stateNode=m,W.memoizedState={element:E,isDehydrated:N,cache:null,transitions:null,pendingSuspenseBoundaries:null},Np(W),m}function Aoe(m,f,N){var E=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:_,key:E==null?null:""+E,children:m,containerInfo:f,implementation:N}}function UL(m){if(!m)return Ao;m=m._reactInternals;e:{if(Br(m)!==m||m.tag!==1)throw Error(r(170));var f=m;do{switch(f.tag){case 3:f=f.stateNode.context;break e;case 1:if(li(f.type)){f=f.stateNode.__reactInternalMemoizedMergedChildContext;break e}}f=f.return}while(f!==null);throw Error(r(171))}if(m.tag===1){var N=m.type;if(li(N))return ve(m,N,f)}return f}function zL(m,f,N,E,B,W,de,Ie,Xe){return m=$2(N,E,!0,m,B,W,de,Ie,Xe),m.context=UL(null),N=m.current,E=Dd(),B=qf(N),W=Lu(E,B),W.callback=f??null,$u(N,W,B),m.current.lanes=B,lo(m,B,E),du(m,E),m}function VN(m,f,N,E){var B=f.current,W=Dd(),de=qf(B);return N=UL(N),f.context===null?f.context=N:f.pendingContext=N,f=Lu(W,de),f.payload={element:m},E=E===void 0?null:E,E!==null&&(f.callback=E),m=$u(B,f,de),m!==null&&(rh(m,B,de,W),Sp(m,B,de)),de}function WN(m){return m=m.current,m.child?(m.child.tag===5,m.child.stateNode):null}function HL(m,f){if(m=m.memoizedState,m!==null&&m.dehydrated!==null){var N=m.retryLane;m.retryLane=N!==0&&N<f?N:f}}function F2(m,f){HL(m,f),(m=m.alternate)&&HL(m,f)}function Moe(){return null}var qL=typeof reportError=="function"?reportError:function(m){console.error(m)};function B2(m){this._internalRoot=m}KN.prototype.render=B2.prototype.render=function(m){var f=this._internalRoot;if(f===null)throw Error(r(409));VN(m,f,null,null)},KN.prototype.unmount=B2.prototype.unmount=function(){var m=this._internalRoot;if(m!==null){this._internalRoot=null;var f=m.containerInfo;ax(function(){VN(null,m,null,null)}),f[fl]=null}};function KN(m){this._internalRoot=m}KN.prototype.unstable_scheduleHydration=function(m){if(m){var f=fn();m={blockedOn:null,target:m,priority:f};for(var N=0;N<Da.length&&f!==0&&f<Da[N].priority;N++);Da.splice(N,0,m),N===0&&Zc(m)}};function U2(m){return!(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)}function GN(m){return!(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11&&(m.nodeType!==8||m.nodeValue!==" react-mount-point-unstable "))}function VL(){}function Roe(m,f,N,E,B){if(B){if(typeof E=="function"){var W=E;E=function(){var Pt=WN(de);W.call(Pt)}}var de=zL(f,E,m,0,null,!1,!1,"",VL);return m._reactRootContainer=de,m[fl]=de.current,ld(m.nodeType===8?m.parentNode:m),ax(),de}for(;B=m.lastChild;)m.removeChild(B);if(typeof E=="function"){var Ie=E;E=function(){var Pt=WN(Xe);Ie.call(Pt)}}var Xe=$2(m,0,!1,null,null,!1,!1,"",VL);return m._reactRootContainer=Xe,m[fl]=Xe.current,ld(m.nodeType===8?m.parentNode:m),ax(function(){VN(f,Xe,N,E)}),Xe}function YN(m,f,N,E,B){var W=N._reactRootContainer;if(W){var de=W;if(typeof B=="function"){var Ie=B;B=function(){var Xe=WN(de);Ie.call(Xe)}}VN(f,de,m,B)}else de=Roe(N,f,m,B,E);return WN(de)}Ds=function(m){switch(m.tag){case 3:var f=m.stateNode;if(f.current.memoizedState.isDehydrated){var N=Mn(f.pendingLanes);N!==0&&(Lr(f,N|1),du(f,Rt()),(Ca&6)===0&&(kv=Rt()+500,ms()))}break;case 13:ax(function(){var E=nu(m,1);if(E!==null){var B=Dd();rh(E,m,1,B)}}),F2(m,1)}},nl=function(m){if(m.tag===13){var f=nu(m,134217728);if(f!==null){var N=Dd();rh(f,m,134217728,N)}F2(m,134217728)}},co=function(m){if(m.tag===13){var f=qf(m),N=nu(m,f);if(N!==null){var E=Dd();rh(N,m,f,E)}F2(m,f)}},fn=function(){return Vr},bi=function(m,f){var N=Vr;try{return Vr=m,f()}finally{Vr=N}},ft=function(m,f,N){switch(f){case"input":if(et(m,N),f=N.name,N.type==="radio"&&f!=null){for(N=m;N.parentNode;)N=N.parentNode;for(N=N.querySelectorAll("input[name="+JSON.stringify(""+f)+'][type="radio"]'),f=0;f<N.length;f++){var E=N[f];if(E!==m&&E.form===m.form){var B=Ou(E);if(!B)throw Error(r(90));me(E),et(E,B)}}}break;case"textarea":we(m,N);break;case"select":f=N.value,f!=null&&Be(m,!!N.multiple,f,!1)}},ne=M2,Oe=ax;var Ioe={usingClientEntryPoint:!1,Events:[Lc,Iu,Ou,Ce,Dt,M2]},cw={findFiberByHostInstance:Dc,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Ooe={bundleType:cw.bundleType,version:cw.version,rendererPackageName:cw.rendererPackageName,rendererConfig:cw.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:k.ReactCurrentDispatcher,findHostInstanceByFiber:function(m){return m=ua(m),m===null?null:m.stateNode},findFiberByHostInstance:cw.findFiberByHostInstance||Moe,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};
8if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var QN=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!QN.isDisabled&&QN.supportsFiber)try{Sr=QN.inject(Ooe),Os=QN}catch{}}return uu.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ioe,uu.createPortal=function(m,f){var N=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!U2(f))throw Error(r(200));return Aoe(m,f,null,N)},uu.createRoot=function(m,f){if(!U2(m))throw Error(r(299));var N=!1,E="",B=qL;return f!=null&&(f.unstable_strictMode===!0&&(N=!0),f.identifierPrefix!==void 0&&(E=f.identifierPrefix),f.onRecoverableError!==void 0&&(B=f.onRecoverableError)),f=$2(m,1,!1,null,null,N,!1,E,B),m[fl]=f.current,ld(m.nodeType===8?m.parentNode:m),new B2(f)},uu.findDOMNode=function(m){if(m==null)return null;if(m.nodeType===1)return m;var f=m._reactInternals;if(f===void 0)throw typeof m.render=="function"?Error(r(188)):(m=Object.keys(m).join(","),Error(r(268,m)));return m=ua(f),m=m===null?null:m.stateNode,m},uu.flushSync=function(m){return ax(m)},uu.hydrate=function(m,f,N){if(!GN(f))throw Error(r(200));return YN(null,m,f,!0,N)},uu.hydrateRoot=function(m,f,N){if(!U2(m))throw Error(r(405));var E=N!=null&&N.hydratedSources||null,B=!1,W="",de=qL;if(N!=null&&(N.unstable_strictMode===!0&&(B=!0),N.identifierPrefix!==void 0&&(W=N.identifierPrefix),N.onRecoverableError!==void 0&&(de=N.onRecoverableError)),f=zL(f,null,m,1,N??null,B,!1,W,de),m[fl]=f.current,ld(m),E)for(m=0;m<E.length;m++)N=E[m],B=N._getVersion,B=B(N._source),f.mutableSourceEagerHydrationData==null?f.mutableSourceEagerHydrationData=[N,B]:f.mutableSourceEagerHydrationData.push(N,B);return new KN(f)},uu.render=function(m,f,N){if(!GN(f))throw Error(r(200));return YN(null,m,f,!1,N)},uu.unmountComponentAtNode=function(m){if(!GN(m))throw Error(r(40));return m._reactRootContainer?(ax(function(){YN(null,null,m,!1,function(){m._reactRootContainer=null,m[fl]=null})}),!0):!1},uu.unstable_batchedUpdates=M2,uu.unstable_renderSubtreeIntoContainer=function(m,f,N,E){if(!GN(N))throw Error(r(200));if(m==null||m._reactInternals===void 0)throw Error(r(38));return YN(m,f,N,!1,E)},uu.version="18.3.1-next-f1338f8080-20240426",uu}var JL;function fW(){if(JL)return q2.exports;JL=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(s){console.error(s)}}return e(),q2.exports=Hoe(),q2.exports}var e$;function qoe(){if(e$)return ZN;e$=1;var e=fW();return ZN.createRoot=e.createRoot,ZN.hydrateRoot=e.hydrateRoot,ZN}var Voe=qoe(),u=Pk();const Ne=ei(u),bb=Loe({__proto__:null,default:Ne},[u]);function Woe(e,s){if(e instanceof RegExp)return{keys:!1,pattern:e};var r,n,a,i,o=[],l="",c=e.split("/");for(c[0]||c.shift();a=c.shift();)r=a[0],r==="*"?(o.push(r),l+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):r===":"?(n=a.indexOf("?",1),i=a.indexOf(".",1),o.push(a.substring(1,~n?n:~i?i:a.length)),l+=~n&&!~i?"(?:/([^/]+?))?":"/([^/]+?)",~i&&(l+=(~n?"?":"")+"\\"+a.substring(i))):l+="/"+a;return{keys:o,pattern:new RegExp("^"+l+(s?"(?=$|/)":"/?$"),"i")}}var K2={exports:{}},G2={};var t$;function Koe(){if(t$)return G2;t$=1;var e=Pk();function s(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var r=typeof Object.is=="function"?Object.is:s,n=e.useState,a=e.useEffect,i=e.useLayoutEffect,o=e.useDebugValue;function l(p,g){var v=g(),b=n({inst:{value:v,getSnapshot:g}}),y=b[0].inst,w=b[1];return i(function(){y.value=v,y.getSnapshot=g,c(y)&&w({inst:y})},[p,v,g]),a(function(){return c(y)&&w({inst:y}),p(function(){c(y)&&w({inst:y})})},[p]),o(v),v}function c(p){var g=p.getSnapshot;p=p.value;try{var v=g();return!r(p,v)}catch{return!0}}function d(p,g){return g()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:l;return G2.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,G2}var s$;function Goe(){return s$||(s$=1,K2.exports=Koe()),K2.exports}var Yoe=Goe();const Qoe=bb.useInsertionEffect,Xoe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Zoe=Xoe?u.useLayoutEffect:u.useEffect,Joe=Qoe||Zoe,gW=e=>{const s=u.useRef([e,(...r)=>s[0](...r)]).current;return Joe(()=>{s[0]=e}),s[1]},ele="popstate",LI="pushState",$I="replaceState",tle="hashchange",r$=[ele,LI,$I,tle],sle=e=>{for(const s of r$)addEventListener(s,e);return()=>{for(const s of r$)removeEventListener(s,e)}},xW=(e,s)=>Yoe.useSyncExternalStore(sle,e,s),rle=()=>location.search,nle=({ssrSearch:e=""}={})=>xW(rle,()=>e),n$=()=>location.pathname,ale=({ssrPath:e}={})=>xW(n$,e?()=>e:n$),ile=(e,{replace:s=!1,state:r=null}={})=>history[s?$I:LI](r,"",e),ole=(e={})=>[ale(e),ile],a$=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[a$]>"u"){for(const e of[LI,$I]){const s=history[e];history[e]=function(){const r=s.apply(this,arguments),n=new Event(e);return n.arguments=arguments,dispatchEvent(n),r}}Object.defineProperty(window,a$,{value:!0})}const lle=(e,s)=>s.toLowerCase().indexOf(e.toLowerCase())?"~"+s:s.slice(e.length)||"/",vW=(e="")=>e==="/"?"":e,cle=(e,s)=>e[0]==="~"?e.slice(1):vW(s)+e,dle=(e="",s)=>lle(b5(vW(e)),b5(s)),ule=e=>e[0]==="?"?e.slice(1):e,b5=e=>{try{return decodeURI(e)}catch{return e}},mle=e=>b5(ule(e)),yW={hook:ole,searchHook:nle,parser:Woe,base:"",ssrPath:void 0,ssrSearch:void 0,hrefs:e=>e},bW=u.createContext(yW),lv=()=>u.useContext(bW),wW={},jW=u.createContext(wW),Ek=()=>u.useContext(jW),Tk=e=>{const[s,r]=e.hook(e);return[dle(e.base,s),gW((n,a)=>
8r(cle(n,e.base),a))]},Ia=()=>Tk(lv()),hle=()=>{const e=lv();return mle(e.searchHook(e))},FI=(e,s,r,n)=>{const{pattern:a,keys:i}=s instanceof RegExp?{keys:!1,pattern:s}:e(s||"*",n),o=a.exec(r)||[],[l,...c]=o;return l!==void 0?[!0,(()=>{const d=i!==!1?Object.fromEntries(i.map((p,g)=>[p,c[g]])):o.groups;let h={...c};return d&&Object.assign(h,d),h})(),...n?[l]:[]]:[!1,null]},NW=e=>FI(lv().parser,e,Ia()[0]),ple=({children:e,...s})=>{const r=lv(),n=s.hook?yW:r;let a=n;const[i,o]=s.ssrPath?.split("?")??[];o&&(s.ssrSearch=o,s.ssrPath=i),s.hrefs=s.hrefs??s.hook?.hrefs;let l=u.useRef({}),c=l.current,d=c;for(let h in n){const p=h==="base"?n[h]+(s[h]||""):s[h]||n[h];c===d&&p!==d[h]&&(l.current=d={...d}),d[h]=p,p!==n[h]&&(a=d)}return u.createElement(bW.Provider,{value:a,children:e})},i$=({children:e,component:s},r)=>s?u.createElement(s,{params:r}):typeof e=="function"?e(r):e,fle=e=>{let s=u.useRef(wW),r=s.current;for(const n in e)e[n]!==r[n]&&(r=e);return Object.keys(e).length===0&&(r=e),s.current=r},ds=({path:e,nest:s,match:r,...n})=>{const a=lv(),[i]=Tk(a),[o,l,c]=r??FI(a.parser,e,i,s),d=fle({...Ek(),...l});if(!o)return null;const h=c?u.createElement(ple,{base:c},i$(n,d)):i$(n,d);return u.createElement(jW.Provider,{value:d,children:h})},Rx=u.forwardRef((e,s)=>{const r=lv(),[n,a]=Tk(r),{to:i="",href:o=i,onClick:l,asChild:c,children:d,className:h,replace:p,state:g,...v}=e,b=gW(w=>{w.ctrlKey||w.metaKey||w.altKey||w.shiftKey||w.button!==0||(l?.(w),w.defaultPrevented||(w.preventDefault(),a(o,e)))}),y=r.hrefs(o[0]==="~"?o.slice(1):r.base+o,r);return c&&u.isValidElement(d)?u.cloneElement(d,{onClick:b,href:y}):u.createElement("a",{...v,onClick:b,href:y,className:h?.call?h(n===o):h,children:d,ref:s})}),SW=e=>Array.isArray(e)?e.flatMap(s=>SW(s&&s.type===u.Fragment?s.props.children:s)):[e],o$=({children:e,location:s})=>{const r=lv(),[n]=Tk(r);for(const a of SW(e)){let i=0;if(u.isValidElement(a)&&(i=FI(r.parser,a.props.path,s||n,a.props.nest))[0])return u.cloneElement(a,{match:i})}return null};var cv=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(){}},Bx=typeof window>"u"||"Deno"in globalThis;function bm(){}function gle(e,s){return typeof e=="function"?e(s):e}function w5(e){return typeof e=="number"&&e>=0&&e!==1/0}function CW(e,s){return Math.max(e+(s||0)-Date.now(),0)}function ry(e,s){return typeof e=="function"?e(s):e}function hh(e,s){return typeof e=="function"?e(s):e}function l$(e,s){const{type:r="all",exact:n,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(n){if(s.queryHash!==BI(o,s.options))return!1}else if(!j0(s.queryKey,o))return!1}if(r!=="all"){const c=s.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&s.isStale()!==l||a&&a!==s.state.fetchStatus||i&&!i(s))}function c$(e,s){const{exact:r,status:n,predicate:a,mutationKey:i}=e;if(i){if(!s.options.mutationKey)return!1;if(r){if(Ux(s.options.mutationKey)!==Ux(i))return!1}else if(!j0(s.options.mutationKey,i))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function BI(e,s){return(s?.queryKeyHashFn||Ux)(e)}function Ux(e){return JSON.stringify(e,(s,r)=>j5(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function j0(e,s){return e===s?!0:typeof e!=typeof s?!1:e&&s&&typeof e=="object"&&typeof s=="object"?!Object.keys(s).some(r=>!j0(e[r],s[r])):!1}function UI(e,s){if(e===s)return e;const r=d$(e)&&d$(s);if(r||j5(e)&&j5(s)){const n=r?e:Object.keys(e),a=n.length,i=r?s:Object.keys(s),o=i.length,l=r?[]:{};let c=0;for(let d=0;d<o;d++){const h=r?d:i[d];(!r&&n.includes(h)||r)&&e[h]===void 0&&s[h]===void 0?(l[h]=void 0,c++):(l[h]=UI(e[h],s[h]),l[h]===e[h]&&e[h]!==void 0&&c++)}return a===o&&c===a?e:l}return s}function NS(e,s){if(!s||Object.keys(e).length!==Object.keys(s).length)return!1;for(const r in e)if(e[r]!==s[r])return!1;return!0}function d$(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function j5(e){if(!u$(e))return!1;const s=e.constructor;if(s===void 0)return!0;const r=s.prototype;return!(!u$(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function u$(e){return Object.prototype.toString.call(e)==="[object Object]"}function xle(e){return new Promise(s=>{setTimeout(s,e)})}function N5(e,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,s):r.structuralSharing!==!1?UI(e,s):s}function SS(e){return e}function vle(e,s,r=0){const n=[...e,s];return r&&n.length>r?n.slice(1):n}function yle(e,s,r=0){const n=[s,...e];return r&&n.length>r?n.slice(0,-1):n}var zI=Symbol();function kW(e,s){return!e.queryFn&&s?.initialPromise?()=>s.initialPromise:!e.queryFn||e.queryFn===zI?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var ble=class extends cv{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!Bx&&window.addEventListener){const s=()=>e();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();
vendor: 26,246 bytes, line 8
8this.listeners.forEach(s=>{s(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},HI=new ble,wle=class extends cv{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!Bx&&window.addEventListener){const s=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},CS=new wle;function S5(){let e,s;const r=new Promise((a,i)=>{e=a,s=i});r.status="pending",r.catch(()=>{});function n(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{n({status:"fulfilled",value:a}),e(a)},r.reject=a=>{n({status:"rejected",reason:a}),s(a)},r}function jle(e){return Math.min(1e3*2**e,3e4)}function _W(e){return(e??"online")==="online"?CS.isOnline():!0}var PW=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Y2(e){return e instanceof PW}function EW(e){let s=!1,r=0,n=!1,a;const i=S5(),o=y=>{n||(g(new PW(y)),e.abort?.())},l=()=>{s=!0},c=()=>{s=!1},d=()=>HI.isFocused()&&(e.networkMode==="always"||CS.isOnline())&&e.canRun(),h=()=>_W(e.networkMode)&&e.canRun(),p=y=>{n||(n=!0,e.onSuccess?.(y),a?.(),i.resolve(y))},g=y=>{n||(n=!0,e.onError?.(y),a?.(),i.reject(y))},v=()=>new Promise(y=>{a=w=>{(n||d())&&y(w)},e.onPause?.()}).then(()=>{a=void 0,n||e.onContinue?.()}),b=()=>{if(n)return;let y;const w=r===0?e.initialPromise:void 0;try{y=w??e.fn()}catch(j){y=Promise.reject(j)}Promise.resolve(y).then(p).catch(j=>{if(n)return;const x=e.retry??(Bx?0:3),C=e.retryDelay??jle,k=typeof C=="function"?C(r,j):C,S=x===!0||typeof x=="number"&&r<x||typeof x=="function"&&x(r,j);if(s||!S){g(j);return}r++,e.onFail?.(r,j),xle(k).then(()=>d()?void 0:v()).then(()=>{s?g(j):b()})})};return{promise:i,cancel:o,continue:()=>(a?.(),i),cancelRetry:l,continueRetry:c,canStart:h,start:()=>(h()?b():v().then(b),i)}}function Nle(){let e=[],s=0,r=l=>{l()},n=l=>{l()},a=l=>setTimeout(l,0);const i=l=>{s?e.push(l):a(()=>{r(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;s++;try{c=l()}finally{s--,s||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{a=l}}}var Lo=Nle(),TW=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),w5(this.gcTime)&&(this.#e=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Bx?1/0:300*1e3))}clearGcTimeout(){this.#e&&(clearTimeout(this.#e),this.#e=void 0)}},Sle=class extends TW{#e;#t;#r;#s;#n;#a;constructor(e){super(),this.#a=!1,this.#n=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.cache,this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Cle(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#s?.promise}setOptions(e){this.options={...this.#n,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,s){const r=N5(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:s?.updatedAt,manual:s?.manual}),r}setState(e,s){this.#i({type:"setState",state:e,setStateOptions:s})}cancel(e){const s=this.#s?.promise;return this.#s?.cancel(e),s?s.then(bm).catch(bm):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>hh(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===zI||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!CW(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(s=>s.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#s?.continue()}onOnline(){this.observers.find(s=>s.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#s?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(s=>s!==e),this.observers.length||(this.#s&&(this.#a?this.#s.cancel({revert:!0}):this.#s.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}fetch(e,s){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&s?.cancelRefetch)this.cancel({silent:!0});else if(this.#s)return this.#s.continueRetry(),this.#s.promise}if(e&&this.setOptions(e),!this.options.queryFn){const l=this.observers.find(c=>c.options.queryFn);l&&this.setOptions(l.options)}const r=new AbortController,n=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#a=!0,r.signal)})},a=()=>{const l=kW(this.options,s),c={queryKey:this.queryKey,meta:this.meta};return n(c),this.#a=!1,this.options.persister?this.options.persister(l,c,this):l(c)},i={fetchOptions:s,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:a};n(i),this.options.behavior?.onFetch(i,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==i.fetchOptions?.meta)&&this.#i({type:"fetch",meta:i.fetchOptions?.meta});const o=l=>{Y2(l)&&l.silent||this.#i({type:"error",error:l}),Y2(l)||(this.#r.config.onError?.(l,this),this.#r.config.onSettled?.(this.state.data,l,this)),this.scheduleGc()};return this.#s=EW({initialPromise:s?.initialPromise,fn:i.fetchFn,abort:r.abort.bind(r),onSuccess:l=>{if(l===void 0){o(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(l)}catch(c){o(c);return}this.#r.config.onSuccess?.(l,this),this.#r.config.onSettled?.(l,this.state.error,this),this.scheduleGc()},onError:o,onFail:(l,c)=>{this.#i({type:"failed",failureCount:l,error:c})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}),this.#s.start()}#i(e){const s=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...AW(r.data,this.options),fetchMeta:e.meta??null};case"success":return{...r,data:e.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return Y2(n)&&n.revert&&this.#t?{...this.#t,fetchStatus:"idle"}:{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=s(this.state),Lo.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function AW(e,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:_W(s.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Cle(e){const s=typeof e.initialData=="function"?e.initialData():e.initialData,r=s!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:s,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var kle=class extends cv{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,s,r){const n=s.queryKey,a=s.queryHash??BI(n,s);let i=this.get(a);return i||(i=new Sle({cache:this,queryKey:n,queryHash:a,options:e.defaultQueryOptions(s),state:r,defaultOptions:e.getQueryDefaults(n)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const s=this.#e.get(e.queryHash);s&&(e.destroy(),s===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Lo.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const s={exact:!0,...e};return this.getAll().find(r=>l$(s,r))}findAll(e={}){const s=this.getAll();return Object.keys(e).length>0?s.filter(r=>l$(e,r)):s}notify(e){Lo.batch(()=>{this.listeners.forEach(s=>{s(e)})})}onFocus(){Lo.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Lo.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},_le=class extends TW{#e;#t;#r;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||MW(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(s=>s!==e),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#t.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){this.#r=EW({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(n,a)=>{this.#s({type:"failed",failureCount:n,error:a})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});const s=this.state.status==="pending",r=!this.#r.canStart();try{if(!s){this.#s({type:"pending",variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);const a=await this.options.onMutate?.(e);a!==this.state.context&&this.#s({type:"pending",context:a,variables:e,isPaused:r})}const n=await this.#r.start();return await this.#t.config.onSuccess?.(n,e,this.state.context,this),await this.options.onSuccess?.(n,e,this.state.context),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(n,null,e,this.state.context),this.#s({type:"success",data:n}),n}catch(n){try{throw await this.#t.config.onError?.(n,e,this.state.context,this),await this.options.onError?.(n,e,this.state.context),await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,n,e,this.state.context),n}finally{this.#s({type:"error",error:n})}}finally{this.#t.runNext(this)}}#s(e){const s=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=s(this.state),Lo.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:"updated",action:e})})}};function MW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ple=class extends cv{constructor(e={}){super(),this.config=e,this.#e=new Map,this.#t=Date.now()}#e;#t;build(e,s,r){const n=new _le({mutationCache:this,mutationId:++this.#t,options:e.defaultMutationOptions(s),state:r});return this.add(n),n}add(e){const s=JN(e),r=this.#e.get(s)??[];r.push(e),this.#e.set(s,r),this.notify({type:"added",mutation:e})}remove(e){const s=JN(e);if(this.#e.has(s)){const r=this.#e.get(s)?.filter(n=>n!==e);r&&(r.length===0?this.#e.delete(s):this.#e.set(s,r))}this.notify({type:"removed",mutation:e})}canRun(e){const s=this.#e.get(JN(e))?.find(r=>r.state.status==="pending");return!s||s===e}runNext(e){return this.#e.get(JN(e))?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve()}clear(){Lo.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}getAll(){return[...this.#e.values()].flat()}find(e){const s={exact:!0,...e};return this.getAll().find(r=>c$(s,r))}findAll(e={}){return this.getAll().filter(s=>c$(e,s))}notify(e){Lo.batch(()=>{this.listeners.forEach(s=>{s(e)})})}resumePausedMutations(){const e=this.getAll().filter(s=>s.state.isPaused);return Lo.batch(()=>Promise.all(e.map(s=>s.continue().catch(bm))))}};function JN(e){return e.options.scope?.id??String(e.mutationId)}function m$(e){return{onFetch:(s,r)=>{const n=s.options,a=s.fetchOptions?.meta?.fetchMore?.direction,i=s.state.data?.pages||[],o=s.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let h=!1;const p=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(s.signal.aborted?h=!0:s.signal.addEventListener("abort",()=>{h=!0}),s.signal)})},g=kW(s.options,s.fetchOptions),v=async(b,y,w)=>{if(h)return Promise.reject();if(y==null&&b.pages.length)return Promise.resolve(b);const j={queryKey:s.queryKey,pageParam:y,direction:w?"backward":"forward",meta:s.options.meta};p(j);const x=await g(j),{maxPages:C}=s.options,k=w?yle:vle;return{pages:k(b.pages,x,C),pageParams:k(b.pageParams,y,C)}};if(a&&i.length){const b=a==="backward",y=b?Ele:h$,w={pages:i,pageParams:o},j=y(n,w);l=await v(w,j,b)}else{const b=e??i.length;do{const y=c===0?o[0]??n.initialPageParam:h$(n,l);if(c>0&&y==null)break;l=await v(l,y),c++}while(c<b)}return l};s.options.persister?s.fetchFn=()=>s.options.persister?.(d,{queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r):s.fetchFn=d}}}function h$(e,{pages:s,pageParams:r}){const n=s.length-1;return s.length>0?e.getNextPageParam(s[n],s,r[n],r):void 0}function Ele(e,{pages:s,pageParams:r}){return s.length>0?e.getPreviousPageParam?.(s[0],s,r[0],r):void 0}var Tle=class{#e;#t;#r;#s;#n;#a;#i;#o;constructor(e={}){this.#e=e.queryCache||new kle,this.#t=e.mutationCache||new Ple,this.#r=e.defaultOptions||{},this.#s=new Map,this.#n=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#i=HI.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#o=CS.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#i?.(),this.#i=void 0,this.#o?.(),this.#o=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const s=this.defaultQueryOptions({queryKey:e});return this.#e.get(s.queryHash)?.state.data}ensureQueryData(e){const s=this.getQueryData(e.queryKey);if(s===void 0)return this.fetchQuery(e);{const r=this.defaultQueryOptions(e),n=this.#e.build(this,r);return e.revalidateIfStale&&n.isStaleByTime(ry(r.staleTime,n))&&this.prefetchQuery(r),Promise.resolve(s)}}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:s,state:r})=>{const n=r.data;return[s,n]})}setQueryData(e,s,r){const n=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(n.queryHash)?.state.data,o=gle(s,i);if(o!==void 0)return this.#e.build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,s,r){return Lo.batch(()=>this.#e.findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(e){const s=this.defaultQueryOptions({queryKey:e});return this.#e.get(s.queryHash)?.state}removeQueries(e){const s=this.#e;Lo.batch(()=>{s.findAll(e).forEach(r=>{s.remove(r)})})}resetQueries(e,s){const r=this.#e,n={type:"active",...e};return Lo.batch(()=>(r.findAll(e).forEach(a=>{a.reset()}),this.refetchQueries(n,s)))}cancelQueries(e={},s={}){const r={revert:!0,...s},n=Lo.batch(()=>this.#e.findAll(e).map(a=>a.cancel(r)));return Promise.all(n).then(bm).catch(bm)}invalidateQueries(e={},s={}){return Lo.batch(()=>{if(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e.refetchType==="none")return Promise.resolve();const r={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(r,s)})}refetchQueries(e={},s){const r={...s,cancelRefetch:s?.cancelRefetch??!0},n=Lo.batch(()=>this.#e.findAll(e).filter(a=>!a.isDisabled()).map(a=>{let i=a.fetch(void 0,r);return r.throwOnError||(i=i.catch(bm)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(bm)}fetchQuery(e){const s=this.defaultQueryOptions(e);s.retry===void 0&&(s.retry=!1);const r=this.#e.build(this,s);return r.isStaleByTime(ry(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(bm).catch(bm)}fetchInfiniteQuery(e){return e.behavior=m$(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(bm).catch(bm)}ensureInfiniteQueryData(e){return e.behavior=m$(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return CS.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,s){this.#s.set(Ux(e),{queryKey:e,defaultOptions:s})}getQueryDefaults(e){const s=[...this.#s.values()];let r={};return s.forEach(n=>{j0(e,n.queryKey)&&(r={...r,...n.defaultOptions})}),r}setMutationDefaults(e,s){this.#n.set(Ux(e),{mutationKey:e,defaultOptions:s})}getMutationDefaults(e){const s=[...this.#n.values()];let r={};return s.forEach(n=>{j0(e,n.mutationKey)&&(r={...r,...n.defaultOptions})}),r}defaultQueryOptions(e){if(e._defaulted)return e;const s={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return s.queryHash||(s.queryHash=BI(s.queryKey,s)),s.refetchOnReconnect===void 0&&(s.refetchOnReconnect=s.networkMode!=="always"),s.throwOnError===void 0&&(s.throwOnError=!!s.suspense),!s.networkMode&&s.persister&&(s.networkMode="offlineFirst"),s.enabled!==!0&&s.queryFn===zI&&(s.enabled=!1),s}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},qI=class extends cv{constructor(e,s){super(),this.options=s,this.#e=e,this.#o=null,this.#i=S5(),this.options.experimental_prefetchInRender||this.#i.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(s)}#e;#t=void 0;#r=void 0;#s=void 0;#n;#a;#i;#o;#m;#u;#l;#c;#d;#h;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),p$(this.#t,this.options)?this.#p():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return C5(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return C5(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#w(),this.#t.removeObserver(this)}setOptions(e,s){const r=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof hh(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#j(),this.#t.setOptions(this.options),r._defaulted&&!NS(this.options,r)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const a=this.hasListeners();a&&f$(this.#t,n,this.options,r)&&this.#p(),this.updateResult(s),a&&(this.#t!==n||hh(this.options.enabled,this.#t)!==hh(r.enabled,this.#t)||ry(this.options.staleTime,this.#t)!==ry(r.staleTime,this.#t))&&this.#g();const i=this.#x();a&&(this.#t!==n||hh(this.options.enabled,this.#t)!==hh(r.enabled,this.#t)||i!==this.#h)&&this.#v(i)}getOptimisticResult(e){const s=this.#e.getQueryCache().build(this.#e,e),r=this.createResult(s,e);return Mle(this,r)&&(this.#s=r,this.#a=this.options,this.#n=this.#t.state),r}getCurrentResult(){return this.#s}trackResult(e,s){const r={};return Object.keys(e).forEach(n=>{Object.defineProperty(r,n,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(n),s?.(n),e[n])})}),r}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const s=this.#e.defaultQueryOptions(e),r=this.#e.getQueryCache().build(this.#e,s);return r.fetch().then(()=>this.createResult(r,s))}fetch(e){return this.#p({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#p(e){this.#j();let s=this.#t.fetch(this.options,e);return e?.throwOnError||(s=s.catch(bm)),s}#g(){this.#b();const e=ry(this.options.staleTime,this.#t);if(Bx||this.#s.isStale||!w5(e))return;const r=CW(this.#s.dataUpdatedAt,e)+1;this.#c=setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#w(),this.#h=e,!(Bx||hh(this.options.enabled,this.#t)===!1||!w5(this.#h)||this.#h===0)&&(this.#d=setInterval(()=>{(this.options.refetchIntervalInBackground||HI.isFocused())&&this.#p()},this.#h))}#y(){this.#g(),this.#v(this.#x())}#b(){this.#c&&(clearTimeout(this.#c),this.#c=void 0)}#w(){this.#d&&(clearInterval(this.#d),this.#d=void 0)}createResult(e,s){const r=this.#t,n=this.options,a=this.#s,i=this.#n,o=this.#a,c=e!==r?e.state:this.#r,{state:d}=e;let h={...d},p=!1,g;if(s._optimisticResults){const A=this.hasListeners(),T=!A&&p$(e,s),M=A&&f$(e,r,s,n);(T||M)&&(h={...h,...AW(d.data,e.options)}),s._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:v,errorUpdatedAt:b,status:y}=h;if(s.select&&h.data!==void 0)if(a&&h.data===i?.data&&s.select===this.#m)g=this.#u;else try{this.#m=s.select,g=s.select(h.data),g=N5(a?.data,g,s),this.#u=g,this.#o=null}catch(A){this.#o=A}else g=h.data;if(s.placeholderData!==void 0&&g===void 0&&y==="pending"){let A;if(a?.isPlaceholderData&&s.placeholderData===o?.placeholderData)A=a.data;else if(A=typeof s.placeholderData=="function"?s.placeholderData(this.#l?.state.data,this.#l):s.placeholderData,s.select&&A!==void 0)try{A=s.select(A),this.#o=null}catch(T){this.#o=T}A!==void 0&&(y="success",g=N5(a?.data,A,s),p=!0)}this.#o&&(v=this.#o,g=this.#u,b=Date.now(),y="error");const w=h.fetchStatus==="fetching",j=y==="pending",x=y==="error",C=j&&w,k=g!==void 0,_={status:y,fetchStatus:h.fetchStatus,isPending:j,isSuccess:y==="success",isError:x,isInitialLoading:C,isLoading:C,data:g,dataUpdatedAt:h.dataUpdatedAt,error:v,errorUpdatedAt:b,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>c.dataUpdateCount||h.errorUpdateCount>c.errorUpdateCount,isFetching:w,isRefetching:w&&!j,isLoadingError:x&&!k,isPaused:h.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:x&&k,isStale:VI(e,s),refetch:this.refetch,promise:this.#i};if(this.options.experimental_prefetchInRender){const A=R=>{_.status==="error"?R.reject(_.error):_.data!==void 0&&R.resolve(_.data)},T=()=>{const R=this.#i=_.promise=S5();A(R)},M=this.#i;switch(M.status){case"pending":e.queryHash===r.queryHash&&A(M);break;case"fulfilled":(_.status==="error"||_.data!==M.value)&&T();break;case"rejected":(_.status!=="error"||_.error!==M.reason)&&T();break}}return _}updateResult(e){const s=this.#s,r=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#a=this.options,this.#n.data!==void 0&&(this.#l=this.#t),NS(r,s))return;this.#s=r;const n={},a=()=>{if(!s)return!0;const{notifyOnChangeProps:i}=this.options,o=typeof i=="function"?i():i;if(o==="all"||!o&&!this.#f.size)return!0;const l=new Set(o??this.#f);return this.options.throwOnError&&l.add("error"),Object.keys(this.#s).some(c=>{const d=c;return this.#s[d]!==s[d]&&l.has(d)})};e?.listeners!==!1&&a()&&(n.listeners=!0),this.#N({...n,...e})}#j(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const s=this.#t;this.#t=e,this.#r=e.state,this.hasListeners()&&(s?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#N(e){Lo.batch(()=>{e.listeners&&this.listeners.forEach(s=>{s(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Ale(e,s){return hh(s.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&s.retryOnMount===!1)}function p$(e,s){return Ale(e,s)||e.state.data!==void 0&&C5(e,s,s.refetchOnMount)}function C5(e,s,r){if(hh(s.enabled,e)!==!1){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&VI(e,s)}return!1}function f$(e,s,r,n){return(e!==s||hh(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&VI(e,r)}function VI(e,s){return hh(s.enabled,e)!==!1&&e.isStaleByTime(ry(s.staleTime,e))}function Mle(e,s){return!NS(e.getCurrentResult(),s)}function g$(e,s){return e.filter(r=>!s.includes(r))}function Rle(e,s,r){const n=e.slice(0);return n[s]=r,n}var Ile=class extends cv{#e;#t;#r;#s;#n;#a;#i;#o;constructor(e,s,r){super(),this.#e=e,this.#s=r,this.#r=[],this.#n=[],this.#t=[],this.setQueries(s)}
8onSubscribe(){this.listeners.size===1&&this.#n.forEach(e=>{e.subscribe(s=>{this.#c(e,s)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#n.forEach(e=>{e.destroy()})}setQueries(e,s,r){this.#r=e,this.#s=s,Lo.batch(()=>{const n=this.#n,a=this.#l(this.#r);a.forEach(c=>c.observer.setOptions(c.defaultedQueryOptions,r));const i=a.map(c=>c.observer),o=i.map(c=>c.getCurrentResult()),l=i.some((c,d)=>c!==n[d]);n.length===i.length&&!l||(this.#n=i,this.#t=o,this.hasListeners()&&(g$(n,i).forEach(c=>{c.destroy()}),g$(i,n).forEach(c=>{c.subscribe(d=>{this.#c(c,d)})}),this.#d()))})}getCurrentResult(){return this.#t}getQueries(){return this.#n.map(e=>e.getCurrentQuery())}getObservers(){return this.#n}getOptimisticResult(e,s){const n=this.#l(e).map(a=>a.observer.getOptimisticResult(a.defaultedQueryOptions));return[n,a=>this.#u(a??n,s),()=>this.#m(n,e)]}#m(e,s){const r=this.#l(s);return r.map((n,a)=>{const i=e[a];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,o=>{r.forEach(l=>{l.observer.trackProp(o)})})})}#u(e,s){return s?((!this.#a||this.#t!==this.#o||s!==this.#i)&&(this.#i=s,this.#o=this.#t,this.#a=UI(this.#a,s(e))),this.#a):e}#l(e){const s=new Map(this.#n.map(n=>[n.options.queryHash,n])),r=[];return e.forEach(n=>{const a=this.#e.defaultQueryOptions(n),i=s.get(a.queryHash);if(i)r.push({defaultedQueryOptions:a,observer:i});else{const o=this.#n.find(l=>l.options.queryHash===a.queryHash);r.push({defaultedQueryOptions:a,observer:o??new qI(this.#e,a)})}}),r.sort((n,a)=>e.findIndex(i=>i.queryHash===n.defaultedQueryOptions.queryHash)-e.findIndex(i=>i.queryHash===a.defaultedQueryOptions.queryHash))}#c(e,s){const r=this.#n.indexOf(e);r!==-1&&(this.#t=Rle(this.#t,r,s),this.#d())}#d(){if(this.hasListeners()){const e=this.#a,s=this.#u(this.#m(this.#t,this.#r),this.#s?.combine);e!==s&&Lo.batch(()=>{this.listeners.forEach(r=>{r(this.#t)})})}}},Ole=class extends cv{#e;#t=void 0;#r;#s;constructor(s,r){super(),this.#e=s,this.setOptions(r),this.bindMethods(),this.#n()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(s){const r=this.options;this.options=this.#e.defaultMutationOptions(s),NS(this.options,r)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#r,observer:this}),r?.mutationKey&&this.options.mutationKey&&Ux(r.mutationKey)!==Ux(this.options.mutationKey)?this.reset():this.#r?.state.status==="pending"&&this.#r.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#r?.removeObserver(this)}onMutationUpdate(s){this.#n(),this.#a(s)}getCurrentResult(){return this.#t}reset(){this.#r?.removeObserver(this),this.#r=void 0,this.#n(),this.#a()}mutate(s,r){return this.#s=r,this.#r?.removeObserver(this),this.#r=this.#e.getMutationCache().build(this.#e,this.options),this.#r.addObserver(this),this.#r.execute(s)}#n(){const s=this.#r?.state??MW();this.#t={...s,isPending:s.status==="pending",isSuccess:s.status==="success",isError:s.status==="error",isIdle:s.status==="idle",mutate:this.mutate,reset:this.reset}}#a(s){Lo.batch(()=>{if(this.#s&&this.hasListeners()){const r=this.#t.variables,n=this.#t.context;s?.type==="success"?(this.#s.onSuccess?.(s.data,r,n),this.#s.onSettled?.(s.data,null,r,n)):s?.type==="error"&&(this.#s.onError?.(s.error,r,n),this.#s.onSettled?.(void 0,s.error,r,n))}this.listeners.forEach(r=>{r(this.#t)})})}},RW=u.createContext(void 0),Su=e=>{const s=u.useContext(RW);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},Dle=({client:e,children:s})=>(u.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),t.jsx(RW.Provider,{value:e,children:s})),IW=u.createContext(!1),OW=()=>u.useContext(IW);IW.Provider;function Lle(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var $le=u.createContext(Lle()),DW=()=>u.useContext($le);function LW(e,s){return typeof e=="function"?e(...s):!!e}function kS(){}var $W=(e,s)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(s.isReset()||(e.retryOnMount=!1))},FW=e=>{u.useEffect(()=>{e.clearReset()},[e])},BW=({result:e,errorResetBoundary:s,throwOnError:r,query:n})=>e.isError&&!s.isReset()&&!e.isFetching&&n&&LW(r,[e.error,n]),UW=e=>{e.suspense&&(e.staleTime===void 0&&(e.staleTime=1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))}
8,zW=(e,s)=>e.isLoading&&e.isFetching&&!s,k5=(e,s)=>e?.suspense&&s.isPending,_S=(e,s,r)=>s.fetchOptimistic(e).catch(()=>{r.clearReset()});function Ix({queries:e,...s},r){const n=Su(),a=OW(),i=DW(),o=u.useMemo(()=>e.map(b=>{const y=n.defaultQueryOptions(b);return y._optimisticResults=a?"isRestoring":"optimistic",y}),[e,n,a]);o.forEach(b=>{UW(b),$W(b,i)}),FW(i);const[l]=u.useState(()=>new Ile(n,o,s)),[c,d,h]=l.getOptimisticResult(o,s.combine);u.useSyncExternalStore(u.useCallback(b=>a?kS:l.subscribe(Lo.batchCalls(b)),[l,a]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),u.useEffect(()=>{l.setQueries(o,s,{listeners:!1})},[o,s,l]);const g=c.some((b,y)=>k5(o[y],b))?c.flatMap((b,y)=>{const w=o[y];if(w){const j=new qI(n,w);if(k5(w,b))return _S(w,j,i);zW(b,a)&&_S(w,j,i)}return[]}):[];if(g.length>0)throw Promise.all(g);const v=c.find((b,y)=>{const w=o[y];return w&&BW({result:b,errorResetBoundary:i,throwOnError:w.throwOnError,query:n.getQueryCache().get(w.queryHash)})});if(v?.error)throw v.error;return d(h())}function Fle(e,s,r){const n=Su(),a=OW(),i=DW(),o=n.defaultQueryOptions(e);
8n.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=a?"isRestoring":"optimistic",UW(o),$W(o,i),FW(i);const l=!n.getQueryCache().get(o.queryHash),[c]=u.useState(()=>new s(n,o)),d=c.getOptimisticResult(o);if(u.useSyncExternalStore(u.useCallback(h=>{const p=a?kS:c.subscribe(Lo.batchCalls(h));return c.updateResult(),p},[c,a]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),u.useEffect(()=>{c.setOptions(o,{listeners:!1})},[o,c]),k5(o,d))throw _S(o,c,i);if(BW({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:n.getQueryCache().get(o.queryHash)}))throw d.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!Bx&&zW(d,a)&&(l?_S(o,c,i):n.getQueryCache().get(o.queryHash)?.promise)?.catch(kS).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?d:c.trackResult(d)}function ze(e,s){return Fle(e,qI)}function Et(e,s){const r=Su(),[n]=u.useState(()=>new Ole(r,e));u.useEffect(()=>{n.setOptions(e)},[n,e]);const a=u.useSyncExternalStore(u.useCallback(o=>n.subscribe(Lo.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=u.useCallback((o,l)=>{n.mutate(o,l).catch(kS)},[n]);if(a.error&&LW(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}const Ble=1,Ule=1e6;let Q2=0;function zle(){return Q2=(Q2+1)%Number.MAX_SAFE_INTEGER,Q2.toString()}const X2=new Map,x$=e=>{if(X2.has(e))return;const s=setTimeout(()=>{X2.delete(e),Jw({type:"REMOVE_TOAST",toastId:e})},Ule);X2.set(e,s)},Hle=(e,s)=>{switch(s.type){case"ADD_TOAST":return{...e,toasts:[s.toast,...e.toasts].slice(0,Ble)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(r=>r.id===s.toast.id?{...r,...s.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=s;return r?x$(r):e.toasts.forEach(n=>{x$(n.id)}),{...e,toasts:e.toasts.map(n=>
8n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return s.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(r=>r.id!==s.toastId)}}},sS=[];let rS={toasts:[]};function Jw(e){rS=Hle(rS,e),sS.forEach(s=>{s(rS)})}function HW({...e}){const s=zle(),r=a=>Jw({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>Jw({type:"DISMISS_TOAST",toastId:s});return Jw({type:"ADD_TOAST",toast:{...e,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function Hs(){const[e,s]=u.useState(rS);return u.useEffect(()=>(sS.push(s),()=>{const r=sS.indexOf(s);r>-1&&sS.splice(r,1)}),[e]),{...e,toast:HW,dismiss:r=>Jw({type:"DISMISS_TOAST",toastId:r})}}async function qW(e){if(!e.ok){const s=await e.text()||e.statusText;throw e.status===403&&s.includes("viewAsBlocked")&&HW({title:"Read-only preview",description:"You're viewing as another user. Changes are disabled — exit View As to make changes.",variant:"destructive"}),new Error(`${e.status}: ${s}`)}}async function Ze(e,s,r){const n=await fetch(s,{method:e,headers:r?{"Content-Type":"application/json"}:{},body:r?JSON.stringify(r):void 0,credentials:"include"});return await qW(n),n}const qle=({on401:e})=>async({queryKey:s})=>{const r=await fetch(s.join("/"),{credentials:"include"});return await qW(r),await r.json()},Je=new Tle({defaultOptions:{queries:{queryFn:qle({on401:"throw"}),refetchInterval:!1,refetchOnWindowFocus:!1,staleTime:1/0,retry:!1},mutations:{retry:!1}}});var Em=fW();const VW=ei(Em);function Ms(e,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e?.(a),r===!1||!a.defaultPrevented)return s?.(a)}}function v$(e,s){if(typeof e=="function")return e(s);e!=null&&(e.current=s)}function jf(...e){return s=>{let r=!1;const n=e.map(a=>{const i=v$(a,s);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let a=0;a<n.length;a++){const i=n[a];typeof i=="function"?i():v$(e[a],null)}}}}function mr(...e){return u.useCallback(jf(...e),e)}function Vle(e,s){const r=u.createContext(s),n=i=>{const{children:o,...l}=i,c=u.useMemo(()=>l,Object.values(l));return t.jsx(r.Provider,{value:c,children:o})};n.displayName=e+"Provider";function a(i){const o=u.useContext(r);if(o)return o;if(s!==void 0)return s;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[n,a]}function oo(e,s=[]){let r=[];function n(i,o){const l=u.createContext(o),c=r.length;r=[...r,o];const d=p=>{const{scope:g,children:v,...b}=p,y=g?.[e]?.[c]||l,w=u.useMemo(()=>b,Object.values(b));return t.jsx(y.Provider,{value:w,children:v})};d.displayName=i+"Provider";function h(p,g){const v=g?.[e]?.[c]||l,b=u.useContext(v);if(b)return b;if(o!==void 0)return o;throw new Error(`\`${p}\` must be used within \`${i}\``)}return[d,h]}const a=()=>{const i=r.map(o=>u.createContext(o));return function(l){const c=l?.[e]||i;return u.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[n,Wle(a,...s)]}function Wle(...e){const s=e[0];if(e.length===1)return s;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=n.reduce((l,{useScope:c,scopeName:d})=>{const p=c(i)[`__scope${d}`];return{...l,...p}},{});return u.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])}};return r.scopeName=s.scopeName,r}function zx(e){const s=Kle(e),r=u.forwardRef((n,a)=>{const{children:i,...o}=n,l=u.Children.toArray(i),c=l.find(Gle);if(c){const d=c.props.children,h=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return t.jsx(s,{...o,ref:a,children:u.isValidElement(d)?u.cloneElement(d,void 0,h):null})}return t.jsx(s,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}var WW=zx("Slot");function Kle(e){const s=u.forwardRef((r,n)=>{const{children:a,...i}=r;if(u.isValidElement(a)){const o=Qle(a),l=Yle(i,a.props);return a.type!==u.Fragment&&(l.ref=n?jf(n,o):o),u.cloneElement(a,l)}return u.Children.count(a)>1?u.Children.only(null):null});return s.displayName=`${e}.SlotClone`,s}var KW=Symbol("radix.slottable");function GW(e){const s=({children:r})=>t.jsx(t.Fragment,{children:r});return s.displayName=`${e}.Slottable`,s.__radixId=KW,s}function Gle(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===KW}function Yle(e,s){const r={...s};for(const n in s){const a=e[n],i=s[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{i(...l),a(...l)}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}
vendor: 6,662 bytes, line 8
8:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function Qle(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function Bj(e){const s=e+"CollectionProvider",[r,n]=oo(s),[a,i]=r(s,{collectionRef:{current:null},itemMap:new Map}),o=y=>{const{scope:w,children:j}=y,x=Ne.useRef(null),C=Ne.useRef(new Map).current;return t.jsx(a,{scope:w,itemMap:C,collectionRef:x,children:j})};o.displayName=s;const l=e+"CollectionSlot",c=zx(l),d=Ne.forwardRef((y,w)=>{const{scope:j,children:x}=y,C=i(l,j),k=mr(w,C.collectionRef);return t.jsx(c,{ref:k,children:x})});d.displayName=l;const h=e+"CollectionItemSlot",p="data-radix-collection-item",g=zx(h),v=Ne.forwardRef((y,w)=>{const{scope:j,children:x,...C}=y,k=Ne.useRef(null),S=mr(w,k),_=i(h,j);return Ne.useEffect(()=>(_.itemMap.set(k,{ref:k,...C}),()=>{_.itemMap.delete(k)})),t.jsx(g,{[p]:"",ref:S,children:x})});v.displayName=h;function b(y){const w=i(e+"CollectionConsumer",y);return Ne.useCallback(()=>{const x=w.collectionRef.current;if(!x)return[];const C=Array.from(x.querySelectorAll(`[${p}]`));return Array.from(w.itemMap.values()).sort((_,A)=>C.indexOf(_.ref.current)-C.indexOf(A.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:d,ItemSlot:v},b,n]}var Xle=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Cr=Xle.reduce((e,s)=>{const r=zx(`Primitive.${s}`),n=u.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(c,{...l,ref:i})});return n.displayName=`Primitive.${s}`,{...e,[s]:n}},{});function WI(e,s){e&&Em.flushSync(()=>e.dispatchEvent(s))}function Za(e){const s=u.useRef(e);return u.useEffect(()=>{s.current=e}),u.useMemo(()=>(...r)=>s.current?.(...r),[])}function YW(e,s=globalThis?.document){const r=Za(e);u.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return s.addEventListener("keydown",n,{capture:!0}),()=>s.removeEventListener("keydown",n,{capture:!0})},[r,s])}var Zle="DismissableLayer",_5="dismissableLayer.update",Jle="dismissableLayer.pointerDownOutside",ece="dismissableLayer.focusOutside",y$,QW=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),wb=u.forwardRef((e,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...c}=e,d=u.useContext(QW),[h,p]=u.useState(null),g=h?.ownerDocument??globalThis?.document,[,v]=u.useState({}),b=mr(s,A=>p(A)),y=Array.from(d.layers),[w]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),j=y.indexOf(w),x=h?y.indexOf(h):-1,C=d.layersWithOutsidePointerEventsDisabled.size>0,k=x>=j,S=sce(A=>{const T=A.target,M=[...d.branches].some(R=>R.contains(T));!k||M||(a?.(A),o?.(A),A.defaultPrevented||l?.())},g),_=rce(A=>{const T=A.target;[...d.branches].some(R=>R.contains(T))||(i?.(A),o?.(A),A.defaultPrevented||l?.())},g);return YW(A=>{x===d.layers.size-1&&(n?.(A),!A.defaultPrevented&&l&&(A.preventDefault(),l()))},g),u.useEffect(()=>{if(h)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(y$=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),b$(),()=>{r&&d.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=y$)}},[h,g,r,d]),u.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),b$())},[h,d]),u.useEffect(()=>{const A=()=>v({});return document.addEventListener(_5,A),()=>document.removeEventListener(_5,A)},[]),t.jsx(Cr.div,{...c,ref:b,style:{pointerEvents:C?k?"auto":"none":void 0,...e.style},onFocusCapture:Ms(e.onFocusCapture,_.onFocusCapture),onBlurCapture:Ms(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Ms(e.onPointerDownCapture,S.onPointerDownCapture)})});wb.displayName=Zle;var tce="DismissableLayerBranch",XW=u.forwardRef((e,s)=>{const r=u.useContext(QW),n=u.useRef(null),a=mr(s,n);return u.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),t.jsx(Cr.div,{...e,ref:a})});XW.displayName=tce;function sce(e,s=globalThis?.document){const r=Za(e),n=u.useRef(!1),a=u.useRef(()=>{});return u.useEffect(()=>{const i=l=>{if(l.target&&!n.current){let c=function(){ZW(Jle,r,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=c,s.addEventListener("click",a.current,{once:!0})):c()}else s.removeEventListener("click",a.current);n.current=!1},o=window.setTimeout(()=>{s.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),s.removeEventListener("pointerdown",i),s.removeEventListener("click",a.current)}},[s,r]),{onPointerDownCapture:()=>n.current=!0}}function rce(e,s=globalThis?.document){const r=Za(e),n=u.useRef(!1);return u.useEffect(()=>{const a=i=>{i.target&&!n.current&&ZW(ece,r,{originalEvent:i},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function b$(){const e=new CustomEvent(_5);document.dispatchEvent(e)}function ZW(e,s,r,{discrete:n}){const a=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});s&&a.addEventListener(e,s,{once:!0}),n?WI(a,i):a.dispatchEvent(i)}var nce=wb,ace=XW,da=globalThis?.document?u.useLayoutEffect:()=>{},ice="Portal",Uj=u.forwardRef((e,s)=>{const{container:r,...n}=e,[a,i]=u.useState(!1);da(()=>i(!0),[]);const o=r||a&&globalThis?.document?.body;return o?VW.createPortal(t.jsx(Cr.div,{...n,ref:s}),o):null});Uj.displayName=ice;function oce(e,s){return u.useReducer((r,n)=>s[r][n]??r,e)}var $m=e=>{const{present:s,children:r}=e,n=lce(s),a=typeof r=="function"?r({present:n.isPresent}):u.Children.only(r),i=mr(n.ref,cce(a));return typeof r=="function"||n.isPresent?u.cloneElement(a,{ref:i}):null};$m.displayName="Presence";function lce(e){const[s,r]=u.useState(),n=u.useRef({}),a=u.useRef(e),i=u.useRef("none"),o=e?"mounted":"unmounted",[l,c]=oce(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=e1(n.current);i.current=l==="mounted"?d:"none"},[l]),da(()=>{const d=n.current,h=a.current;if(h!==e){const g=i.current,v=e1(d);e?c("MOUNT"):v==="none"||d?.display==="none"?c("UNMOUNT"):c(h&&g!==v?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),da(()=>
8{if(s){let d;const h=s.ownerDocument.defaultView??window,p=v=>{const y=e1(n.current).includes(v.animationName);if(v.target===s&&y&&(c("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",d=h.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},g=v=>{v.target===s&&(i.current=e1(n.current))};return s.addEventListener("animationstart",g),s.addEventListener("animationcancel",p),s.addEventListener("animationend",p),()=>{h.clearTimeout(d),s.removeEventListener("animationstart",g),s.removeEventListener("animationcancel",p),s.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{d&&(n.current=getComputedStyle(d)),r(d)},[])}}function e1(e){return e?.animationName||"none"}function cce(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function ip({prop:e,defaultProp:s,onChange:r=()=>{}}){const[n,a]=dce({defaultProp:s,onChange:r}),i=e!==void 0,o=i?e:n,l=Za(r),c=u.useCallback(d=>{if(i){const p=typeof d=="function"?d(e):d;p!==e&&l(p)}else a(d)},[i,e,a,l]);return[o,c]}function dce({defaultProp:e,onChange:s}){const r=u.useState(e),[n]=r,a=u.useRef(n),i=Za(s);return u.useEffect(()=>{a.current!==n&&(i(n),a.current=n)},[n,a,i]),r}var uce="VisuallyHidden",zj=u.forwardRef((e,s)=>t.jsx(Cr.span,{...e,ref:s,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));zj.displayName=uce;var mce=zj,KI="ToastProvider",[GI,hce,pce]=Bj("Toast"),[JW]=oo("Toast",[pce]),[fce,Ak]=JW(KI),eK=e=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:i=50,children:o}=e,[l,c]=u.useState(null),[d,h]=u.useState(0),p=u.useRef(!1),g=u.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${KI}\`. Expected non-empty \`string\`.`),t.jsx(GI.Provider,{scope:s,children:t.jsx(fce,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:i,toastCount:d,viewport:l,onViewportChange:c,onToastAdd:u.useCallback(()=>h(v=>v+1),[]),onToastRemove:u.useCallback(()=>h(v=>v-1),[]),isFocusedToastEscapeKeyDownRef:p,isClosePausedRef:g,children:o})})};eK.displayName=KI;var tK="ToastViewport",gce=["F8"],P5="toast.viewportPause",E5="toast.viewportResume",sK=u.forwardRef((e,s)=>{const{__scopeToast:r,hotkey:n=gce,label:a="Notifications ({hotkey})",...i}=e,o=Ak(tK,r),l=hce(r),c=u.useRef(null),d=u.useRef(null),h=u.useRef(null),p=u.useRef(null),g=mr(s,p,o.onViewportChange),v=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=o.toastCount>0;u.useEffect(()=>{const w=j=>{n.length!==0&&n.every(C=>j[C]||j.code===C)&&p.current?.focus()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]),u.useEffect(()=>{const w=c.current,j=p.current;if(b&&w&&j){const x=()=>{if(!o.isClosePausedRef.current){const _=new CustomEvent(P5);j.dispatchEvent(_),o.isClosePausedRef.current=!0}},C=()=>{if(o.isClosePausedRef.current){const _=new CustomEvent(E5);j.dispatchEvent(_),o.isClosePausedRef.current=!1}},k=_=>{!w.contains(_.relatedTarget)&&C()},S=()=>{w.contains(document.activeElement)||C()};return w.addEventListener("focusin",x),w.addEventListener("focusout",k),w.addEventListener("pointermove",x),w.addEventListener("pointerleave",S),window.addEventListener("blur",x),window.addEventListener("focus",C),()=>{w.removeEventListener("focusin",x),w.removeEventListener("focusout",k),w.removeEventListener("pointermove",x),w.removeEventListener("pointerleave",S),window.removeEventListener("blur",x),window.removeEventListener("focus",C)}}},[b,o.isClosePausedRef]);const y=u.useCallback(({tabbingDirection:w})=>{const x=l().map(C=>{const k=C.ref.current,S=[k,...Ece(k)];return w==="forwards"?S:S.reverse()});return(w==="forwards"?x.reverse():x).flat()},[l]);return u.useEffect(()=>{const w=p.current;if(w){const j=x=>{const C=x.altKey||x.ctrlKey||x.metaKey;
8if(x.key==="Tab"&&!C){const S=document.activeElement,_=x.shiftKey;if(x.target===w&&_){d.current?.focus();return}const M=y({tabbingDirection:_?"backwards":"forwards"}),R=M.findIndex(D=>D===S);Z2(M.slice(R+1))?x.preventDefault():_?d.current?.focus():h.current?.focus()}};return w.addEventListener("keydown",j),()=>w.removeEventListener("keydown",j)}},[l,y]),t.jsxs(ace,{ref:c,role:"region","aria-label":a.replace("{hotkey}",v),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&t.jsx(T5,{ref:d,onFocusFromOutsideViewport:()=>{const w=y({tabbingDirection:"forwards"});Z2(w)}}),t.jsx(GI.Slot,{scope:r,children:t.jsx(Cr.ol,{tabIndex:-1,...i,ref:g})}),b&&t.jsx(T5,{ref:h,onFocusFromOutsideViewport:()=>{const w=y({tabbingDirection:"backwards"});Z2(w)}})]})});sK.displayName=tK;var rK="ToastFocusProxy",T5=u.forwardRef((e,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=e,i=Ak(rK,r);return t.jsx(zj,{"aria-hidden":!0,tabIndex:0,...a,ref:s,style:{position:"fixed"},onFocus:o=>{const l=o.relatedTarget;!i.viewport?.contains(l)&&n()}})});T5.displayName=rK;var Mk="Toast",xce="toast.swipeStart",vce="toast.swipeMove",yce="toast.swipeCancel",bce="toast.swipeEnd",nK=u.forwardRef((e,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:i,...o}=e,[l=!0,c]=ip({prop:n,defaultProp:a,onChange:i});return t.jsx($m,{present:r||l,children:t.jsx(Nce,{open:l,...o,ref:s,onClose:()=>c(!1),onPause:Za(e.onPause),onResume:Za(e.onResume),onSwipeStart:Ms(e.onSwipeStart,d=>{d.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Ms(e.onSwipeMove,d=>{const{x:h,y:p}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","move"),d.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${h}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${p}px`)}),onSwipeCancel:Ms(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:Ms(e.onSwipeEnd,d=>{const{x:h,y:p}=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",`${h}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${p}px`),c(!1)})})})});nK.displayName=Mk;var[wce,jce]=JW(Mk,{onClose(){}}),Nce=u.forwardRef((e,s)=>{const{__scopeToast:r,type:n="foreground",duration:a,open:i,onClose:o,onEscapeKeyDown:l,onPause:c,onResume:d,onSwipeStart:h,onSwipeMove:p,onSwipeCancel:g,onSwipeEnd:v,...b}=e,y=Ak(Mk,r),[w,j]=u.useState(null),x=mr(s,q=>j(q)),C=u.useRef(null),k=u.useRef(null),S=a||y.duration,_=u.useRef(0),A=u.useRef(S),T=u.useRef(0),{onToastAdd:M,onToastRemove:R}=y,D=Za(()=>{w?.contains(document.activeElement)&&y.viewport?.focus(),o()}),$=u.useCallback(q=>{!q||q===1/0||(window.clearTimeout(T.current),_.current=new Date().getTime(),T.current=window.setTimeout(D,q))},[D]);u.useEffect(()=>{const q=y.viewport;if(q){const V=()=>{$(A.current),d?.()},K=()=>{const G=new Date().getTime()-_.current;A.current=A.current-G,window.clearTimeout(T.current),c?.()};return q.addEventListener(P5,K),q.addEventListener(E5,V),()=>{q.removeEventListener(P5,K),q.removeEventListener(E5,V)}}},[y.viewport,S,c,d,$]),u.useEffect(()=>{i&&!y.isClosePausedRef.current&&$(S)},[i,S,y.isClosePausedRef,$]),u.useEffect(()=>(M(),()=>R()),[M,R]);const O=u.useMemo(()=>w?uK(w):null,[w]);return y.viewport?t.jsxs(t.Fragment,{children:[O&&t.jsx(Sce,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:O}),t.jsx(wce,{scope:r,onClose:D,children:Em.createPortal(t.jsx(GI.ItemSlot,{scope:r,children:t.jsx(nce,{asChild:!0,onEscapeKeyDown:Ms(l,()=>{y.isFocusedToastEscapeKeyDownRef.current||D(),y.isFocusedToastEscapeKeyDownRef.current=!1}),children:t.jsx(Cr.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":y.swipeDirection,...b,ref:x,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:Ms(e.onKeyDown,q=>{q.key==="Escape"&&(l?.(q.nativeEvent),q.nativeEvent.defaultPrevented||(y.isFocusedToastEscapeKeyDownRef.current=!0,D()))}),onPointerDown:Ms(e.onPointerDown,q=>{q.button===0&&(C.current={x:q.clientX,y:q.clientY})}),onPointerMove:Ms(e.onPointerMove,q=>{if(!C.current)return;const V=q.clientX-C.current.x,K=q.clientY-C.current.y,G=!!k.current,z=["left","right"].includes(y.swipeDirection),Z=["left","up"].includes(y.swipeDirection)?Math.min:Math.max,ee=z?Z(0,V):0,Q=z?0:Z(0,K),Y=q.pointerType==="touch"?10:2,oe={x:ee,y:Q},he={originalEvent:q,delta:oe};G?(k.current=oe,t1(vce,p,he,{discrete:!1})):w$(oe,y.swipeDirection,Y)?(k.current=oe,t1(xce,h,he,{discrete:!1}),q.target.setPointerCapture(q.pointerId)):(Math.abs(V)>Y||Math.abs(K)>Y)&&(C.current=null)}),onPointerUp:Ms(e.onPointerUp,q=>{const V=k.current,K=q.target;if(K.hasPointerCapture(q.pointerId)&&K.releasePointerCapture(q.pointerId),k.current=null,C.current=null,V){const G=q.currentTarget,z={originalEvent:q,delta:V};w$(V,y.swipeDirection,y.swipeThreshold)?t1(bce,v,z,{discrete:!0}):t1(yce,g,z,{discrete:!0}),G.addEventListener("click",Z=>Z.preventDefault(),{once:!0})}})})})}),y.viewport)})]}):null}),Sce=e=>{const{__scopeToast:s,children:r,...n}=e,a=Ak(Mk,s),[i,o]=u.useState(!1),[l,c]=u.useState(!1);return _ce(()=>o(!0)),u.useEffect(()=>{const d=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(d)},[]),l?null:t.jsx(Uj,{asChild:!0,children:t.jsx(zj,{...n,children:i&&t.jsxs(t.Fragment,{children:[a.label," ",r]})})})},Cce="ToastTitle",aK=u.forwardRef((e,s)=>{const{__scopeToast:r,...n}=e;return t.jsx(Cr.div,{...n,ref:s})});aK.displayName=Cce;var kce="ToastDescription",iK=u.forwardRef((e,s)=>{const{__scopeToast:r,...n}=e;return t.jsx(Cr.div,{...n,ref:s})});iK.displayName=kce;var oK="ToastAction",lK=u.forwardRef((e,s)=>{const{altText:r,...n}=e;return r.trim()?t.jsx(dK,{altText:r,asChild:!0,children:t.jsx(YI,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${oK}\`. Expected non-empty \`string\`.`),null)});lK.displayName=oK;var cK="ToastClose",YI=u.forwardRef((e,s)=>{const{__scopeToast:r,...n}=e,a=jce(cK,r);return t.jsx(dK,{asChild:!0,children:t.jsx(Cr.button,{type:"button",...n,ref:s,onClick:Ms(e.onClick,a.onClose)})})});YI.displayName=cK;var dK=u.forwardRef((e,s)=>{const{__scopeToast:r,altText:n,...a}=e;return t.jsx(Cr.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function uK(e){const s=[];
8return Array.from(e.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Pce(n)){const a=n.ariaHidden||n.hidden||n.style.display==="none",i=n.dataset.radixToastAnnounceExclude==="";if(!a)if(i){const o=n.dataset.radixToastAnnounceAlt;o&&s.push(o)}else s.push(...uK(n))}}),s}function t1(e,s,r,{discrete:n}){const a=r.originalEvent.currentTarget,i=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r});s&&a.addEventListener(e,s,{once:!0}),n?WI(a,i):a.dispatchEvent(i)}var w$=(e,s,r=0)=>{const n=Math.abs(e.x),a=Math.abs(e.y),i=n>a;return s==="left"||s==="right"?i&&n>r:!i&&a>r};function _ce(e=()=>{}){const s=Za(e);da(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function Pce(e){return e.nodeType===e.ELEMENT_NODE}function Ece(e){const s=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function Z2(e){const s=document.activeElement;return e.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var Tce=eK,mK=sK,hK=nK,pK=aK,fK=iK,gK=lK,xK=YI;function vK(e){var s,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(s=0;s<a;s++)e[s]&&(r=vK(e[s]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function An(){for(var e,s,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(s=vK(e))&&(n&&(n+=" "),n+=s);return n}const j$=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,N$=An,Hj=(e,s)=>r=>{var n;if(s?.variants==null)return N$(e,r?.class,r?.className);const{variants:a,defaultVariants:i}=s,o=Object.keys(a).map(d=>{const h=r?.[d],p=i?.[d];if(h===null)return null;const g=j$(h)||j$(p);return a[d][g]}),l=r&&Object.entries(r).reduce((d,h)=>{let[p,g]=h;return g===void 0||(d[p]=g),d},{}),c=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((d,h)=>{let{class:p,className:g,...v}=h;return Object.entries(v).every(b=>{let[y,w]=b;return Array.isArray(w)?w.includes({...i,...l}[y]):{...i,...l}[y]===w})?[...d,p,g]:d},[]);return N$(e,o,c,r?.class,r?.className)};const Ace=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),yK=(...e)=>e.filter((s,r,n)=>!!s&&n.indexOf(s)===r).join(" ");var Mce={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"};const Rce=u.forwardRef(({color:e="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:i,iconNode:o,...l},c)=>u.createElement("svg",{ref:c,...Mce,width:s,height:s,stroke:e,strokeWidth:n?Number(r)*24/Number(s):r,className:yK("lucide",a),...l},[...o.map(([d,h])=>u.createElement(d,h)),...Array.isArray(i)?i:[i]]));const Ve=(e,s)=>{const r=u.forwardRef(({className:n,...a},i)=>u.createElement(Rce,{ref:i,iconNode:s,className:yK(`lucide-${Ace(e)}`,n),...a}));return r.displayName=`${e}`,r};const vc=Ve("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"}]]);const bK=Ve("Aperture",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14.31 8 5.74 9.94",key:"1y6ab4"}],["path",{d:"M9.69 8h11.48",key:"1wxppr"}],["path",{d:"m7.38 12 5.74-9.94",key:"1grp0k"}],["path",{d:"M9.69 16 3.95 6.06",key:"libnyf"}],["path",{d:"M14.31 16H2.83",key:"x5fava"}],["path",{d:"m16.62 12-5.74 9.94",key:"1vwawt"}]]);const Ice=Ve("Apple",[["path",{d:"M12 20.94c1.5 0 2.75 1.06 4 1.06 3 0 6-8 6-12.22A4.91 4.91 0 0 0 17 5c-2.22 0-4 1.44-5 2-1-.56-2.78-2-5-2a4.9 4.9 0 0 0-5 4.78C2 14 5 22 8 22c1.25 0 2.5-1.06 4-1.06Z",key:"3s7exb"}],["path",{d:"M10 2c1 .5 2 2 2 5",key:"fcco2y"}]]);const Oce=Ve("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const Dce=Ve("ArrowDownLeft",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);const Lce=Ve("ArrowDownRight",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);const $ce=Ve("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);const S$=Ve("ArrowDownZA",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}
8],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);const wK=Ve("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);const Wi=Ve("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const N0=Ve("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const C$=Ve("ArrowUpAZ",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);const PS=Ve("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"}]]);const Fce=Ve("ArrowUpLeft",[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]]);const Bce=Ve("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);const jK=Ve("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);const Uce=Ve("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);const zce=Ve("Backpack",[["path",{d:"M4 10a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z",key:"1ol0lm"}],["path",{d:"M8 10h8",key:"c7uz4u"}],["path",{d:"M8 18h8",key:"1no2b1"}],["path",{d:"M8 22v-6a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v6",key:"1fr6do"}],["path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2",key:"donm21"}]]);const ES=Ve("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);const mi=Ve("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"}]]);const k$=Ve("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);const Hce=Ve("Bird",[["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20",key:"oj1oa8"}],["path",{d:"m20 7 2 .5-2 .5",key:"12nv4d"}],["path",{d:"M10 18v3",key:"1yea0a"}],["path",{d:"M14 17.75V21",key:"1pymcb"}],["path",{d:"M7 18a6 6 0 0 0 3.84-10.61",key:"1npnn0"}]]);const A5=Ve("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);const NK=Ve("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);const M5=Ve("BrainCircuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);const uw=Ve("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);const oh=Ve("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);const jy=Ve("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"}
8],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);const xi=Ve("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"}]]);const SK=Ve("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);const qce=Ve("Bus",[["path",{d:"M8 6v6",key:"18i7km"}],["path",{d:"M15 6v6",key:"1sg6z9"}],["path",{d:"M2 12h19.6",key:"de5uta"}],["path",{d:"M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3",key:"1wwztk"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}],["path",{d:"M9 18h5",key:"lrx6i"}],["circle",{cx:"16",cy:"18",r:"2",key:"1v4tcr"}]]);const R5=Ve("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);const nS=Ve("CalendarDays",[["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"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);const ro=Ve("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"}]]);const wo=Ve("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const Rk=Ve("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);const Vce=Ve("Cat",[["path",{d:"M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z",key:"x6xyqk"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M11.25 16.25h1.5L12 17l-.75-.75Z",key:"12kq1m"}]]);const no=Ve("Cctv",[["path",{d:"M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97",key:"ir91b5"}],["path",{d:"M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z",key:"jlp8i1"}],["path",{d:"M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15",key:"19bib8"}],["path",{d:"M2 21v-4",key:"l40lih"}],["path",{d:"M7 9h.01",key:"19b3jx"}]]);const QI=Ve("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"}]]);const Wce=Ve("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);const Hx=Ve("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);const Kce=Ve("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",ke
8y:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);const Hd=Ve("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Xa=Ve("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Kl=Ve("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const hi=Ve("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ig=Ve("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const CK=Ve("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);const ta=Ve("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"}]]);const Ny=Ve("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);const ar=Ve("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const kK=Ve("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);const Gce=Ve("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"}]]);const _K=Ve("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);const Yce=Ve("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);const rf=Ve("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"}]]);const PK=Ve("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Qce=Ve("Clapperboard",[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]]);const Xce=Ve("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);const cn=Ve("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);const Zce=Ve("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);const pn=Ve("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);const EK=Ve("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const I5=Ve("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"}]]);const uf=Ve("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}
8],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);const Jce=Ve("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);const mg=Ve("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);const mf=Ve("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"}]]);const ede=Ve("Dog",[["path",{d:"M11.25 16.25h1.5L12 17z",key:"w7jh35"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309",key:"u7s9ue"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5",key:"v8hric"}]]);const S0=Ve("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);const ya=Ve("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"}]]);const TK=Ve("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"}]]);const _$=Ve("Eclipse",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a7 7 0 1 0 10 10",key:"1yuj32"}]]);const tde=Ve("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);const op=Ve("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"}]]);const Gp=Ve("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"}]]);const Xr=Ve("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"}]]);const AK=Ve("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);const J2=Ve("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",key:"1mlx9k"}]]);const XI=Ve("FileDown",[["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:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);const eP=Ve("FileSpreadsheet",[["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:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);const xu=Ve("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"}]]);const ZI=Ve("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);const qj=Ve("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);const sde=Ve("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}
8],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);const rde=Ve("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);const P$=Ve("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"}]]);const hf=Ve("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);const nde=Ve("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);const Yp=Ve("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"}]]);const MK=Ve("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);const ade=Ve("Grid2x2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M12 3v18",key:"108xh3"}]]);const JI=Ve("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const RK=Ve("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);const Fa=Ve("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"}]]);const IK=Ve("Headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);const OK=Ve("HeartPulse",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"1uw2ng"}]]);const ide=Ve("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);const e0=Ve("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"}]]);const ode=Ve("Hotel",[["path",{d:"M10 22v-6.57",key:"1wmca3"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M12 7h.01",key:"1ivr5q"}],["path",{d:"M14 15.43V22",key:"1q2vjd"}],["path",{d:"M15 16a5 5 0 0 0-6 0",key:"o9wqvi"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 7h.01",key:"1vti4s"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]]);const Ik=Ve("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);const lde=Ve("ImageOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]);const Ok=Ve("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const Sy=Ve("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);const $w=Ve("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);const yg=Ve("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"}]]);const DK=Ve("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);
8const eO=Ve("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);const tO=Ve("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"}]]);const Cy=Ve("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);const LK=Ve("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);const cde=Ve("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"}]]);const $K=Ve("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const dde=Ve("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);const s1=Ve("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);const ky=Ve("ListVideo",[["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}],["path",{d:"m16 12 5 3-5 3v-6Z",key:"zpskkp"}]]);const ude=Ve("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);const Fe=Ve("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const mde=Ve("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);const ka=Ve("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"}]]);const hde=Ve("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"}]]);const qi=Ve("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"}]]);const ql=Ve("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);const pde=Ve("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);const pf=Ve("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"}]]);const fde=Ve("MemoryStick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]);const FK=Ve("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);const O5=Ve("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);const qx=Ve("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);const C0=Ve("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"}]]);const BK=Ve("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const gde=Ve("MonitorCheck",[["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);const Cg=Ve("MonitorPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);const Vx=Ve("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"}]]);const E$=Ve("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);const _y=Ve("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);const cg=Ve("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"}]]);const UK=Ve("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);const sO=Ve("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);const rO=Ve("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);const xde=Ve("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);const nO=Ve("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"}]]);const T$=Ve("PawPrint",[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]]);const vde=Ve("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"}]]);const ga=Ve("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"}]]);const yde=Ve("PersonStanding",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["path",{d:"m9 20 3-6 3 6",key:"se2kox"}],["path",{d:"m6 8 6 2 6-2",key:"4o3us4"}],["path",{d:"M12 10v4",key:"1kjpxc"}
8]]);const Qp=Ve("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"}]]);const vu=Ve("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const bde=Ve("Plug2",[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0Z",key:"wtfw2c"}]]);const Fo=Ve("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const kg=Ve("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);const Wh=Ve("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["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"}]]);const zK=Ve("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);const HK=Ve("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);const tl=Ve("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"}]]);const wde=Ve("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);const bh=Ve("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"}]]);const aO=Ve("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);const t0=Ve("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);const Vl=Ve("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"}]]);const qK=Ve("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);const ai=Ve("ScanSearch",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]]);const yc=Ve("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);const Ja=Ve("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"}]]);const Wx=Ve("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"}]]);const jde=Ve("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);const xd=Ve("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"}]]);const Nde=Ve("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);const Sde=Ve("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]);const iO=Ve("ShieldAlert",[["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
8y:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);const vi=Ve("ShieldCheck",[["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",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const uc=Ve("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",key:"oel41y"}]]);const Cde=Ve("Ship",[["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1 .6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"iegodh"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-9-4-9 4c0 2.9.94 5.34 2.81 7.76",key:"fp8vka"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M12 10v4",key:"1kjpxc"}],["path",{d:"M12 2v3",key:"qbqxhf"}]]);const VK=Ve("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);const kde=Ve("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);const _de=Ve("Signal",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]]);const Pde=Ve("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]);const Ede=Ve("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);const oO=Ve("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);const Yc=Ve("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const Do=Ve("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"}]]);const Tde=Ve("SquarePlus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);const WK=Ve("Star",[["polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2",key:"8f66p6"}]]);const Ade=Ve("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);const A$=Ve("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);const KK=Ve("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);
8const Py=Ve("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const Mde=Ve("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);const D5=Ve("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);const Rde=Ve("Thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]);const Ide=Ve("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);const Ode=Ve("TicketPercent",[["path",{d:"M2 9a3 3 0 1 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 1 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"1l48ns"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);const k0=Ve("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);const Dde=Ve("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"}]]);const sa=Ve("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"}]]);const lO=Ve("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);const Pn=Ve("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"}]]);const cO=Ve("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);const Lde=Ve("Umbrella",[["path",{d:"M22 12a10.06 10.06 1 0 0-20 0Z",key:"1teyop"}],["path",{d:"M12 12v8a2 2 0 0 0 4 0",key:"ulpmoc"}],["path",{d:"M12 2v1",key:"11qlp1"}]]);const Om=Ve("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"}]]);const GK=Ve("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"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);const ny=Ve("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"}]]);const dO=Ve("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"}]]);const Ba=Ve("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"}]]);const YK=Ve("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]]);const QK=Ve("VideoOff",[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const Vi=Ve("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);const XK=Ve("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);const M$=Ve("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);const ZK=Ve("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const $de=Ve("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"}
vendor: 10,406 bytes, line 8
8],["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"}]]);const jb=Ve("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"}]]);const Fde=Ve("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);const va=Ve("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const Nb=Ve("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"}]]);const Vj=Ve("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);const uO=Ve("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),mO="-",Bde=e=>{const s=zde(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(mO);return l[0]===""&&l.length!==1&&l.shift(),JK(l,s)||Ude(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},JK=(e,s)=>{if(e.length===0)return s.classGroupId;const r=e[0],n=s.nextPart.get(r),a=n?JK(e.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const i=e.join(mO);return s.validators.find(({validator:o})=>o(i))?.classGroupId},R$=/^\[(.+)\]$/,Ude=e=>{if(R$.test(e)){const s=R$.exec(e)[1],r=s?.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},zde=e=>{const{theme:s,prefix:r}=e,n={nextPart:new Map,validators:[]};return qde(Object.entries(e.classGroups),r).forEach(([i,o])=>{L5(o,n,i,s)}),n},L5=(e,s,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?s:I$(s,a);i.classGroupId=r;return}if(typeof a=="function"){if(Hde(a)){L5(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([i,o])=>{L5(o,I$(s,i),r,n)})})},I$=(e,s)=>{let r=e;return s.split(mO).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},Hde=e=>e.isThemeGetter,qde=(e,s)=>s?e.map(([r,n])=>{const a=n.map(i=>typeof i=="string"?s+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,l])=>[s+o,l])):i);return[r,a]}):e,Vde=e=>{if(e<1)return{get:()=>{},set:()=>{}};let s=0,r=new Map,n=new Map;const a=(i,o)=>{r.set(i,o),s++,s>e&&(s=0,n=r,r=new Map)};return{get(i){let o=r.get(i);if(o!==void 0)return o;if((o=n.get(i))!==void 0)return a(i,o),o},set(i,o){r.has(i)?r.set(i,o):a(i,o)}}},eG="!",Wde=e=>{const{separator:s,experimentalParseClassName:r}=e,n=s.length===1,a=s[0],i=s.length,o=l=>{const c=[];let d=0,h=0,p;for(let w=0;w<l.length;w++){let j=l[w];if(d===0){if(j===a&&(n||l.slice(w,w+i)===s)){c.push(l.slice(h,w)),h=w+i;continue}if(j==="/"){p=w;continue}}j==="["?d++:j==="]"&&d--}const g=c.length===0?l:l.substring(h),v=g.startsWith(eG),b=v?g.substring(1):g,y=p&&p>h?p-h:void 0;return{modifiers:c,hasImportantModifier:v,baseClassName:b,maybePostfixModifierPosition:y}};return r?l=>r({className:l,parseClassName:o}):o},Kde=e=>{if(e.length<=1)return e;const s=[];let r=[];return e.forEach(n=>{n[0]==="["?(s.push(...r.sort(),n),r=[]):r.push(n)}),s.push(...r.sort()),s},Gde=e=>({cache:Vde(e.cacheSize),parseClassName:Wde(e),...Bde(e)}),Yde=/\s+/,Qde=(e,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,i=[],o=e.trim().split(Yde);let l="";for(let c=o.length-1;c>=0;c-=1){const d=o[c],{modifiers:h,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:v}=r(d);let b=!!v,y=n(b?g.substring(0,v):g);if(!y){if(!b){l=d+(l.length>0?" "+l:l);continue}if(y=n(g),!y){l=d+(l.length>0?" "+l:l);continue}b=!1}const w=Kde(h).join(":"),j=p?w+eG:w,x=j+y;if(i.includes(x))continue;i.push(x);const C=a(y,b);for(let k=0;k<C.length;++k){const S=C[k];i.push(j+S)}l=d+(l.length>0?" "+l:l)}return l};function Xde(){let e=0,s,r,n="";for(;e<arguments.length;)(s=arguments[e++])&&(r=tG(s))&&(n&&(n+=" "),n+=r);return n}const tG=e=>{if(typeof e=="string")return e;let s,r="";for(let n=0;n<e.length;n++)e[n]&&(s=tG(e[n]))&&(r&&(r+=" "),r+=s);return r};function Zde(e,...s){let r,n,a,i=o;function o(c){const d=s.reduce((h,p)=>p(h),e());return r=Gde(d),n=r.cache.get,a=r.cache.set,i=l,l(c)}function l(c){const d=n(c);if(d)return d;const h=Qde(c,r);return a(c,h),h}return function(){return i(Xde.apply(null,arguments))}}const Bi=e=>{const s=r=>r[e]||[];return s.isThemeGetter=!0,s},sG=/^\[(?:([a-z-]+):)?(.+)\]$/i,Jde=/^\d+\/\d+$/,eue=new Set(["px","full","screen"]),tue=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sue=/\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$/,rue=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,nue=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,aue=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Rp=e=>ay(e)||eue.has(e)||Jde.test(e),Gf=e=>Sb(e,"length",hue),ay=e=>!!e&&!Number.isNaN(Number(e)),tP=e=>Sb(e,"number",ay),mw=e=>!!e&&Number.isInteger(Number(e)),iue=e=>e.endsWith("%")&&ay(e.slice(0,-1)),Rn=e=>sG.test(e),Yf=e=>tue.test(e),oue=new Set(["length","size","percentage"]),lue=e=>Sb(e,oue,rG),cue=e=>Sb(e,"position",rG),due=new Set(["image","url"]),uue=e=>Sb(e,due,fue),mue=e=>Sb(e,"",pue),hw=()=>!0,Sb=(e,s,r)=>{const n=sG.exec(e);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},hue=e=>sue.test(e)&&!rue.test(e),rG=()=>!1,pue=e=>nue.test(e),fue=e=>aue.test(e),gue=()=>{const e=Bi("colors"),s=Bi("spacing"),r=Bi("blur"),n=Bi("brightness"),a=Bi("borderColor"),i=Bi("borderRadius"),o=Bi("borderSpacing"),l=Bi("borderWidth"),c=Bi("contrast"),d=Bi("grayscale"),h=Bi("hueRotate"),p=Bi("invert"),g=Bi("gap"),v=Bi("gradientColorStops"),b=Bi("gradientColorStopPositions"),y=Bi("inset"),w=Bi("margin"),j=Bi("opacity"),x=Bi("padding"),C=Bi("saturate"),k=Bi("scale"),S=Bi("sepia"),_=Bi("skew"),A=Bi("space"),T=Bi("translate"),M=()=>["auto","contain","none"],R=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto",Rn,s],$=()=>[Rn,s],O=()=>["",Rp,Gf],q=()=>["auto",ay,Rn],V=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],K=()=>["solid","dashed","dotted","double","none"],G=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],z=()=>["start","end","center","between","around","evenly","stretch"],Z=()=>["","0",Rn],ee=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Q=()=>[ay,Rn];return{cacheSize:500,separator:":",theme:{colors:[hw],spacing:[Rp,Gf],blur:["none","",Yf,Rn],brightness:Q(),borderColor:[e],borderRadius:["none","","full",Yf,Rn],borderSpacing:$(),borderWidth:O(),contrast:Q(),grayscale:Z(),hueRotate:Q(),invert:Z(),gap:$(),gradientColorStops:[e],gradientColorStopPositions:[iue,Gf],inset:D(),margin:D(),opacity:Q(),padding:$(),saturate:Q(),scale:Q(),sepia:Z(),skew:Q(),space:$(),translate:$()},classGroups:{aspect:[{aspect:["auto","square","video",Rn]}],container:["container"],columns:[{columns:[Yf]}],"break-after":[{"break-after":ee()}],"break-before":[{"break-before":ee()}],"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:[...V(),Rn]}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",mw,Rn]}],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",Rn]}],grow:[{grow:Z()}],shrink:[{shrink:Z()}],order:[{order:["first","last","none",mw,Rn]}],"grid-cols":[{"grid-cols":[hw]}],"col-start-end":[{col:["auto",{span:["full",mw,Rn]},Rn]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[hw]}],"row-start-end":[{row:["auto",{span:[mw,Rn]},Rn]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Rn]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Rn]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...z()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...z(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...z(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[x]}],px:[{px:[x]}],py:[{py:[x]}],ps:[{ps:[x]}
vendor: 8,343 bytes, line 8
8],pe:[{pe:[x]}],pt:[{pt:[x]}],pr:[{pr:[x]}],pb:[{pb:[x]}],pl:[{pl:[x]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[A]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[A]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Rn,s]}],"min-w":[{"min-w":[Rn,s,"min","max","fit"]}],"max-w":[{"max-w":[Rn,s,"none","full","min","max","fit","prose",{screen:[Yf]},Yf]}],h:[{h:[Rn,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Rn,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Rn,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Rn,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Yf,Gf]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",tP]}],"font-family":[{font:[hw]}],"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",Rn]}],"line-clamp":[{"line-clamp":["none",ay,tP]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Rp,Rn]}],"list-image":[{"list-image":["none",Rn]}],"list-style-type":[{list:["none","disc","decimal",Rn]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[j]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[j]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...K(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Rp,Gf]}],"underline-offset":[{"underline-offset":["auto",Rp,Rn]}],"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:$()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Rn]}],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",Rn]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[j]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...V(),cue]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",lue]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},uue]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[v]}],"gradient-via":[{via:[v]}],"gradient-to":[{to:[v]}],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":[j]}],"border-style":[{border:[...K(),"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":[j]}],"divide-style":[{divide:K()}],"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:["",...K()]}],"outline-offset":[{"outline-offset":[Rp,Rn]}],"outline-w":[{outline:[Rp,Gf]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:O()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[j]}],"ring-offset-w":[{"ring-offset":[Rp,Gf]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Yf,mue]}],"shadow-color":[{shadow:[hw]}],opacity:[{opacity:[j]}],"mix-blend":[{"mix-blend":[...G(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":G()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",Yf,Rn]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[p]}],saturate:[{saturate:[C]}],sepia:[{sepia:[S]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[p]}],"backdrop-opacity":[{"backdrop-opacity":[j]}],"backdrop-saturate":[{"backdrop-saturate":[C]}],"backdrop-sepia":[{"backdrop-sepia":[S]}],"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",Rn]}],duration:[{duration:Q()}],ease:[{ease:["linear","in","out","in-out",Rn]}],delay:[{delay:Q()}],animate:[{animate:["none","spin","ping","pulse","bounce",Rn]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[mw,Rn]}],"translate-x":[{"translate-x":[T]}],"translate-y":[{"translate-y":[T]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Rn]}],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",Rn]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":$()}],"scroll-mx":[{"scroll-mx":$()}],"scroll-my":[{"scroll-my":$()}],"scroll-ms":[{"scroll-ms":$()}],"scroll-me":[{"scroll-me":$()}],"scroll-mt":[{"scroll-mt":$()}],"scroll-mr":[{"scroll-mr":$()}],"scroll-mb":[{"scroll-mb":$()}],"scroll-ml":[{"scroll-ml":$()}],"scroll-p":[{"scroll-p":$()}],"scroll-px":[{"scroll-px":$()}],"scroll-py":[{"scroll-py":$()}],"scroll-ps":[{"scroll-ps":$()}],"scroll-pe":[{"scroll-pe":$()}],"scroll-pt":[{"scroll-pt":$()}],"scroll-pr":[{"scroll-pr":$()}],"scroll-pb":[{"scroll-pb":$()}],"scroll-pl":[{"scroll-pl":$()}],"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"]}
8],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",Rn]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Rp,Gf,tP]}],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"]}}},xue=Zde(gue);function Cs(...e){return xue(An(e))}function Vp(e){return(e??"").trim()}function zi(e,s){return Vp(e).localeCompare(Vp(s))}function nG(e){const{camera:s,severity:r,label:n,displayName:a,ext:i="mp4"}=e,l=n==="motion"||r==="detection"||!r&&!n?"motion":"ai",c=(a||s).replace(/[\\/:*?"<>|]/g,"_"),d=typeof e.startTime=="number"?new Date(e.startTime*1e3):e.startTime,h=y=>y.toString().padStart(2,"0"),p=d.getHours(),g=p>=12?"PM":"AM",v=p%12||12,b=`${h(d.getMonth()+1)}-${h(d.getDate())}-${d.getFullYear()} ${h(v)}_${h(d.getMinutes())}_${h(d.getSeconds())} ${g}`;return`${s}_${l}-${c}-${b}.${i}`}const vue=Tce,aG=u.forwardRef(({className:e,...s},r)=>t.jsx(mK,{ref:r,className:Cs("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),...s}));aG.displayName=mK.displayName;const yue=Hj("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"}}),iG=u.forwardRef(({className:e,variant:s,...r},n)=>t.jsx(hK,{ref:n,className:Cs(yue({variant:s}),e),...r}));iG.displayName=hK.displayName;const bue=u.forwardRef(({className:e,...s},r)=>t.jsx(gK,{ref:r,className:Cs("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 hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...s}));bue.displayName=gK.displayName;const oG=u.forwardRef(({className:e,...s},r)=>t.jsx(xK,{ref:r,className:Cs("absolute right-2 top-2 rounded-md p-1 text-foreground
vendor: 3,866 bytes, line 8
8/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...s,children:t.jsx(va,{className:"h-4 w-4"})}));oG.displayName=xK.displayName;const lG=u.forwardRef(({className:e,...s},r)=>t.jsx(pK,{ref:r,className:Cs("text-sm font-semibold",e),...s}));lG.displayName=pK.displayName;const cG=u.forwardRef(({className:e,...s},r)=>t.jsx(fK,{ref:r,className:Cs("text-sm opacity-90",e),...s}));cG.displayName=fK.displayName;function wue(){const{toasts:e}=Hs();return t.jsxs(vue,{children:[e.map(function({id:s,title:r,description:n,action:a,...i}){return t.jsxs(iG,{...i,children:[t.jsxs("div",{className:"grid gap-1",children:[r&&t.jsx(lG,{children:r}),n&&t.jsx(cG,{children:n})]}),a,t.jsx(oG,{})]},s)}),t.jsx(aG,{})]})}var jue=bb[" useId ".trim().toString()]||(()=>{}),Nue=0;function wu(e){const[s,r]=u.useState(jue());return da(()=>{r(n=>n??String(Nue++))},[e]),s?`radix-${s}`:""}const Sue=["top","right","bottom","left"],_g=Math.min,Gu=Math.max,TS=Math.round,r1=Math.floor,tp=e=>({x:e,y:e}),Cue={left:"right",right:"left",bottom:"top",top:"bottom"},kue={start:"end",end:"start"};function $5(e,s,r){return Gu(e,_g(s,r))}function ff(e,s){return typeof e=="function"?e(s):e}function gf(e){return e.split("-")[0]}function Cb(e){return e.split("-")[1]}function hO(e){return e==="x"?"y":"x"}function pO(e){return e==="y"?"height":"width"}function Pg(e){return["top","bottom"].includes(gf(e))?"y":"x"}function fO(e){return hO(Pg(e))}function _ue(e,s,r){r===void 0&&(r=!1);const n=Cb(e),a=fO(e),i=pO(a);let o=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[i]>s.floating[i]&&(o=AS(o)),[o,AS(o)]}function Pue(e){const s=AS(e);return[F5(e),s,F5(s)]}function F5(e){return e.replace(/start|end/g,s=>kue[s])}function Eue(e,s,r){const n=["left","right"],a=["right","left"],i=["top","bottom"],o=["bottom","top"];switch(e){case"top":case"bottom":return r?s?a:n:s?n:a;case"left":case"right":return s?i:o;default:return[]}}function Tue(e,s,r,n){const a=Cb(e);let i=Eue(gf(e),r==="start",n);return a&&(i=i.map(o=>o+"-"+a),s&&(i=i.concat(i.map(F5)))),i}function AS(e){return e.replace(/left|right|bottom|top/g,s=>Cue[s])}function Aue(e){return{top:0,right:0,bottom:0,left:0,...e}}function dG(e){return typeof e!="number"?Aue(e):{top:e,right:e,bottom:e,left:e}}function MS(e){const{x:s,y:r,width:n,height:a}=e;return{width:n,height:a,top:r,left:s,right:s+n,bottom:r+a,x:s,y:r}}function O$(e,s,r){let{reference:n,floating:a}=e;const i=Pg(s),o=fO(s),l=pO(o),c=gf(s),d=i==="y",h=n.x+n.width/2-a.width/2,p=n.y+n.height/2-a.height/2,g=n[l]/2-a[l]/2;let v;switch(c){case"top":v={x:h,y:n.y-a.height};break;case"bottom":v={x:h,y:n.y+n.height};break;case"right":v={x:n.x+n.width,y:p};break;case"left":v={x:n.x-a.width,y:p};break;default:v={x:n.x,y:n.y}}switch(Cb(s)){case"start":v[o]-=g*(r&&d?-1:1);break;case"end":v[o]+=g*(r&&d?-1:1);break}return v}const Mue=async(e,s,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:i=[],platform:o}=r,l=i.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(s));let d=await o.getElementRects({reference:e,floating:s,strategy:a}),{x:h,y:p}=O$(d,n,c),g=n,v={},b=0;for(let y=0;y<l.length;y++){const{name:w,fn:j}=l[y],{x,y:C,data:k,reset:S}=await j({x:h,y:p,initialPlacement:n,placement:g,strategy:a,middlewareData:v,rects:d,platform:o,elements:{reference:e,floating:s}});h=x??h,p=C??p,v={...v,[w]:{...v[w],...k}},S&&b<=50&&(b++,typeof S=="object"&&(S.placement&&(g=S.placement),S.rects&&(d=S.rects===!0?await o.getElementRects({reference:e,floating:s,strategy:a}):S.rects),{x:h,y:p}=O$(d,g,c)),y=-1)}return{x:h,y:p,placement:g,strategy:a,middlewareData:v}};
vendor: 9,123 bytes, line 8
8async function _0(e,s){var r;s===void 0&&(s={});const{x:n,y:a,platform:i,rects:o,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:p="floating",altBoundary:g=!1,padding:v=0}=ff(s,e),b=dG(v),w=l[g?p==="floating"?"reference":"floating":p],j=MS(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(w)))==null||r?w:w.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:c})),x=p==="floating"?{x:n,y:a,width:o.floating.width,height:o.floating.height}:o.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),k=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},S=MS(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:C,strategy:c}):x);return{top:(j.top-S.top+b.top)/k.y,bottom:(S.bottom-j.bottom+b.bottom)/k.y,left:(j.left-S.left+b.left)/k.x,right:(S.right-j.right+b.right)/k.x}}const Rue=e=>({name:"arrow",options:e,async fn(s){const{x:r,y:n,placement:a,rects:i,platform:o,elements:l,middlewareData:c}=s,{element:d,padding:h=0}=ff(e,s)||{};if(d==null)return{};const p=dG(h),g={x:r,y:n},v=fO(a),b=pO(v),y=await o.getDimensions(d),w=v==="y",j=w?"top":"left",x=w?"bottom":"right",C=w?"clientHeight":"clientWidth",k=i.reference[b]+i.reference[v]-g[v]-i.floating[b],S=g[v]-i.reference[v],_=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let A=_?_[C]:0;(!A||!await(o.isElement==null?void 0:o.isElement(_)))&&(A=l.floating[C]||i.floating[b]);const T=k/2-S/2,M=A/2-y[b]/2-1,R=_g(p[j],M),D=_g(p[x],M),$=R,O=A-y[b]-D,q=A/2-y[b]/2+T,V=$5($,q,O),K=!c.arrow&&Cb(a)!=null&&q!==V&&i.reference[b]/2-(q<$?R:D)-y[b]/2<0,G=K?q<$?q-$:q-O:0;return{[v]:g[v]+G,data:{[v]:V,centerOffset:q-V-G,...K&&{alignmentOffset:G}},reset:K}}}),Iue=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(s){var r,n;const{placement:a,middlewareData:i,rects:o,initialPlacement:l,platform:c,elements:d}=s,{mainAxis:h=!0,crossAxis:p=!0,fallbackPlacements:g,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:y=!0,...w}=ff(e,s);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const j=gf(a),x=Pg(l),C=gf(l)===l,k=await(c.isRTL==null?void 0:c.isRTL(d.floating)),S=g||(C||!y?[AS(l)]:Pue(l)),_=b!=="none";!g&&_&&S.push(...Tue(l,y,b,k));const A=[l,...S],T=await _0(s,w),M=[];let R=((n=i.flip)==null?void 0:n.overflows)||[];if(h&&M.push(T[j]),p){const q=_ue(a,o,k);M.push(T[q[0]],T[q[1]])}if(R=[...R,{placement:a,overflows:M}],!M.every(q=>q<=0)){var D,$;const q=(((D=i.flip)==null?void 0:D.index)||0)+1,V=A[q];if(V)return{data:{index:q,overflows:R},reset:{placement:V}};let K=($=R.filter(G=>G.overflows[0]<=0).sort((G,z)=>G.overflows[1]-z.overflows[1])[0])==null?void 0:$.placement;if(!K)switch(v){case"bestFit":{var O;const G=(O=R.filter(z=>{if(_){const Z=Pg(z.placement);return Z===x||Z==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(Z=>Z>0).reduce((Z,ee)=>Z+ee,0)]).sort((z,Z)=>z[1]-Z[1])[0])==null?void 0:O[0];G&&(K=G);break}case"initialPlacement":K=l;break}if(a!==K)return{reset:{placement:K}}}return{}}}};function D$(e,s){return{top:e.top-s.height,right:e.right-s.width,bottom:e.bottom-s.height,left:e.left-s.width}}function L$(e){return Sue.some(s=>e[s]>=0)}const Oue=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=ff(e,s);switch(n){case"referenceHidden":{const i=await _0(s,{...a,elementContext:"reference"}),o=D$(i,r.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:L$(o)}}}case"escaped":{const i=await _0(s,{...a,altBoundary:!0}),o=D$(i,r.floating);return{data:{escapedOffsets:o,escaped:L$(o)}}}default:return{}}}}};async function Due(e,s){const{placement:r,platform:n,elements:a}=e,i=await(n.isRTL==null?void 0:n.isRTL(a.floating)),o=gf(r),l=Cb(r),c=Pg(r)==="y",d=["left","top"].includes(o)?-1:1,h=i&&c?-1:1,p=ff(s,e);let{mainAxis:g,crossAxis:v,alignmentAxis:b}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof b=="number"&&(v=l==="end"?b*-1:b),c?{x:v*h,y:g*d}:{x:g*d,y:v*h}}const Lue=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(s){var r,n;const{x:a,y:i,placement:o,middlewareData:l}=s,c=await Due(s,e);return o===((r=l.offset)==null?void 0:r.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:a+c.x,y:i+c.y,data:{...c,placement:o}}}}},$ue=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:i=!0,crossAxis:o=!1,limiter:l={fn:w=>{let{x:j,y:x}=w;return{x:j,y:x}}},...c}=ff(e,s),d={x:r,y:n},h=await _0(s,c),p=Pg(gf(a)),g=hO(p);let v=d[g],b=d[p];if(i){const w=g==="y"?"top":"left",j=g==="y"?"bottom":"right",x=v+h[w],C=v-h[j];v=$5(x,v,C)}if(o){const w=p==="y"?"top":"left",j=p==="y"?"bottom":"right",x=b+h[w],C=b-h[j];b=$5(x,b,C)}const y=l.fn({...s,[g]:v,[p]:b});return{...y,data:{x:y.x-r,y:y.y-n,enabled:{[g]:i,[p]:o}}}}}},Fue=function(e){return e===void 0&&(e={}),{options:e,fn(s){const{x:r,y:n,placement:a,rects:i,middlewareData:o}=s,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=ff(e,s),h={x:r,y:n},p=Pg(a),g=hO(p);let v=h[g],b=h[p];const y=ff(l,s),w=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(c){const C=g==="y"?"height":"width",k=i.reference[g]-i.floating[C]+w.mainAxis,S=i.reference[g]+i.reference[C]-w.mainAxis;v<k?v=k:v>S&&(v=S)}if(d){var j,x;const C=g==="y"?"width":"height",k=["top","left"].includes(gf(a)),S=i.reference[p]-i.floating[C]+(k&&((j=o.offset)==null?void 0:j[p])||0)+(k?0:w.crossAxis),_=i.reference[p]+i.reference[C]+(k?0:((x=o.offset)==null?void 0:x[p])||0)-(k?w.crossAxis:0);b<S?b=S:b>_&&(b=_)}return{[g]:v,[p]:b}}}},Bue=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(s){var r,n;const{placement:a,rects:i,platform:o,elements:l}=s,{apply:c=()=>{},...d}=ff(e,s),h=await _0(s,d),p=gf(a),g=Cb(a),v=Pg(a)==="y",{width:b,height:y}=i.floating;let w,j;p==="top"||p==="bottom"?(w=p,j=g===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(j=p,w=g==="end"?"top":"bottom");const x=y-h.top-h.bottom,C=b-h.left-h.right,k=_g(y-h[w],x),S=_g(b-h[j],C),_=!s.middlewareData.shift;let A=k,T=S;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(T=C),(n=s.middlewareData.shift)!=null&&n.enabled.y&&(A=x),_&&!g){const R=Gu(h.left,0),D=Gu(h.right,0),$=Gu(h.top,0),O=Gu(h.bottom,0);v?T=b-2*(R!==0||D!==0?R+D:Gu(h.left,h.right)):A=y-2*($!==0||O!==0?$+O:Gu(h.top,h.bottom))}await c({...s,availableWidth:T,availableHeight:A});const M=await o.getDimensions(l.floating);return b!==M.width||y!==M.height?{reset:{rects:!0}}:{}}}};function Dk(){return typeof window<"u"}function kb(e){return uG(e)?(e.nodeName||"").toLowerCase():"#document"}function Zu(e){var s;return(e==null||(s=e.ownerDocument)==null?void 0:s.defaultView)||window}function fp(e){var s;return(s=(uG(e)?e.ownerDocument:e.document)||window.document)==null?void 0:s.documentElement}function uG(e){return Dk()?e instanceof Node||e instanceof Zu(e).Node:!1}function wh(e){return Dk()?e instanceof Element||e instanceof Zu(e).Element:!1}function lp(e){return Dk()?e instanceof HTMLElement||e instanceof Zu(e).HTMLElement:!1}function $$(e){return!Dk()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Zu(e).ShadowRoot}function Wj(e){const{overflow:s,overflowX:r,overflowY:n,display:a}=jh(e);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!["inline","contents"].includes(a)}function Uue(e){return["table","td","th"].includes(kb(e))}function Lk(e){return[":popover-open",":modal"].some(s=>{try{return e.matches(s)}catch{return!1}})}function gO(e){const s=xO(),r=wh(e)?jh(e):e;return["transform","translate","scale","rotate","perspective"].some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!s&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!s&&(r.filter?r.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(n=>(r.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(r.contain||"").includes(n))}function zue(e){let s=Eg(e);for(;lp(s)&&!Ey(s);){if(gO(s))return s;if(Lk(s))return null;s=Eg(s)}return null}function xO(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Ey(e){return["html","body","#document"].includes(kb(e))}function jh(e){return Zu(e).getComputedStyle(e)}function $k(e){return wh(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Eg(e){if(kb(e)==="html")return e;const s=e.assignedSlot||e.parentNode||$$(e)&&e.host||fp(e);return $$(s)?s.host:s}function mG(e){const s=Eg(e);return Ey(s)?e.ownerDocument?e.ownerDocument.body:e.body:lp(s)&&Wj(s)?s:mG(s)}function P0(e,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=mG(e),i=a===((n=e.ownerDocument)==null?void 0:n.body),o=Zu(a);if(i){const l=B5(o);
vendor: 4,312 bytes, line 8
8return s.concat(o,o.visualViewport||[],Wj(a)?a:[],l&&r?P0(l):[])}return s.concat(a,P0(a,[],r))}function B5(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hG(e){const s=jh(e);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=lp(e),i=a?e.offsetWidth:r,o=a?e.offsetHeight:n,l=TS(r)!==i||TS(n)!==o;return l&&(r=i,n=o),{width:r,height:n,$:l}}function vO(e){return wh(e)?e:e.contextElement}function iy(e){const s=vO(e);if(!lp(s))return tp(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:i}=hG(s);let o=(i?TS(r.width):r.width)/n,l=(i?TS(r.height):r.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const Hue=tp(0);function pG(e){const s=Zu(e);return!xO()||!s.visualViewport?Hue:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function que(e,s,r){return s===void 0&&(s=!1),!r||s&&r!==Zu(e)?!1:s}function Kx(e,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=e.getBoundingClientRect(),i=vO(e);let o=tp(1);s&&(n?wh(n)&&(o=iy(n)):o=iy(e));const l=que(i,r,n)?pG(i):tp(0);let c=(a.left+l.x)/o.x,d=(a.top+l.y)/o.y,h=a.width/o.x,p=a.height/o.y;if(i){const g=Zu(i),v=n&&wh(n)?Zu(n):n;let b=g,y=B5(b);for(;y&&n&&v!==b;){const w=iy(y),j=y.getBoundingClientRect(),x=jh(y),C=j.left+(y.clientLeft+parseFloat(x.paddingLeft))*w.x,k=j.top+(y.clientTop+parseFloat(x.paddingTop))*w.y;c*=w.x,d*=w.y,h*=w.x,p*=w.y,c+=C,d+=k,b=Zu(y),y=B5(b)}}return MS({width:h,height:p,x:c,y:d})}function yO(e,s){const r=$k(e).scrollLeft;return s?s.left+r:Kx(fp(e)).left+r}function fG(e,s,r){r===void 0&&(r=!1);const n=e.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:yO(e,n)),i=n.top+s.scrollTop;return{x:a,y:i}}function Vue(e){let{elements:s,rect:r,offsetParent:n,strategy:a}=e;const i=a==="fixed",o=fp(n),l=s?Lk(s.floating):!1;if(n===o||l&&i)return r;let c={scrollLeft:0,scrollTop:0},d=tp(1);const h=tp(0),p=lp(n);if((p||!p&&!i)&&((kb(n)!=="body"||Wj(o))&&(c=$k(n)),lp(n))){const v=Kx(n);d=iy(n),h.x=v.x+n.clientLeft,h.y=v.y+n.clientTop}const g=o&&!p&&!i?fG(o,c,!0):tp(0);return{width:r.width*d.x,height:r.height*d.y,x:r.x*d.x-c.scrollLeft*d.x+h.x+g.x,y:r.y*d.y-c.scrollTop*d.y+h.y+g.y}}function Wue(e){return Array.from(e.getClientRects())}function Kue(e){const s=fp(e),r=$k(e),n=e.ownerDocument.body,a=Gu(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),i=Gu(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let o=-r.scrollLeft+yO(e);const l=-r.scrollTop;return jh(n).direction==="rtl"&&(o+=Gu(s.clientWidth,n.clientWidth)-a),{width:a,height:i,x:o,y:l}}function Gue(e,s){const r=Zu(e),n=fp(e),a=r.visualViewport;let i=n.clientWidth,o=n.clientHeight,l=0,c=0;if(a){i=a.width,o=a.height;const d=xO();(!d||d&&s==="fixed")&&(l=a.offsetLeft,c=a.offsetTop)}return{width:i,height:o,x:l,y:c}}function Yue(e,s){const r=Kx(e,!0,s==="fixed"),n=r.top+e.clientTop,a=r.left+e.clientLeft,i=lp(e)?iy(e):tp(1),o=e.clientWidth*i.x,l=e.clientHeight*i.y,c=a*i.x,d=n*i.y;return{width:o,height:l,x:c,y:d}}function F$(e,s,r){let n;if(s==="viewport")n=Gue(e,r);else if(s==="document")n=Kue(fp(e));else if(wh(s))n=Yue(s,r);else{const a=pG(e);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return MS(n)}function gG(e,s){const r=Eg(e);return r===s||!wh(r)||Ey(r)?!1:jh(r).position==="fixed"||gG(r,s)}function Que(e,s){const r=s.get(e);if(r)return r;let n=P0(e,[],!1).filter(l=>wh(l)&&kb(l)!=="body"),a=null;const i=jh(e).position==="fixed";let o=i?Eg(e):e;for(;wh(o)&&!Ey(o);){const l=jh(o),c=gO(o);!c&&l.position==="fixed"&&(a=null),(i?!c&&!a:!c&&l.position==="static"&&!!a&&["absolute","fixed"].includes(a.position)||Wj(o)&&!c&&gG(e,o))?n=n.filter(h=>h!==o):a=l,o=Eg(o)}return s.set(e,n),n}function Xue(e){let{element:s,boundary:r,rootBoundary:n,strategy:a}=e;const o=[...r==="clippingAncestors"?Lk(s)?[]:Que(s,this._c):[].concat(r),n],l=o[0],c=o.reduce((d,h)=>{const p=F$(s,h,a);return d.top=Gu(p.top,d.top),d.right=_g(p.right,d.right),d.bottom=_g(p.bottom,d.bottom),d.left=Gu(p.left,d.left),d},F$(s,l,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Zue(e){const{width:s,height:r}=hG(e);return{width:s,height:r}}function Jue(e,s,r){const n=lp(s),a=fp(s),i=r==="fixed",o=Kx(e,!0,i,s);let l={scrollLeft:0,scrollTop:0};const c=tp(0);if(n||!n&&!i)if((kb(s)!=="body"||Wj(a))&&(l=$k(s)),n){const g=Kx(s,
vendor: 4,350 bytes, line 8
8!0,i,s);c.x=g.x+s.clientLeft,c.y=g.y+s.clientTop}else a&&(c.x=yO(a));const d=a&&!n&&!i?fG(a,l):tp(0),h=o.left+l.scrollLeft-c.x-d.x,p=o.top+l.scrollTop-c.y-d.y;return{x:h,y:p,width:o.width,height:o.height}}function sP(e){return jh(e).position==="static"}function B$(e,s){if(!lp(e)||jh(e).position==="fixed")return null;if(s)return s(e);let r=e.offsetParent;return fp(e)===r&&(r=r.ownerDocument.body),r}function xG(e,s){const r=Zu(e);if(Lk(e))return r;if(!lp(e)){let a=Eg(e);for(;a&&!Ey(a);){if(wh(a)&&!sP(a))return a;a=Eg(a)}return r}let n=B$(e,s);for(;n&&Uue(n)&&sP(n);)n=B$(n,s);return n&&Ey(n)&&sP(n)&&!gO(n)?r:n||zue(e)||r}const eme=async function(e){const s=this.getOffsetParent||xG,r=this.getDimensions,n=await r(e.floating);return{reference:Jue(e.reference,await s(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function tme(e){return jh(e).direction==="rtl"}const sme={convertOffsetParentRelativeRectToViewportRelativeRect:Vue,getDocumentElement:fp,getClippingRect:Xue,getOffsetParent:xG,getElementRects:eme,getClientRects:Wue,getDimensions:Zue,getScale:iy,isElement:wh,isRTL:tme};function vG(e,s){return e.x===s.x&&e.y===s.y&&e.width===s.width&&e.height===s.height}function rme(e,s){let r=null,n;const a=fp(e);function i(){var l;clearTimeout(n),(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:h,top:p,width:g,height:v}=d;if(l||s(),!g||!v)return;const b=r1(p),y=r1(a.clientWidth-(h+g)),w=r1(a.clientHeight-(p+v)),j=r1(h),C={rootMargin:-b+"px "+-y+"px "+-w+"px "+-j+"px",threshold:Gu(0,_g(1,c))||1};let k=!0;function S(_){const A=_[0].intersectionRatio;if(A!==c){if(!k)return o();A?o(!1,A):n=setTimeout(()=>{o(!1,1e-7)},1e3)}A===1&&!vG(d,e.getBoundingClientRect())&&o(),k=!1}try{r=new IntersectionObserver(S,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(S,C)}r.observe(e)}return o(!0),i}function yG(e,s,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,d=vO(e),h=a||i?[...d?P0(d):[],...P0(s)]:[];h.forEach(j=>{a&&j.addEventListener("scroll",r,{passive:!0}),i&&j.addEventListener("resize",r)});const p=d&&l?rme(d,r):null;let g=-1,v=null;o&&(v=new ResizeObserver(j=>{let[x]=j;x&&x.target===d&&v&&(v.unobserve(s),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var C;(C=v)==null||C.observe(s)})),r()}),d&&!c&&v.observe(d),v.observe(s));let b,y=c?Kx(e):null;c&&w();function w(){const j=Kx(e);y&&!vG(y,j)&&r(),y=j,b=requestAnimationFrame(w)}return r(),()=>{var j;h.forEach(x=>{a&&x.removeEventListener("scroll",r),i&&x.removeEventListener("resize",r)}),p?.(),(j=v)==null||j.disconnect(),v=null,c&&cancelAnimationFrame(b)}}const nme=Lue,ame=$ue,ime=Iue,ome=Bue,lme=Oue,U$=Rue,cme=Fue,dme=(e,s,r)=>{const n=new Map,a={platform:sme,...r},i={...a.platform,_c:n};return Mue(e,s,{...a,platform:i})};var aS=typeof document<"u"?u.useLayoutEffect:u.useEffect;function RS(e,s){if(e===s)return!0;if(typeof e!=typeof s)return!1;if(typeof e=="function"&&e.toString()===s.toString())return!0;let r,n,a;if(e&&s&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==s.length)return!1;for(n=r;n--!==0;)if(!RS(e[n],s[n]))return!1;return!0}if(a=Object.keys(e),r=a.length,r!==Object.keys(s).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(s,a[n]))return!1;for(n=r;n--!==0;){const i=a[n];if(!(i==="_owner"&&e.$$typeof)&&!RS(e[i],s[i]))return!1}return!0}return e!==e&&s!==s}function bG(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function z$(e,s){const r=bG(e);return Math.round(s*r)/r}function rP(e){const s=u.useRef(e);return aS(()=>{s.current=e}),s}function wG(e){e===void 0&&(e={});const{placement:s="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[h,p]=u.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[g,v]=u.useState(n);RS(g,n)||v(n);const[b,y]=u.useState(null),[w,j]=u.useState(null),x=u.useCallback(z=>{z!==_.current&&(_.current=z,y(z))},[]),C=u.useCallback(z=>{z!==A.current&&(A.current=z,j(z))},[]),k=i||b,S=o||w,_=u.useRef(null),A=u.useRef(null),T=u.useRef(h),M=c!=null,R=rP(c),D=rP(a),$=rP(d
vendor: 5,061 bytes, line 8
8),O=u.useCallback(()=>{if(!_.current||!A.current)return;const z={placement:s,strategy:r,middleware:g};D.current&&(z.platform=D.current),dme(_.current,A.current,z).then(Z=>{const ee={...Z,isPositioned:$.current!==!1};q.current&&!RS(T.current,ee)&&(T.current=ee,Em.flushSync(()=>{p(ee)}))})},[g,s,r,D,$]);aS(()=>{d===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,p(z=>({...z,isPositioned:!1})))},[d]);const q=u.useRef(!1);aS(()=>(q.current=!0,()=>{q.current=!1}),[]),aS(()=>{if(k&&(_.current=k),S&&(A.current=S),k&&S){if(R.current)return R.current(k,S,O);O()}},[k,S,O,R,M]);const V=u.useMemo(()=>({reference:_,floating:A,setReference:x,setFloating:C}),[x,C]),K=u.useMemo(()=>({reference:k,floating:S}),[k,S]),G=u.useMemo(()=>{const z={position:r,left:0,top:0};if(!K.floating)return z;const Z=z$(K.floating,h.x),ee=z$(K.floating,h.y);return l?{...z,transform:"translate("+Z+"px, "+ee+"px)",...bG(K.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:Z,top:ee}},[r,l,K.floating,h.x,h.y]);return u.useMemo(()=>({...h,update:O,refs:V,elements:K,floatingStyles:G}),[h,O,V,K,G])}const ume=e=>{function s(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:a}=typeof e=="function"?e(r):e;return n&&s(n)?n.current!=null?U$({element:n.current,padding:a}).fn(r):{}:n?U$({element:n,padding:a}).fn(r):{}}}},jG=(e,s)=>({...nme(e),options:[e,s]}),NG=(e,s)=>({...ame(e),options:[e,s]}),SG=(e,s)=>({...cme(e),options:[e,s]}),CG=(e,s)=>({...ime(e),options:[e,s]}),kG=(e,s)=>({...ome(e),options:[e,s]}),_G=(e,s)=>({...lme(e),options:[e,s]}),PG=(e,s)=>({...ume(e),options:[e,s]});var mme="Arrow",EG=u.forwardRef((e,s)=>{const{children:r,width:n=10,height:a=5,...i}=e;return t.jsx(Cr.svg,{...i,ref:s,width:n,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});EG.displayName=mme;var hme=EG;function _b(e){const[s,r]=u.useState(void 0);return da(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=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 n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),s}var bO="Popper",[TG,Pb]=oo(bO),[pme,AG]=TG(bO),MG=e=>{const{__scopePopper:s,children:r}=e,[n,a]=u.useState(null);return t.jsx(pme,{scope:s,anchor:n,onAnchorChange:a,children:r})};MG.displayName=bO;var RG="PopperAnchor",IG=u.forwardRef((e,s)=>{const{__scopePopper:r,virtualRef:n,...a}=e,i=AG(RG,r),o=u.useRef(null),l=mr(s,o);return u.useEffect(()=>{i.onAnchorChange(n?.current||o.current)}),n?null:t.jsx(Cr.div,{...a,ref:l})});IG.displayName=RG;var wO="PopperContent",[fme,gme]=TG(wO),OG=u.forwardRef((e,s)=>{const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:h=0,sticky:p="partial",hideWhenDetached:g=!1,updatePositionStrategy:v="optimized",onPlaced:b,...y}=e,w=AG(wO,r),[j,x]=u.useState(null),C=mr(s,le=>x(le)),[k,S]=u.useState(null),_=_b(k),A=_?.width??0,T=_?.height??0,M=n+(i!=="center"?"-"+i:""),R=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},D=Array.isArray(d)?d:[d],$=D.length>0,O={padding:R,boundary:D.filter(vme),altBoundary:$},{refs:q,floatingStyles:V,placement:K,isPositioned:G,middlewareData:z}=wG({strategy:"fixed",placement:M,whileElementsMounted:(...le)=>yG(...le,{animationFrame:v==="always"}),elements:{reference:w.anchor},middleware:[jG({mainAxis:a+T,alignmentAxis:o}),c&&NG({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?SG():void 0,...O}),c&&CG({...O}),kG({...O,apply:({elements:le,rects:ue,availableWidth:fe,availableHeight:H})=>{const{width:se,height:me}=ue.reference,ge=le.floating.style;ge.setProperty("--radix-popper-available-width",`${fe}px`),ge.setProperty("--radix-popper-available-height",`${H}px`),ge.setProperty("--radix-popper-anchor-width",`${se}px`),ge.setProperty("--radix-popper-anchor-height",`${me}px`)}}),k&&PG({element:k,padding:l}),yme({arrowWidth:A,arrowHeight:T}),g&&_G({strategy:"referenceHidden",...O})]}),[Z,ee]=$G(K),Q=Za(b);da(()=>{G&&Q?.()},[G,Q]);const Y=z.arrow?.x,oe=z.arrow?.y,he=z.arrow?.centerOffset!==0,[je,pe]=u.useState();return da(()=>{j&&pe(window.getComputedStyle(j).zIndex)},[j]),t.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:G?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:je,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(" "),...z.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(fme,{scope:r,placedSide:Z,onArrowChange:S,arrowX:Y,arrowY:oe,shouldHideArrow:he,children:t.jsx(Cr.div,{"data-side":Z,"data-align":ee,...y,ref:C,style:{...y.style,animation:G?void 0:"none"}})})})});OG.displayName=wO;var DG="PopperArrow",xme={top:"bottom",right:"left",bottom:"top",left:"r
8ight"},LG=u.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,i=gme(DG,n),o=xme[i.placedSide];return t.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:t.jsx(hme,{...a,ref:r,style:{...a.style,display:"block"}})})});LG.displayName=DG;function vme(e){return e!==null}var yme=e=>({name:"transformOrigin",options:e,fn(s){const{placement:r,rects:n,middlewareData:a}=s,o=a.arrow?.centerOffset!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[d,h]=$G(r),p={start:"0%",center:"50%",end:"100%"}[h],g=(a.arrow?.x??0)+l/2,v=(a.arrow?.y??0)+c/2;let b="",y="";return d==="bottom"?(b=o?p:`${g}px`,y=`${-c}px`):d==="top"?(b=o?p:`${g}px`,y=`${n.floating.height+c}px`):d==="right"?(b=`${-c}px`,y=o?p:`${v}px`):d==="left"&&(b=`${n.floating.width+c}px`,y=o?p:`${v}px`),{data:{x:b,y}}}});function $G(e){const[s,r="center"]=e.split("-");return[s,r]}var jO=MG,NO=IG,SO=OG,CO=LG,[Fk]=oo("Tooltip",[Pb]),Bk=Pb(),FG="TooltipProvider",bme=700,U5="tooltip.open",[wme,kO]=Fk(FG),BG=e=>{const{__scopeTooltip:s,delayDuration:r=bme,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:i}=e,o=u.useRef(!0),l=u.useRef(!1),c=u.useRef(0);return u.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),t.jsx(wme,{scope:s,isOpenDelayedRef:o,delayDuration:r,onOpen:u.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:u.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,n)},[n]),isPointerInTransitRef:l,onPointerInTransitChange:u.useCallback(d=>{l.current=d},[]),disableHoverableContent:a,children:i})};BG.displayName=FG;var Uk="Tooltip",[jme,zk]=Fk(Uk),UG=e=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a=!1,onOpenChange:i,disableHoverableContent:o,delayDuration:l}=e,c=kO(Uk,e.__scopeTooltip),d=Bk(s),[h,p]=u.useState(null),g=wu(),v=u.useRef(0),b=o??c.disableHoverableContent,y=l??c.delayDuration,w=u.useRef(!1),[j=!1,x]=ip({prop:n,defaultProp:a,onChange:A=>{A?(c.onOpen(),document.dispatchEvent(new CustomEvent(U5))):c.onClose(),i?.(A)}}),C=u.useMemo(()=>j?w.current?"delayed-open":"instant-open":"closed",[j]),k=u.useCallback(()=>{window.clearTimeout(v.current),v.current=0,w.current=!1,x(!0)},[x]),S=u.useCallback(()=>{window.clearTimeout(v.current),v.current=0,x(!1)},[x]),_=u.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{w.current=!0,x(!0),v.current=0},y)},[y,x]);return u.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),t.jsx(jO,{...d,children:t.jsx(jme,{scope:s,contentId:g,open:j,stateAttribute:C,trigger:h,onTriggerChange:p,onTriggerEnter:u.useCallback(()=>{c.isOpenDelayedRef.current?_():k()},[c.isOpenDelayedRef,_,k]),onTriggerLeave:u.useCallback(()=>{b?S():(window.clearTimeout(v.current),v.current=0)},[S,b]),onOpen:k,onClose:S,disableHoverableContent:b,children:r})})};UG.displayName=Uk;var z5="TooltipTrigger",zG=u.forwardRef((e,s)=>{const{__scopeTooltip:r,...n}=e,a=zk(z5,r),i=kO(z5,r),o=Bk(r),l=u.useRef(null),c=mr(s,l,a.onTriggerChange),d=u.useRef(!1),h=u.useRef(!1),p=u.useCallback(()=>d.current=!1,[]);return u.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),t.jsx(NO,{asChild:!0,...o,children:t.jsx(Cr.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:c,onPointerMove:Ms(e.onPointerMove,g=>{g.pointerType!=="touch"&&!h.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),h.current=!0)}),onPointerLeave:Ms(e.onPointerLeave,()=>{a.onTriggerLeave(),h.current=!1}),onPointerDown:Ms(e.onPointerDown,()=>{a.open&&a.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:Ms(e.onFocus,()=>{d.current||a.onOpen()}),onBlur:Ms(e.onBlur,a.onClose),onClick:Ms(e.onClick,a.onClose)})})});zG.displayName=z5;var Nme="TooltipPortal",[fWe,Sme]=Fk(Nme,{forceMount:void 0}),Ty="TooltipContent",HG=u.forwardRef((e,s)=>{const r=Sme(Ty,e.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...i}=e,o=zk(Ty,e.__scopeTooltip);return t.jsx($m,{present:n||o.open,children:o.disableHoverableContent?t.jsx(qG,{side:a,...i,ref:s}):t.jsx(Cme,{side:a,...i,ref:s})})}),Cme=u.forwardRef((e,s)=>{const r=zk(Ty,e.__scopeTooltip),n=kO(Ty,e.__scopeTooltip),a=u.useRef(null),i=mr(s,a),[o,l]=u.useState(null),{trigger:c,onClose:d}=r,h=a.current,{onPointerInTransitChange:p}=n,g=u.useCallback(()=>
vendor: 4,171 bytes, line 8
8{l(null),p(!1)},[p]),v=u.useCallback((b,y)=>{const w=b.currentTarget,j={x:b.clientX,y:b.clientY},x=Tme(j,w.getBoundingClientRect()),C=Ame(j,x),k=Mme(y.getBoundingClientRect()),S=Ime([...C,...k]);l(S),p(!0)},[p]);return u.useEffect(()=>()=>g(),[g]),u.useEffect(()=>{if(c&&h){const b=w=>v(w,h),y=w=>v(w,c);return c.addEventListener("pointerleave",b),h.addEventListener("pointerleave",y),()=>{c.removeEventListener("pointerleave",b),h.removeEventListener("pointerleave",y)}}},[c,h,v,g]),u.useEffect(()=>{if(o){const b=y=>{const w=y.target,j={x:y.clientX,y:y.clientY},x=c?.contains(w)||h?.contains(w),C=!Rme(j,o);x?g():C&&(g(),d())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[c,h,o,d,g]),t.jsx(qG,{...e,ref:i})}),[kme,_me]=Fk(Uk,{isInside:!1}),Pme=GW("TooltipContent"),qG=u.forwardRef((e,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...l}=e,c=zk(Ty,r),d=Bk(r),{onClose:h}=c;return u.useEffect(()=>(document.addEventListener(U5,h),()=>document.removeEventListener(U5,h)),[h]),u.useEffect(()=>{if(c.trigger){const p=g=>{g.target?.contains(c.trigger)&&h()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[c.trigger,h]),t.jsx(wb,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:p=>p.preventDefault(),onDismiss:h,children:t.jsxs(SO,{"data-state":c.stateAttribute,...d,...l,ref:s,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:[t.jsx(Pme,{children:n}),t.jsx(kme,{scope:r,isInside:!0,children:t.jsx(mce,{id:c.contentId,role:"tooltip",children:a||n})})]})})});HG.displayName=Ty;var VG="TooltipArrow",Eme=u.forwardRef((e,s)=>{const{__scopeTooltip:r,...n}=e,a=Bk(r);return _me(VG,r).isInside?null:t.jsx(CO,{...a,...n,ref:s})});Eme.displayName=VG;function Tme(e,s){const r=Math.abs(s.top-e.y),n=Math.abs(s.bottom-e.y),a=Math.abs(s.right-e.x),i=Math.abs(s.left-e.x);switch(Math.min(r,n,a,i)){case i:return"left";case a:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function Ame(e,s,r=5){const n=[];switch(s){case"top":n.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":n.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":n.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":n.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return n}function Mme(e){const{top:s,right:r,bottom:n,left:a}=e;return[{x:a,y:s},{x:r,y:s},{x:r,y:n},{x:a,y:n}]}function Rme(e,s){const{x:r,y:n}=e;let a=!1;for(let i=0,o=s.length-1;i<s.length;o=i++){const l=s[i].x,c=s[i].y,d=s[o].x,h=s[o].y;c>n!=h>n&&r<(d-l)*(n-c)/(h-c)+l&&(a=!a)}return a}function Ime(e){const s=e.slice();return s.sort((r,n)=>r.x<n.x?-1:r.x>n.x?1:r.y<n.y?-1:r.y>n.y?1:0),Ome(s)}function Ome(e){if(e.length<=1)return e.slice();const s=[];for(let n=0;n<e.length;n++){const a=e[n];for(;s.length>=2;){const i=s[s.length-1],o=s[s.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))s.pop();else break}s.push(a)}s.pop();const r=[];for(let n=e.length-1;n>=0;n--){const a=e[n];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(),s.length===1&&r.length===1&&s[0].x===r[0].x&&s[0].y===r[0].y?s:s.concat(r)}var Dme=BG,Lme=UG,$me=zG,WG=HG;const KG=Dme,Wt=Lme,Kt=$me,Yt=u.forwardRef(({className:e,sideOffset:s=4,...r},n)=>t.jsx(WG,{ref:n,sideOffset:s,className:Cs("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]:sli
8de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin] tooltip-content",e),...r}));Yt.displayName=WG.displayName;const Fme={theme:"dark",setTheme:()=>null},GG=u.createContext(Fme);function Bme({children:e,defaultTheme:s="dark",storageKey:r="nvr-portal-theme",...n}){const[a,i]=u.useState(()=>{const l=localStorage.getItem(r);return l==="light"||l==="dark"||l==="darker"?l:l==="system"?"dark":s});u.useEffect(()=>{const l=window.document.documentElement;l.classList.remove("light","dark","darker"),a==="darker"?l.classList.add("dark","darker"):l.classList.add(a)},[a]);const o={theme:a,setTheme:l=>{localStorage.setItem(r,l),i(l)}};return t.jsx(GG.Provider,{...n,value:o,children:e})}const YG=()=>{const e=u.useContext(GG);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};async function Ume(){const e=await fetch("/api/auth/user",{credentials:"include"});if(e.status===401)return null;if(!e.ok)throw new Error(`${e.status}: ${e.statusText}`);return e.json()}async function zme(){await fetch("/api/logout",{method:"POST",credentials:"include"})}function Gi(){const e=Su(),{data:s,isLoading:r}=ze({queryKey:["/api/auth/user"],queryFn:Ume,retry:!1,staleTime:1e3*60*5}),n=Et({mutationFn:zme,onSuccess:()=>{e.removeQueries({predicate:a=>a.queryKey[0]!=="/api/auth/user"}),e.setQueryData(["/api/auth/user"],null),window.scrollTo(0,0)}});return{user:s,isLoading:r,isAuthenticated:!!s,logout:n.mutate,isLoggingOut:n.isPending}}var ba;(function(e){e.assertEqual=a=>{};function s(a){}e.assertIs=s;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 n(a,i=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(ba||(ba={}));var H5;(function(e){e.mergeShapes=(s,r)=>({...s,...r})})(H5||(H5={}));const rr=ba.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Kp=e=>{switch(typeof e){case"undefined":return rr.undefined;case"string":return rr.string;case"number":return Number.isNaN(e)?rr.nan:rr.number;case"boolean":return rr.boolean;case"function":return rr.function;case"bigint":return rr.bigint;case"symbol":return rr.symbol;case"object":return Array.isArray(e)?rr.array:e===null?rr.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?rr.promise:typeof Map<"u"&&e instanceof Map?rr.map:typeof Set<"u"&&e instanceof Set?rr.set:typeof Date<"u"&&e instanceof Date?rr.date:rr.object;default:return rr.unknown}}
vendor: 40,282 bytes, line 8
8,rs=ba.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"]),Hme=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class Ju extends Error{get errors(){return this.issues}constructor(s){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=s}format(s){const r=s||function(i){return i.message},n={_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)n._errors.push(r(o));else{let l=n,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),n}static assert(s){if(!(s instanceof Ju))throw new Error(`Not a ZodError: ${s}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ba.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(s=r=>r.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];r[i]=r[i]||[],r[i].push(s(a))}else n.push(s(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Ju.create=e=>new Ju(e);const Ay=(e,s)=>{let r;switch(e.code){case rs.invalid_type:e.received===rr.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case rs.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,ba.jsonStringifyReplacer)}`;break;case rs.unrecognized_keys:r=`Unrecognized key(s) in object: ${ba.joinValues(e.keys,", ")}`;break;case rs.invalid_union:r="Invalid input";break;case rs.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ba.joinValues(e.options)}`;break;case rs.invalid_enum_value:r=`Invalid enum value. Expected ${ba.joinValues(e.options)}, received '${e.received}'`;break;case rs.invalid_arguments:r="Invalid function arguments";break;case rs.invalid_return_type:r="Invalid function return type";break;case rs.invalid_date:r="Invalid date";break;case rs.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}"`:ba.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case rs.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 rs.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 rs.custom:r="Invalid input";break;case rs.invalid_intersection_types:r="Intersection results could not be merged";break;case rs.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case rs.not_finite:r="Number must be finite";break;default:r=s.defaultError,ba.assertNever(e)}return{message:r}};let QG=Ay;function qme(e){QG=e}function IS(){return QG}const OS=e=>{const{data:s,path:r,errorMaps:n,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=n.filter(d=>!!d).slice().reverse();for(const d of c)l=d(o,{data:s,defaultError:l}).message;return{...a,path:i,message:l}},Vme=[];function Gs(e,s){const r=IS(),n=OS({issueData:s,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Ay?void 0:Ay].filter(a=>!!a)});e.common.issues.push(n)}class _d{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(s,r){const n=[];for(const a of r){if(a.status==="aborted")return Yr;a.status==="dirty"&&s.dirty(),n.push(a.value)}return{status:s.value,value:n}}static async mergeObjectAsync(s,r){const n=[];for(const a of r){const i=await a.key,o=await a.value;n.push({key:i,value:o})}return _d.mergeObjectSync(s,n)}static mergeObjectSync(s,r){const n={};for(const a of r){const{key:i,value:o}=a;if(i.status==="aborted"||o.status==="aborted")return Yr;i.status==="dirty"&&s.dirty(),o.status==="dirty"&&s.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(n[i.value]=o.value)}return{status:s.value,value:n}}}const Yr=Object.freeze({status:"aborted"}),Yv=e=>({status:"dirty",value:e}),Yd=e=>({status:"valid",value:e}),q5=e=>e.status==="aborted",V5=e=>e.status==="dirty",Gx=e=>e.status==="valid",E0=e=>typeof Promise<"u"&&e instanceof Promise;var Nr;(function(e){e.errToObj=s=>typeof s=="string"?{message:s}:s||{},e.toString=s=>typeof s=="string"?s:s?.message})(Nr||(Nr={}));class cp{constructor(s,r,n,a){this._cachedPath=[],this.parent=s,this.data=r,this._path=n,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 H$=(e,s)=>{if(Gx(s))return{success:!0,data:s.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 Ju(e.common.issues);return this._error=r,this._error}}};function En(e){if(!e)return{};const{errorMap:s,invalid_type_error:r,required_error:n,description:a}=e;if(s&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return s?{errorMap:s,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??n??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??r??l.defaultError}},description:a}}class Un{get description(){return this._def.description}_getType(s){return Kp(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:Kp(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new _d,ctx:{common:s.parent.common,data:s.data,parsedType:Kp(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(E0(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(s){const r=this._parse(s);return Promise.resolve(r)}parse(s,r){const n=this.safeParse(s,r);if(n.success)return n.data;throw n.error}safeParse(s,r){const n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Kp(s)},a=this._parseSync({data:s,path:n.path,parent:n});return H$(n,a)}"~validate"(s){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Kp(s)};if(!this["~standard"].async)try{const n=this._parseSync({data:s,path:[],parent:r});return Gx(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:s,path:[],parent:r}).then(n=>Gx(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(s,r){const n=await this.safeParseAsync(s,r);if(n.success)return n.data;throw n.error}async safeParseAsync(s,r){const n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:s,parsedType:Kp(s)},a=this._parse({data:s,path:n.path,parent:n}),i=await(E0(a)?a:Promise.resolve(a));return H$(n,i)}refine(s,r){const n=a=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(a):r;return this._refinement((a,i)=>{const o=s(a),l=()=>i.addIssue({code:rs.custom,...n(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(s,r){return this._refinement((n,a)=>s(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(s){return new Nh({schema:this,typeName:Zr.ZodEffects,effect:{type:"refinement",refinement:s}})}superRefine(s){return this._refinement(s)}constructor(s){this.spa=this.safeParseAsync,this._def=s,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 sp.create(this,this._def)}nullable(){return Rg.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return vh.create(this)}promise(){return Ry.create(this,this._def)}or(s){return R0.create([this,s],this._def)}and(s){return I0.create(this,s,this._def)}transform(s){return new Nh({...En(this._def),schema:this,typeName:Zr.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new F0({...En(this._def),innerType:this,defaultValue:r,typeName:Zr.ZodDefault})}brand(){return new _O({typeName:Zr.ZodBranded,type:this,...En(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new B0({...En(this._def),innerType:this,catchValue:r,typeName:Zr.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return Kj.create(this,s)}readonly(){return U0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Wme=/^c[^\s-]{8,}$/i,Kme=/^[0-9a-z]+$/,Gme=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Yme=/^[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,Qme=/^[a-z0-9_-]{21}$/i,Xme=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Zme=/^[-+]?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)?)??$/,Jme=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ehe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let nP;const the=/^(?:(?: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])$/,she=/^(?:(?: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])$/,rhe=/^(([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]))$/,nhe=/^(([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])$/,ahe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ihe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,XG="((\\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])))",ohe=new RegExp(`^${XG}$`);function ZG(e){let s="[0-5]\\d";e.precision?s=`${s}\\.\\d{${e.precision}}`:e.precision==null&&(s=`${s}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${s})${r}`}function lhe(e){return new RegExp(`^${ZG(e)}$`)}function JG(e){let s=`${XG}T${ZG(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),s=`${s}(${r.join("|")})`,new RegExp(`^${s}$`)}function che(e,s){return!!((s==="v4"||!s)&&the.test(e)||(s==="v6"||!s)&&rhe.test(e))}function dhe(e,s){if(!Xme.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||s&&a.alg!==s)}catch{return!1}}function uhe(e,s){return!!((s==="v4"||!s)&&she.test(e)||(s==="v6"||!s)&&nhe.test(e))}class xh extends Un{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==rr.string){const i=this._getOrReturnCtx(s);return Gs(i,{code:rs.invalid_type,expected:rr.string,received:i.parsedType}),Yr}const n=new _d;let a;for(const i of this._def.checks)if(i.kind==="min")s.data.length<i.value&&(a=this._getOrReturnCtx(s,a),Gs(a,{code:rs.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")s.data.length>i.value&&(a=this._getOrReturnCtx(s,a),Gs(a,{code:rs.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const o=s.data.length>i.value,l=s.data.length<i.value;(o||l)&&(a=this._getOrReturnCtx(s,a),o?Gs(a,{code:rs.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&Gs(a,{code:rs.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Jme.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"email",code:rs.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")nP||(nP=new RegExp(ehe,"u")),nP.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"emoji",code:rs.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Yme.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"uuid",code:rs.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Qme.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"nanoid",code:rs.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Wme.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"cuid",code:rs.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Kme.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"cuid2",code:rs.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Gme.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"ulid",code:rs.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(s.data)}catch{a=this._getOrReturnCtx(s,a),Gs(a,{validation:"url",code:rs.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"regex",code:rs.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?s.data=s.data.trim():i.kind==="includes"?s.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(s,a),Gs(a,{code:rs.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?s.data=s.data.toLowerCase():i.kind==="toUpperCase"?s.data=s.data.toUpperCase():i.kind==="startsWith"?s.data.startsWith(i.value)||(a=this._getOrReturnCtx(s,a),Gs(a,{code:rs.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?s.data.endsWith(i.value)||(a=this._getOrReturnCtx(s,a),Gs(a,{code:rs.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?JG(i).test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{code:rs.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?ohe.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{code:rs.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?lhe(i).test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{code:rs.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Zme.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"duration",code:rs.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?che(s.data,i.version)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"ip",code:rs.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?dhe(s.data,i.alg)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"jwt",code:rs.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?uhe(s.data,i.version)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"cidr",code:rs.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?ahe.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"base64",code:rs.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?ihe.test(s.data)||(a=this._getOrReturnCtx(s,a),Gs(a,{validation:"base64url",code:rs.invalid_string,message:i.message}),n.dirty()):ba.assertNever(i);return{status:n.value,value:s.data}}_regex(s,r,n){return this.refinement(a=>s.test(a),{validation:r,code:rs.invalid_string,...Nr.errToObj(n)})}_addCheck(s){return new xh({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...Nr.errToObj(s)})}url(s){return this._addCheck({kind:"url",...Nr.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...Nr.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...Nr.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...Nr.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...Nr.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...Nr.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...Nr.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...Nr.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...Nr.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...Nr.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...Nr.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...Nr.errToObj(s)})}datetime(s){return typeof s=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:s}):this._addCheck({kind:"datetime",precision:typeof s?.precision>"u"?null:s?.precision,offset:s?.offset??!1,local:s?.local??!1,...Nr.errToObj(s?.message)})}date(s){return this._addCheck({kind:"date",message:s})}time(s){return typeof s=="string"?this._addCheck({kind:"time",precision:null,message:s}):this._addCheck({kind:"time",precision:typeof s?.precision>"u"?null:s?.precision,...Nr.errToObj(s?.message)})}duration(s){return this._addCheck({kind:"duration",...Nr.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...Nr.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r?.position,...Nr.errToObj(r?.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...Nr.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...Nr.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...Nr.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...Nr.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...Nr.errToObj(r)})}nonempty(s){return this.min(1,Nr.errToObj(s))}trim(){return new xh({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new xh({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new xh({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(s=>s.kind==="datetime")}get isDate(){return!!this._def.checks.find(s=>s.kind==="date")}get isTime(){return!!this._def.checks.find(s=>s.kind==="time")}get isDuration(){return!!this._def.checks.find(s=>s.kind==="duration")}get isEmail(){return!!this._def.checks.find(s=>s.kind==="email")}get isURL(){return!!this._def.checks.find(s=>s.kind==="url")}get isEmoji(){return!!this._def.checks.find(s=>s.kind==="emoji")}get isUUID(){return!!this._def.checks.find(s=>s.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(s=>s.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(s=>s.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(s=>s.kind==="cuid2")}get isULID(){return!!this._def.checks.find(s=>s.kind==="ulid")}get isIP(){return!!this._def.checks.find(s=>s.kind==="ip")}get isCIDR(){return!!this._def.checks.find(s=>s.kind==="cidr")}get isBase64(){return!!this._def.checks.find(s=>s.kind==="base64")}get isBase64url(){return!!this._def.checks.find(s=>s.kind==="base64url")}get minLength(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxLength(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.value<s)&&(s=r.value);return s}}xh.create=e=>new xh({checks:[],typeName:Zr.ZodString,coerce:e?.coerce??!1,...En(e)});function mhe(e,s){const r=(e.toString().split(".")[1]||"").length,n=(s.toString().split(".")[1]||"").length,a=r>n?r:n,i=Number.parseInt(e.toFixed(a).replace(".","")),o=Number.parseInt(s.toFixed(a).replace(".",""));return i%o/10**a}class Tg extends Un{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(s){if(this._def.coerce&&(s.data=Number(s.data)),this._getType(s)!==rr.number){const i=this._getOrReturnCtx(s);return Gs(i,{code:rs.invalid_type,expected:rr.number,received:i.parsedType}),Yr}let n;const a=new _d;for(const i of this._def.checks)i.kind==="int"?ba.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Gs(n,{code:rs.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?s.data<i.value:s.data<=i.value)&&(n=this._getOrReturnCtx(s,n),Gs(n,{code:rs.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?s.data>i.value:s.data>=i.value)&&(n=this._getOrReturnCtx(s,n),Gs(n,{code:rs.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?mhe(s.data,i.value)!==0&&(n=this._getOrReturnCtx(s,n),Gs(n,{code:rs.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Gs(n,{code:rs.not_finite,message:i.message}),a.dirty()):ba.assertNever(i);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,Nr.toString(r))}gt(s,r){return this.setLimit("min",s,!1,Nr.toString(r))}lte(s,r){return this.setLimit("max",s,!0,Nr.toString(r))}lt(s,r){return this.setLimit("max",s,!1,Nr.toString(r))}setLimit(s,r,n,a){return new Tg({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:Nr.toString(a)}]})}_addCheck(s){return new Tg({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:Nr.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Nr.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Nr.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Nr.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Nr.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:Nr.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:Nr.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Nr.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Nr.toString(s)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.value<s)&&(s=r.value);return s}get isInt(){return!!this._def.checks.find(s=>s.kind==="int"||s.kind==="multipleOf"&&ba.isInteger(s.value))}get isFinite(){let s=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(s===null||n.value<s)&&(s=n.value)}return Number.isFinite(r)&&Number.isFinite(s)}}Tg.create=e=>new Tg({checks:[],typeName:Zr.ZodNumber,coerce:e?.coerce||!1,...En(e)});class Ag extends Un{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(s){if(this._def.coerce)try{s.data=BigInt(s.data)}catch{return this._getInvalidInput(s)}if(this._getType(s)!==rr.bigint)return this._getInvalidInput(s);let n;const a=new _d;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?s.data<i.value:s.data<=i.value)&&(n=this._getOrReturnCtx(s,n),Gs(n,{code:rs.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?s.data>i.value:s.data>=i.value)&&(n=this._getOrReturnCtx(s,n),Gs(n,{code:rs.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?s.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(s,n),Gs(n,{code:rs.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):ba.assertNever(i);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return Gs(r,{code:rs.invalid_type,expected:rr.bigint,received:r.parsedType}),Yr}gte(s,r){return this.setLimit("min",s,!0,Nr.toString(r))}gt(s,r){return this.setLimit("min",s,!1,Nr.toString(r))}lte(s,r){return this.setLimit("max",s,!0,Nr.toString(r))}lt(s,r){return this.setLimit("max",s,!1,Nr.toString(r))}setLimit(s,r,n,a){return new Ag({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:Nr.toString(a)}]})}_addCheck(s){return new Ag({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Nr.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Nr.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Nr.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Nr.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:Nr.toString(r)})}get minValue(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s}get maxValue(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.value<s)&&(s=r.value);return s}}Ag.create=e=>new Ag({checks:[],typeName:Zr.ZodBigInt,coerce:e?.coerce??!1,...En(e)});class T0 extends Un{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==rr.boolean){const n=this._getOrReturnCtx(s);return Gs(n,{code:rs.invalid_type,expected:rr.boolean,received:n.parsedType}),Yr}return Yd(s.data)}}T0.create=e=>new T0({typeName:Zr.ZodBoolean,coerce:e?.coerce||!1,...En(e)});class Yx extends Un{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==rr.date){const i=this._getOrReturnCtx(s);return Gs(i,{code:rs.invalid_type,expected:rr.date,received:i.parsedType}),Yr}if(Number.isNaN(s.data.getTime())){const i=this._getOrReturnCtx(s);return Gs(i,{code:rs.invalid_date}),Yr}const n=new _d;let a;for(const i of this._def.checks)i.kind==="min"?s.data.getTime()<i.value&&(a=this._getOrReturnCtx(s,a),Gs(a,{code:rs.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?s.data.getTime()>i.value&&(a=this._getOrReturnCtx(s,a),Gs(a,{code:rs.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):ba.assertNever(i);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new Yx({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:Nr.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:Nr.toString(r)})}get minDate(){let s=null;for(const r of this._def.checks)r.kind==="min"&&(s===null||r.value>s)&&(s=r.value);return s!=null?new Date(s):null}get maxDate(){let s=null;for(const r of this._def.checks)r.kind==="max"&&(s===null||r.value<s)&&(s=r.value);return s!=null?new Date(s):null}}Yx.create=e=>new Yx({checks:[],coerce:e?.coerce||!1,typeName:Zr.ZodDate,...En(e)});class DS extends Un{_parse(s){if(this._getType(s)!==rr.symbol){const n=this._getOrReturnCtx(s);return Gs(n,{code:rs.invalid_type,expected:rr.symbol,received:n.parsedType}),Yr}return Yd(s.data)}}DS.create=e=>new DS({typeName:Zr.ZodSymbol,...En(e)});class A0 extends Un{_parse(s){if(this._getType(s)!==rr.undefined){const n=this._getOrReturnCtx(s);return Gs(n,{code:rs.invalid_type,expected:rr.undefined,received:n.parsedType}),Yr}return Yd(s.data)}}A0.create=e=>new A0({typeName:Zr.ZodUndefined,...En(e)});class M0 extends Un{_parse(s){if(this._getType(s)!==rr.null){const n=this._getOrReturnCtx(s);return Gs(n,{code:rs.invalid_type,expected:rr.null,received:n.parsedType}),Yr}return Yd(s.data)}}M0.create=e=>new M0({typeName:Zr.ZodNull,...En(e)});class My extends Un{constructor(){super(...arguments),this._any=!0}_parse(s){return Yd(s.data)}}My.create=e=>new My({typeName:Zr.ZodAny,...En(e)});class Ox extends Un{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Yd(s.data)}}Ox.create=e=>new Ox({typeName:Zr.ZodUnknown,...En(e)});class xf extends Un{_parse(s){const r=this._getOrReturnCtx(s);return Gs(r,{code:rs.invalid_type,expected:rr.never,received:r.parsedType}),Yr}}xf.create=e=>new xf({typeName:Zr.ZodNever,...En(e)});class LS extends Un{_parse(s){if(this._getType(s)!==rr.undefined){const n=this._getOrReturnCtx(s);return Gs(n,{code:rs.invalid_type,expected:rr.void,received:n.parsedType}),Yr}return Yd(s.data)}}LS.create=e=>new LS({typeName:Zr.ZodVoid,...En(e)});class vh extends Un{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==rr.array)return Gs(r,{code:rs.invalid_type,expected:rr.array,received:r.parsedType}),Yr;if(a.exactLength!==null){const o=r.data.length>a.exactLength.value,l=r.data.length<a.exactLength.value;(o||l)&&(Gs(r,{code:o?rs.too_big:rs.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}),n.dirty())}if(a.minLength!==null&&r.data.length<a.minLength.value&&(Gs(r,{code:rs.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&r.data.length>a.maxLength.value&&(Gs(r,{code:rs.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>a.type._parseAsync(new cp(r,o,r.path,l)))).then(o=>_d.mergeArray(n,o));const i=[...r.data].map((o,l)=>a.type._parseSync(new cp(r,o,r.path,l)));return _d.mergeArray(n,i)}get element(){return this._def.type}min(s,r){return new vh({...this._def,minLength:{value:s,message:Nr.toString(r)}})}max(s,r){return new vh({...this._def,maxLength:{value:s,message:Nr.toString(r)}})}length(s,r){return new vh({...this._def,exactLength:{value:s,message:Nr.toString(r)}})}nonempty(s){return this.min(1,s)}}vh.create=(e,s)=>new vh({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Zr.ZodArray,...En(s)});function Kv(e){if(e instanceof jo){const s={};for(const r in e.shape){const n=e.shape[r];s[r]=sp.create(Kv(n))}return new jo({...e._def,shape:()=>s})}else return e instanceof vh?new vh({...e._def,type:Kv(e.element)}):e instanceof sp?sp.create(Kv(e.unwrap())):e instanceof Rg?Rg.create(Kv(e.unwrap())):e instanceof dp?dp.create(e.items.map(s=>Kv(s))):e}class jo extends Un{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const s=this._def.shape(),r=ba.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==rr.object){const d=this._getOrReturnCtx(s);return Gs(d,{code:rs.invalid_type,expected:rr.object,received:d.parsedType}),Yr}const{status:n,ctx:a}=this._processInputParams(s),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof xf&&this._def.unknownKeys==="strip"))for(const d in a.data)o.includes(d)||l.push(d);const c=[];for(const d of o){const h=i[d],p=a.data[d];c.push({key:{status:"valid",value:d},value:h._parse(new cp(a,p,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof xf){const d=this._def.unknownKeys;if(d==="passthrough")for(const h of l)c.push({key:{status:"valid",value:h},value:{status:"valid",value:a.data[h]}});else if(d==="strict")l.length>0&&(Gs(a,{code:rs.unrecognized_keys,keys:l}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const h of l){const p=a.data[h];c.push({key:{status:"valid",value:h},value:d._parse(new cp(a,p,a.path,h)),alwaysSet:h in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const d=[];for(const h of c){const p=await h.key,g=await h.value;d.push({key:p,value:g,alwaysSet:h.alwaysSet})}return d}).then(d=>_d.mergeObjectSync(n,d)):_d.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(s){return Nr.errToObj,new jo({...this._def,unknownKeys:"strict",...s!==void 0?{errorMap:(r,n)=>{const a=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:Nr.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new jo({...this._def,unknownKeys:"strip"})}passthrough(){return new jo({...this._def,unknownKeys:"passthrough"})}extend(s){return new jo({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new jo({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:Zr.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new jo({...this._def,catchall:s})}pick(s){const r={};for(const n of ba.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new jo({...this._def,shape:()=>r})}omit(s){const r={};for(const n of ba.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new jo({...this._def,shape:()=>r})}deepPartial(){return Kv(this)}partial(s){const r={};for(const n of ba.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new jo({...this._def,shape:()=>r})}required(s){const r={};for(const n of ba.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof sp;)i=i._def.innerType;r[n]=i}return new jo({...this._def,shape:()=>r})}keyof(){return eY(ba.objectKeys(this.shape))}}jo.create=(e,s)=>new jo({shape:()=>e,unknownKeys:"strip",catchall:xf.create(),typeName:Zr.ZodObject,...En(s)});jo.strictCreate=(e,s)=>new jo({shape:()=>e,unknownKeys:"strict",catchall:xf.create(),typeName:Zr.ZodObject,...En(s)});jo.lazycreate=(e,s)=>new jo({shape:e,unknownKeys:"strip",catchall:xf.create(),typeName:Zr.ZodObject,...En(s)});class R0 extends Un{_parse(s){const{ctx:r}=this._processInputParams(s),n=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 Ju(l.ctx.common.issues));return Gs(r,{code:rs.invalid_union,unionErrors:o}),Yr}if(r.common.async)return Promise.all(n.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 n){const d={...r,common:{...r.common,issues:[]},parent:null},h=c._parseSync({data:r.data,path:r.path,parent:d});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,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 Ju(c));return Gs(r,{code:rs.invalid_union,unionErrors:l}),Yr}}get options(){return this._def.options}}R0.create=(e,s)=>new R0({options:e,typeName:Zr.ZodUnion,...En(s)});const Hp=e=>e instanceof D0?Hp(e.schema):e instanceof Nh?Hp(e.innerType()):e instanceof L0?[e.value]:e instanceof Mg?e.options:e instanceof $0?ba.objectValues(e.enum):e instanceof F0?Hp(e._def.innerType):e instanceof A0?[void 0]:e instanceof M0?[null]:e instanceof sp?[void 0,...Hp(e.unwrap())]:e instanceof Rg?[null,...Hp(e.unwrap())]:e instanceof _O||e instanceof U0?Hp(e.unwrap()):e instanceof B0?Hp(e._def.innerType):[];class Hk extends Un{_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==rr.object)return Gs(r,{code:rs.invalid_type,expected:rr.object,received:r.parsedType}),Yr;const n=this.discriminator,a=r.data[n],i=this.optionsMap.get(a);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(Gs(r,{code:rs.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Yr)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(s,r,n){const a=new Map;for(const i of r){const o=Hp(i.shape[s]);if(!o.length)throw new Error(`A discriminator value for key \`${s}\` could not be extracted from all schema options`);for(const l of o){if(a.has(l))throw new Error(`Discriminator property ${String(s)} has duplicate value ${String(l)}`);
vendor: 4,718 bytes, line 8
8a.set(l,i)}}return new Hk({typeName:Zr.ZodDiscriminatedUnion,discriminator:s,options:r,optionsMap:a,...En(n)})}}function W5(e,s){const r=Kp(e),n=Kp(s);if(e===s)return{valid:!0,data:e};if(r===rr.object&&n===rr.object){const a=ba.objectKeys(s),i=ba.objectKeys(e).filter(l=>a.indexOf(l)!==-1),o={...e,...s};for(const l of i){const c=W5(e[l],s[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(r===rr.array&&n===rr.array){if(e.length!==s.length)return{valid:!1};const a=[];for(let i=0;i<e.length;i++){const o=e[i],l=s[i],c=W5(o,l);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return r===rr.date&&n===rr.date&&+e==+s?{valid:!0,data:e}:{valid:!1}}class I0 extends Un{_parse(s){const{status:r,ctx:n}=this._processInputParams(s),a=(i,o)=>{if(q5(i)||q5(o))return Yr;const l=W5(i.value,o.value);return l.valid?((V5(i)||V5(o))&&r.dirty(),{status:r.value,value:l.data}):(Gs(n,{code:rs.invalid_intersection_types}),Yr)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>a(i,o)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}I0.create=(e,s,r)=>new I0({left:e,right:s,typeName:Zr.ZodIntersection,...En(r)});class dp extends Un{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==rr.array)return Gs(n,{code:rs.invalid_type,expected:rr.array,received:n.parsedType}),Yr;if(n.data.length<this._def.items.length)return Gs(n,{code:rs.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Yr;!this._def.rest&&n.data.length>this._def.items.length&&(Gs(n,{code:rs.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new cp(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>_d.mergeArray(r,o)):_d.mergeArray(r,i)}get items(){return this._def.items}rest(s){return new dp({...this._def,rest:s})}}dp.create=(e,s)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new dp({items:e,typeName:Zr.ZodTuple,rest:null,...En(s)})};class O0 extends Un{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==rr.object)return Gs(n,{code:rs.invalid_type,expected:rr.object,received:n.parsedType}),Yr;const a=[],i=this._def.keyType,o=this._def.valueType;for(const l in n.data)a.push({key:i._parse(new cp(n,l,n.path,l)),value:o._parse(new cp(n,n.data[l],n.path,l)),alwaysSet:l in n.data});return n.common.async?_d.mergeObjectAsync(r,a):_d.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(s,r,n){return r instanceof Un?new O0({keyType:s,valueType:r,typeName:Zr.ZodRecord,...En(n)}):new O0({keyType:xh.create(),valueType:s,typeName:Zr.ZodRecord,...En(r)})}}class $S extends Un{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==rr.map)return Gs(n,{code:rs.invalid_type,expected:rr.map,received:n.parsedType}),Yr;const a=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,c],d)=>({key:a._parse(new cp(n,l,n.path,[d,"key"])),value:i._parse(new cp(n,c,n.path,[d,"value"]))}));if(n.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const d=await c.key,h=await c.value;if(d.status==="aborted"||h.status==="aborted")return Yr;(d.status==="dirty"||h.status==="dirty")&&r.dirty(),l.set(d.value,h.value)}return{status:r.value,value:l}})}else{const l=new Map;for(const c of o){const d=c.key,h=c.value;if(d.status==="aborted"||h.status==="aborted")return Yr;(d.status==="dirty"||h.status==="dirty")&&r.dirty(),l.set(d.value,h.value)}return{status:r.value,value:l}}}}$S.create=(e,s,r)=>new $S({valueType:s,keyType:e,typeName:Zr.ZodMap,...En(r)});class Qx extends Un{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==rr.set)return Gs(n,{code:rs.invalid_type,expected:rr.set,received:n.parsedType}),Yr;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(Gs(n,{code:rs.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(Gs(n,{code:rs.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;
vendor: 4,524 bytes, line 8
8for(const h of c){if(h.status==="aborted")return Yr;h.status==="dirty"&&r.dirty(),d.add(h.value)}return{status:r.value,value:d}}const l=[...n.data.values()].map((c,d)=>i._parse(new cp(n,c,n.path,d)));return n.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(s,r){return new Qx({...this._def,minSize:{value:s,message:Nr.toString(r)}})}max(s,r){return new Qx({...this._def,maxSize:{value:s,message:Nr.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}Qx.create=(e,s)=>new Qx({valueType:e,minSize:null,maxSize:null,typeName:Zr.ZodSet,...En(s)});class oy extends Un{constructor(){super(...arguments),this.validate=this.implement}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==rr.function)return Gs(r,{code:rs.invalid_type,expected:rr.function,received:r.parsedType}),Yr;function n(l,c){return OS({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,IS(),Ay].filter(d=>!!d),issueData:{code:rs.invalid_arguments,argumentsError:c}})}function a(l,c){return OS({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,IS(),Ay].filter(d=>!!d),issueData:{code:rs.invalid_return_type,returnTypeError:c}})}const i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Ry){const l=this;return Yd(async function(...c){const d=new Ju([]),h=await l._def.args.parseAsync(c,i).catch(v=>{throw d.addIssue(n(c,v)),d}),p=await Reflect.apply(o,this,h);return await l._def.returns._def.type.parseAsync(p,i).catch(v=>{throw d.addIssue(a(p,v)),d})})}else{const l=this;return Yd(function(...c){const d=l._def.args.safeParse(c,i);if(!d.success)throw new Ju([n(c,d.error)]);const h=Reflect.apply(o,this,d.data),p=l._def.returns.safeParse(h,i);if(!p.success)throw new Ju([a(h,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...s){return new oy({...this._def,args:dp.create(s).rest(Ox.create())})}returns(s){return new oy({...this._def,returns:s})}implement(s){return this.parse(s)}strictImplement(s){return this.parse(s)}static create(s,r,n){return new oy({args:s||dp.create([]).rest(Ox.create()),returns:r||Ox.create(),typeName:Zr.ZodFunction,...En(n)})}}class D0 extends Un{get schema(){return this._def.getter()}_parse(s){const{ctx:r}=this._processInputParams(s);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}D0.create=(e,s)=>new D0({getter:e,typeName:Zr.ZodLazy,...En(s)});class L0 extends Un{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Gs(r,{received:r.data,code:rs.invalid_literal,expected:this._def.value}),Yr}return{status:"valid",value:s.data}}get value(){return this._def.value}}L0.create=(e,s)=>new L0({value:e,typeName:Zr.ZodLiteral,...En(s)});function eY(e,s){return new Mg({values:e,typeName:Zr.ZodEnum,...En(s)})}class Mg extends Un{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Gs(r,{expected:ba.joinValues(n),received:r.parsedType,code:rs.invalid_type}),Yr}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(s.data)){const r=this._getOrReturnCtx(s),n=this._def.values;return Gs(r,{received:r.data,code:rs.invalid_enum_value,options:n}),Yr}return Yd(s.data)}get options(){return this._def.values}get enum(){const s={};for(const r of this._def.values)s[r]=r;return s}get Values(){const s={};for(const r of this._def.values)s[r]=r;return s}get Enum(){const s={};for(const r of this._def.values)s[r]=r;return s}extract(s,r=this._def){return Mg.create(s,{...this._def,...r})}exclude(s,r=this._def){return Mg.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}Mg.create=eY;class $0 extends Un{_parse(s){const r=ba.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==rr.string&&n.parsedType!==rr.number){const a=ba.objectValues(r);return Gs(n,{expected:ba.joinValues(a),received:n.parsedType,code:rs.invalid_type}),Yr}if(this._cache||(this._cache=new Set(ba.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=ba.objectValues(r);return Gs(n,{received:n.data,code:rs.invalid_enum_value,options:a}),Yr}return Yd(s.data)}get enum(){return this._def.values}}$0.create=(e,s)=>new $0({values:e,typeName:Zr.ZodNativeEnum,...En(s)});class Ry extends Un{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==rr.promise&&r.common.async===!1)return Gs(r,{code:rs.invalid_type,expected:rr.promise,received:r.parsedType}),Yr;
vendor: 4,098 bytes, line 8
8const n=r.parsedType===rr.promise?r.data:Promise.resolve(r.data);return Yd(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Ry.create=(e,s)=>new Ry({type:e,typeName:Zr.ZodPromise,...En(s)});class Nh extends Un{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Zr.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(s){const{status:r,ctx:n}=this._processInputParams(s),a=this._def.effect||null,i={addIssue:o=>{Gs(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const o=a.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return Yr;const c=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return c.status==="aborted"?Yr:c.status==="dirty"||r.value==="dirty"?Yv(c.value):c});{if(r.value==="aborted")return Yr;const l=this._def.schema._parseSync({data:o,path:n.path,parent:n});return l.status==="aborted"?Yr:l.status==="dirty"||r.value==="dirty"?Yv(l.value):l}}if(a.type==="refinement"){const o=l=>{const c=a.refinement(l,i);if(n.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(n.common.async===!1){const l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?Yr:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?Yr:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(a.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Gx(o))return Yr;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:n.data,path:n.path,parent:n}).then(o=>Gx(o)?Promise.resolve(a.transform(o.value,i)).then(l=>({status:r.value,value:l})):Yr);ba.assertNever(a)}}Nh.create=(e,s,r)=>new Nh({schema:e,typeName:Zr.ZodEffects,effect:s,...En(r)});Nh.createWithPreprocess=(e,s,r)=>new Nh({schema:s,effect:{type:"preprocess",transform:e},typeName:Zr.ZodEffects,...En(r)});class sp extends Un{_parse(s){return this._getType(s)===rr.undefined?Yd(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}sp.create=(e,s)=>new sp({innerType:e,typeName:Zr.ZodOptional,...En(s)});class Rg extends Un{_parse(s){return this._getType(s)===rr.null?Yd(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}Rg.create=(e,s)=>new Rg({innerType:e,typeName:Zr.ZodNullable,...En(s)});class F0 extends Un{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===rr.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}F0.create=(e,s)=>new F0({innerType:e,typeName:Zr.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...En(s)});class B0 extends Un{_parse(s){const{ctx:r}=this._processInputParams(s),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return E0(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ju(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ju(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}B0.create=(e,s)=>new B0({innerType:e,typeName:Zr.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...En(s)});class FS extends Un{_parse(s){if(this._getType(s)!==rr.nan){const n=this._getOrReturnCtx(s);return Gs(n,{code:rs.invalid_type,expected:rr.nan,received:n.parsedType}),Yr}
8return{status:"valid",value:s.data}}}FS.create=e=>new FS({typeName:Zr.ZodNaN,...En(e)});const hhe=Symbol("zod_brand");class _O extends Un{_parse(s){const{ctx:r}=this._processInputParams(s),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Kj extends Un{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Yr:i.status==="dirty"?(r.dirty(),Yv(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Yr:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(s,r){return new Kj({in:s,out:r,typeName:Zr.ZodPipeline})}}class U0 extends Un{_parse(s){const r=this._def.innerType._parse(s),n=a=>(Gx(a)&&(a.value=Object.freeze(a.value)),a);return E0(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}U0.create=(e,s)=>new U0({innerType:e,typeName:Zr.ZodReadonly,...En(s)});function q$(e,s){const r=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function PO(e,s={},r){return e?My.create().superRefine((n,a)=>{const i=e(n);if(i instanceof Promise)return i.then(o=>{if(!o){const l=q$(s,n),c=l.fatal??r??!0;a.addIssue({code:"custom",...l,fatal:c})}});if(!i){const o=q$(s,n),l=o.fatal??r??!0;a.addIssue({code:"custom",...o,fatal:l})}}):My.create()}const phe={object:jo.lazycreate};var Zr;(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"})(Zr||(Zr={}));const fhe=(e,s={message:`Input not instance of ${e.name}`})=>PO(r=>r instanceof e,s),it=xh.create,_r=Tg.create,ghe=FS.create,xhe=Ag.create,nf=T0.create,vhe=Yx.create,yhe=DS.create,bhe=A0.create,tY=M0.create,BS=My.create,whe=Ox.create,jhe=xf.create,Nhe=LS.create,z0=vh.create,Gd=jo.create,She=jo.strictCreate,qk=R0.create,Che=Hk.create,khe=I0.create,_he=dp.create,sY=O0.create,Phe=$S.create,Ehe=Qx.create,The=oy.create,Ahe=D0.create,Hu=L0.create,Wc=Mg.create,Mhe=$0.create,Rhe=Ry.create,V$=Nh.create,Ihe=sp.create,Ohe=Rg.create,Dhe=Nh.createWithPreprocess,Lhe=Kj.create,$he=()=>it().optional(),Fhe=()=>_r().optional(),Bhe=()=>nf().optional(),iS={string:(e=>xh.create({...e,coerce:!0})),number:(e=>Tg.create({...e,coerce:!0})),boolean:(e=>T0.create({...e,coerce:!0})),bigint:(e=>Ag.create({...e,coerce:!0})),date:(e=>Yx.create({...e,coerce:!0}))},Uhe=Yr,zhe=Object.freeze(Object.defineProperty({__proto__:null,BRAND:hhe,DIRTY:Yv,EMPTY_PATH:Vme,INVALID:Yr,NEVER:Uhe,OK:Yd,ParseStatus:_d,Schema:Un,ZodAny:My,ZodArray:vh,ZodBigInt:Ag,ZodBoolean:T0,ZodBranded:_O,ZodCatch:B0,ZodDate:Yx,ZodDefault:F0,ZodDiscriminatedUnion:Hk,ZodEffects:Nh,ZodEnum:Mg,ZodError:Ju,get ZodFirstPartyTypeKind(){return Zr},ZodFunction:oy,ZodIntersection:I0,ZodIssueCode:rs,ZodLazy:D0,ZodLiteral:L0,ZodMap:$S,ZodNaN:FS,ZodNativeEnum:$0,ZodNever:xf,ZodNull:M0,ZodNullable:Rg,ZodNumber:Tg,ZodObject:jo,ZodOptional:sp,ZodParsedType:rr,ZodPipeline:Kj,ZodPromise:Ry,ZodReadonly:U0,ZodRecord:O0,ZodSchema:Un,ZodSet:Qx,ZodString:xh,ZodSymbol:DS,ZodTransformer:Nh,ZodTuple:dp,ZodType:Un,ZodUndefined:A0,ZodUnion:R0,ZodUnknown:Ox,ZodVoid:LS,addIssueToContext:Gs,any:BS,array:z0,bigint:xhe,boolean:nf,coerce:iS,custom:PO,date:vhe,datetimeRegex:JG,defaultErrorMap:Ay,discriminatedUnion:Che,effect:V$,enum:Wc,function:The,getErrorMap:IS,getParsedType:Kp,instanceof:fhe,intersection:khe,isAborted:q5,isAsync:E0,isDirty:V5,isValid:Gx,late:phe,lazy:Ahe,literal:Hu,makeIssue:OS,map:Phe,nan:ghe,n
8ativeEnum:Mhe,never:jhe,null:tY,nullable:Ohe,number:_r,object:Gd,get objectUtil(){return H5},oboolean:Bhe,onumber:Fhe,optional:Ihe,ostring:$he,pipeline:Lhe,preprocess:Dhe,promise:Rhe,quotelessJson:Hme,record:sY,set:Ehe,setErrorMap:qme,strictObject:She,string:it,symbol:yhe,transformer:V$,tuple:_he,undefined:bhe,union:qk,unknown:whe,get util(){return ba},void:Nhe},Symbol.toStringTag,{value:"Module"})),vs=Wc(["true","false"]).catch("true").default("true"),pw=Wc(["true","false"]).catch("false").default("false"),Hhe=Gd({id:it().trim().min(1).max(100),imageUrl:it().max(2e3).refine(e=>e===""||e.startsWith("/public-objects/")||/^https:\/\/\S+$/i.test(e),"Image URL must be a published object or HTTPS URL"),eventDate:it().trim().min(1).max(200),location:it().trim().min(1).max(300),websiteTitle:it().max(200),websiteUrl:it().max(2e3).refine(e=>e===""||/^https?:\/\/\S+$/i.test(e),"Website URL must be http(s)"),description:it().trim().min(1).max(5e3)}).superRefine((e,s)=>{e.websiteUrl&&!e.websiteTitle.trim()&&s.addIssue({code:rs.custom,path:["websiteTitle"],message:"Website title is required when a URL is provided"}),e.websiteTitle.trim()&&!e.websiteUrl&&s.addIssue({code:rs.custom,path:["websiteUrl"],message:"Website URL is required when a title is provided"})}),US=Gd({brandName:it(),productName:it(),legalCompanyName:it(),tagline:it(),domain:it(),website:it(),phone:it(),phoneHref:it(),businessHours:it(),addressLine1:it(),addressLine2:it(),supportEmail:it(),salesEmail:it(),billingEmail:it(),infoEmail:it(),alertsEmail:it(),helpEmail:it(),noreplyEmail:it(),appEmblemUrl:it(),emailLogoUrl:it(),faviconUrl:it(),appleTouchIconUrl:it(),pwaIcon192Url:it(),pwaIcon512Url:it(),ogImageUrl:it(),brandColor:it(),themeColor:it(),showDemetriMode:vs,extendTheme:pw,emailUseBrandColors:pw,showTestimonials:vs,landingFeaturePills:it(),landingShowHero:vs,landingHeroBadge:it(),landingHeroHeading:it(),landingHeroHeadingHighlight:it(),landingHeroSubheading:it(),landingHeroCustomButtonEnabled:pw,landingHeroCustomButtonText:it().trim().max(120),landingHeroCustomButtonUrl:it().trim().max(2e3).refine(e=>{if(!e)return!0;try{const s=new URL(e);return(s.protocol==="https:"||s.protocol==="http:")&&/^https?:\/\//i.test(e)}catch{return!1}},"Enter a complete http:// or https:// URL for the custom button."),landingHeroPrimaryButton:it(),landingHeroSecondaryButton:it(),landingHeroSecondaryButtonUrl:it().trim().max(2e3).refine(e=>{if(!e)return!0;try{const s=new URL(e);return(s.protocol==="https:"||s.protocol==="http:")&&/^https?:\/\//i.test(e)}catch{return!1}},"Enter a complete http:// or https:// URL, or leave blank to open the contact form."),landingHeroChatButton:it(),landingHeroTrustPoints:it(),landingShowTrustedBy:vs,landingTrustedByHeading:it(),landingTrustedByNames:it(),landingShowTestimonials:vs,landingTestimonialsHeading:it(),landingTestimonials:it(),landingShowFeatureGrid:vs,landingFeaturesHeading:it(),landingFeaturesSubheading:it(),landingFeatureCards:it(),landingShowScreenshots:vs,landingScreenshotsHeading:it(),landingScreenshotsSubheading:it(),landingScreenshotCaptions:it(),landingShowAiSearch:vs,landingAiSearchEyebrow:it(),landingAiSearchHeading:it(),landingAiSearchSubheading:it(),landingAiSearchCards:it(),landingShowFacesPeople:vs,landingFacesHeading:it(),landingFacesParagraph:it(),landingFacesBullets:it(),landingFacesButton:it(),landingShowEasySetup:vs,landingSetupEyebrow:it(),landingSetupHeading:it(),landingSetupParagraph:it(),landingSetupSteps:it(),landingSetupImageCaption:it(),landingShowCloudStorage:vs,landingCloudEyebrow:it(),landingCloudHeading:it(),landingCloudParagraph:it(),landingCloudPoints:it(),landingCloudStats:it(),landingShowDeployment:vs,landingDeployEyebrow:it(),landingDeployHeading:it(),landingDeploySubheading:it(),landingDeployPlan1:it(),landingDeployPlan2:it(),landingDeployPlan3:it(),landingAlertsBadge:it(),landingAlertsHeading:it(),landingAlertsPara1:it(),landingAlertsPara2:it(),landingAlertsExamples:it(),landingShowCta:vs,landingCtaHeading:it(),landingCtaSubheading:it(),landingCtaButton:it(),demoBannerMessage:it(),demoAllowMainStream:pw,demoFullJpegQuality:pw,pageText:it(),events:z0(Hhe).max(100).superRefine((e,s)=>{const r=new Set;e.forEach((n,a)=>{r.has(n.id)&&s.addIssue({code:rs.custom,path:[a,"id"],message:"Event IDs must be unique"}),r.add(n.id)})}),legalEntityName:it(),legalDomain:it(),facebookUrl:it(),instagramUrl:it(),linkedinUrl:it(),xUrl:it(),youtubeUrl:it(),pricingUrl:it(),systemHealthUrl:it(),appTitle:it(),metaDescription:it(),ogTitle:it(),ogDescription:it(),pwaName:it(),pwaShortName:it(),pwaDescription:it(),navProducts:vs,navProductsEdge:vs,navProductsBlu:vs,navPricing:vs,navPricingEdge:vs,navPricingBlu:vs,navSolutions:vs,navSolutionsHospitality:vs,navSolutionsRetail:vs,navSolutionsRestaurants:vs,navSolutionsHealthcare:vs,navSolutionsEducation:vs,navSolutionsGovernment:vs,navSolutionsCommercialRealEstate:vs,navSolutionsCannabis:vs,navSolutionsWeaponDetection:vs,navSolutionsFacesPeople:vs,navSolutionsNaturalTextSearch:vs,navSolutionsObjectDetection:vs,navSolutionsVisualComparisons:v
8s,navSolutionsSmartAiAlerts:vs,navSolutionsCloudVideoSurveillance:vs,navSolutionsDeviceNotifications:vs,navSolutionsPtzFisheye:vs,navResources:vs,navResourcesWhitePaper:vs,navResourcesSupportedDevices:vs,navResourcesOemBranding:vs,navResourcesBlog:vs,navResourcesEvents:vs,navSupport:vs,navSupportEdgeAppInstall:vs,navSupportBluDocumentation:vs,navSupportSubmitTicket:vs,navSupportDownloads:vs,navSupportSystemHealth:vs,navContact:vs,navContactUs:vs,navContactChat:vs,navContactRefer:vs,imgChassisNuc:it(),imgChassis2u:it(),imgChassis4u:it(),imgOnboardingLogin:it(),imgOnboardingPassword:it(),imgOnboarding2fa:it(),imgOnboardingLiveView:it(),imgOnboardingEvents:it(),imgOnboardingAddUser:it(),imgOnboardingAddDevice:it(),imgLandingHeroFirearm:it(),imgLandingHeroFirearmShow:vs,imgLandingHeroPhone:it(),imgLandingHeroPhoneShow:vs,imgLandingEventRetrieval:it(),imgLandingEventRetrievalShow:vs,imgLandingAiFeatures:it(),imgLandingAiFeaturesShow:vs,imgLandingNotifications:it(),imgLandingNotificationsShow:vs,imgLandingLiveView:it(),imgLandingLiveViewShow:vs,imgLandingAiTextSearch:it(),imgLandingAiTextSearchShow:vs,imgLandingVisualSearch:it(),imgLandingVisualSearchShow:vs,imgLandingEdgeDevice:it(),imgLandingEdgeDeviceShow:vs,imgLandingCameraDiscovery:it(),imgLandingCameraDiscoveryShow:vs,imgLandingCloudStorage:it(),imgLandingCloudStorageShow:vs,imgLandingSmartAlert:it(),imgLandingSmartAlertShow:vs,imgLandingFacesPeople:it(),imgLandingFacesPeopleShow:vs,imgBluHero:it(),imgBluHeroShow:vs,imgBluEmsDashboard:it(),imgBluEmsDashboardShow:vs,imgBluEmsAiSearch:it(),imgBluEmsAiSearchShow:vs,imgBluEmsOnPremise:it(),imgBluEmsOnPremiseShow:vs,imgBluEmsAiRetrieval:it(),imgBluEmsAiRetrievalShow:vs,imgBluEmsObjectDetect:it(),imgBluEmsObjectDetectShow:vs,imgBluEmsLiveView:it(),imgBluEmsLiveViewShow:vs,imgWeaponHero:it(),imgWeaponHeroShow:vs,imgFacesHero:it(),imgFacesHeroShow:vs,imgFacesSearch:it(),imgFacesSearchShow:vs,imgAlertsInbox:it(),imgAlertsInboxShow:vs,imgAlertsMobile:it(),imgAlertsMobileShow:vs,imgAlertsRule:it(),imgAlertsRuleShow:vs,imgVisualSearch:it(),imgVisualSearchShow:vs,imgVisualMatch:it(),imgVisualMatchShow:vs,imgCloudHero:it(),imgCloudHeroShow:vs,imgNotifHero:it(),imgNotifHeroShow:vs,imgOemHero:it(),imgOemHeroShow:vs,imgInstallApple1:it(),imgInstallApple1Show:vs,imgInstallApple2:it(),imgInstallApple2Show:vs,imgInstallApple3:it(),imgInstallApple3Show:vs,imgInstallAndroid1:it(),imgInstallAndroid1Show:vs,imgInstallAndroid2:it(),imgInstallAndroid2Show:vs,imgInstallAndroid3:it(),imgInstallAndroid3Show:vs});US.partial().superRefine((e,s)=>{e.landingHeroCustomButtonEnabled==="true"&&!e.landingHeroCustomButtonUrl?.trim()&&s.addIssue({code:rs.custom,path:["landingHeroCustomButtonUrl"],message:"A URL is required when enabling the custom homepage button."})});const Iy={brandName:"Truvios",productName:"Truvios Edge",legalCompanyName:"Truvios",tagline:"Centralized Site Management",domain:"truvios.ai",website:"https://truvios.ai",phone:"855-878-8467",phoneHref:"+18558788467",businessHours:"Mon-Fri | 8:30 AM – 5:00 PM",addressLine1:"87 B Montauk Highway",addressLine2:"Copiague, NY 11726",supportEmail:"[email protected]",salesEmail:"[email protected]",billingEmail:"[email protected]",infoEmail:"[email protected]",alertsEmail:"[email protected]",helpEmail:"[email protected]",noreplyEmail:"[email protected]",appEmblemUrl:"",emailLogoUrl:"",faviconUrl:"",appleTouchIconUrl:"",pwaIcon192Url:"",pwaIcon512Url:"",ogImageUrl:"",brandColor:"#3b5bdb",themeColor:"#0a1628",showDemetriMode:"true",extendTheme:"false",emailUseBrandColors:"false",showTestimonials:"true",landingFeaturePills:["Replace or keep your recorder, integrates with any camera.","Local storage and affordable cloud retention subscriptions.","No subscription one-time purchase options.","Free Ai included, with natural language event search."].join(`
9`),landingShowHero:"true",landingHeroBadge:"All In One VMS with Hybrid Storage & AI",landingHeroHeading:"Cloud Video Surveillance With",landingHeroHeadingHighlight:"AI",landingHeroSubheading:"Still Searching Through Hours of Video to Find One Event?",landingHeroCustomButtonEnabled:"false",landingHeroCustomButtonText:"Visit Website",landingHeroCustomButtonUrl:"",landingHeroPrimaryButton:"Get Started Free",landingHeroSecondaryButton:"Learn More",landingHeroSecondaryButtonUrl:"",landingHeroChatButton:"Chat With Us",landingHeroTrustPoints:["Secure Connections","Cloud Accessible","Works With Any Camera"].join(`
10`),landingShowTrustedBy:"true",landingTrustedByHeading:"Trusted By",landingTrustedByNames:["Foxwoods","The Ritz-Carlton","Prana Investments","McDonalds","Brenntag","Vepo Solutions","Douglas Elliman","Hertz","Hilton Garden Inn","Marriott","IHG Hotels & Resorts","LaGuardia Community College","Burger King","North Castle Police Department","Bloomberg","Housatonic Community College","Fazoli's","Planet Fitness","Acadian Health","Fluent Cannabis"].join(`
11`),landingShowTestimonials:"true",landingTestimonialsHeading:"What Our Clients Say",landingTestimonials:["The system gave us complete visibility across all our hotel properties from a single dashboard. It transformed how our security team operates. | James T. | IT Director | Hilton Garden Inn","We can review incidents remotely without driving to the site. {productName} completely changed our security workflow and saved us countless hours. | Maria L. | Security Manager | Planet Fitness","Cloud storage integration saved us during a hard drive failure. Our footage was safe in Google Cloud and we never missed a single moment. | Chris D. | Facilities Manager | Marriott"].join(`
12`),landingShowFeatureGrid:"true",landingFeaturesHeading:"Everything You Need",landingFeaturesSubheading:"Powerful features designed to simplify Edge device management across all your locations",landingFeatureCards:["Role-Based Access | Administrator management of sites and companies to secure all users.","Plug & Play | Connect to {productName} devices without port forwarding.","Web & Mobile | Easy access to all your locations on web browsers, phones and tablets.","Zero Subscription Plans | One-time Edge device purchase with local storage, and Ai features.","Cloud Storage Plans | Affordable cloud storage recording from weeks, months, and years.","Universal Compatibility | Works with any camera, dvr or nvr that supports Onvif or RTSP."].join(`
13`),landingShowScreenshots:"true",landingScreenshotsHeading:"See It In Action",landingScreenshotsSubheading:"Manage every camera, review events, and stay notified — all from a single platform.",landingScreenshotCaptions:["On-Premise & Cloud Search | Search","AI Features","Notifications | Alerts","Live View"].join(`
14`),landingShowAiSearch:"true",landingAiSearchEyebrow:"AI Features",landingAiSearchHeading:"AI-Powered Search",landingAiSearchSubheading:"Find exactly what you're looking for across hours of footage in seconds — using natural language and visual selection.",landingAiSearchCards:['AI Text Search | Type a natural language description like "Find a white van" and the AI instantly searches your recorded footage, returning matching events with confidence scores.',"Visual Search | Draw a box around any person, vehicle, or object in a video frame and the AI finds all matching events across your cameras and locations."].join(`
15`),landingShowFacesPeople:"true",landingFacesHeading:"Faces & People",landingFacesParagraph:"Build a named library of individuals and automatically recognize them across every camera — alerting your team by push notifications the moment a known face appears, whether it's a VIP guest, a banned individual such as a shoplifter, or your employees.",landingFacesBullets:["Per-person face library with reference photos","Real-time recognition across all cameras and sites","Instant alerts on recognition with snapshot and confidence score","Search recordings by person name in plain language"].join(`
16`),landingFacesButton:"Learn More",landingShowEasySetup:"true",landingSetupEyebrow:"Edge Bridge",landingSetupHeading:"Easy Setup",landingSetupParagraph:"Our edge device comes with dual ethernet ports allowing you to connect to your router, and the additional port can be used to connect to a POE switch for your cameras or existing recorder. Run a camera discovery in our software, and setup is complete.",landingSetupSteps:["Connect to Network | Plug the Edge device into your router using one of the built-in dual ethernet ports.","Connect Your Cameras | Use the secondary port to connect all your IP cameras — only required if you have a second network.","Run Camera Discovery | Access Device Settings, run a network scan, and 
16your cameras or existing recorder are found and configured automatically."].join(`
17`),landingSetupImageCaption:"Camera Discovery",landingShowCloudStorage:"true",landingCloudEyebrow:"Cloud Storage",landingCloudHeading:"Your Footage, Protected — When It Matters Most",landingCloudParagraph:"Why add cloud storage? Avoid data overwriting or hard drive failures when you need your footage the most. Most lawsuit claims come several months after the data is no longer available.",landingCloudPoints:["Google Cloud Storage | Edge devices sync recordings directly to Google Cloud Storage — providing multi-region redundancy.","Survive Hard Drive Failures | Local drives fail. Cloud recordings remain intact and accessible regardless of on-site hardware issues.","Stay Protected From Legal Claims | Configure retention periods up to years. Your footage will still be there long after on-premise storage has overwritten it."].join(`
18`),landingCloudStats:["99.9% | Google Cloud Uptime","Up to 5 Years | Cloud Storage Retention"].join(`
19`),landingShowDeployment:"true",landingDeployEyebrow:"Deployment Options",landingDeployHeading:"Choose Your Setup",landingDeploySubheading:"Choose the right setup for your environment",landingDeployPlan1:["Zero | Keep everything on-premise. No Subscription.","+ Use as a VMS or replace existing NVR","+ Includes Local Storage","+ Includes AI","- Basic Smart Alerts (object & face detection)","- Remote Camera Monitoring & Alerts","- Cloud Backup & Storage"].join(`
20`),landingDeployPlan2:["Hybrid | The best of both worlds. Secure cloud redundancy and alerting. | Recommended","+ Use as a VMS or replace existing NVR","+ Includes Local Storage","+ Includes AI","+ Basic Smart Alerts (object & face detection)","* Remote Camera Monitoring & Alerts","* Secure Cloud Backup & Retention"].join(`
21`),landingDeployPlan3:["Plus | Add device monitoring.","+ Use as a VMS or replace existing NVR","+ Includes Local Storage","+ Includes AI","+ Basic Smart Alerts (object & face detection)","+ Remote Camera Monitoring & Alerts","- Cloud Backup & Storage"].join(`
22`),landingAlertsBadge:"Optional Add On",landingAlertsHeading:"Premium Smart Alerts",landingAlertsPara1:"Any subscription plan includes **basic smart alerts** such as object and face recognition detection.",landingAlertsPara2:"**Premium Smart Alerts** let you describe what you want to be notified about in plain English — for example:",landingAlertsExamples:["Person with a gun","Shoplifting","Slip & fall","Any phrase you want detected"].join(`
23`),landingShowCta:"true",landingCtaHeading:"Ready to Simplify & Modernize Your Surveillance?",landingCtaSubheading:"Join now and access all your surveillance locations from a single, secure dashboard.",landingCtaButton:"Get Started Free",demoBannerMessage:"Settings, audio, and exporting are restricted. Live view and recording are intentionally lowered during public testing.",demoAllowMainStream:"false",demoFullJpegQuality:"false",pageText:"",events:[],legalEntityName:"Truvios",legalDomain:"truvios.ai",facebookUrl:"",instagramUrl:"",linkedinUrl:"",xUrl:"",youtubeUrl:"",pricingUrl:"https://pricing.truvios.ai",systemHealthUrl:"https://truvios-services.com",appTitle:"Truvios Edge",metaDescription:"Access all your sites from one dashboard. Connect to multiple locations with live viewing, event retrieval, real-time status monitoring, AI object detection and facial recognition.",ogTitle:"Truvios Edge - Centralized Site Management",ogDescription:"Streamline your video surveillance management with centralized site access.",pwaName:"Truvios Edge",pwaShortName:"Truvios Edge",pwaDescription:"Centralized Site Management Dashboard",navProducts:"true",navProductsEdge:"true",navProductsBlu:"true",navPricing:"true",navPricingEdge:"true",navPricingBlu:"true",navSolutions:"true",navSolutionsHospitality:"true",navSolutionsRetail:"true",navSolutionsRestaurants:"true",navSolutionsHealthcare:"true",navSolutionsEducation:"true",navSolutionsGovernment:"true",navSolutionsCommercialRealEstate:"true",navSolutionsCannabis:"true",navSolutionsWeaponDetection:"true",navSolutionsFacesPeople:"true",navSolutionsNaturalTextSearch:"true",navSolutionsObjectDetection:"true",navSolutionsVisualComparisons:"true",navSolutionsSmartAiAlerts:"true",navSolutionsCloudVideoSurveillance:"true",navSolutionsDeviceNotifications:"true",navSolutionsPtzFisheye:"true",navResources:"true",navResourcesWhitePaper:"true",navResourcesSupportedDevices:"true",navResourcesOemBranding:"true",navResourcesBlog:"true",navResourcesEvents:"true",navSupport:"true",navSupportEdgeAppInstall:"true",navSupportBluDocumentation:"true",navSupportSubmitTicket:"true",navSupportDownloads:"true",navSupportSystemHealth:"true",navContact:"true",navContactUs:"true",navContactChat:"true",navContactRefer:"true",imgChassisNuc:"",imgChassis2u:"",imgChassis4u:"",imgOnboardingLogin:"",imgOnboardingPassword:"",imgOnboarding2fa:"",imgOnboardingLiveView:"",imgOnboardingEvents:"",imgOnboardingAddUser:"",imgOnboardingAddDevice:"",imgLandingHeroFirearm:"",imgLandingHeroFirearmShow:"true",imgLandingHeroPhone:"",imgLandingHeroPhoneShow:"true",imgLandingEventRetrieval:"",imgLandingEventRetrievalShow:"true",imgLandingAiFeatures:"",imgLandingAiFeaturesShow:"true",imgLandingNotifications:"",imgLandingNotificationsShow:"true",imgLandingLiveView:"",imgLandingLiveViewShow:"true",imgLandingAiTextSearch:"",imgLandingAiTextSearchShow:"true",imgLandingVisualSearch:"",imgLandingVisualSearchShow:"true",imgLandingEdgeDevice:"",imgLandingEdgeDeviceShow:"true",imgLandingCameraDiscovery:"",imgLandingCameraDiscoveryShow:"true",imgLandingCloudStorage:"",imgLandingCloudStorageShow:"true",imgLandingSmartAlert:"",imgLandingSmartAlertShow:"true",imgLandingFacesPeople:"",imgLandingFacesPeopleShow:"true",imgBluHero:"",imgBluHeroShow:"true",imgBluEmsDashboard:"",imgBluEmsDashboardShow:"true",imgBluEmsAiSearch:"",imgBluEmsAiSearchShow:"true",imgBluEmsOnPremise:"",imgBluEmsOnPremiseShow:"true",imgBluEmsAiRetrieval:"",imgBluEmsAiRetrievalShow:"true",imgBluEmsObjectDetect:"",imgBluEmsObjectDetectShow:"true",imgBluEmsLiveView:"",imgBluEmsLiveViewShow:"true",imgWeaponHero:"",imgWeaponHeroShow:"true",imgFacesHero:"",imgFacesHeroShow:"true",imgFacesSearch:"",imgFacesSearchShow:"true",imgAlertsInbox:"",imgAlertsInboxShow:"true",imgAlertsMobile:"",imgAlertsMobileShow:"true",imgAlertsRule:"",imgAlertsRuleShow:"true",imgVisualSearch:"",imgVisualSearchShow:"true",imgVisualMatch:"",imgVisualMatchShow:"true",imgCloudHero:"",imgCloudHeroShow:"true",imgNotifHero:"",imgNotifHeroShow:"true",imgOemHero:"",imgOemHeroShow:"true",imgInstallApple1:"",imgInstallApple1Show:"true",imgInstallApple2:"",imgInstallApple2Show:"true",imgInstallApple3:"",imgInstallApple3Show:"true",imgInstallAndroid1:"",imgInstallAndroid1Show:"true",imgInstallAndroid2:"",imgInstallAndroid2Show:"true",imgInstallAndroid3:"",imgInstallAndroid3Show:"true"},W$=[{title:"Identity",description:"Core names used across the product.",fields:[{key:"brandName",label:"Brand name",type:"text"},{key:"productName",label:"Product name",type:"text"},{key:"legalCompanyName",label:"Legal company name",type:"text"},{key:"tagline",label:"Tagline",type:"text"}]},{title:"Contact",description:"Phone, hours and mailing address shown in the footer and elsewhere.",fields:[{key:"domain",label:"Primary domain",type:"text",help:"e.g. truvios.ai"},{key:"website",label:"Website URL",type:"url"},{key:"phone",label:"Phone (display)",type:"text"},{key:"phoneHref",label:"Phone (tel: link)",type:"text",help:"e.g. +18558788467"},{key:"businessHours",label:"Business hours",type:"text"},{key:"addressLine1",label:"Address line 1",type:"text"},{key:"addressLine2",label:"Address line 2",type:"text"}]},{title:"Email addresses",description:"Outbound and contact email addresses.",fields:[{key:"supportEmail",label:"Support email",type:"email"},{key:"salesEmail",label:"Sales email",type:"email"},{key:"billingEmail",label:"Billing email",type:"email"},{key:"infoEmail",label:"Info email",type:"email"},{key:"alertsEmail",label:"Alerts email",type:"email"},{key:"helpEmail",label:"Help email",type:"email"},{key:"noreplyEmail",label:"No-reply email",type:"email"}]},{title:"Logos & images",description:"Leave blank to use the built-in default image.",fields:[{key:"appEmblemUrl",label:"App emblem / logo",type:"image"},{key:"emailLogoUrl",label:"Email logo",type:"image"},{key:"faviconUrl",label:"Favicon",type:"image"},{key:"appleTouchIconUrl",label:"Apple touch icon",type:"image"},{key:"pwaIcon192Url",label:"PWA icon (192px)",type:"image"},{key:"pwaIcon512Url",label:"PWA icon (512px)",type:"image"},{key:"ogImageUrl",label:"Social share image",type:"image"}]},{title:"Edge quote — hardware images",description:"Server / chassis icons shown on the Edge quote and PDF. Leave blank to use the built-in default image.",fields:[{key:"imgChassisNuc",label:"Edge device (Intel NUC)",type:"image"},{key:"imgChassis2u",label:"2U rackmount chassis",type:"image"},{key:"imgChassis4u",label:"4U rackmount chassis",type:"image"}]},{title:"Theme",description:"Brand accent color (buttons, links, highlights) and theme color (the dark background tint used across the app).",fields:[{key:"brandColor",label:"Brand color",type:"color",help:"Accent color for buttons, links, focus rings and highlights."},{key:"themeColor",label:"Theme color",type:"color",help:"Backgroun
23d tint for the app's dark themes, plus the mobile browser bar color."},{key:"showDemetriMode",label:"Show Demetri Mode in user preferences",type:"toggle",help:'When off, the per-user purple "Demetri Mode" toggle is hidden from Preferences and disabled.'},{key:"extendTheme",label:"Extend theme",type:"toggle",help:"When on, blue accents that are hard-coded on the public marketing pages (labels, step numbers, highlights) are recolored to the brand color instead of staying blue."},{key:"emailUseBrandColors",label:"Use brand colors in emails",type:"toggle",help:"When on, outbound email templates are recolored to your palette — backgrounds, borders and neutral text follow the theme color; links, buttons and accents follow the brand color. Each color keeps its own lightness so emails stay readable, and status colors (online green, offline red, warning yellow) are left unchanged. Off by default."}]},{title:"Website content",description:"Show or hide marketing content sections on the public website.",fields:[{key:"showTestimonials",label:"Show testimonials",type:"toggle",help:'When off, the "Trusted By" logos and client quote sections are hidden on the homepage and all Solutions pages.'},{key:"landingFeaturePills",label:"Homepage feature boxes",type:"textarea",help:"The highlight boxes shown under the homepage hero. One box per line — add or remove lines to change how many boxes appear. Leave blank to use the defaults."}]},{title:"Homepage — Hero",description:"The top section of the homepage. Any text field left blank uses the default. The token {productName} is replaced with your product name.",fields:[{key:"landingShowHero",label:"Show hero section",type:"toggle"},{key:"landingHeroBadge",label:"Badge text",type:"text"},{key:"landingHeroHeading",label:"Headline",type:"text"},{key:"landingHeroHeadingHighlight",label:"Headline highlight",type:"text",help:"Shown after the headline in your brand color."},{key:"landingHeroSubheading",label:"Subheading",type:"textarea"},{key:"landingHeroCustomButtonEnabled",label:"Show custom button",type:"toggle",help:"Off by default. When enabled, appears to the left of Get Started Free."},{key:"landingHeroCustomButtonText",label:"Custom button text",type:"text"},{key:"landingHeroCustomButtonUrl",label:"Custom button URL",type:"url",help:"Required when enabled. Enter a complete http:// or https:// address; opens in a new tab."},{key:"landingHeroPrimaryButton",label:"Primary button text",type:"text"},{key:"landingHeroSecondaryButton",label:"Secondary button text",type:"text"},{key:"landingHeroSecondaryButtonUrl",label:"Learn More button link",type:"url",help:"Leave blank to open the Contact Us form (default). Enter a complete http:// or https:// address to open that link in a new tab."},{key:"landingHeroChatButton",label:"Chat button text",type:"text",help:"Shown only when the chat option is enabled."},{key:"landingHeroTrustPoints",label:"Trust points",type:"textarea",help:"Small icon points under the buttons. One per line."}]},{title:"Homepage — Trusted By & Testimonials",description:'The scrolling company names and client quotes. The overall visibility is also controlled by the "Show testimonials" toggle in Website content.',fields:[{key:"landingShowTrustedBy",label:'Show "Trusted By" strip',type:"toggle"},{key:"landingTrustedByHeading",label:"Trusted By heading",type:"text"},{key:"landingTrustedByNames",label:"Company names",type:"textarea",help:"One company per line."},{key:"landingShowTestimonials",label:"Show client quotes",type:"toggle"},{key:"landingTestimonialsHeading",label:"Testimonials heading",type:"text"},{key:"landingTestimonials",label:"Testimonials",type:"textarea",help:"One per line: Quote | Name | Role | Company"}]},{title:"Homepage — Feature Grid",description:'The "Everything You Need" cards.',fields:[{key:"landingShowFeatureGrid",label:"Show feature grid",type:"toggle"},{key:"landingFeaturesHeading",label:"Heading",type:"text"},{key:"landingFeaturesSubheading",label:"Subheading",type:"textarea"},{key:"landingFeatureCards",label:"Feature cards",type:"textarea",help:"One card per line: Title | Description"}]},{title:"Homepage — See It In Action",description:"The app screenshot showcase. Images are set under Home page images.",fields:[{key:"landingShowScreenshots",label:"Show screenshots section",type:"toggle"},{key:"landingScreenshotsHeading",label:"Heading",type:"text"},{key:"landingScreenshotsSubheading",label:"Subheading",type:"textarea"},{key:"landingScreenshotCaptions",label:"Screenshot captions",type:"textarea",help:"One per line, in order: Event Retrieval, AI Features, Notifications, Live View. Optionally add a short mobile label: Caption | Mobile label"}]},{title:"Homepage — AI-Powered Search",description:"The AI text search and visual search showcase.",fields:[{key:"landingShowAiSearch",label:"Show AI search section",type:"toggle"},{key:"landingAiSearchEyebrow",label:"Eyebrow label",type:"text"},{key:"landingAiSearchHeading",label:"Heading",type:"text"},{key:"landingAiSearchSubheading",label:"Subheading",type:"textarea"},{key:"landingAiSearchCards",label:"Cards",type:"textarea",help:"One per line: Title | Description"}]},{title:"Homepage — Faces & People",description:"The face recognition feature section.",fields:[{key:"landingShowFacesPeople",label:"Show Faces & People section",type:"toggle"},{key:"landingFacesHeading",label:"Heading",type:"text"},{key:"landingFacesParagraph",label:"Paragraph",type:"textarea"},{key:"landingFacesBullets",label:"Checklist bullets",type:"textarea",help:"One per line."},{key:"landingFacesButton",label:"Button text",type:"text"}]}
23,{title:"Homepage — Easy Setup",description:"The Edge device setup section with numbered steps.",fields:[{key:"landingShowEasySetup",label:"Show Easy Setup section",type:"toggle"},{key:"landingSetupEyebrow",label:"Eyebrow label",type:"text"},{key:"landingSetupHeading",label:"Heading",type:"text"},{key:"landingSetupParagraph",label:"Paragraph",type:"textarea"},{key:"landingSetupSteps",label:"Steps",type:"textarea",help:"One step per line: Title | Description. Numbered automatically."},{key:"landingSetupImageCaption",label:"Screenshot caption",type:"text",help:"Caption under the small overlapping screenshot."}]},{title:"Homepage — Cloud Storage",description:"The cloud storage value section.",fields:[{key:"landingShowCloudStorage",label:"Show Cloud Storage section",type:"toggle"},{key:"landingCloudEyebrow",label:"Eyebrow label",type:"text"},{key:"landingCloudHeading",label:"Heading",type:"text"},{key:"landingCloudParagraph",label:"Paragraph",type:"textarea"},{key:"landingCloudPoints",label:"Value rows",type:"textarea",help:"One per line: Title | Description"},{key:"landingCloudStats",label:"Stats",type:"textarea",help:"One per line: Value | Label"}]},{title:"Homepage — Deployment Options",description:"The plan comparison cards and Premium Smart Alerts explainer.",fields:[{key:"landingShowDeployment",label:"Show Deployment Options section",type:"toggle"},{key:"landingDeployEyebrow",label:"Eyebrow label",type:"text"},{key:"landingDeployHeading",label:"Heading",type:"text"},{key:"landingDeploySubheading",label:"Subheading",type:"textarea"},{key:"landingDeployPlan1",label:"Plan card 1",type:"textarea",help:"First line: Name | Tagline (add | Badge to highlight the card). Then one feature per line: start with + for included, - for not included, * for included and emphasized."},{key:"landingDeployPlan2",label:"Plan card 2",type:"textarea",help:"Same format as Plan card 1. Leave completely blank to use the default; a card is hidden if its first line has no name."},{key:"landingDeployPlan3",label:"Plan card 3",type:"textarea",help:"Same format as Plan card 1."},{key:"landingAlertsBadge",label:"Smart Alerts badge",type:"text"},{key:"landingAlertsHeading",label:"Smart Alerts heading",type:"text"},{key:"landingAlertsPara1",label:"Smart Alerts paragraph 1",type:"textarea",help:"Wrap text in **double asterisks** to make it bold."},{key:"landingAlertsPara2",label:"Smart Alerts paragraph 2",type:"textarea",help:"Wrap text in **double asterisks** to make it bold."},{key:"landingAlertsExamples",label:"Smart Alerts examples",type:"textarea",help:"One per line."}]},{title:"Homepage — Final Call To Action",description:"The closing sign-up section at the bottom of the homepage.",fields:[{key:"landingShowCta",label:"Show final call to action",type:"toggle"},{key:"landingCtaHeading",label:"Heading",type:"text"},{key:"landingCtaSubheading",label:"Subheading",type:"textarea"},{key:"landingCtaButton",label:"Button text",type:"text"}]},{title:"Live Demo",description:"Behavior of public Live Demo sessions (the banner text and live-view stream quality).",fields:[{key:"demoBannerMessage",label:"Demo banner message",type:"textarea",help:'Shown after "Live Demo —" in the banner at the top of the app during a demo session. The auto sign-out countdown and Exit button are appended automatically.'},{key:"demoAllowMainStream",label:"Allow main stream in Live Demo",type:"toggle",help:"When on, demo visitors can view the full-resolution main stream. When off (default), demo live view is locked to the lower-bandwidth sub stream."},{key:"demoFullJpegQuality",label:"Full snapshot quality in Live Demo",type:"toggle",help:"Controls the JPEG snapshot fallback used when the video stream can't connect. When off (default), demo sessions are capped at 1 snapshot per second at reduced quality. When on, demos use the device's configured snapshot rate and quality."}]},{title:"Legal",description:"Entity name and domain used in legal documents.",fields:[{key:"legalEntityName",label:"Legal entity name",type:"text"},{key:"legalDomain",label:"Legal domain",type:"text"}]}
23,{title:"Social links",description:"Optional social media profile links.",fields:[{key:"facebookUrl",label:"Facebook URL",type:"url"},{key:"instagramUrl",label:"Instagram URL",type:"url"},{key:"linkedinUrl",label:"LinkedIn URL",type:"url"},{key:"xUrl",label:"X / Twitter URL",type:"url"},{key:"youtubeUrl",label:"YouTube URL",type:"url"}]},{title:"External links",description:"Links to external product / status sites.",fields:[{key:"pricingUrl",label:"Pricing site URL",type:"url"},{key:"systemHealthUrl",label:"System health URL",type:"url"}]},{title:"App, SEO & PWA metadata",description:"Browser tab title, meta tags, and installable app names.",fields:[{key:"appTitle",label:"App / tab title",type:"text"},{key:"metaDescription",label:"Meta description",type:"textarea"},{key:"ogTitle",label:"Open Graph title",type:"text"},{key:"ogDescription",label:"Open Graph description",type:"textarea"},{key:"pwaName",label:"PWA name",type:"text"},{key:"pwaShortName",label:"PWA short name",type:"text"},{key:"pwaDescription",label:"PWA description",type:"text"}]},{title:"Navigation menu",description:"Show or hide items in the public website menu. Turning a whole group off (or hiding all of its items) removes the group button. This only hides menu links; the pages still work if visited directly.",fields:[{key:"navProducts",label:"Products menu",type:"toggle"},{key:"navProductsEdge",label:"Products — Edge",type:"toggle"},{key:"navProductsBlu",label:"Products — Blu Legacy",type:"toggle"},{key:"navPricing",label:"Pricing menu",type:"toggle"},{key:"navPricingEdge",label:"Pricing — Edge",type:"toggle"},{key:"navPricingBlu",label:"Pricing — Blu Legacy",type:"toggle"},{key:"navSolutions",label:"Solutions menu",type:"toggle"},{key:"navSolutionsHospitality",label:"Solutions — Hospitality",type:"toggle"},{key:"navSolutionsRetail",label:"Solutions — Retail",type:"toggle"},{key:"navSolutionsRestaurants",label:"Solutions — Restaurants & QSR",type:"toggle"},{key:"navSolutionsHealthcare",label:"Solutions — Healthcare",type:"toggle"},{key:"navSolutionsEducation",label:"Solutions — Education",type:"toggle"},{key:"navSolutionsGovernment",label:"Solutions — Government",type:"toggle"},{key:"navSolutionsCommercialRealEstate",label:"Solutions — Commercial Real Estate",type:"toggle"},{key:"navSolutionsCannabis",label:"Solutions — Cannabis",type:"toggle"},{key:"navSolutionsWeaponDetection",label:"Solutions — Weapon Detection",type:"toggle"},{key:"navSolutionsFacesPeople",label:"Solutions — Faces & People",type:"toggle"},{key:"navSolutionsNaturalTextSearch",label:"Solutions — Natural Text Search",type:"toggle"},{key:"navSolutionsObjectDetection",label:"Solutions — Object Detection",type:"toggle"},{key:"navSolutionsVisualComparisons",label:"Solutions — Visual Comparisons",type:"toggle"},{key:"navSolutionsSmartAiAlerts",label:"Solutions — Smart AI Alerts",type:"toggle"},{key:"navSolutionsCloudVideoSurveillance",label:"Solutions — Cloud Video Surveillance",type:"toggle"},{key:"navSolutionsDeviceNotifications",label:"Solutions — Device Notifications",type:"toggle"},{key:"navSolutionsPtzFisheye",label:"Solutions — PTZ & Fisheye Integration",type:"toggle"},{key:"navResources",label:"Resources menu",type:"toggle"},{key:"navResourcesWhitePaper",label:"Resources — White Paper",type:"toggle"},{key:"navResourcesSupportedDevices",label:"Resources — Supported Devices",type:"toggle"},{key:"navResourcesOemBranding",label:"Resources — OEM Branding",type:"toggle"},{key:"navResourcesBlog",label:"Resources — Blog",type:"toggle"},{key:"navResourcesEvents",label:"Resources — Events",type:"toggle"},{key:"navSupport",label:"Support menu",type:"toggle"},{key:"navSupportEdgeAppInstall",label:"Support — Edge App Install",type:"toggle"},{key:"navSupportBluDocumentation",label:"Support — Blu Documentation",type:"toggle"},{key:"navSupportSubmitTicket",label:"Support — Submit Ticket",type:"toggle"},{key:"navSupportDownloads",label:"Support — Downloads",type:"toggle"},{key:"navSupportSystemHealth",label:"Support — System Health",type:"toggle"},{key:"navContact",label:"Contact menu",type:"toggle"},{key:"navContactUs",label:"Contact — Contact Us",type:"toggle"},{key:"navContactChat",label:"Contact — Chat With Us",type:"toggle"},{key:"navContactRefer",label:"Contact — Refer",type:"toggle"}]},{title:"Onboarding email images",description:"The step-by-step instruction images inside the welcome / invite emails sent to new users. Leave a URL blank to use the built-in illustration.",fields:[{key:"imgOnboardingLogin",label:"How to log in",type:"image"},{key:"imgOnboardingPassword",label:"Change your password",type:"image"},{key:"imgOnboarding2fa",label:"Enable two-factor authentication",type:"image"},{key:"imgOnboardingLiveView",label:"Watch your cameras live",type:"image"},{key:"imgOnboardingEvents",label:"Find and replay events",type:"image"},{key:"imgOnboardingAddUser",label:"Add a new user (owners & admins)",type:"image"},{key:"imgOnboardingAddDevice",label:"Add a new device (admins)",type:"image"}]},{title:"Home page images",description:"Every image on the public home page. Leave a URL blank to use the built-in default; turn an image off to remove it from the page.",fields:[{key:"imgLandingHeroFirearm",label:"Hero — AI firearm search",type:"image",showKey:"imgLandingHeroFirearmShow"},{key:"imgLandingHeroPhone",label:"Hero — mobile dashboard",type:"image",showKey:"imgLandingHeroPhoneShow"},{key:"imgLandingEventRetrieval",label:"See It In Action — Event Retrieval",type:"image",showKey:"imgLandingEventRetrievalShow"},{key:"imgLandingAiFeatures",label:"See It In Action — AI Features",type:"image",showKey:"imgLandingAiFeaturesShow"},{key:"imgLandingNotifications",label:"See It In Action — Notifications",type:"image",showKey:"imgLandingNotificationsShow"},{key:"imgLandingLiveView",label:"See It In Action — Live View",type:"image",showKey:"imgLandingLiveViewShow"},{key:"imgLandingAiTextSearch",label:"AI Search — Text Search",type:"image",showKey:"imgLandingAiTextSearchShow"},{key:"imgLandingVisualSearch",label:"AI Search — Visual Search",type:"image",showKey:"imgLandingVisualSearchShow"},{key:"imgLandingEdgeDevice",label:"Easy Setup — Edge device",type:"image",showKey:"imgLandingEdgeDeviceShow"},{key:"imgLandingCameraDiscovery",label:"Easy Setup — Camera Discovery",type:"image",showKey:"imgLandingCameraDiscoveryShow"},{key:"imgLandingCloudStorage",label:"Cloud Storage screenshot",type:"image",showKey:"imgLandingCloudStorageShow"},{key:"imgLandingSmartAlert",label:"Premium Smart Alerts rule",type:"image",showKey:"imgLandingSmartAlertShow"},{key:"imgLandingFacesPeople",label:"Faces & People recognition",type:"image",showKey:"imgLandingFacesPeopleShow"}]},{title:"Blu Legacy page images",description:"Images on the Blu Legacy product page.",fields:[{key:"imgBluHero",label:"Hero — Blu software",type:"image",showKey:"imgBluHeroShow"},{key:"imgBluEmsDashboard",label:"EMS — Multi-Site Dashboard",type:"image",showKey:"imgBluEmsDashboardShow"}
23,{key:"imgBluEmsAiSearch",label:"EMS — AI-Powered Event Retrieval",type:"image",showKey:"imgBluEmsAiSearchShow"},{key:"imgBluEmsOnPremise",label:"EMS — AI Search",type:"image",showKey:"imgBluEmsOnPremiseShow"},{key:"imgBluEmsAiRetrieval",label:"EMS — Event Playback",type:"image",showKey:"imgBluEmsAiRetrievalShow"},{key:"imgBluEmsObjectDetect",label:"EMS — Object & Person Detection",type:"image",showKey:"imgBluEmsObjectDetectShow"},{key:"imgBluEmsLiveView",label:"EMS — Multi-Camera Live View",type:"image",showKey:"imgBluEmsLiveViewShow"}]},{title:"Weapon Detection page image",description:"Image on the Weapon Detection feature page.",fields:[{key:"imgWeaponHero",label:"Hero image",type:"image",showKey:"imgWeaponHeroShow"}]},{title:"Faces & People page images",description:"Images on the Faces & People feature page.",fields:[{key:"imgFacesHero",label:"Hero image",type:"image",showKey:"imgFacesHeroShow"},{key:"imgFacesSearch",label:"AI Search results",type:"image",showKey:"imgFacesSearchShow"}]},{title:"Smart AI Alerts page images",description:"Images on the Smart AI Alerts feature page.",fields:[{key:"imgAlertsInbox",label:"Alerts inbox",type:"image",showKey:"imgAlertsInboxShow"},{key:"imgAlertsMobile",label:"Mobile alerts",type:"image",showKey:"imgAlertsMobileShow"},{key:"imgAlertsRule",label:"Alert rule",type:"image",showKey:"imgAlertsRuleShow"}]},{title:"Visual Comparisons page images",description:"Images on the Visual Comparisons feature page.",fields:[{key:"imgVisualSearch",label:"Visual search interface",type:"image",showKey:"imgVisualSearchShow"},{key:"imgVisualMatch",label:"Match results",type:"image",showKey:"imgVisualMatchShow"}]},{title:"Cloud Video Surveillance page image",description:"Image on the Cloud Video Surveillance feature page.",fields:[{key:"imgCloudHero",label:"Hero image",type:"image",showKey:"imgCloudHeroShow"}]},{title:"Device Notifications page image",description:"Image on the Device Notifications feature page.",fields:[{key:"imgNotifHero",label:"Hero image",type:"image",showKey:"imgNotifHeroShow"}]},{title:"OEM Branding page image",description:"Image on the OEM Branding resources page.",fields:[{key:"imgOemHero",label:"Hero image",type:"image",showKey:"imgOemHeroShow"}]},{title:"Edge App Install page images",description:"Step-by-step screenshots on the Edge App Install support page.",fields:[{key:"imgInstallApple1",label:"iPhone — step 1",type:"image",showKey:"imgInstallApple1Show"},{key:"imgInstallApple2",label:"iPhone — step 2",type:"image",showKey:"imgInstallApple2Show"},{key:"imgInstallApple3",label:"iPhone — step 3",type:"image",showKey:"imgInstallApple3Show"},{key:"imgInstallAndroid1",label:"Android — step 1",type:"image",showKey:"imgInstallAndroid1Show"},{key:"imgInstallAndroid2",label:"Android — step 2",type:"image",showKey:"imgInstallAndroid2Show"},{key:"imgInstallAndroid3",label:"Android — step 3",type:"image",showKey:"imgInstallAndroid3Show"}]}],rY=u.createContext(Iy);function nY(){return ze({queryKey:["/api/branding"],placeholderData:Iy,staleTime:300*1e3})}function Er(){return u.useContext(rY)}function K5(e){if(!/^#[0-9a-fA-F]{6}$/.test(e))return null;const s=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,n=parseInt(e.slice(5,7),16)/255,a=Math.max(s,r,n),i=Math.min(s,r,n),o=(a+i)/2;let l=0,c=0;if(a!==i){const d=a-i;switch(c=o>.5?d/(2-a-i):d/(a+i),a){case s:l=(r-n)/d+(r<n?6:0);break;case r:l=(n-s)/d+2;break;default:l=(s-r)/d+4;break}l/=6}return{h:Math.round(l*360),s:Math.round(c*100),l:Math.round(o*100)}}function qhe(e){return`${e.h} ${e.s}% ${e.l}%`}const Vhe={"--background":4,"--card":7,"--popover":6,"--sidebar":3,"--secondary":12,"--muted":10,"--accent":12,"--border":12,"--card-border":10,"--sidebar-border":8,"--sidebar-accent":10,"
23--input":18},Whe={"--background":2,"--card":4,"--popover":3,"--sidebar":1,"--secondary":8,"--muted":6,"--accent":8,"--border":8,"--card-border":6,"--sidebar-border":5,"--sidebar-accent":6,"--input":12};function K$(e,s,r,n){const a=Object.entries(n).map(([i,o])=>`${i}:${s} ${r}% ${o}%;`).join("");return`${e}{${a}}`}const Khe={50:97,100:93,200:86,300:78,400:68,500:60,600:53,700:48,800:42,900:33,950:20},Ghe={text:"color",bg:"background-color",border:"border-color"},Yhe=[5,10,20,30,40,50,60,70,75,80,90];function Qhe(e){const s=K5(e);if(!s)return"";const{h:r,s:n}=s,a=[];for(const[i,o]of Object.entries(Ghe))for(const[l,c]of Object.entries(Khe)){a.push(`html.extend-theme .${i}-blue-${l}{${o}:hsl(${r} ${n}% ${c}%)!important}`);for(const d of Yhe)a.push(`html.extend-theme .${i}-blue-${l}\\/${d}{${o}:hsl(${r} ${n}% ${c}% / ${d/100})!important}`)}return a.join(`
24`)}function Xhe(e){const s=[];if(e.brandColor){const i=[`--brand:${e.brandColor};`],o=K5(e.brandColor);if(o){const l=qhe(o),c=Zhe(e.brandColor);for(const d of["--primary","--ring","--sidebar-primary","--sidebar-ring"])i.push(`${d}:${l};`);i.push(`--primary-foreground:${c};`,`--sidebar-primary-foreground:${c};`)}s.push(`html:root{${i.join("")}}`)}const r=K5(e.themeColor);r&&(s.push(K$("html.dark",r.h,r.s,Vhe)),s.push(K$("html.darker",r.h,r.s,Whe)));const n=e.extendTheme!=="false"&&!!e.brandColor;document.documentElement.classList.toggle("extend-theme",n),n&&s.push(Qhe(e.brandColor));let a=document.getElementById("oem-theme-vars");a||(a=document.createElement("style"),a.id="oem-theme-vars",document.head.appendChild(a)),a.textContent=s.join(`
25`)}function Zhe(e){if(!/^#[0-9a-fA-F]{6}$/.test(e))return"0 0% 100%";const s=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return .299*s+.587*r+.114*n>150?"215 25% 15%":"0 0% 100%"}function aP(e,s){if(!s)return;let r=document.querySelector(`meta[name="${e}"]`);r||(r=document.createElement("meta"),r.setAttribute("name",e),document.head.appendChild(r)),r.setAttribute("content",s)}function G5(e,s){s&&document.querySelectorAll(`link[rel="${e}"]`).forEach(r=>r.setAttribute("href",s))}function iP(e,s){if(!s)return;let r=document.querySelector(`meta[property="${e}"]`);r||(r=document.createElement("meta"),r.setAttribute("property",e),document.head.appendChild(r)),r.setAttribute("content",s)}let n1=null;function Jhe(e){try{const s={name:e.pwaName,short_name:e.pwaShortName,description:e.pwaDescription,start_url:"/",display:"standalone",background_color:e.themeColor,theme_color:e.themeColor,icons:[{src:e.pwaIcon192Url||"/icon-192.png",sizes:"192x192",type:"image/png"},{src:e.pwaIcon512Url||"/icon-512.png",sizes:"512x512",type:"image/png"},{src:e.appleTouchIconUrl||"/apple-touch-icon.png",sizes:"180x180",type:"image/png"}]},r=new Blob([JSON.stringify(s)],{type:"application/manifest+json"});n1&&URL.revokeObjectURL(n1),n1=URL.createObjectURL(r),G5("manifest",n1)}catch{}}function epe({children:e}){const{data:s}=nY(),r=s?{...Iy,...s}:Iy,[n]=Ia();return u.useEffect(()=>{document.documentElement.hasAttribute("data-page-head")||(r.appTitle&&(document.title=r.appTitle),aP("description",r.metaDescription),iP("og:title",r.ogTitle||r.appTitle),iP("og:description",r.ogDescription||r.metaDescription),iP("og:image",r.ogImageUrl))},[n,r.appTitle,r.metaDescription,r.ogTitle,r.ogDescription,r.ogImageUrl]),u.useEffect(()=>{Xhe(r),r.themeColor&&aP("theme-color",r.themeColor),aP("apple-mobile-web-app-title",r.brandName),G5("icon",r.faviconUrl),G5("apple-touch-icon",r.appleTouchIconUrl),Jhe(r)},[r.brandColor,r.themeColor,r.brandName,r.faviconUrl,r.appleTouchIconUrl,r.pwaName,r.pwaShortName,r.pwaDescription,r.pwaIcon192Url,r.pwaIcon512Url]),t.jsx(rY.Provider,{value:r,children:e})}Gd({enabled:nf(),userId:it().nullable()});const G$=300*1e3;function tpe(){const{user:e,logout:s}=Gi(),r=Er(),[,n]=Ia(),a=e,i=!!a?.isDemo,o=a?.demoStartedAt??null,[l,c]=u.useState(G$);if(u.useEffect(()=>{if(!i||!o)return;let g=!1;const v=()=>{const y=o+G$-Date.now();c(y),y<=0&&!g&&(g=!0,s(),n("/home"))};v();const b=setInterval(v,1e3);return()=>clearInterval(b)},[i,o,s,n]),!i)return null;const d=Math.max(0,Math.ceil(l/1e3)),h=Math.floor(d/60),p=String(d%60).padStart(2,"0");return t.jsx("div",{className:"w-full bg-amber-500 text-amber-950 dar
25k:bg-amber-600 dark:text-amber-50",style:{paddingTop:"env(safe-area-inset-top)",paddingLeft:"env(safe-area-inset-left)",paddingRight:"env(safe-area-inset-right)"},"data-testid":"banner-demo-session",children:t.jsxs("div",{className:"mx-auto max-w-7xl px-3 py-1.5 flex items-center justify-center gap-2 text-xs sm:text-sm text-center leading-snug",children:[t.jsx(Sy,{className:"h-4 w-4 shrink-0"}),t.jsxs("p",{className:"min-w-0",children:[t.jsx("span",{className:"font-semibold",children:"Live Demo"}),t.jsxs("span",{children:[" — ",r.demoBannerMessage]})," ","Auto sign-out in"," ",t.jsxs("span",{className:"font-semibold tabular-nums","data-testid":"text-demo-countdown",children:[h,":",p]}),"."]}),t.jsx("button",{type:"button",onClick:()=>{s(),n("/home")},className:"shrink-0 underline underline-offset-2 font-medium hover:opacity-80","data-testid":"button-demo-exit",children:"Exit"})]})})}function spe(){const{user:e}=Gi(),[s,r]=u.useState(!1),n=e?.viewAs;if(!n?.active)return null;const a=async()=>{r(!0);try{await Ze("POST","/api/view-as/exit")}catch{}window.location.href="/"};return t.jsx("div",{className:"w-full bg-indigo-600 text-indigo-50 dark:bg-indigo-700",style:{paddingTop:"env(safe-area-inset-top)",paddingLeft:"env(safe-area-inset-left)",paddingRight:"env(safe-area-inset-right)"},"data-testid":"banner-view-as",children:t.jsxs("div",{className:"mx-auto max-w-7xl px-3 py-1.5 flex items-center justify-center gap-2 text-xs sm:text-sm text-center leading-snug",children:[t.jsx(Xr,{className:"h-4 w-4 shrink-0"}),t.jsxs("p",{className:"min-w-0",children:[t.jsx("span",{className:"font-semibold",children:"Viewing as"})," ",t.jsx("span",{className:"font-semibold","data-testid":"text-view-as-name",children:n.emulatedName||"another user"}),t.jsx("span",{children:" — read-only preview of their dashboard."})]}),t.jsxs("button",{type:"button",onClick:a,disabled:s,className:"shrink-0 inline-flex items-center gap-1 underline underline-offset-2 font-medium hover:opacity-80 disabled:opacity-60","data-testid":"button-view-as-exit",children:[s&&t.jsx(Fe,{className:"h-3.5 w-3.5 animate-spin"}),"Exit"]})]})})}const H0=Hj("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover-elevate active-elevate-2",{variants:{variant:{default:"bg-primary text-primary-foreground border border-primary-border",destructive:"bg-destructive text-destructive-foreground border border-destructive-border",outline:" border [border-color:var(--button-outline)]  shadow-xs active:shadow-none ",secondary:"border bg-secondary text-secondary-foreground border border-secondary-border ",ghost:"border border-transparent"},size:{default:"min-h-9 px-4 py-2",sm:"min-h-8 rounded-md px-3 text-xs",lg:"min-h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),L=u.forwardRef(({className:e,variant:s,size:r,asChild:n=!1,...a},i)=>{const o=n?WW:"button";return t.jsx(o,{className:Cs(H0({variant:s,size:r,className:e})),ref:i,...a})});L.displayName="Button";function rpe(){const s=Er().landingFeaturePills.split(`
26`).map(r=>r.trim()).filter(Boolean);return s.length===0?null:t.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4 w-full max-w-5xl",children:s.map((r,n)=>t.jsx("div",{className:"rounded-xl bg-primary/10 border border-primary/20 px-4 py-4 text-center text-sm font-medium text-foreground hover:bg-primary/15 hover:border-primary/30 transition-colors","data-testid":`card-feature-pill-${n}`,children:r},n))})}const ut=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Cs("shadcn-card rounded-xl border bg-card border-card-border text-card-foreground shadow-sm",e),...s}));ut.displayName="Card";const xs=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Cs("flex flex-col space-y-1.5 p-6",e),...s}));xs.displayName="CardHeader";const ys=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Cs("text-2xl font-semibold leading-none tracking-tight",e),...s}));
vendor: 5,679 bytes, line 26
26ys.displayName="CardTitle";const Xs=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Cs("text-sm text-muted-foreground",e),...s}));Xs.displayName="CardDescription";const mt=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Cs("p-6 pt-0",e),...s}));mt.displayName="CardContent";const npe=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Cs("flex items-center p-6 pt-0",e),...s}));npe.displayName="CardFooter";const ke=u.forwardRef(({className:e,type:s,...r},n)=>t.jsx("input",{type:s,className:Cs("flex h-9 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:n,...r}));ke.displayName="Input";var ape="Label",aY=u.forwardRef((e,s)=>t.jsx(Cr.label,{...e,ref:s,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));aY.displayName=ape;var iY=aY;const ipe=Hj("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),re=u.forwardRef(({className:e,...s},r)=>t.jsx(iY,{ref:r,className:Cs(ipe(),e),...s}));re.displayName=iY.displayName;function Y$(e,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e?.(a),r===!1||!a.defaultPrevented)return s?.(a)}}var ope=bb[" useInsertionEffect ".trim().toString()]||da;function lpe({prop:e,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,i,o]=cpe({defaultProp:s,onChange:r}),l=e!==void 0,c=l?e:a;{const h=u.useRef(e!==void 0);u.useEffect(()=>{const p=h.current;p!==l&&console.warn(`${n} is changing from ${p?"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.`),h.current=l},[l,n])}const d=u.useCallback(h=>{if(l){const p=dpe(h)?h(e):h;p!==e&&o.current?.(p)}else i(h)},[l,e,i,o]);return[c,d]}function cpe({defaultProp:e,onChange:s}){const[r,n]=u.useState(e),a=u.useRef(r),i=u.useRef(s);return ope(()=>{i.current=s},[s]),u.useEffect(()=>{a.current!==r&&(i.current?.(r),a.current=r)},[r,a]),[r,n,i]}function dpe(e){return typeof e=="function"}function Gj(e){const s=u.useRef({value:e,previous:e});return u.useMemo(()=>(s.current.value!==e&&(s.current.previous=s.current.value,s.current.value=e),s.current.previous),[e])}function upe(e,s){return u.useReducer((r,n)=>s[r][n]??r,e)}var oY=e=>{const{present:s,children:r}=e,n=mpe(s),a=typeof r=="function"?r({present:n.isPresent}):u.Children.only(r),i=mr(n.ref,hpe(a));return typeof r=="function"||n.isPresent?u.cloneElement(a,{ref:i}):null};oY.displayName="Presence";function mpe(e){const[s,r]=u.useState(),n=u.useRef(null),a=u.useRef(e),i=u.useRef("none"),o=e?"mounted":"unmounted",[l,c]=upe(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=a1(n.current);i.current=l==="mounted"?d:"none"},[l]),da(()=>{const d=n.current,h=a.current;if(h!==e){const g=i.current,v=a1(d);e?c("MOUNT"):v==="none"||d?.display==="none"?c("UNMOUNT"):c(h&&g!==v?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),da(()=>{if(s){let d;const h=s.ownerDocument.defaultView??window,p=v=>{const y=a1(n.current).includes(CSS.escape(v.animationName));if(v.target===s&&y&&(c("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",d=h.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},g=v=>{v.target===s&&(i.current=a1(n.current))};return s.addEventListener("animationstart",g),s.addEventListener("animationcancel",p),s.addEventListener("animationend",p),()=>{h.clearTimeout(d),s.removeEventListener("animationstart",g),s.removeEventListener("animationcancel",p),s.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{n.current=d?getComputedStyle(d):null,r(d)},[])}}function a1(e){return e?.animationName||"none"}function hpe(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function ppe(e){const s=fpe(e),r=u.forwardRef((n,a)=>{const{children:i,...o}=n,l=u.Children.toArray(i),c=l.find(xpe);if(c){const d=c.props.children,h=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return t.jsx(s,{...o,ref:a,children:u.isValidElement(d)?u.cloneElement(d,void 0,h):null})}return t.jsx(s,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function fpe(e){const s=u.forwardRef((r,n)=>{const{children:a,...i}=r;if(u.isValidElement(a)){const o=ype(a),l=vpe(i,a.props);return a.type!==u.Fragment&&(l.ref=n?jf(n,o):o),u.cloneElement(a,l)}return u.Children.count(a)>1?u.Children.only(null):null});return s.displayName=`${e}.SlotClone`,s}var gpe=Symbol("radix.slottable");function xpe(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===gpe}function vpe(e,s){const r={...s};for(const n in s){const a=e[n],i=s[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}
vendor: 7,326 bytes, line 26
26:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function ype(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var bpe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],EO=bpe.reduce((e,s)=>{const r=ppe(`Primitive.${s}`),n=u.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(c,{...l,ref:i})});return n.displayName=`Primitive.${s}`,{...e,[s]:n}},{}),Vk="Checkbox",[wpe]=oo(Vk),[jpe,TO]=wpe(Vk);function Npe(e){const{__scopeCheckbox:s,checked:r,children:n,defaultChecked:a,disabled:i,form:o,name:l,onCheckedChange:c,required:d,value:h="on",internal_do_not_use_render:p}=e,[g,v]=lpe({prop:r,defaultProp:a??!1,onChange:c,caller:Vk}),[b,y]=u.useState(null),[w,j]=u.useState(null),x=u.useRef(!1),C=b?!!o||!!b.closest("form"):!0,k={checked:g,disabled:i,setChecked:v,control:b,setControl:y,name:l,form:o,value:h,hasConsumerStoppedPropagationRef:x,required:d,defaultChecked:bg(a)?!1:a,isFormControl:C,bubbleInput:w,setBubbleInput:j};return t.jsx(jpe,{scope:s,...k,children:Spe(p)?p(k):n})}var lY="CheckboxTrigger",cY=u.forwardRef(({__scopeCheckbox:e,onKeyDown:s,onClick:r,...n},a)=>{const{control:i,value:o,disabled:l,checked:c,required:d,setControl:h,setChecked:p,hasConsumerStoppedPropagationRef:g,isFormControl:v,bubbleInput:b}=TO(lY,e),y=mr(a,h),w=u.useRef(c);return u.useEffect(()=>{const j=i?.form;if(j){const x=()=>p(w.current);return j.addEventListener("reset",x),()=>j.removeEventListener("reset",x)}},[i,p]),t.jsx(EO.button,{type:"button",role:"checkbox","aria-checked":bg(c)?"mixed":c,"aria-required":d,"data-state":pY(c),"data-disabled":l?"":void 0,disabled:l,value:o,...n,ref:y,onKeyDown:Y$(s,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Y$(r,j=>{p(x=>bg(x)?!0:!x),b&&v&&(g.current=j.isPropagationStopped(),g.current||j.stopPropagation())})})});cY.displayName=lY;var AO=u.forwardRef((e,s)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:i,required:o,disabled:l,value:c,onCheckedChange:d,form:h,...p}=e;return t.jsx(Npe,{__scopeCheckbox:r,checked:a,defaultChecked:i,disabled:l,required:o,onCheckedChange:d,name:n,form:h,value:c,internal_do_not_use_render:({isFormControl:g})=>t.jsxs(t.Fragment,{children:[t.jsx(cY,{...p,ref:s,__scopeCheckbox:r}),g&&t.jsx(hY,{__scopeCheckbox:r})]})})});AO.displayName=Vk;var dY="CheckboxIndicator",uY=u.forwardRef((e,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=e,i=TO(dY,r);return t.jsx(oY,{present:n||bg(i.checked)||i.checked===!0,children:t.jsx(EO.span,{"data-state":pY(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...e.style}})})});uY.displayName=dY;var mY="CheckboxBubbleInput",hY=u.forwardRef(({__scopeCheckbox:e,...s},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:o,required:l,disabled:c,name:d,value:h,form:p,bubbleInput:g,setBubbleInput:v}=TO(mY,e),b=mr(r,v),y=Gj(i),w=_b(n);u.useEffect(()=>{const x=g;if(!x)return;const C=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(C,"checked").set,_=!a.current;if(y!==i&&S){const A=new Event("click",{bubbles:_});x.indeterminate=bg(i),S.call(x,bg(i)?!1:i),x.dispatchEvent(A)}},[g,y,i,a]);const j=u.useRef(bg(i)?!1:i);return t.jsx(EO.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??j.current,required:l,disabled:c,name:d,value:h,form:p,...s,tabIndex:-1,ref:b,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});hY.displayName=mY;function Spe(e){return typeof e=="function"}function bg(e){return e==="indeterminate"}function pY(e){return bg(e)?"indeterminate":e?"checked":"unchecked"}const On=u.forwardRef(({className:e,...s},r)=>t.jsx(AO,{ref:r,className:Cs("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...s,children:t.jsx(uY,{className:Cs("flex items-center justify-center text-current"),children:t.jsx(Hd,{className:"h-4 w-4"})})}));On.displayName=AO.displayName;const Nn=u.forwardRef(({className:e,...s},r)=>t.jsx("textarea",{className:Cs("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-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 md:text-sm",e),ref:r,...s}));Nn.displayName="Textarea";var oP="focusScope.autoFocusOnMount",lP="focusScope.autoFocusOnUnmount",Q$={bubbles:!1,cancelable:!0},Cpe="FocusScope",Wk=u.forwardRef((e,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=e,[l,c]=u.useState(null),d=Za(a),h=Za(i),p=u.useRef(null),g=mr(s,y=>c(y)),v=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(n){let y=function(C){if(v.paused||!l)return;const k=C.target;l.contains(k)?p.current=k:tg(p.current,{select:!0})},w=function(C){if(v.paused||!l)return;const k=C.relatedTarget;k!==null&&(l.contains(k)||tg(p.current,{select:!0}))},j=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&tg(l)};document.addEventListener("focusin",y),document.addEventListener("focusout",w);const x=new MutationObserver(j);return l&&x.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",w),x.disconnect()}}},[n,l,v.paused]),u.useEffect(()=>{if(l){Z$.add(v);const y=document.activeElement;if(!l.contains(y)){const j=new CustomEvent(oP,Q$);l.addEventListener(oP,d),l.dispatchEvent(j),j.defaultPrevented||(kpe(Ape(fY(l)),{select:!0}),document.activeElement===y&&tg(l))}return()=>{l.removeEventListener(oP,d),setTimeout(()=>{const j=new CustomEvent(lP,Q$);l.addEventListener(lP,h),l.dispatchEvent(j),j.defaultPrevented||tg(y??document.body,{select:!0}),l.removeEventListener(lP,h),Z$.remove(v)},0)}}},[l,d,h,v]);const b=u.useCallback(y=>{if(!r&&!n||v.paused)return;const w=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,j=document.activeElement;if(w&&j){const x=y.currentTarget,[C,k]=_pe(x);C&&k?!y.shiftKey&&j===k?(y.preventDefault(),r&&tg(C,{select:!0})):y.shiftKey&&j===C&&(y.preventDefault(),r&&tg(k,{select:!0})):j===x&&y.preventDefault()}},[r,n,v.paused]);return t.jsx(Cr.div,{tabIndex:-1,...o,ref:g,onKeyDown:b})});Wk.displayName=Cpe;function kpe(e,{select:s=!1}={}){const r=document.activeElement;for(const n of e)if(tg(n,{select:s}),document.activeElement!==r)return}function _pe(e){const s=fY(e),r=X$(s,e),n=X$(s.reverse(),e);return[r,n]}function fY(e){const s=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}
vendor: 6,877 bytes, lines 26-41
26function X$(e,s){for(const r of e)if(!Ppe(r,{upTo:s}))return r}function Ppe(e,{upTo:s}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(s!==void 0&&e===s)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Epe(e){return e instanceof HTMLInputElement&&"select"in e}function tg(e,{select:s=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Epe(e)&&s&&e.select()}}var Z$=Tpe();function Tpe(){let e=[];return{add(s){const r=e[0];s!==r&&r?.pause(),e=J$(e,s),e.unshift(s)},remove(s){e=J$(e,s),e[0]?.resume()}}}function J$(e,s){const r=[...e],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function Ape(e){return e.filter(s=>s.tagName!=="A")}var cP=0;function MO(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??e6()),document.body.insertAdjacentElement("beforeend",e[1]??e6()),cP++,()=>{cP===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),cP--}},[])}function e6(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Kh=function(){return Kh=Object.assign||function(s){for(var r,n=1,a=arguments.length;n<a;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(s[i]=r[i])}return s},Kh.apply(this,arguments)};function gY(e,s){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&s.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)s.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r}function Mpe(e,s,r){if(r||arguments.length===2)for(var n=0,a=s.length,i;n<a;n++)(i||!(n in s))&&(i||(i=Array.prototype.slice.call(s,0,n)),i[n]=s[n]);return e.concat(i||Array.prototype.slice.call(s))}var oS="right-scroll-bar-position",lS="width-before-scroll-bar",Rpe="with-scroll-bars-hidden",Ipe="--removed-body-scroll-bar-size";function dP(e,s){return typeof e=="function"?e(s):e&&(e.current=s),e}function Ope(e,s){var r=u.useState(function(){return{value:e,callback:s,facade:{get current(){return r.value},set current(n){var a=r.value;a!==n&&(r.value=n,r.callback(n,a))}}}})[0];return r.callback=s,r.facade}var Dpe=typeof window<"u"?u.useLayoutEffect:u.useEffect,t6=new WeakMap;function Lpe(e,s){var r=Ope(null,function(n){return e.forEach(function(a){return dP(a,n)})});return Dpe(function(){var n=t6.get(r);if(n){var a=new Set(n),i=new Set(e),o=r.current;a.forEach(function(l){i.has(l)||dP(l,null)}),i.forEach(function(l){a.has(l)||dP(l,o)})}t6.set(r,e)},[e]),r}function $pe(e){return e}function Fpe(e,s){s===void 0&&(s=$pe);var r=[],n=!1,a={read:function(){if(n)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=s(i,n);return r.push(o),function(){r=r.filter(function(l){return l!==o})}},assignSyncMedium:function(i){for(n=!0;r.length;){var o=r;r=[],o.forEach(i)}r={push:function(l){return i(l)},filter:function(){return r}}},assignMedium:function(i){n=!0;var o=[];if(r.length){var l=r;r=[],l.forEach(i),o=r}var c=function(){var h=o;o=[],h.forEach(i)},d=function(){return Promise.resolve().then(c)};d(),r={push:function(h){o.push(h),d()},filter:function(h){return o=o.filter(h),r}}}};return a}function Bpe(e){e===void 0&&(e={});var s=Fpe(null);return s.options=Kh({async:!0,ssr:!1},e),s}var xY=function(e){var s=e.sideCar,r=gY(e,["sideCar"]);if(!s)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=s.read();if(!n)throw new Error("Sidecar medium not found");return u.createElement(n,Kh({},r))};xY.isSideCarExport=!0;function Upe(e,s){return e.useMedium(s),xY}var vY=Bpe(),uP=function(){},Kk=u.forwardRef(function(e,s){var r=u.useRef(null),n=u.useState({onScrollCapture:uP,onWheelCapture:uP,onTouchMoveCapture:uP}),a=n[0],i=n[1],o=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,h=e.enabled,p=e.shards,g=e.sideCar,v=e.noIsolation,b=e.inert,y=e.allowPinchZoom,w=e.as,j=w===void 0?"div":w,x=e.gapMode,C=gY(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=g,S=Lpe([r,s]),_=Kh(Kh({},C),a);return u.createElement(u.Fragment,null,h&&u.createElement(k,{sideCar:vY,removeScrollBar:d,shards:p,noIsolation:v,inert:b,setCallbacks:i,allowPinchZoom:!!y,lockRef:r,gapMode:x}),o?u.cloneElement(u.Children.only(l),Kh(Kh({},_),{ref:S})):u.createElement(j,Kh({},_,{className:c,ref:S}),l))});Kk.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Kk.classNames={fullWidth:lS,zeroRight:oS};var zpe=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Hpe(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var s=zpe();return s&&e.setAttribute("nonce",s),e}function qpe(e,s){e.styleSheet?e.styleSheet.cssText=s:e.appendChild(document.createTextNode(s))}function Vpe(e){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(e)}var Wpe=function(){var e=0,s=null;return{add:function(r){e==0&&(s=Hpe())&&(qpe(s,r),Vpe(s)),e++},remove:function(){e--,!e&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},Kpe=function(){var e=Wpe();return function(s,r){u.useEffect(function(){return e.add(s),function(){e.remove()}},[s&&r])}},yY=function(){var e=Kpe(),s=function(r){var n=r.styles,a=r.dynamic;return e(n,a),null};return s},Gpe={left:0,top:0,right:0,gap:0},mP=function(e){return parseInt(e||"",10)||0},Ype=function(e){var s=window.getComputedStyle(document.body),r=s[e==="padding"?"paddingLeft":"marginLeft"],n=s[e==="padding"?"paddingTop":"marginTop"],a=s[e==="padding"?"paddingRight":"marginRight"];return[mP(r),mP(n),mP(a)]},Qpe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Gpe;var s=Ype(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:s[0],top:s[1],right:s[2],gap:Math.max(0,n-r+s[2]-s[0])}},Xpe=yY(),ly="data-scroll-locked",Zpe=function(e,s,r,n){var a=e.left,i=e.top,o=e.right,l=e.gap;return r===void 0&&(r="margin"),`
27  .`.concat(Rpe,` {
28   overflow: hidden `).concat(n,`;
29   padding-right: `).concat(l,"px ").concat(n,`;
30  }
31  body[`).concat(ly,`] {
32    overflow: hidden `).concat(n,`;
33    overscroll-behavior: contain;
34    `).concat([s&&"position: relative ".concat(n,";"),r==="margin"&&`
35    padding-left: `.concat(a,`px;
36    padding-top: `).concat(i,`px;
37    padding-right: `).concat(o,`px;
38    margin-left:0;
39    margin-top:0;
40    margin-right: `).concat(l,"px ").concat(n,`;
41    `),r==="padding"&&"padding-right: ".concat(l,"px ").concat(n,";
41")].filter(Boolean).join(""),`
42  }
43  
44  .`).concat(oS,` {
45    right: `).concat(l,"px ").concat(n,`;
46  }
47  
48  .`).concat(lS,` {
49    margin-right: `).concat(l,"px ").concat(n,`;
50  }
51  
52  .`).concat(oS," .").concat(oS,` {
53    right: 0 `).concat(n,`;
54  }
55  
56  .`).concat(lS," .").concat(lS,` {
57    margin-right: 0 `).concat(n,`;
58  }
59  
60  body[`).concat(ly,`] {
61    `).concat(Ipe,": ").concat(l,`px;
62  }
63`)},s6=function(){var e=parseInt(document.body.getAttribute(ly)||"0",10);return isFinite(e)?e:0},Jpe=function(){u.useEffect(function(){return document.body.setAttribute(ly,(s6()+1).toString()),function(){var e=s6()-1;e<=0?document.body.removeAttribute(ly):document.body.setAttribute(ly,e.toString())}},[])},efe=function(e){var s=e.noRelative,r=e.noImportant,n=e.gapMode,a=n===void 0?"margin":n;Jpe();var i=u.useMemo(function(){return Qpe(a)},[a]);return u.createElement(Xpe,{styles:Zpe(i,!s,a,r?"":"!important")})},Y5=!1;if(typeof window<"u")try{var i1=Object.defineProperty({},"passive",{get:function(){return Y5=!0,!0}});window.addEventListener("test",i1,i1),window.removeEventListener("test",i1,i1)}catch{Y5=!1}var Pv=Y5?{passive:!1}:!1,tfe=function(e){return e.tagName==="TEXTAREA"},bY=function(e,s){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!tfe(e)&&r[s]==="visible")},sfe=function(e){return bY(e,"overflowY")},rfe=function(e){return bY(e,"overflowX")},r6=function(e,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=wY(e,n);if(a){var i=jY(e,n),o=i[1],l=i[2];if(o>l)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},nfe=function(e){var s=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[s,r,n]},afe=function(e){var s=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[s,r,n]},wY=function(e,s){return e==="v"?sfe(s):rfe(s)},jY=function(e,s){return e==="v"?nfe(s):afe(s)},ife=function(e,s){return e==="h"&&s==="rtl"?-1:1},ofe=function(e,s,r,n,a){var i=ife(e,window.getComputedStyle(s).direction),o=i*n,l=r.target,c=s.contains(l),d=!1,h=o>0,p=0,g=0;do{var v=jY(e,l),b=v[0],y=v[1],w=v[2],j=y-w-i*b;(b||j)&&wY(e,l)&&(p+=j,g+=b),l instanceof ShadowRoot?l=l.host:l=l.parentNode}while(!c&&l!==document.body||c&&(s.contains(l)||s===l));return(h&&Math.abs(p)<1||!h&&Math.abs(g)<1)&&(d=!0),d},o1=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},n6=function(e){return[e.deltaX,e.deltaY]},a6=function(e){return e&&"current"in e?e.current:e},lfe=function(e,s){return e[0]===s[0]&&e[1]===s[1]},cfe=function(e){return`
64  .block-interactivity-`.concat(e,` {pointer-events: none;}
65  .allow-interactivity-`).concat(e,` {pointer-events: all;}
66`)},dfe=0,Ev=[];function ufe(e){var s=u.useRef([]),r=u.useRef([0,0]),n=u.useRef(),a=u.useState(dfe++)[0],i=u.useState(yY)[0],o=u.useRef(e);u.useEffect(function(){o.current=e},[e]),u.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var y=Mpe([e.lockRef.current],(e.shards||[]).map(a6),!0).filter(Boolean);return y.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),y.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=u.useCallback(function(y,w){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!o.current.allowPinchZoom;var j=o1(y),x=r.current,C="deltaX"in y?y.deltaX:x[0]-j[0],k="deltaY"in y?y.deltaY:x[1]-j[1],S,_=y.target,A=Math.abs(C)>Math.abs(k)?"h":"v";if("touches"in y&&A==="h"&&_.type==="range")return!1;var T=r6(A,_);if(!T)return!0;if(T?S=A:(S=A==="v"?"h":"v",T=r6(A,_)),!T)return!1;if(!n.current&&"changedTouches"in y&&(C||k)&&(n.current=S),!S)return!0;var M=n.current||S;return ofe(M,w,y,M==="h"?C:k)},[]),c=u.useCallback(function(y){var w=y;if(!(!Ev.length||Ev[Ev.length-1]!==i)){var j="deltaY"in w?n6(w):o1(w),x=s.current.filter(function(S){return S.name===w.type&&(S.target===w.target||w.target===S.shadowParent)&&lfe(S.delta,j)})[0];if(x&&x.should){w.cancelable&&w.preventDefault();return}
vendor: 4,464 bytes, line 66
66if(!x){var C=(o.current.shards||[]).map(a6).filter(Boolean).filter(function(S){return S.contains(w.target)}),k=C.length>0?l(w,C[0]):!o.current.noIsolation;k&&w.cancelable&&w.preventDefault()}}},[]),d=u.useCallback(function(y,w,j,x){var C={name:y,delta:w,target:j,should:x,shadowParent:mfe(j)};s.current.push(C),setTimeout(function(){s.current=s.current.filter(function(k){return k!==C})},1)},[]),h=u.useCallback(function(y){r.current=o1(y),n.current=void 0},[]),p=u.useCallback(function(y){d(y.type,n6(y),y.target,l(y,e.lockRef.current))},[]),g=u.useCallback(function(y){d(y.type,o1(y),y.target,l(y,e.lockRef.current))},[]);u.useEffect(function(){return Ev.push(i),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:g}),document.addEventListener("wheel",c,Pv),document.addEventListener("touchmove",c,Pv),document.addEventListener("touchstart",h,Pv),function(){Ev=Ev.filter(function(y){return y!==i}),document.removeEventListener("wheel",c,Pv),document.removeEventListener("touchmove",c,Pv),document.removeEventListener("touchstart",h,Pv)}},[]);var v=e.removeScrollBar,b=e.inert;return u.createElement(u.Fragment,null,b?u.createElement(i,{styles:cfe(a)}):null,v?u.createElement(efe,{gapMode:e.gapMode}):null)}function mfe(e){for(var s=null;e!==null;)e instanceof ShadowRoot&&(s=e.host,e=e.host),e=e.parentNode;return s}const hfe=Upe(vY,ufe);var Yj=u.forwardRef(function(e,s){return u.createElement(Kk,Kh({},e,{ref:s,sideCar:hfe}))});Yj.classNames=Kk.classNames;var pfe=function(e){if(typeof document>"u")return null;var s=Array.isArray(e)?e[0]:e;return s.ownerDocument.body},Tv=new WeakMap,l1=new WeakMap,c1={},hP=0,NY=function(e){return e&&(e.host||NY(e.parentNode))},ffe=function(e,s){return s.map(function(r){if(e.contains(r))return r;var n=NY(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},gfe=function(e,s,r,n){var a=ffe(s,Array.isArray(e)?e:[e]);c1[r]||(c1[r]=new WeakMap);var i=c1[r],o=[],l=new Set,c=new Set(a),d=function(p){!p||l.has(p)||(l.add(p),d(p.parentNode))};a.forEach(d);var h=function(p){!p||c.has(p)||Array.prototype.forEach.call(p.children,function(g){if(l.has(g))h(g);else try{var v=g.getAttribute(n),b=v!==null&&v!=="false",y=(Tv.get(g)||0)+1,w=(i.get(g)||0)+1;Tv.set(g,y),i.set(g,w),o.push(g),y===1&&b&&l1.set(g,!0),w===1&&g.setAttribute(r,"true"),b||g.setAttribute(n,"true")}catch(j){console.error("aria-hidden: cannot operate on ",g,j)}})};return h(s),l.clear(),hP++,function(){o.forEach(function(p){var g=Tv.get(p)-1,v=i.get(p)-1;Tv.set(p,g),i.set(p,v),g||(l1.has(p)||p.removeAttribute(n),l1.delete(p)),v||p.removeAttribute(r)}),hP--,hP||(Tv=new WeakMap,Tv=new WeakMap,l1=new WeakMap,c1={})}},Gk=function(e,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),a=pfe(e);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),gfe(n,a,r,"aria-hidden")):function(){return null}},RO="Dialog",[SY,CY]=oo(RO),[xfe,Eh]=SY(RO),kY=e=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:o=!0}=e,l=u.useRef(null),c=u.useRef(null),[d=!1,h]=ip({prop:n,defaultProp:a,onChange:i});return t.jsx(xfe,{scope:s,triggerRef:l,contentRef:c,contentId:wu(),titleId:wu(),descriptionId:wu(),open:d,onOpenChange:h,onOpenToggle:u.useCallback(()=>h(p=>!p),[h]),modal:o,children:r})};kY.displayName=RO;var _Y="DialogTrigger",PY=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=Eh(_Y,r),i=mr(s,a.triggerRef);return t.jsx(Cr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":DO(a.open),...n,ref:i,onClick:Ms(e.onClick,a.onOpenToggle)})});PY.displayName=_Y;var IO="DialogPortal",[vfe,EY]=SY(IO,{forceMount:void 0}),TY=e=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=e,i=Eh(IO,s);return t.jsx(vfe,{scope:s,forceMount:r,children:u.Children.map(n,o=>t.jsx($m,{present:r||i.open,children:t.jsx(Uj,{asChild:!0,container:a,children:o})}))})};TY.displayName=IO;var zS="DialogOverlay",AY=u.forwardRef((e,s)=>{const r=EY(zS,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,i=Eh(zS,e.__scopeDialog);return i.modal?t.jsx($m,{present:n||i.open,children:t.jsx(bfe,{...a,ref:s})}):null});AY.displayName=zS;var yfe=zx("DialogOverlay.RemoveScroll"),bfe=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=Eh(zS,r);return t.jsx(Yj,{as:yfe,allowPinchZoom:!0,shards:[a.contentRef],children:t.jsx(Cr.div,{"data-state":DO(
vendor: 4,403 bytes, lines 66-70
66a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),Xx="DialogContent",MY=u.forwardRef((e,s)=>{const r=EY(Xx,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,i=Eh(Xx,e.__scopeDialog);return t.jsx($m,{present:n||i.open,children:i.modal?t.jsx(wfe,{...a,ref:s}):t.jsx(jfe,{...a,ref:s})})});MY.displayName=Xx;var wfe=u.forwardRef((e,s)=>{const r=Eh(Xx,e.__scopeDialog),n=u.useRef(null),a=mr(s,r.contentRef,n);return u.useEffect(()=>{const i=n.current;if(i)return Gk(i)},[]),t.jsx(RY,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ms(e.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Ms(e.onPointerDownOutside,i=>{const o=i.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&i.preventDefault()}),onFocusOutside:Ms(e.onFocusOutside,i=>i.preventDefault())})}),jfe=u.forwardRef((e,s)=>{const r=Eh(Xx,e.__scopeDialog),n=u.useRef(!1),a=u.useRef(!1);return t.jsx(RY,{...e,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;r.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),RY=u.forwardRef((e,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=e,l=Eh(Xx,r),c=u.useRef(null),d=mr(s,c);return MO(),t.jsxs(t.Fragment,{children:[t.jsx(Wk,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:t.jsx(wb,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":DO(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),t.jsxs(t.Fragment,{children:[t.jsx(Sfe,{titleId:l.titleId}),t.jsx(kfe,{contentRef:c,descriptionId:l.descriptionId})]})]})}),OO="DialogTitle",IY=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=Eh(OO,r);return t.jsx(Cr.h2,{id:a.titleId,...n,ref:s})});IY.displayName=OO;var OY="DialogDescription",DY=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=Eh(OY,r);return t.jsx(Cr.p,{id:a.descriptionId,...n,ref:s})});DY.displayName=OY;var LY="DialogClose",$Y=u.forwardRef((e,s)=>{const{__scopeDialog:r,...n}=e,a=Eh(LY,r);return t.jsx(Cr.button,{type:"button",...n,ref:s,onClick:Ms(e.onClick,()=>a.onOpenChange(!1))})});$Y.displayName=LY;function DO(e){return e?"open":"closed"}var FY="DialogTitleWarning",[Nfe,BY]=Vle(FY,{contentName:Xx,titleName:OO,docsSlug:"dialog"}),Sfe=({titleId:e})=>{const s=BY(FY),r=`\`${s.contentName}\` requires a \`${s.titleName}\` for the component to be accessible for screen reader users.
67
68If you want to hide the \`${s.titleName}\`, you can wrap it with our VisuallyHidden component.
69
70For more information, see https://radix-ui.com/primitives/docs/components/${s.docsSlug}`;return u.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},Cfe="DialogDescriptionWarning",kfe=({contentRef:e,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${BY(Cfe).contentName}}.`;return u.useEffect(()=>{const a=e.current?.getAttribute("aria-describedby");s&&a&&(document.getElementById(s)||console.warn(n))},[n,e,s]),null},UY=kY,zY=PY,HY=TY,LO=AY,$O=MY,FO=IY,BO=DY,Yk=$Y;const Ys=UY,_fe=zY,Pfe=HY,HS=Yk,qY=u.forwardRef(({className:e,...s},r)=>t.jsx(LO,{ref:r,className:Cs("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),...s}));qY.displayName=LO.displayName;const Ws=u.forwardRef(({className:e,children:s,hideClose:r,...n},a)=>t.jsxs(Pfe,{children:[t.jsx(qY,{}),t.jsxs($O,{ref:a,className:Cs("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
70nded-lg",e),...n,children:[s,!r&&t.jsxs(Yk,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(va,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ws.displayName=$O.displayName;const Zs=({className:e,...s})=>t.jsx("div",{className:Cs("flex flex-col space-y-1.5 text-center sm:text-left",e),...s});Zs.displayName="DialogHeader";const In=({className:e,...s})=>t.jsx("div",{className:Cs("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...s});In.displayName="DialogFooter";const Ks=u.forwardRef(({className:e,...s},r)=>t.jsx(FO,{ref:r,className:Cs("text-lg font-semibold leading-none tracking-tight",e),...s}));Ks.displayName=FO.displayName;const cr=u.forwardRef(({className:e,...s},r)=>t.jsx(BO,{ref:r,className:Cs("text-sm text-muted-foreground",e),...s}));cr.displayName=BO.displayName;var VY={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},i6=Ne.createContext&&Ne.createContext(VY),Efe=["attr","size","title"];function Tfe(e,s){if(e==null)return{};var r=Afe(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Afe(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function qS(){return qS=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},qS.apply(this,arguments)}function o6(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function VS(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?o6(Object(r),!0).forEach(function(n){Mfe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o6(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Mfe(e,s,r){return s=Rfe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Rfe(e){var s=Ife(e,"string");return typeof s=="symbol"?s:s+""}function Ife(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function WY(e){return e&&e.map((s,r)=>Ne.createElement(s.tag,VS({key:r},s.attr),WY(s.child)))}function KY(e){return s=>Ne.createElement(Ofe,qS({attr:VS({},e.attr)},s),WY(e.child))}function Ofe(e){var s=r=>{var{attr:n,size:a,title:i}=e,o=Tfe(e,Efe),l=a||r.size||"1em",c;return r.className&&(c=r.className),e.className&&(c=(c?c+" ":"")+e.className),Ne.createElement("svg",qS({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,n,o,{className:c,style:VS(VS({color:e.color||r.color},r.style),e.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),i&&Ne.createElement("title",null,i),e.children)};return i6!==void 0?Ne.createElement(i6.Consumer,null,r=>s(r)):s(VY)}function GY(e){return KY({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M12.19 2.38a9.344 9.344 0 0 0-9.234 6.893c.053-.02-.055.013 0 0-3.875 2.551-3.922 8.11-.247 10.941l.006-.007-.007.03a6.717 6.717 0 0 0 4.077 1.356h5.173l.03.03h5.192c6.687.053 9.376-8.605 3.835-12.35a9.365 9.365 0 0 0-2.821-4.552l-.043.043.006-.05A9.344 9.344 0 0 0 12.19 2.38zm-.358 4.146c1.244-.04 2.518.368 3.486 1.15a5.186 5.186 0 0 1 1.862 4.078v.518c3.53-.07 3.53 5.262 0 5.193h-5.193l-.008.009v-.04H6.785a2.59 2.59 0 0 1-1.067-.23h.001a2.597 2.597 0 1 1 3.437-3.437l3.013-3.012A6.747 6.747 0 0 0 8.11 8.24c.018-.01.04-.026.054-.023a5.186 5.186 0 0 1 3.67-1.69z"},child:[]}]})(e)}function Dfe(e){return KY({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M11.668 14.544l-.028-5.226c.138-.055.387-.111.608-.111.995 0 1.41.774 1.41 2.682 0 1.853-.47 2.765-1.438 2.765-.22 0-.441-.055-.552-.11zM3.124 7.438c4.203-3.843 9.29-4.866 14.018-4.866 1.3 0 2.544.083 3.76.194h-.028v11.253c0 2.184-.774 3.926-2.295 5.171-1.355 1.134-5.447 2.959-6.581 3.456-1.161-.525-5.253-2.378-6.581-3.456-1.493-1.244-2.295-3.014-2.295-5.171V7.438zm12.664 2.599c.028.912.276 1.576 1.687 2.406.747.442 1.051.747 1.051 1.272 0 .581-.387.94-1.
70023.94-.553 0-1.189-.304-1.631-.691v1.576c.553.304 1.217.525 1.88.525 1.687 0 2.433-1.189 2.461-2.267.028-.995-.249-1.742-1.659-2.571-.608-.387-1.134-.636-1.106-1.244 0-.581.525-.802.995-.802.581 0 1.161.332 1.521.691V8.378c-.304-.221-.94-.581-1.88-.553-1.135.028-2.296.829-2.296 2.212zm-5.834 9.484h1.714l-.028-3.594c.166.028.415.083.774.083 1.908 0 2.986-1.687 2.986-4.175 0-2.461-1.106-4.009-3.152-4.009-.94 0-1.687.221-2.295.608v11.087zm-5.945-6.166c0 1.797.829 2.71 2.516 2.71 1.051 0 1.908-.249 2.571-.691V7.991H7.41v6.387c-.194.138-.47.221-.802.221-.774 0-.885-.719-.885-1.189V7.991H4.009v5.364zM22.12 2.295v11.723c0 2.516-.94 4.645-2.765 6.111-1.549 1.3-6.332 3.429-7.355 3.871-1.023-.442-5.806-2.571-7.355-3.843-1.797-1.465-2.765-3.594-2.765-6.111V2.295C4.756.747 8.074 0 12 0s7.244.747 10.12 2.295zm-.304.221c-2.71-1.465-6-2.184-9.788-2.184s-7.079.746-9.788 2.184v11.502c0 2.433.912 4.452 2.627 5.862 1.576 1.3 6.581 3.484 7.161 3.76.581-.249 5.585-2.433 7.161-3.733 1.714-1.41 2.627-3.429 2.627-5.862V2.516zm-2.433 20.295c0 .47-.387.829-.829.829a.831.831 0 0 1-.829-.829c0-.47.387-.829.829-.829.441 0 .801.359.829.829zm-.166 0a.679.679 0 0 0-.664-.691c-.359 0-.664.332-.664.691 0 .359.304.664.664.664a.673.673 0 0 0 .664-.664zm-.553.055c.028.055.304.442.304.442h-.221s-.276-.387-.276-.415h-.028v.415h-.194v-.995l.304-.028c.249 0 .332.166.332.304s-.083.25-.221.277zm.027-.276c0-.055 0-.138-.166-.138h-.083v.304h.028c.194 0 .221-.083.221-.166z"},child:[]}]})(e)}const Tm="/assets/Asset_4@4x-8_1770268570170-C9BTzik4.png",Lfe="/assets/IMG_2033_1774467465240-D9D-eIvp.jpg",l6="/assets/IMG_0010_1775090686858-BVL-WMIj.png",c6="/assets/IMG_0011_1775090686859-vuXnR5g1.png",Q5="/assets/IMG_0012_1775090686859-CgSSw8Y7.png",$fe="/assets/image_1779915109611-CezkPR11.png",d6="/assets/IMG_0022_1775233740095-DuM4Pu4m.png",Ffe="/assets/edge_1775238025454-BmNNWrtm.png",Bfe="/assets/IMG_0023_1775238272985-BEUQEMTq.png",YY="/assets/IMG_0027_1775242169322-BYUE6ccE.png",Ufe="/assets/Text_To_Search_1776271662867-HTnQdNgZ.png",QY="/assets/firearm_1778087492765-DemUmYEE.png",XY="/assets/Visual_Search_1776271662867-BVFMvlyv.png",ZY="/assets/image_1779674941859-BDvN7saG.png",zfe=e=>{const s=`Customer acknowledges that this section is intended to be interpreted broadly to protect ${e}'s legitimate business interests, intellectual property, confidential information, cloud infrastructure, software platform, reseller ecosystem, and goodwill. These obligations survive termination where their nature so requires.`;return`${e.toUpperCase()} TERMS & CONDITIONS
71
72These Terms and Conditions ("Terms") govern all purchases, subscriptions, software licenses, cloud services, reseller relationships, OEM relationships, demonstrations, beta programs, webinars, training, support services and use of products and services provided by ${e}. By accessing or using any ${e} product or service, Customer agrees to these Terms.
73
741. Definitions
75
76Define Customer, Reseller, OEM, Services, Software, Confidential Information, Intellectual Property, Documentation, End User and Subscription.
77
78Detailed Provision: ${s}
79
802. License Grant
81
82${e} grants a limited, revocable, non-exclusive, non-transferable, non-sublicensable license solely for Customer's internal business purposes and authorized resale where applicable.
83
84Detailed Provision: ${s}
85
863. Intellectual Property
87
88All software, firmware, source code, object code, APIs, SDKs, interfaces, workflows, documentation, images, graphics, recordings, webinars, demonstrations, training materials, inventions, derivative works, trade secrets, trademarks, service marks and copyrights remain the exclusive property of ${e}.
89
90Detailed Provision: ${s}
91
924. Restrictions
93
94Customer shall not copy, modify, reverse engineer, decompile, disassemble, scrape, benchmark, create derivative works, bypass security, or use ${e} Confidential Information to design, develop, market or support competing products.
95
96Detailed Provision: ${s}
97
985. Confidential Information
99
100Includes all non-public information disclosed in writing, orally, electronically, visually or through meetings, webinars, demonstrations, support, APIs, pricing, roadmaps, architecture and business methods.
101
102Detailed Provision: ${s}
103
1046. Webinars, Demonstrations & Training
105
106All demonstrations, recordings, presentations, onboarding sessions and technical discussions are Confidential Information and may not be reproduced, distributed or used outside the authorized business relationship.
107
108Detailed Provision: ${s}
109
1107. Orders & Payment
111
112Recurring fees may be charged automatically. ${e} may suspend services or shipments for delinquent accounts.
113
114Detailed Provision: ${s}
115
1168. Returns
117
118RMA required. Approved returns within 90 days may be subject to restocking and diagnostic fees. No returns after 90 days unless required by law.
119
120Detailed Provision: ${s}
121
1229. Support
123
124Support is provided only to the contracting customer unless ${e} authorizes otherwise.
125
126Detailed Provision: ${s}
127
12810. Warranty Disclaimer
129
130Except as expressly stated, products and services are provided AS IS and AS AVAILABLE.
131
132Detailed Provision: ${s}
133
13411. Limitation of Liability
135
136To the maximum extent permitted by law, ${e} is not liable for indirect, incidental, consequential, special or punitive damages, including loss of recordings, profits or data.
137
138Detailed Provision: ${s}
139
14012. Data & Cloud Services
141
142Customer is responsible for verifying retention policies, exports and backups appropriate for its business.
143
144Detailed Provision: ${s}
145
14613. Suspension & Termination
147
148${e} may suspend services for breach, non-payment, security concerns or unlawful use.
149
150Detailed Provision: ${s}
151
15214. Injunctive Relief
153
154Unauthorized use of confidential information or intellectual property may cause irreparable harm. ${e} may seek temporary, preliminary and permanent injunctive relief.
155
156Detailed Provision: ${s}
157
15815. Attorney's Fees
159
160Where permitted by law or contract, the prevailing party is entitled to reasonable attorney's fees and costs.
161
162Detailed Provision: ${s}
163
16416. Governing Law & Venue
165
166Governed by New York law. Exclusive jurisdiction and venue shall lie in the state and federal courts located in Suffolk County, New York.
167
168Detailed Provision: ${s}
169
17017. Miscellaneous
171
172Force majeure, severability, assignment restrictions, electronic acceptance, amendments, survival, export compliance, waiver, entire agreement.
173
174Detailed Provision: ${s}`},Hfe=(e,s,r)=>{const n=[e,s,r].filter(Boolean).join(", "),a="The parties agree that any ambiguity shall be interpreted to provide maximum protection for Confidential Information consistent with applicable law.";return`${(e||"").toUpperCase()} MUTUAL CONFIDENTIALITY & NON-DISCLOSURE AGREEMENT
175
176This Mutual Confidentiality & Non-Disclosure Agreement (Agreement) is entered into between ${e} and the Recipient.
177
178Purpose
179
180Confidential Information is disclosed solely to evaluate or conduct a business relationship.
181
182${a}
183
184Definition of Confidential Information
185
186Includes all non-public technical, software, operational, financial, pricing, roadmap, API, customer, reseller, OEM, support, webinar, demonstration, architecture and training information, regardless of form.
187
188${a}
189
190Exclusions
191
192Information that becomes public without breach, was already lawfully known, independently developed without use of Confidential Information, or lawfully received from a third party.
193
194${a}
195
196Non-Disclosure
197
198Recipient shall not disclose Confidential Information except to personnel with a need to know who are bound by equivalent obligations.
199
200${a}
201
202Non-Use
203
204Recipient shall not use Confidential Information to develop, improve, market, license, manufacture, support or operate any competing product or service.
205
206${a}
207
208Protection
209
210Recipient shall protect Confidential Information using at least reasonable care and appropriate administrative, technical and physical safeguards.
211
212${a}
213
214Return or Destruction
215
216Upon request or termination, Recipient shall promptly return or permanently destroy Confidential Information and certify destruction upon request.
217
218${a}
219
220Trade Secrets
221
222Trade secrets remain protected as long as they qualify as trade secrets under applicable law.
223
224${a}
225
226Remedies
227
228Recipient acknowledges irreparable harm and agrees ${e} may seek injunctive relief in addition to damages and other remedies.
229
230${a}
231
232Attorney's Fees
233
234Where permitted, prevailing party may recover reasonable attorney's fees and costs.
235
236${a}
237
238Term
239
240General confidentiality obligations survive five years after termination; trade secret obligations survive for so long as the information remains protected.
241
242${a}
243
244Law & Venue
245
246Governed by New York law with exclusive jurisdiction in Suffolk County, New York.
247
248${a}
249
250Disclosing Party: ${n}.`},d1=[{label:"My Profile",icon:xi},{label:"Create Login",icon:dO},{label:"Billing",icon:Jce},{label:"Sign & Accept",icon:xu}];function qfe({variant:e="modal",onClose:s}){const r=e==="modal",{toast:n}=Hs(),a=Er(),i=zfe(a.legalCompanyName),o=Hfe(a.legalEntityName,a.addressLine1,a.addressLine2),[l,c]=u.useState(0),[d,h]=u.useState(!1),[p,g]=u.useState(!1),[v,b]=u.useState({companyName:"",principalContact:"",title:"",principalPhone:"",billingEmail:"",federalTaxId:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"United States",techFirstName:"",techLastName:"",techEmail:"",techPhone:"",password:"",confirmPassword:"",billingFirstName:"",billingLastName:"",billingContactEmail:"",billingPhone:"",acceptedTerms:!1,acceptedNda:!1,signature:""}),y=(k,S)=>b(_=>({..._,[k]:S})),w=(k,S,_,A=!1,T="text")=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:k,className:"text-sm",children:[S,A&&t.jsx("span",{className:"text-destructive ml-0.5",children:"*"})]}),t.jsx(ke,{id:k,type:T,placeholder:_,value:v[k],onChange:M=>y(k,M.target.value),required:A,"data-testid":`input-${k}`})]});function j(){if(l===0&&(!v.companyName||!v.principalContact||!v.principalPhone||!v.billingEmail||!v.addressLine1||!v.city||!v.state||!v.postalCode))return n({title:"Missing fields",description:"Please fill in all required fields.",variant:"destructive"}),!1;if(l===1){if(!v.techFirstName||!v.techLastName||!v.techEmail)return n({title:"Missing fields",description:"First name, last name and email are required.",variant:"destructive"}),!1;if(!v.password||v.password.length<8)return n({title:"Password too short",description:"Password must be at least 8 characters.",variant:"destructive"}),!1;if(v.password!==v.confirmPassword)return n({title:"Passwords do not match",description:"Please make sure both password fields match.",variant:"destructive"}),!1}if(l===3){if(!v.acceptedTerms||!v.acceptedNda)return n({title:"Agreement required",description:"Please accept the Terms and NDA to continue.",variant:"destructive"}),!1;if(!v.signature.trim())return n({title:"Signature required",description:"Please type your full name as your signature.",variant:"destructive"}),!1}return!0}async function x(){if(j()){h(!0);try{const k=await fetch("/api/reseller-applications",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v)});if(!k.ok){const S=await k.json();throw new Error(S.message||"Submission failed")}g(!0)}catch(k){n({title:"Submission Error",description:k.message,variant:"destructive"})}finally{h(!1)}}}if(p){const k=t.jsx(ut,{className:r?"w-full max-w-md mx-4":"w-full",children:t.jsxs(mt,{className:"p-8 text-center space-y-4",children:[t.jsx(ar,{className:"w-16 h-16 text-green-500 mx-auto"}),t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Application Submitted!"}),t.jsxs("p",{className:"text-muted-foreground",children:["Thank you, ",t.jsx("strong",{children:v.techFirstName}),". Your customer application for ",t.jsx("strong",{children:v.companyName})," has been received and is under review."]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll notify you at ",t.jsx("strong",{children:v.techEmail})," once your account has been approved."]}),s&&t.jsx(L,{onClick:s,className:"w-full mt-2",children:"Close"})]})});return r?t.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm",children:k}):k}const C=t.jsx(ut,{className:r?"w-full max-w-2xl max-h-[90vh] flex flex-col":"w-full flex flex-col",children:t.jsxs(mt,{className:"p-0 flex flex-col flex-1 min-h-0",children:[t.jsxs("div",{className:"flex items-center justify-between px-6 pt-6 pb-4 border-b border-border flex-shrink-0",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Customer Registration"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Step ",l+1," of ",d1.length]})]}),r&&t.jsx(L,{size:"icon",variant:"ghost",onClick:s,"data-testid":"button-close-registration",children:t.jsx(va,{className:"w-4 h-4"})})]}),t.jsx("div",{className:"flex items-center px-6 py-3 border-b border-border gap-0 flex-shrink-0",children:d1.map((k,S)=>{const _=k.icon,A=S<l,T=S===l;return t.jsxs("div",{className:"flex items-center flex-1",children:[t.jsxs("div",{className:`flex items-center gap-1.5 text-xs font-medium transition-colors ${T?"text-primary":A?"text-green-500":"text-muted-foreground"}`,children:[t.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${T?"bg-primary text-primary-foreground":A?"bg-green-500 text-white":"bg-muted"}`,children:A?t.jsx(ar,{className:"w-3.5 h-3.5"}):t.jsx(_,{className:"w-3 h-3"})}),t.jsx("span",{className:"hidden sm:inline",children:k.label})]}),S<d1.length-1&&t.jsx("div",{className:`flex-1 h-px mx-2 ${S<l?"bg-green-500":"bg-border"}`})]},S)})}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[l===0&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Congratulations! You are one step closer to becoming a ",a.brandName," customer. Fill out your information below."]}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[w("companyName","Company Name or Individual","Acme Security Inc.",!0),w("principalContact","Principal Contact","John Smith",!0),w("title","Title","Owner / Manager"),w("principalPhone","Principal Phone","(555) 000-0000",!0,"tel"),w("billingEmail","Email Address","[email protected]",!0,"email"),w("federalTaxId","Federal Tax ID","XX-XXXXXXX"),w("techPhone","Mobile Number","(555) 000-0000",!1,"tel")]}),t.jsxs("div",{className:"pt-2",children:[t.jsx("p",{className:"text-sm font-medium text-foreground mb-3",children:"Physical Address"}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[t.jsx("div",{className:"sm:col-span-2",children:w("addressLine1","Address Line 1","123 Main Street",!0)}),t.jsx("div",{className:"sm:col-span-2",children:w("addressLine2","Address Line 2","Suite 100")}),w("city","City","New York",!0),w("state","State / Province","NY",!0),w("postalCode","Postal Code","10001",!0),w("country","Country","United States")]})]})]}),l===1&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Create your login to ",a.productName]}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[w("techFirstName","First Name","Jane",!0),w("techLastName","Last Name","Doe",!0),t.jsx("div",{className:"sm:col-span-2",children:w("techEmail","Email Address","[email protected]",!0,"email")}),t.jsx("div",{className:"sm:col-span-2",children:t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[w("password","Password","Minimum 8 characters",!0,"password"),w("confirmPassword","Verify Password","Re-enter password",!0,"password")]})})]})]}),l===2&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Billing contact for invoices and payments. Leave blank if the same as the principal contact."}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[w("billingFirstName","First Name","John"),w("billingLastName","Last Name","Smith"),t.jsx("div",{className:"sm:col-span-2",children:w("billingContactEmail","Email","[email protected]",!1,"email")}),w("billingPhone","Phone Number","(555) 000-0000",!1,"tel")]})]}),l===3&&t.jsxs("div",{className:"space-y-5",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Please review and accept the Terms & Conditions and Mutual Non-Disclosure Agreement below."}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Terms & Conditions"}),t.jsx("div",{className:"h-36 overflow-y-auto rounded-lg border border-border bg-muted/30 p-3 text-xs text-muted-foreground leading-relaxed whitespace-pre-line",children:i}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(On,{id:"acceptedTerms",checked:v.acceptedTerms,onCheckedChange:k=>y("acceptedTerms",k===!0),"data-testid":"checkbox-terms"}),t.jsx(re,{htmlFor:"acceptedTerms",className:"text-sm cursor-pointer",children:"I have read and agree to the Terms & Conditions"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Mutual Confidentiality & Non-Disclosure Agreement"}),t.jsx("div",{className:"h-36 overflow-y-auto rounded-lg border border-border bg-muted/30 p-3 text-xs text-muted-foreground leading-relaxed whitespace-pre-line",children:o}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(On,{id:"acceptedNda",checked:v.acceptedNda,onCheckedChange:k=>y("acceptedNda",k===!0),"data-testid":"checkbox-nda"}),t.jsx(re,{htmlFor:"acceptedNda",className:"text-sm cursor-pointer",children:"I have read and agree to the Mutual Non-Disclosure Agreement"})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"signature",className:"text-sm",children:["Signature (Type your full legal name)",t.jsx("span",{className:"text-destructive ml-0.5",children:"*"})]}),t.jsx(ke,{id:"signature",placeholder:"Your full name",value:v.signature,onChange:k=>y("signature",k.target.value),className:"font-serif italic text-base","data-testid":"input-signature"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"By typing your name above, you certify that all information has been supplied truthfully and accurately."})]})]})]}),t.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border flex-shrink-0",children:[l===0&&!r?t.jsx("span",{}):t.jsxs(L,{variant:"outline",onClick:()=>l===0?s?.():c(k=>k-1),"data-testid":"button-prev-step",children:[t.jsx(Kl,{className:"w-4 h-4 mr-1"}),l===0?"Cancel":"Back"]}),l<d1.length-1?t.jsxs(L,{onClick:()=>{j()&&(l===0&&!v.techEmail&&y("techEmail",v.billingEmail),c(k=>k+1))},"data-testid":"button-next-step",children:["Next",t.jsx(hi,{className:"w-4 h-4 ml-1"})]}):t.jsxs(L,{onClick:x,disabled:d,"data-testid":"button-submit-application",children:[d?t.jsx(Fe,{className:"w-4 h-4 animate-spin mr-2"}):null,"Submit Application"]})]})]})});return r?t.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",children:C}):C}function sl({onClose:e}){return t.jsx(qfe,{variant:"modal",onClose:e})}function X5(){const e=window.Tawk_API;if(e?.maximize){e.maximize();return}window._tawkPendingOpen=!0,e&&!e.onLoad&&(e.onLoad=function(){window._tawkPendingOpen&&(window._tawkPendingOpen=!1,window.Tawk_API?.maximize?.())})}function JY(e){if(!e||!e.trim())return{};try{const s=JSON.parse(e);if(!s||typeof s!="object"||Array.isArray(s))return{};const r={};
250for(const[n,a]of Object.entries(s))typeof a=="string"&&a.trim()!==""&&(r[n]=a);return r}catch{return{}}}function u6(e){const s=Object.entries(e).filter(([,r])=>typeof r=="string"&&r.trim()!=="");return s.length===0?"":(s.sort(([r],[n])=>r<n?-1:r>n?1:0),JSON.stringify(Object.fromEntries(s)))}function Vfe(e,s){return s&&e.editorValue?e.editorValue(s):s}function Wfe(e,s){return e.replace(/\{productName\}/g,s.productName).replace(/\{brandName\}/g,s.brandName).replace(/\{phone\}/g,s.phone).replace(/\{supportEmail\}/g,s.supportEmail).replace(/\{salesEmail\}/g,s.salesEmail).replace(/\{domain\}/g,s.domain)}const m6=e=>e.split(`
251`).map(s=>s.trim()).filter(Boolean),Kfe=e=>e.split(`
252`).map(s=>s.trim()),Gfe=e=>e.split("|").map(s=>s.trim());function Yfe(e,s,r,n,a){const i=e[`${s}.${r}`]??n[r]??"";return Wfe(i,a)}function Qfe(e){const s={};for(const r of e.fields)s[r.key]=r.def;return s}const eQ=["Activity","AlertTriangle","Aperture","Bell","Briefcase","Building2","Calendar","Camera","Car","Cctv","CircleDollarSign","Clock","Cloud","Compass","Eye","FileText","Filter","Globe2","HardDrive","Layers","Lock","MapPin","Maximize2","Move","Package","Radio","RefreshCw","RotateCw","Scale","Search","Shield","ShieldCheck","Star","TrendingDown","UserCheck","Users","Wifi","ZoomIn","Zap","AlertCircle","Award","BarChart3","Bookmark","Building","CheckCircle2","Clapperboard","Database","DollarSign","Download","Fingerprint","Flag","Gauge","Globe","GraduationCap","Grid3x3","Headphones","Heart","HeartPulse","Home","Image","Key","Landmark","Leaf","LineChart","Link","Mail","MessageSquare","Monitor","MonitorPlay","Phone","PieChart","Rocket","Server","Settings","ShoppingCart","Sparkles","Store","Tag","Target","ThumbsUp","Truck","Utensils","Video","Wrench"],Xfe=new Set(eQ);function Zfe(e){return Xfe.has(e)}const Z5={Activity:vc,AlertTriangle:Pn,Aperture:bK,Bell:mi,Briefcase:oh,Building2:xi,Calendar:ro,Camera:wo,Car:Rk,Cctv:no,CircleDollarSign:kK,Clock:cn,Cloud:pn,Compass:EK,Eye:Xr,FileText:xu,Filter:qj,Globe2:TK,HardDrive:Fa,Layers:eO,Lock:ka,MapPin:ql,Maximize2:pf,Move:_y,Package:sO,Radio:zK,RefreshCw:tl,RotateCw:aO,Scale:qK,Search:yc,Shield:uc,ShieldCheck:vi,Star:WK,TrendingDown:lO,UserCheck:GK,Users:Ba,Wifi:jb,ZoomIn:Vj,Zap:Nb,AlertCircle:ta,Award:Uce,BarChart3:QI,Bookmark:NK,Building:SK,CheckCircle2:ar,Clapperboard:Qce,Database:mf,DollarSign:S0,Download:ya,Fingerprint:sde,Flag:rde,Gauge:hf,Globe:Yp,GraduationCap:MK,Grid3x3:JI,Headphones:IK,Heart:ide,HeartPulse:OK,Home:Ik,Image:Ok,Key:yg,Landmark:DK,Leaf:LK,LineChart:Wce,Link:$K,Mail:qi,MessageSquare:qx,Monitor:Vx,MonitorPlay:Cg,Phone:Qp,PieChart:Kce,Rocket:wde,Server:Wx,Settings:xd,ShoppingCart:kde,Sparkles:Do,Store:Ade,Tag:Py,Target:Mde,ThumbsUp:Ide,Truck:cO,Utensils:YK,Video:Vi,Wrench:Fde},Jfe=[...eQ].sort((e,s)=>e<s?-1:e>s?1:0);function tQ(e,s){if(!e)return s;const r=e.trim();return r?Z5[r]??s:s}function rn(e){const s=Er(),r=u.useMemo(()=>JY(s.pageText),[s.pageText]),n=u.useMemo(()=>Qfe(e),[e]),a=u.useMemo(()=>({productName:s.productName,brandName:s.brandName,phone:s.phone,supportEmail:s.supportEmail,salesEmail:s.salesEmail,domain:s.domain}),[s]);return u.useMemo(()=>{const i=d=>Yfe(r,e.key,d,n,a);return{t:i,tLines:d=>m6(i(d)),tParts:d=>m6(i(d)).map(Gfe),tIcons:(d,h)=>{const p=r[`${e.key}.${d}`],g=p!=null?Kfe(p):[];return v=>{const b=h[v%h.length],y=g[v];return tQ(y,b)}}}},[r,n,a,e.key])}const sQ={key:"publicNav",title:"Navigation Bar",group:"Chrome",fields:[{key:"groups.products",label:"Group: Products",def:"Products"},{key:"groups.pricing",label:"Group: Pricing",def:"Pricing"},{key:"groups.solutions",label:"Group: Solutions",def:"Solutions"},{key:"groups.resources",label:"Group: Resources",def:"Resources"},{key:"groups.support",label:"Group: Support",def:"Support"},{key:"groups.contact",label:"Group: Contact",def:"Contact"},{key:"solutions.byIndustry",label:"Solutions heading: By Industry (desktop)",def:"By Industry"},{key:"solutions.byFeature",label:"Solutions heading: By Feature (desktop)",def:"By Feature"},{key:"solutions.byIndustryMobile",label:"Solutions heading: By Industry (mobile)",def:"Solutions · By Industry"},{key:"solutions.byFeatureMobile",label:"Solutions heading: By Feature (mobile)",def:"Solutions · By Feature"},{key:"solutions.soonBadge",label:'"Soon" badge for upcoming industries',def:"Soon"},{key:"products.edge",label:"Products item: Edge",def:"Edge"},{key:"products.blu",label:"Products item: Blu Legacy",def:"Blu Legacy"},{key:"pricing.edge",label:"Pricing item: Edge",def:"Edge"},{key:"pricing.blu",label:"Pricing item: Blu Legacy",def:"Blu Legacy"},{key:"solutions.industries",label:"Industry item labels",def:["Hospital
252ity","Retail","Restaurants & QSR","Healthcare","Education","Government","Commercial Real Estate","Cannabis"].join(`
253`),multiline:!0,help:"One industry label per line, in order. Icons and links are fixed per position."},{key:"solutions.features",label:"Feature item labels",def:["Weapon Detection","Faces & People","Natural Text Search","Object Detection","Visual Comparisons","Smart AI Alerts","Cloud Video Surveillance","Device Notifications","PTZ & Fisheye Integration"].join(`
254`),multiline:!0,help:"One feature label per line, in order. Icons and links are fixed per position."},{key:"resources.whitePaper",label:"Resources item: White Paper",def:"White Paper"},{key:"resources.supportedDevices",label:"Resources item: Supported Devices",def:"Supported Devices"},{key:"resources.oemBranding",label:"Resources item: OEM Branding",def:"OEM Branding"},{key:"resources.blog",label:"Resources item: Blog",def:"Blog"},{key:"resources.events",label:"Resources item: Events",def:"Events"},{key:"support.edgeAppInstall",label:"Support item: Edge App Install",def:"Edge App Install"},{key:"support.bluDocumentation",label:"Support item: Blu Documentation",def:"Blu Documentation"},{key:"support.submitTicket",label:"Support item: Submit Ticket",def:"Submit Ticket"},{key:"support.downloads",label:"Support item: Downloads",def:"Downloads"},{key:"support.systemHealth",label:"Support item: System Health",def:"System Health"},{key:"contact.contactUs",label:"Contact item: Contact Us",def:"Contact Us"},{key:"contact.chat",label:"Contact item: Chat With Us",def:"Chat With Us"},{key:"contact.refer",label:"Contact item: Refer",def:"Refer"},{key:"buttons.liveDemo",label:"Button: Live Demo",def:"Live Demo"},{key:"buttons.dashboard",label:"Button: Dashboard",def:"Dashboard"},{key:"buttons.signIn",label:"Button: Sign In",def:"Sign In"}]},Fw=[{label:"Hospitality",icon:ode,path:"/solutions/hospitality",live:!0,brandingKey:"navSolutionsHospitality"},{label:"Retail",icon:VK,path:"/solutions/retail",live:!0,brandingKey:"navSolutionsRetail"},{label:"Restaurants & QSR",icon:YK,path:"/solutions/restaurants",live:!0,brandingKey:"navSolutionsRestaurants"},{label:"Healthcare",icon:OK,path:"/solutions/healthcare",live:!0,brandingKey:"navSolutionsHealthcare"},{label:"Education",icon:MK,path:"/solutions/education",live:!0,brandingKey:"navSolutionsEducation"},{label:"Government",icon:DK,path:"/solutions/government",live:!0,brandingKey:"navSolutionsGovernment"},{label:"Commercial Real Estate",icon:SK,path:"/solutions/commercial-real-estate",live:!0,brandingKey:"navSolutionsCommercialRealEstate"},{label:"Cannabis",icon:LK,path:"/solutions/cannabis",live:!0,brandingKey:"navSolutionsCannabis"}],J5=[{label:"Weapon Detection",icon:iO,path:"/solutions/features/weapon-detection",brandingKey:"navSolutionsWeaponDetection"},{label:"Faces & People",icon:Ba,path:"/solutions/features/faces-people",brandingKey:"navSolutionsFacesPeople"},{label:"Natural Text Search",icon:yc,path:"/solutions/features/natural-text-search",brandingKey:"navSolutionsNaturalTextSearch"},{label:"Object Detection",icon:Xr,path:"/solutions/features/object-detection",brandingKey:"navSolutionsObjectDetection"},{label:"Visual Comparisons",icon:nde,path:"/solutions/features/visual-comparisons",brandingKey:"navSolutionsVisualComparisons"},{label:"Smart AI Alerts",icon:Nb,path:"/solutions/features/smart-ai-alerts",brandingKey:"navSolutionsSmartAiAlerts"},{label:"Cloud Video Surveillance",icon:pn,path:"/cloud-video-surveillance",brandingKey:"navSolutionsCloudVideoSurveillance"},{label:"Device Notifications",icon:mi,path:"/solutions/features/device-notifications",brandingKey:"navSolutionsDeviceNotifications"},{label:"PTZ & Fisheye Integration",icon:_y,path:"/ptz-fisheye",brandingKey:"navSolutionsPtzFisheye"}],h6=[{path:"/blog",labelKey:"resources.blog",icon:A5,visibilityKey:"resourcesBlog",testIdBase:"resource-blog"},{path:"/resources/events",labelKey:"resources.events",icon:nS,visibilityKey:"resourcesEvents",testIdBase:"resource-events"},{path:"/resources/oem-branding",labelKey:"resources.oemBranding",icon:xi,visibilityKey:"resourcesOemBranding",testIdBase:"resource-oem-branding"},{path:"/resources/supported-devices",labelKey:"resources.supportedDevices",icon:uf,visibilityKey:"resourcesSupportedDevices",testIdBase:"resource-supported-devices"},{path:"/resources/white-paper",labelKey:"resources.whitePaper",icon:xu,visibilityKey:"resourcesWhitePaper",testIdBase:"resource-white-paper"}];function ege(e){const s=g=>g!=="false",r={productsEdge:s(e.navProductsEdge),productsBlu:s(e.navProductsBlu),pricingEdge:s(e.navPricingEdge),pricingBlu:s(e.navPricingBlu),solutions:s(e.navSolutions),resourcesWhitePaper:s(e.navResourcesWhitePaper),resourcesSupportedDevices:s(e.navResourcesSupportedDevices),resourcesOemBranding:s(e.navResourcesOemBranding),resourcesBlog:s(e.navResourcesBlog),resourcesEvents:s(e.navResourcesEvents),supportEdgeAppInstall:s(e.navSupportEdgeAppInstall),supportBluDocumentation:s(e.navSupportBluDocumentation),supportSubmitTicket:s(e.navSupportSubmitTicket),supportDownloads:s(e.navSupportDownloads),supportSystemHealth:s(e.navSupportSystemHealth),contactUs:s(e.navContactUs),contactChat:s(e.navContactChat),contactRefer:s(e.navContactRefer)},n=Fw.filter(g=>s(String(e[g.brandingKey]))),a=J5.filter(g=>s(String(e[g.brandingKey]))),i=s(e.navProducts)&&(r.productsEdge||r.productsBlu),o=s(e.navPricing)&&(r.pricingEdge||r.pricingBlu),l=r.solutions&&(n.length>0||a.length>0),c=s(e.navResources)&&(r.resourcesWhitePaper||r.resourcesSupportedDevices||r.resourcesOemBranding||r.resourcesBlog||r.resourcesEvents),d=s(e.navSupport)&&(r.supportEdgeAppInstall||r.supportBluDocumentation||r.supportSubmitTicket||r.supportDownloads||r.supportSystemHealth),h=s(e.navContact)&&(r.contactUs||r.contactChat||r.contactRefer),p=r.supportSystemHealth&&(r.supportEdgeAppInstall||r.supportBluDocumentation||r.supportSubmitTicket||r.supportDownloads);return{nav:r,visibleIndustries:n,visibleFeatures:a,showProducts:i,showPricing:o,showSolutions:l,showResources:c,showSupport:d,showContact:h,showSupportSystemHealthDiv
254ider:p}}function pa({onSignIn:e,onContact:s}){const[r,n]=Ia(),{user:a}=Gi(),i=Er(),{t:o,tLines:l}=rn(sQ),c=l("solutions.industries"),d=l("solutions.features"),{data:h}=ze({queryKey:["/api/user/role"],enabled:!!a}),p=h?.role==="admin"&&!!h?.hideOrdersQuotes,{data:g}=ze({queryKey:["/api/demo-account/availability"]}),v=!!g?.available,[b,y]=u.useState(!1),w=async()=>{if(!b){y(!0);try{await Ze("POST","/api/demo-login"),Je.removeQueries({predicate:ge=>ge.queryKey[0]!=="/api/auth/user"}),await Je.invalidateQueries({queryKey:["/api/auth/user"]}),n("/")}catch{y(!1)}}},{nav:j,visibleIndustries:x,visibleFeatures:C,showProducts:k,showPricing:S,showSolutions:_,showResources:A,showSupport:T,showContact:M,showSupportSystemHealthDivider:R}=ege(i),D=S&&!p,[$,O]=u.useState(!1),[q,V]=u.useState(!1),[K,G]=u.useState(!1),[z,Z]=u.useState(!1),[ee,Q]=u.useState(!1),[Y,oe]=u.useState(!1),[he,je]=u.useState(!1),pe=u.useRef(null),le=u.useRef(null),ue=u.useRef(null),fe=u.useRef(null),H=u.useRef(null),se=u.useRef(null);u.useEffect(()=>(document.body.style.overflow=he?"hidden":"",()=>{document.body.style.overflow=""}),[he]),u.useEffect(()=>{function ge(be){pe.current&&!pe.current.contains(be.target)&&O(!1),le.current&&!le.current.contains(be.target)&&V(!1),ue.current&&!ue.current.contains(be.target)&&G(!1),fe.current&&!fe.current.contains(be.target)&&Z(!1),H.current&&!H.current.contains(be.target)&&Q(!1),se.current&&!se.current.contains(be.target)&&oe(!1)}return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[]);const me=()=>{e?e():n("/?signin=1")};return t.jsx(t.Fragment,{children:t.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"flex items-center justify-between h-16 gap-4",children:[t.jsxs("button",{className:"flex items-center gap-3 min-w-0",onClick:()=>n("/home"),"data-testid":"nav-logo",children:[t.jsx("img",{src:i.appEmblemUrl||Tm,alt:i.brandName,className:"w-10 h-10 object-contain flex-shrink-0"}),t.jsx("span",{className:"text-xl font-light text-foreground truncate min-w-0 max-w-[55vw] sm:max-w-none",children:i.brandName})]}),t.jsxs("div",{className:"hidden lg:flex items-center gap-1",children:[k&&t.jsxs("div",{className:"relative",ref:pe,children:[t.jsxs("button",{onClick:()=>O(ge=>!ge),className:"flex items-center gap-1 px-3 py-2 text-sm font-medium text-foreground/80 hover:text-foreground rounded-md hover:bg-muted/60 transition-colors","data-testid":"nav-products",children:[o("groups.products")," ",t.jsx(Xa,{className:`w-3.5 h-3.5 transition-transform ${$?"rotate-180":""}`})]}),$&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 w-48 rounded-lg border border-border bg-background/95 backdrop-blur-md shadow-lg py-1 z-50",children:[j.productsEdge&&t.jsxs("button",{className:`w-full text-left flex items-center gap-3 px-4 py-2 text-sm hover:bg-muted/60 transition-colors ${r==="/"||r==="/home"?"text-primary font-medium":"text-foreground/80 hover:text-foreground"}`,onClick:()=>{O(!1),n("/home")},"data-testid":"nav-product-edge",children:[t.jsx(no,{className:"w-4 h-4 text-primary shrink-0"}),o("products.edge")]}),j.productsBlu&&t.jsxs("button",{className:`w-full text-left flex items-center gap-3 px-4 py-2 text-sm hover:bg-muted/60 transition-colors ${r==="/blu"?"text-primary font-medium":"text-foreground/80 hover:text-foreground"}`,onClick:()=>{O(!1),n("/blu")},"data-testid":"nav-product-blu",children:[t.jsx(no,{className:"w-4 h-4 text-primary shrink-0"}),o("products.blu")]})]})]}),D&&t.jsxs("div",{className:"relative",ref:le,children:[t.jsxs("button",{onClick:()=>V(ge=>!ge),className:"flex items-center gap-1 px-3 py-2 text-sm font-medium text-foreground/80 hover:text-foreground rounded-md hover:bg-muted/60 transition-colors","data-testid":"nav-pricing",children:[o("groups.pricing")," ",t.jsx(Xa,{className:`w-3.5 h-3.5 transition-transform ${q?"rotate-180":""}`})]}),q&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 w-48 rounded-lg border border-border bg-background/95 backdrop-blur-md shadow-lg py-1 z-50",children:[j.pricingEdge&&t.jsxs("button",{className:"w-full text-left flex items-center gap-3 px-4 py-2 text-sm text-foreground
254/80 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>{V(!1),n("/edge-quote")},"data-testid":"nav-pricing-edge",children:[t.jsx(no,{className:"w-4 h-4 text-primary shrink-0"}),o("pricing.edge")]}),j.pricingBlu&&t.jsxs("a",{href:i.pricingUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>V(!1),"data-testid":"nav-pricing-blu",children:[t.jsx(no,{className:"w-4 h-4 text-primary shrink-0"}),o("pricing.blu"),t.jsx(op,{className:"w-3 h-3 ml-auto text-muted-foreground"})]})]})]}),_&&t.jsxs("div",{className:"relative",ref:ue,children:[t.jsxs("button",{onClick:()=>G(ge=>!ge),className:"flex items-center gap-1 px-3 py-2 text-sm font-medium text-foreground/80 hover:text-foreground rounded-md hover:bg-muted/60 transition-colors","data-testid":"nav-solutions",children:[o("groups.solutions")," ",t.jsx(Xa,{className:`w-3.5 h-3.5 transition-transform ${K?"rotate-180":""}`})]}),K&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 w-64 rounded-lg border border-border bg-background/95 backdrop-blur-md shadow-lg py-2 z-50",children:[x.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"px-4 py-1.5 text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:o("solutions.byIndustry")}),x.map(ge=>ge.live?t.jsxs("button",{onClick:()=>{G(!1),n(ge.path)},className:"w-full text-left flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors",children:[t.jsx(ge.icon,{className:"w-4 h-4 text-primary shrink-0"}),c[Fw.indexOf(ge)]??ge.label]},ge.label):t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 text-sm text-foreground/40 cursor-not-allowed",children:[t.jsx(ge.icon,{className:"w-4 h-4 shrink-0"}),c[Fw.indexOf(ge)]??ge.label,t.jsx("span",{className:"ml-auto text-xs text-muted-foreground/60",children:o("solutions.soonBadge")})]},ge.label))]}),C.length>0&&t.jsxs(t.Fragment,{children:[x.length>0&&t.jsx("div",{className:"my-1 border-t border-border/50"}),t.jsx("p",{className:"px-4 py-1.5 text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:o("solutions.byFeature")}),C.map(ge=>t.jsxs("button",{onClick:()=>{G(!1),n(ge.path)},className:"w-full text-left flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors",children:[t.jsx(ge.icon,{className:"w-4 h-4 text-primary shrink-0"}),d[J5.indexOf(ge)]??ge.label]},ge.label))]})]})]}),A&&t.jsxs("div",{className:"relative",ref:fe,children:[t.jsxs("button",{onClick:()=>Z(ge=>!ge),className:"flex items-center gap-1 px-3 py-2 text-sm font-medium text-foreground/80 hover:text-foreground rounded-md hover:bg-muted/60 transition-colors","data-testid":"nav-resources",children:[o("groups.resources")," ",t.jsx(Xa,{className:`w-3.5 h-3.5 transition-transform ${z?"rotate-180":""}`})]}),z&&t.jsx("div",{className:"absolute top-full left-0 mt-1 w-52 rounded-lg border border-border bg-background/95 backdrop-blur-md shadow-lg py-1 z-50",children:h6.map(ge=>j[ge.visibilityKey]&&t.jsxs("button",{className:"w-full text-left flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>{Z(!1),n(ge.path)},"data-testid":`nav-${ge.testIdBase}`,children:[t.jsx(ge.icon,{className:"w-4 h-4 text-primary shrink-0"}),o(ge.labelKey)]},ge.path))})]}),T&&t.jsxs("div",{className:"relative",ref:H,children:[t.jsxs("button",{onClick:()=>Q(ge=>!ge),className:"flex items-center gap-1 px-3 py-2 text-sm font-medium text-foreground/80 hover:text-foreground rounded-md hover:bg-muted/60 transition-colors","data-testid":"nav-support",children:[o("groups.support")," ",t.jsx(Xa,{className:`w-3.5 h-3.5 transition-transform ${ee?"rotate-180":""}`})]}),ee&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 w-52 rounded-lg border border-border bg-background/95 backdrop-blur-md shadow-lg py-1 z-50",children:[j.supportEdgeAppInstall&&t.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-2 text-sm text-foreground
254/80 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>{Q(!1),n("/support/edge-app-install")},"data-testid":"nav-support-edge-app-install",children:[t.jsx(Yc,{className:"w-4 h-4 text-primary shrink-0"}),o("support.edgeAppInstall")]}),j.supportBluDocumentation&&t.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>{Q(!1),n("/support/blu-documentation")},"data-testid":"nav-support-blu-documentation",children:[t.jsx(A5,{className:"w-4 h-4 text-primary shrink-0"}),o("support.bluDocumentation")]}),j.supportSubmitTicket&&t.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>{Q(!1),n("/support/submit-ticket")},"data-testid":"nav-support-submit-ticket",children:[t.jsx(k0,{className:"w-4 h-4 text-primary shrink-0"}),o("support.submitTicket")]}),j.supportDownloads&&t.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>{Q(!1),n("/support/downloads")},"data-testid":"nav-support-downloads",children:[t.jsx(ya,{className:"w-4 h-4 text-primary shrink-0"}),o("support.downloads")]}),j.supportSystemHealth&&t.jsxs(t.Fragment,{children:[R&&t.jsx("div",{className:"my-1 border-t border-border/50"}),t.jsxs("a",{href:i.systemHealthUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors","data-testid":"nav-support-service-health",onClick:()=>Q(!1),children:[t.jsx(vc,{className:"w-4 h-4 text-primary shrink-0"}),o("support.systemHealth")]})]})]})]}),M&&t.jsxs("div",{className:"relative",ref:se,children:[t.jsxs("button",{onClick:()=>oe(ge=>!ge),className:"flex items-center gap-1 px-3 py-2 text-sm font-medium text-foreground/80 hover:text-foreground rounded-md hover:bg-muted/60 transition-colors","data-testid":"nav-contact",children:[o("groups.contact")," ",t.jsx(Xa,{className:`w-3.5 h-3.5 transition-transform ${Y?"rotate-180":""}`})]}),Y&&t.jsxs("div",{className:"absolute top-full right-0 mt-1 w-44 rounded-lg border border-border bg-background/95 backdrop-blur-md shadow-lg py-1 z-50",children:[j.contactUs&&t.jsxs("button",{className:"w-full text-left flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>{oe(!1),s?.()},"data-testid":"nav-contact-us",children:[t.jsx(Qp,{className:"w-4 h-4 text-primary shrink-0"}),o("contact.contactUs")]}),j.contactChat&&t.jsxs("button",{className:"w-full text-left flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>{oe(!1),X5()},"data-testid":"nav-chat-with-us",children:[t.jsx(O5,{className:"w-4 h-4 text-primary shrink-0"}),o("contact.chat")]}),j.contactRefer&&t.jsxs("button",{className:"w-full text-left flex items-center gap-3 px-4 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>{oe(!1),n("/refer")},"data-testid":"nav-refer",children:[t.jsx(ny,{className:"w-4 h-4 text-primary shrink-0"}),o("contact.refer")]})]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsxs("a",{href:`tel:${i.phoneHref}`,className:"hidden sm:flex items-center gap-1.5 text-sm font-medium text-foreground/80 hover:text-foreground transition-colors","data-testid":"nav-call-us",children:[t.jsx(Qp,{className:"w-3.5 h-3.5 text-primary"}),t.jsx("span",{children:i.phone})]}),v&&t.jsx(L,{variant:"outline",onClick:w,disabled:b,"data-testid":"button-live-demo",children:o("buttons.liveDemo")}),a?t.jsx(L,{onClick:()=>n("/"),"data-testid":"button-dashboard",children:o("buttons.dashboard")}):t.jsx(L,{onClick:me,"data-testid":"button-login",children:o("buttons.signIn")}),t.jsx("button",{className:"lg:hidden p-2 rounded-md text-foreground/70 hover:text-foreground hover:bg-muted/60 transition-colors",onClick:()=>je(ge=>!ge),"data-testid":"nav-mobile-toggle",children:he?t.jsx(va,{className:"w-5 h-5"}):t.jsx(FK,{className:"w-5 h-5"})})]})]}),he&&t.jsxs("div",{className:"lg:hidden border-t border-border py-3 space-y-1 overflow-y-auto max-h-[calc(100vh-4rem)]",style:{WebkitOverflowScrolling:"touch"},children:[k&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:o("groups.products")}),j.productsEdge&&t.jsxs("button",{onClick:()=>{je(!1),n("/home")},className:`w-full text-left flex items-center gap-3 px-5 py-2 text-sm hover:bg-muted/60 rounded-md transition-colors ${r==="/"||r==="/home"?"text-primary font-medium":"text-foreground
254/80 hover:text-foreground"}`,children:[t.jsx(no,{className:"w-4 h-4 text-primary shrink-0"}),o("products.edge")]}),j.productsBlu&&t.jsxs("button",{onClick:()=>{je(!1),n("/blu")},className:`w-full text-left flex items-center gap-3 px-5 py-2 text-sm hover:bg-muted/60 rounded-md transition-colors ${r==="/blu"?"text-primary font-medium":"text-foreground/80 hover:text-foreground"}`,children:[t.jsx(no,{className:"w-4 h-4 text-primary shrink-0"}),o("products.blu")]})]}),D&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:o("groups.pricing")}),j.pricingEdge&&t.jsxs("button",{onClick:()=>{je(!1),n("/edge-quote")},className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors","data-testid":"mobile-pricing-edge",children:[t.jsx(S0,{className:"w-4 h-4 text-primary shrink-0"}),o("pricing.edge")]}),j.pricingBlu&&t.jsxs("a",{href:i.pricingUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors",onClick:()=>je(!1),"data-testid":"mobile-pricing-blu",children:[t.jsx(S0,{className:"w-4 h-4 text-primary shrink-0"}),o("pricing.blu"),t.jsx(op,{className:"w-3 h-3 ml-auto text-muted-foreground"})]})]}),_&&t.jsxs(t.Fragment,{children:[x.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:o("solutions.byIndustryMobile")}),x.map(ge=>ge.live?t.jsxs("button",{onClick:()=>{je(!1),n(ge.path)},className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors",children:[t.jsx(ge.icon,{className:"w-4 h-4 text-primary shrink-0"}),c[Fw.indexOf(ge)]??ge.label]},ge.label):t.jsxs("div",{className:"flex items-center gap-3 px-5 py-2 text-sm text-foreground/40",children:[t.jsx(ge.icon,{className:"w-4 h-4 shrink-0"}),c[Fw.indexOf(ge)]??ge.label,t.jsx("span",{className:"ml-auto text-xs text-muted-foreground/50",children:o("solutions.soonBadge")})]},ge.label))]}),C.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:o("solutions.byFeatureMobile")}
254),C.map(ge=>t.jsxs("button",{onClick:()=>{je(!1),n(ge.path)},className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors",children:[t.jsx(ge.icon,{className:"w-4 h-4 text-primary shrink-0"}),d[J5.indexOf(ge)]??ge.label]},ge.label))]})]}),A&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:o("groups.resources")}),h6.map(ge=>j[ge.visibilityKey]&&t.jsxs("button",{onClick:()=>{je(!1),n(ge.path)},"data-testid":`mobile-${ge.testIdBase}`,className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors",children:[t.jsx(ge.icon,{className:"w-4 h-4 text-primary shrink-0"}),o(ge.labelKey)]},ge.path))]}),T&&t.jsxs("div",{className:"pt-1 pb-1",children:[t.jsx("p",{className:"px-3 py-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground/60",children:o("groups.support")}),j.supportEdgeAppInstall&&t.jsxs("button",{onClick:()=>{je(!1),n("/support/edge-app-install")},className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors","data-testid":"mobile-support-edge-app-install",children:[t.jsx(Yc,{className:"w-4 h-4 text-primary shrink-0"}),o("support.edgeAppInstall")]}),j.supportBluDocumentation&&t.jsxs("button",{onClick:()=>{je(!1),n("/support/blu-documentation")},className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors","data-testid":"mobile-support-blu-documentation",children:[t.jsx(A5,{className:"w-4 h-4 text-primary shrink-0"}),o("support.bluDocumentation")]}),j.supportSubmitTicket&&t.jsxs("button",{onClick:()=>{je(!1),n("/support/submit-ticket")},className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors","data-testid":"mobile-support-submit-ticket",children:[t.jsx(k0,{className:"w-4 h-4 text-primary shrink-0"}),o("support.submitTicket")]}),j.supportDownloads&&t.jsxs("button",{onClick:()=>{je(!1),n("/support/downloads")},className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors","data-testid":"mobile-support-downloads",children:[t.jsx(ya,{className:"w-4 h-4 text-primary shrink-0"}),o("support.downloads")]}),j.supportSystemHealth&&t.jsxs(t.Fragment,{children:[R&&t.jsx("div",{className:"my-1 mx-3 border-t border-border/50"}),t.jsxs("a",{href:i.systemHealthUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors",onClick:()=>je(!1),"data-testid":"mobile-support-service-health",children:[t.jsx(vc,{className:"w-4 h-4 text-primary shrink-0"}),o("support.systemHealth")]})]})]}),M&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:o("groups.contact")}),j.contactUs&&t.jsxs("button",{className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors",onClick:()=>{je(!1),s?.()},"data-testid":"mobile-contact-us",children:[t.jsx(Qp,{className:"w-4 h-4 text-primary shrink-0"}),o("contact.contactUs")]}),j.contactChat&&t.jsxs("button",{className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors",onClick:()=>{je(!1),X5()},"data-testid":"mobile-chat-with-us",children:[t.jsx(O5,{className:"w-4 h-4 text-primary shrink-0"}),o("contact.chat")]}),j.contactRefer&&t.jsxs("button",{className:"w-full text-left flex items-center gap-3 px-5 py-2 text-sm text-foreground/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors",onClick:()=>{je(!1),n("/refer")},"data-testid":"mobile-refer",children:[t.jsx(ny,{className:"w-4 h-4 text-primary shrink-0"}),o("contact.refer")]})]}),t.jsxs("a",{href:`tel:${i.phoneHref}`,className:"flex items-center gap-2 px-3 py-2 text-sm font-medium text-foreground
254/80 hover:text-foreground hover:bg-muted/60 rounded-md transition-colors",children:[t.jsx(Qp,{className:"w-3.5 h-3.5 text-primary"}),i.phone]}),t.jsxs("div",{className:"px-3 pt-1 pb-2 space-y-2",children:[v&&t.jsx(L,{variant:"outline",className:"w-full",onClick:()=>{je(!1),w()},disabled:b,"data-testid":"mobile-button-live-demo",children:o("buttons.liveDemo")}),a?t.jsx(L,{className:"w-full",onClick:()=>{je(!1),n("/")},"data-testid":"mobile-button-dashboard",children:o("buttons.dashboard")}):t.jsx(L,{className:"w-full",onClick:()=>{je(!1),me()},"data-testid":"mobile-button-login",children:o("buttons.signIn")})]})]})]})})})}const rQ={key:"publicFooter",title:"Footer",group:"Chrome",fields:[{key:"callLabel",label:"Call label (before business hours)",def:"Call Us -"},{key:"emailLabel",label:"Email label",def:"Email Us"},{key:"copyrightPrefix",label:"Copyright prefix (before brand name)",def:"Copyright 2025"},{key:"termsLink",label:"Terms link label",def:"Terms & Conditions"},{key:"privacyLink",label:"Privacy link label",def:"Privacy Policy"}]};function _a(){const e=Er(),{t:s}=rn(rQ);return t.jsx("footer",{className:"bg-[#06060f] border-t border-white/10",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"py-10 grid grid-cols-1 sm:grid-cols-3 gap-8 border-b border-white/10",children:[t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"mt-0.5 shrink-0 text-[var(--brand)]",children:t.jsx(Qp,{className:"w-6 h-6"})}),t.jsxs("div",{children:[t.jsxs("p",{className:"text-xs text-[var(--brand)] font-medium mb-1",children:[s("callLabel")," ",e.businessHours]}),t.jsx("a",{href:`tel:${e.phoneHref}`,className:"text-white font-semibold text-lg leading-tight hover:text-[var(--brand)] transition-colors",children:e.phone})]})]}),t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"mt-0.5 shrink-0 text-[var(--brand)]",children:t.jsx(ql,{className:"w-6 h-6"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-[var(--brand)] font-medium mb-1",children:e.addressLine1}),t.jsx("p",{className:"text-white font-semibold text-lg leading-tight",children:e.addressLine2})]})]}),t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"mt-0.5 shrink-0 text-[var(--brand)]",children:t.jsx(Ja,{className:"w-6 h-6"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-[var(--brand)] font-medium mb-1",children:s("emailLabel")}),t.jsx("a",{href:`mailto:${e.infoEmail}`,className:"text-white font-semibold text-lg leading-tight hover:text-[var(--brand)] transition-colors",children:e.infoEmail})]})]})]}),t.jsxs("div",{className:"py-5 flex flex-col sm:flex-row items-center justify-between gap-3",children:[t.jsxs("p",{className:"text-sm text-white/60 order-2 sm:order-1",children:[s("copyrightPrefix")," ",t.jsx("span",{className:"font-bold text-white/80",children:e.brandName})]}),t.jsxs("div",{className:"flex items-center gap-5 order-1 sm:order-2",children:[t.jsx(Rx,{href:"/terms-conditions",className:"text-sm text-white/60 hover:text-white transition-colors",children:s("termsLink")}),t.jsx(Rx,{href:"/privacy-policy",className:"text-sm text-white/60 hover:text-white transition-colors",children:s("privacyLink")})]})]})]})})}const nQ={key:"landing",title:"Landing / Homepage (icons only)",group:"General",fields:[{key:"hero.trustIcons",label:"Hero trust-point icons",def:["Shield","Cloud","Cctv"].join(`
255`),multiline:!0,icon:!0,help:"One lucide icon name per line, cycled across the hero trust points."},{key:"features.icons",label:"Feature card icons",def:["Building2","Wifi","MonitorPlay","CircleDollarSign","Cloud","Video"].join(`
256`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the feature cards."}]},vm=e=>e.split(`
257`).map(s=>s.trim()).filter(Boolean),sg=e=>e.split("|").map(s=>s.trim()),tge=[uc,pn,no],sge=[xi,jb,Cg,kK,pn,Vi];function p6(e){return e.split("**").map((r,n)=>n%2===1?t.jsx("span",{className:"font-semibold text-foreground",children:r},n):t.jsx("span",{children:r},n))}function rge(e){const s=vm(e);
257if(s.length===0)return null;const[r,n="",a=""]=sg(s[0]);if(!r)return null;const i=s.slice(1).flatMap(o=>{const l=o.match(/^([+\-*])\s*(.+)$/);return l?[{label:l[2],kind:l[1]}]:[]});return{name:r,tagline:n,badge:a,features:i}}function f6(){const[e,s]=u.useState(""),[r,n]=u.useState(""),[a,i]=u.useState(!1),[o,l]=u.useState(!1),[c,d]=u.useState(!1),[h,p]=u.useState(!1),[g,v]=u.useState(""),[b,y]=u.useState(["","","","","",""]),[w,j]=u.useState(""),[x,C]=u.useState(""),[k,S]=u.useState(!1),[_,A]=u.useState(!1),[T,M]=u.useState(!1),[R,D]=u.useState(""),[$,O]=u.useState(""),[q,V]=u.useState(""),[K,G]=u.useState(""),[z,Z]=u.useState(!1),[ee,Q]=u.useState(!1),[Y,oe]=u.useState(null),[he,je]=u.useState(""),[pe,le]=u.useState(""),[ue,fe]=u.useState(""),H=u.useRef([]),[se,me]=u.useState(!1),[ge,be]=u.useState(""),[ce,Pe]=u.useState(!1),[et,$e]=u.useState(!1),[,bt]=Ia(),Ae=Su(),{toast:Be}=Hs(),J=Er(),ae=US.shape.landingHeroCustomButtonUrl.safeParse(J.landingHeroCustomButtonUrl),{tIcons:we}=rn(nQ),Qe=we("hero.trustIcons",tge),ye=we("features.icons",sge),te=Ge=>Ge.split("{productName}").join(J.productName),Ue=(Ge,ft=!1)=>{const He=sg(vm(J.landingScreenshotCaptions)[Ge]??"");return te(ft&&He[1]||He[0]||"")};u.useEffect(()=>{const Ge=new URLSearchParams(window.location.search);if(Ge.get("signin")==="1"&&(d(!0),window.history.replaceState({},"","/")),Ge.get("register")==="1"&&(A(!0),window.history.replaceState({},"","/")),Ge.get("contact")==="1"&&(M(!0),window.history.replaceState({},"","/")),Ge.get("forgot")==="1"){const ft=Ge.get("email");ft&&be(ft),d(!0),me(!0),window.history.replaceState({},"","/")}},[]);function We(Ge,ft){if(ft.length>1&&(ft=ft.slice(-1)),ft&&!/^\d$/.test(ft))return;const He=[...b];He[Ge]=ft,y(He),ft&&Ge<5&&H.current[Ge+1]?.focus()}function St(Ge,ft){ft.key==="Backspace"&&!b[Ge]&&Ge>0&&H.current[Ge-1]?.focus()}function It(Ge){Ge.preventDefault();const ft=Ge.clipboardData.getData("text").replace(/\D/g,"").slice(0,6);if(ft.length===6){const He=ft.split("");y(He),H.current[5]?.focus()}}async function ns(Ge){if(Ge.preventDefault(),!(!e||!r)){l(!0);try{const ft=await fetch("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:e,password:r})});if(!ft.ok){const zt=await ft.json();Be({title:"Login Failed",description:zt.message||"Invalid email or password",variant:"destructive"});return}const He=await ft.json();if(He.requiresMfa){v(He.mfaToken),j(He.mfaMethod),C(He.maskedTarget),p(!0),y(["","","","","",""]),Be({title:"Verification Code Sent",description:`A code has been sent to ${He.maskedTarget}`}),setTimeout(()=>H.current[0]?.focus(),100);return}if(He.requiresMfaSetup){je(He.setupToken),fe(He.maskedTarget||""),oe("code"),y(["","","","","",""]),Be({title:"Verification Code Sent",description:`A code has been sent to ${He.maskedTarget} to set up two-factor authentication.`}),setTimeout(()=>H.current[0]?.focus(),100);return}Ae.removeQueries({predicate:zt=>zt.queryKey[0]!=="/api/auth/user"}),await Ae.invalidateQueries({queryKey:["/api/auth/user"]}),bt("/")}catch{Be({title:"Connection Error",description:"Unable to connect to the server",variant:"destructive"})}finally{l(!1)}}}async function dt(Ge){Ge.preventDefault();const ft=b.join("");if(ft.length===6){l(!0);try{const He=await fetch("/api/login/mfa-verify",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({mfaToken:g,code:ft,rememberDevice:k})});if(!He.ok){const zt=await He.json();if(He.status===401){Be({title:"Session Expired",description:"Please sign in again.",variant:"destructive"}),pt();return}Be({title:"Verification Failed",description:zt.message||"Invalid code",variant:"destructive"}),y(["","","","","",""]),H.current[0]?.focus();return}Ae.removeQueries({predicate:zt=>zt.queryKey[0]!=="/api/auth/user"}),await Ae.invalidateQueries({queryKey:["/api/auth/user"]}),bt("/")}catch{Be({title:"Connection Error",description:"Unable to connect to the server",variant:"destructive"})}finally{l(!1)}}}async function Qt(){l(!0);try{const Ge=await fetch("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:e,password:r})});if(!Ge.ok){Be({title:"Error",description:"Could not resend code. Please try again.",variant:"destructive"}),pt();return}const ft=await Ge.json();ft.requiresMfa&&(v(ft.mfaToken),y(["","","","","",""]),Be({title:"Code Resent",description:`A new code has been sent to ${ft.maskedTarget}`}),setTimeout(()=>
257H.current[0]?.focus(),100))}catch{Be({title:"Connection Error",description:"Unable to connect to the server",variant:"destructive"})}finally{l(!1)}}async function Re(Ge){if(Ge.preventDefault(),!!ge){$e(!0);try{await fetch("/api/auth/forgot-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:ge})}),Pe(!0)}catch{Be({title:"Error",description:"Could not send reset email. Please try again.",variant:"destructive"})}finally{$e(!1)}}}function pt(){p(!1),v(""),y(["","","","","",""]),j(""),C(""),S(!1),oe(null),je(""),le(""),fe(""),me(!1),be(""),Pe(!1)}async function Ft(){l(!0);try{const Ge=await fetch("/api/login/mfa-setup/send-code",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({setupToken:he})});if(!Ge.ok){const He=await Ge.json();if(Ge.status===401){Be({title:"Session Expired",description:"Please sign in again.",variant:"destructive"}),pt();return}Be({title:"Error",description:He.message||"Failed to resend code",variant:"destructive"});return}const ft=await Ge.json();y(["","","","","",""]),Be({title:"Code Resent",description:`A new code has been sent to ${ft.maskedTarget}`}),setTimeout(()=>H.current[0]?.focus(),100)}catch{Be({title:"Connection Error",description:"Unable to connect to the server",variant:"destructive"})}finally{l(!1)}}async function Es(Ge){Ge.preventDefault();const ft=b.join("");if(ft.length===6){l(!0);try{const He=await fetch("/api/login/mfa-setup/verify",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({setupToken:he,code:ft,rememberDevice:k})});if(!He.ok){const zt=await He.json();if(He.status===401){Be({title:"Session Expired",description:"Please sign in again.",variant:"destructive"}),pt();return}Be({title:"Verification Failed",description:zt.message||"Invalid code",variant:"destructive"}),y(["","","","","",""]),H.current[0]?.focus();return}Ae.removeQueries({predicate:zt=>zt.queryKey[0]!=="/api/auth/user"}),await Ae.invalidateQueries({queryKey:["/api/auth/user"]}),bt("/")}catch{Be({title:"Connection Error",description:"Unable to connect to the server",variant:"destructive"})}finally{l(!1)}}}return t.jsxs("div",{className:"min-h-screen bg-background",children:[_&&t.jsx(sl,{onClose:()=>A(!1)}),t.jsx(Ys,{open:T,onOpenChange:Ge=>{M(Ge),Ge||(D(""),O(""),V(""),G(""),Q(!1))},children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Contact Us"}),t.jsx(cr,{children:"Send us a message and we'll get back to you shortly."})]}),ee?t.jsxs("div",{className:"py-8 flex flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/10 flex items-center justify-center",children:t.jsx(Ja,{className:"w-6 h-6 text-green-500"})}),t.jsx("p",{className:"font-semibold text-foreground",children:"Message sent!"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["We'll be in touch at ",t.jsx("span",{className:"text-foreground",children:$}),"."]}),t.jsx(L,{variant:"outline",className:"mt-2",onClick:()=>M(!1),children:"Close"})]}):t.jsxs("form",{className:"space-y-4",onSubmit:async Ge=>{Ge.preventDefault(),Z(!0);try{const ft=await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:R,email:$,phone:q,message:K})});if(ft.ok)Q(!0);else{const He=await ft.json().catch(()=>({}));Be({title:"Failed to send",description:He.message||"Please try again.",variant:"destructive"})}}catch{Be({title:"Failed to send",description:"Network error. Please try again.",variant:"destructive"})}finally{Z(!1)}},children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"contact-name",children:"Name"}),t.jsx(ke,{id:"contact-name","data-testid":"input-contact-name",placeholder:"Your name",value:R,onChange:Ge=>D(Ge.target.value),required:!0})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"contact-email",children:"Email"}),t.jsx(ke,{id:"contact-email",type:"email","data-testid":"input-contact-email",placeholder:"[email protected]",value:$,onChange:Ge=>O(Ge.target.value),required:!0})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"contact-phone",children:"Phone Number"}),t.jsx(ke,{id:"contact-phone",type:"tel","data-testid":"input-contact-phone",placeholder:"+1 (555) 000-0000",value:q,onChange:Ge=>V(Ge.target.value)})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"contact-message",children:"Message"}),t.jsx(Nn,{id:"contact-message","data-testid":"input-contact-message",placeholder:"How can we help?",rows:4,value:K,onChange:Ge=>G(Ge.target.value),required:!0})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:z,"data-testid":"button-contact-send",children:z?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Sending…"]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),"Send Message"]})})]})]})}),t.jsx(pa,{onSignIn:()=>d(!0),onContact:()=>M(!0)}),c&&t.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm",children:t.jsx(ut,{className:"w-full max-w-md mx-4",children:t.jsxs(mt,{className:"p-6 space-y-6",children:[t.jsx("div",{className:"flex justify-end -mt-1 -mr-1",children:t.jsx(L,{size:"icon",variant:"ghost",onClick:()=>{d(!1),pt()},"data-testid":"button-close-login",children:t.jsx(va,{className:"w-4 h-4"})})}),!h&&!Y&&!se?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("img",{src:J.appEmblemUrl||Tm,alt:J.brandName,className:"w-14 h-14 object-contain mx-auto"}),t.jsxs("h2",{className:"text-xl font-semibold text-foreground",children:["Sign in to ",J.productName]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter your credentials to access the dashboard"})]}),t.jsxs("form",{onSubmit:ns,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:"login-email",children:"Email"}),t.jsx(ke,{id:"login-email",type:"email",placeholder:"[email protected]",value:e,onCh
257ange:Ge=>s(Ge.target.value),required:!0,autoComplete:"email","data-testid":"input-email"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(re,{htmlFor:"login-password",children:"Password"}),t.jsx("button",{type:"button",onClick:()=>{be(e),me(!0)},className:"text-xs text-primary hover:underline","data-testid":"button-forgot-password",children:"Forgot password?"})]}),t.jsxs("div",{className:"relative",children:[t.jsx(ke,{id:"login-password",type:a?"text":"password",placeholder:"Enter your password",value:r,onChange:Ge=>n(Ge.target.value),required:!0,autoComplete:"current-password",className:"pr-10","data-testid":"input-password"}),t.jsx("button",{type:"button",onClick:()=>i(!a),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground","data-testid":"button-toggle-password",children:a?t.jsx(Gp,{className:"w-4 h-4"}):t.jsx(Xr,{className:"w-4 h-4"})})]})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:o,"data-testid":"button-submit-login",children:o?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):"Sign In"})]})]}):!h&&!Y&&se?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("img",{src:J.appEmblemUrl||Tm,alt:J.brandName,className:"w-14 h-14 object-contain mx-auto"}),t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Reset your password"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:ce?"Check your email for a reset link. It expires in 1 hour.":"Enter your email and we'll send you a reset link."})]}),ce?t.jsx("div",{className:"space-y-4",children:t.jsx(L,{className:"w-full",variant:"outline",onClick:()=>{me(!1),Pe(!1),be("")},"data-testid":"button-back-to-login-sent",children:"Back to Sign In"})}):t.jsxs("form",{onSubmit:Re,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:"forgot-email",children:"Email"}),t.jsx(ke,{id:"forgot-email",type:"email",placeholder:"[email protected]",value:ge,onChange:Ge=>be(Ge.target.value),required:!0,autoComplete:"email","data-testid":"input-forgot-email"})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:et,"data-testid":"button-send-reset",children:et?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):"Send Reset Link"}),t.jsx("button",{type:"button",onClick:()=>me(!1),className:"w-full text-sm text-muted-foreground hover:text-foreground text-center","data-testid":"button-back-to-login",children:"Back to Sign In"})]})]}):Y?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("img",{src:J.appEmblemUrl||Tm,alt:J.brandName,className:"w-14 h-14 object-contain mx-auto"}),t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Set Up Two-Factor Authentication"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Your organization requires 2FA. Enter the 6-digit code sent to ",ue,"."]})]}),t.jsxs("form",{onSubmit:Es,className:"space-y-4",children:[t.jsx("div",{className:"flex justify-center gap-2",onPaste:It,children:b.map((Ge,ft)=>t.jsx(ke,{ref:He=>{H.current[ft]=He},type:"text",inputMode:"numeric",maxLength:1,value:Ge,onChange:He=>We(ft,He.target.value),onKeyDown:He=>St(ft,He),className:"w-11 h-12 text-center text-lg font-mono","data-testid":`input-setup-code-${ft}`},ft))}),t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(On,{id:"remember-device-setup",checked:k,onCheckedChange:Ge=>S(Ge===!0),"data-testid":"checkbox-remember-device-setup"}),t.jsx(re,{htmlFor:"remember-device-setup",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this device for 30 days"})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:o||b.join("").length!==6,"data-testid":"button-verify-setup-code",children:o?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):"Verify & Sign In"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs(L,{type:"button",variant:"ghost",onClick:pt,"data-testid":"button-back-from-setup",children:[t.jsx(Wi,{className:"w-4 h-4 mr-2"}),"Back"]}),t.jsx(L,{type:"button",variant:"ghost",onClick:Ft,disabled:o,"data-testid":"button-resend-setup-code",children:"Resend Code"})]})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("img",{src:J.appEmblemUrl||Tm,alt:J.brandName,className:"w-14 h-14 object-contain mx-auto"}),t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Two-Factor Authentication"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Enter the 6-digit code sent to ",x]})]}),t.jsxs("form",{onSubmit:dt,className:"space-y-4",children:[t.jsx("div",{className:"flex justify-center gap-2",onPaste:It,children:b.map((Ge,ft)=>t.jsx(ke,{ref:He=>{H.current[ft]=He},type:"text",inputMode:"numeric",maxLength:1,value:Ge,onChange:He=>We(ft,He.target.value),onKeyDown:He=>St(ft,He),className:"w-11 h-12 text-center text-lg font-mono","data-testid":`input-mfa-code-${ft}`},ft))}),t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsx(On,{id:"remember-device",checked:k,onCheckedChange:Ge=>S(Ge===!0),"data-testid":"checkbox-remember-device"}),t.jsx(re,{htmlFor:"remember-device",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this device for 30 days"})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:o||b.join("").length!==6,"data-testid":"button-verify-mfa",children:o?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):"Verify"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs(L,{type:"button",variant:"ghost",onClick:pt,"data-testid":"button-back-to-login",children:[t.jsx(Wi,{className:"w-4 h-4 mr-2"}),"Back"]}),t.jsx(L,{type:"button",variant:"ghost",onClick:Qt,disabled:o,"data-testid":"button-resend-code",children:"Resend Code"})]})]})]})]})})}),J.landingShowHero!=="false"&&t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-7xl mx-auto",children:t.jsxs("div",{className:"flex flex-col items-center text-center space-y-8",children:[t.jsxs("div",{className:"space-y-4",children:[J.landingHeroBadge&&t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:te(J.landingHeroBadge)}),t.jsxs("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight max-w-3xl",children:[te(J.landingHeroHeading),J.landingHeroHeadingHighlight&&t.jsxs("span",{className:"text-primary",children:[" ",te(J.landingHeroHeadingHighlight)," "]})]}),t.jsxs("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto text-center",children:[te(J.landingHeroSubheading),t.jsx("br",{}),t.jsx("br",{})]})]}),t.jsx(rpe,{}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[J.landingHeroCustomButtonEnabled==="true"&&ae.success&&ae.data&&t.jsx(L,{size:"lg",variant:"outline",asChild:!0,children:t.jsx("a",{href:ae.data,target:"_blank",rel:"noopener noreferrer","data-testid":"button-hero-custom",children:te(J.landingHeroCustomButtonText)})}),t.jsx(L,{size:"lg",onClick:()=>A(!0),"data-testid":"button-get-started",children:te(J.landingHeroPrimaryButton)}),J.landingHeroSecondaryButtonUrl?t.jsx(L,{size:"lg",variant:"outline",asChild:!0,children:t.jsx("a",{href:J.landingHeroSecondaryButtonUrl,target:"_blank",rel:"noopener noreferrer","data-testid":"button-learn-more",children:te(J.landingHeroSecondaryButton)})}):t.jsx(L,{size:"lg",variant:"outline","data-testid":"button-learn-more",onClick:()=>M(!0),children:te(J.landingHeroSecondaryButton)}),J.navContactChat!=="false"&&t.jsxs(L,{size:"lg",variant:"outline","data-testid":"button-chat-with-us",onClick:X5,children:[t.jsx(O5,{className:"w-4 h-4 mr-2"}),te(J.landingHeroChatButton)]})]}),t.jsx("div",{className:"flex justify-center items-center gap-6 text-sm text-muted-foreground",children:vm(J.landingHeroTrustPoints).map((Ge,ft)=>{const He=Qe(ft);return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(He,{className:"w-4 h-4 text-primary"}),t.jsx("span",{children:te(Ge)})]},Ge)})}),J.imgLandingHeroFirearmShow!=="false"&&t.jsxs("div",{className:"relative flex items-center justify-center w-full mt-2",children:[t.jsx("div",{className:"absolute inset-0 blur-3xl op
257acity-20 pointer-events-none",style:{background:"radial-gradient(ellipse at 50% 50%, #0DAAEC 0%, transparent 70%)"}}),t.jsx("img",{src:J.imgLandingHeroFirearm||QY,alt:"AI Search example finding a person with a firearm",className:"relative rounded-2xl w-full max-w-3xl",style:{display:"block",boxShadow:"0 0 0 1px rgba(13,170,236,0.2), 0 0 16px 4px rgba(13,170,236,0.1), 0 16px 40px rgba(0,0,0,0.3)"},"data-testid":"img-ai-search-firearm"})]}),J.imgLandingHeroPhoneShow!=="false"&&t.jsxs("div",{className:"relative flex items-center justify-center w-full mt-4",children:[t.jsx("div",{className:"absolute inset-0 blur-3xl opacity-20 pointer-events-none",style:{background:"radial-gradient(ellipse at 50% 60%, #0DAAEC 0%, transparent 70%)"}}),t.jsx("img",{src:J.imgLandingHeroPhone||Lfe,alt:`${J.productName} dashboard on mobile`,className:"relative rounded-3xl",style:{width:"min(420px, 100%)",display:"block",boxShadow:"0 0 0 1px rgba(13,170,236,0.2), 0 0 16px 4px rgba(13,170,236,0.1), 0 16px 40px rgba(0,0,0,0.3)",imageRendering:"auto"}})]})]})})}),J.showTestimonials!=="false"&&t.jsxs(t.Fragment,{children:[J.landingShowTrustedBy!=="false"&&t.jsxs("section",{className:"py-10 border-y border-border/40 overflow-hidden",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-8",children:te(J.landingTrustedByHeading)}),t.jsx("div",{className:"overflow-hidden w-full",children:t.jsx("div",{className:"marquee-track",children:vm(J.landingTrustedByNames).map((Ge,ft)=>t.jsx("span",{className:"shrink-0 mx-12 text-foreground/50 font-semibold text-sm tracking-widest uppercase whitespace-nowrap hover:text-foreground/80 transition-colors cursor-default",children:Ge},ft))})})]}),J.landingShowTestimonials!=="false"&&t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-10",children:te(J.landingTestimonialsHeading)}),t.jsx("div",{className:"grid md:grid-cols-3 gap-6",children:vm(J.landingTestimonials).map(Ge=>{const[ft="",He="",zt="",fs=""]=sg(Ge).map(te);return{quote:ft,name:He,role:zt,company:fs}}).map(Ge=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-6 flex flex-col gap-4",children:[t.jsx("div",{className:"text-2xl text-primary/60 font-serif leading-none",children:'"'}),t.jsxs("p",{className:"text-sm text-muted-foreground leading-relaxed flex-1",children:['"',Ge.quote,'"']}),t.jsxs("div",{className:"border-t border-border/40 pt-4",children:[t.jsx("p",{className:"font-semibold text-foreground text-sm",children:Ge.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[Ge.role," · ",Ge.company]})]})]},Ge.name))})]})})]}),J.landingShowFeatureGrid!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:"text-center space-y-4 mb-16",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:te(J.landingFeaturesHeading)}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:te(J.landingFeaturesSubheading)})]}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6",children:vm(J.landingFeatureCards).map((Ge,ft)=>{const[He="",zt=""]=sg(Ge).map(te);return{icon:ye(ft),title:He,description:zt}}).map((Ge,ft)=>t.jsx(ut,{className:"bg-card border-card-border hover-elevate",children:t.jsxs(mt,{className:"p-6 space-y-4",children:[t.jsx("div",{className:"w-12 h-12 rounded-lg bg-primary/10 flex items-center justify-center",children:t.jsx(Ge.icon,{className:"w-6 h-6 text-primary"})}),t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:Ge.title}),t.jsx("p",{className:"text-muted-foreground",children:Ge.description})]})},ft))})]})}),J.landingShowScreenshots!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground mb-4",children:te(J.landingScreenshotsHeading)}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:te(J.landingScreenshotsSubheading)})]}),t.jsxs("div",{className:"hidden sm:flex items-end justify-center gap-6 lg:gap-10 mb-10",children:[J.imgLandingEventRetrievalShow!=="false"&&t.jsxs("div",{className:"flex flex-col items-center gap-4 flex-none w-[28%] max-w-[220px]",children:[t.jsx("img",{src:J.imgLandingEventRetrieval||l6,alt:"Event Retrieval",className:"w-full rounded-2xl shadow-2xl border border-white/10 object-cover"}),t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:Ue(0)})]}),J.imgLandingAiFeaturesShow!=="false"&&t.jsxs("div",{className:"flex flex-col items-center gap-4 flex-none w-[28%] max-w-[220px]",children:[t.jsx("img",{src:J.imgLandingAiFeatures||d6,alt:"AI Features",className:"w-full rounded-2xl shadow-2xl border border-white/10 object-cover"}),t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:Ue(1)})]}),J.imgLandingNotificationsShow!=="false"&&t.jsxs("div",{className:"flex flex-col items-center gap-4 flex-none w-[28%] max-w-[220px]",children:[t.jsx("img",{src:J.imgLandingNotifications||Q5,alt:"Notifications",className:"w-full rounded-2xl shadow-2xl border border-white/10 object-cover"}),t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:Ue(2)})]})]}),J.imgLandingLiveViewShow!=="false"&&t.jsxs("div",{className:"hidden sm:flex flex-col items-center gap-4",children:[t.jsx("img",{src:J.imgLandingLiveView||c6,alt:"Edge+ Live View",className:"w-full max-w-3xl rounded-2xl shadow-2xl border border-white/10 object-cover"}),t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:Ue(3)})]}),t.jsxs("div",{className:"sm:hidden flex flex-col items-center gap-10",children:[J.imgLandingLiveViewShow!=="false"&&t.jsxs("div",{className:"flex flex-col items-center gap-3 w-full max-w-xs",children:[t.jsx("img",{src:J.imgLandingLiveView||c6,alt:"Edge+ Live View",className:"w-full rounded-2xl shadow-xl border border-white/10"}),t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:Ue(3,!0)})]}),t.jsxs("div",{className:"flex gap-4 w-full justify-center",children:[J.imgLandingEventRetrievalShow!=="false"&&t.jsxs("div",{className:"flex flex-col items-center gap-3 w-[30%]",children:[t.jsx("img",{src:J.imgLandingEventRetrieval||l6,alt:"Event Retrieval",className:"w-full rounded-2xl shadow-xl border border-white/10"}),t.jsx("p",{className:"text-xs font-medium text-muted-foreground text-center",children:Ue(0,!0)})]}),J.imgLandingAiFeaturesShow!=="false"&&t.jsxs("div",{className:"flex flex-col items-center gap-3 w-[30%]",children:[t.jsx("img",{src:J.imgLandingAiFeatures||d6,alt:"AI Features",className:"w-full rounded-2xl shadow-xl border border-white/10"}),t.jsx("p",{className:"text-xs font-medium text-muted-foreground text-center",children:Ue(1,!0)})]}),J.imgLandingNotificationsShow!=="false"&&t.jsxs("div",{className:"flex flex-col items-center gap-3 w-[30%]",children:[t.jsx("img",{src:J.imgLandingNotifications||Q5,alt:"Notifications",className:"w-full rounded-2xl shadow-xl border border-white/10"}),t.jsx("p",{className:"text-xs font-medium text-muted-foreground text-center",children:Ue(2,!0)})]})]})]})]})}),J.landingShowAiSearch!=="false"&&(()=>{const Ge=vm(J.landingAiSearchCards).map(He=>{const[zt="",fs=""]=sg(He).map(te);return{title:zt,desc:fs}}
257),ft=[J.imgLandingAiTextSearchShow!=="false"&&t.jsx("div",{className:"w-full aspect-[16/10] rounded-2xl shadow-2xl border border-white/10 overflow-hidden",children:t.jsx("img",{src:J.imgLandingAiTextSearch||Ufe,alt:Ge[0]?.title||"AI Text Search",className:"w-full h-full object-cover","data-testid":"img-ai-text-search"})},"text"),J.imgLandingVisualSearchShow!=="false"&&t.jsx("div",{className:"w-full aspect-[16/10] rounded-2xl shadow-2xl border border-white/10 overflow-hidden",children:t.jsx("img",{src:J.imgLandingVisualSearch||XY,alt:Ge[1]?.title||"Visual Search",className:"w-full h-full object-cover","data-testid":"img-ai-visual-search"})},"visual")];return t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500 mb-3",children:te(J.landingAiSearchEyebrow)}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground mb-4",children:te(J.landingAiSearchHeading)}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:te(J.landingAiSearchSubheading)})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-8 lg:gap-12",children:Ge.map((He,zt)=>t.jsxs("div",{className:"flex flex-col items-center gap-5",children:[ft[zt],t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:He.title}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-sm mx-auto",children:He.desc})]})]},zt))})]})})})(),J.landingShowFacesPeople!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-6xl mx-auto",children:t.jsxs("div",{className:"flex flex-col lg:flex-row items-center gap-12 lg:gap-16",children:[J.imgLandingFacesPeopleShow!=="false"&&t.jsx("div",{className:"flex-1 w-full order-2 lg:order-1",children:t.jsx("div",{className:"w-full rounded-2xl shadow-2xl border border-white/10 overflow-hidden",children:t.jsx("img",{src:J.imgLandingFacesPeople||ZY,alt:"Faces & People recognition library",className:"w-full h-full object-cover","data-testid":"img-faces-people"})})}),t.jsxs("div",{className:"flex-1 text-center lg:text-left order-1 lg:order-2",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground mb-5",children:te(J.landingFacesHeading)}),t.jsx("p",{className:"text-lg text-muted-foreground mb-8 max-w-lg mx-auto lg:mx-0",children:te(J.landingFacesParagraph)}),t.jsx("div",{className:"space-y-3 text-left max-w-lg mx-auto lg:mx-0 mb-8",children:vm(J.landingFacesBullets).map(te).map(Ge=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-blue-500 shrink-0 mt-1"}),t.jsx("span",{className:"text-sm text-foreground/80",children:Ge})]},Ge))}),t.jsx(Rx,{href:"/solutions/features/faces-people",children:t.jsx(L,{variant:"outline","data-testid":"button-faces-people-learn-more",children:te(J.landingFacesButton)})})]})]})})}),J.landingShowEasySetup!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-black/20",children:t.jsx("div",{className:"max-w-6xl mx-auto",children:t.jsxs("div",{className:"flex flex-col lg:flex-row items-center gap-12 lg:gap-20",children:[t.jsx("div",{className:"flex-1 flex justify-center lg:justify-end order-1 lg:order-none",children:t.jsxs("div",{className:"relative w-full max-w-md pb-10",children:[J.imgLandingEdgeDeviceShow!=="false"&&t.jsx("div",{className:"bg-black rounded-3xl overflow-hidden w-full",children:t.jsx("img",{src:J.imgLandingEdgeDevice||Ffe,alt:`${J.productName} Device`,className:"w-full h-auto"})}),J.imgLandingCameraDiscoveryShow!=="false"&&t.jsxs("div",{className:"absolute -bottom-6 -right-4 sm:-right-6 w-44 sm:w-48 lg:w-52",children:[t.jsx("img",{src:J.imgLandingCameraDiscovery||Bfe,alt:"Camera Discovery",className:"w-full rounded-2xl shadow-2xl border border-white/10"}),t.jsx("p",{className:"text-xs font-medium text-muted-foreground text-center mt-1.5",children:te(J.landingSetupImageCaption)})]})]})}),t.jsxs("div",{className:"flex-1 text-center lg:text-left",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500 mb-3",children:te(J.landingSetupEyebrow)}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground mb-5",children:te(J.landingSetupHeading)}),t.jsx("p",{className:"text-lg text-muted-foreground mb-10 max-w-lg mx-auto lg:mx-0",children:te(J.landingSetupParagraph)}),t.jsx("div",{className:"space-y-4 text-left",children:vm(J.landingSetupSteps).map((Ge,ft)=>{const[He="",zt=""]=sg(Ge).map(te);return{n:String(ft+1).padStart(2,"0"),title:He,desc:zt}}).map(Ge=>t.jsxs("div",{className:"flex items-start gap-4 p-4 rounded-xl bg-white/5 border border-white/10",children:[t.jsx("span",{className:"text-xl font-bold text-blue-500/70 tabular-nums w-10 shrink-0 pt-0.5",children:Ge.n}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground text-sm mb-1",children:Ge.title}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:Ge.desc})]})]},Ge.n))})]})]})})}),J.landingShowCloudStorage!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-6xl mx-auto",children:t.jsxs("div",{className:"flex flex-col lg:flex-row items-center gap-12 lg:gap-20",children:[t.jsxs("div",{className:"flex-1 text-center lg:text-left order-2 lg:order-none",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500 mb-3",children:te(J.landingCloudEyebrow)}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground mb-5",children:te(J.landingCloudHeading)}),t.jsx("p",{className:"text-lg text-muted-foreground mb-10 max-w-lg mx-auto lg:mx-0",children:te(J.landingCloudParagraph)}),t.jsx("div",{className:"space-y-4 text-left",children:vm(J.landingCloudPoints).map((Ge,ft)=>{const[He="",zt=""]=sg(Ge).map(te);return{icon:[t.jsx(GY,{className:"w-5 h-5 text-primary mt-0.5"},"gc"),"⚠️","⚖️"][ft%3],title:He,desc:zt}}).map(Ge=>t.jsxs("div",{className:"flex items-start gap-4 p-4 rounded-xl bg-white/5 border border-white/10",children:[t.jsx("span",{className:"text-xl shrink-0 pt-0.5",children:Ge.icon}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground text-sm mb-1",children:Ge.title}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:Ge.desc})]})]},Ge.title))}),t.jsx("div",{className:"flex flex-wrap gap-8 pt-6 justify-center lg:justify-start",children:vm(J.landingCloudStats).map(Ge=>sg(Ge).map(te)).map(([Ge,ft])=>t.jsxs("div",{children:[t.jsx("p",{className:"text-2xl font-bold text-primary",children:Ge}),t.jsx("p",{className:"text-sm text-muted-foreground",children:ft})]},ft))})]}),J.imgLandingCloudStorageShow!=="false"&&t.jsx("div",{className:"flex-1 flex justify-center lg:justify-start order-1 lg:order-none",children:t.jsx("div",{className:"w-56 sm:w-64 lg:w-72",children:t.jsx("img",{src:J.imgLandingCloudStorage||YY,alt:"Cloud Storage Settings",className:"w-full rounded-3xl shadow-2xl border border-white/10"})})})]})})}),J.landingShowDeployment!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/20",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center space-y-4 mb-14",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:te(J.landingDeployEyebrow)}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:te(J.landingDeployHeading)}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:te(J.landingDeploySubheading)})]}),t.jsx("div",{className:"grid md:grid-cols-3 gap-6 items-stretch",children:[J.landingDeployPlan1,J.landingDeployPlan2,J.landingDeployPlan3].map(Ge=>rge(te(Ge))).filter(Ge=>Ge!==null).map((Ge,ft)=>Ge.badge?t.jsxs("div",{className:"rounded-2xl border-2 border-blue-500 bg-card p-6 flex flex-col gap-5 relative",children:[t.jsx("span",{className:"absolute top-4 right-4 text-[10px] font-bold uppercase tracking-widest bg-blue-500 text-white px-2.5 py-1 rounded-full",children:Ge.badge}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-xl font-bold text-blue-400 mb-2",children:Ge.name}),t.jsx("p",{className:"text-sm text-muted-foreground",children:Ge.tagline})]}),t.jsx("ul",{className:"space-y-3 flex-1",children:Ge.features.map(He=>t.jsxs("li",{className:`flex items-start gap-3 text-sm ${He.kind==="-"?"text-muted-foreground
257/40":He.kind==="*"?"text-foreground font-semibold":"text-foreground"}`,children:[He.kind==="-"?t.jsx(rf,{className:"w-4 h-4 text-red-400/50 shrink-0 mt-0.5"}):t.jsx(ar,{className:"w-4 h-4 text-blue-400 shrink-0 mt-0.5"}),He.label]},He.label))})]},ft):t.jsxs("div",{className:"rounded-2xl border border-border/60 bg-card p-6 flex flex-col gap-5",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-xl font-bold text-foreground mb-2",children:Ge.name}),t.jsx("p",{className:"text-sm text-muted-foreground",children:Ge.tagline})]}),t.jsx("ul",{className:"space-y-3 flex-1",children:Ge.features.map(He=>t.jsxs("li",{className:`flex items-start gap-3 text-sm ${He.kind==="-"?"text-muted-foreground/40":He.kind==="*"?"text-foreground font-semibold":"text-foreground"}`,children:[He.kind==="-"?t.jsx(rf,{className:"w-4 h-4 text-red-400/50 shrink-0 mt-0.5"}):t.jsx(ar,{className:"w-4 h-4 text-green-500 shrink-0 mt-0.5"}),He.label]},He.label))})]},ft))}),t.jsx("div",{className:"mt-12 rounded-2xl border border-border/60 bg-card p-6 sm:p-8","data-testid":"section-premium-smart-alerts",children:t.jsxs("div",{className:"grid md:grid-cols-2 gap-8 items-center",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsx("span",{className:"inline-block text-[10px] font-bold uppercase tracking-widest bg-blue-500 text-white px-2.5 py-1 rounded-full",children:te(J.landingAlertsBadge)}),t.jsx("h3",{className:"text-2xl sm:text-3xl font-bold text-foreground",children:te(J.landingAlertsHeading)}),t.jsx("p",{className:"text-muted-foreground",children:p6(te(J.landingAlertsPara1))}),t.jsx("p",{className:"text-muted-foreground",children:p6(te(J.landingAlertsPara2))}),t.jsx("ul",{className:"space-y-2",children:vm(J.landingAlertsExamples).map(te).map(Ge=>t.jsxs("li",{className:"flex items-start gap-3 text-sm text-foreground",children:[t.jsx(ar,{className:"w-4 h-4 text-blue-400 shrink-0 mt-0.5"}),Ge]},Ge))})]}),J.imgLandingSmartAlertShow!=="false"&&t.jsx("div",{className:"flex justify-center",children:t.jsx("img",{src:J.imgLandingSmartAlert||$fe,alt:"Creating a Premium Smart Alert rule named Retail Theft Alert",className:"rounded-xl border border-border/60 shadow-lg max-w-full h-auto","data-testid":"img-smart-alert-rule"})})]})})]})}),J.landingShowCta!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:te(J.landingCtaHeading)}),t.jsx("p",{className:"text-lg text-muted-foreground",children:te(J.landingCtaSubheading)}),t.jsx(L,{size:"lg",onClick:()=>A(!0),"data-testid":"button-cta-signup",children:te(J.landingCtaButton)})]})}),t.jsx(_a,{})]})}const aQ={key:"getStarted",title:"Get Started",group:"General",fields:[{key:"hero.badge",label:"Hero badge",def:"All-In-One VMS with Hybrid Storage & AI"},{key:"hero.heading",label:"Hero heading",def:`Cloud Video Surveillance With
258AI`,multiline:!0,help:"Two parts: main heading text and the highlighted word. One per line."},{key:"hero.subheading",label:"Hero subheading",def:"Have a question or want to see what {brandName} can do for your sites? Send us a message and our team will get back to you shortly.",multiline:!0},{key:"highlights.items",label:"Highlight bullets",def:["Works with any camera — replace or keep your recorder.","Local storage and affordable cloud retention options.","Free AI included, with natural language event search.","No subscription, one-time purchase options available."].join(`
259`),multiline:!0,help:"One highlight per line."},{key:"trustBadges.items",label:"Trust badges",def:["Secure Connections","Cloud Accessible","Works With Any Camera","Multi-Site Live View"].join(`
260`),multiline:!0,help:"One badge label per line. Icons are fixed per position."},{key:"form.heading",label:"Form heading",def:"Contact Us"},{key:"form.subheading",label:"Form subheading",def:"Send us a message and we'll get back to you shortly."},{key:"form.sentTitle",label:"Form sent title",def:"Message sent!"},{key:"form.sentBodyPrefix",label:"Form sent body prefix",def:"We'll be in touch at "},{key:"form.sentBodySuffix",label:"Form sent body suffix",def:"."},{key:"form.sendAnotherButton",label:"Send another button",def:"Send another message"},{key:"form.nameLabel",label:"Name label",def:"Name"},{key:"form.namePlaceholder",label:"Name placeholder",def:"Your name"},{key:"form.emailLabel",label:"Email label",def:"Email"},{key:"form.emailPlaceholder",label:"Email placeholder",def:"[email protected]"},{key:"form.phoneLabel",label:"Phone label",def:"Phone Number"},{key:"form.phonePlaceholder",label:"Phone placeholder",def:"+1 (555) 000-0000"},{key:"form.messageLabel",label:"Message label",def:"Message"},{key:"form.messagePlaceholder",label:"Message placeholder",def:"How can we help?"},{key:"form.sendButton",label:"Send button",def:"Send Message"},{key:"form.sendingButton",label:"Sending button",def:"Sending…"}]},g6=[uc,pn,no,Vi];function x6(){const{toast:e}
260=Hs(),{t:s,tLines:r}=rn(aQ),[,n]=Ia(),a=r("hero.heading"),[i,o]=u.useState(""),[l,c]=u.useState(""),[d,h]=u.useState(""),[p,g]=u.useState(""),[v,b]=u.useState(!1),[y,w]=u.useState(!1);return t.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[t.jsx(pa,{onSignIn:()=>n("/?signin=1")}),t.jsx("main",{className:"flex-1 pt-28 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto grid grid-cols-1 lg:grid-cols-2 gap-12 items-start",children:[t.jsxs("div",{className:"space-y-8 lg:pt-6",children:[t.jsxs("div",{className:"space-y-4",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:[t.jsx(Do,{className:"w-4 h-4"}),s("hero.badge")]}),t.jsxs("h1",{className:"text-4xl sm:text-5xl font-bold text-foreground leading-tight","data-testid":"text-get-started-headline",children:[a[0],t.jsxs("span",{className:"text-primary",children:[" ",a[1]]})]}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-xl","data-testid":"text-get-started-subtext",children:s("hero.subheading")})]}),t.jsx("ul",{className:"space-y-3",children:r("highlights.items").map((j,x)=>t.jsxs("li",{className:"flex items-start gap-3 text-foreground","data-testid":`text-highlight-${x}`,children:[t.jsx(ar,{className:"w-5 h-5 text-primary shrink-0 mt-0.5"}),t.jsx("span",{className:"text-sm sm:text-base",children:j})]},x))}),t.jsx("div",{className:"flex flex-wrap items-center gap-6 text-sm text-muted-foreground pt-2",children:r("trustBadges.items").map((j,x)=>{const C=g6[x%g6.length];return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(C,{className:"w-4 h-4 text-primary"}),t.jsx("span",{children:j})]},j)})})]}),t.jsxs("div",{className:"lg:sticky lg:top-24",children:[t.jsxs("div",{className:"mb-4 text-center lg:text-left",children:[t.jsx("h2",{className:"text-xl font-semibold text-foreground","data-testid":"text-form-heading",children:s("form.heading")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:s("form.subheading")})]}),t.jsx("div",{className:"rounded-lg border border-border bg-card p-6",children:y?t.jsxs("div",{className:"py-8 flex flex-col items-center gap-3 text-center","data-testid":"status-contact-sent",children:[t.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/10 flex items-center justify-center",children:t.jsx(Ja,{className:"w-6 h-6 text-green-500"})}),t.jsx("p",{className:"font-semibold text-foreground",children:s("form.sentTitle")}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[s("form.sentBodyPrefix"),t.jsx("span",{className:"text-foreground",children:l}),s("form.sentBodySuffix")]}),t.jsx(L,{variant:"outline",className:"mt-2",onClick:()=>{o(""),c(""),h(""),g(""),w(!1)},"data-testid":"button-contact-another",children:s("form.sendAnotherButton")})]}):t.jsxs("form",{className:"space-y-4",onSubmit:async j=>{j.preventDefault(),b(!0);try{const x=await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i,email:l,phone:d,message:p})});if(x.ok)w(!0);else{const C=await x.json().catch(()=>({}));e({title:"Failed to send",description:C.message||"Please try again.",variant:"destructive"})}}catch{e({title:"Failed to send",description:"Network error. Please try again.",variant:"destructive"})}finally{b(!1)}},children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"contact-name",children:s("form.nameLabel")}),t.jsx(ke,{id:"contact-name","data-testid":"input-contact-name",placeholder:s("form.namePlaceholder"),value:i,onChange:j=>o(j.target.value),required:!0})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"contact-email",children:s("form.emailLabel")}),t.jsx(ke,{id:"contact-email",type:"email","data-testid":"input-contact-email",placeholder:s("form.emailPlaceholder"),value:l,onChange:j=>c(j.target.value),required:!0})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"contact-phone",children:s("form.phoneLabel")}),t.jsx(ke,{id:"contact-phone",type:"tel","data-testid":"input-contact-phone",placeholder:s("form.phonePlaceholder"),value:d,onChange:j=>h(j.target.value)})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"contact-message",children:s("form.messageLabel")}),t.jsx(Nn,{id:"contact-message","data-testid":"input-contact-message",placeholder:s("form.messagePlaceholder"),rows:4,value:p,onChange:j=>g(j.target.value),required:!0})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:v,"data-testid":"button-contact-send",children:v?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),s("form.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),s("form.sendButton")]})})]})})]})]})}),t.jsx(_a,{})]})}const iQ={key:"bluLegacy",title:"Blu Legacy",group:"General",fields:[{key:"hero.badge",label:"Hero badge",def:"Event Management With Long-Term Storage"},{key:"hero.heading",label:"Hero heading (parts)",def:"Make Existing Systems | Smart | with Long-Term Storage",multiline:!0,help:'Three parts split by " | ": before, highlighted 
260word, after.'},{key:"hero.subheading",label:"Hero subheading",def:"Blu Legacy includes a native desktop application built for long-term video storage access from months to years, AI-powered event search, and system monitoring, powered by our patented Tru-Two compression with optional Google Cloud Storage.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Learn More"},{key:"hero.badges",label:"Hero trust badges",def:["Secure Connections","Cloud Accessible","Works With Any Camera"].join(`
261`),multiline:!0,help:"One badge per line. Icons are fixed per position."},{key:"trustedBy.heading",label:"Trusted-by heading",def:"Trusted By"},{key:"trustedBy.names",label:"Trusted-by names",def:["Foxwoods","The Ritz-Carlton","Prana Investments","McDonalds","Brenntag","Vepo Solutions","Douglas Elliman","Hertz","Hilton Garden Inn","Marriott","IHG Hotels & Resorts","LaGuardia Community College","Burger King","North Castle Police Department","Bloomberg","Housatonic Community College","Fazoli's","Planet Fitness","Acadian Health","Fluent Cannabis"].join(`
262`),multiline:!0,help:"One company name per line."},{key:"testimonials.heading",label:"Testimonials heading",def:"What Our Clients Say"},{key:"testimonials.items",label:"Testimonial cards",def:["The system gave us complete visibility across all our hotel properties from a single dashboard. It transformed how our security team operates. | James T. | IT Director | Hilton Garden Inn","We can review incidents remotely without driving to the site. {productName} completely changed our security workflow and saved us countless hours. | Maria L. | Security Manager | Planet Fitness","Cloud storage integration saved us during a hard drive failure. Our footage was safe in Google Cloud and we never missed a single moment. | Chris D. | Facilities Manager | Marriott"].join(`
263`),multiline:!0,help:'One card per line: "Quote | Name | Role | Company".'},{key:"products.badge",label:"Products badge",def:"Blu Storage"},{key:"products.heading",label:"Products heading",def:"The Right Blu For You"},{key:"products.subheading",label:"Products subheading",def:"Choose the solution that fits your bandwidth, AI needs, and storage requirements."},{key:"products.stats",label:"Products stats",def:["99.9% | Google Cloud Uptime","Up to 5 Years | Cloud Storage Retention"].join(`
264`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"products.descriptions",label:"Product descriptions",def:["Blu | Direct camera to cloud video streaming & recording with no hardware required. Includes 90 days or 1 year of cloud storage plans. Best use for clients with optimal bandwidth with no hardware management & scalable projects.","Blu Bridge | On-premise hardware that fits in your hand. The bridge enables minimal bandwidth when uploading cloud events. Includes 30 days to 3 years of cloud storage plans. Best use for AI analytics & bandwidth stabilization.","Tru Blu | Intel NUC or rack-mounted with hybrid redundancy using NAS storage. Includes bays, drives, with optional cloud storage. Best for advanced AI analytics, closed networks, continuous recording & local storage."].join(`
265`),multiline:!0,help:'One card per line: "Name | Description". Icons are fixed per position.'},{key:"products.mostPopular",label:'"Most Popular" badge',def:"Most Popular"},{key:"products.card1",label:"Product card 1 (Blu)",def:["Blu | Camera Straight To Cloud | cloud","No Hardware Required","No Local Storage","90 Days Or 1 Year Cloud Storage","Essential AI Sensitivity","Requires Good Bandwidth","AES-256 Encrypted P2P Live View","AES-256 Encryption Transit & Rest","Device Monitoring & Alerts","Easy RTSP Stream Setup Management","Scalable Camera Capacity","OS: Linux Virtualization","Life Time Warranty"].join(`
266`),multiline:!0,help:'First line is the header: "Name | Subtitle | Tag". Following lines are feature bullets. Icon and tag color are fixed per position.'},{key:"products.card2",label:"Product card 2 (Blu Bridge)",def:["Blu Bridge | Tiny Device On-Premises | cloud","Intel NUC Mini","No Local Storage","30 Days To 5 Years Cloud Storage","Standard AI Sensitivity","Minimum Bandwidth Required","AES-256 Encrypted P2P Live View","AES-256 Encryption Transit & Rest","Device Monitoring & Alerts","Easy RTSP Stream Setup Management","Up To 64 Cameras Per Bridge","OS: Windows 10 / 11","2 Year Hardware Warranty"].join(`
267`),multiline:!0,help:'First line is the header: "Name | Subtitle | Tag". Following lines are feature bullets. Icon and tag color are fixed per position.'},{key:"products.card3",label:"Product card 3 (Tru Blu)",def:["Tru Blu | Rack Mounted On-Premises | hybrid","Intel NUC Mini, Rack Mount, or Xeon® Grade","30 Days To 3 Years Local Storage","Optional Cloud Storage Up To 5 Years","Advanced AI Sensitivity with GPU","Minimum Bandwidth Required","AES-256 Encrypted P2P Live View","AES-256 Encryption Transit & Rest","Device Monitoring & Alerts","Easy RTSP Stream Setup Management","64 To 128 Cameras (Enterprise)","OS: Windows 10 / 11 / Server 2025","2 or 3 Year Hardware Warranty"].join(`
268`),multiline:!0,help:'First line is the header: "Name | Subtitle | Tag". Following lines are feature bullets. Icon and tag color are fixed per position.'},{key:"steps.heading",label:"How-it-works heading",def:"Simplify Surveillance"},{key:"steps.subheading",label:"How-it-works subheading",def:"No learning curve. Start storing and protecting your video in four simple steps."},{key:"steps.items",label:"Steps",def:["01 | Open Compatibility | Supports all brands of cameras & recorders. Whether you use various IP cameras or NVR systems, we seamlessly integrate with many brands, allowing you to record footage without forcing you to use a specific manufacturer.","02 | Simple Setup | Streamline device management with a single, intuitive interface. Effortlessly provision users across multiple locations while simplifying operations.","03 | Seamlessly Secure | Encryption enabled by default for protection. Automatic software updates, two-factor authentication, and end-to-e
268nd encryption are designed to minimize vulnerabilities and protect data.","04 | Smarter Search | Transform with cutting-edge AI capabilities. Enable new and existing cameras to quickly detect objects while gaining enhanced features and AI updates without firmware restrictions."].join(`
269`),multiline:!0,help:'One step per line: "Number | Title | Description". Icons are fixed per position.'},{key:"ems.badge",label:"EMS badge",def:"E.M.P"},{key:"ems.heading",label:"EMS heading",def:"Event Management Portal"},{key:"ems.subheading",label:"EMS subheading",def:"Windows-based platform to search, review, and manage video events across all your locations."},{key:"ems.items",label:"EMS feature blocks",def:["Multi-Site Dashboard | Monitor total storage consumed, gateway bridge status, and device health across every location — all from one centralized screen.","AI-Powered Event Retrieval | Instantly navigate recorded footage using AI object detection. Person, vehicle, handbag, and more — each event is timestamped and frame-accurate.","AI Search | Select a date range, storage location, then filter by AI category such as Person & Objects or Car Plates & Words to surface the exact moments you need.  Example: Search 'NYPD'","Event Playback | Review footage with full playback controls, export, and share events. AI detection overlays highlight relevant activity directly on the footage.","Smart Object & Person Detection | AI identifies and labels people, objects, and activity captured on camera. Drill into specific events with confidence scores to quickly find what matters.","Multi-Camera Live View | Stream up to dozens of cameras from a single interface. Real-time bandwidth and status indicators keep you informed of every feed's health at a glance."].join(`
270`),multiline:!0,help:'One block per line: "Title | Description". Images and visibility toggles are fixed per position.'},{key:"cta.heading",label:"CTA heading",def:"Ready to Protect Your Surveillance Data?"},{key:"cta.subheading",label:"CTA subheading",def:"Join thousands of locations already storing billions of events securely in the cloud."},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"contact.title",label:"Contact dialog title",def:"Contact Us"},{key:"contact.description",label:"Contact dialog description",def:"Send us a message and we'll get back to you shortly."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message sent!"},{key:"contact.sentBodyPre",label:"Contact sent body (before email)",def:"We'll be in touch at"},{key:"contact.sentBodyPost",label:"Contact sent body (after email)",def:"."},{key:"contact.closeButton",label:"Contact close button",def:"Close"},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone Number"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"+1 (555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Message"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"How can we help?"},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},nge="/assets/image_1775540682593-Vv4MXT1_.png",age="/assets/1_1775583546769-ATyQZ793.png",ige="/assets/2_1775583546769-DELhAzsK.png",oge="/assets/3_1775583546769-C7NywEs7.png",lge="/assets/4_1775583546769-Dch9U4eQ.png",cge="/assets/5_1775590893968-DEUw0RV2.png",dge="/assets/6_1775583546770-cXRoD7e3.png";function v6(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k}=rn(iQ),S=[vi,pn,no],_=[pn,Fa,Wx],A=["bg-blue-500/10 text-blue-400","bg-primary/10 text-primary","bg-vi
270olet-500/10 text-violet-400"],T=[!1,!0,!1],M=[pn,Fa,Wx],R=[bde,jde,vi,ai],$=["products.card1","products.card2","products.card3"].map((K,G)=>{const[z,...Z]=C(K),[ee="",Q="",Y=""]=(z??"").split("|").map(oe=>oe.trim());return{icon:_[G],name:ee,subtitle:Q,tag:Y,tagColor:A[G],featured:T[G],features:Z}}),O=k("steps.items").map(([K="",G="",z=""],Z)=>({step:K,title:G,desc:z,icon:R[Z%R.length]})),q=[{img:j.imgBluEmsDashboard||age,show:j.imgBluEmsDashboardShow},{img:j.imgBluEmsAiSearch||oge,show:j.imgBluEmsAiSearchShow},{img:j.imgBluEmsOnPremise||lge,show:j.imgBluEmsOnPremiseShow},{img:j.imgBluEmsAiRetrieval||ige,show:j.imgBluEmsAiRetrievalShow},{img:j.imgBluEmsObjectDetect||cge,show:j.imgBluEmsObjectDetectShow},{img:j.imgBluEmsLiveView||dge,show:j.imgBluEmsLiveViewShow}],V=k("ems.items").map(([K="",G=""],z)=>({img:q[z]?.img,show:q[z]?.show,title:K,desc:G}));return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-7xl mx-auto",children:t.jsxs("div",{className:"flex flex-col items-center text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight max-w-3xl",children:(()=>{const[K="",G="",z=""]=k("hero.heading")[0]??[];return t.jsxs(t.Fragment,{children:[K,t.jsxs("span",{className:"text-primary",children:[" ",G," "]}),z]})})()}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("hero.secondaryButton")})]}),t.jsx("div",{className:"flex justify-center items-center gap-6 text-sm text-muted-foreground",children:C("hero.badges").map((K,G)=>{const z=S[G%S.length];return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(z,{className:"w-4 h-4 text-primary"}),t.jsx("span",{children:K})]},K)})}),j.imgBluHeroShow!=="false"&&t.jsxs("div",{className:"relative w-full mt-8",children:[t.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-primary/20 to-primary/5 rounded-2xl blur-3xl"}),t.jsx("img",{src:j.imgBluHero||nge,alt:`${j.brandName} Blu Software`,className:"relative w-full rounded-2xl shadow-2xl"})]})]})})}),t.jsxs("section",{className:"py-10 border-y border-border/40 overflow-hidden",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-8",children:x("trustedBy.heading")}),t.jsx("div",{className:"overflow-hidden w-full",children:t.jsx("div",{className:"marquee-track",children:C("trustedBy.names").map((K,G)=>t.jsx("span",{className:"shrink-0 mx-12 text-foreground/50 font-semibold text-sm tracking-widest uppercase whitespace-nowrap hover:text-foreground/80 transition-colors cursor-default",children:K},G))})})]}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-10",children:x("testimonials.heading")}),t.jsx("div",{className:"grid md:grid-cols-3 gap-6",children:k("testimonials.items").map(([K="",G="",z="",Z=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-6 flex flex-col gap-4",children:[t.jsx("div",{className:"text-2xl text-primary/60 font-serif leading-none",children:'"'}),t.jsxs("p",{className:"text-sm text-muted-foreground leading-relaxed flex-1",children:['"',K,'"']}),t.jsxs("div",{className:"border-t border-border/40 pt-4",children:[t.jsx("p",{className:"font-semibold text-foreground text-sm",children:G}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[z," · ",Z]})]})]},G))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:"text-center space-y-4 mb-16",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("products.badge")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("products.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("products.subheading")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-10 pt-2",children:k("products.stats").map(([K="",G=""])=>t.jsxs("div",{children:[t.jsx("p",{className:"text-2xl font-bold text-primary",children:K}),t.jsx("p",{className:"text-sm text-muted-foreground",children:G})]},G))}),t.jsx("div",{className:"grid md:grid-cols-3 gap-6 mt-8 text-left w-full",children:k("products.descriptions").map(([K="",G=""],z)=>{const Z=M[z%M.length];return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 space-y-3",children:[t.jsx("p",{className:"text-lg font-bold text-foreground text-center",children:K}),t.jsx("div",{className:"flex justify-center",children:t.jsx(Z,{className:"w-8 h-8 text-foreground
270/70"})}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:G})]},K)})})]}),t.jsx("div",{className:"grid md:grid-cols-3 gap-6",children:$.map(K=>t.jsx(ut,{className:`bg-card border-card-border flex flex-col ${K.featured?"ring-2 ring-primary shadow-lg shadow-primary/10":""}`,children:t.jsxs(mt,{className:"p-6 flex flex-col flex-1 space-y-5",children:[K.featured&&t.jsx("div",{className:"text-center",children:t.jsx("span",{className:"inline-block px-3 py-0.5 rounded-full text-xs font-semibold bg-primary text-primary-foreground",children:x("products.mostPopular")})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-11 h-11 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:t.jsx(K.icon,{className:"w-5 h-5 text-primary"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-xl font-bold text-foreground",children:K.name}),t.jsx("p",{className:"text-sm text-muted-foreground",children:K.subtitle})]})]}),t.jsx("span",{className:`self-start px-2.5 py-0.5 rounded text-xs font-medium uppercase tracking-wide ${K.tagColor}`,children:K.tag}),t.jsx("ul",{className:"space-y-2 flex-1",children:K.features.map(G=>t.jsxs("li",{className:"flex items-start gap-2 text-sm text-foreground/80",children:[t.jsx(Hd,{className:"w-4 h-4 text-primary flex-shrink-0 mt-0.5"}),G]},G))})]})},K.name))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-7xl mx-auto",children:[t.jsxs("div",{className:"text-center space-y-4 mb-16",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("steps.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("steps.subheading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-6",children:O.map(K=>t.jsxs("div",{className:"rounded-2xl border border-border/50 bg-card p-6 flex flex-col gap-4",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsx("div",{className:"w-12 h-12 rounded-xl bg-primary/10 flex items-center justify-center flex-shrink-0",children:t.jsx(K.icon,{className:"w-6 h-6 text-primary"})}),t.jsx("span",{className:"text-3xl font-bold text-primary/15",children:K.step})]}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:K.title}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:K.desc})]})]},K.step))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto",children:[t.jsxs("div",{className:"text-center space-y-4 mb-12",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("ems.badge")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("ems.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("ems.subheading")})]}),t.jsx("div",{className:"flex flex-col gap-10",children:V.filter(K=>K.show!=="false").map(K=>t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"px-1",children:[t.jsx("p",{className:"text-base font-semibold text-foreground mb-1",children:K.title}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:K.desc})]}),t.jsx("img",{src:K.img,alt:K.title,className:"w-full rounded-xl shadow-lg border border-border/30"})]},K.title))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-4",children:t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")})})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:K=>{n(K),K||(i(""),l(""),d(""),p(""),y(!1))},children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-8 flex flex-col items-center gap-3 text-center",children:[t.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/10 flex items-center justify-center",children:t.jsx(Ja,{className:"w-6 h-6 text-green-500"})}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[x("contact.sentBodyPre")," ",t.jsx("span",{className:"text-foreground",children:o}
270),x("contact.sentBodyPost")]}),t.jsx(L,{variant:"outline",className:"mt-2",onClick:()=>n(!1),children:x("contact.closeButton")})]}):t.jsxs("form",{className:"space-y-4",onSubmit:async K=>{K.preventDefault(),v(!0);try{const G=await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})});if(G.ok)y(!0);else{const z=await G.json().catch(()=>({}));w({title:"Failed to send",description:z.message||"Please try again.",variant:"destructive"})}}catch{w({title:"Failed to send",description:"Network error. Please try again.",variant:"destructive"})}finally{v(!1)}},children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"blu-contact-name",children:x("contact.nameLabel")}),t.jsx(ke,{id:"blu-contact-name",placeholder:x("contact.namePlaceholder"),value:a,onChange:K=>i(K.target.value),required:!0})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"blu-contact-email",children:x("contact.emailLabel")}),t.jsx(ke,{id:"blu-contact-email",type:"email",placeholder:x("contact.emailPlaceholder"),value:o,onChange:K=>l(K.target.value),required:!0})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"blu-contact-phone",children:x("contact.phoneLabel")}),t.jsx(ke,{id:"blu-contact-phone",type:"tel",placeholder:x("contact.phonePlaceholder"),value:c,onChange:K=>d(K.target.value)})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"blu-contact-message",children:x("contact.messageLabel")}),t.jsx(Nn,{id:"blu-contact-message",placeholder:x("contact.messagePlaceholder"),rows:4,value:h,onChange:K=>p(K.target.value),required:!0})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const oQ=e=>`live-stream-source:${e}`;function eM(e){if(!e)return"sub";try{const s=localStorage.getItem(oQ(e));return s==="auto"||s==="main"||s==="sub"||s==="jpeg"?s:"sub"}catch{return"sub"}}function uge(e,s){if(e)try{localStorage.setItem(oQ(e),s)}catch{}}function UO(e){const[s,r]=u.useState(null),n=s?.siteId===e?s.source:eM(e);return[n,i=>{const o=typeof i=="function"?i(n):i;uge(e,o),r({siteId:e,source:o})}]}const mge="truvios-dashboard-frames",hge=1,q0="frames",pge=500,fge=512*1024,gge=1440*60*1e3;let u1=null;function xge(e,s,r){return JSON.stringify([e,s,r])}function lQ(e,s){return JSON.stringify([e,s])}function cQ(){return u1||(u1=new Promise(e=>{if(typeof indexedDB>"u")return e(null);const s=indexedDB.open(mge,hge);s.onupgradeneeded=()=>{const n=s.result.createObjectStore(q0,{keyPath:"key"});n.createIndex("userSite","userSite",{unique:!1}),n.createIndex("savedAt","savedAt",{unique:!1})},s.onsuccess=()=>e(s.result),s.onerror=()=>e(null),s.onblocked=()=>e(null)}),u1)}async function vge(e,s,r){const n=await cQ();return!n||r<=0?[]:new Promise(a=>{const o=n.transaction(q0,"readonly").objectStore(q0).index("userSite").getAll(IDBKeyRange.only(lQ(e,s)));o.onsuccess=()=>{const l=Date.now()-gge,c=o.result.filter(d=>d.savedAt>=l).sort((d,h)=>h.savedAt-d.savedAt).slice(0,r).map(d=>({cameraName:d.cameraName,blob:d.blob}));a(c)},o.onerror=()=>a([])})}async function yge(e,s,r,n){if(n.size<=0||n.size>fge)return;const a=await cQ();a&&await new Promise(i=>{const o=a.transaction(q0,"readwrite"),l=o.objectStore(q0);l.put({key:xge(e,s,r),userSite:lQ(e,s),cameraName:r,blob:n,savedAt:Date.now()});const c=l.count();c.onsuccess=()=>{let d=c.result-pge;if(d<=0)return;const h=l.index("savedAt").openCursor();h.onsuccess=()=>{const p=h.result;!p||d<=0||(p.delete(),d--,p.continue())}},o.oncomplete=()=>i(),o.onerror=()=>i(),o.onabort=()=>i()})}function bge({onRefresh:e,threshold:s=80,maxPull:r=120}){const[n,a]=u.useState(0),[i,o]=u.useState(!1),l=u.useRef(0),c=u.useRef(!1),d=u.useRef(null),h=u.useCallback(b=>{if(i)return;(window.scrollY||document.documentElement.scrollTop)<=0&&(l.current=b.touches[0].clientY,c.current=!0)},[i]),p=u.useCallback(b=>{if(!c.current||i)return;const w=b.touches[0].clientY-l.current;if(w>0){const j=Math.min(w*.5,r);a(j),j>10&&b.preventDefault()}else c.current=!1,a(0)},[i,r]),g=u.useCallback(async()=>
270{if(!(!c.current||i))if(c.current=!1,n>=s){o(!0),a(s);try{await e()}finally{o(!1),a(0)}}else a(0)},[n,s,i,e]);u.useEffect(()=>{const b={passive:!1};return document.addEventListener("touchstart",h,{passive:!0}),document.addEventListener("touchmove",p,b),document.addEventListener("touchend",g,{passive:!0}),()=>{document.removeEventListener("touchstart",h),document.removeEventListener("touchmove",p),document.removeEventListener("touchend",g)}},[h,p,g]);const v=n>=s;return{pullDistance:n,isRefreshing:i,isPastThreshold:v,containerRef:d}}const wge=Hj("whitespace-nowrap inline-flex items-center rounded-md 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 hover-elevate ",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow-xs",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground shadow-xs",outline:" border [border-color:var(--badge-outline)] shadow-xs"}},defaultVariants:{variant:"default"}});function Ke({className:e,variant:s,...r}){return t.jsx("div",{className:Cs(wge({variant:s}),e),...r})}const jge={owner:"Owner",user:"User",admin:"Administrator"};function y6(e){return[e.firstName,e.lastName].filter(Boolean).join(" ").trim()||e.email||"Unknown user"}function Nge({open:e,onOpenChange:s}){const{toast:r}=Hs(),[n,a]=u.useState(""),[i,o]=u.useState(null),{data:l,isLoading:c}=ze({queryKey:["/api/view-as/users"],enabled:e}),d=l?.users??[],h=u.useMemo(()=>{const g=n.trim().toLowerCase();return g?d.filter(v=>`${y6(v)} ${v.email??""}`.toLowerCase().includes(g)):d},[d,n]),p=async g=>{o(g.id);try{await Ze("POST","/api/view-as/start",{userId:g.id}),window.location.href="/"}catch(v){o(null),r({title:"Couldn't start View As",description:v?.message?.replace(/^\d+:\s*/,"")||"Please try again.",variant:"destructive"})}};return t.jsx(Ys,{open:e,onOpenChange:s,children:t.jsxs(Ws,{className:"max-w-md","data-testid":"dialog-view-as",children:[t.jsxs(Zs,{children:[t.jsxs(Ks,{className:"flex items-center gap-2",children:[t.jsx(Xr,{className:"w-5 h-5"}),"View As..."]}),t.jsx(cr,{children:"See the dashboard exactly as another user does. This is read-only — you can't make any changes while viewing as someone else."})]}),t.jsxs("div",{className:"relative",children:[t.jsx(yc,{className:"absolute left-2.5 top-2.5 w-4 h-4 text-muted-foreground"}),t.jsx(ke,{placeholder:"Search by name or email",value:n,onChange:g=>a(g.target.value),className:"pl-8","data-testid":"input-view-as-search"})]}),t.jsx("div",{className:"max-h-80 overflow-y-auto -mx-2 px-2",children:c?t.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:t.jsx(Fe,{className:"w-5 h-5 animate-spin"})}):h.length===0?t.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground","data-testid":"text-view-as-empty",children:d.length===0?"No users available to view as.":"No matches."}):t.jsx("ul",{className:"space-y-1",children:h.map(g=>t.jsx("li",{children:t.jsxs("button",{type:"button",disabled:!!i,onClick:()=>p(g),className:"w-full flex items-center justify-between gap-2 rounded-md px-3 py-2 text-left hover-elevate active-elevate-2 disabled:opacity-60","data-testid":`button-view-as-user-${g.id}`,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:y6(g)}),g.email&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:g.email})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx(Ke,{variant:"secondary",children:jge[g.role]||g.role}),i===g.id&&t.jsx(Fe,{className:"w-4 h-4 animate-spin"})]})]})},g.id))})})]})})}var zO="Avatar",[Sge]=oo(zO),[Cge,dQ]=Sge(zO),uQ=u.forwardRef((e,s)=>{const{__scopeAvatar:r,...n}=e,[a,i]=u.useState("idle");return t.jsx(Cge,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:i,children:t.jsx(Cr.span,{...n,ref:s})})});uQ.displayName=zO;var mQ="AvatarImage",hQ=u.forwardRef((e,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...i}=e,o=dQ(mQ,r),l=kge(n,i),c=Za(d=>{a(d),o.onImageLoadingStatusChange(d)});return da(()=>{l!=="idle"&&c(l)},[l,c]),l==="loaded"?t.jsx(Cr.img,{...i,ref:s,src:n}):null});hQ.displayName=mQ;var pQ="AvatarFallback",fQ=u.forwardRef((e,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=e,i=dQ(pQ,r),[o,l]=u.useState(n===void 0);return u.useEffect(()=>{if(n!==void 0){const c=window.setTimeout(()=>l(!0),n);return()=>window.clearTimeout(c)}},[n]),o&&i.imageLoadingStatus!=="loaded"?t.jsx(Cr.span,{...a,ref:s}):null});fQ.displayName=pQ;function b6(e,s){return e?s?(e.src!==s&&(e.src=s),e.complete&&e.naturalWi
vendor: 7,777 bytes, lines 270-272
270dth>0?"loaded":"loading"):"error":"idle"}function kge(e,{referrerPolicy:s,crossOrigin:r}){const n=Pge(),a=u.useRef(null),i=n?(a.current||(a.current=new window.Image),a.current):null,[o,l]=u.useState(()=>b6(i,e));return da(()=>{l(b6(i,e))},[i,e]),da(()=>{const c=p=>()=>{l(p)};if(!i)return;const d=c("loaded"),h=c("error");return i.addEventListener("load",d),i.addEventListener("error",h),s&&(i.referrerPolicy=s),typeof r=="string"&&(i.crossOrigin=r),()=>{i.removeEventListener("load",d),i.removeEventListener("error",h)}},[i,r,s]),o}function _ge(){return()=>{}}function Pge(){return u.useSyncExternalStore(_ge,()=>!0,()=>!1)}var gQ=uQ,xQ=hQ,vQ=fQ;const cy=u.forwardRef(({className:e,...s},r)=>t.jsx(gQ,{ref:r,className:Cs(`
271      after:content-[''] after:block after:absolute after:inset-0 after:rounded-full after:pointer-events-none after:border after:border-black/10 dark:after:border-white/10
272      relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full`,e),...s}));cy.displayName=gQ.displayName;const dy=u.forwardRef(({className:e,...s},r)=>t.jsx(xQ,{ref:r,className:Cs("aspect-square h-full w-full",e),...s}));dy.displayName=xQ.displayName;const uy=u.forwardRef(({className:e,...s},r)=>t.jsx(vQ,{ref:r,className:Cs("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...s}));uy.displayName=vQ.displayName;var Ege=u.createContext(void 0);function Og(e){const s=u.useContext(Ege);return e||s||"ltr"}var pP="rovingFocusGroup.onEntryFocus",Tge={bubbles:!1,cancelable:!0},Qk="RovingFocusGroup",[tM,yQ,Age]=Bj(Qk),[Mge,Xk]=oo(Qk,[Age]),[Rge,Ige]=Mge(Qk),bQ=u.forwardRef((e,s)=>t.jsx(tM.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(tM.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Oge,{...e,ref:s})})}));bQ.displayName=Qk;var Oge=u.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:h=!1,...p}=e,g=u.useRef(null),v=mr(s,g),b=Og(i),[y=null,w]=ip({prop:o,defaultProp:l,onChange:c}),[j,x]=u.useState(!1),C=Za(d),k=yQ(r),S=u.useRef(!1),[_,A]=u.useState(0);return u.useEffect(()=>{const T=g.current;if(T)return T.addEventListener(pP,C),()=>T.removeEventListener(pP,C)},[C]),t.jsx(Rge,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:y,onItemFocus:u.useCallback(T=>w(T),[w]),onItemShiftTab:u.useCallback(()=>x(!0),[]),onFocusableItemAdd:u.useCallback(()=>A(T=>T+1),[]),onFocusableItemRemove:u.useCallback(()=>A(T=>T-1),[]),children:t.jsx(Cr.div,{tabIndex:j||_===0?-1:0,"data-orientation":n,...p,ref:v,style:{outline:"none",...e.style},onMouseDown:Ms(e.onMouseDown,()=>{S.current=!0}),onFocus:Ms(e.onFocus,T=>{const M=!S.current;if(T.target===T.currentTarget&&M&&!j){const R=new CustomEvent(pP,Tge);if(T.currentTarget.dispatchEvent(R),!R.defaultPrevented){const D=k().filter(K=>K.focusable),$=D.find(K=>K.active),O=D.find(K=>K.id===y),V=[$,O,...D].filter(Boolean).map(K=>K.ref.current);NQ(V,h)}}S.current=!1}),onBlur:Ms(e.onBlur,()=>x(!1))})})}),wQ="RovingFocusGroupItem",jQ=u.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:i,...o}=e,l=wu(),c=i||l,d=Ige(wQ,r),h=d.currentTabStopId===c,p=yQ(r),{onFocusableItemAdd:g,onFocusableItemRemove:v}=d;return u.useEffect(()=>{if(n)return g(),()=>v()},[n,g,v]),t.jsx(tM.ItemSlot,{scope:r,id:c,focusable:n,active:a,children:t.jsx(Cr.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...o,ref:s,onMouseDown:Ms(e.onMouseDown,b=>{n?d.onItemFocus(c):b.preventDefault()}),onFocus:Ms(e.onFocus,()=>d.onItemFocus(c)),onKeyDown:Ms(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){d.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const y=$ge(b,d.orientation,d.dir);if(y!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let j=p().filter(x=>x.focusable).map(x=>x.ref.current);if(y==="last")j.reverse();else if(y==="prev"||y==="next"){y==="prev"&&j.reverse();const x=j.indexOf(b.currentTarget);j=d.loop?Fge(j,x+1):j.slice(x+1)}setTimeout(()=>NQ(j))}})})})});jQ.displayName=wQ;var Dge={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Lge(e,s){return s!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function $ge(e,s,r){const n=Lge(e.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Dge[n]}function NQ(e,s=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function Fge(e,s){return e.map((r,n)=>e[(s+n)%e.length])}var SQ=bQ,CQ=jQ,sM=["Enter"," "],Bge=["ArrowDown","PageUp","Home"],kQ=["ArrowUp","PageDown","End"],Uge=[...Bge,...kQ],zge={ltr:[...sM,"ArrowRight"],rtl:[...sM,"ArrowLeft"]},Hge={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Qj="Menu",[V0,qge,Vge]=Bj(Qj),[dv,_Q]=oo(Qj,[Vge,Pb,Xk]),Zk=Pb(),PQ=Xk(),[Wge,uv]=dv(Qj),[Kge,Xj]=dv(Qj),EQ=e=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:i,modal:o=!0}=e,l=Zk(s),[c,d]=u.useState(null),h=u.useRef(!1),p=Za(i),g=Og(a);return u.useEffect(()=>{const v=()=>{h.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>h.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),t.jsx(jO,{...l,children:t.jsx(Wge,{scope:s,open:r,onOpenChange:p,content:c,onContentChange:d,children:t.jsx(Kge,{scope:s,onClose:u.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:h,dir:g,modal:o,children:n})})})};EQ.displayName=Qj;var Gge="MenuAnchor",HO=u.forwardRef((e,s)=>{const{__scopeMenu:r,...n}=e,a=Zk(r);return t.jsx(NO,{...a,...n,ref:s})});HO.displayName=Gge;var qO="MenuPortal",[Yge,TQ]=dv(qO,{forceMount:void 0}),AQ=e=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=e,i=uv(qO,s);return t.jsx(Yge,{scope:s,forceMount:r,children:t.jsx($m,{present:r||i.open,children:t.jsx(Uj,{asChild:!0,container:a,children:n})})})};AQ.displayName=qO;var Mm="MenuContent",[Qge,VO]=dv(Mm),MQ=u.forwardRef((e,s)=>{const r=TQ(Mm,e.__scopeMenu),{forceMount:n=r.forceMount,...a}=e,i=uv(Mm,e.__scopeMenu),o=Xj(Mm,e.__scopeMenu);return t.jsx(V0.Provider,{scope:e.__scopeMenu,children:t.jsx($m,{present:n||i.open,children:t.jsx(V0.Slot,{scope:e.__scopeMenu,children:o.modal?t.jsx(Xge,{...a,ref:s}):t.jsx(Zge,{...a,ref:s})})})})}),Xge=u.forwardRef((e,s)=>{const r=uv(Mm,e.__scopeMenu),n=u.useRef(null),a=mr(s,n);return u.useEffect(()=>{const i=n.current;if(i)return Gk(i)},[]),t.jsx(WO,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Ms(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Zge=u.forwardRef((e,s)=>{const r=uv(Mm,e.__scopeMenu);return t.jsx(WO,{...e,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Jge=zx("MenuContent.ScrollLock"),WO=u.forwardRef((e,s)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:g,onDismiss:v,disableOutsideScroll:b,...y}=e,w=uv(Mm,r),j=Xj(Mm,r),x=Zk(r),C=PQ(r),k=qge(r),[S,_]=u.useState(null),A=u.useRef(null),T=mr(s,A,w.onContentChange),M=u.useRef(0),R=u.useRef(""),D=u.useRef(0),$=u.useRef(null),O=u.useRef("right"),q=u.useRef(0),V=b?Yj:u.Fragment,K=b?{as:Jge,allowPinchZoom:!0}:void 0,G=Z=>{const ee=R.current+Z,Q=k().filter(le=>
vendor: 14,658 bytes, line 272
272!le.disabled),Y=document.activeElement,oe=Q.find(le=>le.ref.current===Y)?.textValue,he=Q.map(le=>le.textValue),je=uxe(he,ee,oe),pe=Q.find(le=>le.textValue===je)?.ref.current;(function le(ue){R.current=ue,window.clearTimeout(M.current),ue!==""&&(M.current=window.setTimeout(()=>le(""),1e3))})(ee),pe&&setTimeout(()=>pe.focus())};u.useEffect(()=>()=>window.clearTimeout(M.current),[]),MO();const z=u.useCallback(Z=>O.current===$.current?.side&&hxe(Z,$.current?.area),[]);return t.jsx(Qge,{scope:r,searchRef:R,onItemEnter:u.useCallback(Z=>{z(Z)&&Z.preventDefault()},[z]),onItemLeave:u.useCallback(Z=>{z(Z)||(A.current?.focus(),_(null))},[z]),onTriggerLeave:u.useCallback(Z=>{z(Z)&&Z.preventDefault()},[z]),pointerGraceTimerRef:D,onPointerGraceIntentChange:u.useCallback(Z=>{$.current=Z},[]),children:t.jsx(V,{...K,children:t.jsx(Wk,{asChild:!0,trapped:a,onMountAutoFocus:Ms(i,Z=>{Z.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:t.jsx(wb,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:g,onDismiss:v,children:t.jsx(SQ,{asChild:!0,...C,dir:j.dir,orientation:"vertical",loop:n,currentTabStopId:S,onCurrentTabStopIdChange:_,onEntryFocus:Ms(c,Z=>{j.isUsingKeyboardRef.current||Z.preventDefault()}),preventScrollOnEntryFocus:!0,children:t.jsx(SO,{role:"menu","aria-orientation":"vertical","data-state":GQ(w.open),"data-radix-menu-content":"",dir:j.dir,...x,...y,ref:T,style:{outline:"none",...y.style},onKeyDown:Ms(y.onKeyDown,Z=>{const Q=Z.target.closest("[data-radix-menu-content]")===Z.currentTarget,Y=Z.ctrlKey||Z.altKey||Z.metaKey,oe=Z.key.length===1;Q&&(Z.key==="Tab"&&Z.preventDefault(),!Y&&oe&&G(Z.key));const he=A.current;if(Z.target!==he||!Uge.includes(Z.key))return;Z.preventDefault();const pe=k().filter(le=>!le.disabled).map(le=>le.ref.current);kQ.includes(Z.key)&&pe.reverse(),cxe(pe)}),onBlur:Ms(e.onBlur,Z=>{Z.currentTarget.contains(Z.target)||(window.clearTimeout(M.current),R.current="")}),onPointerMove:Ms(e.onPointerMove,W0(Z=>{const ee=Z.target,Q=q.current!==Z.clientX;if(Z.currentTarget.contains(ee)&&Q){const Y=Z.clientX>q.current?"right":"left";O.current=Y,q.current=Z.clientX}}))})})})})})})});MQ.displayName=Mm;var exe="MenuGroup",KO=u.forwardRef((e,s)=>{const{__scopeMenu:r,...n}=e;return t.jsx(Cr.div,{role:"group",...n,ref:s})});KO.displayName=exe;var txe="MenuLabel",RQ=u.forwardRef((e,s)=>{const{__scopeMenu:r,...n}=e;return t.jsx(Cr.div,{...n,ref:s})});RQ.displayName=txe;var WS="MenuItem",w6="menu.itemSelect",Jk=u.forwardRef((e,s)=>{const{disabled:r=!1,onSelect:n,...a}=e,i=u.useRef(null),o=Xj(WS,e.__scopeMenu),l=VO(WS,e.__scopeMenu),c=mr(s,i),d=u.useRef(!1),h=()=>{const p=i.current;if(!r&&p){const g=new CustomEvent(w6,{bubbles:!0,cancelable:!0});p.addEventListener(w6,v=>n?.(v),{once:!0}),WI(p,g),g.defaultPrevented?d.current=!1:o.onClose()}};return t.jsx(IQ,{...a,ref:c,disabled:r,onClick:Ms(e.onClick,h),onPointerDown:p=>{e.onPointerDown?.(p),d.current=!0},onPointerUp:Ms(e.onPointerUp,p=>{d.current||p.currentTarget?.click()}),onKeyDown:Ms(e.onKeyDown,p=>{const g=l.searchRef.current!=="";r||g&&p.key===" "||sM.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Jk.displayName=WS;var IQ=u.forwardRef((e,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...i}=e,o=VO(WS,r),l=PQ(r),c=u.useRef(null),d=mr(s,c),[h,p]=u.useState(!1),[g,v]=u.useState("");return u.useEffect(()=>{const b=c.current;b&&v((b.textContent??"").trim())},[i.children]),t.jsx(V0.ItemSlot,{scope:r,disabled:n,textValue:a??g,children:t.jsx(CQ,{asChild:!0,...l,focusable:!n,children:t.jsx(Cr.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...i,ref:d,onPointerMove:Ms(e.onPointerMove,W0(b=>{n?o.onItemLeave(b):(o.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ms(e.onPointerLeave,W0(b=>o.onItemLeave(b))),onFocus:Ms(e.onFocus,()=>p(!0)),onBlur:Ms(e.onBlur,()=>p(!1))})})})}),sxe="MenuCheckboxItem",OQ=u.forwardRef((e,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=e;return t.jsx(BQ,{scope:e.__scopeMenu,checked:r,children:t.jsx(Jk,{role:"menuitemcheckbox","aria-checked":KS(r)?"mixed":r,...a,ref:s,"data-state":YO(r),onSelect:Ms(a.onSelect,()=>n?.(KS(r)?!0:!r),{checkForDefaultPrevented:!1})})})});OQ.displayName=sxe;var DQ="MenuRadioGroup",[rxe,nxe]=dv(DQ,{value:void 0,onValueChange:()=>{}}),LQ=u.forwardRef((e,s)=>{const{value:r,onValueChange:n,...a}=e,i=Za(n);return t.jsx(rxe,{scope:e.__scopeMenu,value:r,onValueChange:i,children:t.jsx(KO,{...a,ref:s})})});LQ.displayName=DQ;var $Q="MenuRadioItem",FQ=u.forwardRef((e,s)=>{const{value:r,...n}=e,a=nxe($Q,e.__scopeMenu),i=r===a.value;return t.jsx(BQ,{scope:e.__scopeMenu,checked:i,children:t.jsx(Jk,{role:"menuitemradio","aria-checked":i,...n,ref:s,"data-state":YO(i),onSelect:Ms(n.onSelect,()=>a.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});FQ.displayName=$Q;var GO="MenuItemIndicator",[BQ,axe]=dv(GO,{checked:!1}),UQ=u.forwardRef((e,s)=>{const{__scopeMenu:r,forceMount:n,...a}=e,i=axe(GO,r);return t.jsx($m,{present:n||KS(i.checked)||i.checked===!0,children:t.jsx(Cr.span,{...a,ref:s,"data-state":YO(i.checked)})})});UQ.displayName=GO;var ixe="MenuSeparator",zQ=u.forwardRef((e,s)=>{const{__scopeMenu:r,...n}=e;return t.jsx(Cr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});zQ.displayName=ixe;var oxe="MenuArrow",HQ=u.forwardRef((e,s)=>{const{__scopeMenu:r,...n}=e,a=Zk(r);return t.jsx(CO,{...a,...n,ref:s})});HQ.displayName=oxe;var lxe="MenuSub",[gWe,qQ]=dv(lxe),Bw="MenuSubTrigger",VQ=u.forwardRef((e,s)=>{const r=uv(Bw,e.__scopeMenu),n=Xj(Bw,e.__scopeMenu),a=qQ(Bw,e.__scopeMenu),i=VO(Bw,e.__scopeMenu),o=u.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=i,d={__scopeMenu:e.__scopeMenu},h=u.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return u.useEffect(()=>h,[h]),u.useEffect(()=>{const p=l.current;return()=>{window.clearTimeout(p),c(null)}},[l,c]),t.jsx(HO,{asChild:!0,...d,children:t.jsx(IQ,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":GQ(r.open),...e,ref:jf(s,a.onTriggerChange),onClick:p=>{e.onClick?.(p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Ms(e.onPointerMove,W0(p=>{i.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!r.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{r.onOpenChange(!0),h()},100))})),onPointerLeave:Ms(e.onPointerLeave,W0(p=>{h();const g=r.content?.getBoundingClientRect();if(g){const v=r.content?.dataset.side,b=v==="right",y=b?-5:5,w=g[b?"left":"right"],j=g[b?"right":"left"];i.onPointerGraceIntentChange({area:[{x:p.clientX+y,y:p.clientY},{x:w,y:g.top},{x:j,y:g.top},{x:j,y:g.bottom},{x:w,y:g.bottom}],side:v}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(p),p.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ms(e.onKeyDown,p=>{const g=i.searchRef.current!=="";e.disabled||g&&p.key===" "||zge[n.dir].includes(p.key)&&(r.onOpenChange(!0),r.content?.focus(),p.preventDefault())})})})});VQ.displayName=Bw;var WQ="MenuSubContent",KQ=u.forwardRef((e,s)=>{const r=TQ(Mm,e.__scopeMenu),{forceMount:n=r.forceMount,...a}=e,i=uv(Mm,e.__scopeMenu),o=Xj(Mm,e.__scopeMenu),l=qQ(WQ,e.__scopeMenu),c=u.useRef(null),d=mr(s,c);return t.jsx(V0.Provider,{scope:e.__scopeMenu,children:t.jsx($m,{present:n||i.open,children:t.jsx(V0.Slot,{scope:e.__scopeMenu,children:t.jsx(WO,{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:h=>{o.isUsingKeyboardRef.current&&c.current?.focus(),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:Ms(e.onFocusOutside,h=>{h.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ms(e.onEscapeKeyDown,h=>{o.onClose(),h.preventDefault()}),onKeyDown:Ms(e.onKeyDown,h=>{const p=h.currentTarget.contains(h.target),g=Hge[o.dir].includes(h.key);p&&g&&(i.onOpenChange(!1),l.trigger?.focus(),h.preventDefault())})})})})})});KQ.displayName=WQ;function GQ(e){return e?"open":"closed"}function KS(e){return e==="indeterminate"}function YO(e){return KS(e)?"indeterminate":e?"checked":"unchecked"}function cxe(e){const s=document.activeElement;for(const r of e)if(r===s||(r.focus(),document.activeElement!==s))return}function dxe(e,s){return e.map((r,n)=>e[(s+n)%e.length])}function uxe(e,s,r){const a=s.length>1&&Array.from(s).every(d=>d===s[0])?s[0]:s,i=r?e.indexOf(r):-1;let o=dxe(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 mxe(e,s){const{x:r,y:n}=e;let a=!1;for(let i=0,o=s.length-1;i<s.length;o=i++){const l=s[i].x,c=s[i].y,d=s[o].x,h=s[o].y;c>n!=h>n&&r<(d-l)*(n-c)/(h-c)+l&&(a=!a)}return a}function hxe(e,s){if(!s)return!1;const r={x:e.clientX,y:e.clientY};return mxe(r,s)}function W0(e){return s=>s.pointerType==="mouse"?e(s):void 0}var pxe=EQ,fxe=HO,gxe=AQ,xxe=MQ,vxe=KO,yxe=RQ,bxe=Jk,wxe=OQ,jxe=LQ,Nxe=FQ,Sxe=UQ,Cxe=zQ,kxe=HQ,_xe=VQ,Pxe=KQ,QO="DropdownMenu",[Exe]=oo(QO,[_Q]),Qd=_Q(),[Txe,YQ]=Exe(QO),QQ=e=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,c=Qd(s),d=u.useRef(null),[h=!1,p]=ip({prop:a,defaultProp:i,onChange:o});return t.jsx(Txe,{scope:s,triggerId:wu(),triggerRef:d,contentId:wu(),open:h,onOpenChange:p,onOpenToggle:u.useCallback(()=>p(g=>!g),[p]),modal:l,children:t.jsx(pxe,{...c,open:h,onOpenChange:p,dir:n,modal:l,children:r})})};QQ.displayName=QO;var XQ="DropdownMenuTrigger",ZQ=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=e,i=YQ(XQ,r),o=Qd(r);return t.jsx(fxe,{asChild:!0,...o,children:t.jsx(Cr.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":n?"":void 0,disabled:n,...a,ref:jf(s,i.triggerRef),onPointerDown:Ms(e.onPointerDown,l=>{!n&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:Ms(e.onKeyDown,l=>{n||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});ZQ.displayName=XQ;var Axe="DropdownMenuPortal",JQ=e=>{const{__scopeDropdownMenu:s,...r}=e,n=Qd(s);return t.jsx(gxe,{...n,...r})};JQ.displayName=Axe;var eX="DropdownMenuContent",tX=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=YQ(eX,r),i=Qd(r),o=u.useRef(!1);return t.jsx(xxe,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...n,ref:s,onCloseAutoFocus:Ms(e.onCloseAutoFocus,l=>{o.current||a.triggerRef.current?.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:Ms(e.onInteractOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,h=c.button===2||d;(!a.modal||h)&&(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)"}})});tX.displayName=eX;var Mxe="DropdownMenuGroup",Rxe=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(vxe,{...a,...n,ref:s})});Rxe.displayName=Mxe;var Ixe="DropdownMenuLabel",sX=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(yxe,{...a,...n,ref:s})});sX.displayName=Ixe;var Oxe="DropdownMenuItem",rX=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(bxe,{...a,...n,ref:s})});rX.displayName=Oxe;var Dxe="DropdownMenuCheckboxItem",nX=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(wxe,{...a,...n,ref:s})});nX.displayName=Dxe;var Lxe="DropdownMenuRadioGroup",$xe=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(jxe,{...a,...n,ref:s})});$xe.displayName=Lxe;var Fxe="DropdownMenuRadioItem",aX=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(Nxe,{...a,...n,ref:s})});aX.displayName=Fxe;var Bxe="DropdownMenuItemIndicator",iX=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(Sxe,{...a,...n,ref:s})});iX.displayName=Bxe;var Uxe="DropdownMenuSeparator",oX=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(Cxe,{...a,...n,ref:s})});oX.displayName=Uxe;var zxe="DropdownMenuArrow",Hxe=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(kxe,{...a,...n,ref:s})});Hxe.displayName=zxe;var qxe="DropdownMenuSubTrigger",lX=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(_xe,{...a,...n,ref:s})});lX.displayName=qxe;var Vxe="DropdownMenuSubContent",cX=u.forwardRef((e,s)=>{const{__scopeDropdownMenu:r,...n}=e,a=Qd(r);return t.jsx(Pxe,{...a,...n,ref:s,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)"}})});cX.displayName=Vxe;var Wxe=QQ,Kxe=ZQ,Gxe=JQ,dX=tX,uX=sX,mX=rX,hX=nX,pX=aX,fX=iX,gX=oX,xX=lX,vX=cX;const Yxe=Wxe,Qxe=Kxe,Xxe=u.forwardRef(({className:e,inset:s,children:r,...n},a)=>t.jsxs(xX,{ref:a,className:Cs("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",e),...n,children:[r,t.jsx(hi,{className:"ml-auto"})]}));Xxe.displayName=xX.displayName;const Zxe=u.forwardRef(({className:e,...s},r)=>t.jsx(vX,{ref:r,className:Cs("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]:sli
272de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",e),...s}));Zxe.displayName=vX.displayName;const yX=u.forwardRef(({className:e,sideOffset:s=4,...r},n)=>t.jsx(Gxe,{children:t.jsx(dX,{ref:n,sideOffset:s,className:Cs("z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-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 origin-[--radix-dropdown-menu-content-transform-origin]",e),...r})}));yX.displayName=dX.displayName;const rg=u.forwardRef(({className:e,inset:s,...r},n)=>t.jsx(mX,{ref:n,className:Cs("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",e),...r}));rg.displayName=mX.displayName;const Jxe=u.forwardRef(({className:e,children:s,checked:r,...n},a)=>t.jsxs(hX,{ref:a,className:Cs("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:r,...n,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(fX,{children:t.jsx(Hd,{className:"h-4 w-4"})})}),s]}));Jxe.displayName=hX.displayName;const eve=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(pX,{ref:n,className:Cs("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(fX,{children:t.jsx(PK,{className:"h-2 w-2 fill-current"})})}),s]}));eve.displayName=pX.displayName;const tve=u.forwardRef(({className:e,inset:s,...r},n)=>t.jsx(uX,{ref:n,className:Cs("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",e),...r}));tve.displayName=uX.displayName;const rM=u.forwardRef(({className:e,...s},r)=>t.jsx(gX,{ref:r,className:Cs("-mx-1 my-1 h-px bg-muted",e),...s}));rM.displayName=gX.displayName;function sve(e,s){const r=e?.[0]||"",n=s?.[0]||"";return(r+n).toUpperCase()||"U"}function qd({showDashboardLink:e=!1,dashboardHref:s="/",onRefresh:r,onBellClick:n,offlineCount:a,hasNewOffline:i,newSmartAlertCount:o=0}){const{user:l,logout:c}=Gi(),d=Er(),[h,p]=Ia(),[g,v]=u.useState(!1),{data:b}=ze({queryKey:["/api/user/role"]}),y=b?.role||"user",w=y==="superadmin"||y==="admin"||y==="owner",j=!!b?.auditingDisabled,x=y==="admin"&&!!b?.hideOrdersQuotes,C=h==="/",k=!!l?.isDemo,S=l?.viewAs,_=!!S?.active,A=_?S?.realRole||"user":y,T=A==="superadmin"||A==="admin"||A==="owner";return t.jsxs("div",{className:"flex items-center gap-1",children:[C&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{k&&c(),p("/home")},"data-testid":"button-home-dashboard",children:t.jsx(Ik,{className:"w-5 h-5"})})}),t.jsx(Yt,{children:k?"Exit demo":"Website Home"})]}),r&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:r,"data-testid":"button-refresh-dashboard",children:t.jsx(tl,{className:"w-5 h-5"})})}),t.jsx(Yt,{children:"Refresh"})]}),C&&w&&!j&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>p("/audit"),"data-testid":"button-audit",children:t.jsx(xu,{className:"w-5 h-5"})})}),t.jsx(Yt,{children:"Audit Reporting"})]}),n&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{variant:"ghost",size:"icon",className:"relative",onClick:n,"data-testid":"button-notifications-bell",children:[t.jsx(mi,{className:"w-5 h-5"}),(a??0)>0&&i||o>0?t.jsx("span",{className:"absolute -top-1 -right-1 flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded-full bg-destructive text-destructive-foreground text-[10px] font-bold","data-testid":"badge-offline-count",children:(i?a??0:0)+o}):null]})}),t.jsx(Yt,{children:"Notifications"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>p("/preferences"),disabled:k,"data-testid":"button-preferences",children:t.jsx(oO,{className:"w-5 h-5"})})}),t.jsx(Yt,{children:k?"Not available in the live demo":"Preferences"})]}),t.jsxs(Yxe,{modal:!1,children:[t.jsx(Qxe,{asChild:!0,children:t.jsxs(L,{variant:"ghost",className:"gap-2","data-testid":"button-user-menu",children:[t.jsxs(cy,{className:"w-8 h-8",children:[t.jsx(dy,{src:l?.profileImageUrl||void 0}),t.jsx(uy,{className:"bg-primary text-primary-foreground text-xs",children:sve(l?.firstName,l?.lastName)})]}),t.jsx("span",{className:"hidden sm:inline text-sm",children:l?.firstName||"User"}),t.jsx(Xa,{className:"w-4 h-4"})]})}),t.jsxs(yX,{align:"end",className:"w-56",children:[t.jsxs("div",{className:"px-2 py-1.5",children:[t.jsxs("p",{className:"text-sm font-medium",children:[l?.firstName," ",l?.lastName]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:l?.email}),y!=="user"&&t.jsx("p",{className:"text-xs text-primary font-medium mt
272-1",children:y==="superadmin"?`${d.brandName} Database Administrator`:y==="admin"?"Administrator":y==="owner"?"Owner":""})]}),t.jsx(rM,{}),e&&t.jsxs(rg,{onClick:()=>p(s),"data-testid":"menu-dashboard",children:[t.jsx(tO,{className:"w-4 h-4 mr-2"}),"Dashboard"]}),w&&t.jsxs(rg,{onClick:()=>p("/admin"),"data-testid":"menu-admin-control",children:[t.jsx(uc,{className:"w-4 h-4 mr-2"}),y==="owner"?"Owner Settings":"Admin Settings"]}),(y==="superadmin"||y==="admin")&&!x&&t.jsxs(rg,{onClick:()=>p("/edge-quote"),"data-testid":"menu-edge-quote",children:[t.jsx(xu,{className:"w-4 h-4 mr-2"}),"Create Quote"]}),t.jsxs(rg,{onClick:()=>p("/account"),disabled:k,"data-testid":"menu-account",children:[t.jsx(dO,{className:"w-4 h-4 mr-2"}),"My Account"]}),t.jsxs(rg,{onClick:()=>p("/device-notifications"),"data-testid":"menu-device-notifications",children:[t.jsx(mi,{className:"w-4 h-4 mr-2"}),"Notifications"]}),T&&!k&&!_&&t.jsxs(rg,{onClick:()=>v(!0),"data-testid":"menu-view-as",children:[t.jsx(Xr,{className:"w-4 h-4 mr-2"}),"View As..."]}),t.jsx(rM,{}),t.jsxs(rg,{onClick:()=>c(),"data-testid":"menu-logout",children:[t.jsx(hde,{className:"w-4 h-4 mr-2"}),"Sign Out"]})]})]}),t.jsx(Nge,{open:g,onOpenChange:v})]})}const j6=e=>!!e.edgeDevice?.cloudEnabled;function rve({siteId:e,camera:s,allowed:r,offline:n,refreshKey:a,onFrameLoaded:i,onFrameError:o}){const l=Er(),[c,d]=u.useState(""),[h,p]=u.useState(0),g=`/api/sites/${e}/cameras/${encodeURIComponent(s.name)}/thumbnail?w=352&h=288&format=webp&quality=72&t=${a}-${h}`,v=r&&c!==g;return u.useEffect(()=>{if(!c)return;const b=setTimeout(()=>{p(Date.now()),d("")},2e4);return()=>clearTimeout(b)},[c]),t.jsxs("div",{className:"relative aspect-video overflow-hidden bg-background flex items-center justify-center",children:[v?t.jsx("img",{src:g,alt:"",loading:"lazy",className:"w-full h-full object-cover",onLoad:i,onError:()=>{d(g),o()}}):t.jsxs("div",{className:"flex flex-col items-center gap-2 text-muted-foreground text-xs",children:[!n&&r?t.jsx("img",{src:l.appEmblemUrl||"/truvios-emblem.png",alt:"",className:"w-8 h-8 object-contain opacity-80"}):t.jsx(QK,{className:"w-5 h-5"}),t.jsx("span",{children:n?"Camera offline":"Camera Stream Error"})]}),t.jsx("span",{className:"absolute top-2 left-2 rounded bg-background/80 px-1.5 py-0.5 text-[10px] text-foreground",children:s.name})]})}function nve({companies:e,initialSelectedSiteId:s,hideCompanies:r,canOpenDeviceSettings:n,deviceStatuses:a,restartingSites:i,restartingKinds:o,canManageSite:l,canRestartSite:c=!1,isSiteReachable:d,onEditSite:h,onRestartSite:p,onLive:g,matrixLayout:v,matrixLayoutSaving:b,onMatrixLayoutChange:y,renderSiteMetrics:w}){const[,j]=Ia(),[x,C]=u.useState(s??null),[k,S]=u.useState(null),[_,A]=u.useState(""),[T,M]=u.useState(new Set),[R,D]=u.useState(0),[$]=u.useState(()=>Date.now()),[O,q]=u.useState(new Set),V=u.useMemo(()=>e.flatMap(Ae=>Ae.sites),[e]),K=v===4?2:3,G=u.useMemo(()=>[...V].sort((Ae,Be)=>+!!Be.isOnline-+!!Ae.isOnline||zi(Ae.name,Be.name)),[V]),z=r?[{id:"sites-only",name:"Sites",sites:G}]:e,Z=V.find(Ae=>Ae.id===x)??(r?G[0]:V[0]),ee=!!Z?.isOnline&&!i.has(Z.id),Q=!!Z&&i.has(Z.id),Y=Z&&o?.get(Z.id)==="hard"?"Rebooting…":"Restarting…",oe=!ee||!!Z&&d?.(Z)===!1,he=ze({queryKey:["/api/sites",Z?.id,"my-permissions"],enabled:!!Z,refetchInterval:3e4}),je=he.isSuccess&&he.data?.privacyBlocked===!1,pe=ze({queryKey:["/api/sites",Z?.id,"cameras?summary=1"],enabled:ee&&je,retry:1}),le=u.useMemo(()=>je?(pe.data?.cameras??[]).filter(Ae=>Ae.enabled&&!he.data?.restrictedCameras?.includes(Ae.name)):[],[je,pe.data,he.data]),ue=Ae=>a?.find(Be=>Be.edgeDeviceId===Z?.edgeDevice?.id&&Be.cameraName===Ae),fe=Ae=>`${Z?.id}:${Ae}`,H=Ae=>O.has(fe(Ae))?!0:ue(Ae)?.isOnline,se=(Ae,Be)=>
272{const J=fe(Ae);q(ae=>{if(ae.has(J)===Be)return ae;const we=new Set(ae);return Be?we.add(J):we.delete(J),we})},me=le.filter(Ae=>`${Ae.name} ${Ae.displayName||""}`.toLowerCase().includes(_.trim().toLowerCase())),ge=Math.max(0,Math.ceil(me.length/v)-1),be=Math.min(R,ge),ce=me.slice(be*v,(be+1)*v),Pe=le.find(Ae=>Ae.name===k)??me[0],et=le.filter(Ae=>H(Ae.name)===!0).length,$e=le.filter(Ae=>H(Ae.name)===!1).length,bt=Ae=>{C(Ae),q(new Set),S(null),D(0),A("")};return Z?t.jsxs("div",{className:"grid lg:grid-cols-[240px_minmax(0,1fr)] lg:h-[calc(100dvh-200px)] lg:min-h-[320px] border border-border rounded-lg overflow-hidden bg-card","data-testid":"dashboard-classic-view",children:[t.jsxs("aside",{className:"bg-sidebar border-b lg:border-b-0 lg:border-r border-sidebar-border lg:flex lg:flex-col lg:min-h-0","aria-label":"Sites and cameras",children:[t.jsxs("div",{className:"p-4 border-b border-sidebar-border",children:[t.jsx("h2",{className:"font-semibold mb-3",children:"Sites & cameras"}),t.jsx("label",{className:"lg:hidden text-xs text-muted-foreground",htmlFor:"classic-site-picker",children:"Site"}),t.jsx("select",{id:"classic-site-picker",className:"lg:hidden w-full h-9 rounded-md border border-input bg-background px-2 text-sm mb-3",value:Z.id,onChange:Ae=>bt(Ae.target.value),children:z.flatMap(Ae=>Ae.sites.map(Be=>t.jsx("option",{value:Be.id,children:r?Be.name:`${Ae.name} / ${Be.name}`},Be.id)))}),t.jsxs("div",{className:"relative",children:[t.jsx(yc,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),t.jsx(ke,{value:_,onChange:Ae=>{A(Ae.target.value),D(0)},placeholder:"Search cameras...","aria-label":"Search cameras",className:"h-9 pl-8 text-xs"})]})]}),t.jsx("div",{className:"hidden lg:block lg:flex-1 lg:min-h-0 p-2 overflow-y-auto",children:z.map(Ae=>t.jsxs("div",{children:[!r&&t.jsxs("button",{type:"button",className:"flex items-center gap-2 w-full text-left text-xs font-semibold px-2 py-2 hover:bg-muted rounded",onClick:()=>M(Be=>{const J=new Set(Be);return J.has(Ae.id)?J.delete(Ae.id):J.add(Ae.id),J}),"aria-expanded":!T.has(Ae.id),children:[T.has(Ae.id)?t.jsx(hi,{className:"w-3.5 h-3.5"}):t.jsx(Xa,{className:"w-3.5 h-3.5"}),t.jsx(xi,{className:"w-3.5 h-3.5 text-primary"}),t.jsx("span",{className:"truncate",children:Ae.name})]}),(r||!T.has(Ae.id))&&Ae.sites.map((Be,J)=>t.jsxs("div",{children:[r&&!Be.isOnline&&(J===0||Ae.sites[J-1].isOnline)&&t.jsxs("div",{role:"separator","aria-label":"Offline sites",className:"flex items-center gap-2 px-2 pt-3 pb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[t.jsx("span",{children:"Offline"}),t.jsx("span",{className:"h-px flex-1 bg-sidebar-border","aria-hidden":"true"})]}),t.jsxs("button",{type:"button","data-testid":`classic-site-${Be.id}`,onClick:()=>bt(Be.id),className:`flex items-center gap-2 w-full min-w-0 text-left rounded px-2 py-2 text-xs hover:bg-muted ${Z.id===Be.id?"bg-primary/10 text-primary border-l-2 border-primary":"text-muted-foreground"}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${i.has(Be.id)?"bg-amber-500":Be.isOnline?"bg-green-500":"bg-destructive"}`}),j6(Be)?t.jsx(pn,{className:"w-3.5 h-3.5 shrink-0","aria-label":"Cloud-enabled site"}):t.jsx(Fa,{className:"w-3.5 h-3.5 shrink-0"}),t.jsx("span",{className:"truncate flex-1",children:Be.name})]}),Z.id===Be.id&&je&&ee&&t.jsx("div",{className:"ml-5 border-l border-border pl-1",children:le.filter(ae=>`${ae.name} ${ae.displayName||""}`.toLowerCase().includes(_.trim().toLowerCase())).map(ae=>t.jsxs("button",{type:"button",onClick:()=>S(ae.name),className:`flex items-center gap-2 w-full rounded px-2 py-1.5 text-xs text-left hover:bg-muted ${Pe?.name===ae.name?"bg-muted text-foreground":"text-muted-foreground"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${H(ae.name)===!1?"bg-destructive":H(ae.name)===!0?"bg-green-500":"bg-amber-500"}`}),t.jsx("span",{className:"truncate",children:ae.displayName||ae.name})]},ae.name))})]},Be.id))]},Ae.id))}),t.jsxs("div",{className:"hidden lg:flex shrink-0 items-center gap-2 px-4 py-3 text-xs text-muted-foreground border-t border-sidebar-border",children:[t.jsx(vc,{className:"w-3.5 h-3.5 text-primary"}),V.filter(Ae=>Ae.isOnline).length," online · ",V.filter(Ae=>!Ae.isOnline).length," offline"]})]}),t.jsxs("section",{className:"min-w-0 min-h-0 flex flex-col","aria-label":"Classic camera matrix",children:[t.jsx("div",{className:"px-4 sm:px-5 py-4 border-b border-border",children:t.jsxs("div",{children:[t.jsxs("h2",{className:"flex items-center gap-2 font-semibold text-lg",children:[j6(Z)&&t.jsx(pn,{className:"w-4 h-4 shrink-0","aria-label":"Cloud-enabled site"}),Z.name]}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t.jsx("span",{className:`inline-block w-2 h-2 rounded-full mr-1 ${Q?"bg-amber-500":ee?"bg-green-500":"bg-destructive"}`}),Q?Y:ee?"Device online":"Device offline"]})]})}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2 px-4 sm:px-5 py-2.5 border-b border-border bg-muted/30",children:[t.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[t.jsxs("span",{children:[t.jsx("strong",{className:"text-foreground",children:je&&ee?le.length:"—"})," Total Cameras"]}),t.jsxs("span",{children:[t.jsx("strong",{className:"text-foreground",children:je&&ee?et:"—"})," online"]}),t.jsxs("span",{children:[t.jsx("strong",{className:"text-foreground",children:je&&ee?$e:"—"})," offline"]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 sm:gap-2",children:[t.jsxs(L,{size:"sm",variant:"outline",className:"px-2 sm:px-3",disabled:!ee||!je||!Pe||!me.includes(Pe),onClick:()=>{Pe&&g(Z,Pe,le)},children:[t.jsx(vu,{className:"w-3.5 h-3.5 mr-1"})," Live View"]}),t.jsxs(L,{size:"sm",variant:"outline",className:"px-2 sm:px-3",onClick:()=>j(`/recordings?siteId=${encodeURIComponent(Z.id)}&view=events`),children:[t.jsx(cn,{className:"w-3.5 h-3.5 mr-1"})," Events"]}),n&&t.jsxs(L,{size:"sm",variant:"outline",className:"px-2 sm:px-3",disabled:!ee,onClick:()=>
272j(`/device-settings/${Z.id}?from=classic`),"data-testid":"classic-device-settings",children:[t.jsx(xd,{className:"w-3.5 h-3.5 mr-1"}),t.jsx("span",{className:"sm:hidden",children:"Settings"}),t.jsx("span",{className:"hidden sm:inline",children:"Device Settings"})]}),l?.(Z)&&h&&t.jsxs(L,{size:"sm",variant:"outline",className:"px-2 sm:px-3",onClick:()=>h(Z),"data-testid":"classic-edit-site",children:[t.jsx(ga,{className:"w-3.5 h-3.5 mr-1"})," Edit Site"]}),c&&p&&t.jsxs(L,{size:"sm",variant:"outline",className:"px-2 sm:px-3",disabled:oe,onClick:()=>{oe||p(Z)},"data-testid":"classic-restart-site",children:[Q?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(tl,{className:"w-3.5 h-3.5 mr-1"}),Q?Y:"Restart"]})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 sm:px-5 py-3",children:[t.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Camera matrix ",t.jsx("span",{className:"normal-case text-muted-foreground font-normal ml-1",children:je&&ee?`${me.length} channels`:""})]}),t.jsxs("div",{className:"flex items-center border border-border rounded-md","aria-label":"Matrix density",children:[t.jsx(L,{variant:"ghost",size:"icon",className:`h-8 w-8 rounded-r-none ${K===2?"bg-muted":""}`,"aria-label":"Four camera grid","aria-pressed":v===4,disabled:b,onClick:()=>{D(0),y(4)},children:t.jsx(ade,{className:"w-4 h-4"})}),t.jsx(L,{variant:"ghost",size:"icon",className:`h-8 w-8 rounded-l-none ${K===3?"bg-muted":""}`,"aria-label":"Nine camera grid","aria-pressed":v===9,disabled:b,onClick:()=>{D(0),y(9)},children:t.jsx(JI,{className:"w-4 h-4"})})]})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 sm:px-5 pb-4",children:ee?he.isPending?t.jsx("div",{className:"text-center py-16 text-sm text-muted-foreground",children:"Checking video access…"}):he.isError?t.jsx("div",{className:"text-center py-16 text-sm text-destructive",children:"Could not confirm video access. Please try again later."}):he.data?.privacyBlocked?t.jsxs("div",{className:"text-center py-16 text-sm text-muted-foreground","data-testid":"classic-privacy-blocked",children:[t.jsx(ka,{className:"w-7 h-7 mx-auto mb-2"}),"Video hidden by site owner."]}):pe.isPending?t.jsx("div",{className:"text-center py-16 text-sm text-muted-foreground",children:"Loading cameras…"}):pe.isError?t.jsx("div",{className:"text-center py-16 text-sm text-destructive",children:"Could not load cameras. Please try again later."}):me.length===0?t.jsx("div",{className:"text-center py-16 text-sm text-muted-foreground",children:_?"No cameras match your search.":"No cameras are available."}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`grid gap-2 ${K===2?"grid-cols-1 sm:grid-cols-2":"grid-cols-2 xl:grid-cols-3"}`,children:ce.map(Ae=>{const Be=H(Ae.name);return t.jsxs("button",{type:"button","data-testid":`classic-camera-${Ae.name}`,onClick:()=>{S(Ae.name),ee&&je&&g(Z,Ae,le)},className:`min-w-0 border text-left rounded-md overflow-hidden bg-card hover:border-primary/70 ${Pe?.name===Ae.name?"border-primary ring-1 ring-primary":"border-border"}`,children:[t.jsx(rve,{siteId:Z.id,camera:Ae,offline:Be===!1,allowed:je,refreshKey:$,onFrameLoaded:()=>se(Ae.name,!0),onFrameError:()=>se(Ae.name,!1)}),t.jsxs("span",{className:"flex items-center gap-2 px-2 py-2 text-xs",children:[t.jsx("span",{className:`w-2 h-2 shrink-0 rounded-full ${Be===!0?"bg-green-500":Be===!1?"bg-destructive":"bg-amber-500"}`}),t.jsx("span",{className:"truncate flex-1 font-medium",children:Ae.displayName||Ae.name}),t.jsx("span",{className:"text-[10px] text-muted-foreground",children:Be===!1?"OFFLINE":"PREVIEW"})]})]},`${Z.id}:${Ae.name}`)})}),ge>0&&t.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3 text-xs text-muted-foreground",children:[t.jsx(L,{variant:"outline",size:"sm",disabled:be===0,onClick:()=>D(be-1),children:"Previous"}),"Page ",be+1," of ",ge+1,t.jsx(L,{variant:"outline",size:"sm",disabled:be===ge,onClick:()=>D(be+1),children:"Next"})]})]}):t.jsxs("div",{className:"text-center py-16 text-sm text-muted-foreground",children:[t.jsx(QK,{className:"w-7 h-7 mx-auto mb-2"}),"Camera previews unavailable while the site is offline."]})}),w?.(Z)]})]}):t.jsx(ut,{className:"p-12 text-center text-muted-foreground",children:"No sites to show."})}var bX="AlertDialog",[ave]=oo(bX,[CY]),Nf=CY(),wX=e=>{const{__scopeAlertDialog:s,...r}=e,n=Nf(s);return t.jsx(UY,{...n,...r,modal:!0})};wX.displayName=bX;var ive="AlertDialogTrigger",ove=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,a=Nf(r);return t.jsx(zY,{...a,...n,ref:s})});ove.displayName=ive;var lve="AlertDialogPortal",jX=e=>{const{__scopeAlertDialog:s,...r}=e,n=Nf(s);return t.jsx(HY,{...n,...r})};jX.displayName=lve;var cve="AlertDialogOverlay",NX=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,a=Nf(r);return t.jsx(LO,{...a,...n,ref:s})});NX.displayName=cve;var my="AlertDialogContent",[dve,uve]=ave(my),mve=GW("AlertDialogContent"),SX=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,children:n,...a}=e,i=Nf(r),o=u.useRef(null),l=mr(s,o),c=u.useRef(null);return t.jsx(Nfe,{contentName:my,titleName:CX,docsSlug:"alert-dialog",children:t.jsx(dve,{scope:r,cancelRef:c,children:t.jsxs($O,{role:"alertdialog",...i,...a,ref:l,onOpenAutoFocus:Ms(a.onOpenAutoFocus,d=>{d.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[t.jsx(mve,{children:n}),t.jsx(pve,{contentRef:o})]})})})});SX.displayName=my;var CX="AlertDialogTitle",kX=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,a=Nf(r);return t.jsx(FO,{...a,...n,ref:s})});kX.displayName=CX;var _X="AlertDialogDescription",PX=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,a=Nf(r);return t.jsx(BO,{...a,...n,ref:s})});PX.displayName=_X;var hve="AlertDialogAction",EX=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,a=Nf(r);return t.jsx(Yk,{...a,...n,ref:s})});EX.displayName=hve;var TX="AlertDialogCancel",AX=u.forwardRef((e,s)=>{const{__scopeAlertDialog:r,...n}=e,{cancelRef:a}=uve(TX,r),i=Nf(r),o=mr(s,a);return t.jsx(Yk,{...i,...n,ref:o})});AX.displayName=TX;var pve=({contentRef:e})=>{const s=`\`${my}\` requires a description for the component to be accessible for screen reader users.
273
274You can add a description to the \`${my}\` by passing a \`${_X}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
275
276Alternatively, 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 \`${my}\`. 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.
277
278For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return u.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(s)},[s,e]),null},fve=wX,gve=jX,MX=NX,RX=SX,IX=EX,OX=AX,DX=kX,LX=PX;const zd=fve,xve=gve,$X=u.forwardRef(({className:e,...s},r)=>t.jsx(MX,{className:Cs("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),...s,ref:r}));$X.displayName=MX.displayName;const bd=u.forwardRef(({className:e,...s},r)=>t.jsxs(xve,{children:[t.jsx($X,{}),t.jsx(RX,{ref:r,className:Cs("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),...s})]}));bd.displayName=RX.displayName;const wd=({className:e,...s})=>t.jsx("div",{className:Cs("flex flex-col space-y-2 text-center sm:text-left",e),...s});wd.displayName="AlertDialogHeader";const jd=({className:e,...s})=>t.jsx("div",{className:Cs("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...s});jd.displayName="AlertDialogFooter";const Nd=u.forwardRef(({className:e,...s},r)=>t.jsx(DX,{ref:r,className:Cs("text-lg font-semibold",e),...s}));Nd.displayName=DX.displayName;const Sd=u.forwardRef(({className:e,...s},r)=>t.jsx(LX,{ref:r,className:Cs("text-sm text-muted-foreground",e),...s}));Sd.displayName=LX.displayName;const Cd=u.forwardRef(({className:e,...s},r)=>t.jsx(IX,{ref:r,className:Cs(H0(),e),...s}));Cd.displayName=IX.displayName;const Gc=u.forwardRef(({className:e,...s},r)=>t.jsx(OX,{ref:r,className:Cs(H0({variant:"outline"}),"mt-2 sm:mt-0",e),...s}));Gc.displayName=OX.displayName;function XO({site:e,open:s,onOpenChange:r,onMarkRestarting:n,onClearRestarting:a}){const{toast:i}=Hs(),[o,l]=u.useState(null),c=u.useRef(!1),d=u.useRef(!1),h=u.useRef(0),[p,g]=u.useState({loading:!1,available:!1});u.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),u.useEffect(()=>{s&&!c.current&&(h.current+=1,l(e),g({loading:!0,available:!1})),!s&&c.current&&(l(null),g({loading:!1,available:!1})),c.current=s},[s,e]),u.useEffect(()=>{if(!s||!o)return;const x=new AbortController;let C=!0;return g({loading:!0,available:!1}),fetch(`/api/sites/${o.id}/hard-boot-available`,{credentials:"include",signal:x.signal}).then(k=>{if(!k.ok)throw new Error("Unable to check restart availability");return k.json()}).then(k=>{C&&g({loading:!1,available:k.available===!0})}).catch(()=>{C&&g({loading:!1,available:!1})}),()=>{C=!1,x.abort()}},[s,o?.id]);const v=x=>{d.current&&c.current&&h.current===x.session&&r(!1)},b=Et({mutationFn:({site:x})=>Ze("POST",`/api/sites/${x.id}/restart`),onMutate:({site:x})=>{n?.(x.id)},onSuccess:(x,C)=>{const k=C.site;i({title:"Soft boot sent",description:`${k.name} software is restarting. It may take a moment to come back online.`}),v(C),Je.invalidateQueries({queryKey:["/api/sites/restarting"]})},onError:(x,C)=>{const k=C.site;i({title:"Soft boot failed",description:x?.message||"Could not send restart command",variant:"destructive"}),v(C),a?.(k.id)}}),y=Et({mutationFn:({site:x})=>Ze("POST",`/api/sites/${x.id}/hard-boot`),onMutate:({site:x})=>{n?.(x.id)},onSuccess:(x,C)=>{const k=C.site;i({title:"Hard boot sent",description:`${k.name} machine is rebooting. It will be offline for a few minutes.`}
278),v(C),Je.invalidateQueries({queryKey:["/api/sites/restarting"]})},onError:(x,C)=>{const k=C.site;i({title:"Hard boot failed",description:x?.message||"Could not send reboot command",variant:"destructive"}),v(C),a?.(k.id)}}),w=o??e,j=b.isPending||y.isPending;return t.jsx(zd,{open:s,onOpenChange:r,children:t.jsxs(bd,{children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:"Restart Edge Device"}),t.jsx(Sd,{asChild:!0,children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("p",{children:[p.available||p.loading?"Choose a restart method for":"Restart"," ",t.jsx("strong",{children:w.name}),p.available||p.loading?":":"? The Edge software will restart briefly."]}),t.jsxs("div",{className:"space-y-2",children:[(p.available||p.loading)&&t.jsx("div",{className:"rounded-md border border-border p-3",children:t.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Soft Boot"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Restarts the Edge software only. Quick recovery."})]}),t.jsx(L,{size:"sm",className:"w-28",onClick:()=>o&&b.mutate({site:o,session:h.current}),disabled:j||!o,"data-testid":"button-confirm-soft-boot",children:b.isPending?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-3 h-3 mr-1 animate-spin"}),"Rebooting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(tl,{className:"w-3 h-3 mr-1"}),"Soft Boot"]})})]})}),p.loading&&t.jsx("div",{className:"rounded-md border border-border p-3",children:t.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Hard Boot"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Checking availability..."})]}),t.jsxs(L,{size:"sm",variant:"outline",className:"w-28",disabled:!0,children:[t.jsx(Fe,{className:"w-3 h-3 mr-1 animate-spin"}),"Checking"]})]})}),p.available&&!p.loading&&t.jsx("div",{className:"rounded-md border border-border p-3",children:t.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Hard Boot"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Reboots the entire machine. Longer recovery."})]}),t.jsx(L,{size:"sm",className:"w-28",onClick:()=>o&&y.mutate({site:o,session:h.current}),disabled:j||!o,"data-testid":"button-confirm-hard-boot",children:y.isPending?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-3 h-3 mr-1 animate-spin"}),"Rebooting..."]}):t.jsxs(t.Fragment,{children:[t.jsx(kg,{className:"w-3 h-3 mr-1"}),"Hard Boot"]})})]})})]})]})})]}),t.jsx(jd,{children:!p.available&&!p.loading?t.jsxs(t.Fragment,{children:[t.jsx(Gc,{"data-testid":"button-cancel-restart",children:"Cancel"}),t.jsx(Cd,{onClick:()=>o&&b.mutate({site:o,session:h.current}),disabled:b.isPending||!o,"data-testid":"button-confirm-soft-boot",children:b.isPending?"Restarting...":"Restart"})]}):t.jsx(Gc,{"data-testid":"button-cancel-restart",children:"Cancel"})})]})})}function vve(e){if(e.length!==2040)return!1;const s=61,r=new Uint16Array(s*35);for(let a=0;a<34;a++){let i=0;for(let o=0;o<60;o++)e[a*60+o]>100&&i++,r[(a+1)*s+o+1]=r[a*s+o+1]+i}const n=(a,i,o,l)=>r[l*s+o]-r[i*s+o]-r[l*s+a]+r[i*s+a];if(n(0,0,60,34)>=140)return!1;for(let a=0;a<=18;a++)for(let i=7;i<=14;i++){const o=a+Math.ceil(i*.2),l=a+Math.ceil(i*.8),c=a+Math.floor(i*.7);if(n(24,o,29,l)>=3&&n(31,o,36,l)>=3&&n(27,a,33,a+Math.ceil(i*.3))>=3&&n(27,c,33,a+i)>=3&&n(28,a+Math.ceil(i*.3),32,a+Math.floor(i*.7))>=2&&n(10,Math.min(33,a+i+2),50,34)<70)return!0}return!1}function Uw(e){try{const s=document.createElement("canvas");s.width=60,s.height=34;const r=s.getContext("2d",{willReadFrequently:!0});if(!r)return null;r.drawImage(e,0,0,60,34);const n=r.getImageData(0,0,60,34).data,a=new Uint8Array(2040);for(let i=0;i<a.length;i++)a[i]=Math.round(.299*n[i*4]+.587*n[i*4+1]+.114*n[i*4+2]);return vve(a)}catch{return null}}function af({src:e,compact:s=!1,onLoad:r,onError:n,style:a,...i}){const o=Er(),[l,c]=u.useState(""),[d,h]=u.useState(0),p=`${e}${e.includes("?")?"&":"?"}retry=${d}&clientChecks=1`,g=l===p;return u.useEffect(()=>{if(!g)return;const v=setTimeout(()=>{h(Date.now()),c("")},2e4);return()=>clearTimeout(v)},[g]),t.jsxs(t.Fragment,{children:[t.jsx("img",{...i,src:p,style:{...a,visibility:g?"hidden":a?.visibility},onLoad:v=>{if(Uw(v.currentTarget)===!0){c(p),r?.(v);return}c(""),r?.(v)},onError:v=>{c(p),n?.(v)}}),g&&t.jsxs("div",{className:`absolute inset-0 z-[6] flex flex-col items-center justify-center text-center bg-[#0a0a0a] ${s?"gap-0.5 px-0.5":"gap-2 px-2"}`,"data-testid":"live-camera-stream-error",children:[t.jsx("img",{src:o.appEmblemUrl||"/truvios-emblem.png",alt:"",className:`object-contain ${s?"w-4 h-4":"w-10 h-10"}`}),t.jsx("span",{className:`text-white/70 leading-tight ${s?"text-[7px]":"text-xs"}`,children:"Camera Stream Error"})]})]})}function Bt({className:e,...s}){return t.jsx("div",{className:Cs("animate-pulse rounded-md bg-muted",e),...s})}function yve(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return u.useMemo(()=>n=>
278{s.forEach(a=>a(n))},s)}const e_=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Eb(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function ZO(e){return"nodeType"in e}function Xd(e){var s,r;return e?Eb(e)?e:ZO(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function JO(e){const{Document:s}=Xd(e);return e instanceof s}function Zj(e){return Eb(e)?!1:e instanceof Xd(e).HTMLElement}function FX(e){return e instanceof Xd(e).SVGElement}function Tb(e){return e?Eb(e)?e.document:ZO(e)?JO(e)?e:Zj(e)||FX(e)?e.ownerDocument:document:document:document}const Sh=e_?u.useLayoutEffect:u.useEffect;function t_(e){const s=u.useRef(e);return Sh(()=>{s.current=e}),u.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return s.current==null?void 0:s.current(...n)},[])}function bve(){const e=u.useRef(null),s=u.useCallback((n,a)=>{e.current=setInterval(n,a)},[]),r=u.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function K0(e,s){s===void 0&&(s=[e]);const r=u.useRef(e);return Sh(()=>{r.current!==e&&(r.current=e)},s),r}function Jj(e,s){const r=u.useRef();return u.useMemo(()=>{const n=e(r.current);return r.current=n,n},[...s])}function GS(e){const s=t_(e),r=u.useRef(null),n=u.useCallback(a=>{a!==r.current&&s?.(a,r.current),r.current=a},[]);return[r,n]}function YS(e){const s=u.useRef();return u.useEffect(()=>{s.current=e},[e]),s.current}let fP={};function eN(e,s){return u.useMemo(()=>{if(s)return s;const r=fP[e]==null?0:fP[e]+1;return fP[e]=r,e+"-"+r},[e,s])}function BX(e){return function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return n.reduce((i,o)=>{const l=Object.entries(o);for(const[c,d]of l){const h=i[c];h!=null&&(i[c]=h+e*d)}return i},{...s})}}const hy=BX(1),QS=BX(-1);function wve(e){return"clientX"in e&&"clientY"in e}function s_(e){if(!e)return!1;const{KeyboardEvent:s}=Xd(e.target);return s&&e instanceof s}function jve(e){if(!e)return!1;const{TouchEvent:s}=Xd(e.target);return s&&e instanceof s}function XS(e){if(jve(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return wve(e)?{x:e.clientX,y:e.clientY}:null}const vf=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[vf.Translate.toString(e),vf.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:n}=e;return s+" "+r+"ms "+n}}}),N6="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Nve(e){return e.matches(N6)?e:e.querySelector(N6)}const Sve={display:"none"};function Cve(e){let{id:s,value:r}=e;return Ne.createElement("div",{id:s,style:Sve},r)}function kve(e){let{id:s,announcement:r,ariaLiveType:n="assertive"}=e;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ne.createElement("div",{id:s,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function _ve(){const[e,s]=u.useState("");return{announce:u.useCallback(n=>{n!=null&&s(n)},[]),announcement:e}}const UX=u.createContext(null);function Pve(e){const s=u.useContext(UX);u.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function Eve(){const[e]=u.useState(()=>new Set),s=u.useCallback(n=>(e.add(n),()=>e.delete(n)),[e]);return[u.useCallback(n=>{let{type:a,event:i}=n;e.forEach(o=>{var l;return(l=o[a])==null?void 0:l.call(o,i)})},[e]),s]}const Tve={draggable:`
279    To pick up a draggable item, press the space bar.
280    While dragging, use the arrow keys to move the item.
281    Press space again to drop the item in its new position, or press escape to cancel.
282  `},Ave={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function Mve(e){let{announcements:s=Ave,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=Tve}=e;const{announce:i,announcement:o}=_ve(),l=eN("DndLiveRegion"),[c,d]=u.useState(!1);if(u.useEffect(()=>{d(!0)},[]),Pve(u.useMemo(()=>({onDragStart(p){let{active:g}=p;i(s.onDragStart({active:g}))},onDragMove(p){let{active:g,over:v}=p;s.onDragMove&&i(s.onDragMove({active:g,over:v}))},onDragOver(p){let{active:g,over:v}=p;i(s.onDragOver({active:g,over:v}))},onDragEnd(p){let{active:g,over:v}=p;i(s.onDragEnd({active:g,over:v}))},onDragCancel(p){let{active:g,over:v}=p;i(s.onDragCancel({active:g,over:v}))}}),[i,s])),!c)return null;const h=Ne.createElement(Ne.Fragment,null,Ne.createElement(Cve,{id:n,value:a.draggable}),Ne.createElement(kve,{id:l,announcement:o}));return r?Em.createPortal(h,r):h}var Hl;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Hl||(Hl={}));function ZS(){}function Rve(e,s){return u.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Ive(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return u.useMemo(()=>[...s].filter(n=>n!=null),[...s])}const Ch=Object.freeze({x:0,y:0});function Ove(e,s){return Math.sqrt(Math.pow(e.x-s.x,2)+Math.pow(e.y-s.y,2))}function Dve(e,s){const r=XS(e);if(!r)return"0 0";const n={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return n.x+"% "+n.y+"%"}function Lve(e,s){let{data:{value:r}}=e,{data:{value:n}}=s;return r-n}function $ve(e,s){let{data:{value:r}}=e,{data:{value:n}}=s;return n-r}function Fve(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function S6(e,s,r){return s===void 0&&(s=e.left),r===void 0&&(r=e.top),{x:s+e.width*.5,y:r+e.height*.5}}
282const C6=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=e;const a=S6(s,s.left,s.top),i=[];for(const o of n){const{id:l}=o,c=r.get(l);if(c){const d=Ove(S6(c),a);i.push({id:l,data:{droppableContainer:o,value:d}})}}return i.sort(Lve)};function Bve(e,s){const r=Math.max(s.top,e.top),n=Math.max(s.left,e.left),a=Math.min(s.left+s.width,e.left+e.width),i=Math.min(s.top+s.height,e.top+e.height),o=a-n,l=i-r;if(n<a&&r<i){const c=s.width*s.height,d=e.width*e.height,h=o*l,p=h/(c+d-h);return Number(p.toFixed(4))}return 0}const Uve=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=e;const a=[];for(const i of n){const{id:o}=i,l=r.get(o);if(l){const c=Bve(l,s);c>0&&a.push({id:o,data:{droppableContainer:i,value:c}})}}return a.sort($ve)};function zve(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function zX(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Ch}function Hve(e){return function(r){for(var n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];return a.reduce((o,l)=>({...o,top:o.top+e*l.y,bottom:o.bottom+e*l.y,left:o.left+e*l.x,right:o.right+e*l.x}),{...r})}}const qve=Hve(1);function HX(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function Vve(e,s,r){const n=HX(s);if(!n)return e;const{scaleX:a,scaleY:i,x:o,y:l}=n,c=e.left-o-(1-a)*parseFloat(r),d=e.top-l-(1-i)*parseFloat(r.slice(r.indexOf(" ")+1)),h=a?e.width/a:e.width,p=i?e.height/i:e.height;return{width:h,height:p,top:d,right:c+h,bottom:d+p,left:c}}const Wve={ignoreTransform:!1};function Ab(e,s){s===void 0&&(s=Wve);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:d,transformOrigin:h}=Xd(e).getComputedStyle(e);d&&(r=Vve(r,d,h))}const{top:n,left:a,width:i,height:o,bottom:l,right:c}=r;return{top:n,left:a,width:i,height:o,bottom:l,right:c}}function k6(e){return Ab(e,{ignoreTransform:!0})}function Kve(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Gve(e,s){return s===void 0&&(s=Xd(e).getComputedStyle(e)),s.position==="fixed"}function Yve(e,s){s===void 0&&(s=Xd(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const i=s[a];return typeof i=="string"?r.test(i):!1})}function e3(e,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(JO(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!Zj(a)||FX(a)||r.includes(a))return r;const i=Xd(e).getComputedStyle(a);return a!==e&&Yve(a,i)&&r.push(a),Gve(a,i)?r:n(a.parentNode)}return e?n(e):r}function qX(e){const[s]=e3(e,1);return s??null}function gP(e){return!e_||!e?null:Eb(e)?e:ZO(e)?JO(e)||e===Tb(e).scrollingElement?window:Zj(e)?e:null:null}function VX(e){return Eb(e)?e.scrollX:e.scrollLeft}function WX(e){return Eb(e)?e.scrollY:e.scrollTop}function nM(e){return{x:VX(e),y:WX(e)}}var hc;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(hc||(hc={}));function KX(e){return!e_||!e?!1:e===document.scrollingElement}function GX(e){const s={x:0,y:0},r=KX(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},a=e.scrollTop<=s.y,i=e.scrollLeft<=s.x,o=e.scrollTop>=n.y,l=e.scrollLeft>=n.x;return{isTop:a,isLeft:i,isBottom:o,isRight:l,maxScroll:n,minScroll:s}}const Qve={x:.2,y:.2};function Xve(e,s,r,n,a){let{top:i,left:o,right:l,bottom:c}=r;n===void 0&&(n=10),a===void 0&&(a=Qve);const{isTop:d,isBottom:h,isLeft:p,isRight:g}=GX(e),v={x:0,y:0},b={x:0,y:0},y={height:s.height*a.y,width:s.width*a.x};return!d&&i<=s.top+y.height?(v.y=hc.Backward,b.y=n*Math.abs((s.top+y.height-i)/y.height)):!h&&c>=s.bottom-y.height&&(v.y=hc.Forward,b.y=n*Math.abs((s.bottom-y.height-c)/y.height)),!g&&l>=s.right-y.width?(v.x=hc.Forward,b.x=n*Math.abs((s.right-y.width-l)/y.width)):!p&&o<=s.left+y.width&&(v.x=hc.Backward,b.x=n*Math.abs((s.left+y.width-o)/y.width)),{direction:v,speed:b}}function Zve(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:o}=window;return{top:0,left:0,right:i,bottom:o,width:i,height:o}}const{top:s,left:r,right:n,bottom:a}=e.getBoundingClientRect();return{top:s,left:r,right:n,bottom:a,width:e.clientWidth,height:e.clientHeight}}function YX(e){return e.reduce((s,r)=>hy(s,nM(r)),Ch)}function Jve(e){return e.reduce((s,r)=>s+VX(r),0)}function eye(e){return e.reduce((s,r)=>s+WX(r),0)}function QX(e,s){if(s===void 0&&(s=Ab),!e)return;const{top:r,left:n,bottom:a,right:i}=s(e);qX(e)&&(a<=0||i<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const tye=[["x",["left","right"],Jve],["y",["top","bottom"],eye]];class t3{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=e3(r),a=YX(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[i,o,l]of tye)for(const c of o)Object.defineProperty(this,c,{get:()=>{const d=l(n),h=a[i]-d;return this.rect[c]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class s0{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>
282{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=s}add(s,r,n){var a;(a=this.target)==null||a.addEventListener(s,r,n),this.listeners.push([s,r,n])}}function sye(e){const{EventTarget:s}=Xd(e);return e instanceof s?e:Tb(e)}function xP(e,s){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+n**2)>s:"x"in s&&"y"in s?r>s.x&&n>s.y:"x"in s?r>s.x:"y"in s?n>s.y:!1}var Sm;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Sm||(Sm={}));function _6(e){e.preventDefault()}function rye(e){e.stopPropagation()}var $a;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})($a||($a={}));const XX={start:[$a.Space,$a.Enter],cancel:[$a.Esc],end:[$a.Space,$a.Enter,$a.Tab]},nye=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case $a.Right:return{...r,x:r.x+25};case $a.Left:return{...r,x:r.x-25};case $a.Down:return{...r,y:r.y+25};case $a.Up:return{...r,y:r.y-25}}};class ZX{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new s0(Tb(r)),this.windowListeners=new s0(Xd(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Sm.Resize,this.handleCancel),this.windowListeners.add(Sm.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Sm.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&QX(n),r(Ch)}handleKeyDown(s){if(s_(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:i=XX,coordinateGetter:o=nye,scrollBehavior:l="smooth"}=a,{code:c}=s;if(i.end.includes(c)){this.handleEnd(s);return}if(i.cancel.includes(c)){this.handleCancel(s);return}const{collisionRect:d}=n.current,h=d?{x:d.left,y:d.top}:Ch;this.referenceCoordinates||(this.referenceCoordinates=h);const p=o(s,{active:r,context:n.current,currentCoordinates:h});if(p){const g=QS(p,h),v={x:0,y:0},{scrollableAncestors:b}=n.current;for(const y of b){const w=s.code,{isTop:j,isRight:x,isLeft:C,isBottom:k,maxScroll:S,minScroll:_}=GX(y),A=Zve(y),T={x:Math.min(w===$a.Right?A.right-A.width/2:A.right,Math.max(w===$a.Right?A.left:A.left+A.width/2,p.x)),y:Math.min(w===$a.Down?A.bottom-A.height/2:A.bottom,Math.max(w===$a.Down?A.top:A.top+A.height/2,p.y))},M=w===$a.Right&&!x||w===$a.Left&&!C,R=w===$a.Down&&!k||w===$a.Up&&!j;if(M&&T.x!==p.x){const D=y.scrollLeft+g.x,$=w===$a.Right&&D<=S.x||w===$a.Left&&D>=_.x;if($&&!g.y){y.scrollTo({left:D,behavior:l});return}$?v.x=y.scrollLeft-D:v.x=w===$a.Right?y.scrollLeft-S.x:y.scrollLeft-_.x,v.x&&y.scrollBy({left:-v.x,behavior:l});break}else if(R&&T.y!==p.y){const D=y.scrollTop+g.y,$=w===$a.Down&&D<=S.y||w===$a.Up&&D>=_.y;if($&&!g.x){y.scrollTo({top:D,behavior:l});return}$?v.y=y.scrollTop-D:v.y=w===$a.Down?y.scrollTop-S.y:y.scrollTop-_.y,v.y&&y.scrollBy({top:-v.y,behavior:l});break}}this.handleMove(s,hy(QS(p,this.referenceCoordinates),v))}}}handleMove(s,r){const{onMove:n}=this.props;s.preventDefault(),n(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}ZX.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:n=XX,onActivation:a}=s,{active:i}=r;const{code:o}=e.nativeEvent;if(n.start.includes(o)){const l=i.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),a?.({event:e.nativeEvent}),!0)}return!1}}];function P6(e){return!!(e&&"distance"in e)}function E6(e){return!!(e&&"delay"in e)}class s3{constructor(s,r,n){var a;n===void 0&&(n=sye(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:i}=s,{target:o}=i;this.props=s,this.events=r,this.document=Tb(o),this.documentListeners=new s0(this.document),this.listeners=new s0(n),this.windowListeners=new s0(Xd(o)),this.initialCoordinates=(a=XS(i))!=null?a:Ch,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Sm.Resize,this.handleCancel),this.windowListeners.add(Sm.DragStart,_6),this.windowListeners.add(Sm.VisibilityChange,this.handleCancel),this.windowListeners.add(Sm.ContextMenu,_6),this.documentListeners.add(Sm.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(E6(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(P6(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:n,onPending:a}=this.props;a(n,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Sm.Click,rye,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Sm.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:n,initialCoordinates:a,props:i}=this,{onMove:o,options:{activationConstraint:l}}=i;if(!a)return;
282const c=(r=XS(s))!=null?r:Ch,d=QS(a,c);if(!n&&l){if(P6(l)){if(l.tolerance!=null&&xP(d,l.tolerance))return this.handleCancel();if(xP(d,l.distance))return this.handleStart()}if(E6(l)&&xP(d,l.tolerance))return this.handleCancel();this.handlePending(l,d);return}s.cancelable&&s.preventDefault(),o(c)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===$a.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const aye={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class r3 extends s3{constructor(s){const{event:r}=s,n=Tb(r.target);super(s,aye,n)}}r3.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;return!r.isPrimary||r.button!==0?!1:(n?.({event:r}),!0)}}];const iye={move:{name:"mousemove"},end:{name:"mouseup"}};var aM;(function(e){e[e.RightClick=2]="RightClick"})(aM||(aM={}));class oye extends s3{constructor(s){super(s,iye,Tb(s.event.target))}}oye.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;return r.button===aM.RightClick?!1:(n?.({event:r}),!0)}}];const vP={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class lye extends s3{constructor(s){super(s,vP)}static setup(){return window.addEventListener(vP.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(vP.move.name,s)};function s(){}}}lye.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:n}=s;const{touches:a}=r;return a.length>1?!1:(n?.({event:r}),!0)}}];var r0;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(r0||(r0={}));var JS;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(JS||(JS={}));function cye(e){let{acceleration:s,activator:r=r0.Pointer,canScroll:n,draggingRect:a,enabled:i,interval:o=5,order:l=JS.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:h,delta:p,threshold:g}=e;const v=uye({delta:p,disabled:!i}),[b,y]=bve(),w=u.useRef({x:0,y:0}),j=u.useRef({x:0,y:0}),x=u.useMemo(()=>{switch(r){case r0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case r0.DraggableRect:return a}},[r,a,c]),C=u.useRef(null),k=u.useCallback(()=>{const _=C.current;if(!_)return;const A=w.current.x*j.current.x,T=w.current.y*j.current.y;_.scrollBy(A,T)},[]),S=u.useMemo(()=>l===JS.TreeOrder?[...d].reverse():d,[l,d]);u.useEffect(()=>{if(!i||!d.length||!x){y();return}for(const _ of S){if(n?.(_)===!1)continue;const A=d.indexOf(_),T=h[A];if(!T)continue;const{direction:M,speed:R}=Xve(_,T,x,s,g);for(const D of["x","y"])v[D][M[D]]||(R[D]=0,M[D]=0);if(R.x>0||R.y>0){y(),C.current=_,b(k,o),w.current=R,j.current=M;return}}w.current={x:0,y:0},j.current={x:0,y:0},y()},[s,k,n,y,i,o,JSON.stringify(x),JSON.stringify(v),b,d,S,h,JSON.stringify(g)])}const dye={x:{[hc.Backward]:!1,[hc.Forward]:!1},y:{[hc.Backward]:!1,[hc.Forward]:!1}};function uye(e){let{delta:s,disabled:r}=e;const n=YS(s);return Jj(a=>{if(r||!n||!a)return dye;const i={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[hc.Backward]:a.x[hc.Backward]||i.x===-1,[hc.Forward]:a.x[hc.Forward]||i.x===1},y:{[hc.Backward]:a.y[hc.Backward]||i.y===-1,[hc.Forward]:a.y[hc.Forward]||i.y===1}}},[r,s,n])}function mye(e,s){const r=s!=null?e.get(s):void 0,n=r?r.node.current:null;return Jj(a=>{var i;return s==null?null:(i=n??a)!=null?i:null},[n,s])}function hye(e,s){return u.useMemo(()=>e.reduce((r,n)=>{const{sensor:a}=n,i=a.activators.map(o=>({eventName:o.eventName,handler:s(o.handler,n)}));return[...r,...i]},[]),[e,s])}var G0;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(G0||(G0={}));var iM;(function(e){e.Optimized="optimized"})(iM||(iM={}));const T6=new Map;function pye(e,s){let{dragging:r,dependencies:n,config:a}=s;const[i,o]=u.useState(null),{frequency:l,measure:c,strategy:d}=a,h=u.useRef(e),p=w(),g=K0(p),v=u.useCallback(function(j){j===void 0&&(j=[]),!g.current&&o(x=>x===null?j:x.concat(j.filter(C=>!x.includes(C))))},[g]),b=u.useRef(null),y=Jj(j=>{if(p&&!r)return T6;if(!j||j===T6||h.current!==e||i!=null){const x=new Map;for(let C of e){if(!C)continue;if(i&&i.length>0&&!i.includes(C.id)&&C.rect.current){x.set(C.id,C.rect.current);continue}const k=C.node.current,S=k?new t3(c(k),k):null;C.rect.current=S,S&&x.set(C.id,S)}return x}return j},[e,i,r,p,c]);return u.useEffect(()=>{h.current=e},[e]),u.useEffect(()=>{p||v()},[r,p]),u.useEffect(()=>{i&&i.length>0&&o(null)},[JSON.stringify(i)]),u.useEffect(()=>{p||typeof l!="number"||b.current!==null||(b.current=setTimeout(()=>{v(),b.current=null},l))},[l,p,v,...n]),{droppableRects:y,measureDroppableContainers:v,measuringScheduled:i!=null};function w(){switch(d){case G0.Always:return!1;case G0.BeforeDragging:return r;default:return!r}}}function n3(e,s){return Jj(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function fye(e,s){return n3(e,s)}function gye(e){let{callback:s,disabled:r}=e;const n=t_(s),a=u.useMemo(()=>
282{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(n)},[n,r]);return u.useEffect(()=>()=>a?.disconnect(),[a]),a}function r_(e){let{callback:s,disabled:r}=e;const n=t_(s),a=u.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(n)},[r]);return u.useEffect(()=>()=>a?.disconnect(),[a]),a}function xye(e){return new t3(Ab(e),e)}function A6(e,s,r){s===void 0&&(s=xye);const[n,a]=u.useState(null);function i(){a(c=>{if(!e)return null;if(e.isConnected===!1){var d;return(d=c??r)!=null?d:null}const h=s(e);return JSON.stringify(c)===JSON.stringify(h)?c:h})}const o=gye({callback(c){if(e)for(const d of c){const{type:h,target:p}=d;if(h==="childList"&&p instanceof HTMLElement&&p.contains(e)){i();break}}}}),l=r_({callback:i});return Sh(()=>{i(),e?(l?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[e]),n}function vye(e){const s=n3(e);return zX(e,s)}const M6=[];function yye(e){const s=u.useRef(e),r=Jj(n=>e?n&&n!==M6&&e&&s.current&&e.parentNode===s.current.parentNode?n:e3(e):M6,[e]);return u.useEffect(()=>{s.current=e},[e]),r}function bye(e){const[s,r]=u.useState(null),n=u.useRef(e),a=u.useCallback(i=>{const o=gP(i.target);o&&r(l=>l?(l.set(o,nM(o)),new Map(l)):null)},[]);return u.useEffect(()=>{const i=n.current;if(e!==i){o(i);const l=e.map(c=>{const d=gP(c);return d?(d.addEventListener("scroll",a,{passive:!0}),[d,nM(d)]):null}).filter(c=>c!=null);r(l.length?new Map(l):null),n.current=e}return()=>{o(e),o(i)};function o(l){l.forEach(c=>{const d=gP(c);d?.removeEventListener("scroll",a)})}},[a,e]),u.useMemo(()=>e.length?s?Array.from(s.values()).reduce((i,o)=>hy(i,o),Ch):YX(e):Ch,[e,s])}function R6(e,s){s===void 0&&(s=[]);const r=u.useRef(null);return u.useEffect(()=>{r.current=null},s),u.useEffect(()=>{const n=e!==Ch;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?QS(e,r.current):Ch}function wye(e){u.useEffect(()=>{if(!e_)return;const s=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function jye(e,s){return u.useMemo(()=>e.reduce((r,n)=>{let{eventName:a,handler:i}=n;return r[a]=o=>{i(o,s)},r},{}),[e,s])}function JX(e){return u.useMemo(()=>e?Kve(e):null,[e])}const I6=[];function Nye(e,s){s===void 0&&(s=Ab);const[r]=e,n=JX(r?Xd(r):null),[a,i]=u.useState(I6);function o(){i(()=>e.length?e.map(c=>KX(c)?n:new t3(s(c),c)):I6)}const l=r_({callback:o});return Sh(()=>{l?.disconnect(),o(),e.forEach(c=>l?.observe(c))},[e]),a}function eZ(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return Zj(s)?s:e}function Sye(e){let{measure:s}=e;const[r,n]=u.useState(null),a=u.useCallback(d=>{for(const{target:h}of d)if(Zj(h)){n(p=>{const g=s(h);return p?{...p,width:g.width,height:g.height}:g});break}},[s]),i=r_({callback:a}),o=u.useCallback(d=>{const h=eZ(d);i?.disconnect(),h&&i?.observe(h),n(h?s(h):null)},[s,i]),[l,c]=GS(o);return u.useMemo(()=>({nodeRef:l,rect:r,setRef:c}),[r,l,c])}const Cye=[{sensor:r3,options:{}},{sensor:ZX,options:{}}],kye={current:{}},cS={draggable:{measure:k6},droppable:{measure:k6,strategy:G0.WhileDragging,frequency:iM.Optimized},dragOverlay:{measure:Ab}};class n0 extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,n;return(r=(n=this.get(s))==null?void 0:n.node.current)!=null?r:void 0}}const _ye={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new n0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ZS},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:cS,measureDroppableContainers:ZS,windowRect:null,measuringScheduled:!1},tZ={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ZS,draggableNodes:new Map,over:null,measureDroppableContainers:ZS},tN=u.createContext(tZ),sZ=u.createContext(_ye);function Pye(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new n0}}}function Eye(e,s){switch(s.type){case Hl.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case Hl.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case Hl.DragEnd:case Hl.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Hl.RegisterDroppable:{const{element:r}=s,{id:n}
282=r,a=new n0(e.droppable.containers);return a.set(n,r),{...e,droppable:{...e.droppable,containers:a}}}case Hl.SetDroppableDisabled:{const{id:r,key:n,disabled:a}=s,i=e.droppable.containers.get(r);if(!i||n!==i.key)return e;const o=new n0(e.droppable.containers);return o.set(r,{...i,disabled:a}),{...e,droppable:{...e.droppable,containers:o}}}case Hl.UnregisterDroppable:{const{id:r,key:n}=s,a=e.droppable.containers.get(r);if(!a||n!==a.key)return e;const i=new n0(e.droppable.containers);return i.delete(r),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Tye(e){let{disabled:s}=e;const{active:r,activatorEvent:n,draggableNodes:a}=u.useContext(tN),i=YS(n),o=YS(r?.id);return u.useEffect(()=>{if(!s&&!n&&i&&o!=null){if(!s_(i)||document.activeElement===i.target)return;const l=a.get(o);if(!l)return;const{activatorNode:c,node:d}=l;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const h of[c.current,d.current]){if(!h)continue;const p=Nve(h);if(p){p.focus();break}}})}},[n,s,a,o,i]),null}function rZ(e,s){let{transform:r,...n}=s;return e!=null&&e.length?e.reduce((a,i)=>i({transform:a,...n}),r):r}function Aye(e){return u.useMemo(()=>({draggable:{...cS.draggable,...e?.draggable},droppable:{...cS.droppable,...e?.droppable},dragOverlay:{...cS.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Mye(e){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=e;const i=u.useRef(!1),{x:o,y:l}=typeof a=="boolean"?{x:a,y:a}:a;Sh(()=>{if(!o&&!l||!s){i.current=!1;return}if(i.current||!n)return;const d=s?.node.current;if(!d||d.isConnected===!1)return;const h=r(d),p=zX(h,n);if(o||(p.x=0),l||(p.y=0),i.current=!0,Math.abs(p.x)>0||Math.abs(p.y)>0){const g=qX(d);g&&g.scrollBy({top:p.y,left:p.x})}},[s,o,l,n,r])}const n_=u.createContext({...Ch,scaleX:1,scaleY:1});var ig;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ig||(ig={}));const O6=u.memo(function(s){var r,n,a,i;let{id:o,accessibility:l,autoScroll:c=!0,children:d,sensors:h=Cye,collisionDetection:p=Uve,measuring:g,modifiers:v,...b}=s;const y=u.useReducer(Eye,void 0,Pye),[w,j]=y,[x,C]=Eve(),[k,S]=u.useState(ig.Uninitialized),_=k===ig.Initialized,{draggable:{active:A,nodes:T,translate:M},droppable:{containers:R}}=w,D=A!=null?T.get(A):null,$=u.useRef({initial:null,translated:null}),O=u.useMemo(()=>{var zt;return A!=null?{id:A,data:(zt=D?.data)!=null?zt:kye,rect:$}:null},[A,D]),q=u.useRef(null),[V,K]=u.useState(null),[G,z]=u.useState(null),Z=K0(b,Object.values(b)),ee=eN("DndDescribedBy",o),Q=u.useMemo(()=>R.getEnabled(),[R]),Y=Aye(g),{droppableRects:oe,measureDroppableContainers:he,measuringScheduled:je}=pye(Q,{dragging:_,dependencies:[M.x,M.y],config:Y.droppable}),pe=mye(T,A),le=u.useMemo(()=>G?XS(G):null,[G]),ue=He(),fe=fye(pe,Y.draggable.measure);Mye({activeNode:A!=null?T.get(A):null,config:ue.layoutShiftCompensation,initialRect:fe,measure:Y.draggable.measure});const H=A6(pe,Y.draggable.measure,fe),se=A6(pe?pe.parentElement:null),me=u.useRef({activatorEvent:null,active:null,activeNode:pe,collisionRect:null,collisions:null,droppableRects:oe,draggableNodes:T,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ge=R.getNodeFor((r=me.current.over)==null?void 0:r.id),be=Sye({measure:Y.dragOverlay.measure}),ce=(n=be.nodeRef.current)!=null?n:pe,Pe=_?(a=be.rect)!=null?a:H:null,et=!!(be.nodeRef.current&&be.rect),$e=vye(et?null:H),bt=JX(ce?Xd(ce):null),Ae=yye(_?ge??pe:null),Be=Nye(Ae),J=rZ(v,{transform:{x:M.x-$e.x,y:M.y-$e.y,scaleX:1,scaleY:1},activatorEvent:G,active:O,activeNodeRect:H,containerNodeRect:se,draggingNodeRect:Pe,over:me.current.over,overlayNodeRect:be.rect,scrollableAncestors:Ae,scrollableAncestorRects:Be,windowRect:bt}),ae=le?hy(le,M):null,we=bye(Ae),Qe=R6(we),ye=R6(we,[H]),te=hy(J,Qe),Ue=Pe?qve(Pe,J):null,We=O&&Ue?p({active:O,collisionRect:Ue,droppableRects:oe,droppableContainers:Q,pointerCoordinates:ae}):null,St=Fve(We,"id"),[It,ns]=u.useState(null),dt=et?J:hy(J,ye),Qt=zve(dt,(i=It?.rect)!=null?i:null,H),Re=u.useRef(null),pt=u.useCallback((zt,fs)=>{let{sensor:Ce,options:Dt}=fs;if(q.current==null)return;const ne=T.get(q.current);if(!ne)return;const Oe=zt.nativeEvent,De=new Ce({active:q.current,activeNode:ne,event:Oe,options:Dt,context:me,onAbort(Ct){if(!T.get(Ct))return;const{onDragAbort:xr}=Z.current,qe={id:Ct};xr?.(qe),x({type:"onDragAbort",event:qe})},onPending(Ct,Lt,xr,qe){if(!T.get(Ct))return;const{onDragPending:Ut}=Z.current,gt={id:Ct,constraint:Lt,initialCoordinates:xr,offset:qe};Ut?.(gt),x({type:"onDragPending",event:gt})},onStart(Ct){const Lt=q.current;if(Lt==null)return;const xr=T.get(Lt);if(!xr)return;const{onDragStart:qe}=Z.current,Xt={activatorEvent:Oe,active:{id:Lt,data:xr.data,rect:$}};Em.unstable_batchedUpdates(()=>{qe?.(Xt),S(ig.Initializing),j({type:Hl.DragStart,initialCoordinates:Ct,active:Lt}),x({type:"onDragStart",event:Xt}),K(Re.current),z(Oe)})},onMove(Ct){j({type:Hl.DragMove,coordinates:Ct})},onEnd:jt(Hl.DragEnd),onCancel:jt(Hl.DragCancel)});Re.current=De;function jt(Ct){return async function(){const{active:xr,collisions:qe,over:Xt,scrollAdjustedTranslate:Ut}=me.current;let gt=null;if(xr&&Ut){const{cancelDrop:es}=Z.current;gt={activatorEvent:Oe,active:xr,collisions:qe,delta:Ut,over:Xt},Ct===Hl.DragEnd&&typeof es=="function"&&await Promise.resolve(es(gt))&&(Ct=Hl.DragCancel)}q.current=null,Em.unstable_batchedUpdates(()=>{j({type:Ct}),S(ig.Uninitialized),ns(null),K(null),z(null),Re.current=null;const es=Ct===Hl.DragEnd?"onDragEnd":"onDragCancel";if(gt){const br=Z.current[es];br?.(gt),x({type:es,event:gt})}})}}},[T]),Ft=u.useCallback((zt,fs)=>(Ce,Dt)=>
282{const ne=Ce.nativeEvent,Oe=T.get(Dt);if(q.current!==null||!Oe||ne.dndKit||ne.defaultPrevented)return;const De={active:Oe};zt(Ce,fs.options,De)===!0&&(ne.dndKit={capturedBy:fs.sensor},q.current=Dt,pt(Ce,fs))},[T,pt]),Es=hye(h,Ft);wye(h),Sh(()=>{H&&k===ig.Initializing&&S(ig.Initialized)},[H,k]),u.useEffect(()=>{const{onDragMove:zt}=Z.current,{active:fs,activatorEvent:Ce,collisions:Dt,over:ne}=me.current;if(!fs||!Ce)return;const Oe={active:fs,activatorEvent:Ce,collisions:Dt,delta:{x:te.x,y:te.y},over:ne};Em.unstable_batchedUpdates(()=>{zt?.(Oe),x({type:"onDragMove",event:Oe})})},[te.x,te.y]),u.useEffect(()=>{const{active:zt,activatorEvent:fs,collisions:Ce,droppableContainers:Dt,scrollAdjustedTranslate:ne}=me.current;if(!zt||q.current==null||!fs||!ne)return;const{onDragOver:Oe}=Z.current,De=Dt.get(St),jt=De&&De.rect.current?{id:De.id,rect:De.rect.current,data:De.data,disabled:De.disabled}:null,Ct={active:zt,activatorEvent:fs,collisions:Ce,delta:{x:ne.x,y:ne.y},over:jt};Em.unstable_batchedUpdates(()=>{ns(jt),Oe?.(Ct),x({type:"onDragOver",event:Ct})})},[St]),Sh(()=>{me.current={activatorEvent:G,active:O,activeNode:pe,collisionRect:Ue,collisions:We,droppableRects:oe,draggableNodes:T,draggingNode:ce,draggingNodeRect:Pe,droppableContainers:R,over:It,scrollableAncestors:Ae,scrollAdjustedTranslate:te},$.current={initial:Pe,translated:Ue}},[O,pe,We,Ue,T,ce,Pe,oe,R,It,Ae,te]),cye({...ue,delta:M,draggingRect:Ue,pointerCoordinates:ae,scrollableAncestors:Ae,scrollableAncestorRects:Be});const Ge=u.useMemo(()=>({active:O,activeNode:pe,activeNodeRect:H,activatorEvent:G,collisions:We,containerNodeRect:se,dragOverlay:be,draggableNodes:T,droppableContainers:R,droppableRects:oe,over:It,measureDroppableContainers:he,scrollableAncestors:Ae,scrollableAncestorRects:Be,measuringConfiguration:Y,measuringScheduled:je,windowRect:bt}),[O,pe,H,G,We,se,be,T,R,oe,It,he,Ae,Be,Y,je,bt]),ft=u.useMemo(()=>({activatorEvent:G,activators:Es,active:O,activeNodeRect:H,ariaDescribedById:{draggable:ee},dispatch:j,draggableNodes:T,over:It,measureDroppableContainers:he}),[G,Es,O,H,j,ee,T,It,he]);return Ne.createElement(UX.Provider,{value:C},Ne.createElement(tN.Provider,{value:ft},Ne.createElement(sZ.Provider,{value:Ge},Ne.createElement(n_.Provider,{value:Qt},d)),Ne.createElement(Tye,{disabled:l?.restoreFocus===!1})),Ne.createElement(Mve,{...l,hiddenTextDescribedById:ee}));function He(){const zt=V?.autoScrollEnabled===!1,fs=typeof c=="object"?c.enabled===!1:c===!1,Ce=_&&!zt&&!fs;return typeof c=="object"?{...c,enabled:Ce}:{enabled:Ce}}}),Rye=u.createContext(null),D6="button",Iye="Draggable";function nZ(e){let{id:s,data:r,disabled:n=!1,attributes:a}=e;const i=eN(Iye),{activators:o,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:h,draggableNodes:p,over:g}=u.useContext(tN),{role:v=D6,roleDescription:b="draggable",tabIndex:y=0}=a??{},w=c?.id===s,j=u.useContext(w?n_:Rye),[x,C]=GS(),[k,S]=GS(),_=jye(o,s),A=K0(r);Sh(()=>(p.set(s,{id:s,key:i,node:x,activatorNode:k,data:A}),()=>{const M=p.get(s);M&&M.key===i&&p.delete(s)}),[p,s]);const T=u.useMemo(()=>({role:v,tabIndex:y,"aria-disabled":n,"aria-pressed":w&&v===D6?!0:void 0,"aria-roledescription":b,"aria-describedby":h.draggable}),[n,v,y,w,b,h.draggable]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:T,isDragging:w,listeners:n?void 0:_,node:x,over:g,setNodeRef:C,setActivatorNodeRef:S,transform:j}}function aZ(){return u.useContext(sZ)}const Oye="Droppable",Dye={timeout:25};function a3(e){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=e;const i=eN(Oye),{active:o,dispatch:l,over:c,measureDroppableContainers:d}=u.useContext(tN),h=u.useRef({disabled:r}),p=u.useRef(!1),g=u.useRef(null),v=u.useRef(null),{disabled:b,updateMeasurementsFor:y,timeout:w}={...Dye,...a},j=K0(y??n),x=u.useCallback(()=>{if(!p.current){p.current=!0;return}v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>{d(Array.isArray(j.current)?j.current:[j.current]),v.current=null},w)},[w]),C=r_({callback:x,disabled:b||!o}),k=u.useCallback((T,M)=>{C&&(M&&(C.unobserve(M),p.current=!1),T&&C.observe(T))},[C]),[S,_]=GS(k),A=K0(s);return u.useEffect(()=>{!C||!S.current||(C.disconnect(),p.current=!1,C.observe(S.current))},[S,C]),u.useEffect(()=>(l({type:Hl.RegisterDroppable,element:{id:n,key:i,disabled:r,node:S,rect:g,data:A}}),()=>l({type:Hl.UnregisterDroppable,key:i,id:n})),[n]),u.useEffect(()=>{r!==h.current.disabled&&(l({type:Hl.SetDroppableDisabled,id:n,key:i,disabled:r}),h.current.disabled=r)},[n,i,r,l]),{active:o,rect:g,isOver:c?.id===n,node:S,over:c,setNodeRef:_}}function Lye(e){let{animation:s,children:r}=e;const[n,a]=u.useState(null),[i,o]=u.useState(null),l=YS(r);return!r&&!n&&l&&a(l),Sh(()=>
282{if(!i)return;const c=n?.key,d=n?.props.id;if(c==null||d==null){a(null);return}Promise.resolve(s(d,i)).then(()=>{a(null)})},[s,n,i]),Ne.createElement(Ne.Fragment,null,r,n?u.cloneElement(n,{ref:o}):null)}const $ye={x:0,y:0,scaleX:1,scaleY:1};function Fye(e){let{children:s}=e;return Ne.createElement(tN.Provider,{value:tZ},Ne.createElement(n_.Provider,{value:$ye},s))}const Bye={position:"fixed",touchAction:"none"},Uye=e=>s_(e)?"transform 250ms ease":void 0,zye=u.forwardRef((e,s)=>{let{as:r,activatorEvent:n,adjustScale:a,children:i,className:o,rect:l,style:c,transform:d,transition:h=Uye}=e;if(!l)return null;const p=a?d:{...d,scaleX:1,scaleY:1},g={...Bye,width:l.width,height:l.height,top:l.top,left:l.left,transform:vf.Transform.toString(p),transformOrigin:a&&n?Dve(n,l):void 0,transition:typeof h=="function"?h(n):h,...c};return Ne.createElement(r,{className:o,style:g,ref:s},i)}),Hye=e=>s=>{let{active:r,dragOverlay:n}=s;const a={},{styles:i,className:o}=e;if(i!=null&&i.active)for(const[l,c]of Object.entries(i.active))c!==void 0&&(a[l]=r.node.style.getPropertyValue(l),r.node.style.setProperty(l,c));if(i!=null&&i.dragOverlay)for(const[l,c]of Object.entries(i.dragOverlay))c!==void 0&&n.node.style.setProperty(l,c);return o!=null&&o.active&&r.node.classList.add(o.active),o!=null&&o.dragOverlay&&n.node.classList.add(o.dragOverlay),function(){for(const[c,d]of Object.entries(a))r.node.style.setProperty(c,d);o!=null&&o.active&&r.node.classList.remove(o.active)}},qye=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:vf.Transform.toString(s)},{transform:vf.Transform.toString(r)}]},Vye={duration:250,easing:"ease",keyframes:qye,sideEffects:Hye({styles:{active:{opacity:"0"}}})};function Wye(e){let{config:s,draggableNodes:r,droppableContainers:n,measuringConfiguration:a}=e;return t_((i,o)=>{if(s===null)return;const l=r.get(i);if(!l)return;const c=l.node.current;if(!c)return;const d=eZ(o);if(!d)return;const{transform:h}=Xd(o).getComputedStyle(o),p=HX(h);if(!p)return;const g=typeof s=="function"?s:Kye(s);return QX(c,a.draggable.measure),g({active:{id:i,data:l.data,node:c,rect:a.draggable.measure(c)},draggableNodes:r,dragOverlay:{node:o,rect:a.dragOverlay.measure(d)},droppableContainers:n,measuringConfiguration:a,transform:p})})}function Kye(e){const{duration:s,easing:r,sideEffects:n,keyframes:a}={...Vye,...e};return i=>{let{active:o,dragOverlay:l,transform:c,...d}=i;if(!s)return;const h={x:l.rect.left-o.rect.left,y:l.rect.top-o.rect.top},p={scaleX:c.scaleX!==1?o.rect.width*c.scaleX/l.rect.width:1,scaleY:c.scaleY!==1?o.rect.height*c.scaleY/l.rect.height:1},g={x:c.x-h.x,y:c.y-h.y,...p},v=a({...d,active:o,dragOverlay:l,transform:{initial:c,final:g}}),[b]=v,y=v[v.length-1];if(JSON.stringify(b)===JSON.stringify(y))return;const w=n?.({active:o,dragOverlay:l,...d}),j=l.node.animate(v,{duration:s,easing:r,fill:"forwards"});return new Promise(x=>{j.onfinish=()=>{w?.(),x()}})}}let L6=0;function Gye(e){return u.useMemo(()=>{if(e!=null)return L6++,L6},[e])}const $6=Ne.memo(e=>
282{let{adjustScale:s=!1,children:r,dropAnimation:n,style:a,transition:i,modifiers:o,wrapperElement:l="div",className:c,zIndex:d=999}=e;const{activatorEvent:h,active:p,activeNodeRect:g,containerNodeRect:v,draggableNodes:b,droppableContainers:y,dragOverlay:w,over:j,measuringConfiguration:x,scrollableAncestors:C,scrollableAncestorRects:k,windowRect:S}=aZ(),_=u.useContext(n_),A=Gye(p?.id),T=rZ(o,{activatorEvent:h,active:p,activeNodeRect:g,containerNodeRect:v,draggingNodeRect:w.rect,over:j,overlayNodeRect:w.rect,scrollableAncestors:C,scrollableAncestorRects:k,transform:_,windowRect:S}),M=n3(g),R=Wye({config:n,draggableNodes:b,droppableContainers:y,measuringConfiguration:x}),D=M?w.setRef:void 0;return Ne.createElement(Fye,null,Ne.createElement(Lye,{animation:R},p&&A?Ne.createElement(zye,{key:A,id:p.id,ref:D,as:l,activatorEvent:h,adjustScale:s,className:c,transition:i,rect:M,style:{zIndex:d,...a},transform:T},r):null))});function eC(e,s,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function Yye(e,s){return e.reduce((r,n,a)=>{const i=s.get(n);return i&&(r[a]=i),r},Array(e.length))}function m1(e){return e!==null&&e>=0}function Qye(e,s){if(e===s)return!0;if(e.length!==s.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==s[r])return!1;return!0}function Xye(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Oy=e=>{let{rects:s,activeIndex:r,overIndex:n,index:a}=e;const i=eC(s,n,r),o=s[a],l=i[a];return!l||!o?null:{x:l.left-o.left,y:l.top-o.top,scaleX:l.width/o.width,scaleY:l.height/o.height}},h1={scaleX:1,scaleY:1},Zye=e=>{var s;let{activeIndex:r,activeNodeRect:n,index:a,rects:i,overIndex:o}=e;const l=(s=i[r])!=null?s:n;if(!l)return null;if(a===r){const d=i[o];return d?{x:0,y:r<o?d.top+d.height-(l.top+l.height):d.top-l.top,...h1}:null}const c=Jye(i,a,r);return a>r&&a<=o?{x:0,y:-l.height-c,...h1}:a<r&&a>=o?{x:0,y:l.height+c,...h1}:{x:0,y:0,...h1}};function Jye(e,s,r){const n=e[s],a=e[s-1],i=e[s+1];return n?r<s?a?n.top-(a.top+a.height):i?i.top-(n.top+n.height):0:i?i.top-(n.top+n.height):a?n.top-(a.top+a.height):0:0}const iZ="Sortable",oZ=Ne.createContext({activeIndex:-1,containerId:iZ,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Oy,disabled:{draggable:!1,droppable:!1}});function a0(e){let{children:s,id:r,items:n,strategy:a=Oy,disabled:i=!1}=e;const{active:o,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=aZ(),p=eN(iZ,r),g=l.rect!==null,v=u.useMemo(()=>n.map(_=>typeof _=="object"&&"id"in _?_.id:_),[n]),b=o!=null,y=o?v.indexOf(o.id):-1,w=d?v.indexOf(d.id):-1,j=u.useRef(v),x=!Qye(v,j.current),C=w!==-1&&y===-1||x,k=Xye(i);Sh(()=>{x&&b&&h(v)},[x,v,b,h]),u.useEffect(()=>{j.current=v},[v]);const S=u.useMemo(()=>({activeIndex:y,containerId:p,disabled:k,disableTransforms:C,items:v,overIndex:w,useDragOverlay:g,sortedRects:Yye(v,c),strategy:a}),[y,p,k.draggable,k.droppable,C,v,w,c,g,a]);return Ne.createElement(oZ.Provider,{value:S},s)}const ebe=e=>{let{id:s,items:r,activeIndex:n,overIndex:a}=e;return eC(r,n,a).indexOf(s)},tbe=e=>{let{containerId:s,isSorting:r,wasDragging:n,index:a,items:i,newIndex:o,previousItems:l,previousContainerId:c,transition:d}=e;return!d||!n||l!==i&&a===o?!1:r?!0:o!==a&&s===c},sbe={duration:200,easing:"ease"},lZ="transform",rbe=vf.Transition.toString({property:lZ,duration:0,easing:"linear"}),nbe={roleDescription:"sortable"};function abe(e){let{disabled:s,index:r,node:n,rect:a}=e;const[i,o]=u.useState(null),l=u.useRef(r);return Sh(()=>{if(!s&&r!==l.current&&n.current){const c=a.current;if(c){const d=Ab(n.current,{ignoreTransform:!0}),h={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(h.x||h.y)&&o(h)}}r!==l.current&&(l.current=r)},[s,r,n,a]),u.useEffect(()=>{i&&o(null)},[i]),i}function cZ(e){let{animateLayoutChanges:s=tbe,attributes:r,disabled:n,data:a,getNewIndex:i=ebe,id:o,strategy:l,resizeObserverConfig:c,transition:d=sbe}=e;const{items:h,containerId:p,activeIndex:g,disabled:v,disableTransforms:b,sortedRects:y,overIndex:w,useDragOverlay:j,strategy:x}=u.useContext(oZ),C=ibe(n,v),k=h.indexOf(o),S=u.useMemo(()=>({sortable:{containerId:p,index:k,items:h},...a}),[p,a,k,h]),_=u.useMemo(()=>h.slice(h.indexOf(o)),[h,o]),{rect:A,node:T,isOver:M,setNodeRef:R}=a3({id:o,data:S,disabled:C.droppable,resizeObserverConfig:{updateMeasurementsFor:_,...c}}),{active:D,activatorEvent:$,activeNodeRect:O,attributes:q,setNodeRef:V,listeners:K,isDragging:G,over:z,setActivatorNodeRef:Z,transform:ee}=nZ({id:o,data:S,attributes:{...nbe,...r},disabled:C.draggable}),Q=yve(R,V),Y=!!D,oe=Y&&!b&&m1(g)&&m1(w),he=!j&&G,je=he&&oe?ee:null,le=oe?je??(l??x)({rects:y,activeNodeRect:O,activeIndex:g,overIndex:w,index:k}):null,ue=m1(g)&&m1(w)?i({id:o,items:h,activeIndex:g,overIndex:w}
282):k,fe=D?.id,H=u.useRef({activeId:fe,items:h,newIndex:ue,containerId:p}),se=h!==H.current.items,me=s({active:D,containerId:p,isDragging:G,isSorting:Y,id:o,index:k,items:h,newIndex:H.current.newIndex,previousItems:H.current.items,previousContainerId:H.current.containerId,transition:d,wasDragging:H.current.activeId!=null}),ge=abe({disabled:!me,index:k,node:T,rect:A});return u.useEffect(()=>{Y&&H.current.newIndex!==ue&&(H.current.newIndex=ue),p!==H.current.containerId&&(H.current.containerId=p),h!==H.current.items&&(H.current.items=h)},[Y,ue,p,h]),u.useEffect(()=>{if(fe===H.current.activeId)return;if(fe!=null&&H.current.activeId==null){H.current.activeId=fe;return}const ce=setTimeout(()=>{H.current.activeId=fe},50);return()=>clearTimeout(ce)},[fe]),{active:D,activeIndex:g,attributes:q,data:S,rect:A,index:k,newIndex:ue,items:h,isOver:M,isSorting:Y,isDragging:G,listeners:K,node:T,overIndex:w,over:z,setNodeRef:Q,setActivatorNodeRef:Z,setDroppableNodeRef:R,setDraggableNodeRef:V,transform:ge??le,transition:be()};function be(){if(ge||se&&H.current.newIndex===k)return rbe;if(!(he&&!s_($)||!d)&&(Y||me))return vf.Transition.toString({...d,property:lZ})}}function ibe(e,s){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e?.draggable)!=null?r:s.draggable,droppable:(n=e?.droppable)!=null?n:s.droppable}}$a.Down,$a.Right,$a.Up,$a.Left;function obe(e,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e?.(a),r===!1||!a.defaultPrevented)return s?.(a)}}var lbe=bb[" useInsertionEffect ".trim().toString()]||da;function cbe({prop:e,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,i,o]=dbe({defaultProp:s,onChange:r}),l=e!==void 0,c=l?e:a;{const h=u.useRef(e!==void 0);u.useEffect(()=>{const p=h.current;p!==l&&console.warn(`${n} is changing from ${p?"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.`),h.current=l},[l,n])}const d=u.useCallback(h=>{if(l){const p=ube(h)?h(e):h;p!==e&&o.current?.(p)}else i(h)},[l,e,i,o]);return[c,d]}function dbe({defaultProp:e,onChange:s}){const[r,n]=u.useState(e),a=u.useRef(r),i=u.useRef(s);return lbe(()=>{i.current=s},[s]),u.useEffect(()=>{a.current!==r&&(i.current?.(r),a.current=r)},[r,a]),[r,n,i]}function ube(e){return typeof e=="function"}function mbe(e){const s=hbe(e),r=u.forwardRef((n,a)=>{const{children:i,...o}=n,l=u.Children.toArray(i),c=l.find(fbe);if(c){const d=c.props.children,h=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return t.jsx(s,{...o,ref:a,children:u.isValidElement(d)?u.cloneElement(d,void 0,h):null})}return t.jsx(s,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function hbe(e){const s=u.forwardRef((r,n)=>{const{children:a,...i}=r;if(u.isValidElement(a)){const o=xbe(a),l=gbe(i,a.props);return a.type!==u.Fragment&&(l.ref=n?jf(n,o):o),u.cloneElement(a,l)}return u.Children.count(a)>1?u.Children.only(null):null});return s.displayName=`${e}.SlotClone`,s}var pbe=Symbol("radix.slottable");function fbe(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pbe}function gbe(e,s){const r={...s};for(const n in s){const a=e[n],i=s[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function xbe(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var vbe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],dZ=vbe.reduce((e,s)=>{const r=mbe(`Primitive.${s}`),n=u.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(c,{...l,ref:i})});return n.displayName=`Primitive.${s}`,{...e,[s]:n}},{}),a_="Switch",[ybe]=oo(a_),[bbe,wbe]=ybe(a_),uZ=u.forwardRef((e,s)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:d,form:h,...p}=e,[g,v]=u.useState(null),b=mr(s,C=>v(C)),y=u.useRef(!1),w=g?h||!!g.closest("form"):!0,[j,x]=cbe({prop:a,defaultProp:i??!1,onChange:d,caller:a_});return t.jsxs(bbe,{scope:r,checked:j,disabled:l,children:[t.jsx(dZ.button,{type:"button",role:"switch","aria-checked":j,"aria-required":o,"data-state":fZ(j),"data-disabled":l?"":void 0,disabled:l,value:c,...p,ref:b,onClick:obe(e.onClick,C=>{x(k=>!k),w&&(y.current=C.isPropagationStopped(),y.current||C.stopPropagation())})}),w&&t.jsx(pZ,{control:g,bubbles:!y.current,name:n,value:c,checked:j,required:o,disabled:l,form:h,style:{transform:"translateX(-100%)"}})]})});uZ.displayName=a_;var mZ="SwitchThumb",hZ=u.forwardRef((e,s)=>{const{__scopeSwitch:r,...n}=e,a=wbe(mZ,r);return t.jsx(dZ.span,{"data-state":fZ(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});hZ.displayName=mZ;var jbe="SwitchBubbleInput",pZ=u.forwardRef(({__scopeSwitch:e,control:s,checked:r,bubbles:n=!0,...a},i)=>{const o=u.useRef(null),l=mr(o,i),c=Gj(r),d=_b(s);return u.useEffect(()=>{const h=o.current;if(!h)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"checked").set;if(c!==r&&v){const b=new Event("click",{bubbles:n});v.call(h,r),h.dispatchEvent(b)}},[c,r,n]),t.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}})});pZ.displayName=jbe;function fZ(e){return e?"checked":"unchecked"}var gZ=uZ,Nbe=hZ;const sr=u.forwardRef(({className:e,...s},r)=>t.jsx(gZ,{className:Cs("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors 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 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...s,ref:r,children:t.jsx(Nbe,{className:Cs("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")})}
282));sr.displayName=gZ.displayName;var sN=e=>e.type==="checkbox",Cx=e=>e instanceof Date,Bd=e=>e==null;const xZ=e=>typeof e=="object";var el=e=>!Bd(e)&&!Array.isArray(e)&&xZ(e)&&!Cx(e),vZ=e=>el(e)&&e.target?sN(e.target)?e.target.checked:e.target.value:e,Sbe=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,yZ=(e,s)=>e.has(Sbe(s)),Cbe=e=>{const s=e.constructor&&e.constructor.prototype;return el(s)&&s.hasOwnProperty("isPrototypeOf")},i3=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function qc(e){let s;const r=Array.isArray(e),n=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)s=new Date(e);else if(e instanceof Set)s=new Set(e);else if(!(i3&&(e instanceof Blob||n))&&(r||el(e)))if(s=r?[]:{},!r&&!Cbe(e))s=e;else for(const a in e)e.hasOwnProperty(a)&&(s[a]=qc(e[a]));else return e;return s}var i_=e=>Array.isArray(e)?e.filter(Boolean):[],Jo=e=>e===void 0,Vs=(e,s,r)=>{if(!s||!el(e))return r;const n=i_(s.split(/[,[\].]+?/)).reduce((a,i)=>Bd(a)?a:a[i],e);return Jo(n)||n===e?Jo(e[s])?r:e[s]:n},Ku=e=>typeof e=="boolean",o3=e=>/^\w*$/.test(e),bZ=e=>i_(e.replace(/["|']|\]/g,"").split(/\.|\[/)),Qa=(e,s,r)=>{let n=-1;const a=o3(s)?[s]:bZ(s),i=a.length,o=i-1;for(;++n<i;){const l=a[n];let c=r;if(n!==o){const d=e[l];c=el(d)||Array.isArray(d)?d:isNaN(+a[n+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const tC={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},ph={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ip={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},wZ=Ne.createContext(null),o_=()=>Ne.useContext(wZ),kbe=e=>{const{children:s,...r}=e;return Ne.createElement(wZ.Provider,{value:r},s)};var jZ=(e,s,r,n=!0)=>{const a={defaultValues:s._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return s._proxyFormState[o]!==ph.all&&(s._proxyFormState[o]=!n||ph.all),r&&(r[o]=!0),e[o]}});return a};function _be(e){const s=o_(),{control:r=s.control,disabled:n,name:a,exact:i}=e||{},[o,l]=Ne.useState(r._formState),c=Ne.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=Ne.useRef(a);return d.current=a,Ne.useEffect(()=>r._subscribe({name:d.current,formState:c.current,exact:i,callback:h=>{!n&&l({...r._formState,...h})}}),[r,n,i]),Ne.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),Ne.useMemo(()=>jZ(o,r,c.current,!1),[o,r])}var Yh=e=>typeof e=="string",NZ=(e,s,r,n,a)=>Yh(e)?(n&&s.watch.add(e),Vs(r,e,a)):Array.isArray(e)?e.map(i=>(n&&s.watch.add(i),Vs(r,i))):(n&&(s.watchAll=!0),r);function Pbe(e){const s=o_(),{control:r=s.control,name:n,defaultValue:a,disabled:i,exact:o}=e||{},l=Ne.useRef(n),c=Ne.useRef(a);l.current=n,Ne.useEffect(()=>r._subscribe({name:l.current,formState:{values:!0},exact:o,callback:p=>!i&&h(NZ(l.current,r._names,p.values||r._formValues,!1,c.current))}),[r,i,o]);const[d,h]=Ne.useState(r._getWatch(n,a));return Ne.useEffect(()=>r._removeUnmounted()),d}function Ebe(e){const s=o_(),{name:r,disabled:n,control:a=s.control,shouldUnregister:i}=e,o=yZ(a._names.array,r),l=Pbe({control:a,name:r,defaultValue:Vs(a._formValues,r,Vs(a._defaultValues,r,e.defaultValue)),exact:!0}),c=_be({control:a,name:r,exact:!0}),d=Ne.useRef(e),h=Ne.useRef(a.register(r,{...e.rules,value:l,...Ku(e.disabled)?{disabled:e.disabled}:{}})),p=Ne.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Vs(c.errors,r)},isDirty:{enumerable:!0,get:()=>!!Vs(c.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!Vs(c.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!Vs(c.validatingFields,r)},error:{enumerable:!0,get:()=>Vs(c.errors,r)}}),[c,r]),g=Ne.useCallback(w=>h.current.onChange({target:{value:vZ(w),name:r},type:tC.CHANGE}),[r]),v=Ne.useCallback(()=>h.current.onBlur({target:{value:Vs(a._formValues,r),name:r},type:tC.BLUR}),[r,a._formValues]),b=Ne.useCallback(w=>{const j=Vs(a._fields,r);j&&w&&(j._f.ref={focus:()=>w.focus(),select:()=>w.select(),setCustomValidity:x=>w.setCustomValidity(x),reportValidity:()=>w.reportValidity()})},[a._fields,r]),y=Ne.useMemo(()=>({name:r,value:l,...Ku(n)||c.disabled?{disabled:c.disabled||n}:{},onChange:g,onBlur:v,ref:b}),[r,n,c.disabled,g,v,b,l]);return Ne.useEffect(()=>{const w=a._options.shouldUnregister||i;a.register(r,{...d.current.rules,...Ku(d.current.disabled)?{disabled:d.current.disabled}:{}});const j=(x,C)=>{const k=Vs(a._fields,x);k&&k._f&&(k._f.mount=C)};if(j(r,!0),w){const x=qc(Vs(a._options.defaultValues,r));Qa(a._defaultValues,r,x),Jo(Vs(a._formValues,r))&&Qa(a._formValues,r,x)}return!o&&a.register(r),()=>{(o?w&&!a._state.action:w)?a.unregister(r):j(r,!1)}},[r,a,o,i]),Ne.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),Ne.useMemo(()=>({field:y,formState:c,fieldState:p}),[y,c,p])}const Tbe=e=>e.render(Ebe(e));var SZ=(e,s,r,n,a)=>s?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:a||!0}}:{},i0=e=>Array.isArray(e)?e:[e],F6=()=>{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=[]}}},oM=e=>Bd(e)||!xZ(e);function dg(e,s){if(oM(e)||oM(s))return e===s;if(Cx(e)&&Cx(s))return e.getTime()===s.getTime();const r=Object.keys(e),n=Object.keys(s);if(r.length!==n.length)return!1;for(const a of r){const i=e[a];if(!n.includes(a))return!1;if(a!=="ref"){const o=s[a];if(Cx(i)&&Cx(o)||el(i)&&el(o)||Array.isArray(i)&&Array.isArray(o)?!dg(i,o):i!==o)return!1}}return!0}var Fd=e=>el(e)&&!Object.keys(e).length,l3=e=>e.type==="file",fh=e=>typeof e=="function",sC=e=>{if(!i3)return!1;const s=e?e.ownerDocument:0;return e instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},CZ=e=>e.type==="select-multiple",c3=e=>e.type==="radio",Abe=e=>c3(e)||sN(e),yP=e=>sC(e)&&e.isConnected;function Mbe(e,s){const r=s.slice(0,-1).length;let n=0;for(;n<r;)e=Jo(e)?n++:e[s[n++]];return e}function Rbe(e){for(const s in e)if(e.hasOwnProperty(s)&&!Jo(e[s]))return!1;return!0}function zl(e,s){const r=Array.isArray(s)?s:o3(s)?[s]:bZ(s),n=r.length===1?e:Mbe(e,r),a=r.length-1,i=r[a];return n&&delete n[i],a!==0&&(el(n)&&Fd(n)||Array.isArray(n)&&Rbe(n))&&zl(e,r.slice(0,-1)),e}var kZ=e=>{for(const s in e)if(fh(e[s]))return!0;return!1};function rC(e,s={}){const r=Array.isArray(e);if(el(e)||r)for(const n in e)Array.isArray(e[n])||el(e[n])&&!kZ(e[n])?(s[n]=Array.isArray(e[n])?[]:{}
vendor: 4,518 bytes, line 282
282,rC(e[n],s[n])):Bd(e[n])||(s[n]=!0);return s}function _Z(e,s,r){const n=Array.isArray(e);if(el(e)||n)for(const a in e)Array.isArray(e[a])||el(e[a])&&!kZ(e[a])?Jo(s)||oM(r[a])?r[a]=Array.isArray(e[a])?rC(e[a],[]):{...rC(e[a])}:_Z(e[a],Bd(s)?{}:s[a],r[a]):r[a]=!dg(e[a],s[a]);return r}var fw=(e,s)=>_Z(e,s,rC(s));const B6={value:!1,isValid:!1},U6={value:!0,isValid:!0};var PZ=e=>{if(Array.isArray(e)){if(e.length>1){const s=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:s,isValid:!!s.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Jo(e[0].attributes.value)?Jo(e[0].value)||e[0].value===""?U6:{value:e[0].value,isValid:!0}:U6:B6}return B6},EZ=(e,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>Jo(e)?e:s?e===""?NaN:e&&+e:r&&Yh(e)?new Date(e):n?n(e):e;const z6={isValid:!1,value:null};var TZ=e=>Array.isArray(e)?e.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,z6):z6;function H6(e){const s=e.ref;return l3(s)?s.files:c3(s)?TZ(e.refs).value:CZ(s)?[...s.selectedOptions].map(({value:r})=>r):sN(s)?PZ(e.refs).value:EZ(Jo(s.value)?e.ref.value:s.value,e)}var Ibe=(e,s,r,n)=>{const a={};for(const i of e){const o=Vs(s,i);o&&Qa(a,i,o._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:n}},nC=e=>e instanceof RegExp,gw=e=>Jo(e)?e:nC(e)?e.source:el(e)?nC(e.value)?e.value.source:e.value:e,q6=e=>({isOnSubmit:!e||e===ph.onSubmit,isOnBlur:e===ph.onBlur,isOnChange:e===ph.onChange,isOnAll:e===ph.all,isOnTouch:e===ph.onTouched});const V6="AsyncFunction";var Obe=e=>!!e&&!!e.validate&&!!(fh(e.validate)&&e.validate.constructor.name===V6||el(e.validate)&&Object.values(e.validate).find(s=>s.constructor.name===V6)),Dbe=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),W6=(e,s,r)=>!r&&(s.watchAll||s.watch.has(e)||[...s.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const o0=(e,s,r,n)=>{for(const a of r||Object.keys(e)){const i=Vs(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&s(o.refs[0],a)&&!n)return!0;if(o.ref&&s(o.ref,o.name)&&!n)return!0;if(o0(l,s))break}else if(el(l)&&o0(l,s))break}}};function K6(e,s,r){const n=Vs(e,r);if(n||o3(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const i=a.join("."),o=Vs(s,i),l=Vs(e,i);if(o&&!Array.isArray(o)&&r!==i)return{name:r};if(l&&l.type)return{name:i,error:l};a.pop()}return{name:r}}var Lbe=(e,s,r,n)=>{r(e);const{name:a,...i}=e;return Fd(i)||Object.keys(i).length>=Object.keys(s).length||Object.keys(i).find(o=>s[o]===(!n||ph.all))},$be=(e,s,r)=>!e||!s||e===s||i0(e).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),Fbe=(e,s,r,n,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(s||e):(r?n.isOnBlur:a.isOnBlur)?!e:(r?n.isOnChange:a.isOnChange)?e:!0,Bbe=(e,s)=>!i_(Vs(e,s)).length&&zl(e,s),Ube=(e,s,r)=>{const n=i0(Vs(e,r));return Qa(n,"root",s[r]),Qa(e,r,n),e},dS=e=>Yh(e);function G6(e,s,r="validate"){if(dS(e)||Array.isArray(e)&&e.every(dS)||Ku(e)&&!e)return{type:r,message:dS(e)?e:"",ref:s}}var Av=e=>el(e)&&!nC(e)?e:{value:e,message:""},Y6=async(e,s,r,n,a,i)=>{const{ref:o,refs:l,required:c,maxLength:d,minLength:h,min:p,max:g,pattern:v,validate:b,name:y,valueAsNumber:w,mount:j}=e._f,x=Vs(r,y);if(!j||s.has(y))return{};const C=l?l[0]:o,k=$=>{a&&C.reportValidity&&(C.setCustomValidity(Ku($)?"":$||""),C.reportValidity())},S={},_=c3(o),A=sN(o),T=_||A,M=(w||l3(o))&&Jo(o.value)&&Jo(x)||sC(o)&&o.value===""||x===""||Array.isArray(x)&&!x.length,R=SZ.bind(null,y,n,S),D=($,O,q,V=Ip.maxLength,K=Ip.minLength)=>{const G=$?O:q;S[y]={type:$?V:K,message:G,ref:o,...R($?V:K,G)}};if(i?!Array.isArray(x)||!x.length:c&&(!T&&(M||Bd(x))||Ku(x)&&!x||A&&!PZ(l).isValid||_&&!TZ(l).isValid)){const{value:$,message:O}=dS(c)?{value:!!c,message:c}:Av(c);if($&&(S[y]={type:Ip.required,message:O,ref:C,...R(Ip.required,O)},!n))return k(O),S}if(!M&&(!Bd(p)||!Bd(g))){let $,O;const q=Av(g),V=Av(p);if(!Bd(x)&&!isNaN(x)){const K=o.valueAsNumber||x&&+x;Bd(q.value)||($=K>q.value),Bd(V.value)||(O=K<V.value)}else{const K=o.valueAsDate||new Date(x),G=ee=>new Date(new Date().toDateString()+" "+ee),z=o.type=="time",Z=o.type=="week";Yh(q.value)&&x&&($=z?G(x)>G(q.value):Z?x>q.value:K>new Date(q.value)),Yh(V.value)&&x&&(O=z?G(x)<G(V.value):Z?x<V.value:K<new Date(V.value))}if(($||O)&&(D(!!$,q.message,V.message,Ip.max,Ip.min),!n))return k(S[y].message),S}if((d||h)&&!M&&(Yh(x)||i&&Array.isArray(x))){const $=Av(d),O=Av(h),q=!Bd($.value)&&x.length>+$.value,V=!Bd(O.value)&&x.length<+O.value;if((q||V)&&(D(q,$.message,O.message),!n))return k(S[y].message),S}
282if(v&&!M&&Yh(x)){const{value:$,message:O}=Av(v);if(nC($)&&!x.match($)&&(S[y]={type:Ip.pattern,message:O,ref:o,...R(Ip.pattern,O)},!n))return k(O),S}if(b){if(fh(b)){const $=await b(x,r),O=G6($,C);if(O&&(S[y]={...O,...R(Ip.validate,O.message)},!n))return k(O.message),S}else if(el(b)){let $={};for(const O in b){if(!Fd($)&&!n)break;const q=G6(await b[O](x,r),C,O);q&&($={...q,...R(O,q.message)},k(q.message),n&&(S[y]=$))}if(!Fd($)&&(S[y]={ref:C,...$},!n))return S}}return k(!0),S};const zbe={mode:ph.onSubmit,reValidateMode:ph.onChange,shouldFocusError:!0};function Hbe(e={}){let s={...zbe,...e},r={submitCount:0,isDirty:!1,isLoading:fh(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1};const n={};let a=el(s.defaultValues)||el(s.values)?qc(s.values||s.defaultValues)||{}:{},i=s.shouldUnregister?{}:qc(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 h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let p={...h};const g={array:F6(),state:F6()},v=q6(s.mode),b=q6(s.reValidateMode),y=s.criteriaMode===ph.all,w=J=>ae=>{clearTimeout(d),d=setTimeout(J,ae)},j=async J=>{if(!s.disabled&&(h.isValid||p.isValid||J)){const ae=s.resolver?Fd((await M()).errors):await D(n,!0);ae!==r.isValid&&g.state.next({isValid:ae})}},x=(J,ae)=>{!s.disabled&&(h.isValidating||h.validatingFields||p.isValidating||p.validatingFields)&&((J||Array.from(l.mount)).forEach(we=>{we&&(ae?Qa(r.validatingFields,we,ae):zl(r.validatingFields,we))}),g.state.next({validatingFields:r.validatingFields,isValidating:!Fd(r.validatingFields)}))},C=(J,ae=[],we,Qe,ye=!0,te=!0)=>{if(Qe&&we&&!s.disabled){if(o.action=!0,te&&Array.isArray(Vs(n,J))){const Ue=we(Vs(n,J),Qe.argA,Qe.argB);ye&&Qa(n,J,Ue)}if(te&&Array.isArray(Vs(r.errors,J))){const Ue=we(Vs(r.errors,J),Qe.argA,Qe.argB);ye&&Qa(r.errors,J,Ue),Bbe(r.errors,J)}if((h.touchedFields||p.touchedFields)&&te&&Array.isArray(Vs(r.touchedFields,J))){const Ue=we(Vs(r.touchedFields,J),Qe.argA,Qe.argB);ye&&Qa(r.touchedFields,J,Ue)}(h.dirtyFields||p.dirtyFields)&&(r.dirtyFields=fw(a,i)),g.state.next({name:J,isDirty:O(J,ae),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Qa(i,J,ae)},k=(J,ae)=>{Qa(r.errors,J,ae),g.state.next({errors:r.errors})},S=J=>{r.errors=J,g.state.next({errors:r.errors,isValid:!1})},_=(J,ae,we,Qe)=>{const ye=Vs(n,J);if(ye){const te=Vs(i,J,Jo(we)?Vs(a,J):we);Jo(te)||Qe&&Qe.defaultChecked||ae?Qa(i,J,ae?te:H6(ye._f)):K(J,te),o.mount&&j()}},A=(J,ae,we,Qe,ye)=>{let te=!1,Ue=!1;const We={name:J};if(!s.disabled){if(!we||Qe){(h.isDirty||p.isDirty)&&(Ue=r.isDirty,r.isDirty=We.isDirty=O(),te=Ue!==We.isDirty);const St=dg(Vs(a,J),ae);Ue=!!Vs(r.dirtyFields,J),St?zl(r.dirtyFields,J):Qa(r.dirtyFields,J,!0),We.dirtyFields=r.dirtyFields,te=te||(h.dirtyFields||p.dirtyFields)&&Ue!==!St}if(we){const St=Vs(r.touchedFields,J);St||(Qa(r.touchedFields,J,we),We.touchedFields=r.touchedFields,te=te||(h.touchedFields||p.touchedFields)&&St!==we)}te&&ye&&g.state.next(We)}return te?We:{}},T=(J,ae,we,Qe)=>{const ye=Vs(r.errors,J),te=(h.isValid||p.isValid)&&Ku(ae)&&r.isValid!==ae;if(s.delayError&&we?(c=w(()=>k(J,we)),c(s.delayError)):(clearTimeout(d),c=null,we?Qa(r.errors,J,we):zl(r.errors,J)),(we?!dg(ye,we):ye)||!Fd(Qe)||te){const Ue={...Qe,...te&&Ku(ae)?{isValid:ae}:{},errors:r.errors,name:J};r={...r,...Ue},g.state.next(Ue)}},M=async J=>{x(J,!0);const ae=await s.resolver(i,s.context,Ibe(J||l.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return x(J),ae},R=async J=>{const{errors:ae}=await M(J);if(J)for(const we of J){const Qe=Vs(ae,we);Qe?Qa(r.errors,we,Qe):zl(r.errors,we)}else r.errors=ae;return ae},D=async(J,ae,we={valid:!0})=>{for(const Qe in J){const ye=J[Qe];if(ye){const{_f:te,...Ue}=ye;if(te){const We=l.array.has(te.name),St=ye._f&&Obe(ye._f);St&&h.validatingFields&&x([Qe],!0);const It=await Y6(ye,l.disabled,i,y,s.shouldUseNativeValidation&&!ae,We);if(St&&h.validatingFields&&x([Qe]),It[te.name]&&(we.valid=!1,ae))break;!ae&&(Vs(It,te.name)?We?Ube(r.errors,It,te.name):Qa(r.errors,te.name,It[te.name]):zl(r.errors,te.name))}!Fd(Ue)&&await D(Ue,ae,we)}}return we.valid},$=()=>{for(const J of l.unMount){const ae=Vs(n,J);ae&&(ae._f.refs?ae._f.refs.every(we=>!yP(we)):!yP(ae._f.ref))&&fe(J)}l.unMount=new Set},O=(J,ae)=>
vendor: 5,542 bytes, line 282
282!s.disabled&&(J&&ae&&Qa(i,J,ae),!dg(Y(),a)),q=(J,ae,we)=>NZ(J,l,{...o.mount?i:Jo(ae)?a:Yh(J)?{[J]:ae}:ae},we,ae),V=J=>i_(Vs(o.mount?i:a,J,s.shouldUnregister?Vs(a,J,[]):[])),K=(J,ae,we={})=>{const Qe=Vs(n,J);let ye=ae;if(Qe){const te=Qe._f;te&&(!te.disabled&&Qa(i,J,EZ(ae,te)),ye=sC(te.ref)&&Bd(ae)?"":ae,CZ(te.ref)?[...te.ref.options].forEach(Ue=>Ue.selected=ye.includes(Ue.value)):te.refs?sN(te.ref)?te.refs.length>1?te.refs.forEach(Ue=>(!Ue.defaultChecked||!Ue.disabled)&&(Ue.checked=Array.isArray(ye)?!!ye.find(We=>We===Ue.value):ye===Ue.value)):te.refs[0]&&(te.refs[0].checked=!!ye):te.refs.forEach(Ue=>Ue.checked=Ue.value===ye):l3(te.ref)?te.ref.value="":(te.ref.value=ye,te.ref.type||g.state.next({name:J,values:qc(i)})))}(we.shouldDirty||we.shouldTouch)&&A(J,ye,we.shouldTouch,we.shouldDirty,!0),we.shouldValidate&&Q(J)},G=(J,ae,we)=>{for(const Qe in ae){const ye=ae[Qe],te=`${J}.${Qe}`,Ue=Vs(n,te);(l.array.has(J)||el(ye)||Ue&&!Ue._f)&&!Cx(ye)?G(te,ye,we):K(te,ye,we)}},z=(J,ae,we={})=>{const Qe=Vs(n,J),ye=l.array.has(J),te=qc(ae);Qa(i,J,te),ye?(g.array.next({name:J,values:qc(i)}),(h.isDirty||h.dirtyFields||p.isDirty||p.dirtyFields)&&we.shouldDirty&&g.state.next({name:J,dirtyFields:fw(a,i),isDirty:O(J,te)})):Qe&&!Qe._f&&!Bd(te)?G(J,te,we):K(J,te,we),W6(J,l)&&g.state.next({...r}),g.state.next({name:o.mount?J:void 0,values:qc(i)})},Z=async J=>{o.mount=!0;const ae=J.target;let we=ae.name,Qe=!0;const ye=Vs(n,we),te=Ue=>{Qe=Number.isNaN(Ue)||Cx(Ue)&&isNaN(Ue.getTime())||dg(Ue,Vs(i,we,Ue))};if(ye){let Ue,We;const St=ae.type?H6(ye._f):vZ(J),It=J.type===tC.BLUR||J.type===tC.FOCUS_OUT,ns=!Dbe(ye._f)&&!s.resolver&&!Vs(r.errors,we)&&!ye._f.deps||Fbe(It,Vs(r.touchedFields,we),r.isSubmitted,b,v),dt=W6(we,l,It);Qa(i,we,St),It?(ye._f.onBlur&&ye._f.onBlur(J),c&&c(0)):ye._f.onChange&&ye._f.onChange(J);const Qt=A(we,St,It),Re=!Fd(Qt)||dt;if(!It&&g.state.next({name:we,type:J.type,values:qc(i)}),ns)return(h.isValid||p.isValid)&&(s.mode==="onBlur"?It&&j():It||j()),Re&&g.state.next({name:we,...dt?{}:Qt});if(!It&&dt&&g.state.next({...r}),s.resolver){const{errors:pt}=await M([we]);if(te(St),Qe){const Ft=K6(r.errors,n,we),Es=K6(pt,n,Ft.name||we);Ue=Es.error,we=Es.name,We=Fd(pt)}}else x([we],!0),Ue=(await Y6(ye,l.disabled,i,y,s.shouldUseNativeValidation))[we],x([we]),te(St),Qe&&(Ue?We=!1:(h.isValid||p.isValid)&&(We=await D(n,!0)));Qe&&(ye._f.deps&&Q(ye._f.deps),T(we,We,Ue,Qt))}},ee=(J,ae)=>{if(Vs(r.errors,ae)&&J.focus)return J.focus(),1},Q=async(J,ae={})=>{let we,Qe;const ye=i0(J);if(s.resolver){const te=await R(Jo(J)?J:ye);we=Fd(te),Qe=J?!ye.some(Ue=>Vs(te,Ue)):we}else J?(Qe=(await Promise.all(ye.map(async te=>{const Ue=Vs(n,te);return await D(Ue&&Ue._f?{[te]:Ue}:Ue)}))).every(Boolean),!(!Qe&&!r.isValid)&&j()):Qe=we=await D(n);return g.state.next({...!Yh(J)||(h.isValid||p.isValid)&&we!==r.isValid?{}:{name:J},...s.resolver||!J?{isValid:we}:{},errors:r.errors}),ae.shouldFocus&&!Qe&&o0(n,ee,J?ye:l.mount),Qe},Y=J=>{const ae={...o.mount?i:a};return Jo(J)?ae:Yh(J)?Vs(ae,J):J.map(we=>Vs(ae,we))},oe=(J,ae)=>({invalid:!!Vs((ae||r).errors,J),isDirty:!!Vs((ae||r).dirtyFields,J),error:Vs((ae||r).errors,J),isValidating:!!Vs(r.validatingFields,J),isTouched:!!Vs((ae||r).touchedFields,J)}),he=J=>{J&&i0(J).forEach(ae=>zl(r.errors,ae)),g.state.next({errors:J?r.errors:{}})},je=(J,ae,we)=>{const Qe=(Vs(n,J,{_f:{}})._f||{}).ref,ye=Vs(r.errors,J)||{},{ref:te,message:Ue,type:We,...St}=ye;Qa(r.errors,J,{...St,...ae,ref:Qe}),g.state.next({name:J,errors:r.errors,isValid:!1}),we&&we.shouldFocus&&Qe&&Qe.focus&&Qe.focus()},pe=(J,ae)=>fh(J)?g.state.subscribe({next:we=>J(q(void 0,ae),we)}):q(J,ae,!0),le=J=>g.state.subscribe({next:ae=>{$be(J.name,ae.name,J.exact)&&Lbe(ae,J.formState||h,bt,J.reRenderRoot)&&J.callback({values:{...i},...r,...ae})}}).unsubscribe,ue=J=>(o.mount=!0,p={...p,...J.formState},le({...J,formState:p})),fe=(J,ae={})=>{for(const we of J?i0(J):l.mount)l.mount.delete(we),l.array.delete(we),ae.keepValue||(zl(n,we),zl(i,we)),!ae.keepError&&zl(r.errors,we),!ae.keepDirty&&zl(r.dirtyFields,we),!ae.keepTouched&&zl(r.touchedFields,we),!ae.keepIsValidating&&zl(r.validatingFields,we),!s.shouldUnregister&&!ae.keepDefaultValue&&zl(a,we);g.state.next({values:qc(i)}),g.state.next({...r,...ae.keepDirty?{isDirty:O()}:{}}),!ae.keepIsValid&&j()},H=({disabled:J,name:ae})=>{(Ku(J)&&o.mount||J||l.disabled.has(ae))&&(J?l.disabled.add(ae):l.disabled.delete(ae))},se=(J,ae={})=>{let we=Vs(n,J);const Qe=Ku(ae.disabled)||Ku(s.disabled);return Qa(n,J,{...we||{},_f:{...we&&we._f?we._f:{ref:{name:J}},name:J,mount:!0,...ae}}),l.mount.add(J),we?H({disabled:Ku(ae.disabled)?ae.disabled:s.disabled,name:J}):_(J,!0,ae.value),{...Qe?{disabled:ae.disabled||s.disabled}:{},...s.progressive?{required:!!ae.required,min:gw(ae.min),max:gw(ae.max),minLength:gw(ae.minLength),maxLength:gw(ae.maxLength),pattern:gw(ae.pattern)}:{},name:J,onChange:Z,onBlur:Z,ref:ye=>{if(ye){se(J,ae),we=Vs(n,J);const te=Jo(ye.value)&&ye.querySelectorAll&&ye.querySelectorAll("input,select,textarea")[0]||ye,Ue=Abe(te),We=we._f.refs||[];if(Ue?We.find(St=>St===te):te===we._f.ref)return;Qa(n,J,{_f:{...we._f,...Ue?{refs:[...We.filter(yP),te,...Array.isArray(Vs(a,J))?[{}]:[]],ref:{type:te.type,name:J}}:{ref:te}}}),_(J,!1,void 0,te)}else we=Vs(n,J,{}),we._f&&(we._f.mount=!1),(s.shouldUnregister||ae.shouldUnregister)&&!(yZ(l.array,J)&&o.action)&&l.unMount.add(J)}}},me=()=>s.shouldFocusError&&o0(n,ee,l.mount),ge=J=>{Ku(J)&&(g.state.next({disabled:J}),o0(n,(ae,we)=>{const Qe=Vs(n,we);Qe&&(ae.disabled=Qe._f.disabled||J,Array.isArray(Qe._f.refs)&&Qe._f.refs.forEac
vendor: 2,360 bytes, line 282
282h(ye=>{ye.disabled=Qe._f.disabled||J}))},0,!1))},be=(J,ae)=>async we=>{let Qe;we&&(we.preventDefault&&we.preventDefault(),we.persist&&we.persist());let ye=qc(i);if(g.state.next({isSubmitting:!0}),s.resolver){const{errors:te,values:Ue}=await M();r.errors=te,ye=Ue}else await D(n);if(l.disabled.size)for(const te of l.disabled)Qa(ye,te,void 0);if(zl(r.errors,"root"),Fd(r.errors)){g.state.next({errors:{}});try{await J(ye,we)}catch(te){Qe=te}}else ae&&await ae({...r.errors},we),me(),setTimeout(me);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Fd(r.errors)&&!Qe,submitCount:r.submitCount+1,errors:r.errors}),Qe)throw Qe},ce=(J,ae={})=>{Vs(n,J)&&(Jo(ae.defaultValue)?z(J,qc(Vs(a,J))):(z(J,ae.defaultValue),Qa(a,J,qc(ae.defaultValue))),ae.keepTouched||zl(r.touchedFields,J),ae.keepDirty||(zl(r.dirtyFields,J),r.isDirty=ae.defaultValue?O(J,qc(Vs(a,J))):O()),ae.keepError||(zl(r.errors,J),h.isValid&&j()),g.state.next({...r}))},Pe=(J,ae={})=>{const we=J?qc(J):a,Qe=qc(we),ye=Fd(J),te=ye?a:Qe;if(ae.keepDefaultValues||(a=we),!ae.keepValues){if(ae.keepDirtyValues){const Ue=new Set([...l.mount,...Object.keys(fw(a,i))]);for(const We of Array.from(Ue))Vs(r.dirtyFields,We)?Qa(te,We,Vs(i,We)):z(We,Vs(te,We))}else{if(i3&&Jo(J))for(const Ue of l.mount){const We=Vs(n,Ue);if(We&&We._f){const St=Array.isArray(We._f.refs)?We._f.refs[0]:We._f.ref;if(sC(St)){const It=St.closest("form");if(It){It.reset();break}}}}for(const Ue of l.mount)z(Ue,Vs(te,Ue))}i=qc(te),g.array.next({values:{...te}}),g.state.next({values:{...te}})}l={mount:ae.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!h.isValid||!!ae.keepIsValid||!!ae.keepDirtyValues,o.watch=!!s.shouldUnregister,g.state.next({submitCount:ae.keepSubmitCount?r.submitCount:0,isDirty:ye?!1:ae.keepDirty?r.isDirty:!!(ae.keepDefaultValues&&!dg(J,a)),isSubmitted:ae.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:ye?{}:ae.keepDirtyValues?ae.keepDefaultValues&&i?fw(a,i):r.dirtyFields:ae.keepDefaultValues&&J?fw(a,J):ae.keepDirty?r.dirtyFields:{},touchedFields:ae.keepTouched?r.touchedFields:{},errors:ae.keepErrors?r.errors:{},isSubmitSuccessful:ae.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},et=(J,ae)=>Pe(fh(J)?J(i):J,ae),$e=(J,ae={})=>{const we=Vs(n,J),Qe=we&&we._f;if(Qe){const ye=Qe.refs?Qe.refs[0]:Qe.ref;
282ye.focus&&(ye.focus(),ae.shouldSelect&&fh(ye.select)&&ye.select())}},bt=J=>{r={...r,...J}},Be={control:{register:se,unregister:fe,getFieldState:oe,handleSubmit:be,setError:je,_subscribe:le,_runSchema:M,_getWatch:q,_getDirty:O,_setValid:j,_setFieldArray:C,_setDisabledField:H,_setErrors:S,_getFieldArray:V,_reset:Pe,_resetDefaultValues:()=>fh(s.defaultValues)&&s.defaultValues().then(J=>{et(J,s.resetOptions),g.state.next({isLoading:!1})}),_removeUnmounted:$,_disableForm:ge,_subjects:g,_proxyFormState:h,get _fields(){return n},get _formValues(){return i},get _state(){return o},set _state(J){o=J},get _defaultValues(){return a},get _names(){return l},set _names(J){l=J},get _formState(){return r},get _options(){return s},set _options(J){s={...s,...J}}},subscribe:ue,trigger:Q,register:se,handleSubmit:be,watch:pe,setValue:z,getValues:Y,reset:et,resetField:ce,clearErrors:he,unregister:fe,setError:je,setFocus:$e,getFieldState:oe};return{...Be,formControl:Be}}function lM(e={}){const s=Ne.useRef(void 0),r=Ne.useRef(void 0),[n,a]=Ne.useState({isDirty:!1,isValidating:!1,isLoading:fh(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:fh(e.defaultValues)?void 0:e.defaultValues});s.current||(s.current={...e.formControl?e.formControl:Hbe(e),formState:n},e.formControl&&e.defaultValues&&!fh(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions));const i=s.current.control;return i._options=e,Ne.useLayoutEffect(()=>i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState}),reRenderRoot:!0}),[i]),Ne.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),Ne.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==n.isDirty&&i._subjects.state.next({isDirty:o})}},[i,n.isDirty]),Ne.useEffect(()=>{e.values&&!dg(e.values,r.current)?(i._reset(e.values,i._options.resetOptions),r.current=e.values,a(o=>({...o}))):i._resetDefaultValues()},[e.values,i]),Ne.useEffect(()=>{e.errors&&!Fd(e.errors)&&i._setErrors(e.errors)},[e.errors,i]),Ne.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()}),Ne.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[e.shouldUnregister,i]),s.current.formState=jZ(n,i),s.current}const Q6=(e,s,r)=>{if(e&&"reportValidity"in e){const n=Vs(r,s);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},AZ=(e,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?Q6(n.ref,r,e):n.refs&&n.refs.forEach(a=>Q6(a,r,e))}},qbe=(e,s)=>{s.shouldUseNativeValidation&&AZ(e,s);const r={};for(const n in e){const a=Vs(s.fields,n),i=Object.assign(e[n]||{},{ref:a&&a.ref});if(Vbe(s.names||Object.keys(e),n)){const o=Object.assign({},Vs(r,n));Qa(o,"root",i),Qa(r,n,o)}else Qa(r,n,i)}return r},Vbe=(e,s)=>e.some(r=>r.startsWith(s+"."));var Wbe=function(e,s){for(var r={};e.length;){var n=e[0],a=n.code,i=n.message,o=n.path.join(".");if(!r[o])if("unionErrors"in n){var l=n.unionErrors[0].errors[0];r[o]={message:l.message,type:l.code}}else r[o]={message:i,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(h){return h.errors.forEach(function(p){return e.push(p)})}),s){var c=r[o].types,d=c&&c[n.code];r[o]=SZ(o,s,r,a,d?[].concat(d,n.message):n.message)}e.shift()}return r},cM=function(e,s,r){return r===void 0&&(r={}),function(n,a,i){try{return Promise.resolve((function(o,l){try{var c=Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](n,s)).then(function(d){return i.shouldUseNativeValidation&&AZ({},i),{errors:{},values:r.raw?n: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?.errors)})(o))return{values:{},errors:qbe(Wbe(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}}};const dM=kbe,MZ=u.createContext({}),lh=({...e})=>t.jsx(MZ.Provider,{value:{name:e.name},children:t.jsx(Tbe,{...e})}),l_=()=>{const e=u.useContext(MZ),s=u.useContext(RZ),{getFieldState:r,formState:n}=o_(),a=r(e.name,n);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:i}=s;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...a}},RZ=u.createContext({}),wm=u.forwardRef(({className:e,...s},r)=>{const n=u.useId();return t.jsx(RZ.Provider,{value:{id:n},children:t.jsx("div",{ref:r,className:Cs("space-y-2",e),...s})})});wm.displayName="FormItem";const jm=u.forwardRef(({className:e,...s},r)=>{const{error:n,formItemId:a}=l_();return t.jsx(re,{ref:r,className:Cs(n&&"text-destructive",e),htmlFor:a,...s})});jm.displayName="FormLabel";const dh=u.forwardRef(({...e},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:i}=l_();return t.jsx(WW,{ref:s,id:n,"aria-describedby":r?`${a} ${i}`:`${a}`,"aria-invalid":!!r,...e})});dh.displayName="FormControl";const Kbe=u.forwardRef(({className:e,...s},r)=>{const{formDescriptionId:n}=l_();return t.jsx("p",{ref:r,id:n,className:Cs("text-sm text-muted-foreground",e),...s})});Kbe.displayName="FormDescription";const Nm=u.forwardRef(({className:e,children:s,...r},n)=>{const{error:a,formMessageId:i}=l_(),o=a?String(a?.message??""):s;return o?t.jsx("p",{ref:n,id:i,className:Cs("text-sm font-medium text-destructive",e),...r,children:o}):null});Nm.displayName="FormMessage";function Y0(e,[s,r]){return Math.min(r,Math.max(s,e))}var Gbe=[" ","Enter","ArrowUp","ArrowDown"],Ybe=[" ","Enter"],rN="Select",[c_,d_,Qbe]=Bj(rN),[Mb]=oo(rN,[Qbe,Pb]),u_=Pb(),[Xbe,Dg]=Mb(rN),[Zbe,Jbe]=Mb(rN),IZ=e=>{const{__scopeSelect:s,children:r,open:n,defaultOpen:a,onOpenChange:i,value:o,defaultValue:l,onValueChange:c,dir:d,name:h,autoComplete:p,disabled:g,required:v,form:b}=e,y=u_(s),[w,j]=u.useState(null),[x,C]=u.useState(null),[k,S]=u.useState(!1),_=Og(d),[A=!1,T]=ip({prop:n,defaultProp:a,onChange:i}),[M,R]=ip({prop:o,defaultProp:l,onChange:c}),D=u.useRef(null),$=w?b||!!w.closest("form"):!0,[O,q]=u.useState(new Set),V=Array.from(O).map(K=>K.props.value).join(";");return t.jsx(jO,{...y,children:t.jsxs(Xbe,{required:v,scope:s,trigger:w,onTriggerChange:j,valueNode:x,onValueNodeChange:C,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:wu(),value:M,onValueChange:R,open:A,onOpenChange:T,dir:_,triggerPointerDownPosRef:D,disabled:g,children:[t.jsx(c_.Provider,{scope:s,children:t.jsx(Zbe,{scope:e.__scopeSelect,onNativeOptionAdd:u.useCallback(K=>{q(G=>new Set(G).add(K))},[]),onNativeOptionRemove:u.useCallback(K=>{q(G=>{const z=new Set(G);return z.delete(K),z})},[]),children:r})}),$?t.jsxs(aJ,{"aria-hidden":!0,required:v,tabIndex:-1,name:h,autoComplete:p,value:M,onChange:K=>
vendor: 16,438 bytes, line 282
282R(K.target.value),disabled:g,form:b,children:[M===void 0?t.jsx("option",{value:""}):null,Array.from(O)]},V):null]})})};IZ.displayName=rN;var OZ="SelectTrigger",DZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=e,i=u_(r),o=Dg(OZ,r),l=o.disabled||n,c=mr(s,o.onTriggerChange),d=d_(r),h=u.useRef("touch"),[p,g,v]=iJ(y=>{const w=d().filter(C=>!C.disabled),j=w.find(C=>C.value===o.value),x=oJ(w,y,j);x!==void 0&&o.onValueChange(x.value)}),b=y=>{l||(o.onOpenChange(!0),v()),y&&(o.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})};return t.jsx(NO,{asChild:!0,...i,children:t.jsx(Cr.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":nJ(o.value)?"":void 0,...a,ref:c,onClick:Ms(a.onClick,y=>{y.currentTarget.focus(),h.current!=="mouse"&&b(y)}),onPointerDown:Ms(a.onPointerDown,y=>{h.current=y.pointerType;const w=y.target;w.hasPointerCapture(y.pointerId)&&w.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(b(y),y.preventDefault())}),onKeyDown:Ms(a.onKeyDown,y=>{const w=p.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&g(y.key),!(w&&y.key===" ")&&Gbe.includes(y.key)&&(b(),y.preventDefault())})})})});DZ.displayName=OZ;var LZ="SelectValue",$Z=u.forwardRef((e,s)=>{const{__scopeSelect:r,className:n,style:a,children:i,placeholder:o="",...l}=e,c=Dg(LZ,r),{onValueNodeHasChildrenChange:d}=c,h=i!==void 0,p=mr(s,c.onValueNodeChange);return da(()=>{d(h)},[d,h]),t.jsx(Cr.span,{...l,ref:p,style:{pointerEvents:"none"},children:nJ(c.value)?t.jsx(t.Fragment,{children:o}):i})});$Z.displayName=LZ;var ewe="SelectIcon",FZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,children:n,...a}=e;return t.jsx(Cr.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});FZ.displayName=ewe;var twe="SelectPortal",BZ=e=>t.jsx(Uj,{asChild:!0,...e});BZ.displayName=twe;var Zx="SelectContent",UZ=u.forwardRef((e,s)=>{const r=Dg(Zx,e.__scopeSelect),[n,a]=u.useState();if(da(()=>{a(new DocumentFragment)},[]),!r.open){const i=n;return i?Em.createPortal(t.jsx(zZ,{scope:e.__scopeSelect,children:t.jsx(c_.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),i):null}return t.jsx(HZ,{...e,ref:s})});UZ.displayName=Zx;var ih=10,[zZ,Lg]=Mb(Zx),swe="SelectContentImpl",rwe=zx("SelectContent.RemoveScroll"),HZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:l,sideOffset:c,align:d,alignOffset:h,arrowPadding:p,collisionBoundary:g,collisionPadding:v,sticky:b,hideWhenDetached:y,avoidCollisions:w,...j}=e,x=Dg(Zx,r),[C,k]=u.useState(null),[S,_]=u.useState(null),A=mr(s,le=>k(le)),[T,M]=u.useState(null),[R,D]=u.useState(null),$=d_(r),[O,q]=u.useState(!1),V=u.useRef(!1);u.useEffect(()=>{if(C)return Gk(C)},[C]),MO();const K=u.useCallback(le=>{const[ue,...fe]=$().map(me=>me.ref.current),[H]=fe.slice(-1),se=document.activeElement;for(const me of le)if(me===se||(me?.scrollIntoView({block:"nearest"}),me===ue&&S&&(S.scrollTop=0),me===H&&S&&(S.scrollTop=S.scrollHeight),me?.focus(),document.activeElement!==se))return},[$,S]),G=u.useCallback(()=>K([T,C]),[K,T,C]);u.useEffect(()=>{O&&G()},[O,G]);const{onOpenChange:z,triggerPointerDownPosRef:Z}=x;u.useEffect(()=>{if(C){let le={x:0,y:0};const ue=H=>{le={x:Math.abs(Math.round(H.pageX)-(Z.current?.x??0)),y:Math.abs(Math.round(H.pageY)-(Z.current?.y??0))}},fe=H=>{le.x<=10&&le.y<=10?H.preventDefault():C.contains(H.target)||z(!1),document.removeEventListener("pointermove",ue),Z.current=null};return Z.current!==null&&(document.addEventListener("pointermove",ue),document.addEventListener("pointerup",fe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ue),document.removeEventListener("pointerup",fe,{capture:!0})}}},[C,z,Z]),u.useEffect(()=>{const le=()=>z(!1);return window.addEventListener("blur",le),window.addEventListener("resize",le),()=>{window.removeEventListener("blur",le),window.removeEventListener("resize",le)}},[z]);const[ee,Q]=iJ(le=>{const ue=$().filter(se=>!se.disabled),fe=ue.find(se=>se.ref.current===document.activeElement),H=oJ(ue,le,fe);H&&setTimeout(()=>H.ref.current.focus())}),Y=u.useCallback((le,ue,fe)=>{const H=!V.current&&!fe;(x.value!==void 0&&x.value===ue||H)&&(M(le),H&&(V.current=!0))},[x.value]),oe=u.useCallback(()=>C?.focus(),[C]),he=u.useCallback((le,ue,fe)=>{const H=!V.current&&!fe;(x.value!==void 0&&x.value===ue||H)&&D(le)},[x.value]),je=n==="popper"?uM:qZ,pe=je===uM?{side:l,sideOffset:c,align:d,alignOffset:h,arrowPadding:p,collisionBoundary:g,collisionPadding:v,sticky:b,hideWhenDetached:y,avoidCollisions:w}:{};return t.jsx(zZ,{scope:r,content:C,viewport:S,onViewportChange:_,itemRefCallback:Y,selectedItem:T,onItemLeave:oe,itemTextRefCallback:he,focusSelectedItem:G,selectedItemText:R,position:n,isPositioned:O,searchRef:ee,children:t.jsx(Yj,{as:rwe,allowPinchZoom:!0,children:t.jsx(Wk,{asChild:!0,trapped:x.open,onMountAutoFocus:le=>{le.preventDefault()},onUnmountAutoFocus:Ms(a,le=>{x.trigger?.focus({preventScroll:!0}),le.preventDefault()}),children:t.jsx(wb,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:le=>le.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:t.jsx(je,{role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:le=>le.preventDefault(),...j,...pe,onPlaced:()=>q(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:Ms(j.onKeyDown,le=>{const ue=le.ctrlKey||le.altKey||le.metaKey;if(le.key==="Tab"&&le.preventDefault(),!ue&&le.key.length===1&&Q(le.key),["ArrowUp","ArrowDown","Home","End"].includes(le.key)){let H=$().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(le.key)&&(H=H.slice().reverse()),["ArrowUp","ArrowDown"].includes(le.key)){const se=le.target,me=H.indexOf(se);H=H.slice(me+1)}setTimeout(()=>K(H)),le.preventDefault()}})})})})})})});HZ.displayName=swe;var nwe="SelectItemAlignedPosition",qZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=e,i=Dg(Zx,r),o=Lg(Zx,r),[l,c]=u.useState(null),[d,h]=u.useState(null),p=mr(s,A=>h(A)),g=d_(r),v=u.useRef(!1),b=u.useRef(!0),{viewport:y,selectedItem:w,selectedItemText:j,focusSelectedItem:x}=o,C=u.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&d&&y&&w&&j){const A=i.trigger.getBoundingClientRect(),T=d.getBoundingClientRect(),M=i.valueNode.getBoundingClientRect(),R=j.getBoundingClientRect();if(i.dir!=="rtl"){const se=R.left-T.left,me=M.left-se,ge=A.left-me,be=A.width+ge,ce=Math.max(be,T.width),Pe=window.innerWidth-ih,et=Y0(me,[ih,Math.max(ih,Pe-ce)]);l.style.minWidth=be+"px",l.style.left=et+"px"}else{const se=T.right-R.right,me=window.innerWidth-M.right-se,ge=window.innerWidth-A.right-me,be=A.width+ge,ce=Math.max(be,T.width),Pe=window.innerWidth-ih,et=Y0(me,[ih,Math.max(ih,Pe-ce)]);l.style.minWidth=be+"px",l.style.right=et+"px"}const D=g(),$=window.innerHeight-ih*2,O=y.scrollHeight,q=window.getComputedStyle(d),V=parseInt(q.borderTopWidth,10),K=parseInt(q.paddingTop,10),G=parseInt(q.borderBottomWidth,10),z=parseInt(q.paddingBottom,10),Z=V+K+O+z+G,ee=Math.min(w.offsetHeight*5,Z),Q=window.getComputedStyle(y),Y=parseInt(Q.paddingTop,10),oe=parseInt(Q.paddingBottom,10),he=A.top+A.height/2-ih,je=$-he,pe=w.offsetHeight/2,le=w.offsetTop+pe,ue=V+K+le,fe=Z-ue;if(ue<=he){const se=D.length>0&&w===D[D.length-1].ref.current;l.style.bottom="0px";const me=d.clientHeight-y.offsetTop-y.offsetHeight,ge=Math.max(je,pe+(se?oe:0)+me+G),be=ue+ge;l.style.height=be+"px"}else{const se=D.length>0&&w===D[0].ref.current;l.style.top="0px";const ge=Math.max(he,V+y.offsetTop+(se?Y:0)+pe)+fe;l.style.height=ge+"px",y.scrollTop=ue-he+y.offsetTop}l.style.margin=`${ih}px 0`,l.style.minHeight=ee+"px",l.style.maxHeight=$+"px",n?.(),requestAnimationFrame(()=>v.current=!0)}},[g,i.trigger,i.valueNode,l,d,y,w,j,i.dir,n]);da(()=>C(),[C]);const[k,S]=u.useState();da(()=>{d&&S(window.getComputedStyle(d).zIndex)},[d]);const _=u.useCallback(A=>{A&&b.current===!0&&(C(),x?.(),b.current=!1)},[C,x]);return t.jsx(iwe,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:v,onScrollButtonChange:_,children:t.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:t.jsx(Cr.div,{...a,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});qZ.displayName=nwe;var awe="SelectPopperPosition",uM=u.forwardRef((e,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=ih,...i}=e,o=u_(r);return t.jsx(SO,{...o,...i,ref:s,align:n,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)"}})});uM.displayName=awe;var[iwe,d3]=Mb(Zx,{}),mM="SelectViewport",VZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,nonce:n,...a}=e,i=Lg(mM,r),o=d3(mM,r),l=mr(s,i.onViewportChange),c=u.useRef(0);return t.jsxs(t.Fragment,{children:[t.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:n}),t.jsx(c_.Slot,{scope:r,children:t.jsx(Cr.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Ms(a.onScroll,d=>{const h=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:g}=o;if(g?.current&&p){const v=Math.abs(c.current-h.scrollTop);if(v>0){const b=window.innerHeight-ih*2,y=parseFloat(p.style.minHeight),w=parseFloat(p.style.height),j=Math.max(y,w);if(j<b){const x=j+v,C=Math.min(b,x),k=x-C;p.style.height=C+"px",p.style.bottom==="0px"&&(h.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}c.current=h.scrollTop})})})]})});VZ.displayName=mM;var WZ="SelectGroup",[owe,lwe]=Mb(WZ),cwe=u.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e,a=wu();return t.jsx(owe,{scope:r,id:a,children:t.jsx(Cr.div,{role:"group","aria-labelledby":a,...n,ref:s})})});cwe.displayName=WZ;var KZ="SelectLabel",GZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e,a=lwe(KZ,r);return t.jsx(Cr.div,{id:a.id,...n,ref:s})});GZ.displayName=KZ;var aC="SelectItem",[dwe,YZ]=Mb(aC),QZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:i,...o}=e,l=Dg(aC,r),c=Lg(aC,r),d=l.value===n,[h,p]=u.useState(i??""),[g,v]=u.useState(!1),b=mr(s,x=>c.itemRefCallback?.(x,n,a)),y=wu(),w=u.useRef("touch"),j=()=>{a||(l.onValueChange(n),l.onOpenChange(!1))};if(n==="")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 t.jsx(dwe,{scope:r,value:n,disabled:a,textId:y,isSelected:d,onItemTextChange:u.useCallback(x=>{p(C=>C||(x?.textContent??"").trim())},[]),children:t.jsx(c_.ItemSlot,{scope:r,value:n,disabled:a,textValue:h,children:t.jsx(Cr.div,{role:"option","aria-labelledby":y,"data-highlighted":g?"":void 0,"aria-selected":d&&g,"data-state":d?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:b,onFocus:Ms(o.onFocus,()=>v(!0)),onBlur:Ms(o.onBlur,()=>v(!1)),onClick:Ms(o.onClick,()=>{w.current!=="mouse"&&j()}),onPointerUp:Ms(o.onPointerUp,()=>{w.current==="mouse"&&j()}),onPointerDown:Ms(o.onPointerDown,x=>{w.current=x.pointerType}),onPointerMove:Ms(o.onPointerMove,x=>{w.current=x.pointerType,a?c.onItemLeave?.():w.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ms(o.onPointerLeave,x=>{x.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:Ms(o.onKeyDown,x=>{c.searchRef?.current!==""&&x.key===" "||(Ybe.includes(x.key)&&j(),x.key===" "&&x.preventDefault())})})})})});QZ.displayName=aC;var zw="SelectItemText",XZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,className:n,style:a,...i}=e,o=Dg(zw,r),l=Lg(zw,r),c=YZ(zw,r),d=Jbe(zw,r),[h,p]=u.useState(null),g=mr(s,j=>p(j),c.onItemTextChange,j=>l.itemTextRefCallback?.(j,c.value,c.disabled)),v=h?.textContent,b=u.useMemo(()=>t.jsx("option",{value:c.value,disabled:c.disabled,children:v},c.value),[c.disabled,c.value,v]),{onNativeOptionAdd:y,onNativeOptionRemove:w}=d;return da(()=>(y(b),()=>w(b)),[y,w,b]),t.jsxs(t.Fragment,{children:[t.jsx(Cr.span,{id:c.textId,...i,ref:g}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Em.createPortal(i.children,o.valueNode):null]})});XZ.displayName=zw;var ZZ="SelectItemIndicator",JZ=u.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e;return YZ(ZZ,r).isSelected?t.jsx(Cr.span,{"aria-hidden":!0,...n,ref:s}):null});JZ.displayName=ZZ;var hM="SelectScrollUpButton",eJ=u.forwardRef((e,s)=>{const r=Lg(hM,e.__scopeSelect),n=d3(hM,e.__scopeSelect),[a,i]=u.useState(!1),o=mr(s,n.onScrollButtonChange);return da(()=>{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?t.jsx(sJ,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});eJ.displayName=hM;var pM="SelectScrollDownButton",tJ=u.forwardRef((e,s)=>{const r=Lg(pM,e.__scopeSelect),n=d3(pM,e.__scopeSelect),[a,i]=u.useState(!1),o=mr(s,n.onScrollButtonChange);return da(()=>{if(r.viewport&&r.isPositioned){let l=function(){const d=c.scrollHeight-c.clientHeight,h=Math.ceil(c.scrollTop)<d;i(h)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?t.jsx(sJ,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});tJ.displayName=pM;var sJ=u.forwardRef((e,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=e,i=Lg("SelectScrollButton",r),o=u.useRef(null),l=d_(r),c=u.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return u.useEffect(()=>()=>c(),[c]),da(()=>{l().find(h=>h.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),t.jsx(Cr.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Ms(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(n,50))}),onPointerMove:Ms(a.onPointerMove,()=>{i.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(n,50))}),onPointerLeave:Ms(a.onPointerLeave,()=>{c()})})}),uwe="SelectSeparator",rJ=u.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e;return t.jsx(Cr.div,{"aria-hidden":!0,...n,ref:s})});rJ.displayName=uwe;var fM="SelectArrow",mwe=u.forwardRef((e,s)=>{const{__scopeSelect:r,...n}=e,a=u_(r),i=Dg(fM,r),o=Lg(fM,r);return i.open&&o.position==="popper"?t.jsx(CO,{...a,...n,ref:s}):null});mwe.displayName=fM;function nJ(e){return e===""||e===void 0}var aJ=u.forwardRef((e,s)=>{const{value:r,...n}=e,a=u.useRef(null),i=mr(s,a),o=Gj(r);return u.useEffect(()=>{const l=a.current,c=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==r&&h){const p=new Event("change",{bubbles:!0});h.call(l,r),l.dispatchEvent(p)}},[o,r]),t.jsx(zj,{asChild:!0,children:t.jsx("select",{...n,ref:i,defaultValue:r})})});aJ.displayName="BubbleSelect";function iJ(e){const s=Za(e),r=u.useRef(""),n=u.useRef(0),a=u.useCallback(o=>{const l=r.current+o;s(l),(function c(d){r.current=d,window.clearTimeout(n.current),d!==""&&(n.current=window.setTimeout(()=>c(""),1e3))})(l)},[s]),i=u.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return u.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,i]}function oJ(e,s,r){const a=s.length>1&&Array.from(s).every(d=>d===s[0])?s[0]:s,i=r?e.indexOf(r):-1;let o=hwe(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 hwe(e,s){return e.map((r,n)=>e[(s+n)%e.length])}var pwe=IZ,lJ=DZ,fwe=$Z,gwe=FZ,xwe=BZ,cJ=UZ,vwe=VZ,dJ=GZ,uJ=QZ,ywe=XZ,bwe=JZ,mJ=eJ,hJ
282=tJ,pJ=rJ;const Us=pwe,zs=fwe,$s=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(lJ,{ref:n,className:Cs("flex h-9 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[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:[s,t.jsx(gwe,{asChild:!0,children:t.jsx(Xa,{className:"h-4 w-4 opacity-50"})})]}));$s.displayName=lJ.displayName;const fJ=u.forwardRef(({className:e,...s},r)=>t.jsx(mJ,{ref:r,className:Cs("flex cursor-default items-center justify-center py-1",e),...s,children:t.jsx(Ig,{className:"h-4 w-4"})}));fJ.displayName=mJ.displayName;const gJ=u.forwardRef(({className:e,...s},r)=>t.jsx(hJ,{ref:r,className:Cs("flex cursor-default items-center justify-center py-1",e),...s,children:t.jsx(Xa,{className:"h-4 w-4"})}));gJ.displayName=hJ.displayName;const Fs=u.forwardRef(({className:e,children:s,position:r="popper",...n},a)=>t.jsx(xwe,{children:t.jsxs(cJ,{ref:a,className:Cs("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-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 origin-[--radix-select-content-transform-origin]",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,...n,children:[t.jsx(fJ,{}),t.jsx(vwe,{className:Cs("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),t.jsx(gJ,{})]})}));Fs.displayName=cJ.displayName;const wwe=u.forwardRef(({className:e,...s},r)=>t.jsx(dJ,{ref:r,className:Cs("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...s}));wwe.displayName=dJ.displayName;const rt=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(uJ,{ref:n,className:Cs("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(bwe,{children:t.jsx(Hd,{className:"h-4 w-4"})})}),t.jsx(ywe,{children:s})]}));rt.displayName=uJ.displayName;const jwe=u.forwardRef(({className:e,...s},r)=>t.jsx(pJ,{ref:r,className:Cs("-mx-1 my-1 h-px bg-muted",e),...s}));jwe.displayName=pJ.displayName;const Nwe=Gd({name:it().min(1,"Company name is required"),description:it().optional(),resellerId:it().optional()});function u3({open:e,onOpenChange:s,company:r,resellers:n,onCreated:a,defaultResellerId:i}){const{toast:o}=Hs(),l=!!r,c=lM({resolver:cM(Nwe),defaultValues:{name:"",description:"",resellerId:""}});u.useEffect(()=>{e&&(r?c.reset({name:r.name,description:r.description||"",resellerId:r.resellerId||""}):c.reset({name:"",description:"",resellerId:i||""}))},[e,r,i,c]);const d=Et({mutationFn:async S=>{const _={name:S.name,description:S.description};return S.resellerId&&(_.resellerId=S.resellerId),(await Ze("POST","/api/companies",_)).json()},onSuccess:S=>{Je.invalidateQueries({queryKey:["/api/companies"]}),o({title:"Success",description:"Company created successfully"}),s(!1),a?.(S)},onError:S=>{const _=S.message.replace(/^\d{3}:\s*/,"");let A="Failed to create company";try{A=JSON.parse(_).message||A}catch{}o({title:"Could not create company",description:A,variant:"destructive"})}}),h=Et({mutationFn:S=>{const _={name:S.name,description:S.description};return n&&(_.resellerId=S.resellerId||null),Ze("PATCH",`/api/companies/${r?.id}`,_)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/companies"]}),o({title:"Success",description:"Company updated successfully"}),s(!1)},onError:()=>{o({title:"Error",description:"Failed to update company",variant:"destructive"})}}),[p,g]=u.useState(null),[v,b]=u.useState(!1),[y,w]=u.useState(null),[j,x]=u.useState(!1),C=async S=>{if(!l){d.mutate(S);return}const _=r?.resellerId||"",A=S.resellerId||"";if(!(!!n&&_!==A)||!r?.id){h.mutate(S);return}b(!0);try{const D=(await(await Ze("POST","/api/admin/access-impact-preview",{kind:"company_reseller_change",companyId:r.id,newResellerId:A||null})).json()).affectedOwners||[];if(D.length>0){g(D),w(S),x(!0),b(!1);return}}catch{}b(!1),h.mutate(S)},k=d.isPending||h.isPending||v;return t.jsxs(Ys,{open:e,onOpenChange:S=>{k||s(S)},children:[t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:l?"Edit Company":"Add Company"}),t.jsx(cr,{children:l?"Update the company details below.":"Add a new company to organize your sites."})]}),t.jsx(dM,{...c,children:t.jsxs("form",{onSubmit:S=>{S.stopPropagation(),c.handleSubmit(C)(S)},className:"space-y-4",children:[t.jsx(lh,{control:c.control,name:"name",render:({field:S})=>t.jsxs(wm,{children:[t.jsx(jm,{children:"Company Name"}),t.jsx(dh,{children:t.jsx(ke,{placeholder:"Enter company name",...S,"data-testid":"input-company-name"})}),t.jsx(Nm,{})]})}),t.jsx(lh,{control:c.control,name:"description",render:({field:S})=>t.jsxs(wm,{children:[t.jsx(jm,{children:"Description (Optional)"}),t.jsx(dh,{children:t.jsx(Nn,{placeholder:"Enter description",className:"resize-none",...S,"data-testid":"input-company-description"})}),t.jsx(Nm,{})]})}),n&&n.length>0&&t.jsx(lh,{control:c.control,name:"resellerId",render:({field:S})=>t.jsxs(wm,{children:[t.jsx(jm,{children:"Assigned Customer"}),t.jsxs(Us,{value:S.value||"",onValueChange:S.onChange,children:[t.jsx(dh,{children:t.jsx($s,{"data-testid":"select-company-reseller",children:t.jsx(zs,{placeholder:"Select a customer..."})})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"none",children:"No Customer"}),n.map(_=>t.jsx(rt,{value:_.userId,children:_.businessName}
282,_.userId))]})]}),t.jsx(Nm,{})]})}),t.jsxs(In,{className:"flex-col sm:flex-row gap-2",children:[t.jsx(L,{type:"button",variant:"outline",onClick:()=>s(!1),disabled:k,"data-testid":"button-cancel-company",children:"Cancel"}),t.jsx(L,{type:"submit",disabled:k,"data-testid":"button-save-company",children:k?"Saving...":l?"Save Changes":"Add Company"})]})]})})]}),t.jsx(Ys,{open:j,onOpenChange:S=>{x(S),S||(g(null),w(null))},children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Confirm Customer Reassignment"}),t.jsxs(cr,{children:["Reassigning this company's customer will revoke Device Settings access from the following owner",(p?.length??0)===1?"":"s","."]})]}),t.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3 text-sm space-y-2","data-testid":"warning-reseller-change-impact",children:t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:(p||[]).map(S=>{const _=[S.firstName,S.lastName].filter(Boolean).join(" ").trim(),A=_||S.email||S.userId,T=S.lostDeviceSerials&&S.lostDeviceSerials.length>0?S.lostDeviceSerials.join(", "):`${S.lostDeviceIds.length} device${S.lostDeviceIds.length===1?"":"s"}`;return t.jsxs("li",{"data-testid":`text-reseller-impact-owner-${S.userId}`,children:[t.jsx("span",{className:"font-medium",children:A}),S.email&&_?t.jsxs("span",{className:"text-muted-foreground",children:[" (",S.email,")"]}):null,t.jsxs("span",{className:"text-muted-foreground",children:[" — loses access to ",T]})]},S.userId)})})}),t.jsxs(In,{className:"flex-col sm:flex-row gap-2",children:[t.jsx(L,{type:"button",variant:"outline",onClick:()=>{x(!1),g(null),w(null)},"data-testid":"button-cancel-reseller-change",children:"Cancel"}),t.jsx(L,{type:"button",variant:"destructive",disabled:h.isPending,onClick:()=>{if(!y)return;const S=y;x(!1),g(null),w(null),h.mutate(S)},"data-testid":"button-confirm-reseller-change",children:h.isPending?"Saving...":"Reassign anyway"})]})]})})]})}function X6({value:e,onChange:s,onBlur:r}){const n=u.useId(),[a,i]=u.useState(!1),[o,l]=u.useState([]),[c,d]=u.useState(-1),[h,p]=u.useState(null),g=u.useRef(null),v=u.useRef(0),b=u.useRef("");u.useEffect(()=>{if(l([]),d(-1),p(null),!a||e.trim().length<3||e===g.current)return;if(Date.now()<v.current){p(b.current);return}const j=new AbortController,x=window.setTimeout(async()=>{try{const C=await fetch(`/api/sites/address-suggestions?q=${encodeURIComponent(e.trim())}`,{credentials:"include",signal:j.signal}),k=await C.json();if(C.status===429){const S=Number(C.headers.get("Retry-After"));Number.isFinite(S)&&S>0&&(v.current=Date.now()+Math.min(S,86400)*1e3),b.current=k.message||"Too many address searches. You can enter the address manually."}if(!C.ok)throw new Error(k.message||"Suggestions unavailable. You can enter the address manually.");j.signal.aborted||l(Array.isArray(k.suggestions)?k.suggestions:[])}catch(C){j.signal.aborted||p(C instanceof Error?C.message:"Suggestions unavailable. You can enter the address manually.")}},350);return()=>{window.clearTimeout(x),j.abort()}},[e,a]);const y=j=>{g.current=j,s(j),l([]),d(-1),i(!1)},w=a&&o.length>0;return t.jsxs("div",{className:"relative min-w-0 flex-1",children:[t.jsx(ke,{placeholder:"Street address, city, region",value:e,onChange:j=>{g.current=null,s(j.target.value)},onFocus:()=>i(!0),onBlur:()=>{i(!1),r()},onKeyDown:j=>{j.key==="Escape"?(i(!1),l([])):w&&j.key==="ArrowDown"?(j.preventDefault(),d(x=>(x+1)%o.length)):w&&j.key==="ArrowUp"?(j.preventDefault(),d(x=>x<=0?o.length-1:x-1)):w&&j.key==="Enter"&&c>=0&&(j.preventDefault(),y(o[c]))},role:"combobox","aria-autocomplete":"list","aria-expanded":w,"aria-controls":w?n:void 0,"aria-activedescendant":w&&c>=0?`${n}-${c}`:void 0,autoComplete:"off","data-testid":"input-site-address"}),w&&t.jsxs("div",{id:n,role:"listbox","aria-label":"Suggested site addresses",className:"absolute left-0 right-0 top-full z-[60] mt-1 max-h-56 overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md",children:[o.map((j,x)=>t.jsx("button",{type:"button",role:"option",id:`${n}-${x}`,"aria-selected":x===c,className:`block w-full rounded-sm px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground ${x===c?"bg-accent text-accent-foreground":""}`,onMouseDown:C=>C.preventDefault(),onClick:()=>y(j),children:j},`${j}-${x}`)),t.jsx("div",{className:"px-3 py-1 text-right text-xs text-muted-foreground",translate:"no",children:"Google Maps"})]}),a&&h&&e.trim().length>=3&&t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",role:"status",children:h})]})}var Swe="Separator",Z6="horizontal",Cwe=["horizontal","vertical"],xJ=u.forwardRef((e,s)=>{const{decorative:r,orientation:n=Z6,...a}=e,i=kwe(n)?n:Z6,l=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return t.jsx(Cr.div,{"data-orientation":i,...l,...a,ref:s})});xJ.displayName=Swe;function kwe(e){return Cwe.includes(e)}var vJ=xJ;const Qh=u.forwardRef(({className:e,orientation:s="horizontal",decorative:r=!0,...n},a)=>t.jsx(vJ,{ref:a,decorative:r,orientation:s,className:Cs("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));Qh.displayName=vJ.displayName;const J6="__add_new_company__";
282function _we({value:e,onChange:s,currentCompanyId:r,currentCompanyName:n,role:a,disabled:i}){const o=a==="admin"||a==="superadmin",[l,c]=u.useState(!1),[d,h]=u.useState(null),p=u.useRef(!0);u.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]),u.useEffect(()=>{o||c(!1)},[o]);const g=ze({queryKey:["/api/companies"]}),v=g.data?.find(x=>x.id===r),y=[...(g.data||[]).filter(x=>!o||a==="superadmin"||v&&x.resellerId===v.resellerId)];d&&!y.some(x=>x.id===d.id)&&y.push(d),y.some(x=>x.id===r)||y.unshift({id:r,name:n||v?.name||"Current company",resellerId:v?.resellerId??null});const w=ze({queryKey:["/api/admin/resellers"],enabled:l&&a==="superadmin"}),j=y.find(x=>x.id===e)?.name||n||"Current company";return t.jsxs(t.Fragment,{children:[t.jsxs(Us,{value:e,onValueChange:x=>{!o||i||!x||(x===J6?c(!0):s(x))},disabled:!o||i||g.isPending||g.isError,children:[t.jsx($s,{id:"site-company","aria-label":"Company","data-testid":"select-site-company",children:t.jsx(zs,{children:j})}),t.jsxs(Fs,{className:"w-[var(--radix-select-trigger-width)] max-w-[calc(100vw-2rem)]",children:[y.map(x=>t.jsx(rt,{value:x.id,className:"whitespace-normal break-words [&>span:last-child]:min-w-0 [&>span:last-child]:whitespace-normal [&>span:last-child]:break-words",children:x.name},x.id)),o&&t.jsx(rt,{value:J6,children:"Add new company…"})]})]},y.map(x=>x.id).sort().join(":")),g.isError&&o&&t.jsxs("div",{className:"text-sm text-destructive",role:"alert",children:["Could not load companies."," ",t.jsx(L,{type:"button",variant:"ghost",className:"h-auto p-0 underline",onClick:()=>{g.refetch()},children:"Retry"})]}),t.jsx(u3,{open:l&&o,onOpenChange:c,defaultResellerId:v?.resellerId,resellers:a==="superadmin"?w.data:void 0,onCreated:x=>{!p.current||!o||(h(x),s(x.id))}})]})}function Pwe({affected:e,onCancel:s,onConfirm:r}){return t.jsx(zd,{open:e!==null,onOpenChange:n=>{n||s()},children:t.jsxs(bd,{children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:"Confirm Company Reassignment"}),t.jsx(Sd,{children:"Moving this site will remove access for the following accounts. Their existing company and site assignments will not be changed."})]}),t.jsx("ul",{className:"list-disc space-y-2 pl-5 text-sm","data-testid":"warning-site-company-impact",children:(e||[]).map(n=>t.jsxs("li",{children:[t.jsx("span",{className:"font-medium",children:[n.firstName,n.lastName].filter(Boolean).join(" ")||n.email}),n.email&&(n.firstName||n.lastName)?` (${n.email})`:"",n.lostDeviceSerials?.length?` — ${n.lostDeviceSerials.join(", ")}`:""]},n.userId))}),t.jsxs(jd,{children:[t.jsx(Gc,{onClick:s,"data-testid":"button-cancel-site-company-change",children:"Cancel"}),t.jsx(Cd,{onClick:r,"data-testid":"button-confirm-site-company-change",children:"Confirm Move"})]})]})})}const Ewe=Gd({name:it().min(1,"Site name is required"),description:it().optional(),address:it().optional(),serialNumber:it().min(1,"Serial number is required")}),Twe=Gd({companyId:it().min(1,"Company is required"),name:it().min(1,"Site name is required"),description:it().optional(),address:it().optional(),serialNumber:it().optional()});function yJ({open:e,onOpenChange:s,companyId:r,site:n,isAdmin:a=!1,companyName:i,initialCompanyId:o}){const{toast:l}=Hs(),c=Er(),d=!!n,h=!!n?.locationHidden,[p,g]=u.useState("idle"),[v,b]=u.useState(""),[y,w]=u.useState(null),[j,x]=u.useState(!1),[C,k]=u.useState(""),[S,_]=u.useState(!1),[A,T]=u.useState(null),[M,R]=u.useState(null),D=u.useRef(0),{data:$}=ze({queryKey:["/api/user/role"],enabled:e&&d}),O=$?.role==="admin"||$?.role==="superadmin",q=!!n&&n.isOnline===!1,V=d&&a&&q,K=lM({resolver:cM(Ewe),defaultValues:{name:"",description:"",address:"",serialNumber:""}}),G=lM({resolver:cM(Twe),defaultValues:{companyId:"",name:"",description:"",address:"",serialNumber:""}});u.useEffect(()=>{D.current++,_(!1),T(null),R(null),e&&(g("idle"),b(""),w(null),k(""),n?G.reset({companyId:o||n.companyId,name:n.name,description:n.description||"",address:n.address||"",serialNumber:n.serialNumber||""}):K.reset({name:"",description:"",address:"",serialNumber:""}))},[e,n,o,K,G]),u.useEffect(()=>{n&&$&&!O&&G.setValue("companyId",n.companyId)},[n,$,O,G]);const z=Et({mutationFn:le=>{const ue={name:le.name,description:le.description,address:le.address?.trim()||null,companyId:r,serialNumber:le.serialNumber.trim().toUpperCase()};return Ze("POST","/api/sites",ue)},onSuccess:()=>
282{Je.invalidateQueries({queryKey:["/api/companies"]}),l({title:"Success",description:"Site added successfully"}),s(!1)},onError:async le=>{const ue=le?.message||"";if(ue.includes("409"))l({title:"Error",description:ue.toLowerCase().includes("activated")?"This device has already been activated on another site":"This device is already registered to another account",variant:"destructive"});else if(ue.includes("422"))try{const fe=JSON.parse(ue.match(/\{.*\}/)?.[0]||"{}");l({title:"Validation Failed",description:fe.message||"Device validation failed",variant:"destructive"})}catch{l({title:"Validation Failed",description:"Device connection or credential check failed",variant:"destructive"})}else{const fe=he(ue);k(fe),l({title:"Could not save site",description:fe,variant:"destructive"})}}}),Z=Et({mutationFn:({data:le,confirmed:ue=!1,confirmedAffectedUserIds:fe})=>{const H={name:le.name,description:le.description};return h||(H.address=le.address?.trim()||null),le.companyId!==n?.companyId&&(H.companyId=le.companyId,H.confirmAccessLoss=ue,ue&&(H.confirmedAffectedUserIds=fe)),Ze("PATCH",`/api/sites/${n?.id}`,H)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/companies"]}),Je.invalidateQueries({queryKey:["/api/sites"]}),Je.invalidateQueries({queryKey:["/api/edge-devices"]}),Je.invalidateQueries({queryKey:["/api/user/role"]}),l({title:"Success",description:"Site updated successfully"}),s(!1)},onError:(le,ue)=>{try{const H=JSON.parse((le?.message||"").replace(/^\d{3}:\s*/,""));if(H.code==="ACCESS_IMPACT_CONFIRMATION_REQUIRED"&&Array.isArray(H.affectedOwners)&&H.affectedOwners.length){R(ue.data),T(H.affectedOwners);return}}catch{}const fe=he(le?.message||"");k(fe),l({title:"Could not save site",description:fe,variant:"destructive"})}}),ee=Et({mutationFn:()=>Ze("DELETE",`/api/sites/${n?.id}`),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/companies"]}),Je.invalidateQueries({queryKey:["/api/subscriptions"]}),Je.invalidateQueries({queryKey:["/api/subscription-summary"]}),Je.invalidateQueries({queryKey:["/api/edge-devices"]}),Je.invalidateQueries({queryKey:["/api/cloud-storage/settings"]}),l({title:"Success",description:"Site deactivated successfully"}),x(!1),s(!1)},onError:()=>{l({title:"Error",description:"Failed to deactivate site",variant:"destructive"})}}),Q=async le=>{if(le.trim()){g("validating"),b(""),w(null);try{const fe=await(await Ze("POST","/api/edge-devices/validate-serial",{serialNumber:le.trim().toUpperCase(),companyId:r})).json();if(fe.found){const H={version:fe.version,host:fe.host,port:fe.port,isOnline:fe.isOnline,isEdgeDevice:fe.isEdgeDevice,apiAuthValid:fe.apiAuthValid,apiAuthError:fe.apiAuthError,error:fe.error};w(H),!H.isOnline||!H.isEdgeDevice||!H.apiAuthValid?(g("invalid"),H.isOnline?H.isEdgeDevice?b("One or more credential checks failed"):b(`Device is not running ${c.productName} software`):b("Device is offline or unreachable")):g("valid")}else g("invalid"),b("Device not found in registry")}catch(ue){g("invalid");const fe=ue?.message||"";fe.includes("409")?b(fe.toLowerCase().includes("activated")?"This device has already been activated on another site.":"This device is already registered to another account."):fe.includes("404")?b("Serial number not found. Contact your administrator to register the device."):b("Failed to validate serial number")}}},Y=async le=>{if(p!=="valid"){await Q(le.serialNumber);return}z.mutate(le)},oe=async le=>{if(k(""),le.companyId===n?.companyId){Z.mutate({data:le});return}if(!O){k("Only administrators can change the company assigned to a site.");return}const ue=D.current;_(!0);try{const H=await(await Ze("POST","/api/admin/access-impact-preview",{kind:"site_company_change",siteId:n?.id,newCompanyId:le.companyId})).json();if(ue!==D.current)return;if(!Array.isArray(H.affectedOwners))throw new Error("Could not check access changes. Please try again.");H.affectedOwners.length?(R(le),T(H.affectedOwners)):Z.mutate({data:le})}catch(fe){if(ue!==D.current)return;const H=he(fe?.message||"");k(H),l({title:"Could not check company reassignment",description:H,variant:"destructive"})}finally{ue===D.current&&_(!1)}};function he(le){const ue=le.replace(/^\d{3}:\s*/,"");try{const fe=JSON.parse(ue);return fe.message||fe.error||ue||"The site could not be saved."}catch{return ue||"The site could not be saved. Please try again."}}const je=z.isPending||Z.isPending||p==="validating",pe=()=>{Z.isPending||(D.current++,_(!1),T(null),R(null),s(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(Ys,{open:e,onOpenChange:le=>{le?s(!0):pe()},children:t.jsxs(Ws,{className:"sm:max-w-lg",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:d?"Edit Site":"Add Site"}),t.jsx(cr,{children:d?"Update the site details below.":"Enter the serial number from your Edge device to add a new site."})]}),d?t.jsx(dM,{...G,children:t.jsxs("form",{onSubmit:G.handleSubmit(oe),className:"space-y-4",children:[t.jsx(lh,{control:G.control,name:"companyId",render:({field:le})=>t.jsxs(wm,{children:[t.jsx(jm,{htmlFor:"site-company",children:"Company"}),t.jsx(_we,{value:le.value,onChange:le.onChange,currentCompanyId:n.companyId,currentCompanyName:i,role:$?.role,disabled:Z.isPending||S}),!O&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Only administrators can change the assigned company."}),t.jsx(Nm,{})]})}),t.jsx(lh,{control:G.control,name:"name",render:({field:le})=>t.jsxs(wm,{children:[t.jsx(jm,{children:"Site Name"}),t.jsx(dh,{children:t.jsx(ke,{placeholder:"e.g., Main Office, Warehouse A",...le,"data-testid":"input-site-name"})}),t.jsx(Nm,{})]})}),h?t.jsx("p",{className:"text-sm text-muted-foreground",role:"status",children:"Address editing is unavailable because this site’s location is hidden by policy."}):t.jsx(t.Fragment,{children:t.jsx(lh,{control:G.control,name:"address",render:({field:le})=>t.jsxs(wm,{children:[t.jsx(jm,{children:"Site Address (Optional)"}),t.jsx(dh,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(X6,{value:le.value||"",onChange:ue=>{le.onChange(ue),k("")},onBlur:le.onBlur}),t.jsx(L,{type:"button",variant:"outline",onClick:()=>{le.onChange(""),k("")},"aria-label":"Clear site address",children:"Clear"})]})}),t.jsx(Nm,{})]})})}),C&&t.jsx("p",{className:"text-sm text-destructive",role:"alert",children:C}),t.jsx(lh,{control:G.control,name:"description",render:({field:le})=>t.jsxs(wm,{children:[t.jsx(jm,{children:"Description (Optional)"}),t.jsx(dh,{children:t.jsx(Nn,{placeholder:"Brief description of this site",className:"resize-none",...le,"data-testid":"input-site-description"})}),t.jsx(Nm,{})]})}),a&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs(re,{className:"flex items-center gap-2",children:[t.jsx(Fa,{className:"w-4 h-4"})," Serial Number"]}),t.jsx(ke,{value:n?.serialNumber||"",readOnly:!0,disabled:!0,className:"font-mono uppercase","data-testid":"text-edit-site-serial"})]}),t.jsxs(In,{className:"flex-col sm:flex-row gap-2 pt-4",children:[V?t.jsxs(L,{type:"button",variant:"outline",onClick:()=>x(!0),disabled:ee.isPending,className:"text-destructive hover:text-destructive hover:bg-destructive/10 sm:mr-auto","data-testid":"button-deactivate-site",children:[t.jsx(sa,{className:"w-4 h-4 mr-2"}),"Deactivate Device"]}):t.jsx("div",{className:"flex-1"}),t.jsx(L,{type:"button",variant:"outline",onClick:pe,disabled:Z.isPending,"data-testid":"button-cancel-site",children:"Cancel"}),t.jsx(L,{type:"submit",disabled:Z.isPending||S,"data-testid":"button-save-site",children:S?"Checking access...":Z.isPending?"Saving...":"Save Changes"})]})]})}):t.jsx(dM,{...K,children:t.jsxs("form",{onSubmit:K.handleSubmit(Y),className:"space-y-4",children:[t.jsx(lh,{control:K.control,name:"serialNumber",render:({field:le})=>t.jsxs(wm,{children:[t.jsx(jm,{children:"Serial Number"}),t.jsx(dh,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ke,{placeholder:"TE-XXXXXXXXX",className:"font-mono uppercase",...le,onChange:ue=>{le.onChange(ue),g("idle"),b(""),w(null)},"data-testid":"input-site-serial"}),t.jsx(L,{type:"button",variant:"outline",size:"default",onClick:()=>Q(le.value),disabled:!le.value.trim()||p==="validating","data-testid":"button-validate-serial",children:p==="validating"?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):"Verify"})]})}),t.jsx(Nm,{})]})}),y&&(p==="valid"||p==="invalid")&&t.jsxs("div",{className:"space-y-1.5 rounded-md border p-3","data-testid":"status-serial-checks",children:[t.jsxs("div",{className:`flex items-center gap-2 text-sm ${y.isOnline?"text-green-600 dark:text-green-400":"text-destructive"}`,"data-testid":"status-connection",children:[y.isOnline?t.jsx(jb,{className:"w-4 h-4 shrink-0"}):t.jsx($de,{className:"w-4 h-4 shrink-0"}),"Connection: ",y.isOnline?"Online":"Offline / Unreachable"]}),y.isOnline&&t.jsxs("div",{className:`flex items-center gap-2 text-sm ${y.isEdgeDevice?"text-green-600 dark:text-green-400":"text-destructive"}`,"data-testid":"status-edge-device",children:[y.isEdgeDevice?t.jsx(ar,{className:"w-4 h-4 shrink-0"}):t.jsx(rf,{className:"w-4 h-4 shrink-0"}),c.productName,": ",y.isEdgeDevice?y.version?`Detected (v${y.version})`:"Detected":"Not detected"]}),y.isOnline&&y.isEdgeDevice&&t.jsx(t.Fragment,{children:t.jsxs("div",{className:`flex items-center gap-2 text-sm ${y.apiAuthValid?"text-green-600 dark:text-green-400":"text-destructive"}`,"data-testid":"status-api-auth",children:[y.apiAuthValid?t.jsx(uc,{className:"w-4 h-4 shrink-0"}):t.jsx(iO,{className:"w-4 h-4 shrink-0"}),"API Auth: ",y.apiAuthValid?"Valid":y.apiAuthError||"Failed"]})})]}),p==="invalid"&&!y&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive","data-testid":"status-serial-invalid",children:[t.jsx(rf,{className:"w-4 h-4"}),v]}),t.jsx(Qh,{}),t.jsx(lh,{control:K.control,name:"name",render:({field:le})=>t.jsxs(wm,{children:[t.jsx(jm,{children:"Site Name"}),t.jsx(dh,{children:t.jsx(ke,{placeholder:"e.g., Main Office, Warehouse A",...le,"data-testid":"input-site-name"})}),t.jsx(Nm,{})]})}),t.jsx(lh,{control:K.control,name:"address",render:({field:le})=>t.jsxs(wm,{children:[t.jsx(jm,{children:"Site Address (Optional)"}),t.jsx(dh,{children:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(X6,{value:le.value||"",onChange:ue=>{le.onChange(ue),k("")},onBlur:le.onBlur}),t.jsx(L,{type:"button",variant:"outline",onClick:()=>{le.onChange(""),k("")},"aria-label":"Clear site address",children:"Clear"})]})}),t.jsx(Nm,{})]})}),C&&t.jsx("p",{className:"text-sm text-destructive",role:"alert",children:C}),t.jsx(lh,{control:K.control,name:"description",render:({field:le})=>t.jsxs(wm,{children:[t.jsx(jm,{children:"Description (Optional)"}),t.jsx(dh,{children:t.jsx(Nn,{placeholder:"Brief description of this site",className:"resize-none",...le,"data-testid":"input-site-description"})}),t.jsx(Nm,{})]})}),t.jsxs(In,{className:"flex-col sm:flex-row gap-2 pt-4",children:[t.jsx("div",{className:"flex-1"}),t.jsx(L,{type:"button",variant:"outline",onClick:()=>s(!1),"data-testid":"button-cancel-site",children:"Cancel"}),t.jsx(L,{type:"submit",disabled:je,"data-testid":"button-save-site",children:je?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 animate-spin mr-2"}),p==="validating"?"Verifying...":"Adding..."]}):p==="valid"?"Add Site":"Verify & Add"})]})]})}),t.jsx(Pwe,{affected:A,onCancel:()=>{T(null),R(null)},onConfirm:()=>{if(!M)return;const le=M,ue=(A||[]).map(fe=>fe.userId);T(null),R(null),Z.mutate({data:le,confirmed:!0,confirmedAffectedUserIds:ue})}})]})}),t.jsx(zd,{open:j,onOpenChange:x,children:t.jsxs(bd,{children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:"Deactivate Device"}),t.jsxs(Sd,{children:["Are you sure you want to deactivate ",t.jsx("strong",{children:n?.name}),"? This will permanently remove the site and any active subscription will be cancelled."]})]}),t.jsxs(jd,{children:[t.jsx(Gc,{"data-testid":"button-cancel-deactivate-site",children:"Cancel"}),t.jsx(Cd,{onClick:()=>ee.mutate(),disabled:ee.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90","data-testid":"button-confirm-deactivate-site",children:ee.isPending?"Deactivating...":"Deactivate"})]})]})})]})}async function Awe(e,s,r,n,a){await a(`/api/sites/${encodeURIComponent(e)}/blueprints/${encodeURIComponent(s)}/placements/${encodeURIComponent(r)}`,"PUT",n)}const Mwe="/assets/CCTV_dome_camera.svg_1790367034660-BQ_CthQf.webp",Rwe=5*1024*1024,Iwe=new Set(["image/jpeg","image/png","image/webp"]),Mv=e=>Math.max(0,Math.min(100,e)),xw=e=>e.displayName||e.name,Owe=e=>e==="online"||e==="offline"?e:"unknown";async function eF(e){const s=await e.json().catch(()=>({}));return s.message||s.error||`Request failed (${e.status}).`}function tF(e){return new Promise((s,r)=>{const n=new FileReader;n.onload=()=>
282{if(typeof n.result!="string"||!n.result.includes(",")){r(new Error("The selected blueprint could not be read."));return}s(n.result.slice(n.result.indexOf(",")+1))},n.onerror=()=>r(new Error("The selected blueprint could not be read.")),n.readAsDataURL(e)})}function Dwe({site:e,open:s,mode:r,canManage:n,onOpenChange:a,onOpenCamera:i,onBlueprintsChanged:o}){const[l,c]=u.useState(null),[d,h]=u.useState(""),[p,g]=u.useState(!1),[v,b]=u.useState(!1),[y,w]=u.useState(""),[j,x]=u.useState(""),[C,k]=u.useState(null),[S,_]=u.useState(!1),[A,T]=u.useState({}),[M,R]=u.useState(null),[D,$]=u.useState(null),[O,q]=u.useState(1),[V,K]=u.useState(!1),G=u.useRef(null),z=u.useRef(null),Z=u.useRef(null),ee=u.useRef(null),[Q,Y]=u.useState(null),oe=u.useMemo(()=>[...l?.blueprints??[]].sort((ye,te)=>ye.sortOrder-te.sortOrder||ye.name.localeCompare(te.name)),[l?.blueprints]),he=S?null:oe.find(ye=>ye.id===d)??oe[0]??null,je=r==="edit"&&n&&!!l?.canManage&&!l.privacyBlocked,pe=l?.cameras??[],le=he?.placements.filter(ye=>pe.some(te=>te.name===ye.cameraName))??[],ue=(he?.placements.length??0)-le.length,fe=new Set(he?.placements.map(ye=>ye.cameraName)??[]),H=u.useMemo(()=>{const ye=new Map;return oe.filter(te=>te.id!==he?.id).forEach(te=>{te.placements.forEach(Ue=>{const We=ye.get(Ue.cameraName)??[];We.push(te.name),ye.set(Ue.cameraName,We)})}),ye},[oe,he?.id]),se=u.useCallback(async(ye=!0,te=!1)=>{Z.current?.abort();const Ue=new AbortController;Z.current=Ue,ye&&g(!0);try{const We=await fetch(`/api/sites/${encodeURIComponent(e.id)}/blueprints${te?"?preview=1":""}`,{credentials:"include",signal:Ue.signal});if(!Ue.signal.aborted&&[401,403,404].includes(We.status)&&c(null),!We.ok)throw new Error(await eF(We));const St=await We.json(),It={...St,cameras:Array.isArray(St.cameras)?St.cameras.filter(ns=>ns&&typeof ns.name=="string").map(ns=>({...ns,displayName:typeof ns.displayName=="string"?ns.displayName:ns.name,status:Owe(ns.status)})):[]};return Ue.signal.aborted||(c(It),h(ns=>It.blueprints.some(dt=>dt.id===ns)?ns:[...It.blueprints].sort((dt,Qt)=>dt.sortOrder-Qt.sortOrder)[0]?.id??"")),It.blueprints}catch(We){return Ue.signal.aborted||w(We instanceof Error?We.message:"Could not load site blueprints."),null}finally{!Ue.signal.aborted&&ye&&g(!1)}},[e.id]);u.useEffect(()=>{if(!s)return;w(""),(async()=>await se(!0,!0)&&!Z.current?.signal.aborted&&await se(!1))();const ye=window.setInterval(()=>se(!1),2e4);return()=>{window.clearInterval(ye),Z.current?.abort(),ee.current?.abort(),c(null)}},[s,se]),u.useEffect(()=>{x(he?.name??""),k(null),R(null),$(null),q(1)},[he?.id]);const me=async(ye,te,Ue)=>{const We=await fetch(ye,{method:te,credentials:"include",...Ue?{headers:{"Content-Type":"application/json"},body:JSON.stringify(Ue)}:{}});if(!We.ok)throw new Error(await eF(We))},ge=(ye,te,Ue)=>new Promise((We,St)=>{const It=new XMLHttpRequest;ee.current=It;try{It.open(te,ye),It.withCredentials=!0,It.setRequestHeader("Content-Type","application/json"),It.upload.onprogress=ns=>{ns.lengthComputable&&ns.total>0&&Y(Math.max(0,Math.min(100,Math.round(ns.loaded/ns.total*100))))},It.onload=()=>{if(It.status>=200&&It.status<300){We();return}let ns="";try{const dt=JSON.parse(It.responseText||"{}");ns=dt.message||dt.error||""}catch{}St(new Error(ns||`Request failed (${It.status}).`))},It.onerror=()=>St(new Error("Network error while uploading the blueprint.")),It.onabort=()=>St(new Error("Blueprint upload was cancelled.")),It.onloadend=()=>{ee.current===It&&(ee.current=null)},It.send(JSON.stringify(Ue))}catch(ns){ee.current===It&&(ee.current=null),St(ns)}}),be=async()=>{if(!C){w("Choose a JPEG, PNG, or WebP blueprint image."),z.current?.focus();return}if(!j.trim()){w("Enter a name for this floor.");return}b(!0),w("");try{const ye=await tF(C);Y(0),await ge(`/api/sites/${encodeURIComponent(e.id)}/blueprints`,"POST",{name:j.trim(),imageBase64:ye,imageMimeType:C.type}),Y(null),o?.(),k(null),z.current&&(z.current.value=""),_(!1);const te=await se();te?.length&&h([...te].sort((Ue,We)=>Ue.sortOrder-We.sortOrder).at(-1).id)}catch(ye){w(ye instanceof Error?ye.message:"Could not upload the blueprint.")}finally{Y(null),b(!1)}},ce=async ye=>{if(he){b(!0),w(""),ye.imageBase64&&Y(0);try{const te=`/api/sites/${encodeURIComponent(e.id)}/blueprints/${encodeURIComponent(he.id)}`;ye.imageBase64?(await ge(te,"PATCH",ye),Y(null)):await me(te,"PATCH",ye),ye.imageBase64&&T(Ue=>({...Ue,[he.id]:(Ue[he.id]??0)+1})),k(null),z.current&&(z.current.value=""),await se()}catch(te){w(te instanceof Error?te.message:"Could not update the blueprint.")}finally{ye.imageBase64&&Y(null),b(!1)}}},Pe=ye=>{if(w(""),!ye){k(null);return}if(!Iwe.has(ye.type)){k(null),w("Choose a JPEG, PNG, or WebP blueprint image.");return}if(ye.size>Rwe){k(null),w("Blueprint images must be 5 MB or smaller.");return}k(ye),!he&&!j.trim()&&x(ye.name.replace(/\.[^.]+$/,"").slice(0,120))},et=async()=>
282{if(he){b(!0),w("");try{await me(`/api/sites/${encodeURIComponent(e.id)}/blueprints/${encodeURIComponent(he.id)}`,"DELETE"),o?.(),K(!1),h(""),await se()}catch(ye){K(!1),w(ye instanceof Error?ye.message:"Could not delete the blueprint.")}finally{b(!1)}}},$e=async ye=>{if(!he||!je)return;const te=oe.findIndex(We=>We.id===he.id),Ue=oe[te+ye];if(Ue){b(!0),w("");try{await me(`/api/sites/${encodeURIComponent(e.id)}/blueprints/${encodeURIComponent(he.id)}`,"PATCH",{sortOrder:Ue.sortOrder}),await me(`/api/sites/${encodeURIComponent(e.id)}/blueprints/${encodeURIComponent(Ue.id)}`,"PATCH",{sortOrder:he.sortOrder}),await se()}catch(We){w(We instanceof Error?We.message:"Could not reorder the blueprint.")}finally{b(!1)}}},bt=async(ye,te)=>{if(!(!he||!je||v)){b(!0),w("");try{await Awe(e.id,he.id,ye,{x:Mv(te.x),y:Mv(te.y)},me),R(null),$(null),await se(!1)}catch(Ue){w(Ue instanceof Error?Ue.message:"Could not save this camera position."),await se(!1)}finally{b(!1)}}},Ae=async ye=>{if(!(!he||!je)){b(!0),w("");try{await me(`/api/sites/${encodeURIComponent(e.id)}/blueprints/${encodeURIComponent(he.id)}/placements/${encodeURIComponent(ye)}`,"DELETE"),await se(!1)}catch(te){w(te instanceof Error?te.message:"Could not remove this camera position.")}finally{b(!1)}}},Be=ye=>{const te=G.current?.getBoundingClientRect();if(!te||te.width===0||te.height===0)return{x:50,y:50};const Ue="touches"in ye?ye.touches[0]:ye;return{x:Mv((Ue.clientX-te.left)/te.width*100),y:Mv((Ue.clientY-te.top)/te.height*100)}},J=ye=>{const te=pe.find(We=>We.name===ye);if(!te||te.status!=="online")return;const Ue=pe.map(We=>({name:We.name,displayName:We.displayName||We.name,enabled:!0}));i(e,{name:te.name,displayName:te.displayName||te.name,enabled:!0},Ue)},ae=ye=>{if(!M||!je)return;const te=D??he?.placements.find(St=>St.cameraName===M)??{x:50,y:50},Ue=ye.shiftKey?10:2,We={ArrowLeft:{x:-Ue,y:0},ArrowRight:{x:Ue,y:0},ArrowUp:{x:0,y:-Ue},ArrowDown:{x:0,y:Ue}};We[ye.key]?(ye.preventDefault(),$({x:Mv(te.x+We[ye.key].x),y:Mv(te.y+We[ye.key].y)})):ye.key==="Enter"||ye.key===" "?(ye.preventDefault(),bt(M,D??te)):ye.key==="Escape"&&(R(null),$(null))},we=ye=>{ye||(Z.current?.abort(),R(null),$(null),w("")),a(ye)},Qe=ye=>t.jsxs(Ke,{variant:ye==="online"?"secondary":"outline",className:"shrink-0 capitalize",children:[t.jsx("span",{className:`mr-1.5 h-1.5 w-1.5 rounded-full ${ye==="online"?"bg-emerald-500":ye==="offline"?"bg-destructive":"bg-muted-foreground"}`}),ye]});return t.jsx(Ys,{open:s,onOpenChange:we,children:t.jsxs(Ws,{className:"max-h-[92vh] w-[calc(100vw-1rem)] max-w-6xl overflow-y-auto p-4 sm:w-full sm:p-6",children:[t.jsxs(Zs,{children:[t.jsxs(Ks,{children:[r==="edit"?"Floor Editor":"View Floors"," · ",e.name]}),t.jsx(cr,{children:"Select a floor to view its plan. Camera positions are approximate and do not change the device configuration."})]}),p&&!l?t.jsxs("div",{className:"flex min-h-56 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(Fe,{className:"h-4 w-4 animate-spin"}),"Loading blueprints…"]}):l?.privacyBlocked?t.jsx("p",{className:"rounded-md border border-destructive/50 bg-destructive/5 p-4 text-sm",role:"alert",children:"Video and blueprint access is restricted by the site owner."}):y&&!l?t.jsxs("div",{className:"space-y-3 rounded-md border border-destructive/50 bg-destructive/5 p-4",children:[t.jsx("p",{className:"text-sm",role:"alert",children:y}),t.jsxs(L,{type:"button",variant:"outline",disabled:p,onClick:()=>se(),children:[p&&t.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}),"Retry"]})]}):t.jsxs("div",{className:"space-y-4",children:[oe.length>0&&he&&t.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[t.jsxs("div",{className:"min-w-40 flex-1 space-y-1.5",children:[t.jsx(re,{htmlFor:"blueprint-floor",children:"Floor plan"}),t.jsx("select",{id:"blueprint-floor",value:he.id,onChange:ye=>h(ye.target.value),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:oe.map(ye=>t.jsx("option",{value:ye.id,children:ye.name},ye.id))})]}),je&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex gap-1",children:[t.jsx(L,{type:"button",variant:"outline",size:"icon",disabled:v||oe[0]?.id===he.id,"aria-label":"Move floor earlier",onClick:()=>$e(-1),children:t.jsx(jK,{className:"h-4 w-4"})}),t.jsx(L,{type:"button",variant:"outline",size:"icon",disabled:v||oe.at(-1)?.id===he.id,"aria-label":"Move floor later",onClick:()=>$e(1),children:t.jsx(wK,{className:"h-4 w-4"})})]}),t.jsxs(L,{type:"button",variant:"outline",disabled:v,onClick:()=>K(!0),children:[t.jsx(sa,{className:"mr-2 h-4 w-4"}),"Delete floor"]}),t.jsxs(L,{type:"button",variant:"outline",disabled:v,onClick:()=>{_(!0),x(""),k(null),w("")},children:[t.jsx(Fo,{className:"mr-2 h-4 w-4"}),"Add floor"]})]})]}),je&&t.jsxs("div",{className:"grid gap-3 rounded-md border p-3 sm:grid-cols-[minmax(10rem,1fr)_minmax(14rem,1fr)_auto] sm:items-start",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"blueprint-floor-name",children:he?"Floor name":"New floor name"}),t.jsx(ke,{id:"blueprint-floor-name",value:j,onChange:ye=>x(ye.target.value),maxLength:120,placeholder:"e.g. First floor"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"blueprint-image",children:he?"Replace plan (optional)":"Blueprint image"}),t.jsx(ke,{ref:z,id:"blueprint-image",type:"file",accept:"image/jpeg,image/png,image/webp",onChange:ye=>Pe(ye.target.files?.[0])}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"JPEG, PNG, or WebP · maximum 5 MB"})]}),t.jsxs("div",{className:"flex flex-wrap gap-2 sm:pt-6",children:[he?t.jsx(t.Fragment,{children:t.jsxs(L,{type:"button",disabled:v||j.trim()===he.name&&!C,onClick:async()=>
282{if(!j.trim()){w("Enter a name for this floor.");return}let ye;try{C&&(ye=await tF(C));const te={};j.trim()&&j.trim()!==he.name&&(te.name=j.trim()),ye&&C&&(te.imageBase64=ye,te.imageMimeType=C.type),Object.keys(te).length&&await ce(te)}catch(te){w(te instanceof Error?te.message:"Could not read the replacement image.")}},children:[v?t.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}):t.jsx(Hd,{className:"mr-2 h-4 w-4"}),"Save floor"]})}):t.jsxs(L,{type:"button",disabled:v||!C,onClick:be,children:[v?t.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}):t.jsx(Om,{className:"mr-2 h-4 w-4"}),"Upload blueprint"]}),S&&oe.length>0&&t.jsx(L,{type:"button",variant:"outline",disabled:v,onClick:()=>{_(!1),k(null),w("")},children:"Cancel add"})]}),Q!==null&&t.jsxs("div",{className:"col-span-full space-y-1","aria-live":"polite",children:[t.jsx("div",{role:"progressbar","aria-label":"Blueprint image upload progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Q,"aria-valuetext":`${Q}%`,className:"h-2 overflow-hidden rounded-full bg-muted",children:t.jsx("div",{className:"h-full rounded-full bg-primary transition-[width] duration-150",style:{width:`${Q}%`}})}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[he?"Uploading replacement blueprint":"Uploading blueprint"," · ",Q,"%"]})]})]}),oe.length===0&&!je&&!y&&t.jsx("p",{className:"rounded-md border p-8 text-center text-sm text-muted-foreground",children:"No blueprint has been uploaded for this site yet."}),he&&t.jsxs("div",{className:je?"grid gap-4 lg:grid-cols-[minmax(0,1fr)_17rem]":"min-w-0",children:[t.jsxs("div",{className:"min-w-0 space-y-2",children:[je&&t.jsx("p",{className:"text-sm text-muted-foreground",children:M?t.jsxs(t.Fragment,{children:["Position ",t.jsx("span",{className:"font-medium text-foreground",children:pe.find(ye=>ye.name===M)?.displayName||M}),": tap or click the plan, or use arrow keys then Enter. ",t.jsx(L,{type:"button",variant:"ghost",className:"h-auto p-0 text-primary",onClick:()=>{R(null),$(null)},children:"Cancel"})]}):"Drag a camera onto the plan, or select one and tap a location. Use Move on a marker to reposition it."}),t.jsx("div",{className:"max-h-[58vh] overflow-auto rounded-md border bg-muted/20 p-2",children:t.jsxs("div",{ref:G,className:"relative w-full outline-none focus-visible:ring-2 focus-visible:ring-ring",style:{width:`${O*100}%`},tabIndex:je&&M?0:-1,role:"application","aria-label":M?`Positioning ${M}. Use arrow keys to move, Enter to save, Escape to cancel.`:`${he.name} blueprint`,onKeyDown:ae,onDragOver:ye=>{je&&(ye.preventDefault(),ye.dataTransfer.dropEffect="move")},onDrop:ye=>{if(!je)return;ye.preventDefault();const te=ye.dataTransfer.getData("text/plain").replace(/^blueprint-camera:/,"");te&&bt(te,Be(ye))},onClick:ye=>{!M||!je||ye.target.closest("[data-blueprint-marker]")||bt(M,Be(ye))},children:[t.jsx("img",{src:O>1.5?`${he.imageUrl}?original=1`:he.imageUrl,alt:`${he.name} blueprint`,className:"block h-auto w-full select-none",draggable:!1,onError:()=>w("The blueprint image could not be loaded.")},`${he.id}:${he.imageUrl}:${A[he.id]??0}`),le.map(ye=>{const te=pe.find(We=>We.name===ye.cameraName);if(!te)return null;const Ue=M===ye.cameraName&&D?D:ye;return t.jsxs("div",{"data-blueprint-marker":!0,className:"absolute z-10",style:{left:`${Ue.x}%`,top:`${Ue.y}%`,transform:`translate(-50%, -50%) scale(${O})`},children:[t.jsxs(L,{type:"button",variant:te?.status==="online"?"default":"secondary",size:"sm",draggable:je,"aria-label":`${te?xw(te):ye.cameraName}, ${te?.status??"unknown"}${je?". Drag to move or use Move.":""}`,title:`${te?xw(te):ye.cameraName} · ${te?.status??"unknown"}`,className:"h-auto max-w-44 flex-col gap-0.5 rounded-xl p-1.5 shadow-lg",disabled:!te||te.status!=="online",onDragStart:We=>We.dataTransfer.setData("text/plain",`blueprint-camera:${ye.cameraName}`),onClick:We=>{We.stopPropagation(),J(ye.cameraName)},children:[t.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-full bg-white/95",children:t.jsx("img",{src:Mwe,alt:"",className:"h-10 w-10 object-contain",draggable:!1})}),t.jsx("span",{className:"max-w-40 truncate text-xs",children:xw(te)}),te.status!=="online"&&t.jsx("span",{className:`shrink-0 rounded px-1 text-[10px] font-semibold uppercase ${te.status==="offline"?"bg-destructive/15 text-destructive":"bg-muted text-muted-foreground"}`,children:te.status==="offline"?"Offline":"Status unknown"})]}),je&&t.jsxs("div",{className:"absolute left-full top-0 ml-1 flex gap-1",children:[t.jsx(L,{type:"button",variant:"secondary",size:"icon",className:"h-7 w-7 shadow","aria-label":`Move ${te?.displayName||ye.cameraName}`,onClick:We=>{We.stopPropagation(),R(ye.cameraName),$(null),requestAnimationFrame(()=>G.current?.focus())},children:t.jsx(_y,{className:"h-3.5 w-3.5"})}),t.jsx(L,{type:"button",variant:"destructive",size:"icon",className:"h-7 w-7 shadow","aria-label":`Remove ${te?.displayName||ye.cameraName}`,disabled:v,onClick:We=>{We.stopPropagation(),Ae(ye.cameraName)},children:t.jsx(va,{className:"h-3.5 w-3.5"})})]})]},ye.cameraName)}),M&&D&&!he.placements.some(ye=>ye.cameraName===M)&&t.jsx("div",{className:"pointer-events-none absolute z-20",style:{left:`${D.x}%`,top:`${D.y}%`,transform:`translate(-50%, -50%) scale(${O})`},children:t.jsx(Ke,{children:pe.find(ye=>
282ye.name===M)?.displayName||M})})]})}),ue>0&&t.jsxs("p",{className:"text-xs text-muted-foreground",role:"status",children:[ue===1?"One camera placement is hidden":`${ue} camera placements are hidden`," because the camera is no longer enabled or available to this account."]}),je&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Zoom: ",Math.round(O*100),"%"]}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(L,{type:"button",variant:"outline",size:"icon","aria-label":"Zoom out",disabled:O<=.5,onClick:()=>q(ye=>Math.max(.5,Math.round((ye-.25)*100)/100)),children:t.jsx(BK,{className:"h-4 w-4"})}),t.jsx(L,{type:"button",variant:"outline",size:"icon","aria-label":"Zoom in",disabled:O>=2.5,onClick:()=>q(ye=>Math.min(2.5,Math.round((ye+.25)*100)/100)),children:t.jsx(Fo,{className:"h-4 w-4"})})]})]})]}),je&&t.jsxs("aside",{className:"min-w-0 space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Enabled cameras"}),t.jsx(L,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Refresh camera status",disabled:p,onClick:()=>se(),children:t.jsx(tl,{className:`h-4 w-4 ${p?"animate-spin":""}`})})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:je?"Drag a camera to place it, or select one and tap the plan.":"Select an online camera marker to open live view."}),t.jsxs("div",{className:"max-h-[42vh] space-y-1 overflow-y-auto",children:[pe.map(ye=>{const te=fe.has(ye.name),Ue=H.get(ye.name)??[],We=!je||te||v;return t.jsxs("button",{type:"button",draggable:je&&!te&&!v,onDragStart:St=>St.dataTransfer.setData("text/plain",`blueprint-camera:${ye.name}`),onClick:()=>{We||(R(ye.name),$(null),requestAnimationFrame(()=>G.current?.focus()))},disabled:We,"aria-label":`${xw(ye)} · ${ye.status}${te?" · placed on this floor":Ue.length?` · move from ${Ue.join(", ")}`:""}`,className:`flex w-full items-center justify-between gap-2 rounded-md border px-2.5 py-2 text-left text-sm ${We?"cursor-default opacity-70":"cursor-grab hover:bg-accent active:cursor-grabbing"}`,children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate font-medium",children:xw(ye)}),te?t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Placed on this floor"}):Ue.length>0?t.jsxs("span",{className:"block text-xs text-muted-foreground",children:["Move from ",Ue.join(", ")]}):null]}),Qe(ye.status)]},ye.name)}),pe.length===0&&t.jsx("p",{className:"rounded-md border p-3 text-sm text-muted-foreground",children:"No enabled cameras are available. Camera placements will appear here when the device configuration has enabled cameras."})]})]})]}),je&&oe.length===0&&t.jsx("p",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground",children:"Upload a plan for each floor. Camera placements become available after a blueprint is saved."}),y&&t.jsxs("p",{className:"flex items-center gap-2 text-sm text-destructive",role:"alert",children:[t.jsx(ta,{className:"h-4 w-4 shrink-0"}),y]})]}),t.jsx(In,{children:t.jsx(L,{type:"button",variant:"outline",onClick:()=>we(!1),children:"Close"})}),t.jsx(zd,{open:V,onOpenChange:K,children:t.jsxs(bd,{children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:"Delete this floor plan?"}),t.jsxs(Sd,{children:["This deletes “",he?.name,"”, its blueprint image, and camera placements on this floor. Other floors are unchanged."]})]}),t.jsxs(jd,{children:[t.jsx(Gc,{disabled:v,children:"Cancel"}),t.jsxs(Cd,{disabled:v,onClick:ye=>{ye.preventDefault(),et()},children:[v?t.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}):t.jsx(sa,{className:"mr-2 h-4 w-4"}),"Delete floor"]})]})]})})]})})}let Rv=null,Hw=null,gM=!1;const iC="Google rejected the Maps browser key. In Google Cloud, enable Maps JavaScript API and billing, and check that the key saved under API Settings → Google Maps Browser Key allows this website. Refresh Map View after changing the key.",p1="h-[32dvh] min-h-[220px] max-h-[280px] sm:h-[55vh] sm:min-h-80 sm:max-h-none",cx="w-full min-w-0 px-2 text-xs sm:w-auto 
282sm:px-4 sm:text-sm";function Lwe(e){return gM?Promise.reject(new Error(iC)):window.google?.maps?Promise.resolve(window.google.maps):Rv||(Rv=new Promise((s,r)=>{window.gm_authFailure=()=>{gM=!0,Rv=null,Hw?.(),r(new Error(iC))};const n=document.querySelector('script[data-dashboard-google-maps="true"]'),a=()=>window.google?.maps?s(window.google.maps):r(new Error("Google Maps did not initialize."));if(n){n.addEventListener("load",a,{once:!0}),n.addEventListener("error",()=>r(new Error("Google Maps failed to load.")),{once:!0});return}const i=document.createElement("script");i.dataset.dashboardGoogleMaps="true",i.async=!0,i.src=`https://maps.googleapis.com/maps/api/js?key=${encodeURIComponent(e)}&libraries=geometry`,i.onload=a,i.onerror=()=>r(new Error("Google Maps failed to load. Check network access and API key restrictions.")),document.head.appendChild(i)}).catch(s=>{throw Rv=null,s}),Rv)}function dx(e){if(e.locationHidden)return null;const s=e.latitude??e.edgeDevice?.approximateLatitude??e.edgeDevice?.latitude,r=e.longitude??e.edgeDevice?.approximateLongitude??e.edgeDevice?.longitude;return typeof s=="number"&&typeof r=="number"&&Number.isFinite(s)&&Number.isFinite(r)?{lat:s,lng:r,approximate:e.latitude==null||e.longitude==null}:null}function $we({sites:e,isLoading:s,canEditSite:r,canEditFloors:n,canOpenDeviceSettings:a,restartingSites:i,onEditSite:o,onOpenCamera:l}){const[,c]=Ia(),h=Er().appEmblemUrl||"/truvios-emblem.png",p=u.useRef(null),g=u.useRef(null),v=u.useRef(null),b=u.useRef([]),y=u.useRef([]),[w,j]=u.useState({loading:!0,available:!1,key:null,error:null}),[x,C]=u.useState(null),k=e.find(ce=>ce.id===x)??null,S=!!k?.isOnline&&!i.has(k.id),_=ze({queryKey:["/api/sites",k?.id,"my-permissions"],enabled:!!k,refetchInterval:3e4}),A=ze({queryKey:["/api/sites",k?.id,"cameras?summary=1"],enabled:S&&_.isSuccess&&_.data?.privacyBlocked===!1,retry:1}),T=(A.data?.cameras??[]).filter(ce=>ce.enabled&&!_.data?.restrictedCameras?.includes(ce.name)),[M,R]=u.useState(!1),[D,$]=u.useState(""),[O,q]=u.useState(!1),[V,K]=u.useState(null),[G,z]=u.useState("view"),Z=e.find(ce=>ce.id===V&&!ce.locationHidden)??null,[ee,Q]=u.useState(null),Y=!!ee&&ee.siteId===k?.id&&ee.hasFloors,oe=!!ee&&ee.siteId===k?.id&&ee.canManage,[he,je]=u.useState(""),[pe,le]=u.useState(0),[ue,fe]=u.useState(null),H=u.useMemo(()=>e.map(ce=>({site:ce,point:dx(ce)})).filter(ce=>!!ce.point),[e]),se=u.useMemo(()=>e.filter(ce=>!ce.locationHidden&&!dx(ce)),[e]),me=u.useMemo(()=>e.filter(ce=>ce.locationHidden),[e]),ge=(ce,Pe)=>{C(ce),R(!1),Pe&&g.current&&(g.current.panTo({lat:Pe.lat,lng:Pe.lng}),g.current.setZoom(Math.max(g.current.getZoom()??0,15)))};u.useEffect(()=>{let ce=!0;if(Q(null),je(""),!(!k||k.locationHidden))return fetch(`/api/sites/${encodeURIComponent(k.id)}/blueprints`,{credentials:"include"}).then(async Pe=>{if(!Pe.ok){const et=await Pe.json().catch(()=>({}));throw new Error(et.message||`Blueprint request failed (${Pe.status}).`)}return Pe.json()}).then(Pe=>{ce&&Q({siteId:k.id,hasFloors:!Pe.privacyBlocked&&Array.isArray(Pe.blueprints)&&Pe.blueprints.length>0,canManage:!Pe.privacyBlocked&&Pe.canManage===!0})}).catch(Pe=>{ce&&(Q(null),je(Pe.message||"Could not check site blueprints."))}),()=>{ce=!1}},[k?.id,k?.locationHidden,pe]),u.useEffect(()=>{let ce=!0;return fetch("/api/map/config",{credentials:"include"}).then(async Pe=>{if(!Pe.ok)throw new Error(`Map configuration request failed (${Pe.status}).`);return Pe.json()}).then(Pe=>{ce&&j({loading:!1,available:!!Pe.available,key:Pe.key??null,error:null})}).catch(Pe=>{ce&&j({loading:!1,available:!1,key:null,error:Pe.message||"Unable to load map configuration."})}),()=>{ce=!1}},[]),u.useEffect(()=>{if(!w.key||!w.available||!p.current)return;let ce=!0;const Pe=()=>{ce&&(q(!1),fe(iC))};return Hw=Pe,Lwe(w.key).then(et=>{if(!ce||!p.current)return;if(gM)throw new Error(iC);q(!0),g.current||(g.current=new et.Map(p.current,{center:H[0]?.point??{lat:39.5,lng:-98.35},zoom:H.length===1?12:4,mapTypeControl:!1,streetViewControl:!1,fullscreenControl:!0,gestureHandling:window.matchMedia("(max-width: 639px)").matches?"cooperative":"greedy"})),b.current.forEach(ae=>ae.setMap(null)),y.current.forEach(ae=>ae.setMap(null)),y.current=[];const $e=getComputedStyle(document.documentElement).getPropertyValue("--primary").trim(),bt=/^\d+(?:\.\d+)?\s+\d+(?:\.\d+)?%\s+\d+(?:\.\d+)?%$/.test($e)?`hsl(${$e})`:"#3b5bdb",Ae=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="52" viewBox="0 0 40 52">
283        <path d="M20 1C9.5 1 1 9.5 1 20c0 14 19 30 19 30s19-16 19-30C39 9.5 30.5 1 20 1Z" fill="${bt}" stroke="white" stroke-width="2"/>
284        <rect x="12" y="12" width="16" height="17" rx="2" fill="white"/>
285        <path d="M18 29v-5h4v5M15 16h2v2h-2zm8 0h2v2h-2zm-8 5h2v2h-2zm8 0h2v2h-2z" fill="${bt}"/>
286      </svg>`,Be={url:`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(Ae)}`,scaledSize:new et.Size(40,52),anchor:new et.Point(20,50)};b.current=H.map(({site:ae,point:we})=>{const Qe=new et.Marker({map:g.current,position:{lat:we.lat,lng:we.lng},title:`${ae.name}${we.approximate?" — approximate location":""}`,icon:Be,opacity:we.approximate?.75:1});Qe.addListener("click",()=>ge(ae.id,we));const ye=new et.OverlayView,te=document.createElement("button");
286te.type="button",te.title=ae.name,te.setAttribute("aria-label",`Select ${ae.name} on map`),te.style.cssText="position:absolute;box-sizing:border-box;width:20px;height:20px;padding:1px;border:0;border-radius:3px;background:white;cursor:pointer;",te.style.opacity=we.approximate?"0.75":"1";const Ue=document.createElement("img");return Ue.src=h,Ue.alt="",Ue.style.cssText="display:block;width:100%;height:100%;object-fit:contain;",Ue.onerror=()=>te.remove(),te.appendChild(Ue),te.addEventListener("click",We=>{We.stopPropagation(),ge(ae.id,we)}),ye.onAdd=()=>ye.getPanes()?.overlayMouseTarget.appendChild(te),ye.draw=()=>{const We=ye.getProjection()?.fromLatLngToDivPixel(new et.LatLng(we.lat,we.lng));We&&(te.style.left=`${We.x-10}px`,te.style.top=`${We.y-40}px`)},ye.onRemove=()=>te.remove(),ye.setMap(g.current),y.current.push(ye),Qe});const J=JSON.stringify(H.map(({site:ae,point:we})=>[ae.id,we.lat,we.lng]).sort(([ae],[we])=>String(ae).localeCompare(String(we))));if(v.current!==J){v.current=J;const ae=H.find(({site:we})=>we.id===x)?.point;if(ae)g.current.panTo({lat:ae.lat,lng:ae.lng}),g.current.setZoom(Math.max(g.current.getZoom()??0,15));else if(H.length>1){const we=new et.LatLngBounds;H.forEach(({point:Qe})=>we.extend({lat:Qe.lat,lng:Qe.lng})),g.current.fitBounds(we)}else H.length===1?(g.current.setCenter({lat:H[0].point.lat,lng:H[0].point.lng}),g.current.setZoom(12)):(g.current.getStreetView().setVisible(!1),g.current.setCenter({lat:39.5,lng:-98.35}),g.current.setZoom(2))}ce&&Hw===Pe&&fe(null)}).catch(et=>{ce&&fe(et.message||"Google Maps could not be loaded.")}),()=>{ce=!1,Hw===Pe&&(Hw=null),b.current.forEach(et=>et.setMap(null)),b.current=[],y.current.forEach(et=>et.setMap(null)),y.current=[]}},[w,H,h]),u.useEffect(()=>{const ce=window.matchMedia("(max-width: 639px)"),Pe=()=>g.current?.setOptions({gestureHandling:ce.matches?"cooperative":"greedy"});return ce.addEventListener("change",Pe),()=>ce.removeEventListener("change",Pe)},[]),u.useEffect(()=>{if(!k||!M||!window.google?.maps||!g.current)return;const ce=dx(k);if(!ce)return;let Pe=!0;return new window.google.maps.StreetViewService().getPanorama({location:{lat:ce.lat,lng:ce.lng},radius:75},($e,bt)=>{if(Pe)if(bt===window.google.maps.StreetViewStatus.OK&&$e?.location?.latLng){const Ae=g.current.getStreetView();Ae.setPosition($e.location.latLng),Ae.setVisible(!0),$("")}else R(!1),$("Street View imagery is not available near this location.")}),()=>{Pe=!1,g.current?.getStreetView().setVisible(!1)}},[k,M]);const be=w.error||ue;return t.jsxs("div",{className:"space-y-4","data-testid":"dashboard-map-view",children:[t.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_19rem]",children:[t.jsx(ut,{className:"overflow-hidden",children:w.loading?t.jsx("div",{className:`flex ${p1} items-center justify-center text-sm text-muted-foreground`,children:"Loading map configuration…"}):be?t.jsxs("div",{className:`flex ${p1} flex-col items-center justify-center gap-3 p-6 text-center`,role:"alert",children:[t.jsx(ta,{className:"h-8 w-8 text-destructive"}),t.jsx("p",{className:"font-medium",children:"Map unavailable"}),t.jsx("p",{className:"max-w-lg text-sm text-muted-foreground",children:be})]}):!w.available||!w.key?t.jsxs("div",{className:`flex ${p1} flex-col items-center justify-center gap-3 p-6 text-center`,children:[t.jsx(ql,{className:"h-8 w-8 text-muted-foreground"}),t.jsx("p",{className:"font-medium",children:"Google Maps is not configured"}),t.jsx("p",{className:"max-w-lg text-sm text-muted-foreground",children:"Map view requires an available Google Maps JavaScript API key. Sites without map coordinates remain listed beside the map."})]}):t.jsx("div",{ref:p,className:`${p1} w-full`,"aria-label":"Site locations map"})}),t.jsxs(ut,{className:"order-first p-4 sm:order-none lg:max-h-[55vh] lg:min-h-80 lg:overflow-y-auto",children:[t.jsxs("div",{className:"sm:hidden",children:[t.jsxs("label",{htmlFor:"map-site-picker",className:"mb-2 block text-sm font-semibold",children:["Sites ",t.jsxs("span",{className:"font-normal text-muted-foreground",children:["· ",e.length," matching"]})]}),t.jsxs("select",{id:"map-site-picker",className:"h-10 w-full rounded-md border border-input bg-background px-3 text-sm",value:k?.id??"",disabled:s||e.length===0,onChange:ce=>{const Pe=e.find(et=>et.id===ce.target.value);Pe&&ge(Pe.id,dx(Pe))},children:[t.jsx("option",{value:"",disabled:!0,children:s?"Loading sites…":e.length?"Select a site":"No sites match your search"}),e.map(ce=>t.jsx("option",{value:ce.id,children:ce.name},ce.id))]})]}),t.jsxs("div",{className:"hidden sm:block",children:[t.jsx("div",{className:"mb-3 flex items-center justify-between",children:t.jsxs("div",{children:[t.jsx("h2",{className:"font-semibold",children:"Sites"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.length," matching"]})]})}),s?t.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Loading sites…"}):e.length===0?t.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No sites match your search."}):t.jsx("div",{className:"space-y-2",children:e.map(ce=>{const Pe=dx(ce);return t.jsxs("button",{className:`w-full rounded-md border p-3 text-left transition-colors hover:bg-muted ${k?.id===ce.id?"border-primary bg-muted":""}`,onClick:()=>{ge(ce.id,Pe)},children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("span",{className:"font-medium",children:ce.name}),ce.locationHidden?t.jsx(Ke,{variant:"outline",children:"Location hidden"}):Pe?t.jsx(Ke,{variant:"secondary",children:Pe.approximate?"Approximate":"Mapped"}):t.jsx(Ke,{variant:"outline",children:"Not placed"})]}),ce.address&&t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:ce.address})]},ce.id)})}),se.length>0&&t.jsxs("p",{className:"mt-4 border-t pt-3 text-xs text-muted-foreground",children:[se.length," site",se.length===1?"":"s"," without an available location are shown above."]}),me.length>0&&t.jsxs("p",{className:"mt-4 border-t pt-3 text-xs text-muted-foreground",children:[me.length," site",me.length===1?"":"s"," have locations hidden by policy."]})]})]})]}),k&&t.jsxs(ut,{className:"p-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:flex-wrap",children:[t.jsxs(L,{className:cx,variant:"outline",disabled:!S||!_.isSuccess||_.data?.privacyBlocked!==!1||!A.isSuccess||T.length===0,onClick:()=>l(k,T[0],T),"data-testid":"map-live-view",children:[t.jsx(vu,{className:"mr-2 h-4 w-4"}),"Live View"]}),t.jsxs(L,{className:cx,variant:"outline",onClick:()=>c(`/recordings?siteId=${encodeURIComponent(k.id)}&view=events`),"data-testid":"map-events",children:[t.jsx(cn,{className:"mr-2 h-4 w-4"}),"Events"]}),a&&t.jsxs(L,{className:cx,variant:"outline",disabled:!S,onClick:()=>
286c(`/device-settings/${encodeURIComponent(k.id)}`),"data-testid":"map-device-settings",children:[t.jsx(xd,{className:"mr-2 h-4 w-4"}),"Device Settings"]}),r(k)&&t.jsxs(L,{className:cx,variant:"outline",onClick:()=>o(k),children:[t.jsx(ga,{className:"mr-2 h-4 w-4"}),"Edit address"]}),dx(k)&&t.jsx(L,{className:cx,variant:"outline",disabled:!O,onClick:()=>{$(""),R(ce=>!ce)},children:M?"Hide Street View":"Street View"}),!k.locationHidden&&n&&oe&&t.jsxs(L,{className:cx,onClick:()=>{z("edit"),K(k.id)},children:[t.jsx(ga,{className:"mr-2 h-4 w-4"}),"Floor Editor"]}),!k.locationHidden&&Y&&t.jsxs(L,{className:cx,variant:"outline",onClick:()=>{z("view"),K(k.id)},children:[t.jsx(eO,{className:"mr-2 h-4 w-4"}),"View Floors"]})]}),k.locationHidden&&t.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"Location hidden by site policy."}),dx(k)?.approximate&&t.jsx("p",{className:"mt-3 text-sm font-medium text-amber-700 dark:text-amber-400",children:"Approximate Edge device location — not the exact site address."}),S&&_.isError&&t.jsx("p",{className:"mt-3 text-sm text-destructive",role:"alert",children:"Could not confirm video access. Please try again later."}),S&&_.data?.privacyBlocked&&t.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"Live View is hidden by site policy."}),S&&_.isSuccess&&_.data?.privacyBlocked===!1&&A.isError&&t.jsx("p",{className:"mt-3 text-sm text-destructive",role:"alert",children:"Could not load cameras. Please try again later."}),D&&t.jsx("p",{className:"mt-3 text-sm text-muted-foreground",role:"status",children:D}),he&&t.jsx("p",{className:"mt-3 text-sm text-destructive",role:"alert",children:he})]}),Z&&t.jsx(Dwe,{site:Z,open:!0,mode:G,canManage:n&&oe,onBlueprintsChanged:()=>le(ce=>ce+1),onOpenChange:ce=>{ce||(K(null),le(Pe=>Pe+1))},onOpenCamera:l})]})}const Fwe=8443;function Bwe(e){const s=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(e.trim());if(!s)return null;for(let r=1;r<=4;r++)if(Number(s[r])>255)return null;return`${s[1]}-${s[2]}-${s[3]}-${s[4]}.local.truvios.io`}function Uwe(e){const s=Bwe(e);return s?`https://${s}:${Fwe}`:null}function bJ(e){return ze({queryKey:["/api/sites",e,"local-access"],enabled:!!e&&e!=="none",staleTime:300*1e3})}const zwe=1500,Hwe=3e4,bP=new Map;function qwe(e,s=zwe){const r=bP.get(e);if(r)return r;const n=(async()=>{try{const a=new AbortController,i=setTimeout(()=>a.abort(),s);try{return(await fetch(`${e}/healthz`,{method:"GET",mode:"cors",credentials:"omit",cache:"no-store",signal:a.signal})).ok}finally{clearTimeout(i)}}catch{return!1}})();return bP.set(e,n),n.then(()=>{setTimeout(()=>bP.delete(e),Hwe)}),n}async function uS(e){if(!e||!e.enabled||!e.localIp)return null;const s=Uwe(e.localIp);return s&&await qwe(s)?s:null}function sF(e){return e.replace(/^http/,"ws")}function wJ(e){const{data:s}=bJ(e),[r,n]=u.useState(null),a=!!s?.enabled,i=s?.localIp??null;return u.useEffect(()=>{let o=!1;return n(null),uS(a&&i?{enabled:a,localIp:i}:null).then(l=>{o||n(l)}),()=>{o=!0}},[a,i,e]),r}let hg={category:null},Qv=0,pg=!1,Xp=null,py=0;const vw=new Map;function oC(e){const s={category:e.category};for(const r of["siteId","camera","eventId","source","searchTerm"]){const n=e[r];typeof n=="string"&&n.length&&(s[r]=n.slice(0,r==="searchTerm"?500:200))}return typeof e.playbackTime=="number"&&Number.isFinite(e.playbackTime)&&(s.playbackTime=Math.max(0,Math.min(e.playbackTime,1e12))),e.searchSiteIds&&(s.searchSiteIds=[...new Set(e.searchSiteIds.filter(r=>typeof r=="string"&&r.length).map(r=>r.slice(0,200)))].slice(0,100)),s}async function Dy(){if(!(!pg||document.visibilityState==="hidden"))try{await fetch("/api/audit/live/heartbeat",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(oC(hg)),keepalive:!0})}catch{}}function m3(e){!pg||e!==py||document.visibilityState==="hidden"||(Xp=setTimeout(()=>{!pg||e!==py||(Xp=null,Dy().finally(()=>m3(e)))},15e3+Math.floor(Math.random()*10001)))}function rF(){document.visibilityState==="visible"?(Dy(),!Xp&&pg&&m3(py)):Xp&&(clearTimeout(Xp),Xp=null)}function Vwe(){if(pg)return()=>{};pg=!0;const e=++py;return document.addEventListener("visibilitychange",rF),Dy(),m3(e),()=>{!pg||e!==py||(pg=!1,py++,Xp&&clearTimeout(Xp),Xp=null,document.removeEventListener("visibilitychange",rF))}}function lC(e){const s=++Qv;return hg=oC(e),Dy(),{update:n=>{Qv===s&&(hg=oC(n))},clear:()=>{Qv===s&&(Qv++,hg={category:null},Dy())}}}function Wwe(e,s){const r=`${e}\0${s}\0${++Qv}`;vw.set(r,{siteId:e,camera:s});const n=i=>{if(vw.size===0)hg={category:null},Qv++;else{const o=[...vw.entries()],l=o[o.length-1][1];hg=oC({category:"live_view",...l})}i&&Dy()},a=hg.category==="live_view";return n(!a),()=>{vw.delete(r)&&hg.category==="live_view"&&n(vw.size===0)}}const Iv=new Map;function nF(e,s="unknown"){const r=`${s}:${e}`,n=Iv.get(r);if(n)return n;const a=(async()=>{const i=await fetch(`/api/sites/${e}/ws-token`);if(!i.ok)throw new Error(`WebSocket token request failed (${i.status})`);const o=await i.json();if(typeof o.token!="string"||!o.token)throw new Error("WebSocket token response was invali
286d");return o.token})();return Iv.set(r,a),a.then(()=>{Iv.get(r)===a&&Iv.delete(r)},()=>{Iv.get(r)===a&&Iv.delete(r)}),a}const aF=new Map;function Kwe(e,s,r){const n=`${e}:${s}:${r}`;let a=2166136261;for(let i=0;i<n.length;i++)a^=n.charCodeAt(i),a=Math.imul(a,16777619);return(a>>>0)%500}function Gwe(e,s,r){const n=Date.now(),a=aF.get(e),i=a&&n-a.at<750?a.slot+1:0;return aF.set(e,{at:n,slot:i}),Math.min(5e3,Math.min(1e3*r,5e3)+i*125+Kwe(e,s,r))}const Ywe=9e4,Qwe=15e3,Xwe=1e4,Zwe=3e3,Jwe=45e3;function Ly({siteId:e,cameraName:s,className:r="",refreshKey:n=0,objectFit:a="cover",autoAspect:i=!1,onAspectDetected:o,streamSource:l="sub",singleView:c=!1}){const d=Er(),[h,p]=u.useState(!1),[g,v]=u.useState(!1),{user:b}=Gi();u.useEffect(()=>{if(b)return Wwe(e,s)},[b?.id,e,s]),u.useEffect(()=>{v(!1);let gt,es=!1;const br=()=>{if(es)return;const xn=j.current;if(!document.hidden&&pe.current&&xn&&xn.readyState>=2){const Br=Uw(xn);Br!==null&&v(Br)}gt=setTimeout(br,c?3e3:3e4)};let fr=0;for(const xn of`${e}:${s}`)fr=Math.imul(fr,31)+xn.charCodeAt(0)|0;return gt=setTimeout(br,c?500+(fr>>>0)%3e3:2e3+(fr>>>0)%15e3),()=>{es=!0,clearTimeout(gt)}},[e,s,c]);const y=String(b?.id??"anonymous"),w=u.useRef(null),j=u.useRef(null),x=u.useRef(null),C=u.useRef(null),k=u.useRef(null),[S,_]=u.useState("init"),[A,T]=u.useState(null),[M,R]=u.useState(!1),D=`cam-aspect-${e}-${s}`,[$,O]=u.useState(()=>{if(!i)return 16/9;const gt=parseFloat(localStorage.getItem(D)??"");return isFinite(gt)&&gt>0?gt:16/9}),q=(gt,es)=>{if(!gt||!es)return;const br=gt/es;i&&O(br),o?.(br);try{localStorage.setItem(D,String(br))}catch{}},V=u.useRef(null),K=u.useRef(null),G=u.useRef(null),z=u.useRef([]),Z=u.useRef(null),ee=u.useRef(null),Q=u.useRef(null),Y=u.useRef(null),oe=u.useRef(!0),he=u.useRef(0),je=u.useRef(!1),pe=u.useRef(!1),le=u.useRef(0),ue=u.useRef(0),fe=u.useRef(null),H=u.useRef(null),se=u.useRef(null),me=u.useRef(0),ge=u.useRef(0),be=u.useRef(0),ce=u.useRef(null),Pe=u.useRef(null),et=u.useRef(0),$e=u.useRef(!1),bt=u.useRef(null),{data:Ae}=bJ(e),Be=u.useRef(Ae);Be.current=Ae;const J=u.useRef(null),ae=u.useRef(!1),we=u.useRef(!1);u.useEffect(()=>{let gt=!1;return ae.current=!1,we.current=!1,J.current=null,uS(Ae).then(es=>{gt||(J.current=es)}),()=>{gt=!0}},[Ae,e]);const{data:Qe}=ze({queryKey:["/api/sites",e,"stream-options"],staleTime:300*1e3}),ye=Qe?.forceSubStreamLive??!1,te=Qe?.protocol??"mse",Ue=Math.max(1,Math.min(2,Qe?.jpegFps??1)),We=Math.max(40,Math.min(100,Qe?.jpegQuality??100)),St=Math.round(1e3/Ue),It=ye?"sub":l==="main"?"main":l==="sub"?"sub":c?"main":"sub",ns=l==="jpeg"?"jpeg":te,dt=It==="sub"?`${s}_sub`:s,Qt=u.useRef(It==="main");Qt.current=It==="main";const Re=u.useRef(St),pt=u.useRef(We),Ft=u.useRef(Ywe),Es=u.useRef(Qwe),Ge=u.useRef(Xwe),ft=u.useRef(Zwe),He=u.useRef(Jwe);Re.current=St,pt.current=We;const zt=u.useCallback(gt=>{const es=w.current;es&&(es.style.opacity=String(gt))},[]),fs=u.useCallback(gt=>{const es=C.current;es&&(gt?(es.textContent=gt,es.style.display="flex"):es.style.display="none")},[]),Ce=u.useCallback(()=>{const gt=x.current;gt&&(gt.style.display="none")},[]),Dt=u.useCallback(()=>{const gt=x.current;gt&&(gt.style.display="flex")},[]),ne=u.useCallback(()=>{if(pe.current||!w.current||$e.current)return;$e.current=!0,et.current++;const es=et.current,br=Qt.current?"&stream=record":"",fr=`/api/sites/${e}/cameras/${encodeURIComponent(s)}/thumbnail?t=${es}${br}&quality=${pt.current}&clientChecks=1`,xn=we.current?null:J.current,Br=fr,Pi=xn?`${xn}${fr}`:Br;let Qn=!1;const ii=setTimeout(()=>{Ln()},15e3),ua=()=>Qn?!1:(Qn=!0,clearTimeout(ii),es===et.current&&($e.current=!1),!0),Ua=Hr=>{ua()&&w.current&&(es<et.current||(w.current.src=Hr,p(!1),v(!1),fs("")))},Ln=()=>{ua()&&es===et.current&&!pe.current&&(p(!0),Ce())},Ir=new Image;Ir.onload=()=>{const Hr=Uw(Ir);if(Hr===!0||Hr===null&&xn)if(xn){we.current=!0;const lt=new Image;lt.onload=()=>{Uw(lt)===!0?Ln():Ua(lt.src)},lt.onerror=Ln,lt.src=Br}else Ln();else Ua(Ir.src)},xn?Ir.onerror=()=>{we.current=!0;const Hr=new Image;Hr.onload=()=>{Uw(Hr)===!0?Ln():Ua(Hr.src)},Hr.onerror=Ln,Hr.src=Br}:Ir.onerror=Ln,Ir.src=Pi},[e,s,fs,Ce]),Oe=u.useRef(!1),De=u.useCallback(()=>{Pe.current||(Oe.current=!0,ne(),Pe.current=setInterval(ne,Re.current))},[ne]),jt=u.useCallback(()=>{Pe.current&&(clearInterval(Pe.current),Pe.current=null),et.current++,$e.current=!1},[]),Ct=u.useCallback(()=>{ce.current&&(clearInterval(ce.current),ce.current=null)},[]),Lt=u.useCallback(()=>{Ct(),me.current=Date.now(),ce.current=setInterval(()=>{if(!je.current||!oe.current)return;const gt=Date.now(),es=gt-me.current;if(es>Ft.current){console.log(`[MSE] Hard stall ${Math.round(es/1e3)}s — closing WS`),V.current?.close();return}if(!pe.current&&ge.current>0){const br=gt-ge.current;br>6e4&&(console.log(`[MSE] No video after ${Math.round(br/1e3)}s — reconnecting`),V.current?.close())}},2e3)},[Ct]),xr=u.useCallback(()=>{Ct(),H.current&&(clearTimeout(H.current),H.current=null),se.current&&(clearTimeout(se.current),se.current=null),je.current=!1,ge.current=0,be.current=0,pe.current=!1;try{V.current?.close()}catch{}if(V.current=null,K.current?.readyState==="open")try{K.current.endOfStream()}catch{}K.current=null,G.current=null,z.current=[],Z.current&&(URL.revokeObjectURL(Z.current),Z.current=null);const gt=j.current;gt&&(gt.onplaying=null,gt.onwaiting=null,gt.onerror=null,gt.onemptied=null,gt.pause(),gt.removeAttribute("src"),gt.srcObject=null,gt.load())},[Ct]),qe=u.useCallback(()=>{Y.current&&(clearInterval(Y.current),Y.current=null),Q.current?.close(),Q.current=null,ee.current?.close(),ee.current=null;const gt=j.current;gt&&(gt.onplaying=null,gt.pause(),gt.srcObject=null,gt.load())},[]),Xt=u.useCallback(()=>{const gt=G.current;if(!gt||gt.updating)return;const es=j.current;if(es&&gt.buffered.length>0){const fr=gt.buffered.start(0);if(es.currentTime-fr>30)try{gt.remove(fr,es.currentTime-15);return}catch{}}const br=z.current.shift();if(br)try{gt.appendBuffer(br)}catch(fr){fr.name==="QuotaExceededError"&&z.current.unshift(br)}},[]),Ut=u.useCallback(gt=>{const es=Date.now();me.current=es,se.current&&(clearTimeout(se.current),se.current=null);const br=G.current;if(!br){z.current.push(gt);return}if(br.updating){z.current.push(gt);return}try{br.appendBuffer(gt)}catch(fr){fr.name==="QuotaExceededError"&&z.current.push(gt)}},[]);return u.useEffect(()=>{oe.current=!0,he.current++;const gt=he.current;le.current=0,ue.current=0;const es=j.current,br=ns==="auto",fr={useRtc:ns!=="jpeg"};if(ns==="jpeg")return _("JPEG"),pe.current=!1,zt(1),De(),Ce(),fs(""),()=>{oe.current=!1,jt()};br&&(zt(1),De());const xn=/iPad|iPhone|iPod/.test(navigator.userAgent)||/Mac/i.test(navigator.userAgent)&&navigator.maxTouchPoints>1,Br=/Safari/i.test(navigator.userAgent)&&!/Chrome|Chromium|Android/i.test(navigator.userAgent),Pi=window.MediaSource??window.ManagedMediaSource,Qn=()=>{es.onplaying=()=>
286{pe.current=!0,ge.current=0,q(es.videoWidth,es.videoHeight),bt.current&&(clearTimeout(bt.current),bt.current=null),H.current&&(clearTimeout(H.current),H.current=null),se.current&&(clearTimeout(se.current),se.current=null),jt(),zt(0),p(!1),Ce(),fs("")},es.onwaiting=()=>{pe.current=!1,j.current?.play().catch(()=>{}),H.current&&clearTimeout(H.current),fr.useRtc?(se.current&&clearTimeout(se.current),se.current=setTimeout(()=>{se.current=null,!pe.current&&je.current&&(console.log("[MSE] Video frozen too long — reconnecting"),V.current?.close())},He.current)):H.current=setTimeout(()=>{H.current=null,zt(1),De(),se.current&&clearTimeout(se.current),se.current=setTimeout(()=>{se.current=null,!pe.current&&je.current&&(console.log("[MSE] JPEG fallback for 15s with no resume — reconnecting"),V.current?.close())},He.current)},ft.current)},es.onerror=()=>{pe.current=!1,fr.useRtc||(zt(1),De()),console.log("[MSE] video error")},es.onemptied=()=>{pe.current=!1,fr.useRtc||zt(1)}};let ii=()=>{};const ua=()=>{if(!oe.current||he.current!==gt)return;fe.current&&clearTimeout(fe.current),bt.current&&(clearTimeout(bt.current),bt.current=null),le.current++;const Ir=Gwe(e,s,le.current);console.log(`[Stream] Reconnect #${le.current} in ${Ir}ms`),fs("↻ Reconnecting…"),!fr.useRtc||br?De():Dt(),fe.current=setTimeout(()=>{oe.current&&he.current===gt&&ii()},Ir)},Ua=async()=>{if(!oe.current||he.current!==gt)return;ue.current=0,xr(),Qn();let Ir=null,Hr=null;const lt=()=>{Ir&&(clearTimeout(Ir),Ir=null),Hr&&(clearTimeout(Hr),Hr=null)};let Rt=!1,At=!1;try{if(!oe.current||he.current!==gt)return;const Ht=await nF(e,y);if(!oe.current||he.current!==gt)return;let mn=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`;if(!ae.current){const Sr=await uS(Be.current);Sr&&oe.current&&he.current===gt&&(mn=sF(Sr),Rt=!0)}const hr=`${mn}/nvr/${e}/live/mse/api/ws?src=${encodeURIComponent(dt)}&_wstoken=${Ht}`;console.log(`[MSE] Connecting gen=${gt} attempt #${le.current}${Rt?" (LAN)":""}`);const Sn=new WebSocket(hr);V.current=Sn,Sn.binaryType="arraybuffer",Ir=setTimeout(()=>{Sn.readyState!==WebSocket.OPEN&&(console.log("[MSE] Connect timeout"),Sn.close())},Ge.current),Sn.onopen=()=>{Ir&&(clearTimeout(Ir),Ir=null),At=!0,le.current=0,_(Os=>Os.replace(/→.*/,"")+"→WS-open"),console.log("[MSE] WS open");const Sr=xn||Br?'video/mp4; codecs="avc1.42E01E"':'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';console.log(`[MSE] Requesting codec (iOS=${xn} Safari=${Br}): ${Sr}`),Sn.send(JSON.stringify({type:"mse",value:Sr})),Hr=setTimeout(()=>{je.current||(console.log(`[MSE] No codec in ${Es.current/1e3}s — reconnecting`),Sn.close())},Es.current)},Sn.onmessage=({data:Sr})=>{if(!(!oe.current||he.current!==gt))if(typeof Sr=="string"){let Os;try{Os=JSON.parse(Sr)}catch{return}if(Os.type==="mse"&&Os.value){lt(),_(Xn=>Xn+"→codec"),console.log("[MSE] Codec:",Os.value);let ur=Os.value;if(xn||Br){const Xn=ur.match(/codecs="([^"]+)"/);if(Xn){const Jr=Xn[1].split(",").map(vn=>vn.trim()).find(vn=>/^(avc|hev|hvc|vp8|vp9|av01)/i.test(vn));Jr&&(ur=`video/mp4; codecs="${Jr}"`)}}console.log(`[MSE] addSourceBuffer MIME: ${ur}`);const nr=!window.MediaSource&&!!window.ManagedMediaSource,qr=new Pi;K.current=qr;const So=()=>{if(!(!oe.current||he.current!==gt))try{_(Jr=>Jr+"→sb");const Xn=qr.addSourceBuffer(ur);if(G.current=Xn,Xn.addEventListener("updateend",Xt),Xt(),je.current=!0,ge.current=Date.now(),Lt(),!nr){const Jr=vn=>{es.play().catch(Mn=>{console.warn(`[MSE] play() attempt ${vn} rejected:`,Mn?.message??Mn),vn<3&&oe.current?setTimeout(()=>Jr(vn+1),800):(console.warn("[MSE] play() failed after retries — reconnecting"),ua())})};Jr(1)}}catch(Xn){ue.current++,console.warn(`[MSE] addSourceBuffer failed (attempt ${ue.current}):`,Xn),_(Jr=>Jr+"→sb-fail"),ue.current>=3?(console.warn("[MSE] Giving up MSE after repeated codec failures"),xr(),fs("")):ua()}};if(nr){let Xn=!1;const Jr=Mn=>{Xn||(Xn=!0,_(Dr=>Dr+`→${Mn}`),So())};qr.addEventListener("startStreaming",()=>Jr("stream-start"),{once:!0}),qr.addEventListener("sourceopen",()=>{_(Mn=>Mn+"→src-open"),setTimeout(()=>{Xn||Jr("src-open-fallback")},1e3)},{once:!0});const vn=()=>_(Mn=>Mn+`→vid-err:${es.error?.code??"?"}`);es.addEventListener("error",vn,{once:!0}),es.srcObject=qr,es.play().then(()=>_(Mn=>Mn+"→play-ok")).catch(Mn=>_(Dr=>Dr+`→play-err:${Mn?.name??Mn}`)),setTimeout(()=>{if(Xn||!oe.current||he.current!==gt)return;_(Dr=>Dr+"→objUrl-try"),es.srcObject=null;const Mn=URL.createObjectURL(qr);Z.current=Mn,es.src=Mn,es.play().then(()=>_(Dr=>Dr+"→objUrl-play-ok")).catch(Dr=>_(en=>en+`→objUrl-play-err:${Dr?.name}`))},3e3)}else{const Xn=URL.createObjectURL(qr);Z.current=Xn,es.src=Xn,qr.addEventListener("sourceopen",()=>{_(Jr=>Jr+"→src-open"),!(!oe.current||he.current!==gt)&&So()})}}}else Sr instanceof ArrayBuffer&&Ut(Sr)},Sn.onerror=Sr=>{_(Os=>Os+"→WS-err"),lt()}
286,Sn.onclose=()=>{lt(),_(Sr=>Sr+"→WS-closed"),console.log(`[MSE] WS closed (mseActive=${je.current})`),!(!oe.current||he.current!==gt)&&(Rt&&!At&&(console.log("[MSE] LAN connect failed — falling back to proxy"),ae.current=!0),Ct(),je.current=!1,ua())}}catch(Ht){console.warn("[MSE] Error:",Ht?.message??Ht),Rt&&!At&&(ae.current=!0),oe.current&&he.current===gt&&ua()}},Ln=async()=>{if(!oe.current||he.current!==gt)return;R(!1),T(null),qe(),_("WebRTC");const Ir=br?8:15;let Hr=!1;const lt=()=>{Y.current&&(clearInterval(Y.current),Y.current=null)};try{if(!oe.current||he.current!==gt)return;const Rt=await nF(e,y);if(!oe.current||he.current!==gt)return;let Ht=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`,vr=!1;if(!ae.current){const Os=await uS(Be.current);Os&&oe.current&&he.current===gt&&(Ht=sF(Os),vr=!0)}const mn=`${Ht}/nvr/${e}/live/webrtc/api/ws?src=${encodeURIComponent(dt)}&_wstoken=${Rt}`;console.log(`[WebRTC] Connecting gen=${gt} attempt #${le.current}${vr?" (LAN)":""}`);const hr=new WebSocket(mn);Q.current=hr;const Sn=setTimeout(()=>{Hr||(_(Os=>Os+"→ws-timeout"),hr.close())},br?5e3:1e4),Sr=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});ee.current=Sr,Sr.addTransceiver("video",{direction:"recvonly"}),Sr.oniceconnectionstatechange=()=>{const Os=Sr.iceConnectionState;if(Os==="checking"){let ur=Ir;T(ur),lt(),Y.current=setInterval(()=>{ur-=1,T(ur),ur<=0&&(lt(),oe.current&&he.current===gt&&(br?(console.warn("[Auto] WebRTC ICE timed out — falling back to MSE"),hr.close(),fr.useRtc=!1,Qn(),ii=Ua,le.current=0,Ua()):(console.warn("[WebRTC] ICE timed out — media ports unreachable"),R(!0),hr.close())))},1e3)}else(Os==="connected"||Os==="completed"||Os==="failed")&&(lt(),T(null))},Sr.ontrack=Os=>{Hr=!0,clearTimeout(Sn),le.current=0,_(nr=>nr+"→track");const ur=j.current;!ur||!oe.current||he.current!==gt||(ur.srcObject=Os.streams[0],ur.onplaying=()=>{pe.current=!0,q(ur.videoWidth,ur.videoHeight),jt(),zt(0),p(!1),Ce(),fs(""),_(nr=>nr+"→playing")},ur.play().catch(nr=>_(qr=>qr+`→play-err:${nr?.name??nr}`)))},Sr.onconnectionstatechange=()=>{const Os=Sr.connectionState;_(ur=>ur+`→${Os}`),(Os==="failed"||Os==="closed")&&oe.current&&he.current===gt&&(pe.current=!1,Y.current||ua())},Sr.onicecandidate=Os=>{Os.candidate&&hr.readyState===WebSocket.OPEN&&hr.send(JSON.stringify({type:"webrtc/candidate",value:Os.candidate.candidate}))},hr.onopen=()=>{_(Os=>Os+"→WS-open"),Sr.createOffer().then(Os=>{Sr.setLocalDescription(Os),hr.send(JSON.stringify({type:"webrtc/offer",value:Os.sdp})),_(ur=>ur+"→offer-sent")}).catch(Os=>_(ur=>ur+`→offer-err:${Os?.name}`))},hr.onmessage=async Os=>{let ur;try{ur=JSON.parse(Os.data)}catch{return}if(ur.type==="webrtc/answer"){_(nr=>nr+"→answer");try{await Sr.setRemoteDescription({type:"answer",sdp:ur.value})}catch(nr){_(qr=>qr+`→sdp-err:${nr?.name}`)}}else if(ur.type==="webrtc/candidate"&&ur.value)try{await Sr.addIceCandidate({candidate:ur.value,sdpMid:"0",sdpMLineIndex:0})}catch{}},hr.onerror=()=>_(Os=>Os+"→WS-err"),hr.onclose=()=>{clearTimeout(Sn);const Os=pe.current;pe.current=!1,console.log(`[WebRTC] WS closed (trackReceived=${Hr} wasPlaying=${Os})`),!(!oe.current||he.current!==gt)&&(vr&&!Hr&&(console.log("[WebRTC] LAN connect failed — falling back to proxy"),ae.current=!0),(!Hr||!Os)&&(br&&!Hr?(console.log("[Auto] WebRTC no track received — falling back to MSE"),fr.useRtc=!1,Qn(),ii=Ua,le.current=0,Ua()):ua()))}}catch(Rt){console.warn("[WebRTC] Error:",Rt?.message??Rt),_(At=>At+`→err:${Rt?.name}`),oe.current&&he.current===gt&&ua()}};return ns==="webrtc"||ns==="auto"?(_(br?"Auto→WebRTC":"WebRTC"),ii=Ln,Ln()):(_("MSE"),Qn(),ii=Ua,Ua()),()=>{console.log(`[Stream] Unmounting gen=${gt}`),oe.current=!1,bt.current&&(clearTimeout(bt.current),bt.current=null),fe.current&&(clearTimeout(fe.current),fe.current=null),xr(),qe(),jt()}},[e,s,ns,dt]),u.useEffect(()=>{Pe.current&&(clearInterval(Pe.current),Pe.current=setInterval(ne,St))},[St,ne]),t.jsxs("div",{ref:k,className:`relative bg-black flex items-center justify-center overflow-hidden ${r}`,style:i?{aspectRatio:$,transition:"aspect-ratio 0.35s ease"}:void 0,children:[t.jsx("video",{ref:j,className:`absolute inset-0 w-full h-full ${a==="contain"?"object-contain":"object-cover"}
286`,autoPlay:!0,muted:!0,playsInline:!0}),t.jsx("img",{ref:w,alt:s,className:`absolute inset-0 w-full h-full ${a==="contain"?"object-contain":"object-cover"} z-[5]`,style:{opacity:0},onLoad:gt=>{if(Oe.current&&Ce(),!pe.current){const es=gt.currentTarget;q(es.naturalWidth,es.naturalHeight)}},onError:()=>{Oe.current&&Ce()}}),t.jsx("div",{ref:x,className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:t.jsx(Fe,{className:"w-8 h-8 animate-spin text-white/40"})}),(g||h&&!pe.current)&&t.jsxs("div",{className:"absolute inset-0 z-[15] bg-[#0a0a0a] flex flex-col items-center justify-center gap-2 text-center px-2","data-testid":"live-camera-stream-error",children:[t.jsx("img",{src:d.appEmblemUrl||"/truvios-emblem.png",alt:"",className:"w-10 h-10 object-contain"}),t.jsx("span",{className:"text-xs text-white/70",children:"Camera Stream Error"})]}),M&&t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/90 z-20 p-3 text-center",children:[t.jsx("div",{className:"text-yellow-400 text-2xl mb-2",children:"⚠"}),t.jsx("p",{className:"text-white text-xs font-semibold mb-1",children:"WebRTC connection failed"}),t.jsxs("p",{className:"text-white/60 text-[10px] leading-snug",children:["ICE timed out — the edge device's media ports may not be reachable from this network. Switch to ",t.jsx("span",{className:"font-semibold text-white/80",children:"MSE"})," in Stream Options."]})]}),t.jsx("div",{ref:C,style:{display:"none"}}),Qe?.debugWebRtc&&t.jsx("div",{className:"absolute bottom-1 left-1 z-20 bg-black/70 text-white text-[10px] font-mono px-1 rounded leading-4 select-none pointer-events-none",children:A!==null?`${S}→connecting(${A}s)`:S})]})}function cC({siteId:e,className:s}){return wJ(e)?t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(Ke,{variant:"outline",className:`gap-1 text-[10px] px-1.5 py-0 border-green-500/40 text-green-600 dark:text-green-400 bg-green-500/10 no-default-hover-elevate no-default-active-elevate shrink-0 ${s??""}`,"data-testid":"badge-lan-active",children:[t.jsx(jb,{className:"h-3 w-3"}),"LAN"]})}),t.jsx(Yt,{children:"Streaming directly from the Edge device on your local network"})]}):null}function wg(e,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e?.(a),r===!1||!a.defaultPrevented)return s?.(a)}}function jJ(e){const s=e0e(e),r=u.forwardRef((n,a)=>{const{children:i,...o}=n,l=u.Children.toArray(i),c=l.find(s0e);if(c){const d=c.props.children,h=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return t.jsx(s,{...o,ref:a,children:u.isValidElement(d)?u.cloneElement(d,void 0,h):null})}return t.jsx(s,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function e0e(e){const s=u.forwardRef((r,n)=>{const{children:a,...i}=r;if(u.isValidElement(a)){const o=n0e(a),l=r0e(i,a.props);return a.type!==u.Fragment&&(l.ref=n?jf(n,o):o),u.cloneElement(a,l)}return u.Children.count(a)>1?u.Children.only(null):null});return s.displayName=`${e}.SlotClone`,s}var t0e=Symbol("radix.slottable");function s0e(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===t0e}function r0e(e,s){const r={...s};for(const n in s){const a=e[n],i=s[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function n0e(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var a0e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Sf=a0e.reduce((e,s)=>{const r=jJ(`Primitive.${s}`),n=u.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(c,{...l,ref:i})});return n.displayName=`Primitive.${s}`,{...e,[s]:n}},{});function i0e(e,s){e&&Em.flushSync(()=>
vendor: 10,140 bytes, line 286
286e.dispatchEvent(s))}var o0e="DismissableLayer",xM="dismissableLayer.update",l0e="dismissableLayer.pointerDownOutside",c0e="dismissableLayer.focusOutside",iF,NJ=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),SJ=u.forwardRef((e,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...c}=e,d=u.useContext(NJ),[h,p]=u.useState(null),g=h?.ownerDocument??globalThis?.document,[,v]=u.useState({}),b=mr(s,A=>p(A)),y=Array.from(d.layers),[w]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),j=y.indexOf(w),x=h?y.indexOf(h):-1,C=d.layersWithOutsidePointerEventsDisabled.size>0,k=x>=j,S=m0e(A=>{const T=A.target,M=[...d.branches].some(R=>R.contains(T));!k||M||(a?.(A),o?.(A),A.defaultPrevented||l?.())},g),_=h0e(A=>{const T=A.target;[...d.branches].some(R=>R.contains(T))||(i?.(A),o?.(A),A.defaultPrevented||l?.())},g);return YW(A=>{x===d.layers.size-1&&(n?.(A),!A.defaultPrevented&&l&&(A.preventDefault(),l()))},g),u.useEffect(()=>{if(h)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(iF=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(h)),d.layers.add(h),oF(),()=>{r&&d.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=iF)}},[h,g,r,d]),u.useEffect(()=>()=>{h&&(d.layers.delete(h),d.layersWithOutsidePointerEventsDisabled.delete(h),oF())},[h,d]),u.useEffect(()=>{const A=()=>v({});return document.addEventListener(xM,A),()=>document.removeEventListener(xM,A)},[]),t.jsx(Sf.div,{...c,ref:b,style:{pointerEvents:C?k?"auto":"none":void 0,...e.style},onFocusCapture:wg(e.onFocusCapture,_.onFocusCapture),onBlurCapture:wg(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:wg(e.onPointerDownCapture,S.onPointerDownCapture)})});SJ.displayName=o0e;var d0e="DismissableLayerBranch",u0e=u.forwardRef((e,s)=>{const r=u.useContext(NJ),n=u.useRef(null),a=mr(s,n);return u.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),t.jsx(Sf.div,{...e,ref:a})});u0e.displayName=d0e;function m0e(e,s=globalThis?.document){const r=Za(e),n=u.useRef(!1),a=u.useRef(()=>{});return u.useEffect(()=>{const i=l=>{if(l.target&&!n.current){let c=function(){CJ(l0e,r,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(s.removeEventListener("click",a.current),a.current=c,s.addEventListener("click",a.current,{once:!0})):c()}else s.removeEventListener("click",a.current);n.current=!1},o=window.setTimeout(()=>{s.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),s.removeEventListener("pointerdown",i),s.removeEventListener("click",a.current)}},[s,r]),{onPointerDownCapture:()=>n.current=!0}}function h0e(e,s=globalThis?.document){const r=Za(e),n=u.useRef(!1);return u.useEffect(()=>{const a=i=>{i.target&&!n.current&&CJ(c0e,r,{originalEvent:i},{discrete:!1})};return s.addEventListener("focusin",a),()=>s.removeEventListener("focusin",a)},[s,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function oF(){const e=new CustomEvent(xM);document.dispatchEvent(e)}function CJ(e,s,r,{discrete:n}){const a=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});s&&a.addEventListener(e,s,{once:!0}),n?i0e(a,i):a.dispatchEvent(i)}var wP=0;function p0e(){u.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??lF()),document.body.insertAdjacentElement("beforeend",e[1]??lF()),wP++,()=>{wP===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),wP--}},[])}function lF(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var jP="focusScope.autoFocusOnMount",NP="focusScope.autoFocusOnUnmount",cF={bubbles:!1,cancelable:!0},f0e="FocusScope",kJ=u.forwardRef((e,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=e,[l,c]=u.useState(null),d=Za(a),h=Za(i),p=u.useRef(null),g=mr(s,y=>c(y)),v=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(n){let y=function(C){if(v.paused||!l)return;const k=C.target;l.contains(k)?p.current=k:ng(p.current,{select:!0})},w=function(C){if(v.paused||!l)return;const k=C.relatedTarget;k!==null&&(l.contains(k)||ng(p.current,{select:!0}))},j=function(C){if(document.activeElement===document.body)for(const S of C)S.removedNodes.length>0&&ng(l)};document.addEventListener("focusin",y),document.addEventListener("focusout",w);const x=new MutationObserver(j);return l&&x.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",w),x.disconnect()}}},[n,l,v.paused]),u.useEffect(()=>{if(l){uF.add(v);const y=document.activeElement;if(!l.contains(y)){const j=new CustomEvent(jP,cF);l.addEventListener(jP,d),l.dispatchEvent(j),j.defaultPrevented||(g0e(w0e(_J(l)),{select:!0}),document.activeElement===y&&ng(l))}return()=>{l.removeEventListener(jP,d),setTimeout(()=>{const j=new CustomEvent(NP,cF);l.addEventListener(NP,h),l.dispatchEvent(j),j.defaultPrevented||ng(y??document.body,{select:!0}),l.removeEventListener(NP,h),uF.remove(v)},0)}}},[l,d,h,v]);const b=u.useCallback(y=>{if(!r&&!n||v.paused)return;const w=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,j=document.activeElement;if(w&&j){const x=y.currentTarget,[C,k]=x0e(x);C&&k?!y.shiftKey&&j===k?(y.preventDefault(),r&&ng(C,{select:!0})):y.shiftKey&&j===C&&(y.preventDefault(),r&&ng(k,{select:!0})):j===x&&y.preventDefault()}},[r,n,v.paused]);return t.jsx(Sf.div,{tabIndex:-1,...o,ref:g,onKeyDown:b})});kJ.displayName=f0e;function g0e(e,{select:s=!1}={}){const r=document.activeElement;for(const n of e)if(ng(n,{select:s}),document.activeElement!==r)return}function x0e(e){const s=_J(e),r=dF(s,e),n=dF(s.reverse(),e);return[r,n]}function _J(e){const s=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)s.push(r.currentNode);return s}function dF(e,s){for(const r of e)if(!v0e(r,{upTo:s}))return r}function v0e(e,{upTo:s}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(s!==void 0&&e===s)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function y0e(e){return e instanceof HTMLInputElement&&"select"in e}function ng(e,{select:s=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&y0e(e)&&s&&e.select()}}var uF=b0e();function b0e(){let e=[];return{add(s){const r=e[0];s!==r&&r?.pause(),e=mF(e,s),e.unshift(s)},remove(s){e=mF(e,s),e[0]?.resume()}}}function mF(e,s){const r=[...e],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function w0e(e){return e.filter(s=>s.tagName!=="A")}var j0e="Arrow",PJ=u.forwardRef((e,s)=>{const{children:r,width:n=10,height:a=5,...i}=e;return t.jsx(Sf.svg,{...i,ref:s,width:n,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});PJ.displayName=j0e;var N0e=PJ,h3="Popper",[EJ,TJ]=oo(h3),[S0e,AJ]=EJ(h3),MJ=e=>{const{__scopePopper:s,children:r}=e,[n,a]=u.useState(null);return t.jsx(S0e,{scope:s,anchor:n,onAnchorChange:a,children:r})};MJ.displayName=h3;var RJ="PopperAnchor",IJ=u.forwardRef((e,s)=>{const{__scopePopper:r,virtualRef:n,...a}=e,i=AJ(RJ,r),o=u.useRef(null),l=mr(s,o),c=u.useRef(null);return u.useEffect(()=>{const d=c.current;c.current=n?.current||o.current,d!==c.current&&i.onAnchorChange(c.current)}),n?null:t.jsx(Sf.div,{...a,ref:l})});IJ.displayName=RJ;var p3="PopperContent",[C0e,k0e]=EJ(p3),OJ=u.forwardRef((e,s)=>{const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:h=0,sticky:p="partial",hideWhenDetached:g=!1,updatePositionStrategy:v="optimized",onPlaced:b,...y}=e,w=AJ(p3,r),[j,x]=u.useState(null),C=mr(s,le=>x(le)),[k,S]=u.useState(null),_=_b(k),A=_?.width??0,T=_?.height??0,M=n+(i!=="center"?"-"+i:""),R=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},D=Array.isArray(d)?d:[d],$=D.length>0,O={padding:R,boundary:D.filter(P0e),altBoundary:$},{refs:q,floatingStyles:V,placement:K,isPositioned:G,middlewareData:z}=wG({strategy:"fixed",placement:M,whileElementsMounted:(...le)=>yG(...le,{animationFrame:v==="always"}),elements:{reference:w.anchor},middleware:[jG({mainAxis:a+T,alignmentAxis:o}),c&&NG({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?SG():void 0,...O}),c&&CG({...O}),kG({...O,apply:({elements:le,rects:ue,availableWidth:fe,availableHeight:H})=>{const{width:se,height:me}=ue.reference,ge=le.floating.style;ge.setProperty("--radix-popper-available-width",`${fe}px`),ge.setProperty("--radix-popper-available-height",`${H}px`),ge.setProperty("--radix-popper-anchor-width",`${se}px`),ge.setProperty("--radix-popper-anchor-height",`${me}px`)}}),k&&PG({element:k,padding:l}),E0e({arrowWidth:A,arrowHeight:T}),g&&_G({strategy:"referenceHidden",...O})]}),[Z,ee]=$J(K),Q=Za(b);da(()=>{G&&Q?.()},[G,Q]);const Y=z.arrow?.x,oe=z.arrow?.y,he=z.arrow?.centerOffset!==0,[je,pe]=u.useState();return da(()=>{j&&pe(window.getComputedStyle(j).zIndex)},[j]),t.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:G?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:je,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(" "),...z.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(C0e,{scope:r,placedSide:Z,onArrowChange:S,arrowX:Y,arrowY:oe,shouldHideArrow:he,children:t.jsx(Sf.div,{"data-side":Z,"data-align":ee,...y,ref:C,style:{...y.style,animation:G?void 0:"none"}})})})});OJ.displayName=p3;var DJ="PopperArrow",_0e={top:"bottom",right:"left",bottom:"top",left:"r
286ight"},LJ=u.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,i=k0e(DJ,n),o=_0e[i.placedSide];return t.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:t.jsx(N0e,{...a,ref:r,style:{...a.style,display:"block"}})})});LJ.displayName=DJ;function P0e(e){return e!==null}var E0e=e=>({name:"transformOrigin",options:e,fn(s){const{placement:r,rects:n,middlewareData:a}=s,o=a.arrow?.centerOffset!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[d,h]=$J(r),p={start:"0%",center:"50%",end:"100%"}[h],g=(a.arrow?.x??0)+l/2,v=(a.arrow?.y??0)+c/2;let b="",y="";return d==="bottom"?(b=o?p:`${g}px`,y=`${-c}px`):d==="top"?(b=o?p:`${g}px`,y=`${n.floating.height+c}px`):d==="right"?(b=`${-c}px`,y=o?p:`${v}px`):d==="left"&&(b=`${n.floating.width+c}px`,y=o?p:`${v}px`),{data:{x:b,y}}}});function $J(e){const[s,r="center"]=e.split("-");return[s,r]}var T0e=MJ,FJ=IJ,A0e=OJ,M0e=LJ,R0e="Portal",BJ=u.forwardRef((e,s)=>{const{container:r,...n}=e,[a,i]=u.useState(!1);da(()=>i(!0),[]);const o=r||a&&globalThis?.document?.body;return o?VW.createPortal(t.jsx(Sf.div,{...n,ref:s}),o):null});BJ.displayName=R0e;function I0e(e,s){return u.useReducer((r,n)=>s[r][n]??r,e)}var f3=e=>{const{present:s,children:r}=e,n=O0e(s),a=typeof r=="function"?r({present:n.isPresent}):u.Children.only(r),i=mr(n.ref,D0e(a));return typeof r=="function"||n.isPresent?u.cloneElement(a,{ref:i}):null};f3.displayName="Presence";function O0e(e){const[s,r]=u.useState(),n=u.useRef(null),a=u.useRef(e),i=u.useRef("none"),o=e?"mounted":"unmounted",[l,c]=I0e(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=f1(n.current);i.current=l==="mounted"?d:"none"},[l]),da(()=>{const d=n.current,h=a.current;if(h!==e){const g=i.current,v=f1(d);e?c("MOUNT"):v==="none"||d?.display==="none"?c("UNMOUNT"):c(h&&g!==v?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),da(()=>{if(s){let d;const h=s.ownerDocument.defaultView??window,p=v=>{const y=f1(n.current).includes(CSS.escape(v.animationName));if(v.target===s&&y&&(c("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",d=h.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},g=v=>{v.target===s&&(i.current=f1(n.current))};return s.addEventListener("animationstart",g),s.addEventListener("animationcancel",p),s.addEventListener("animationend",p),()=>{h.clearTimeout(d),s.removeEventListener("animationstart",g),s.removeEventListener("animationcancel",p),s.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{n.current=d?getComputedStyle(d):null,r(d)},[])}}function f1(e){return e?.animationName||"none"}function D0e(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var L0e=bb[" useInsertionEffect ".trim().toString()]||da;function $0e({prop:e,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,i,o]=F0e({defaultProp:s,onChange:r}),l=e!==void 0,c=l?e:a;{const h=u.useRef(e!==void 0);u.useEffect(()=>{const p=h.current;p!==l&&console.warn(`${n} is changing from ${p?"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.`),h.current=l},[l,n])}const d=u.useCallback(h=>{if(l){const p=B0e(h)?h(e):h;p!==e&&o.current?.(p)}else i(h)},[l,e,i,o]);return[c,d]}function F0e({defaultProp:e,onChange:s}){const[r,n]=u.useState(e),a=u.useRef(r),i=u.useRef(s);return L0e(()=>{i.current=s},[s]),u.useEffect(()=>{a.current!==r&&(i.current?.(r),a.current=r)},[r,a]),[r,n,i]}function B0e(e){return typeof e=="function"}var m_="Popover",[UJ]=oo(m_,[TJ]),nN=TJ(),[U0e,$g]=UJ(m_),zJ=e=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:o=!1}=e,l=nN(s),c=u.useRef(null),[d,h]=u.useState(!1),[p,g]=$0e({prop:n,defaultProp:a??!1,onChange:i,caller:m_});return t.jsx(T0e,{...l,children:t.jsx(U0e,{scope:s,contentId:wu(),triggerRef:c,open:p,onOpenChange:g,onOpenToggle:u.useCallback(()=>g(v=>!v),[g]),hasCustomAnchor:d,onCustomAnchorAdd:u.useCallback(()=>h(!0),[]),onCustomAnchorRemove:u.useCallback(()=>h(!1),[]),modal:o,children:r})})};zJ.displayName=m_;var HJ="PopoverAnchor",z0e=u.forwardRef((e,s)=>{const{__scopePopover:r,...n}=e,a=$g(HJ,r),i=nN(r),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=a;return u.useEffect(()=>(o(),()=>l()),[o,l]),t.jsx(FJ,{...i,...n,ref:s})});z0e.displayName=HJ;var qJ="PopoverTrigger",VJ=u.forwardRef((e,s)=>{const{__scopePopover:r,...n}
vendor: 4,106 bytes, line 286
286=e,a=$g(qJ,r),i=nN(r),o=mr(s,a.triggerRef),l=t.jsx(Sf.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":QJ(a.open),...n,ref:o,onClick:wg(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:t.jsx(FJ,{asChild:!0,...i,children:l})});VJ.displayName=qJ;var g3="PopoverPortal",[H0e,q0e]=UJ(g3,{forceMount:void 0}),WJ=e=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=e,i=$g(g3,s);return t.jsx(H0e,{scope:s,forceMount:r,children:t.jsx(f3,{present:r||i.open,children:t.jsx(BJ,{asChild:!0,container:a,children:n})})})};WJ.displayName=g3;var $y="PopoverContent",KJ=u.forwardRef((e,s)=>{const r=q0e($y,e.__scopePopover),{forceMount:n=r.forceMount,...a}=e,i=$g($y,e.__scopePopover);return t.jsx(f3,{present:n||i.open,children:i.modal?t.jsx(W0e,{...a,ref:s}):t.jsx(K0e,{...a,ref:s})})});KJ.displayName=$y;var V0e=jJ("PopoverContent.RemoveScroll"),W0e=u.forwardRef((e,s)=>{const r=$g($y,e.__scopePopover),n=u.useRef(null),a=mr(s,n),i=u.useRef(!1);return u.useEffect(()=>{const o=n.current;if(o)return Gk(o)},[]),t.jsx(Yj,{as:V0e,allowPinchZoom:!0,children:t.jsx(GJ,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:wg(e.onCloseAutoFocus,o=>{o.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:wg(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:wg(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),K0e=u.forwardRef((e,s)=>{const r=$g($y,e.__scopePopover),n=u.useRef(!1),a=u.useRef(!1);return t.jsx(GJ,{...e,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;r.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),GJ=u.forwardRef((e,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:h,...p}=e,g=$g($y,r),v=nN(r);return p0e(),t.jsx(kJ,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:t.jsx(SJ,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:h,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>g.onOpenChange(!1),children:t.jsx(A0e,{"data-state":QJ(g.open),role:"dialog",id:g.contentId,...v,...p,ref:s,style:{...p.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)"}})})})}),YJ="PopoverClose",G0e=u.forwardRef((e,s)=>{const{__scopePopover:r,...n}=e,a=$g(YJ,r);return t.jsx(Sf.button,{type:"button",...n,ref:s,onClick:wg(e.onClick,()=>a.onOpenChange(!1))})});G0e.displayName=YJ;var Y0e="PopoverArrow",Q0e=u.forwardRef((e,s)=>{const{__scopePopover:r,...n}=e,a=nN(r);return t.jsx(M0e,{...a,...n,ref:s})});Q0e.displayName=Y0e;function QJ(e){return e?"open":"closed"}var X0e=zJ,Z0e=VJ,J0e=WJ,XJ=KJ;const vd=X0e,yd=Z0e,Kc=u.forwardRef(({className:e,align:s="center",sideOffset:r=4,...n},a)=>t.jsx(J0e,{children:t.jsx(XJ,{ref:a,align:s,sideOffset:r,className:Cs("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]:sli
286de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",e),...n})}));Kc.displayName=XJ.displayName;const hF=.6,eje=.5;function Q0({siteId:e,cameraName:s,isAdmin:r=!1,compact:n=!1,className:a=""}){const{toast:i}=Hs(),o=Su(),[l,c]=u.useState(!1),[d,h]=u.useState(""),p=u.useRef(!1),{data:g}=ze({queryKey:["/api/sites",e,"cameras",s,"ptz-info"],queryFn:async()=>{const T=await fetch(`/api/sites/${e}/cameras/${encodeURIComponent(s)}/ptz-info`,{credentials:"include"});return T.ok?T.json():{ptzCapable:!1,presets:[]}},staleTime:3e4}),v=u.useCallback(async(T,M,R=5e3)=>{const D=Date.now()+R;for(;Date.now()<D;){await new Promise($=>setTimeout($,500));try{const $=await fetch(`/api/edge-devices/${T}/commands/${M}/status`,{credentials:"include"});if(!$.ok)continue;const O=await $.json();if(O.status==="completed"||O.status==="failed")return{status:O.status,result:O.result??null}}catch{}}return null},[]),b=u.useCallback(async(T,M={})=>{try{const D=await(await Ze("POST",`/api/sites/${e}/cameras/${encodeURIComponent(s)}/ptz`,{action:T,params:M})).json().catch(()=>({}));return D.commandId&&D.edgeDeviceId&&T!=="stop"&&T!=="set_preset"&&T!=="remove_preset"&&(async()=>{const $=await v(D.edgeDeviceId,D.commandId);$?.status==="failed"&&i({title:"PTZ command failed",description:typeof $.result=="string"&&$.result||"Camera reported an error",variant:"destructive"})})(),D}catch(R){i({title:"PTZ command failed",description:R?.message||String(R),variant:"destructive"})}},[e,s,i,v]),y=u.useCallback((T,M,R=0)=>{p.current||(p.current=!0,b("continuous",{pan:T*hF,tilt:M*hF,zoom:R*eje}))},[b]),w=u.useCallback(()=>{p.current&&(p.current=!1,b("stop"))},[b]);u.useEffect(()=>{const T=()=>w();return window.addEventListener("blur",T),()=>{window.removeEventListener("blur",T),p.current&&(p.current=!1,b("stop"))}},[b,w]);const j=Et({mutationFn:async T=>{const R=await(await Ze("POST",`/api/sites/${e}/cameras/${encodeURIComponent(s)}/ptz`,{action:"set_preset",params:{presetName:T}})).json().catch(()=>({}));if(R.commandId&&R.edgeDeviceId){const D=await v(R.edgeDeviceId,R.commandId);if(D?.status==="failed")throw new Error(typeof D.result=="string"&&D.result||"Camera reported an error")}return R},onSuccess:async()=>{h(""),await o.invalidateQueries({queryKey:["/api/sites",e,"cameras",s,"ptz-info"]}),i({title:"Preset saved"})},onError:T=>i({title:"Failed to save preset",description:T?.message,variant:"destructive"})}),x=Et({mutationFn:async T=>{const R=await(await Ze("POST",`/api/sites/${e}/cameras/${encodeURIComponent(s)}/ptz`,{action:"remove_preset",params:{presetToken:T}})).json().catch(()=>({}));if(R.commandId&&R.edgeDeviceId){const D=await v(R.edgeDeviceId,R.commandId);if(D?.status==="failed")throw new Error(typeof D.result=="string"&&D.result||"Camera reported an error")}},onSuccess:async()=>{await o.invalidateQueries({queryKey:["/api/sites",e,"cameras",s,"ptz-info"]}),i({title:"Preset removed"})},onError:T=>i({title:"Failed to remove preset",description:T?.message,variant:"destructive"})});if(!g?.ptzCapable)return null;const C=(T,M,R,D)=>t.jsx("button",{type:"button","aria-label":T,"data-testid":D,className:"w-full h-full flex items-center justify-center bg-black/60 hover:bg-black/80 active:bg-primary/80 text-white rounded-md transition-colors touch-none",onPointerDown:$=>{$.preventDefault(),$.stopPropagation(),M()},onPointerUp:$=>{$.preventDefault(),$.stopPropagation(),w()},onPointerLeave:()=>w(),onPointerCancel:()=>w(),onClick:$=>$.stopPropagation(),children:R}),k=n?"w-7 h-7":"w-10 h-10 max-sm:portrait:w-8 max-sm:portrait:h-8",S=n?"w-3.5 h-3.5":"w-5 h-5 max-sm:portrait:w-4 max-sm:portrait:h-4",_=n?"w-5 h-5":"w-7 h-7 max-sm:portrait:w-5 max-sm:portrait:h-5",A=n?"w-2.5 h-2.5":"w-3.5 h-3.5 max-sm:portrait:w-3 max-sm:portrait:h-3";return t.jsxs("div",{className:`absolute z-20 bg-black/40 rounded-lg p-2 backdrop-blur-sm pointer-events-auto select-none ${n?"bottom-7 right-1":"bottom-12 right-3 max-sm:portrait:bottom-8 max-sm:portrait:right-2 max-sm:portrait:p-1"} ${a}`,onClick:T=>T.stopPropagation(),"data-testid":`ptz-overlay-${s}`,children:[t.jsxs("div",{className:"grid grid-cols-3 gap-1",children:[t.jsx("div",{className:k,children:C("Up-Left",()=>y(-1,1),t.jsx(Fce,{className:S}),`ptz-up-left-${s}`)}),t.jsx("div",{className:k,children:C("Up",()=>y(0,1),t.jsx(Ig,{className:S}),`ptz-up-${s}`)}),t.jsx("div",{className:k,children:C("Up-Right",()=>y(1,1),t.jsx(Bce,{className:S}),`ptz-up-right-${s}`)}),t.jsx("div",{className:k,children:C("Left",()=>y(-1,0),t.jsx(Kl,{className:S}),`ptz-left-${s}`)}),t.jsx("div",{className:`${k} flex items-center justify-center`,children:t.jsx("button",{type:"button","aria-label":"Home","data-testid":`ptz-home-${s}`,className:`${_} flex items-center justify-center bg-black/60 hover:bg-black/80 text-white rounded-md`,onClick:T=>{T.stopPropagation(),b("home")},children:t.jsx(Ik,{className:A})})}),t.jsx("div",{className:k,children:C("Right",()=>y(1,0),t.jsx(hi,{className:S}),`ptz-right-${s}`)}),t.jsx("div",{className:k,children:C("Down-Left",()=>y(-1,-1),t.jsx(Dce,{className:S}),`ptz-down-left-${s}`)}),t.jsx("div",{className:k,children:C("Down",()=>y(0,-1),t.jsx(Xa,{className:S}),`ptz-down-${s}`)}),t.jsx("div",{className:k,children:C("Down-Right",()=>y(1,-1),t.jsx(Lce,{className:S}),`ptz-down-right-${s}`)})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-1 mt-2 max-sm:portrait:mt-1",children:[t.jsx("div",{className:k,children:C("Zoom In",()=>
286y(0,0,1),t.jsx(Fo,{className:S}),`ptz-zoom-in-${s}`)}),t.jsxs(vd,{open:l,onOpenChange:c,children:[t.jsx(yd,{asChild:!0,children:t.jsx("div",{className:`${k} flex items-center justify-center`,children:t.jsx("button",{type:"button","aria-label":"Presets","data-testid":`ptz-presets-${s}`,className:`${_} flex items-center justify-center bg-black/60 hover:bg-black/80 text-white rounded-md`,onClick:T=>T.stopPropagation(),children:t.jsx(NK,{className:A})})})}),t.jsxs(Kc,{className:"w-60 p-2",align:"end",onClick:T=>T.stopPropagation(),onPointerDown:T=>T.stopPropagation(),children:[t.jsx("div",{className:"text-xs font-medium mb-2",children:"Presets"}),(g.presets||[]).length===0&&t.jsx("div",{className:"text-xs text-muted-foreground mb-2",children:"No presets saved"}),t.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:(g.presets||[]).map(T=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(L,{variant:"outline",size:"sm",className:"flex-1 justify-start h-7 text-xs",onClick:()=>{b("goto_preset",{presetToken:T.token}),c(!1)},"data-testid":`ptz-goto-preset-${T.token}`,children:T.name}),r&&t.jsx(L,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>x.mutate(T.token),disabled:x.isPending,"data-testid":`ptz-delete-preset-${T.token}`,children:t.jsx(sa,{className:"w-3 h-3"})})]},T.token))}),r&&t.jsxs("div",{className:"mt-2 pt-2 border-t flex items-center gap-1",children:[t.jsx(ke,{placeholder:"Preset name",value:d,onChange:T=>h(T.target.value),className:"h-7 text-xs","data-testid":`input-ptz-preset-name-${s}`}),t.jsx(L,{size:"sm",className:"h-7",disabled:!d.trim()||j.isPending,onClick:()=>j.mutate(d.trim()),"data-testid":`ptz-save-preset-${s}`,children:"Save"})]})]})]}),t.jsx("div",{className:k,children:C("Zoom Out",()=>y(0,0,-1),t.jsx(BK,{className:S}),`ptz-zoom-out-${s}`)})]})]})}const pF=1,fF=8,gF=2.5;function jg({children:e,className:s,testIdPrefix:r="video-zoom",disabled:n=!1,doubleClickZoom:a=!0,onZoomChange:i}){const o=u.useRef(null),[l,c]=u.useState(1),[d,h]=u.useState({x:0,y:0}),p=u.useRef(1),g=u.useRef({x:0,y:0});p.current=l,g.current=d,u.useRef(new Map);const v=u.useRef(n);v.current=n;const b=u.useRef(a);b.current=a;const y=u.useRef(i);y.current=i,u.useEffect(()=>{y.current?.(l)},[l]);const w=u.useRef(null),j=u.useRef(null),x=u.useRef(0),[C,k]=u.useState(!1);u.useEffect(()=>{const $=()=>k(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",$),$(),()=>document.removeEventListener("fullscreenchange",$)},[]);const[S,_]=u.useState(!1);u.useEffect(()=>{const $=window.matchMedia("(orientation: landscape) and (max-height: 500px)"),O=()=>_($.matches);return $.addEventListener("change",O),O(),()=>$.removeEventListener("change",O)},[]);const A=C||S,T=u.useCallback(($,O)=>{const q=o.current;if(!q||O<=1)return{x:0,y:0};const V=(O-1)*q.clientWidth/2,K=(O-1)*q.clientHeight/2;return{x:Math.max(-V,Math.min(V,$.x)),y:Math.max(-K,Math.min(K,$.y))}},[]),M=u.useCallback(($,O,q)=>{const V=o.current;if(!V)return;const K=p.current,G=Math.max(pF,Math.min(fF,$));if(G===K)return;const z=V.clientWidth/2,Z=V.clientHeight/2,ee=g.current,Q=G/K,Y=O-z-(O-z-ee.x)*Q,oe=q-Z-(q-Z-ee.y)*Q;c(G),h(T({x:Y,y:oe},G))},[T]),R=u.useCallback(()=>{c(1),h({x:0,y:0}),w.current=null,j.current=null},[]);u.useEffect(()=>{const $=o.current;if(!$)return;const O=$.parentElement??$,q=(Y,oe)=>{const he=$.getBoundingClientRect();return{x:Y-he.left,y:oe-he.top}},V=Y=>Y instanceof Element&&!!Y.closest("button, input, select, [data-video-zoom-ignore]"),K=Y=>{if(v.current||V(Y.target)||!Y.ctrlKey&&Y.deltaY>0&&p.current<=1)return;Y.preventDefault(),Y.stopPropagation();const{x:oe,y:he}=q(Y.clientX,Y.clientY),je=Math.exp(-Y.deltaY*(Y.ctrlKey?.01:.0035));M(p.current*je,oe,he)},G=Y=>{if(!(v.current||V(Y.target))){if(Y.touches.length===2){Y.preventDefault();const[oe,he]=[Y.touches[0],Y.touches[1]],je=Math.hypot(oe.clientX-he.clientX,oe.clientY-he.clientY),pe=q((oe.clientX+he.clientX)/2,(oe.clientY+he.clientY)/2);w.current={dist:je,zoom:p.current,midX:pe.x,midY:pe.y,pan:{...g.current}},j.current=null}else if(Y.touches.length===1&&p.current>1){Y.stopPropagation();const oe=Y.touches[0];j.current={x:oe.clientX,y:oe.clientY,pan:{...g.current},moved:!1};const he=Date.now();if(b.current&&he-x.current<300){const{x:je,y:pe}=q(oe.clientX,oe.clientY);M(1,je,pe),j.current=null}x.current=he}else if(Y.touches.length===1){const oe=Date.now();if(b.current&&oe-x.current<300){const he=Y.touches[0],{x:je,y:pe}=q(he.clientX,he.clientY);M(gF,je,pe)}x.current=oe}}},z=Y=>{if(!v.current){if(Y.touches.length===2&&w.current){Y.preventDefault();const[oe,he]=[Y.touches[0],Y.touches[1]],je=Math.hypot(oe.clientX-he.clientX,oe.clientY-he.clientY),pe=w.current,le=
286Math.max(pF,Math.min(fF,pe.zoom*(je/Math.max(1,pe.dist)))),ue=$.clientWidth/2,fe=$.clientHeight/2,H=le/pe.zoom,se=pe.midX-ue-(pe.midX-ue-pe.pan.x)*H,me=pe.midY-fe-(pe.midY-fe-pe.pan.y)*H,ge=q((oe.clientX+he.clientX)/2,(oe.clientY+he.clientY)/2),be=ge.x-pe.midX,ce=ge.y-pe.midY;c(le),h(T({x:se+be,y:me+ce},le))}else if(Y.touches.length===1&&j.current&&p.current>1){Y.preventDefault(),Y.stopPropagation();const oe=Y.touches[0],he=j.current,je=oe.clientX-he.x,pe=oe.clientY-he.y;(Math.abs(je)>6||Math.abs(pe)>6)&&(he.moved=!0),h(T({x:he.pan.x+je,y:he.pan.y+pe},p.current))}}},Z=Y=>{if(Y.touches.length<2){if(w.current&&Y.touches.length===1&&p.current>1){const oe=Y.touches[0];j.current={x:oe.clientX,y:oe.clientY,pan:{...g.current},moved:!0}}w.current=null}Y.touches.length===0&&(j.current?.moved&&(x.current=0),j.current=null),p.current<1.05&&p.current!==1&&R()},ee=Y=>{if(v.current||p.current<=1||Y.button!==0||V(Y.target))return;Y.preventDefault(),Y.stopPropagation();const oe={x:Y.clientX,y:Y.clientY,pan:{...g.current}},he=pe=>{h(T({x:oe.pan.x+(pe.clientX-oe.x),y:oe.pan.y+(pe.clientY-oe.y)},p.current))},je=()=>{window.removeEventListener("mousemove",he),window.removeEventListener("mouseup",je)};window.addEventListener("mousemove",he),window.addEventListener("mouseup",je)},Q=Y=>{if(v.current||!b.current||V(Y.target))return;const{x:oe,y:he}=q(Y.clientX,Y.clientY);M(p.current>1?1:gF,oe,he)};return O.addEventListener("wheel",K,{passive:!1}),O.addEventListener("touchstart",G,{passive:!1}),O.addEventListener("touchmove",z,{passive:!1}),O.addEventListener("touchend",Z),O.addEventListener("touchcancel",Z),O.addEventListener("mousedown",ee),O.addEventListener("dblclick",Q),()=>{O.removeEventListener("wheel",K),O.removeEventListener("touchstart",G),O.removeEventListener("touchmove",z),O.removeEventListener("touchend",Z),O.removeEventListener("touchcancel",Z),O.removeEventListener("mousedown",ee),O.removeEventListener("dblclick",Q)}},[M,T,R]),u.useEffect(()=>{n&&R()},[n,R]);const D=l>1;return t.jsxs("div",{ref:o,className:`relative overflow-hidden w-full h-full ${s||""}`,style:{cursor:D?"grab":void 0,touchAction:D?"none":void 0},"data-testid":`${r}-container`,children:[t.jsx("div",{className:"w-full h-full",style:{transform:D?`translate(${d.x}px, ${d.y}px) scale(${l})`:void 0,transformOrigin:"center center",willChange:D?"transform":void 0},children:e}),!n&&t.jsxs("div",{className:`absolute ${A?"top-16":"top-2"} right-2 z-30 flex flex-col gap-1`,children:[t.jsx("button",{type:"button",className:"flex items-center justify-center w-8 h-8 rounded-md bg-black/50 hover:bg-black/70 text-white/90",onClick:$=>{$.stopPropagation();const O=o.current;M(l*1.5,(O?.clientWidth||0)/2,(O?.clientHeight||0)/2)},title:"Zoom in","data-testid":`${r}-in`,children:t.jsx(Vj,{className:"w-4 h-4"})}),D&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"flex items-center justify-center w-8 h-8 rounded-md bg-black/50 hover:bg-black/70 text-white/90",onClick:$=>{$.stopPropagation();const O=o.current;M(l/1.5,(O?.clientWidth||0)/2,(O?.clientHeight||0)/2)},title:"Zoom out","data-testid":`${r}-out`,children:t.jsx(uO,{className:"w-4 h-4"})}),t.jsx("button",{type:"button",className:"flex items-center justify-center w-8 h-8 rounded-md bg-black/50 hover:bg-black/70 text-white/90",onClick:$=>{$.stopPropagation(),R()},title:"Reset zoom","data-testid":`${r}-reset`,children:t.jsx(bh,{className:"w-4 h-4"})}),t.jsxs("span",{className:"text-[10px] text-center text-white/80 bg-black/50 rounded px-1 py-0.5 select-none","data-testid":`${r}-level`,children:[l.toFixed(1),"x"]})]})]})]})}function tje(e){const s=[],r=[];for(const n of e)(n.isOnline?s:r).push(n);return{online:s,offline:r}}function sje(e,s){return!s||new URLSearchParams(e).get("from")!=="classic"?"/":`/?view=classic&siteId=${encodeURIComponent(s)}`}function rje(e){const s=new URLSearchParams(e);return s.get("view")!=="classic"?null:s.get("siteId")}function nje(){Gi();const e=Er(),[,s]=Ia(),{toast:r}=Hs(),[n,a]=u.useState(!1),[i,o]=u.useState(!1),[l,c]=u.useState(null),[d,h]=u.useState(null),[p,g]=u.useState(null),[v,b]=u.useState(null),[y,w]=u.useState({}),[j,x]=u.useState(!1),[C,k]=u.useState(!1),[S,_]=u.useState(null),[A,T]=u.useState(null),[M,R]=u.useState(()=>
286{if(new URLSearchParams(window.location.search).get("view")==="classic")return"classic";const lt=localStorage.getItem("dashboard_viewMode");return lt==="list"||lt==="classic"||lt==="map"?lt:"grid"}),[D,$]=u.useState(null),[O,q]=u.useState(null),[V,K]=u.useState(!1),[G,z]=u.useState(()=>localStorage.getItem("dashboard_hideCompanies")!=="false"),[Z,ee]=u.useState(""),[Q,Y]=u.useState(new Set),[oe,he]=u.useState(0),je=Ive(Rve(r3,{activationConstraint:{distance:8}})),pe=u.useCallback(async()=>{await Promise.all([Je.invalidateQueries({queryKey:["/api/companies"]}),Je.invalidateQueries({queryKey:["/api/device-notifications/status"]}),Je.invalidateQueries({queryKey:["/api/sites/restarting"]}),Je.invalidateQueries({queryKey:["/api/user/settings"]})]),he(lt=>lt+1)},[]),{pullDistance:le,isRefreshing:ue,isPastThreshold:fe}=bge({onRefresh:pe}),{data:H}=ze({queryKey:["/api/user/mfa/policy"]}),se=u.useRef(!1),{data:me}=ze({queryKey:["/api/device-notifications/status"],refetchInterval:()=>se.current?5e3:3e4}),[ge,be]=u.useState(()=>{try{return JSON.parse(localStorage.getItem("bellDismissedOfflineIds")||"[]")}catch{return[]}}),ce=u.useMemo(()=>{if(!me)return[];const lt=new Set(me.filter(At=>At.monitoringDisabled).map(At=>At.edgeDeviceId)),Rt=new Map;for(const At of me)!At.cameraName&&!lt.has(At.edgeDeviceId)&&Rt.set(At.edgeDeviceId,At.isOnline);return[...Rt.entries()].filter(([,At])=>!At).map(([At])=>At)},[me]),Pe=ce.length,et=ce.some(lt=>!ge.includes(lt)),{data:$e}=ze({queryKey:["/api/device-notifications/smart-alert-events",""],queryFn:async()=>{const lt=await fetch("/api/device-notifications/smart-alert-events",{credentials:"include"});if(!lt.ok)throw new Error("Failed to fetch");return lt.json()},refetchInterval:6e4,select:lt=>lt.map(Rt=>({id:Rt.id,matchedAt:Rt.matchedAt,status:Rt.status}))}),[bt,Ae]=u.useState(()=>{try{return parseInt(localStorage.getItem("bellLastSeenSmartAlerts")||"0",10)}catch{return 0}}),Be=u.useMemo(()=>$e?$e.filter(lt=>(lt.status==="not_reviewed"||!lt.status)&&new Date(lt.matchedAt).getTime()>bt).length:0,[$e,bt]),J=u.useCallback(()=>{localStorage.setItem("bellDismissedOfflineIds",JSON.stringify(ce)),be(ce);const lt=Date.now();localStorage.setItem("bellLastSeenSmartAlerts",String(lt)),Ae(lt),s("/device-notifications")},[ce,s]),{data:ae,isLoading:we}=ze({queryKey:["/api/companies"]}),Qe=u.useMemo(()=>{const lt=new Map;if(!me)return lt;const Rt=new Set(me.filter(At=>At.monitoringDisabled).map(At=>At.edgeDeviceId));for(const At of me)!At.cameraName&&!Rt.has(At.edgeDeviceId)&&lt.set(At.edgeDeviceId,At.isOnline);return lt},[me]),ye=u.useMemo(()=>!ae||Qe.size===0?ae:ae.map(lt=>({...lt,sites:(lt.sites||[]).map(Rt=>{const At=Rt.edgeDevice?.id;if(!At||!Qe.has(At))return Rt;const Ht=Qe.get(At);return Rt.isOnline===Ht?Rt:{...Rt,isOnline:Ht}})})),[ae,Qe]),{data:te}=ze({queryKey:["/api/sites/restarting"],refetchInterval:lt=>{const Rt=lt.state.data;return!!Rt?.restartingSites&&Rt.restartingSites.length>0||se.current?3e3:5e3}}),Ue=u.useMemo(()=>{const lt=new Set(Q);return te?.restartingSites&&te.restartingSites.forEach(Rt=>lt.add(Rt)),lt},[Q,te]),We=u.useMemo(()=>{const lt=new Map;if(te?.entries)for(const Rt of te.entries)lt.set(Rt.siteId,Rt.kind);return Array.from(Q).forEach(Rt=>{lt.has(Rt)||lt.set(Rt,"soft")}),lt},[Q,te]),St=u.useRef(new Set);u.useEffect(()=>{const lt=St.current,Rt=[];if(lt.forEach(At=>{Ue.has(At)||Rt.push(At)}),Rt.length>
2860){Je.invalidateQueries({queryKey:["/api/companies"]}),Je.invalidateQueries({queryKey:["/api/device-notifications/status"]}),he(vr=>vr+1);const At=(ye||[]).flatMap(vr=>vr.sites||[]);let Ht=!1;Rt.forEach(vr=>{const mn=At.find(hr=>hr.id===vr);mn&&mn.isOnline&&(r({title:`${mn.name} is back online`,description:"Restart completed. Refreshing…"}),Ht=!0)}),Ht&&setTimeout(()=>{window.location.reload()},1200)}St.current=new Set(Ue),se.current=Ue.size>0},[Ue,ye]),u.useEffect(()=>{te?.restartingSites&&Y(lt=>{const Rt=te.restartingSites;let At=!1;const Ht=new Set(lt);return Array.from(lt).forEach(vr=>{Rt.includes(vr)||(Ht.delete(vr),At=!0)}),At?Ht:lt})},[te]);const{data:It}=ze({queryKey:["/api/user/role"]}),{data:ns}=ze({queryKey:["/api/user/settings"]}),dt=Et({mutationFn:async lt=>(await Ze("PATCH","/api/user/settings",{classicMatrixLayout:lt})).json(),onMutate:async lt=>{await Je.cancelQueries({queryKey:["/api/user/settings"]});const Rt=Je.getQueryData(["/api/user/settings"]);return Je.setQueryData(["/api/user/settings"],At=>At&&{...At,classicMatrixLayout:lt}),{previous:Rt}},onSuccess:lt=>Je.setQueryData(["/api/user/settings"],lt),onError:(lt,Rt,At)=>{At?.previous&&Je.setQueryData(["/api/user/settings"],At.previous),r({title:"Could not save matrix layout",description:"Please try again.",variant:"destructive"})},onSettled:()=>Je.invalidateQueries({queryKey:["/api/user/settings"]})}),Qt=It?.role||"user",Re=Qt==="superadmin"||Qt==="admin",pt=Re||Qt==="owner",Ft=Re;u.useEffect(()=>{H?.enforced&&ns&&!ns.mfaEnabled&&s("/account#mfa")},[H,ns,s]);const Es=(ns?.refreshRate||30)*1e3,Ge=(ns?.dashboardPreviewRate||10)*1e3,ft=ns?.dashboardPreviewLayout||1,He=ns?.dashboardPreviewCycling??!1,zt=ns?.companySortOrder||"asc",fs=ns?.customCompanyOrder||[],Ce=ns?.siteSortOrder||"asc",Dt=ns?.customSiteOrder||[],ne=lt=>[...lt].sort((Rt,At)=>{if(Ce==="custom"&&Dt.length>0){const Ht=Dt.indexOf(Rt.id),vr=Dt.indexOf(At.id);return Ht===-1&&vr===-1?zi(Rt.name,At.name):Ht===-1?1:vr===-1?-1:Ht-vr}else return Ce==="desc"?zi(At.name,Rt.name):zi(Rt.name,At.name)}),Oe=ye?[...ye].sort((lt,Rt)=>{if(zt==="custom"&&fs.length>0){const At=fs.indexOf(lt.id),Ht=fs.indexOf(Rt.id);return At===-1&&Ht===-1?zi(lt.name,Rt.name):At===-1?1:Ht===-1?-1:At-Ht}else return zt==="desc"?zi(Rt.name,lt.name):zi(lt.name,Rt.name)}):[],De=u.useMemo(()=>{if(!Z.trim())return Oe;const lt=Z.toLowerCase().trim();return Oe.map(Rt=>{if(Rt.name.toLowerCase().includes(lt))return Rt;const Ht=Rt.sites.filter(vr=>vr.name.toLowerCase().includes(lt));return Ht.length>0?{...Rt,sites:Ht}:null}).filter(Boolean)},[Oe,Z]),jt=Et({mutationFn:lt=>Ze("PATCH","/api/user/settings",{customCompanyOrder:lt}),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/user/settings"]})},onError:()=>{r({title:"Error",description:"Failed to save company order",variant:"destructive"})}}),Ct=Et({mutationFn:lt=>Ze("PATCH","/api/user/settings",{customSiteOrder:lt}),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/user/settings"]})},onError:()=>{r({title:"Error",description:"Failed to save company order",variant:"destructive"})}}),Lt=Et({mutationFn:()=>Ze("POST","/api/sites/check-status"),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/companies"]}),Ut()},onError:()=>{}}),xr=Ue.size>0;u.useEffect(()=>{const lt=setInterval(()=>{Lt.mutate()},xr?5e3:Es);return()=>clearInterval(lt)},[Es,xr]);const qe=Et({mutationFn:lt=>Ze("DELETE",`/api/companies/${lt}`),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/companies"]}),r({title:"Company deleted",description:"The company group has been removed"}),k(!1),_(null)},onError:lt=>{const Rt=lt?.message||"Failed to delete company";r({title:"Error",description:Rt,variant:"destructive"})}}),Xt=Et({mutationFn:({siteId:lt,companyId:Rt})=>Ze("PATCH",`/api/sites/${lt}`,{companyId:Rt}),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/companies"]}),r({title:"Site moved",description:"Site has been moved to the new company"})},onError:(lt,{siteId:Rt,companyId:At})=>{let Ht={};try{Ht=JSON.parse((lt?.message||"").replace(/^\d{3}:\s*/,""))}catch{}if(Ht.code==="ACCESS_IMPACT_CONFIRMATION_REQUIRED"){const vr=ye?.flatMap(mn=>mn.sites).find(mn=>mn.id===Rt);if(vr){g(vr),c(vr.companyId),b(At),o(!0),r({title:"Review company move",description:"Review and save the move to confirm the accounts that will lose access."});return}}r({title:"Could not move site",description:Ht.message||"Failed to move site",variant:"destructive"})}}),Ut=u.useCallback(async()=>
286{if(!ye)return;x(!0);const lt=ye.flatMap(At=>At.sites),Rt={};await Promise.all(lt.map(async At=>{Rt[At.id]=!!At.isOnline})),w(Rt),x(!1)},[ye]);u.useEffect(()=>{ye&&ye.length>0&&Ut()},[ye,Ut]);const gt=lt=>!!lt.isOnline,es=async lt=>{window.open(`/api/edge-login/${lt.id}`,"_blank")},br=lt=>{b(null),c(lt),g(null),o(!0)},fr=lt=>{b(null),c(lt.companyId),g(lt),o(!0)},xn=lt=>{h(lt),a(!0)},Br=()=>{h(null),a(!0)},Pi=lt=>{_(lt),k(!0)},Qn=()=>{S&&qe.mutate(S.id)},ii=lt=>{const{active:Rt}=lt,At=Rt.id,Ht=ye?.flatMap(vr=>vr.sites).find(vr=>vr.id===At);Ht&&T(Ht)},ua=lt=>{const{active:Rt,over:At}=lt;if(T(null),!At)return;const Ht=Rt.id,vr=At.id,mn=Rt.data.current,hr=At.data.current,Sn=mn?.type==="company";if(Sn&&zt==="custom"){if(hr?.type==="company"&&Ht!==vr){const Sr=Oe.findIndex(ur=>ur.id===Ht),Os=Oe.findIndex(ur=>ur.id===vr);if(Sr!==-1&&Os!==-1){const ur=eC(Oe.map(nr=>nr.id),Sr,Os);jt.mutate(ur)}}}else if(!Sn){const Sr=Ht,Os=ye?.flatMap(qr=>qr.sites).find(qr=>qr.id===Sr);if(!Os)return;const ur=ye?.flatMap(qr=>qr.sites).find(qr=>qr.id===vr);if(ur&&Os.companyId===ur.companyId&&Sr!==vr&&Ce==="custom"){const qr=ne(ye?.find(Jr=>Jr.id===Os.companyId)?.sites||[]),So=qr.findIndex(Jr=>Jr.id===Sr),Xn=qr.findIndex(Jr=>Jr.id===vr);if(So!==-1&&Xn!==-1){const vn=(Dt.length>0?[...Dt]:ye?.flatMap(Dr=>ne(Dr.sites).map(en=>en.id))||[]).filter(Dr=>Dr!==Sr),Mn=vn.indexOf(vr);vn.splice(Mn>=0?So<Xn?Mn+1:Mn:vn.length,0,Sr),Ct.mutate(vn)}return}if(!Ft)return;let nr=vr;hr?.companyId?nr=hr.companyId:vr.startsWith("drop-")&&(nr=vr.replace("drop-","")),Os.companyId!==nr&&Xt.mutate({siteId:Sr,companyId:nr})}},Ua=lt=>{const{active:Rt,over:At}=lt;if(T(null),!At||Ce!=="custom")return;const Ht=Rt.id,vr=At.id;if(Ht===vr)return;const mn=ye?.flatMap(nr=>nr.sites)||[],Sn=ne(mn).map(nr=>nr.id),Sr=Dt.length>0?[...Dt.filter(nr=>Sn.includes(nr)),...Sn.filter(nr=>!Dt.includes(nr))]:Sn,Os=Sr.indexOf(Ht),ur=Sr.indexOf(vr);Os===-1||ur===-1||Ct.mutate(eC(Sr,Os,ur))},Ln=u.useCallback(async(lt,Rt,At)=>{try{const vr=await(await Ze("PUT",`/api/sites/${lt}/cameras/batch-rename`,{renames:[{oldName:Rt,newName:At}]})).json();return vr.success?(r({title:"Display name saved"}),he(mn=>mn+1),!0):(r({title:"Failed to save",description:vr.error||"Unknown error",variant:"destructive"}),!1)}catch(Ht){return r({title:"Failed to save",description:Ht?.message||"Network error",variant:"destructive"}),!1}},[r]),Ir=u.useCallback(lt=>{Y(Rt=>new Set(Rt).add(lt)),se.current=!0,Je.invalidateQueries({queryKey:["/api/sites/restarting"]})},[]),Hr=u.useCallback(lt=>{Y(Rt=>{const At=new Set(Rt);return At.delete(lt),At})},[]);return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between h-16 gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:e.appEmblemUrl||Tm,alt:e.brandName,className:"w-10 h-10 object-contain"}),t.jsx("span",{className:"text-xl font-light text-foreground hidden sm:inline",children:e.productName})]}),t.jsx(qd,{onRefresh:()=>window.location.reload(),onBellClick:J,offlineCount:Pe,hasNewOffline:et,newSmartAlertCount:Be})]})})}),(le>0||ue)&&t.jsx("div",{className:"flex items-center justify-center overflow-hidden transition-[height] duration-150 ease-out",style:{height:ue?56:le*.7},"data-testid":"pull-to-refresh-indicator",children:t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(tl,{className:`w-5 h-5 transition-transform duration-200 ${ue?"animate-spin":""}`,style:{transform:ue?void 0:`rotate(${Math.min(le/80,1)*360}deg)`}}),t.jsx("span",{children:ue?"Refreshing...":fe?"Release to refresh":"Pull down to refresh"})]})}),t.jsxs("main",{className:"max-w-7xl mx-auto px-2 sm:px-6 lg:px-8 py-8",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4 mb-8",children:[t.jsxs("div",{className:"relative flex-1 w-full sm:w-auto",children:[t.jsx(yc,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none"}),t.jsx(ke,{placeholder:"Search...",value:Z,onChange:lt=>ee(lt.target.value),className:"pl-8 pr-8 w-full","data-testid":"input-search-dashboard"}),Z&&t.jsx("button",{onClick:()=>ee(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","data-testid":"button-clear-search",children:t.jsx(va,{className:"w-4 h-4"})})]}),t.jsxs("div",{className:"flex w-full sm:w-auto items-center gap-2 flex-wrap justify-center sm:justify-end sm:shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 whitespace-nowrap",children:[t.jsxs("div",{className:"flex items-center border border-border rounded-md",children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`h-9 w-9 max-[350px]:h-8 max-[350px]:w-8 rounded-r-none ${M==="classic"?"bg-muted":""}`,onClick:()=>{R("classic"),localStorage.setItem("dashboard_viewMode","classic")},"aria-label":"Classic View",title:"Classic View","data-testid":"button-view-classic",children:t.jsx(JI,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Classic View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`h-9 w-9 max-[350px]:h-8 max-[350px]:w-8 rounded-none ${M==="grid"?"bg-muted":""}`,onClick:()=>{R("grid"),localStorage.setItem("dashboard_viewMode","grid")},"data-testid":"button-view-grid",children:t.jsx(Cy,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Grid View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`h-9 w-9 max-[350px]:h-8 max-[350px]:w-8 rounded-none ${M==="list"?"bg-muted":""}`,onClick:()=>{R("list"),localStorage.setItem("dashboard_viewMode","list")},"data-testid":"button-view-list",children:t.jsx(ude,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"List View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`h-9 w-9 max-[350px]:h-8 max-[350px]:w-8 rounded-l-none ${M==="map"?"bg-muted":""}`,onClick:()=>{R("map"),localStorage.setItem("dashboard_viewMode","map")},"aria-label":"Map View",title:"Map View","data-testid":"button-view-map",children:t.jsx(pde,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Map View"})]})]}),t.jsx("div",{className:"border-l h-6","aria-hidden":"true"}),t.jsxs("div",{className:"flex items-center border border-border rounded-md",children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:"h-9 w-9 max-[350px]:h-8 max-[350px]:w-8 rounded-r-none",onClick:()=>
286s("/multi-live-view"),"data-testid":"button-edge-plus-live-view",children:t.jsx(Vi,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Edge+ Live View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:"h-9 w-9 max-[350px]:h-8 max-[350px]:w-8 rounded-none",onClick:()=>s("/multi-recordings"),"data-testid":"button-edge-plus-retrieval",children:t.jsx(cn,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Edge+ Retrieval"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:"h-9 w-9 max-[350px]:h-8 max-[350px]:w-8 rounded-l-none",onClick:()=>s("/video-export"),"data-testid":"button-video-export",children:t.jsx(ya,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Video Export"})]})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 px-1 sm:px-2 py-1 rounded-md border border-border cursor-pointer",onClick:()=>{const lt=!G;z(lt),localStorage.setItem("dashboard_hideCompanies",String(lt))},"data-testid":"toggle-hide-companies",children:[t.jsx(sr,{checked:G,onCheckedChange:lt=>{z(lt),localStorage.setItem("dashboard_hideCompanies",String(lt))},className:"scale-90","aria-label":"Sites Only"}),t.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap sm:hidden",children:"Sites"}),t.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap hidden sm:inline",children:"Sites Only"})]})}),t.jsx(Yt,{children:"Hide company groupings and show all sites together"})]})]}),Ft&&!G&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{onClick:Br,"data-testid":"button-add-company",children:[t.jsx(Fo,{className:"w-4 h-4 mr-2"}),t.jsx("span",{children:"Add Company"})]})}),t.jsx(Yt,{className:"sm:hidden",children:"Add Company"})]})]})]}),we?t.jsx("div",{className:"space-y-6",children:[1,2].map(lt=>t.jsxs(ut,{children:[t.jsx(xs,{children:t.jsx(Bt,{className:"h-6 w-48"})}),t.jsx(mt,{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(Rt=>t.jsx(Bt,{className:"h-40"},Rt))})]},lt))}):Z&&De.length===0?t.jsx(ut,{className:"p-12 text-center",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-muted flex items-center justify-center",children:t.jsx(yc,{className:"w-8 h-8 text-muted-foreground"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"No results found"}),t.jsxs("p",{className:"text-muted-foreground",children:['No companies or sites match "',Z,'"']})]}),t.jsx(L,{variant:"outline",onClick:()=>ee(""),"data-testid":"button-clear-search-empty",children:"Clear search"})]})}):ye?.length===0?t.jsx(ut,{className:"p-12 text-center",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-muted flex items-center justify-center",children:t.jsx(xi,{className:"w-8 h-8 text-muted-foreground"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"No companies yet"}),t.jsx("p",{className:"text-muted-foreground",children:Ft?"Get started by adding your first company to organize your sites.":"Contact your administrator to add companies and sites."})]}),Ft&&t.jsxs(L,{onClick:Br,"data-testid":"button-add-first-company",children:[t.jsx(Fo,{className:"w-4 h-4 mr-2"}),"Add Company"]})]})}):M==="map"?t.jsx($we,{sites:ne(De.flatMap(lt=>lt.sites)),isLoading:we,canEditSite:lt=>Re||Qt==="owner"&&!!It?.manageableCompanyIds?.includes(lt.companyId),canEditFloors:Re||Qt==="owner",canOpenDeviceSettings:pt,restartingSites:Ue,onEditSite:fr,onOpenCamera:(lt,Rt,At)=>$({site:lt,camera:Rt,cameras:At})}):M==="classic"?t.jsx(nve,{companies:De,initialSelectedSiteId:rje(window.location.search),hideCompanies:G,canOpenDeviceSettings:pt,canManageSite:lt=>G?pt:Re||Qt==="owner"&&It?.companyId===lt.companyId,canRestartSite:Ft,isSiteReachable:gt,restartingKinds:We,onEditSite:fr,onRestartSite:lt=>{q({...lt}),K(!0)},deviceStatuses:me,restartingSites:Ue,onLive:(lt,Rt,At)=>$({site:lt,camera:Rt,cameras:At}),matrixLayout:ns?.classicMatrixLayout===4?4:9,matrixLayoutSaving:dt.isPending||!ns,onMatrixLayoutChange:lt=>dt.mutate(lt),renderSiteMetrics:lt=>t.jsx(ZJ,{site:lt,isOnline:lt.isOnline??!1,variant:"classic"})}):G?(()=>{const lt=De.flatMap(Ht=>Ht.sites),{online:Rt,offline:At}=tje(lt);return lt.length===0?t.jsx(ut,{className:"p-12 text-center",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-muted flex items-center justify-center",children:t.jsx(yc,{className:"w-8 h-8 text-muted-foreground"})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"No sites found"}),t.jsx("p",{className:"text-muted-foreground",children:"No sites match your search"})]})]})}):M==="list"?t.jsxs("div",{className:"space-y-8",children:[Rt.length>0&&t.jsx("div",{className:"grid gap-2",children:ne(Rt).map(Ht=>
286t.jsx(dC,{site:Ht,isAdmin:Ft,canManage:pt,isOwnerOrAbove:pt,isReachable:gt(Ht),isRestarting:Ue.has(Ht.id),restartingKind:We.get(Ht.id),onLaunch:es,onEdit:fr,onMarkRestarting:Ir,onClearRestarting:Hr},Ht.id))}),At.length>0&&t.jsxs("section",{className:"space-y-3","data-testid":"section-offline-sites",children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-border pb-2",children:[t.jsx(kg,{className:"w-4 h-4 text-destructive"}),t.jsx("h2",{className:"text-sm font-semibold uppercase tracking-wide",children:"Offline"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",At.length,")"]})]}),t.jsx("div",{className:"grid gap-2",children:ne(At).map(Ht=>t.jsx(dC,{site:Ht,isAdmin:Ft,canManage:pt,isOwnerOrAbove:pt,isReachable:!1,isRestarting:Ue.has(Ht.id),restartingKind:We.get(Ht.id),onLaunch:es,onEdit:fr,onMarkRestarting:Ir,onClearRestarting:Hr},Ht.id))})]})]}):t.jsxs(O6,{sensors:je,collisionDetection:C6,onDragStart:ii,onDragEnd:Ua,children:[t.jsxs("div",{className:"space-y-8",children:[Rt.length>0&&(Ce==="custom"?t.jsx(a0,{items:ne(Rt).map(Ht=>Ht.id),strategy:Oy,children:t.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:ne(Rt).map(Ht=>t.jsx(uC,{site:Ht,isAdmin:Ft,canManage:pt,isOwnerOrAbove:pt,isReachable:!0,previewCycleInterval:Ge,previewLayout:ft,previewCycling:He,onLaunch:es,onEdit:fr,onSaveDisplayName:Ln,isRestarting:Ue.has(Ht.id),restartingKind:We.get(Ht.id),onMarkRestarting:Ir,onClearRestarting:Hr,cameraRefetchKey:oe},Ht.id))})}):t.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:ne(Rt).map(Ht=>t.jsx(mC,{site:Ht,isAdmin:Ft,canManage:pt,isOwnerOrAbove:pt,isReachable:!0,previewCycleInterval:Ge,previewLayout:ft,previewCycling:He,onLaunch:es,onEdit:fr,onSaveDisplayName:Ln,isRestarting:Ue.has(Ht.id),restartingKind:We.get(Ht.id),onMarkRestarting:Ir,onClearRestarting:Hr,cameraRefetchKey:oe},Ht.id))})),At.length>0&&t.jsxs("section",{className:"space-y-3","data-testid":"section-offline-sites",children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-border pb-2",children:[t.jsx(kg,{className:"w-4 h-4 text-destructive"}),t.jsx("h2",{className:"text-sm font-semibold uppercase tracking-wide",children:"Offline"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",At.length,")"]})]}),Ce==="custom"?t.jsx(a0,{items:ne(At).map(Ht=>Ht.id),strategy:Oy,children:t.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:ne(At).map(Ht=>t.jsx(uC,{site:Ht,isAdmin:Ft,canManage:pt,isOwnerOrAbove:pt,isReachable:!1,previewCycleInterval:Ge,previewLayout:ft,previewCycling:He,onLaunch:es,onEdit:fr,onSaveDisplayName:Ln,isRestarting:Ue.has(Ht.id),restartingKind:We.get(Ht.id),onMarkRestarting:Ir,onClearRestarting:Hr,cameraRefetchKey:oe},Ht.id))})}):t.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:ne(At).map(Ht=>t.jsx(mC,{site:Ht,isAdmin:Ft,canManage:pt,isOwnerOrAbove:pt,isReachable:!1,previewCycleInterval:Ge,previewLayout:ft,previewCycling:He,onLaunch:es,onEdit:fr,onSaveDisplayName:Ln,isRestarting:Ue.has(Ht.id),restartingKind:We.get(Ht.id),onMarkRestarting:Ir,onClearRestarting:Hr,cameraRefetchKey:oe},Ht.id))})]})]}),t.jsx($6,{children:A&&t.jsx("div",{className:"bg-card border border-primary rounded-lg p-4 shadow-lg opacity-90",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Cg,{className:"w-5 h-5 text-primary"}),t.jsx("span",{className:"font-medium",children:A.name})]})})})]})})():t.jsxs(O6,{sensors:je,collisionDetection:C6,onDragStart:ii,onDragEnd:ua,children:[t.jsx(a0,{items:De.map(lt=>lt.id),strategy:Zye,disabled:zt!=="custom",children:t.jsx("div",{className:"space-y-8",children:De.map(lt=>zt==="custom"?t.jsx(mje,{company:lt,isAdmin:Ft,canManage:Re||Qt==="owner"&&It?.companyId===lt.id,isOwnerOrAbove:pt,previewCycleInterval:Ge,previewLayout:ft,previewCycling:He,viewM
286ode:M,onEditCompany:xn,onDeleteCompany:Pi,onAddSite:br,onLaunch:es,onEditSite:fr,isSiteReachable:gt,onSaveDisplayName:Ln,restartingSites:Ue,restartingKinds:We,onMarkRestarting:Ir,onClearRestarting:Hr,cameraRefetchKey:oe,sortSites:ne,siteSortOrder:Ce},lt.id):t.jsx(hje,{company:lt,isAdmin:Ft,canManage:Re||Qt==="owner"&&It?.companyId===lt.id,isOwnerOrAbove:pt,previewCycleInterval:Ge,previewLayout:ft,previewCycling:He,viewMode:M,onEditCompany:xn,onDeleteCompany:Pi,onAddSite:br,onLaunch:es,onEditSite:fr,isSiteReachable:gt,onSaveDisplayName:Ln,restartingSites:Ue,restartingKinds:We,onMarkRestarting:Ir,onClearRestarting:Hr,cameraRefetchKey:oe,sortSites:ne,siteSortOrder:Ce},lt.id))})}),t.jsx($6,{children:A&&t.jsx("div",{className:"bg-card border border-primary rounded-lg p-4 shadow-lg opacity-90",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Cg,{className:"w-5 h-5 text-primary"}),t.jsx("span",{className:"font-medium",children:A.name})]})})})]})]}),t.jsx(u3,{open:n,onOpenChange:a,company:d,onCreated:()=>{G&&(z(!1),localStorage.setItem("dashboard_hideCompanies","false"))}}),t.jsx(yJ,{open:i,onOpenChange:o,companyId:l,site:p,isAdmin:Ft,companyName:ye?.find(lt=>lt.id===p?.companyId)?.name,initialCompanyId:v}),O&&t.jsx(XO,{site:O,open:V,onOpenChange:lt=>{K(lt),lt||q(null)},onMarkRestarting:Ir,onClearRestarting:Hr}),D&&t.jsx(x3,{open:!0,onOpenChange:lt=>{lt||$(null)},siteId:D.site.id,siteName:D.site.name,cameraName:D.camera.name,allCameras:D.cameras,canRename:pt,onSaveDisplayName:Ln},`${D.site.id}:${D.camera.name}`),t.jsx(zd,{open:C,onOpenChange:k,children:t.jsxs(bd,{children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:"Delete Company Group"}),t.jsx(Sd,{children:S&&S.sites.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-destructive font-medium",children:['Cannot delete "',S.name,'"']}),t.jsx("br",{}),t.jsx("br",{}),"This company group contains ",S.sites.length," site(s). Please move or delete all sites before deleting this group."]}):t.jsxs(t.Fragment,{children:['Are you sure you want to delete "',S?.name,'"? This action cannot be undone.']})})]}),t.jsxs(jd,{children:[t.jsx(Gc,{children:"Cancel"}),S&&S.sites.length===0&&t.jsx(Cd,{onClick:Qn,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function aje({siteId:e,isOnline:s,variant:r="card"}){const[n,a]=u.useState(null),[i,o]=u.useState(!0),[l,c]=u.useState(!1);if(u.useEffect(()=>{if(!s){o(!1);return}let j=!1,x=null,C=null;const k=1e3+Array.from(e).reduce((T,M)=>T*31+M.charCodeAt(0)>>>0,0)%1e4,S=T=>{x&&clearTimeout(x),x=null,!(j||document.visibilityState==="hidden")&&(x=setTimeout(_,T))},_=async()=>{if(j||document.visibilityState==="hidden")return;C=new AbortController;const T=setTimeout(()=>C?.abort(),15e3);try{const M=await fetch(`/api/sites/${e}/stats`,{credentials:"include",signal:C.signal});if(M.ok){const R=await M.json();a(R),c(!1)}else c(!0)}catch{c(!0)}finally{clearTimeout(T),C=null,o(!1),S(3e4)}},A=()=>{if(document.visibilityState==="hidden"){x&&clearTimeout(x),x=null,C?.abort();return}S(k)};return S(k),document.addEventListener("visibilitychange",A),()=>{j=!0,x&&clearTimeout(x),C?.abort(),document.removeEventListener("visibilitychange",A)}},[e,s]),!s)return t.jsx("div",{className:`text-xs text-muted-foreground/50 min-w-0 ${r==="classic"?"lg:contents":""}`,"data-testid":`nvr-stats-${e}`,children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(uf,{className:"w-3 h-3 shrink-0"}),t.jsx("span",{className:"whitespace-nowrap",children:"CPU: N/A"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(vc,{className:"w-3 h-3 shrink-0"}),t.jsx("span",{className:"whitespace-nowrap",children:"GPU: N/A"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Fa,{className:"w-3 h-3 shrink-0"}),t.jsx("span",{className:"whitespace-nowrap",children:"N/A TB free"})]})]})});if(i||l||!n)return null;const d=n.gpus.length>0?n.gpus[0]:null,p=d?(j=>{if(typeof j=="number")return j.toFixed(1);if(typeof j=="string"){const x=j.replace("%","").trim();return x==="-"||x===""||isNaN(parseFloat(x))?null:x}return null})(d.gpu):null,g=p?parseFloat(p):0,v=n.cpu>=95?"text-red-500":"text-blue-500",b=g>=95?"text-red-500":"text-blue-500",y="text-blue-500",w=j=>{const x=Math.floor(j/86400),C=Math.floor(j%86400/3600),k=Math.floor(j%3600/60);return x>0?`${x}d ${C}h ${k}m`:C>0?`${C}h ${k}m`:`${k}m`};return t.jsxs("div",{className:`text-xs min-w-0 ${r==="classic"?"lg:contents":""}`,"data-testid":`nvr-stats-${e}`,children:[n.uptime!=null&&t.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[t.jsx(cn,{className:"w-3 h-3 shrink-0"}),t.jsxs("span",{className:"whitespace-nowrap",children:["Edge Uptime: ",w(n.uptime)]})]}),t.jsxs("div",{className:r==="classic"?"lg:flex lg:items-center lg:gap-x-3 lg:flex-nowrap":"",children:[t.jsxs("div",{className:"flex items-center gap-x-3 gap-y-1",children:[t.jsxs("div",{className:`flex items-center gap-1 ${v}`,children:[t.jsx(uf,{className:"w-3 h-3 shrink-0"}),t.jsxs("span",{className:"whitespace-nowrap",children:["CPU: ",n.cpu.toFixed(1),"%"]})]}),p&&t.jsxs("div",{className:`flex items-center gap-1 ${b}`,children:[t.jsx(vc,{className:"w-3 h-3 shrink-0"}),t.jsxs("span",{className:"whitespace-nowrap",children:["GPU: ",p,"%"]})]})]}),n.storage&&t.jsxs("div",{className:`flex items-center gap-1 ${y}`,children:[t.jsx(Fa,{className:"w-3 h-3 shrink-0"}),t.jsxs("span",{className:"whitespace-nowrap",children:[n.storage.free.toFixed(2)," TB free / ",n.storage.total.toFixed(2)," TB Total"]})]})]})]})}function ije({siteId:e,isOnline:s}){const{data:r}=ze({queryKey:["/api/sites",e,"oldest-recording"],queryFn:()=>fetch(`/api/sites/${e}/oldest-recording`,{credentials:"include"}).then(o=>o.ok?o.json():null),enabled:s,staleTime:3e5,retry:!1});if(!r?.oldest)return null;const n=r.cloudEnabled&&r.cloudOldest?r.cloudOldest:r.oldest,a=new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return t.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground","data-testid":`oldest-recording-${e}`,children:[t.jsx(ro,{className:"w-3 h-3 shrink-0"}),t.jsxs("span",{className:"whitespace-nowrap",children:["Oldest Recording",": ",a]})]})}function ZJ({site:e,isOnline:s,variant:r="card"}){const{data:n}=ze({queryKey:["/api/user/settings"]}),{user:a}=Gi(),i=a?.showLocation!==!1,o=n?.showOldestRecording??!0,l=n?.showSystemMetrics??!1,c=e.edgeDevice,d=[c?.city,c?.region].filter(
286Boolean).join(", ");return!(i&&d)&&!o&&!l?null:t.jsxs("div",{"data-testid":r==="classic"?"classic-site-metrics":void 0,className:r==="classic"?"shrink-0 border-t border-border bg-muted/20 px-4 sm:px-5 py-3 flex flex-wrap items-start gap-x-6 gap-y-1 empty:hidden":"space-y-0.5",children:[i&&d&&t.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground min-w-0",children:[t.jsx(ql,{className:"w-3 h-3 shrink-0"}),t.jsx("span",{className:"truncate",children:d})]}),o&&t.jsx(ije,{siteId:e.id,isOnline:s}),l&&t.jsx(aje,{siteId:e.id,isOnline:s,variant:r})]})}const g1=[{value:1,label:"1",cols:1,rows:1},{value:4,label:"4",cols:2,rows:2},{value:9,label:"9",cols:3,rows:3},{value:16,label:"16",cols:4,rows:4},{value:32,label:"32",cols:8,rows:4},{value:64,label:"64",cols:8,rows:8}];function oje({cols:e,rows:s,active:r,dark:n}){const a=Math.min(e,4),i=Math.min(Math.max(1,Math.round(s*a/e)),4),o=r?"fill-primary-foreground":n?"fill-white/50":"fill-muted-foreground/60",l=.8,c=16,d=(c-l*(a-1))/a,h=(c-l*(i-1))/i;return t.jsx("svg",{width:c,height:c,viewBox:`0 0 ${c} ${c}`,className:"shrink-0",children:Array.from({length:i}).map((p,g)=>Array.from({length:a}).map((v,b)=>t.jsx("rect",{x:b*(d+l),y:g*(h+l),width:d,height:h,rx:e===1?2:.5,className:o},`${g}-${b}`)))})}function x3({open:e,onOpenChange:s,siteId:r,siteName:n,cameraName:a,allCameras:i,canRename:o=!1,onCameraRenamed:l,onSaveDisplayName:c}){const[,d]=Ia(),{data:h}=ze({queryKey:["/api/user/role"]}),p=h?.role==="admin"||h?.role==="superadmin",{data:g}=ze({queryKey:["/api/sites",r,"my-permissions"],enabled:e}),v=!!g?.privacyBlocked,[b,y]=u.useState(a),[w,j]=u.useState(0),[x,C]=u.useState(!1),[k,S]=u.useState(!1),[_,A]=u.useState(!1),[T,M]=u.useState(!1),[R,D]=u.useState(""),[$,O]=u.useState({}),[q,V]=u.useState(1),[K,G]=u.useState(0),[z,Z]=u.useState(null),[ee,Q]=UO(r),Y=u.useRef(null),[oe,he]=u.useState(!1),[je,pe]=u.useState(()=>window.innerHeight>window.innerWidth),[le,ue]=u.useState(()=>Math.min(window.innerWidth,window.innerHeight)<640),[fe,H]=u.useState(!0),se=u.useRef(null),[me,ge]=u.useState(1),be=u.useRef(0),ce=u.useRef(0);Hs();const{data:Pe}=ze({queryKey:["/api/sites",r,"stream-options"],staleTime:300*1e3});Pe?.useRtc,u.useEffect(()=>{const De=()=>{he(window.innerWidth<640),pe(window.innerHeight>window.innerWidth),ue(Math.min(window.innerWidth,window.innerHeight)<640)};return De(),window.addEventListener("resize",De),()=>window.removeEventListener("resize",De)},[]),u.useEffect(()=>{if(!e||!le||je)return;const De=b||a,jt=q===1?De:z||De;s(!1),d(`/live/${r}/${encodeURIComponent(jt)}`)},[le,je,e]);const et=oe?g1.filter(De=>De.value===1||De.value===4||De.value===9||De.value===16):g1;u.useEffect(()=>{oe&&q!==1&&q!==4&&q!==9&&q!==16&&V(16)},[oe,q]);const $e=De=>{be.current=De.touches[0].clientX,ce.current=De.touches[0].clientY},bt=De=>{if(me>1)return;const jt=De.changedTouches[0].clientX-be.current,Ct=Math.abs(De.changedTouches[0].clientY-ce.current);Math.abs(jt)>50&&Math.abs(jt)>Ct&&Qe.length>1&&(jt<0?pt():Re())},Ae=De=>{for(const[jt,Ct]of Object.entries($))if(Ct===De)return jt;return De},Be=De=>$[De]?$[De]:i.find(Ct=>Ct.name===De)?.displayName||De;u.useEffect(()=>{const De=i.filter(Ct=>Ct.enabled),jt=De.some(Ct=>Ct.name===a);y(jt?a:De[0]?.name||a),C(!1),A(!1),O({}),Z(null),Y.current=null},[a,e,i]),u.useEffect(()=>{A(!1)},[b,r]);const{data:J}=ze({queryKey:["/api/user-settings"],enabled:e}),ae=Math.round(1e3/Math.max(1,Math.min(2,Pe?.jpegFps??1))),we=Math.max(1,Math.round(1e4/ae));u.useEffect(()=>{if(!e||x)return;const De=setInterval(()=>{j(jt=>jt+1)},ae);return()=>clearInterval(De)},[e,x,ae]),u.useEffect(()=>{if(!e||!k||q!==1)return;const De=(J?.previewCycleRate||5)*1e3,jt=setInterval(()=>{y(Ct=>{const Lt=i.filter(Xt=>Xt.enabled);if(Lt.length<=1)return Ct;const qe=(Lt.findIndex(Xt=>Xt.name===Ct)+1)%Lt.length;return Lt[qe].name}),A(!1)},De);return()=>clearInterval(jt)},[e,k,q,J?.previewCycleRate,i]);const Qe=i.filter(De=>De.enabled),ye=Qe.findIndex(De=>De.name===b),te=g1.find(De=>De.value===q)||g1[0],Ue=te.value,We=Math.max(1,Math.ceil(Qe.length/Ue)),St=Math.min(K,We-1),It=Qe.slice(St*Ue,St*Ue+Ue),ns=u.useCallback(()=>{se.current&&clearTimeout(se.current),se.current=setTimeout(()=>{oe&&!je&&H(!1)},3e3)},[oe,je]);u.useEffect(()=>{if(!e||!oe||je){se.current&&clearTimeout(se.current),H(!0);return}return H(!0),ns(),()=>{se.current&&clearTimeout(se.current)}},[e,oe,je,q,ns]);const dt=u.useCallback(()=>{!oe||je||H(De=>(De||ns(),!De))},[oe,je,ns]),Qt=u.useCallback(De=>{const jt=De.changedTouches[0].clientX-be.current,Ct=Math.abs(De.changedTouches[0].clientY-ce.current);Math.abs(jt)>50&&Math.abs(jt)>Ct&&(jt<0?G(Lt=>Math.min(Lt+1,We-1)):G(Lt=>Math.max(Lt-1,0)))},[We]),Re=()=>{if(Qe.length===0)return;const De=(ye-1+Qe.length)%Qe.length;y(Qe[De].name),A(!1)},pt=()=>{if(Qe.length===0)return;const De=(ye+1)%Qe.length;y(Qe[De].name),A(!1)},Ft=()=>{const jt=`/live/${r}/${encodeURIComponent(q===1?b:z||b)}`;if(!window.open(jt,"_blank")){window.location.assign(jt);return}s(!1)},Es=De=>{Z(jt=>jt===De?null:De)},Ge=De=>{Y.current={layout:q,page:K},V(1),y(De),Z(null),A(!1)},ft=()=>{Y.current&&(V(Y.current.layout),G(Y.current.page),Y.current=null,Z(null))},He=()=>{const De=q===1?b:z||b;D(Be(De)),y(De),M(!0)},[zt,fs]=u.useState(!1),Ce=async()=>
286{if(!b||!R.trim())return;const De=R.trim(),Ct=Ae(b);O(Lt=>({...Lt,[Ct]:De})),l?.(Ct,De),fs(!0);try{await c?.(r,Ct,De)}finally{fs(!1)}M(!1)},Dt=q===1?Be(b):z?Be(z):`${Qe.length} Cameras`,ne=352,Oe=288;return e&&v?t.jsx(Ys,{open:e,onOpenChange:s,children:t.jsxs(Ws,{className:"max-w-md","data-testid":"live-view-blocked",children:[t.jsxs(Zs,{children:[t.jsxs(Ks,{className:"flex items-center gap-2",children:[t.jsx(ka,{className:"w-4 h-4"})," Video hidden"]}),t.jsxs(cr,{children:["The owner of ",n," has turned on privacy. Live video is hidden from administrators."]})]}),t.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8 text-center",children:[t.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center",children:t.jsx(ka,{className:"w-7 h-7 text-muted-foreground"})}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-xs",children:"Ask the site owner to grant Temporary Support access if you need to view video for troubleshooting."})]})]})}):t.jsxs(t.Fragment,{children:[t.jsx(Ys,{open:e,onOpenChange:s,children:t.jsxs(Ws,{className:`p-0 gap-0 overflow-hidden flex flex-col ${oe?q!==1?je?"w-[95vw] max-w-[95vw] rounded-lg":"w-screen max-w-none rounded-none !m-0":je?"w-[95vw] max-w-[95vw] rounded-lg":"w-[90vw] max-w-[1400px]":"w-[90vw] max-w-[1400px]"}`,style:{height:q!==1&&oe&&!je?"100dvh":q!==1&&!oe?"80vh":"auto",maxHeight:oe?je?"85svh":q!==1?"100dvh":"100svh":"90vh"},"data-testid":"live-view-dialog",children:[t.jsxs(Zs,{className:`px-4 border-b border-white/10 flex flex-row items-center justify-between gap-2 space-y-0 shrink-0 bg-black/40 backdrop-blur-sm transition-all duration-300 ${fe?"py-2 opacity-100":"py-0 opacity-0 h-0 overflow-hidden pointer-events-none"}`,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Vi,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx(Ks,{className:`text-sm truncate ${oe&&je?"sr-only":""}`,"data-testid":"live-view-camera-name",children:Dt}),o&&(q===1||z)&&t.jsx(L,{variant:"ghost",size:"icon",className:"shrink-0 hidden sm:inline-flex",onClick:He,"data-testid":"live-view-rename-camera",children:t.jsx(ga,{className:"w-3.5 h-3.5"})}),t.jsx(cr,{className:"sr-only",children:"Live camera view"})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0 mr-6",children:[o&&(q===1||z)&&t.jsx(L,{variant:"ghost",size:"icon",className:"shrink-0 sm:hidden",onClick:He,"data-testid":"live-view-rename-camera-mobile",children:t.jsx(ga,{className:"w-3.5 h-3.5"})}),t.jsx("div",{className:"flex items-center gap-0.5 bg-muted/50 rounded-md p-0.5","data-testid":"live-view-layout-selector",children:et.map(De=>t.jsx("button",{onClick:()=>{V(De.value),G(0),Z(null),Y.current=null,De.value===1&&A(!1)},className:`flex items-center justify-center w-8 h-7 rounded transition-colors ${q===De.value?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:`${De.label} camera${De.value>1?"s":""}`,"data-testid":`live-view-layout-${De.value}`,children:t.jsx(oje,{cols:De.cols,rows:De.rows,active:q===De.value})},De.value))}),oe&&je?t.jsxs("button",{onClick:()=>Q(De=>De==="auto"?"main":De==="main"?"sub":De==="sub"?"jpeg":"auto"),className:"flex items-center gap-1 px-2 h-7 rounded-md bg-muted/50 text-xs font-medium text-foreground",title:"Stream source — tap to cycle Auto / Main / Sub / JPEG","data-testid":"live-view-stream-source-toggle",children:[t.jsx(hf,{className:"w-3.5 h-3.5 text-muted-foreground"}),ee==="auto"?"Auto":ee==="main"?"Main":ee==="sub"?"Sub":"JPEG"]}):t.jsxs("div",{className:"flex items-center gap-0.5 bg-muted/50 rounded-md p-0.5","data-testid":"live-view-stream-source-selector",children:[t.jsx(hf,{className:"w-3.5 h-3.5 text-muted-foreground mx-1 hidden sm:block"}),[{value:"auto",label:"Auto",title:"Auto — main stream for single view, sub stream for grids"},{value:"main",label:"Main",title:"Main stream — higher quality, more bandwidth"},{value:"sub",label:"Sub",title:"Sub stream — lower bandwidth"},{value:"jpeg",label:"JPEG",title:"JPEG — Image stills for lowest bandwidth"}].map(De=>t.jsx("button",{onClick:()=>Q(De.value),className:`flex items-center justify-center px-2 h-7 rounded text-xs font-medium transition-colors ${ee===De.value?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:De.title,"data-testid":`live-view-stream-source-${De.value}`,children:De.label},De.value))]}),!(oe&&je&&q===1)&&t.jsx(cC,{siteId:r}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>S(De=>!De),className:`toggle-elevate ${k?"toggle-elevated":""}`,"data-testid":"live-view-loop-toggle",children:t.jsx(tl,{className:`w-4 h-4 ${k?"animate-spin":""}`,style:k?{animationDuration:"3s"}:void 0})})}),t.jsx(Yt,{children:k?`Looping (${J?.previewCycleRate||5}s)`:"Auto-cycle cameras"})]}),t.jsx(L,{variant:"ghost",size:"icon",className:!oe||!je?"inline-flex":"hidden",onClick:Ft,"data-testid":"live-view-fullscreen",children:t.jsx(pf,{className:"w-4 h-4"})})]})]}),q===1?t.jsxs("div",{className:"relative bg-black flex items-center justify-center overflow-hidden w-full min-h-0",style:{aspectRatio:"16/9",maxHeight:oe&&je?"calc(85svh - 100px)":"calc(90vh - 100px)"},onTouchStart:$e,onTouchEnd:bt,onClick:dt,onDoubleClick:ft,children:[!_&&!i.find(De=>De.name===Ae(b))?.usesGo2rtc&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-8 h-8 border-2 border-primary border-t-transparent roun
286ded-full animate-spin"})}),t.jsx(jg,{testIdPrefix:"zoom-live-dialog",className:"absolute inset-0",doubleClickZoom:!1,onZoomChange:ge,children:i.find(De=>De.name===Ae(b))?.usesGo2rtc?t.jsx(Ly,{siteId:r,cameraName:Ae(b),className:"w-full h-full",refreshKey:w,objectFit:"contain",streamSource:ee,singleView:!0},Ae(b)):t.jsx(af,{src:`/api/sites/${r}/cameras/${encodeURIComponent(Ae(b))}/thumbnail?t=${w}&stream=record&live=1`,alt:Be(b),className:`w-full h-full object-contain transition-opacity ${_?"opacity-100":"opacity-0"}`,onLoad:()=>A(!0),onError:()=>A(!0),"data-testid":"live-view-image"})},`${r}|${Ae(b)}`),t.jsx(Q0,{siteId:r,cameraName:Ae(b),isAdmin:p}),oe&&je&&t.jsx("div",{className:"absolute bottom-2 left-2 z-20 rounded-md bg-black/40 backdrop-blur-sm",children:t.jsx(cC,{siteId:r})}),Qe.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{className:`absolute left-2 top-1/2 -translate-y-1/2 w-9 h-9 rounded-full bg-black/60 backdrop-blur-sm text-white/90 hover:bg-black/80 hover:text-white items-center justify-center transition-all z-20 ${oe?"hidden":"flex"}`,onClick:Re,"data-testid":"live-view-prev",children:t.jsx(Kl,{className:"w-5 h-5"})}),t.jsx("button",{className:`absolute right-2 top-1/2 -translate-y-1/2 w-9 h-9 rounded-full bg-black/60 backdrop-blur-sm text-white/90 hover:bg-black/80 hover:text-white items-center justify-center transition-all z-20 ${oe?"hidden":"flex"}`,onClick:pt,"data-testid":"live-view-next",children:t.jsx(hi,{className:"w-5 h-5"})})]})]}):t.jsx("div",{className:`bg-black overflow-hidden w-full ${le?"shrink-0":"min-h-0 flex-1"}`,onTouchStart:$e,onTouchEnd:Qt,onClick:dt,children:t.jsx("div",{className:"grid w-full",style:{gridTemplateColumns:`repeat(${te.cols}, 1fr)`,...le?{}:{gridTemplateRows:`repeat(${te.rows}, minmax(0, 1fr))`,height:"100%"}},"data-testid":"live-view-grid",children:Array.from({length:Ue}).map((De,jt)=>{const Ct=It[jt],Lt=le?{aspectRatio:"4/3"}:{};if(!Ct)return t.jsx("div",{className:"relative bg-black/80 border border-white/5 flex items-center justify-center overflow-hidden",style:Lt,children:t.jsx(wo,{className:"w-6 h-6 text-white/10"})},`empty-${jt}`);const xr=Ae(Ct.name),qe=Be(Ct.name),Xt=z===Ct.name,Ut=Math.floor((w+jt)/we);return t.jsxs("button",{type:"button",onClick:()=>Es(Ct.name),onDoubleClick:()=>Ge(Ct.name),className:`relative bg-black border transition-colors overflow-hidden select-none ${Xt?"border-primary border-2":"border-white/10"}`,style:Lt,"data-testid":`live-view-grid-cell-${Ct.name}`,children:[Ct.usesGo2rtc?t.jsx(Ly,{siteId:r,cameraName:xr,className:"absolute inset-0 w-full h-full",refreshKey:w,streamSource:ee,singleView:!1},xr):t.jsx(af,{src:`/api/sites/${r}/cameras/${encodeURIComponent(xr)}/thumbnail?t=${Ut}&w=${ne}&h=${Oe}&live=1`,alt:qe,className:"absolute inset-0 w-full h-full object-cover"}),t.jsx("span",{className:"absolute bottom-0 left-0 right-0 text-[10px] text-white bg-black/70 px-1 py-0.5 truncate z-10",children:qe}),Xt&&t.jsx(Q0,{siteId:r,cameraName:xr,isAdmin:p,compact:!0})]},Ct.name)})})}),t.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between gap-2 shrink-0",children:q===1&&Qe.length>1?t.jsx("div",{className:"flex items-center gap-1 overflow-x-auto flex-1",children:Qe.map(De=>{const jt=Be(De.name),Ct=Ae(De.name);return t.jsxs("button",{type:"button",onClick:()=>{y(De.name),A(!1)},className:`relative aspect-video w-20 shrink-0 rounded overflow-hidden border-2 transition-colors ${De.name===b?"border-primary":"border-transparent"}`,"data-testid":`live-view-cam-select-${De.name}`,children:[t.jsx(af,{src:`/api/sites/${r}/cameras/${encodeURIComponent(Ct)}/thumbnail?t=static`,alt:jt,loading:"eager",decoding:"async",className:"w-full h-full object-cover",compact:!0}),t.jsx("span",{className:"absolute bottom-0 left-0 right-0 text-[8px] text-white bg-black/60 px-0.5 truncate text-center",children:jt})]},De.name)})}):q>1&&We>1?t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx(L,{variant:"ghost",size:"sm",disabled:St===0,onClick:()=>G(De=>Math.max(0,De-1)),"data-testid":"live-view-grid-prev-page",children:t.jsx(Kl,{className:"w-4 h-4"})}),t.jsxs("span",{className:"text-xs text-muted-foreground","data-testid":"live-view-grid-page-info",children:["Page ",St+1," of ",We]}),t.jsx(L,{variant:"ghost",size:"sm",disabled:St>=We-1,onClick:()=>G(De=>Math.min(We-1,De+1)),"data-testid":"live-view-grid-next-page",children:t.jsx(hi,{className:"w-4 h-4"})})]}):t.jsx("div",{className:"flex-1"})})]})}),t.jsx(Ys,{open:T,onOpenChange:M,children:t.jsxs(Ws,{onClick:De=>De.stopPropagation(),children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Set Display Name"}
286),t.jsxs(cr,{children:["Set a friendly display name for ",t.jsx("strong",{children:b}),"."]})]}),t.jsxs("div",{className:"space-y-2 py-2",children:[t.jsx(re,{htmlFor:"liveview-camera-name",children:"Display Name"}),t.jsx(ke,{id:"liveview-camera-name",value:R,onChange:De=>D(De.target.value),placeholder:"e.g. Front Door","data-testid":"input-liveview-camera-name",onKeyDown:De=>{De.key==="Enter"&&Ce()}})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>M(!1),"data-testid":"button-cancel-liveview-rename",children:"Cancel"}),t.jsx(L,{onClick:Ce,disabled:!R.trim()||zt,"data-testid":"button-confirm-liveview-rename",children:zt?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):"Save"})]})]})})]})}const xF=3e5,lje=3e4,cje=15e3,x1=new Map,dje=3,vM=[];let SP=0;const JJ=()=>{for(;SP<dje&&vM.length>0;){const e=vM.shift();e.cancelled||(SP++,Promise.resolve().then(e.run).catch(()=>{}).finally(()=>{SP--,JJ()}))}},vF=e=>{const s={run:e,cancelled:!1};return vM.push(s),JJ(),()=>{s.cancelled=!0}},v1=new Map;function uje({siteId:e,siteName:s,isOnline:r,previewCycleInterval:n=1e4,previewLayout:a=1,cycling:i=!0,onCameraClick:o,canRename:l=!1,onSaveDisplayName:c,refetchKey:d=0}){const h=Er(),{user:p}=Gi(),g=p?.id?`${String(p.id)}:thumbnail-v3`:"",[v,b]=u.useState(0),[y,w]=u.useState(0),[j,x]=u.useState(!1),[C,k]=u.useState(null),[S,_]=u.useState(""),[A,T]=u.useState(!1),[M,R]=u.useState(!0),[D,$]=u.useState(0),[O,q]=u.useState(new Map),[V,K]=u.useState(new Set),[G,z]=u.useState(!1),Z=u.useRef(new Map([...v1.entries()].filter(([ae])=>ae.startsWith(`${g}:${e}:`)).map(([ae,we])=>[ae.slice(`${g}:${e}:`.length),we]))),[ee,Q]=u.useState(new Map(Z.current)),Y=u.useRef(new Map),oe=u.useRef(null),he=u.useRef(new Map),je=u.useRef(new Map),pe=u.useRef(new Set);u.useEffect(()=>()=>{he.current.forEach(clearTimeout),he.current.clear()},[]),Hs();const le=a===1?1:6,{data:ue,isLoading:fe,error:H}=ze({queryKey:["/api/sites",e,"cameras"],enabled:r,retry:(ae,we)=>!we?.message?.startsWith("401")&&ae<2,refetchInterval:ae=>ae.state.error&&!ae.state.error?.message?.startsWith("401")?2e4:!1}),se=ue?.cameras??[],me=u.useMemo(()=>se.filter(ae=>ae.enabled),[se]),ge=u.useMemo(()=>{if(a===1)return me.length===0?[]:[me[v%me.length]];const ae=y*le;return me.slice(ae,ae+le)},[me,v,y,a,le]);pe.current=new Set(me.map(ae=>ae.name));const be=H?H.message?.startsWith("401")?"credentials":"fetch":null,{data:ce}=ze({queryKey:["/api/sites",e,"my-permissions"],enabled:r}),Pe=!!ce?.privacyBlocked;u.useEffect(()=>{if(z(!1),!g||!r||ce===void 0)return;if(Pe){z(!0);return}let ae=!1;return vge(g,e,100).then(we=>{if(ae)return;let Qe=!1;for(const ye of we){if(Z.current.has(ye.cameraName))continue;const te=URL.createObjectURL(ye.blob);Z.current.set(ye.cameraName,te),v1.set(`${g}:${e}:${ye.cameraName}`,te),Qe=!0}Qe&&Q(new Map(Z.current))}).finally(()=>{ae||z(!0)}),()=>{ae=!0}},[g,r,ce,Pe,e]),u.useEffect(()=>{if(Pe){for(const[ae,we]of Z.current)we.startsWith("blob:")&&URL.revokeObjectURL(we),v1.delete(`${g}:${e}:${ae}`);Z.current.clear(),Q(new Map)}},[g,Pe,e]),u.useEffect(()=>{d>0&&Je.invalidateQueries({queryKey:["/api/sites",e,"cameras"]})},[d,e]);const et=u.useCallback(ae=>{const we=`${e}:${ae}`,Qe=x1.get(we),ye=Date.now();if(Qe&&ye-Qe.fetchedAt<xF)return Qe.url;const te=`/api/sites/${e}/cameras/${encodeURIComponent(ae)}/thumbnail?w=352&h=288&format=webp&quality=72&t=${ye}`;return x1.set(we,{url:te,fetchedAt:ye}),te},[e]);if(u.useEffect(()=>{if(!r||be||Pe||me.length===0)return;const ae=new Map;me.forEach(we=>{ae.set(we.name,et(we.name))}),q(ae)},[r,be,Pe,me,et]),u.useEffect(()=>{if(!r||be||Pe||me.length===0)return;const ae=setInterval(()=>{const we=new Map;me.forEach(Qe=>{const ye=`${e}:${Qe.name}`;x1.delete(ye),we.set(Qe.name,et(Qe.name))}),q(we)},xF);return()=>clearInterval(ae)},[r,be,Pe,me,e,et]),u.useEffect(()=>{if(!G||!r||be||Pe||se.length===0)return;const ae=new AbortController,we=[...O.entries()],Qe=[],ye=[],te=async([St,It])=>{if(!ae.signal.aborted&&Y.current.get(St)!==It){Y.current.set(St,It);try{const ns=await fetch(It,{credentials:"include",signal:ae.signal});if(!ns.ok)throw ns.headers?.get?.("X-Camera-Stream-Error")==="1"&&K(pt=>new Set(pt).add(`${e}:${St}`)),new Error(`${ns.status}`);const dt=await ns.blob();if(ae.signal.aborted)return;je.current.delete(St),K(pt=>{if(!pt.has(`${e}:${St}`))return pt;const Ft=new Set(pt);return Ft.delete(`${e}:${St}`),Ft}),g&&yge(g,e,St,dt);const Qt=URL.createObjectURL(dt),Re=Z.current.get(St);Z.current.set(St,Qt),v1.set(`${g}:${e}:${St}
286`,Qt),Q(new Map(Z.current)),Re?.startsWith("blob:")&&setTimeout(()=>URL.revokeObjectURL(Re),5e3)}catch{if(Y.current.get(St)===It&&Y.current.delete(St),pe.current.has(St)&&!Z.current.get(St)&&!ae.signal.aborted){const ns=he.current.get(St);ns&&clearTimeout(ns);const dt=(je.current.get(St)??0)+1;je.current.set(St,dt);const Qt=Math.min(6e4,1e4*2**Math.min(dt-1,3)),Re=setTimeout(()=>{he.current.delete(St),!(ae.signal.aborted||!pe.current.has(St)||Z.current.get(St))&&(x1.delete(`${e}:${St}`),q(pt=>{const Ft=new Map(pt);return Ft.set(St,et(St)),Ft}))},Qt);he.current.set(St,Re)}}}},Ue=we.filter(([St])=>!Z.current.has(St)),We=we.filter(([St])=>Z.current.has(St));for(const St of Ue)Qe.push(vF(()=>te(St)));return We.forEach((St,It)=>{const ns=setTimeout(()=>{ae.signal.aborted||Qe.push(vF(()=>te(St)))},lje+It*cje);ye.push(ns)}),Ue.length===0&&We.length===0?()=>ae.abort():()=>{ae.abort(),ye.forEach(clearTimeout),Qe.forEach(St=>St())}},[g,O,G,r,Pe,be,se,e,et]),u.useEffect(()=>{if(!i||!r||be)return;const ae=se.filter(we=>we.enabled).length;if(!(ae<=le))if(a===1){const we=setInterval(()=>{R(!1),setTimeout(()=>{b(Qe=>(Qe+1)%ae),R(!0)},400)},n);return()=>clearInterval(we)}else{const we=Math.ceil(ae/le),Qe=setInterval(()=>{R(!1),setTimeout(()=>{w(ye=>(ye+1)%we),$(ye=>ye+1),R(!0)},400)},n);return()=>clearInterval(Qe)}},[i,r,be,n,a,se,le]),!r)return t.jsx("div",{ref:oe,className:a===1?"":"grid grid-cols-3 gap-1",children:a===1?t.jsx("div",{className:"relative aspect-video rounded overflow-hidden flex items-center justify-center",style:{backgroundColor:"#0a0a0a"},children:t.jsx("img",{src:h.appEmblemUrl||"/truvios-emblem.png",alt:"",className:"w-12 h-12 object-contain",style:{opacity:.15,filter:"grayscale(100%) brightness(0.8)"}})}):[1,2,3,4,5,6].map(ae=>t.jsx("div",{className:"relative aspect-video rounded overflow-hidden flex items-center justify-center",style:{backgroundColor:"#0a0a0a"},children:t.jsx("img",{src:h.appEmblemUrl||"/truvios-emblem.png",alt:"",className:"w-12 h-12 object-contain",style:{opacity:.15,filter:"grayscale(100%) brightness(0.8)"}})},ae))});if(Pe){const ae=({full:we})=>t.jsxs("div",{className:"relative aspect-video rounded overflow-hidden flex flex-col items-center justify-center gap-1 text-center px-2",style:{backgroundColor:"#0a0a0a"},children:[t.jsx(ka,{className:`${we?"w-8 h-8":"w-5 h-5"} text-white/40`}),we&&t.jsx("span",{className:"text-[11px] text-white/50 font-medium leading-tight",children:"Video hidden by site owner"})]});return t.jsx("div",{ref:oe,className:a===1?"":"grid grid-cols-3 gap-1","data-testid":`privacy-blocked-${e}`,children:a===1?t.jsx(ae,{full:!0}):[1,2,3,4,5,6].map(we=>t.jsx(ae,{full:we===1},we))})}if(!be&&(fe||!G)&&ee.size===0)return t.jsx("div",{ref:oe,className:a===1?"":"grid grid-cols-3 gap-1",children:a===1?t.jsx(Bt,{className:"aspect-video rounded"}):[1,2,3].map(ae=>t.jsx(Bt,{className:"aspect-video rounded"},ae))});if(!be&&(fe||!G)){const ae=[...ee.entries()].slice(0,a===1?1:6);return t.jsx("div",{ref:oe,className:a===1?"":"grid grid-cols-3 gap-1",children:ae.map(([we,Qe])=>t.jsxs("div",{className:"relative aspect-video rounded overflow-hidden bg-black",children:[t.jsx("img",{src:Qe,alt:`${s} — cached ${we}`,className:"w-full h-full object-cover","data-testid":`cached-camera-thumbnail-${we}`}),t.jsx("span",{className:"absolute bottom-1 right-1 rounded bg-black/60 px-1.5 py-0.5 text-[9px] text-white/70",children:"Last frame"})]},we))})}if(be==="credentials")return t.jsxs("div",{ref:oe,className:"flex items-center gap-2 text-xs text-muted-foreground p-2 bg-muted/50 rounded",children:[t.jsx(mde,{className:"w-3 h-3"}),t.jsx("span",{children:"No Edge device linked"})]});if(be||se.length===0)return t.jsx("div",{ref:oe,className:a===1?"":"grid grid-cols-3 gap-1",children:(a===1?[1]:[1,2,3,4,5,6]).map(ae=>t.jsx("div",{className:"relative aspect-video rounded overflow-hidden flex items-center justify-center",style:{backgroundColor:"#0a0a0a"},children:t.jsx("img",{src:h.appEmblemUrl||"/truvios-emblem.png",alt:"",className:"w-12 h-12 object-contain",style:{opacity:.15,filter:"grayscale(100%) brightness(0.8)"}})},ae))});const $e=(ae,we,Qe)=>{ae.stopPropagation(),k(we),_(Qe),x(!0)},bt=async()=>
286{if(!C||!S.trim())return;const ae=S.trim();T(!0);try{await c?.(e,C,ae)}finally{T(!1)}x(!1)},Ae=ae=>ae.displayName||ae.name,Be=Math.ceil(me.length/le),J=a===6?le-ge.length:0;return t.jsxs("div",{ref:oe,children:[t.jsxs("div",{className:a===1?"":"grid grid-cols-3 gap-1",style:{opacity:M?1:0,transition:"opacity 0.4s ease-in-out"},children:[ge.map(ae=>{const we=Ae(ae),Qe=ee.get(ae.name);return t.jsxs("div",{className:"relative aspect-video bg-muted rounded overflow-hidden group/thumb cursor-pointer",onClick:()=>o?.(ae.name,se),"data-testid":`camera-thumbnail-${ae.name}`,children:[Qe?t.jsx("img",{src:Qe,alt:"",decoding:"async",className:"w-full h-full object-cover"}):t.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-center px-2",style:{backgroundColor:"#0a0a0a"},children:[t.jsx("img",{src:h.appEmblemUrl||"/truvios-emblem.png",alt:"",className:"w-8 h-8 object-contain",style:{opacity:V.has(`${e}:${ae.name}`)?.8:.15,filter:V.has(`${e}:${ae.name}`)?"none":"grayscale(100%)"}}),V.has(`${e}:${ae.name}`)&&t.jsx("span",{className:"text-[11px] text-white/65","data-testid":`camera-stream-error-${ae.name}`,children:"Camera Stream Error"})]}),t.jsxs("div",{className:`absolute inset-0 transition-opacity flex pointer-events-none ${a===1?"bg-gradient-to-t from-black/60 via-trans
286parent to-transparent opacity-100 items-end pb-1 md:opacity-0 md:bg-black/40 md:from-transparent md:via-transparent md:items-center md:justify-center md:pb-0 group-hover/thumb:opacity-100":"opacity-0 group-hover/thumb:opacity-100 bg-black/40 items-center justify-center"}`,children:[t.jsx("span",{className:`${a===1?"text-xs w-full text-center":"text-[10px]"} text-white/70 font-medium truncate px-1`,children:a===1?we:null}),l&&t.jsx("button",{type:"button",className:"pointer-events-auto absolute top-1 right-1 p-0.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ye=>$e(ye,ae.name,we),"data-testid":`button-rename-camera-${ae.name}`,children:t.jsx(ga,{className:"w-3 h-3 text-white"})})]})]},`${ae.name}-${a===1?v:D}`)}),J>0&&Array.from({length:J}).map((ae,we)=>t.jsx("div",{className:"relative aspect-video rounded overflow-hidden flex items-center justify-center",style:{backgroundColor:"#0a0a0a"},children:t.jsx("img",{src:h.appEmblemUrl||"/truvios-emblem.png",alt:"",className:"w-12 h-12 object-contain",style:{opacity:.15,filter:"grayscale(100%) brightness(0.8)"}})},`empty-${we}`))]}),a===1&&me.length>1&&(i?t.jsx("div",{className:"flex items-center justify-center gap-1 mt-1",children:me.map((ae,we)=>t.jsx("div",{className:`h-1 rounded-full transition-all ${we===v%me.length?"w-3 bg-primary":"w-1.5 bg-muted-foreground/30"}`},we))}):t.jsxs("div",{className:"flex items-center justify-between mt-1",children:[t.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted transition-colors",onClick:ae=>{ae.stopPropagation(),b(we=>(we-1+me.length)%me.length)},"data-testid":"button-prev-camera",children:t.jsx(Kl,{className:"w-4 h-4 text-muted-foreground"})}),t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[v%me.length+1," / ",me.length]}),t.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted transition-colors",onClick:ae=>{ae.stopPropagation(),b(we=>(we+1)%me.length)},"data-testid":"button-next-camera",children:t.jsx(hi,{className:"w-4 h-4 text-muted-foreground"})})]})),a===6&&Be>1&&t.jsxs("div",{className:"flex items-center justify-between mt-1",children:[t.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted transition-colors",onClick:ae=>{ae.stopPropagation(),w(we=>(we-1+Be)%Be),$(we=>we+1)},"aria-label":"Previous camera page","data-testid":"button-prev-camera-page",children:t.jsx(Kl,{className:"w-4 h-4 text-muted-foreground"})}),t.jsx("div",{className:"flex items-center justify-center gap-1","aria-label":`Camera page ${y+1} of ${Be}`,children:Array.from({length:Be}).map((ae,we)=>t.jsx("div",{className:`h-1 rounded-full transition-all ${we===y?"w-3 bg-primary":"w-1.5 bg-muted-foreground/30"}`},we))}),t.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted transition-colors",onClick:ae=>{ae.stopPropagation(),w(we=>(we+1)%Be),$(we=>we+1)},"aria-label":"Next camera page","data-testid":"button-next-camera-page",children:t.jsx(hi,{className:"w-4 h-4 text-muted-foreground"})})]}),t.jsx(Ys,{open:j,onOpenChange:x,children:t.jsxs(Ws,{children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Set Display Name"}),t.jsxs(cr,{children:["Set a friendly display name for ",t.jsx("strong",{children:C}),"."]})]}),t.jsxs("div",{className:"space-y-2 py-2",children:[t.jsx(re,{htmlFor:"camera-name",children:"Display Name"}),t.jsx(ke,{id:"camera-name",value:S,onChange:ae=>_(ae.target.value),placeholder:"e.g. Front Door","data-testid":"input-camera-name",onKeyDown:ae=>{ae.key==="Enter"&&bt()}})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>x(!1),"data-testid":"button-cancel-rename",children:"Cancel"}),t.jsx(L,{onClick:bt,disabled:!S.trim()||A,"data-testid":"button-confirm-rename",children:A?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):"Save"})]})]})})]})}function mje({company:e,isAdmin:s,canManage:r,isOwnerOrAbove:n,previewCycleInterval:a,previewLayout:i,previewCycling:o,viewMode:l,onEditCompany:c,onDeleteCompany:d,onAddSite:h,onLaunch:p,onEditSite:g,isSiteReachable:v,onSaveDisplayName:b,restartingSites:y=new Set,restartingKinds:w=new Map,onMarkRestarting:j,onClearRestarting:x,cameraRefetchKey:C=0,sortSites:k,siteSortOrder:S}
286){const{attributes:_,listeners:A,setNodeRef:T,transform:M,transition:R,isDragging:D}=cZ({id:e.id,data:{type:"company",companyId:e.id}}),{setNodeRef:$,isOver:O}=a3({id:`drop-${e.id}`,data:{type:"company-drop",companyId:e.id}}),q={transform:vf.Transform.toString(M),transition:R,opacity:D?.5:1},V=K=>{T(K),$(K)};return t.jsx("div",{ref:V,style:q,children:t.jsxs(ut,{className:`bg-card border-card-border transition-colors ${O?"ring-2 ring-primary ring-offset-2":""}`,children:[t.jsxs(xs,{className:"flex flex-row items-center justify-between gap-2 sm:gap-4 space-y-0 pb-4 px-3 sm:px-6",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-md bg-primary/10 flex items-center justify-center cursor-grab active:cursor-grabbing",..._,...A,"data-testid":`drag-handle-company-${e.id}`,children:t.jsx(RK,{className:"w-5 h-5 text-primary"})}),t.jsxs("div",{children:[t.jsx(ys,{className:"text-lg",children:e.name}),e.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:e.description})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx(L,{variant:"outline",size:"sm",onClick:()=>c(e),"data-testid":`button-edit-company-${e.id}`,children:t.jsx(ga,{className:"w-4 h-4"})}),s&&t.jsx(L,{variant:"outline",size:"sm",onClick:()=>d(e),"data-testid":`button-delete-company-${e.id}`,children:t.jsx(sa,{className:"w-4 h-4"})}),r&&t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>h(e.id),"data-testid":`button-add-site-${e.id}`,children:[t.jsx(Fo,{className:"w-4 h-4 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Add Site"})]})]})]}),t.jsx(mt,{className:"px-3 sm:px-6",children:e.sites.length===0?t.jsxs("div",{className:"p-8 text-center border border-dashed rounded-lg border-border",children:[t.jsx(Cg,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-muted-foreground",children:"No sites in this company"}),r&&t.jsxs(L,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>h(e.id),children:[t.jsx(Fo,{className:"w-4 h-4 mr-1"}),"Add Site"]})]}):l==="list"?t.jsx("div",{className:"grid gap-2",children:k(e.sites).map(K=>t.jsx(dC,{site:K,isAdmin:s,canManage:r,isOwnerOrAbove:n,isReachable:v(K),isRestarting:y.has(K.id),restartingKind:w.get(K.id),onLaunch:p,onEdit:g,onMarkRestarting:j,onClearRestarting:x},K.id))}):S==="custom"?t.jsx(a0,{items:k(e.sites).map(K=>K.id),strategy:Oy,children:t.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:k(e.sites).map(K=>t.jsx(uC,{site:K,isAdmin:s,canManage:r,isOwnerOrAbove:n,isReachable:v(K),previewCycleInterval:a,previewLayout:i,previewCycling:o,onLaunch:p,onEdit:g,onSaveDisplayName:b,isRestarting:y.has(K.id),restartingKind:w.get(K.id),onMarkRestarting:j,onClearRestarting:x,cameraRefetchKey:C},K.id))})}):t.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:k(e.sites).map(K=>t.jsx(mC,{site:K,isAdmin:s,canManage:r,isOwnerOrAbove:n,isReachable:v(K),previewCycleInterval:a,onLaunch:p,previewLayout:i,previewCycling:o,onEdit:g,onSaveDisplayName:b,isRestarting:y.has(K.id),restartingKind:w.get(K.id),onMarkRestarting:j,onClearRestarting:x,cameraRefetchKey:C},K.id))})})]})})}function hje({company:e,isAdmin:s,canManage:r,isOwnerOrAbove:n,previewCycleInterval:a,previewLayout:i,previewCycling:o,viewMode:l,onEditCompany:c,onDeleteCompany:d,onAddSite:h,onLaunch:p,onEditSite:g,isSiteReachable:v,onSaveDisplayName:b,restartingSites:y=new Set,restartingKinds:w=new Map,onMarkRestarting:j,onClearRestarting:x,cameraRefetchKey:C=0,sortSites:k,siteSortOrder:S}){const{setNodeRef:_,isOver:A}=a3({id:e.id});return t.jsxs(ut,{ref:_,className:`bg-card border-card-border transition-colors ${A?"ring-2 ring-primary ring-offset-2":""}`,children:[t.jsxs(xs,{className:"flex flex-row items-center justify-between gap-2 sm:gap-4 space-y-0 pb-4 px-3 sm:px-6",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-md bg-primary/10 flex items-center justify-center",children:t.jsx(xi,{className:"w-5 h-5 text-primary"})}),t.jsxs("div",{children:[t.jsx(ys,{className:"text-lg",children:e.name}),e.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:e.description})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx(L,{variant:"outline",size:"sm",onClick:()=>c(e),"data-testid":`button-edit-company-${e.id}`,children:t.jsx(ga,{className:"w-4 h-4"})}),s&&t.jsx(L,{variant:"outline",size:"sm",onClick:()=>d(e),"data-testid":`button-delete-company-${e.id}`,children:t.jsx(sa,{className:"w-4 h-4"})}),r&&t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>h(e.id),"data-testid":`button-add-site-${e.id}`,children:[t.jsx(Fo,{className:"w-4 h-4 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Add Site"})]})]})]}),t.jsx(mt,{className:"px-3 sm:px-6",children:e.sites.length===0?t.jsxs("div",{className:`p-8 text-center border border-dashed rounded-lg ${A?"border-primary bg-primary/5":"border-border"}`,children:[t.jsx(Cg,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-muted-foreground",children:A?"Drop site here":"No sites in this company"}),r&&!A&&t.jsxs(L,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>h(e.id),children:[t.jsx(Fo,{className:"w-4 h-4 mr-1"}),"Add Site"]})]}):l==="list"?t.jsx("div",{className:"grid gap-2",children:k(e.sites).map(T=>t.jsx(dC,{site:T,isAdmin:s,canManage:r,isOwnerOrAbove:n,isReachable:v(T),isRestarting:y.has(T.id),restartingKind:w.get(T.id),onLaunch:p,onEdit:g,onMarkRestarting:j,onClearRestarting:x},T.id))}):S==="custom"?t.jsx(a0,{items:k(e.sites).map(T=>T.id),strategy:Oy,children:t.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:k(e.sites).map(T=>t.jsx(uC,{site:T,isAdmin:s,canManage:r,isOwnerOrAbove:n,isReachable:v(T),previewCycleInterval:a,previewLayout:i,previewCycling:o,onLaunch:p,onEdit:g,onSaveDisplayName:b,isRestarting:y.has(T.id),restartingKind:w.get(T.id),onMarkRestarting:j,onClearRestarting:x,cameraRefetchKey:C},T.id))})}):t.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:k(e.sites).map(T=>t.jsx(mC,{site:T,isAdmin:s,canManage:r,isOwnerOrAbove:n,isReachable:v(T),previewCycleInterval:a,previewLayout:i,previewCycling:o,onLaunch:p,onEdit:g,onSaveDisplayName:b,isRestarting:y.has(T.id),restartingKind:w.get(T.id),onMarkRestarting:j,onClearRestarting:x,cameraRefetchKey:C},T.id))})})]})}function dC({site:e,isAdmin:s,canManage:r,isOwnerOrAbove:n,isReachable:a,isRestarting:i=!1,restartingKind:o="soft",onLaunch:l,onEdit:c,onMarkRestarting:d,onClearRestarting:h}){const p=o==="hard"?"Rebooting…":"Restarting…",[,g]=Ia(),{data:v}=ze({queryKey:["/api/user/role"]}),b=e.edgeDevice,y=ze({queryKey:["/api/edge-devices",b?.id,"offline-diagnostics"],queryFn:async()=>{const O=await fetch(`/api/edge-devices/${b?.id}`,{credentials:"include"});if(!O.ok)throw new Error("Unable to load device capabilities");return O.json()},enabled:!a&&v?.role==="superadmin"&&!!b?.id,staleTime:3e4}),[w,j]=u.useState(!1),[x,C]=u.useState(null),[k,S]=u.useState(!1),[_,A]=u.useState(""),[T,M]=u.useState([]),R=()=>{C({...e}),j(!0)},D=O=>{j(O),O||C(null)},$=u.useCallback(async()=>{try{const[O,q]=await Promise.all([fetch(`/api/sites/${e.id}/cameras`,{credentials:"include"}),fetch(`/api/sites/${e.id}/my-permissions`,{credentials:"include"})]);if(O.ok){const V=await O.json(),K=q.ok?await q.json():null,G=K&&!K.isExempt&&K.restrictedCameras?.length?K.restrictedCameras:[],z=(V.cameras||[]).map(ee=>({name:ee.name,enabled:ee.enabled!==!1,usesGo2rtc:ee.usesGo2rtc||!1})).filter(ee=>!G.includes(ee.name)),Z=z.filter(ee=>ee.enabled);Z.length>0&&(A(Z[0].name),M(z),S(!0))}}catch{}},[e.id]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"rounded-md border border-border p-3 hover-elevate","data-testid":`list-site-${e.id}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[t.jsx("div",{className:`w-8 h-8 rounded-md flex items-center justify-center shrink-0 ${i?"bg-amber-400/10":e.isOnline?"bg-primary/10":e.lastChecked?"bg-muted":"bg-amber-400/10"}`,children:i?t.jsx(Fe,{className:"w-4 h-4 text-amber-500 animate-spin"}
286):e.edgeDevice?.cloudEnabled?t.jsx(pn,{className:`w-4 h-4 ${e.isOnline?"text-primary":e.lastChecked?"text-muted-foreground":"text-amber-500"}`}):t.jsx(Fa,{className:`w-4 h-4 ${e.isOnline?"text-primary":e.lastChecked?"text-muted-foreground":"text-amber-500"}`})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium truncate","data-testid":`list-site-name-${e.id}`,children:e.name}),t.jsx("span",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${i?"bg-amber-400 animate-pulse":e.isOnline?"bg-green-500":e.lastChecked?"bg-muted-foreground/40":"bg-amber-400 animate-pulse"}`,"data-testid":`list-site-status-${e.id}`})]}),e.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:e.description.length>50?`${e.description.slice(0,50)}...`:e.description})]})]}),t.jsxs("div",{className:"hidden sm:flex items-center gap-2 shrink-0",children:[n&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",disabled:i||!a&&!(v?.role==="superadmin"&&y.data?.allowDiagnosticsIfOffline),className:i||!a&&!(v?.role==="superadmin"&&y.data?.allowDiagnosticsIfOffline)?"opacity-30":"",onClick:()=>{i||(a?g(`/device-settings/${e.id}`):v?.role==="superadmin"&&y.data?.allowDiagnosticsIfOffline&&g(`/device-settings/${e.id}?tab=diagnostics`))},"data-testid":`list-launch-site-${e.id}`,children:!a&&v?.role==="superadmin"&&y.data?.allowDiagnosticsIfOffline?t.jsx(jy,{className:"w-4 h-4"}):t.jsx(xd,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:i?p:a?"Device Settings":v?.role==="superadmin"&&y.data?.allowDiagnosticsIfOffline?"Diagnostics":e.lastChecked?"Offline":"Initializing"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:$,disabled:!a||i,className:!a||i?"opacity-30":"","data-testid":`list-liveview-site-${e.id}`,children:t.jsx(Vi,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Live View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>g(`/recordings?siteId=${e.id}`),"data-testid":`list-recordings-site-${e.id}`,children:t.jsx(cn,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Recordings"})]}),s&&a&&i&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",disabled:!0,"data-testid":`list-restart-site-${e.id}`,children:t.jsx(Fe,{className:"w-4 h-4 animate-spin"})})}),t.jsx(Yt,{children:p})]}),s&&!i&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>a&&R(),disabled:!a,className:a?"":"opacity-30","data-testid":`list-restart-site-${e.id}`,children:t.jsx(kg,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Restart"})]}),r&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>c(e),"data-testid":`list-edit-site-${e.id}`,children:t.jsx(ga,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Edit Site"})]})]})]}),t.jsxs("div",{className:"flex sm:hidden items-center gap-1 mt-2 pt-2 border-t border-border",children:[n&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",disabled:i||!a&&!(v?.role==="superadmin"&&y.data?.allowDiagnosticsIfOffline),className:i||!a&&!(v?.role==="superadmin"&&y.data?.allowDiagnosticsIfOffline)?"opacity-30":"",onClick:()=>{i||(a?g(`/device-settings/${e.id}`):v?.role==="superadmin"&&y.data?.allowDiagnosticsIfOffline&&g(`/device-settings/${e.id}?tab=diagnostics`))},"data-testid":`list-launch-site-mobile-${e.id}`,children:!a&&v?.role==="superadmin"&&y.data?.allowDiagnosticsIfOffline?t.jsx(jy,{className:"w-4 h-4"}):t.jsx(xd,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:i?p:a?"Device Settings":v?.role==="superadmin"&&y.data?.allowDiagnosticsIfOffline?"Diagnostics":e.lastChecked?"Offline":"Initializing"})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:$,disabled:!a||i,className:!a||i?"opacity-30":"","data-testid":`list-liveview-site-mobile-${e.id}`,children:t.jsx(Vi,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:i?p:"Live View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>g(`/recordings?siteId=${e.id}`),"data-testid":`list-recordings-site-mobile-${e.id}`,children:t.jsx(cn,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Recordings"})]}),s&&a&&i&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",disabled:!0,"data-testid":`list-restart-site-mobile-${e.id}`,children:t.jsx(Fe,{className:"w-4 h-4 animate-spin"})})}),t.jsx(Yt,{children:p})]}),s&&!i&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>a&&R(),disabled:!a,className:a?"":"opacity-30","data-testid":`list-restart-site-mobile-${e.id}`,children:t.jsx(kg,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Restart"})]}),r&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>c(e),"data-testid":`list-edit-site-mobile-${e.id}`,children:t.jsx(ga,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Edit Site"})]})]})]}),t.jsx(XO,{site:x??e,open:w,onOpenChange:D,onMarkRestarting:d,onClearRestarting:h}),t.jsx(x3,{open:k,onOpenChange:S,siteId:e.id,siteName:e.name,cameraName:_,allCameras:T})]})}function uC(e){const{attributes:s,listeners:r,setNodeRef:n,transform:a,transition:i,isDragging:o}=cZ({id:e.site.id,disabled:!e.isOwnerOrAbove}),l={transform:vf.Transform.toString(a),transition:i,opacity:o?.5:1};return t.jsx(eee,{...e,setNodeRef:n,attributes:s,listeners:r,style:l,isDragging:o})}function mC(e){const{attributes:s,listeners:r,setNodeRef:n,transform:a,isDragging:i}=nZ({id:e.site.id,disabled:!e.isAdmin}),o=a?{transform:`translate3d(${a.x}px, ${a.y}px, 0)`}:void 0;return t.jsx(eee,{...e,setNodeRef:n,attributes:s,listeners:r,style:o,isDragging:i})}function eee({site:e,isAdmin:s,canManage:r,isReachable:n,isOwnerOrAbove:a,previewCycleInterval:i,previewLayout:o,previewCycling:l=!0,onLaunch:c,onEdit:d,onSaveDisplayName:h,isRestarting:p=!1,restartingKind:g="soft",onMarkRestarting:v,onClearRestarting:b,cameraRefetchKey:y=0,setNodeRef:w,attributes:j,listeners:x,style:C,isDragging:k}){const S=g==="hard"?"Rebooting…":"Restarting…",{data:_}=ze({queryKey:["/api/user/role"]}),A=e.edgeDevice,T=ze({queryKey:["/api/edge-devices",A?.id,"offline-diagnostics"],queryFn:()=>
286fetch(`/api/edge-devices/${A.id}`,{credentials:"include"}).then(he=>he.json()),enabled:!n&&_?.role==="superadmin"&&!!A?.id,staleTime:3e4}),[,M]=Ia(),[R,D]=u.useState(!1),[$,O]=u.useState(""),[q,V]=u.useState([]),[K,G]=u.useState(!1),[z,Z]=u.useState(null),ee=()=>{Z({...e}),G(!0)},Q=he=>{G(he),he||Z(null)},Y=u.useCallback((he,je)=>{O(he),V(je),D(!0)},[]),oe=u.useCallback(async()=>{try{const[he,je]=await Promise.all([fetch(`/api/sites/${e.id}/cameras`,{credentials:"include"}),fetch(`/api/sites/${e.id}/my-permissions`,{credentials:"include"})]);if(he.ok){const pe=await he.json(),le=je.ok?await je.json():null,ue=le&&!le.isExempt&&le.restrictedCameras?.length?le.restrictedCameras:[],fe=(pe.cameras||[]).map(se=>({name:se.name,enabled:se.enabled!==!1,usesGo2rtc:se.usesGo2rtc||!1})).filter(se=>!ue.includes(se.name)),H=fe.filter(se=>se.enabled);H.length>0&&(O(H[0].name),V(fe),D(!0))}}catch{}},[e.id]);return t.jsxs(t.Fragment,{children:[t.jsx(ut,{ref:w,style:C,className:`bg-muted/30 border-border hover-elevate group h-full min-w-0 ${
286k?"opacity-50":""}`,children:t.jsxs(mt,{className:"p-4 space-y-4 flex flex-col h-full min-w-0",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s&&t.jsx("div",{...j,...x,className:"cursor-grab active:cursor-grabbing p-1 -ml-2 hover:bg-muted rounded touch-none","data-testid":`drag-handle-site-${e.id}`,children:t.jsx(RK,{className:"w-4 h-4 text-muted-foreground"})}),t.jsx("div",{className:`w-10 h-10 rounded-md flex items-center justify-center shrink-0 ${p?"bg-amber-400/10":e.isOnline?"bg-primary/10":e.lastChecked?"bg-muted":"bg-amber-400/10"}`,children:p?t.jsx(Fe,{className:"w-5 h-5 text-amber-500 animate-spin"}):e.edgeDevice?.cloudEnabled?t.jsx(pn,{className:`w-5 h-5 ${e.isOnline?"text-primary":e.lastChecked?"text-muted-foreground":"text-amber-500"}`}):t.jsx(Fa,{className:`w-5 h-5 ${e.isOnline?"text-primary":e.lastChecked?"text-muted-foreground":"text-amber-500"}`})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"font-semibold text-foreground truncate",children:e.name}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-2.5 h-2.5 rounded-full shrink-0 ${p?"bg-amber-400 animate-pulse":e.isOnline?"bg-green-500":e.lastChecked?"bg-muted-foreground/40":"bg-amber-400 animate-pulse"}`}),t.jsx("span",{className:`text-xs ${p?"text-amber-600 dark:text-amber-400":e.isOnline?"text-foreground":e.lastChecked?"text-muted-foreground":"text-amber-600 dark:text-amber-400"}`,children:p?S:e.isOnline?"Online":e.lastChecked?"Offline":"Initializing..."})]})]})]})}),t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:oe,disabled:!n||p,className:!n||p?"opacity-30":"","data-testid":`button-liveview-site-${e.id}`,children:t.jsx(Vi,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Live View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>M(`/recordings?siteId=${e.id}`),"data-testid":`button-recordings-site-${e.id}`,children:t.jsx(cn,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Recordings"})]}),s&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>n&&!p&&ee(),disabled:!n||p,className:!n||p?"opacity-30":"","data-testid":`button-restart-site-${e.id}`,children:p?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):t.jsx(kg,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:p?S:"Restart"})]}),r&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>d(e),"data-testid":`button-edit-site-${e.id}`,children:t.jsx(ga,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Edit Site"})]})]}),t.jsx(uje,{siteId:e.id,siteName:e.name,isOnline:e.isOnline??!1,previewCycleInterval:i,previewLayout:o,cycling:l,onCameraClick:Y,canRename:a,onSaveDisplayName:h,refetchKey:y}),t.jsx(ZJ,{site:e,isOnline:e.isOnline??!1}),t.jsx("div",{className:"flex-1"}),a&&t.jsx("div",{className:"flex items-center gap-2 pt-2",children:t.jsx(L,{variant:!p&&(n||!n&&_?.role==="superadmin"&&T.data?.allowDiagnosticsIfOffline)?"default":"secondary",size:"sm",className:`flex-1 ${p||!n&&!(_?.role==="superadmin"&&T.data?.allowDiagnosticsIfOffline)?"opacity-50":""}`,disabled:p||!n&&!(_?.role==="superadmin"&&T.data?.allowDiagnosticsIfOffline),onClick:()=>{p||(n?M(`/device-settings/${e.id}`):_?.role==="superadmin"&&T.data?.allowDiagnosticsIfOffline&&M(`/device-settings/${e.id}?tab=diagnostics`))},"data-testid":`button-launch-site-${e.id}`,children:p?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}),S]}):n?t.jsxs(t.Fragment,{children:[t.jsx(xd,{className:"w-4 h-4 mr-1"}),"Device Settings"]}):_?.role==="superadmin"&&T.data?.allowDiagnosticsIfOffline?t.jsxs(t.Fragment,{children:[t.jsx(jy,{className:"w-4 h-4 mr-1"}),"Diagnostics"]}):"Offline"})})]})}),t.jsx(XO,{site:z??e,open:K,onOpenChange:Q,onMarkRestarting:v,onClearRestarting:b}),t.jsx(x3,{open:R,onOpenChange:D,siteId:e.id,siteName:e.name,cameraName:$,allCameras:q,canRename:a,onCameraRenamed:()=>{},onSaveDisplayName:h})]})}function h_(){const{user:e}=Gi();return!!e?.viewAs?.active}function tee(e){const s="=".repeat((4-e.length%4)%4),r=(e+s).replace(/-/g,"+").replace(/_/g,"/"),n=atob(r),a=new Uint8Array(n.length);for(let i=0;i<n.length;++i)a[i]=n.charCodeAt(i);return a}function pje(e,s){if(e.length!==s.length)return!1;for(let r=0;r<e.length;++r)if(e[r]!==s[r])return!1;return!0}function fje(e){const s=e.options?.applicationServerKey;return s?new Uint8Array(s):null}function see(e,s){const r=fje(e);return r?!pje(r,tee(s)):!1}async function gje(e){const s=e.endpoint;try{await e.unsubscribe()}catch{}try{await fetch("/api/push/subscribe",{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:s})})}catch{}}async function v3(e){const s=await fetch("/api/push/vapid-public-key");if(!s.ok)return{error:"Web push not configured on the server."};const{publicKey:r}=await s.json(),n=await e.pushManager.getSubscription();n&&see(n,r)&&await gje(n);const i=(await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:tee(r)})).toJSON(),o=await fetch("/api/push/subscribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({endpoint:i.endpoint,keys:i.keys})});if(!o.ok)return{error:"Server refused the subscription."};const{id:l}=await o.json();return{subscriptionId:l,endpoint:i.endpoint}}
286async function xje(){try{if(!("serviceWorker"in navigator)||!("PushManager"in window)||typeof Notification>"u"||Notification.permission!=="granted")return!1;const e=await navigator.serviceWorker.ready,s=await e.pushManager.getSubscription();if(!s)return!1;const r=await fetch("/api/push/vapid-public-key");if(!r.ok)return!1;const{publicKey:n}=await r.json();return see(s,n)?!("error"in await v3(e)):!1}catch{return!1}}function vje(e,s){const r=e?.[0]||"",n=s?.[0]||"";return(r+n).toUpperCase()||"U"}async function yje(e){if(!("serviceWorker"in navigator)||!("PushManager"in window))return{error:"Push not supported in this browser."};const s=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,r=window.navigator?.standalone===!0||window.matchMedia?.("(display-mode: standalone)")?.matches;if(s&&!r)return{error:`On iPhone/iPad, first add ${e} to your Home Screen, open it from there, then enable push.`};try{const n=await navigator.serviceWorker.ready;return await Notification.requestPermission()!=="granted"?{error:"Notification permission was denied. To fix this, click the lock/info icon in your browser's address bar, set Notifications to 'Allow', then try again."}:await v3(n)}catch(n){return{error:n?.message||"Enrollment failed"}}}function bje(e){return e?/Edg\//.test(e)?"Edge":/Chrome\//.test(e)&&!/Chromium/.test(e)?"Chrome":/Firefox\//.test(e)?"Firefox":/Safari\//.test(e)&&!/Chrome/.test(e)?"Safari":/Chromium\//.test(e)?"Chromium":"Browser":"Unknown browser"}function wje(){const{user:e,logout:s}=Gi(),r=h_(),n=Er(),[,a]=Ia(),{toast:i}=Hs(),o=u.useRef(null),[l,c]=u.useState(e?.firstName||""),[d,h]=u.useState(e?.lastName||""),[p,g]=u.useState(""),[v,b]=u.useState(""),[y,w]=u.useState("email"),[j,x]=u.useState(""),[C,k]=u.useState(""),[S,_]=u.useState(!1),[A,T]=u.useState(!1),{data:M,isLoading:R}=ze({queryKey:["/api/user/settings"]}),{data:D}=ze({queryKey:["/api/twilio/status"]}),$=D?.configured??!1,{data:O}=ze({queryKey:["/api/user/mfa/policy"]}),{data:q=[]}=ze({queryKey:["/api/user/trusted-devices"]}),{data:V=[],refetch:K}=ze({queryKey:["/api/push/subscriptions"]}),[G,z]=u.useState(!1);u.useEffect(()=>{if(window.location.hash==="#mfa"){const be=document.getElementById("mfa-section");be&&setTimeout(()=>{be.scrollIntoView({behavior:"smooth",block:"center"})},300)}},[M,O]);const Z=Et({mutationFn:async be=>await(await Ze("PATCH","/api/user/profile",be)).json(),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/auth/user"]}),i({title:"Name updated",description:"Your name has been updated successfully"})},onError:()=>{i({title:"Error",description:"Failed to update name",variant:"destructive"})}}),ee=Et({mutationFn:async be=>{const ce=new FormData;ce.append("photo",be);const Pe=await fetch("/api/user/profile-photo",{method:"POST",body:ce,credentials:"include"});if(!Pe.ok)throw new Error("Upload failed");return Pe.json()},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/auth/user"]}),i({title:"Photo uploaded",description:"Your profile photo has been updated"}),window.location.reload()},onError:()=>{i({title:"Error",description:"Failed to upload photo",variant:"destructive"})}}),Q=Et({mutationFn:async be=>await(await Ze("POST","/api/user/change-password",be)).json(),onSuccess:()=>{g(""),b(""),i({title:"Password changed",description:"Your password has been updated successfully"})},onError:be=>{const ce=be?.message||"Failed to change password";i({title:"Error",description:ce,variant:"destructive"})}}),Y=Et({mutationFn:async be=>await(await Ze("POST","/api/user/mfa/send-code",be)).json(),onSuccess:be=>{_(!0),be.devCode?i({title:"Code sent (Dev Mode)",description:`Your verification code is: ${be.devCode}`,duration:3e4}):i({title:"Code sent",description:`Verification code sent to your ${y}`})},onError:()=>{i({title:"Error",description:"Failed to send verification code",variant:"destructive"})}}),oe=Et({mutationFn:be=>Ze("POST","/api/user/mfa/verify",{code:be}),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/user/settings"]}),_(!1),k(""),T(!1),i({title:"MFA updated",description:"Two-factor authentication has been updated successfully"})},onError:()=>{i({title:"Error",description:"Invalid verification code",variant:"destructive"})}}),he=Et({mutationFn:async()=>{const be=await Ze("POST","/api/user/mfa/disable");if(!be.ok){const ce=await be.json();throw new Error(ce.message||"Failed to disable MFA")}return be},onSuccess:()=>
286{Je.invalidateQueries({queryKey:["/api/user/settings"]}),i({title:"MFA disabled",description:"Two-factor authentication has been disabled"})},onError:be=>{i({title:"Cannot disable MFA",description:be.message||"Failed to disable MFA",variant:"destructive"})}}),je=Et({mutationFn:async be=>{await Ze("DELETE",`/api/user/trusted-devices/${be}`)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/user/trusted-devices"]}),i({title:"Device removed",description:"Trusted device has been removed"})},onError:()=>{i({title:"Error",description:"Failed to remove device",variant:"destructive"})}}),pe=Et({mutationFn:async()=>{await Ze("DELETE","/api/user/trusted-devices")},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/user/trusted-devices"]}),i({title:"All devices removed",description:"All trusted devices have been signed out"})},onError:()=>{i({title:"Error",description:"Failed to remove devices",variant:"destructive"})}}),le=Et({mutationFn:be=>Ze("PATCH","/api/user/settings",{pushSmartAlertsOnly:be}),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/user/settings"]})},onError:()=>{i({title:"Error",description:"Failed to update push setting",variant:"destructive"})}}),ue=be=>{const ce=be.target.files?.[0];if(!ce)return;const Pe=5*1024*1024;if(ce.size>Pe){i({title:"File too large",description:"Please select an image smaller than 5MB",variant:"destructive"});return}if(!["image/jpeg","image/jpg","image/png","image/gif","image/webp"].includes(ce.type)){i({title:"Invalid file type",description:"Please select a JPG, PNG, GIF, or WebP image",variant:"destructive"});return}ee.mutate(ce)},fe=()=>{if(!p){i({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(p.length<6){i({title:"Error",description:"New password must be at least 6 characters",variant:"destructive"});return}if(p!==v){i({title:"Error",description:"New passwords do not match",variant:"destructive"});return}Q.mutate({newPassword:p})},H=()=>{const be={method:y};if(y==="email"){if(!e?.email){i({title:"Error",description:"No email address found on your account",variant:"destructive"});return}be.email=e.email}else{if(!j){i({title:"Error",description:"Please enter a phone number",variant:"destructive"});return}be.phone=j}Y.mutate(be)},se=()=>{if(!C){i({title:"Error",description:"Please enter the verification code",variant:"destructive"});return}oe.mutate(C)},me=async()=>{z(!0);const be=await yje(n.brandName);if(z(!1),"error"in be){i({title:"Push enrollment failed",description:be.error,variant:"destructive"});return}await K(),i({title:"Device enrolled",description:"This browser will receive smart alert push notifications."})},ge=async be=>{try{await fetch("/api/push/subscribe",{method:"DELETE",headers:{"content-type":"application/json"},credentials:"include",body:JSON.stringify({endpoint:be})}),await K(),i({title:"Device removed"})}catch{i({title:"Failed to remove device",variant:"destructive"})}};return R?t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:t.jsx(Fe,{className:"w-8 h-8 animate-spin text-primary"})}):t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{O?.enforced&&M&&!M.mfaEnabled?s():a("/")},"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(dO,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold whitespace-nowrap",children:"My Account"})]}),t.jsx(qd,{showDashboardLink:!0})]})})}),t.jsx("main",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(ga,{className:"w-5 h-5"}),"Name"]}),t.jsx(Xs,{children:"Update your first and last name"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"space-y-4 max-w-sm",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:"first-name",children:"First Name"}
286),t.jsx(ke,{id:"first-name",value:l,onChange:be=>c(be.target.value),placeholder:"First name","data-testid":"input-first-name"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:"last-name",children:"Last Name"}),t.jsx(ke,{id:"last-name",value:d,onChange:be=>h(be.target.value),placeholder:"Last name","data-testid":"input-last-name"})]}),t.jsxs(L,{onClick:()=>Z.mutate({firstName:l.trim(),lastName:d.trim()}),disabled:r||Z.isPending||!l.trim()||!d.trim(),"data-testid":"button-save-name",children:[Z.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Save Name"]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(Om,{className:"w-5 h-5"}),"Profile Photo"]}),t.jsx(Xs,{children:"Upload a photo to personalize your profile"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center gap-6",children:[t.jsxs(cy,{className:"w-24 h-24",children:[t.jsx(dy,{src:e?.profileImageUrl||void 0}),t.jsx(uy,{className:"bg-primary text-primary-foreground text-2xl",children:vje(e?.firstName,e?.lastName)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("input",{ref:o,type:"file",accept:"image/*",className:"hidden",onChange:ue,"data-testid":"input-photo-file"}),t.jsxs(L,{variant:"outline",onClick:()=>o.current?.click(),disabled:ee.isPending,"data-testid":"button-upload-photo",children:[ee.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Om,{className:"w-4 h-4 mr-2"}),"Upload Photo"]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Supported formats: JPG, PNG, GIF, WebP (max 5MB)"})]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(ka,{className:"w-5 h-5"}),"Change Password"]}),t.jsx(Xs,{children:"Update your account password"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"space-y-4 max-w-sm",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:"new-password",children:"New Password"}),t.jsx(ke,{id:"new-password",type:"password",value:p,onChange:be=>g(be.target.value),placeholder:"Enter new password","data-testid":"input-new-password"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:"confirm-password",children:"Confirm New Password"}),t.jsx(ke,{id:"confirm-password",type:"password",value:v,onChange:be=>b(be.target.value),placeholder:"Confirm new password","data-testid":"input-confirm-password"})]}),t.jsxs(L,{onClick:fe,disabled:Q.isPending,"data-testid":"button-change-password",children:[Q.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Change Password"]})]})})]}),t.jsxs(ut,{id:"mfa-section",children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[M?.mfaEnabled?t.jsx(vi,{className:"w-5 h-5 text-green-500 shrink-0"}):t.jsx(uc,{className:"w-5 h-5 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Two-Factor Authentication"}),t.jsx("span",{className:"sm:hidden",children:"2FA"}),M?.mfaEnabled?t.jsx(Ke,{variant:"default",className:"ml-2 bg-green-600",children:"Enabled"}):O?.enforced?t.jsx(Ke,{variant:"destructive",className:"ml-2",children:"Required"}):null]}),t.jsx(Xs,{children:"Add an extra layer of security by requiring a verification code when signing in"})]}),t.jsx(mt,{children:M?.mfaEnabled?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:M.mfaMethod==="email"?t.jsxs(t.Fragment,{children:[t.jsx(qi,{className:"w-4 h-4"}),"Verification codes sent to: ",M.mfaEmail]}):t.jsxs(t.Fragment,{children:[t.jsx(Qp,{className:"w-4 h-4"}),"Verification codes sent to: ",M.mfaPhone]})}),O?.enforced?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600 dark:text-amber-400","data-testid":"text-mfa-enforced",children:[t.jsx(ka,{className:"w-4 h-4"}),O.reason==="superadmin"?`Two-factor authentication is required for all ${n.brandName} DB Admin accounts and cannot be disabled.`:"Two-factor authentication is required by your administrator and cannot be disabled."]}),A?t.jsxs("div",{className:"space-y-3 p-3 rounded-md border",children:[t.jsx(re,{children:"Switch Verification Method"}),t.jsxs("div",{className:"flex gap-4",children:[t.jsxs(L,{variant:y==="email"?"default":"outline",onClick:()=>w("email"),className:"flex items-center gap-2","data-testid":"button-change-mfa-email",children:[t.jsx(qi,{className:"w-4 h-4"}),"Email"]}),$&&t.jsxs(L,{variant:y==="sms"?"default":"outline",onClick:()=>w("sms"),className:"flex items-center gap-2","data-testid":"button-change-mfa-sms",children:[t.jsx(Qp,{className:"w-4 h-4"}),"Text Message"]})]}),y==="email"||!$?t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground","data-testid":"text-change-mfa-email-info",children:[t.jsx(qi,{className:"w-4 h-4"}),"Verification codes will be sent to: ",t.jsx("span",{className:"font-medium text-foreground",children:e?.email})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:"change-mfa-phone",children:"Phone Number"}),t.jsx(ke,{id:"change-mfa-phone",type:"tel",placeholder:"+1234567890",value:j,onChange:be=>x(be.target.value),"data-testid":"input-change-mfa-phone"})]}),S?t.jsxs("div",{children:[t.jsx(re,{htmlFor:"change-verification-code",children:"Enter the 6-digit code"}),t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsx(ke,{id:"change-verification-code",type:"text",maxLength:6,placeholder:"000000",value:C,onChange:be=>k(be.target.value.replace(/\D/g,"")),className:"w-32 text-center tracking-widest font-mono","data-testid":"input-change-verification-code"}),t.jsxs(L,{onClick:se,disabled:oe.isPending,"data-testid":"button-change-verify-code",children:[oe.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Verify"]})]})]}):t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(L,{onClick:H,disabled:Y.isPending,"data-testid":"button-change-send-code",children:[Y.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Send Code"]}),t.jsx(L,{variant:"outline",onClick:()=>{T(!1),_(!1),k("")},"data-testid":"button-cancel-change-method",children:"Cancel"})]})]}):t.jsx(L,{variant:"outline",onClick:()=>{T(!0),w(M.mfaMethod==="email"&&$?"sms":"email"),_(!1),k("")},"data-testid":"button-change-mfa-method",children:"Change Verification Method"})]}):t.jsxs(L,{variant:"destructive",onClick:()=>he.mutate(),disabled:he.isPending,"data-testid":"button-disable-mfa",children:[he.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Disable MFA"]})]}):S?t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{children:[t.jsx(re,{htmlFor:"verification-code",children:"Enter the 6-digit code"}),t.jsxs("div",{className:"flex gap-2 mt-2",children:[t.jsx(ke,{id:"verification-code",type:"text",maxLength:6,placeholder:"000000",value:C,onChange:be=>k(be.target.value.replace(/\D/g,"")),className:"w-32 text-center tracking-widest font-mono","data-testid":"input-verification-code"}),t.jsxs(L,{onClick:se,disabled:oe.isPending,"data-testid":"button-verify-code",children:[oe.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Verify"]}),t.jsx(L,{variant:"outline",onClick:()=>{_(!1),k("")},"data-testid":"button-cancel-verification",children:"Cancel"})]})]})}):t.jsxs("div",{className:"space-y-4",children:[O?.enforced&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-600 dar
286k:text-amber-400 p-3 rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800","data-testid":"text-mfa-required",children:[t.jsx(ka,{className:"w-4 h-4 flex-shrink-0"}),O.reason==="superadmin"?`Two-factor authentication is required for all ${n.brandName} DB Admin accounts. Please set it up below.`:"Two-factor authentication is required by your administrator. Please set it up below."]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(re,{children:"Verification Method"}),t.jsxs("div",{className:"flex gap-4",children:[t.jsxs(L,{variant:y==="email"?"default":"outline",onClick:()=>w("email"),className:"flex items-center gap-2","data-testid":"button-mfa-email",children:[t.jsx(qi,{className:"w-4 h-4"}),"Email"]}),$&&t.jsxs(L,{variant:y==="sms"?"default":"outline",onClick:()=>w("sms"),className:"flex items-center gap-2","data-testid":"button-mfa-sms",children:[t.jsx(Qp,{className:"w-4 h-4"}),"Text Message"]})]})]}),y==="email"||!$?t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground","data-testid":"text-mfa-email-info",children:[t.jsx(qi,{className:"w-4 h-4"}),"Verification codes will be sent to: ",t.jsx("span",{className:"font-medium text-foreground",children:e?.email})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:"mfa-phone",children:"Phone Number"}),t.jsx(ke,{id:"mfa-phone",type:"tel",placeholder:"Enter your phone number",value:j,onChange:be=>x(be.target.value),"data-testid":"input-mfa-phone"})]}),t.jsxs(L,{onClick:H,disabled:Y.isPending,"data-testid":"button-send-code",children:[Y.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Send Verification Code"]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(Yc,{className:"w-5 h-5"}),"Push Notifications",V.length>0&&t.jsx(Ke,{variant:"secondary",className:"ml-2",children:V.length})]}),t.jsx(Xs,{children:"Enrolled browsers and devices receive push notifications for alerts. By default all alert types are pushed — device offline/recovery, login alerts, weekly summaries, and smart alerts."})]}),t.jsxs(mt,{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-sm font-medium",children:"Push smart alerts only"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When on, only smart alert matches send push notifications. Device offline, login, and weekly summary alerts will not push."})]}),t.jsx(sr,{checked:M?.pushSmartAlertsOnly??!1,onCheckedChange:be=>le.mutate(be),disabled:le.isPending,"data-testid":"switch-push-smart-alerts-only"})]}),V.length===0?t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-no-push-subs",children:"No devices enrolled yet."}):t.jsx("div",{className:"space-y-2",children:V.map(be=>t.jsxs("div",{className:"flex items-center justify-between gap-4 p-3 rounded-md border","data-testid":`push-sub-${be.id}`,children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(Yc,{className:"w-5 h-5 text-muted-foreground flex-shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium",children:bje(be.ua)}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Enrolled ",new Date(be.createdAt).toLocaleDateString(),be.lastSeenAt&&` · Last used ${new Date(be.lastSeenAt).toLocaleDateString()}`]})]})]}),t.jsx(L,{size:"icon",variant:"ghost",onClick:()=>ge(be.endpoint),"data-testid":`button-revoke-push-${be.id}`,children:t.jsx(sa,{className:"w-4 h-4 text-destructive"})})]},be.id))}),t.jsxs(L,{variant:"outline",onClick:me,disabled:G,"data-testid":"button-enroll-push",children:[G?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Yc,{className:"w-4 h-4 mr-2"}),"Enroll this device"]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Works on Chrome, Edge, Firefox, and desktop Safari. On iPhone & iPad, add ",n.brandName," to your Home Screen first (requires iOS 16.4+)."]})]})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(Yc,{className:"w-5 h-5"}),"Trusted Devices",q.length>0&&t.jsx(Ke,{variant:"secondary",className:"ml-2",children:q.length})]}),t.jsx(Xs,{children:"Devices that can skip two-factor authentication for 30 days"})]}),t.jsx(mt,{children:q.length===0?t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-no-trusted-devices",children:"No trusted devices"}):t.jsxs("div",{className:"space-y-3",children:[q.map(be=>{const ce=be.deviceType==="Mobile"?Yc:be.deviceType==="Tablet"?KK:Vx,Pe=[be.city,be.region].filter(
286Boolean),et=Pe.length>0?Pe.join(", "):null;return t.jsxs("div",{className:"flex items-center justify-between gap-4 p-3 rounded-md border","data-testid":`trusted-device-${be.id}`,children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(ce,{className:"w-5 h-5 text-muted-foreground flex-shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"text-sm font-medium","data-testid":`text-device-browser-${be.id}`,children:[be.browser||"Unknown Browser"," on ",be.deviceType||"Unknown Device"]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5",children:[be.ipAddress&&t.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":`text-device-ip-${be.id}`,children:["IP: ",be.ipAddress]}),et&&t.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1","data-testid":`text-device-location-${be.id}`,children:[t.jsx(Yp,{className:"w-3 h-3"}),et]})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Trusted ",new Date(be.createdAt).toLocaleDateString()," · Expires ",new Date(be.expiresAt).toLocaleDateString()]})]})]}),t.jsx(L,{size:"icon",variant:"ghost",onClick:()=>je.mutate(be.id),disabled:je.isPending,"data-testid":`button-revoke-device-${be.id}`,children:t.jsx(sa,{className:"w-4 h-4 text-destructive"})})]},be.id)}),q.length>1&&t.jsxs(L,{variant:"destructive",onClick:()=>pe.mutate(),disabled:pe.isPending,"data-testid":"button-revoke-all-devices",children:[pe.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Sign Out All Devices"]})]})})]})]})})]})}var ree=["PageUp","PageDown"],nee=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],aee={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Rb="Slider",[yM,jje,Nje]=Bj(Rb),[iee]=oo(Rb,[Nje]),[Sje,p_]=iee(Rb),oee=u.forwardRef((e,s)=>{const{name:r,min:n=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:c=0,defaultValue:d=[n],value:h,onValueChange:p=()=>{},onValueCommit:g=()=>{},inverted:v=!1,form:b,...y}=e,w=u.useRef(new Set),j=u.useRef(0),C=o==="horizontal"?Cje:kje,[k=[],S]=ip({prop:h,defaultProp:d,onChange:D=>{[...w.current][j.current]?.focus(),p(D)}}),_=u.useRef(k);function A(D){const $=Aje(k,D);R(D,$)}function T(D){R(D,j.current)}function M(){const D=_.current[j.current];k[j.current]!==D&&g(k)}function R(D,$,{commit:O}={commit:!1}){const q=Oje(i),V=Dje(Math.round((D-n)/i)*i+n,q),K=Y0(V,[n,a]);S((G=[])=>{const z=Eje(G,K,$);if(Ije(z,c*i)){j.current=z.indexOf(K);const Z=String(z)!==String(G);return Z&&O&&g(z),Z?z:G}else return G})}return t.jsx(Sje,{scope:e.__scopeSlider,name:r,disabled:l,min:n,max:a,valueIndexToChangeRef:j,thumbs:w.current,values:k,orientation:o,form:b,children:t.jsx(yM.Provider,{scope:e.__scopeSlider,children:t.jsx(yM.Slot,{scope:e.__scopeSlider,children:t.jsx(C,{"aria-disabled":l,"data-disabled":l?"":void 0,...y,ref:s,onPointerDown:Ms(y.onPointerDown,()=>{l||(_.current=k)}),min:n,max:a,inverted:v,onSlideStart:l?void 0:A,onSlideMove:l?void 0:T,onSlideEnd:l?void 0:M,onHomeKeyDown:()=>!l&&R(n,0,{commit:!0}),onEndKeyDown:()=>!l&&R(a,k.length-1,{commit:!0}),onStepKeyDown:({event:D,direction:$})=>{if(!l){const V=ree.includes(D.key)||D.shiftKey&&nee.includes(D.key)?10:1,K=j.current,G=k[K],z=i*V*$;R(G+z,K,{commit:!0})}}})})})})});oee.displayName=Rb;var[lee,cee]=iee(Rb,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Cje=u.forwardRef((e,s)=>{const{min:r,max:n,dir:a,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...h}=e,[p,g]=u.useState(null),v=mr(s,C=>g(C)),b=u.useRef(void 0),y=Og(a),w=y==="ltr",j=w&&!i||!w&&i;function x(C){const k=b.current||p.getBoundingClientRect(),S=[0,k.width],A=y3(S,j?[r,n]:[n,r]);return b.current=k,A(C-k.left)}return t.jsx(lee,{scope:e.__scopeSlider,startEdge:j?"left":"right",endEdge:j?"right":"left",direction:j?1:-1,size:"width",children:t.jsx(dee,{dir:y,"data-orientation":"horizontal",...h,ref:v,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const k=x(C.clientX);o?.(k)},onSlideMove:C=>{const k=x(C.clientX);l?.(k)},onSlideEnd:()=>{b.current=void 0,c?.()},onStepKeyDown:C=>{const S=aee[j?"from-left":"from-right"].includes(C.key);d?.({event:C,direction:S?-1:1})}})})}),kje=u.forwardRef((e,s)=>{const{min:r,max:n,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:l,onStepKeyDown:c,...d}=e,h=u.useRef(null),p=mr(s,h),g=u.useRef(void 0),v=!a;function b(y){const w=g.current||h.current.getBoundingClientRect(),j=[0,w.height],C=y3(j,v?[n,r]:[r,n]);return g.current=w,C(y-w.top)}return t.jsx(lee,{scope:e.__scopeSlider,startEdge:v?"bottom":"top",endEdge:v?"top":"bottom",size:"height",direction:v?1:-1,children:t.jsx(dee,{"data-orientation":"vertical",...d,ref:p,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:y=>{const w=b(y.clientY);i?.(w)},onSlideMove:y=>{const w=b(y.clientY);o?.(w)},onSlideEnd:()=>{g.current=void 0,l?.()},onStepKeyDown:y=>{const j=aee[v?"from-bottom":"from-top"].includes(y.key);c?.({event:y,direction:j?-1:1})}})})}),dee=u.forwardRef((e,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:c,...d}=e,h=p_(Rb,r);return t.jsx(Cr.span,{...d,ref:s,onKeyDown:Ms(e.onKeyDown,p=>{p.key==="Home"?(o(p),p.preventDefault()):p.key==="End"?(l(p),p.preventDefault()):ree.concat(nee).includes(p.key)&&(c(p),p.preventDefault())}),onPointerDown:Ms(e.onPointerDown,p=>{const g=p.target;g.setPointerCapture(p.pointerId),p.preventDefault(),h.thumbs.has(g)?g.focus():n(p)}),onPointerMove:Ms(e.onPointerMove,p=>{p.target.hasPointerCapture(p.pointerId)&&a(p)}),onPointerUp:Ms(e.onPointerUp,p=>{const g=p.target;g.hasPointerCapture(p.pointerId)&&(g.releasePointerCapture(p.pointerId),i(p))})})}),uee="SliderTrack",mee=u.forwardRef((e,s)=>{const{__scopeSlider:r,...n}=e,a=p_(uee,r);return t.jsx(Cr.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});mee.displayName=uee;var bM="SliderRange",hee=u.forwardRef((e,s)=>{const{__scopeSlider:r,...n}=e,a=p_(bM,r),i=cee(bM,r),o=u.useRef(null),l=mr(s,o),c=a.values.length,d=a.values.map(g=>
286fee(g,a.min,a.max)),h=c>1?Math.min(...d):0,p=100-Math.max(...d);return t.jsx(Cr.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:l,style:{...e.style,[i.startEdge]:h+"%",[i.endEdge]:p+"%"}})});hee.displayName=bM;var wM="SliderThumb",pee=u.forwardRef((e,s)=>{const r=jje(e.__scopeSlider),[n,a]=u.useState(null),i=mr(s,l=>a(l)),o=u.useMemo(()=>n?r().findIndex(l=>l.ref.current===n):-1,[r,n]);return t.jsx(_je,{...e,ref:i,index:o})}),_je=u.forwardRef((e,s)=>{const{__scopeSlider:r,index:n,name:a,...i}=e,o=p_(wM,r),l=cee(wM,r),[c,d]=u.useState(null),h=mr(s,x=>d(x)),p=c?o.form||!!c.closest("form"):!0,g=_b(c),v=o.values[n],b=v===void 0?0:fee(v,o.min,o.max),y=Tje(n,o.values.length),w=g?.[l.size],j=w?Mje(w,b,l.direction):0;return u.useEffect(()=>{if(c)return o.thumbs.add(c),()=>{o.thumbs.delete(c)}},[c,o.thumbs]),t.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[l.startEdge]:`calc(${b}% + ${j}px)`},children:[t.jsx(yM.ItemSlot,{scope:e.__scopeSlider,children:t.jsx(Cr.span,{role:"slider","aria-label":e["aria-label"]||y,"aria-valuemin":o.min,"aria-valuenow":v,"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:h,style:v===void 0?{display:"none"}:e.style,onFocus:Ms(e.onFocus,()=>{o.valueIndexToChangeRef.current=n})})}),p&&t.jsx(Pje,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:v},n)]})});pee.displayName=wM;var Pje=e=>{const{value:s,...r}=e,n=u.useRef(null),a=Gj(s);return u.useEffect(()=>{const i=n.current,o=window.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(o,"value").set;if(a!==s&&c){const d=new Event("input",{bubbles:!0});c.call(i,s),i.dispatchEvent(d)}},[a,s]),t.jsx("input",{style:{display:"none"},...r,ref:n,defaultValue:s})};function Eje(e=[],s,r){const n=[...e];return n[r]=s,n.sort((a,i)=>a-i)}function fee(e,s,r){const i=100/(r-s)*(e-s);return Y0(i,[0,100])}function Tje(e,s){return s>2?`Value ${e+1} of ${s}`:s===2?["Minimum","Maximum"][e]:void 0}function Aje(e,s){if(e.length===1)return 0;const r=e.map(a=>Math.abs(a-s)),n=Math.min(...r);return r.indexOf(n)}function Mje(e,s,r){const n=e/2,i=y3([0,50],[0,n]);return(n-i(s)*r)*r}function Rje(e){return e.slice(0,-1).map((s,r)=>e[r+1]-s)}function Ije(e,s){if(s>0){const r=Rje(e);return Math.min(...r)>=s}return!0}function y3(e,s){return r=>{if(e[0]===e[1]||s[0]===s[1])return s[0];const n=(s[1]-s[0])/(e[1]-e[0]);return s[0]+n*(r-e[0])}}function Oje(e){return(String(e).split(".")[1]||"").length}function Dje(e,s){const r=Math.pow(10,s);return Math.round(e*r)/r}var gee=oee,Lje=mee,$je=hee,Fje=pee;const km=u.forwardRef(({className:e,...s},r)=>t.jsxs(gee,{ref:r,className:Cs("relative flex w-full touch-none select-none items-center",e),...s,children:[t.jsx(Lje,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:t.jsx($je,{className:"absolute h-full bg-primary"})}),t.jsx(Fje,{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"})]}));km.displayName=gee.displayName;const Bje=[{id:"display",label:"Display",icon:Xr},{id:"dashboard",label:"Dashboard",icon:tO},{id:"live-view",label:"Live View",icon:Vx},{id:"recordings",label:"Recordings",icon:ZI},{id:"notifications",label:"Notifications",icon:mi},{id:"ai",label:"AI",icon:M5}];function yF(){const{user:e}=Gi(),[,s]=Ia(),{toast:r}=Hs(),{theme:n,setTheme:a}=YG(),i=Er(),[o,l]=u.useState("display"),c=u.useRef({}),{data:d,isLoading:h}=ze({queryKey:["/api/user/settings"]}),{data:p}=ze({queryKey:["/api/user/location/policy"]}),{data:g}=ze({queryKey:["/api/user/role"]});g?.role;const v=["owner","admin","superadmin"].includes(g?.role??""),{data:b,isLoading:y}=ze({queryKey:["/api/device-notifications/preferences"]}),w=Et({mutationFn:async O=>{await Ze("PATCH","/api/device-notifications/preferences",{deviceNotificationsEnabled:O})},onSuccess:()=>
286{Je.invalidateQueries({queryKey:["/api/device-notifications/preferences"]})},onError:()=>{r({title:"Error",description:"Failed to update notification preferences.",variant:"destructive"})}}),j=Et({mutationFn:async O=>{await Ze("PATCH","/api/device-notifications/preferences",{weeklySummaryEnabled:O})},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/device-notifications/preferences"]})},onError:()=>{r({title:"Error",description:"Failed to update summary preferences.",variant:"destructive"})}}),x=Et({mutationFn:async O=>{await Ze("PATCH","/api/device-notifications/preferences",{maxAlertsPerDay:O})},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/device-notifications/preferences"]})},onError:()=>{r({title:"Error",description:"Failed to update max alerts.",variant:"destructive"})}}),C=Et({mutationFn:O=>Ze("PATCH","/api/user/settings",O),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/user/settings"]})},onError:()=>{r({title:"Error",description:"Failed to update preferences",variant:"destructive"})}}),k=Et({mutationFn:O=>Ze("PATCH","/api/user/settings",O),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/user/settings"]})},onError:()=>{r({title:"Error",description:"Failed to update color",variant:"destructive"})}}),S=O=>{C.mutate({refreshRate:parseInt(O,10)})},_=O=>{C.mutate({previewCycleRate:parseInt(O,10)})},A=O=>{C.mutate({dashboardPreviewRate:parseInt(O,10)})},T=O=>{C.mutate({dashboardPreviewLayout:parseInt(O,10)})},M=O=>{C.mutate({companySortOrder:O})},R=O=>{C.mutate({siteSortOrder:O})},D=Et({mutationFn:async O=>{await Ze("PATCH","/api/user/show-location",{showLocation:O})},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/auth/user"]}),Je.invalidateQueries({queryKey:["/api/companies"]}),r({title:"Preference updated",description:"Location visibility preference has been saved"})},onError:()=>{r({title:"Error",description:"Failed to update location preference",variant:"destructive"})}}),$=O=>{l(O);const q=c.current[O];q&&q.scrollIntoView({behavior:"smooth",block:"start"})};return h?t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:t.jsx(Fe,{className:"w-8 h-8 animate-spin text-primary"})}):t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-14",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>s("/"),"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(oO,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold",children:"Preferences"})]}),t.jsx("div",{className:"hidden sm:flex items-center gap-1 overflow-x-auto",children:Bje.map(({id:O,label:q,icon:V})=>t.jsxs("button",{onClick:()=>$(O),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm font-medium whitespace-nowrap transition-colors ${o===O?"bg-primary/10 text-primary":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,"data-testid":`tab-${O}`,children:[t.jsx(V,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden sm:inline",children:q})]},O))}),t.jsx(qd,{showDashboardLink:!0})]})})}),t.jsxs("main",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-10",children:[t.jsxs("section",{ref:O=>{c.current.display=O},"data-testid":"section-display",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(Xr,{className:"w-5 h-5 text-primary"}),t.jsx("h2",{className:"text-lg font-semibold",children:"Display"})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[n==="light"?t.jsx(A$,{className:"w-5 h-5"}):n==="dark"?t.jsx(E$,{className:"w-5 h-5"}):t.jsx(_$,{className:"w-5 h-5"}),"Appearance"]}),t.jsx(Xs,{children:"Choose your preferred display theme"})]}),t.jsx(mt,{children:t.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{value:"light",label:"Light Dark",icon:A$},{value:"dark",label:"Dark",icon:E$},{value:"darker",label:"Darker",icon:_$}].map(({value:O,label:q,icon:V})=>t.jsxs("button",{onClick:()=>{a(O),C.mutate({theme:O})},className:`flex flex-col items-center gap-2 p-3 rounded-md border transition-colors ${n===O?"border-primary bg-primary/10 text-primary":"border-border hover:border-muted-foreground
286/30 text-muted-foreground"}`,"data-testid":`button-theme-${O}`,children:[t.jsx(V,{className:"w-5 h-5"}),t.jsx("span",{className:"text-xs font-medium",children:q})]},O))})})]}),i.showDemetriMode!=="false"&&t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(Do,{className:"w-5 h-5"}),"Demetri Mode"]}),t.jsx(Xs,{children:"Switch the accent color from blue to purple across the entire interface"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Enable purple theme"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Replaces the default blue accents with purple"})]}),t.jsx(sr,{checked:d?.demetriMode??!1,onCheckedChange:O=>C.mutate({demetriMode:O}),disabled:C.isPending,"data-testid":"switch-demetri-mode"})]})})]})]})]}),t.jsxs("section",{ref:O=>{c.current.dashboard=O},"data-testid":"section-dashboard",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(tO,{className:"w-5 h-5 text-primary"}),t.jsx("h2",{className:"text-lg font-semibold",children:"Dashboard"})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{children:"Refresh Rate"}),t.jsx(Xs,{children:"How often the dashboard automatically refreshes site status"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(re,{htmlFor:"refresh-rate",className:"min-w-fit",children:"Refresh every"}),t.jsxs(Us,{value:d?.refreshRate?.toString()||"30",onValueChange:S,disabled:C.isPending,children:[t.jsx($s,{className:"w-40","data-testid":"select-refresh-rate",children:t.jsx(zs,{placeholder:"Select rate"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"10",children:"10 seconds"}),t.jsx(rt,{value:"15",children:"15 seconds"}),t.jsx(rt,{value:"30",children:"30 seconds"}),t.jsx(rt,{value:"60",children:"1 minute"}),t.jsx(rt,{value:"120",children:"2 minutes"}),t.jsx(rt,{value:"300",children:"5 minutes"})]})]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{children:"Preview Cycling"}),t.jsx(Xs,{children:"How often camera previews cycle on the dashboard site cards (if grid-view is selected only)"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(re,{className:"min-w-fit",children:"Auto-cycle"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(L,{variant:d?.dashboardPreviewCycling??!1?"default":"outline",size:"sm",onClick:()=>C.mutate({dashboardPreviewCycling:!0}),disabled:C.isPending,"data-testid":"button-cycling-on",children:"On"}),t.jsx(L,{variant:d?.dashboardPreviewCycling??!1?"outline":"default",size:"sm",onClick:()=>C.mutate({dashboardPreviewCycling:!1}),disabled:C.isPending,"data-testid":"button-cycling-off",children:"Off"})]})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(re,{htmlFor:"dashboard-preview-rate",className:"min-w-fit",children:"Cycle interval"}),t.jsxs(Us,{value:d?.dashboardPreviewRate?.toString()||"10",onValueChange:A,disabled:C.isPending||!(d?.dashboardPreviewCycling??!1),children:[t.jsx($s,{className:"w-40","data-testid":"select-dashboard-preview-rate",children:t.jsx(zs,{placeholder:"Select rate"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"5",children:"5 seconds"}),t.jsx(rt,{value:"10",children:"10 seconds"}),t.jsx(rt,{value:"15",children:"15 seconds"}),t.jsx(rt,{value:"30",children:"30 seconds"}),t.jsx(rt,{value:"60",children:"1 minute"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(re,{htmlFor:"dashboard-preview-layout",className:"min-w-fit",children:"Preview layout"}),t.jsxs(Us,{value:d?.dashboardPreviewLayout?.toString()||"1",onValueChange:T,disabled:C.isPending,children:[t.jsx($s,{className:"w-40","data-testid":"select-dashboard-preview-layout",children:t.jsx(zs,{placeholder:"Select layout"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"1",children:"Single camera"}),t.jsx(rt,{value:"6",children:"6-camera grid"})]})]})]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(s1,{className:"w-5 h-5"}),"Company Order"]}),t.jsx(Xs,{children:"Choose how companies are sorted on the dashboard"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(re,{htmlFor:"sort-order",className:"min-w-fit",children:"Sort companies"}),t.jsxs(Us,{value:d?.companySortOrder||"asc",onValueChange:M,disabled:C.isPending,children:[t.jsx($s,{className:"w-48","data-testid":"select-company-sort",children:t.jsx(zs,{placeholder:"Select order"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"asc",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(C$,{className:"w-4 h-4"}),"A to Z"]})}),t.jsx(rt,{value:"desc",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(S$,{className:"w-4 h-4"}),"Z to A"]})}),t.jsx(rt,{value:"custom",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(s1,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Custom Order"}),t.jsx("span",{className:"sm:hidden",children:"Custom"})]})})]})]})]}),d?.companySortOrder==="custom"&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag and drop companies on the dashboard to set your custom order"})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(s1,{className:"w-5 h-5"}),"Site Order"]}),t.jsx(Xs,{children:"Choose how sites are sorted within each company"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(re,{htmlFor:"site-sort-order",className:"min-w-fit",children:"Sort sites"}),t.jsxs(Us,{value:d?.siteSortOrder||"asc",onValueChange:R,disabled:C.isPending,children:[t.jsx($s,{className:"w-48","data-testid":"select-site-sort",children:t.jsx(zs,{placeholder:"Select order"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"asc",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(C$,{className:"w-4 h-4"}),"A to Z"]})}),t.jsx(rt,{value:"desc",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(S$,{className:"w-4 h-4"}),"Z to A"]})}),t.jsx(rt,{value:"custom",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(s1,{className:"w-4 h-4"}),t.jsx("span",{className:"hidden sm:inline",children:"Custom Order"}),t.jsx("span",{className:"sm:hidden",children:"Custom"})]})})]})]})]}),d?.siteSortOrder==="custom"&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag and drop sites within a company on the dashboard to set your custom order"})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(ql,{className:"w-5 h-5"}),"Edge Locations"]}),t.jsx(Xs,{children:"Control whether edge device locations are shown on your dashboard"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Show device location on dashboard"}),p?.policyAllows===!1?t.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1 mt-1",children:[t.jsx(ka,{className:"w-3 h-3"}),"Location is currently hidden by your administrator's policy"]}):t.jsx("p",{className:"text-xs text-muted-foreground",children:"When enabled, hosted location details will appear on site cards"})]}),t.jsxs(L,{variant:e?.showLocation!==!1&&p?.policyAllows!==!1?"default":"outline",className:"",onClick:()=>D.mutate(e?.showLocation===!1),disabled:D.isPending||p?.policyAllows===!1,"data-testid":"button-toggle-show-location",children:[D.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):p?.policyAllows===!1?t.jsx(ka,{className:"w-4 h-4 mr-2"}):e?.showLocation!==!1?t.jsx(Yp,{className:"w-4 h-4 mr-2"}):t.jsx(ql,{className:"w-4 h-4 mr-2"}),p?.policyAllows===!1?"Hidden by Policy":e?.showLocation!==!1?"Visible":"Hidden"]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(uf,{className:"w-5 h-5"}),"System Metrics"]}),t.jsx(Xs,{children:"Show hardware and uptime stats on dashboard site cards"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Show System Metrics"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Display edge device performance metrics on the dashboard"})]}),t.jsx(sr,{checked:d?.showSystemMetrics??!1,onCheckedChange:O=>C.mutate({showSystemMetrics:O}),disabled:C.isPending,"data-testid":"switch-show-system-metrics"})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(ro,{className:"w-5 h-5"}),"Oldest Recording"]}),t.jsx(Xs,{children:"Show the oldest available recording date on dashboard site cards"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Show Oldest Recording"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the earliest local or cloud recording date for each site"})]}),t.jsx(sr,{checked:d?.showOldestRecording??!0,onCheckedChange:O=>C.mutate({showOldestRecording:O}),disabled:C.isPending,"data-testid":"switch-show-oldest-recording"})]})})]}),v&&t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(Xr,{className:"w-5 h-5"}),"Incognito mode"]}),t.jsx(Xs,{children:"Hide your name and login email address in Live Monitoring."})]}),t.jsxs(mt,{className:"flex items-center justify-between gap-4",children:[t.jsx(re,{htmlFor:"switch-live-monitoring-incognito",children:"Hide my identity in Live Monitoring"}),t.jsx(sr,{id:"switch-live-monitoring-incognito",checked:d?.liveMonitoringIncognito??!1,onCheckedChange:O=>C.mutate({liveMonitoringIncognito:O}),disabled:C.isPending,"data-testid":"switch-live-monitoring-incognito"})]})]})]})]}),t.jsxs("section",{ref:O=>{c.current["live-view"]=O},"data-testid":"section-live-view",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(Vx,{className:"w-5 h-5 text-primary"}),t.jsx("h2",{className:"text-lg font-semibold",children:"Live View"})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{children:"Looping"}),t.jsx(Xs,{children:"How often camera previews cycle to the next camera in live views"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(re,{htmlFor:"preview-cycle-rate",className:"min-w-fit",children:"Cycle interval"}),t.jsxs(Us,{value:d?.previewCycleRate?.toString()||"5",onValueChange:_,disabled:C.isPending,children:[t.jsx($s,{className:"w-40","data-testid":"select-preview-cycle-rate",children:t.jsx(zs,{placeholder:"Select rate"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"3",children:"3 seconds"}),t.jsx(rt,{value:"5",children:"5 seconds"}),t.jsx(rt,{value:"10",children:"10 seconds"}),t.jsx(rt,{value:"15",children:"15 seconds"}),t.jsx(rt,{value:"30",children:"30 seconds"}),t.jsx(rt,{value:"60",children:"1 minute"})]})]})]})})]})})]}),t.jsxs("section",{ref:O=>{c.current.recordings=O},"data-testid":"section-recordings",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(ZI,{className:"w-5 h-5 text-primary"}),t.jsx("h2",{className:"text-lg font-semibold",children:"Recordings"})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(ky,{className:"w-5 h-5"}),"Playback"]}),t.jsx(Xs,{children:"Control auto-play behavior when viewing recordings in the timeline"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Auto-play next clip"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When enabled, the next clip on the same camera will automatically play after the current one ends"})]}),t.jsxs(L,{variant:d?.autoPlayEnabled??!0?"default":"outline",className:"",onClick:()=>C.mutate({autoPlayEnabled:!(d?.autoPlayEnabled??!0)}),disabled:C.isPending,"data-testid":"button-toggle-autoplay",children:[C.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(ky,{className:"w-4 h-4 mr-2"}),d?.autoPlayEnabled??!0?"On":"Off"]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(rO,{className:"w-5 h-5"}),"Timeline Colors"]}),t.jsx(Xs,{children:"Customize the colors used for detection and motion events on the recordings timeline"})]}),t.jsx(mt,{children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(re,{className:"min-w-[120px]",children:"AI Events Color"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"color",value:d?.timelineDetectionColor||"#3b82f6",onChange:O=>k.mutate({timelineDetectionColor:O.target.value}),disabled:k.isPending,className:"w-9 h-9 rounded-md border border-border 
286cursor-pointer","data-testid":"input-detection-color"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:d?.timelineDetectionColor||"#3b82f6"})]})]}),t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(re,{className:"min-w-[120px]",children:"Motion Color"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"color",value:d?.timelineMotionColor||"#eab308",onChange:O=>k.mutate({timelineMotionColor:O.target.value}),disabled:k.isPending,className:"w-9 h-9 rounded-md border border-border cursor-pointer","data-testid":"input-motion-color"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:d?.timelineMotionColor||"#eab308"})]})]}),t.jsx("div",{className:"pt-2",children:t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>k.mutate({timelineDetectionColor:"#3b82f6",timelineMotionColor:"#eab308"}),disabled:k.isPending||d?.timelineDetectionColor==="#3b82f6"&&d?.timelineMotionColor==="#eab308","data-testid":"button-reset-timeline-colors",children:[t.jsx(bh,{className:"w-4 h-4 mr-2"}),"Reset to Defaults"]})})]})})]})]})]}),t.jsxs("section",{ref:O=>{c.current.ai=O},"data-testid":"section-ai",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(M5,{className:"w-5 h-5 text-primary"}),t.jsx("h2",{className:"text-lg font-semibold",children:"AI"})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.jsxs(ut,{className:"md:col-span-2",children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(M5,{className:"w-5 h-5"}),"AI Analysis Settings"]}),t.jsx(Xs,{children:"Control thresholds used for AI-powered features in Recordings"})]}),t.jsxs(mt,{className:"space-y-6",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Color Matching Threshold"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Minimum percentage of the detected object that must match the selected color."})]}),t.jsxs("span",{className:"text-sm font-semibold tabular-nums w-12 text-right","data-testid":"text-color-threshold-value",children:[d?.aiColorThreshold??15,"%"]})]}),t.jsx(km,{min:1,max:100,step:1,value:[d?.aiColorThreshold??15],onValueChange:([O])=>k.mutate({aiColorThreshold:O}),disabled:k.isPending,"data-testid":"slider-color-threshold"}),t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[t.jsx("span",{children:"1% (permissive)"}),t.jsx("span",{children:"100% (strict)"})]})]}),t.jsxs("div",{className:"space-y-3 border-t pt-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Confidence Level Filter"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Only show events where the detection confidence meets this minimum. Set to 0 to show all events."})]}),t.jsxs("span",{className:"text-sm font-semibold tabular-nums w-16 text-right","data-testid":"text-confidence-threshold-value",children:[((d?.aiConfidenceThreshold??0)*100).toFixed(0),"%"]})]}),t.jsx(km,{min:0,max:100,step:1,value:[Math.round((d?.aiConfidenceThreshold??0)*100)],onValueChange:([O])=>k.mutate({aiConfidenceThreshold:O/100}),disabled:k.isPending,"data-testid":"slider-confidence-threshold"}),t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[t.jsx("span",{children:"0% (show all)"}),t.jsx("span",{children:"100% (highest confidence only)"})]})]}),t.jsx("div",{className:"pt-2",children:t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>k.mutate({aiColorThreshold:15,aiConfidenceThreshold:.48}),disabled:k.isPending||d?.aiColorThreshold===15&&d?.aiConfidenceThreshold===.48,"data-testid":"button-reset-ai-settings",children:[t.jsx(bh,{className:"w-4 h-4 mr-2"}),"Reset to Defaults"]})})]})]})})]}),t.jsxs("section",{ref:O=>{c.current.notifications=O},"data-testid":"section-notifications",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[t.jsx(mi,{className:"w-5 h-5 text-primary"}),t.jsx("h2",{className:"text-lg font-semibold",children:"Notifications"})]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.jsxs(ut,{className:"md:col-span-2",children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(mi,{className:"w-5 h-5"}),"Device Notifications"]}),t.jsx(Xs,{children:"Control email alerts for edge device status changes"})]}),t.jsxs(mt,{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Email Alerts"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Receive alerts when devices go offline or come back online."})]}
286),t.jsx(sr,{checked:b?.deviceNotificationsEnabled??!1,onCheckedChange:O=>w.mutate(O),disabled:y||w.isPending,"data-testid":"switch-device-notifications-toggle"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4 border-t pt-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Max Alerts Per Day"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Maximum number of alert emails you can receive per day (1-20)."})]}),t.jsxs(Us,{value:String(b?.maxAlertsPerDay??6),onValueChange:O=>x.mutate(Number(O)),disabled:y||x.isPending,children:[t.jsx($s,{className:"w-20","data-testid":"select-max-alerts",children:t.jsx(zs,{})}),t.jsx(Fs,{children:Array.from({length:20},(O,q)=>q+1).map(O=>t.jsx(rt,{value:String(O),children:O},O))})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4 border-t pt-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Email Summary"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Weekly health summary sent every Monday at 9:00 AM UTC."})]}),t.jsx(sr,{checked:b?.weeklySummaryEnabled??!0,onCheckedChange:O=>j.mutate(O),disabled:y||j.isPending,"data-testid":"switch-weekly-summary-toggle"})]})]})]})})]})]})]})}function nh(e,s){const r=new Set(Array.isArray(e?.companyIds)?e.companyIds:[]),n=new Set(Array.isArray(e?.siteIds)?e.siteIds:[]);if(n.size>0)for(const a of s)(a.sites||[]).some(i=>n.has(i.id))&&r.add(a.id);return Array.from(r)}function Uje(e,s,r){return Array.isArray(e?.siteIds)&&e.siteIds.includes(s)?!0:!!r&&Array.isArray(e?.companyIds)&&e.companyIds.includes(r)}const Fy=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{className:"relative w-full overflow-auto",children:t.jsx("table",{ref:r,className:Cs("w-full caption-bottom text-sm",e),...s})}));Fy.displayName="Table";const By=u.forwardRef(({className:e,...s},r)=>t.jsx("thead",{ref:r,className:Cs("[&_tr]:border-b",e),...s}));By.displayName="TableHeader";const Uy=u.forwardRef(({className:e,...s},r)=>t.jsx("tbody",{ref:r,className:Cs("[&_tr:last-child]:border-0",e),...s}));Uy.displayName="TableBody";const zje=u.forwardRef(({className:e,...s},r)=>t.jsx("tfoot",{ref:r,className:Cs("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...s}));zje.displayName="TableFooter";const hu=u.forwardRef(({className:e,...s},r)=>t.jsx("tr",{ref:r,className:Cs("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...s}));hu.displayName="TableRow";const fa=u.forwardRef(({className:e,...s},r)=>t.jsx("th",{ref:r,className:Cs("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...s}));fa.displayName="TableHead";const ia=u.forwardRef(({className:e,...s},r)=>t.jsx("td",{ref:r,className:Cs("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...s}));ia.displayName="TableCell";const Hje=u.forwardRef(({className:e,...s},r)=>t.jsx("caption",{ref:r,className:Cs("mt-4 text-sm text-muted-foreground",e),...s}));Hje.displayName="TableCaption";function aN(){const{data:e,isLoading:s}=ze({queryKey:["/api/me/permissions"],staleTime:6e4,refetchOnWindowFocus:!0,refetchInterval:3e5});function r(n,a="read"){return!e||!e.isSuperadmin?!1:e.isPrimary?!0:!!e.permissions?.[n]?.[a]}return{permissions:e?.permissions,isSuperadmin:!!e?.isSuperadmin,isPrimary:!!e?.isPrimary,allowEdgeLaunch:e?.allowEdgeLaunch!==!1,isLoading:s,can:r}}var b3="Progress",w3=100,[qje]=oo(b3),[Vje,Wje]=qje(b3),xee=u.forwardRef((e,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:i=Kje,...o}=e;(a||a===0)&&!bF(a)&&console.error(Gje(`${a}`,"Progress"));const l=bF(a)?a:w3;n!==null&&!wF(n,l)&&console.error(Yje(`${n}`,"Progress"));const c=wF(n,l)?n:null,d=hC(c)?i(c,l):void 0;return t.jsx(Vje,{scope:r,value:c,max:l,children:t.jsx(Cr.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":hC(c)?c:void 0,"aria-valuetext":d,role:"progressbar","data-state":bee(c,l),"data-value":c??void 0,"data-max":l,...o,ref:s})})});xee.displayName=b3;var vee="ProgressIndicator",yee=u.forwardRef((e,s)=>{const{__scopeProgress:r,...n}=e,a=Wje(vee,r);return t.jsx(Cr.div,{"data-state":bee(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});yee.displayName=vee;function Kje(e,s){return`${Math.round(e/s*100)}%`}function bee(e,s){return e==null?"indeterminate":e===s?"complete":"loading"}function hC(e){return typeof e=="number"}function bF(e){return hC(e)&&!isNaN(e)&&e>0}function wF(e,s){return hC(e)&&!isNaN(e)&&e<=s&&e>=0}function Gje(e,s){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${w3}\`.`}function Yje(e,s){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${s}\`. The \`value\` prop must be:
287  - a positive number
288  - less than the value passed to \`max\` (or ${w3} if no \`max\` prop is set)
289  - \`null\` or \`undefined\` if the progress is indeterminate.
290
291Defaulting to \`null\`.`}var wee=xee,Qje=yee;const j3=u.forwardRef(({className:e,value:s,...r},n)=>t.jsx(wee,{ref:n,className:Cs("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...r,children:t.jsx(Qje,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));
291j3.displayName=wee.displayName;const Xje=Hj("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"}}),pu=u.forwardRef(({className:e,variant:s,...r},n)=>t.jsx("div",{ref:n,role:"alert",className:Cs(Xje({variant:s}),e),...r}));pu.displayName="Alert";const Yu=u.forwardRef(({className:e,...s},r)=>t.jsx("h5",{ref:r,className:Cs("mb-1 font-medium leading-none tracking-tight",e),...s}));Yu.displayName="AlertTitle";const fu=u.forwardRef(({className:e,...s},r)=>t.jsx("div",{ref:r,className:Cs("text-sm [&_p]:leading-relaxed",e),...s}));fu.displayName="AlertDescription";function un(e){const s=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&s==="[object Date]"?new e.constructor(+e):typeof e=="number"||s==="[object Number]"||typeof e=="string"||s==="[object String]"?new Date(e):new Date(NaN)}function Nu(e,s){return e instanceof Date?new e.constructor(s):new Date(s)}function Ud(e,s){const r=un(e);return isNaN(s)?Nu(e,NaN):(s&&r.setDate(r.getDate()+s),r)}function kh(e,s){const r=un(e);if(isNaN(s))return Nu(e,NaN);if(!s)return r;const n=r.getDate(),a=Nu(e,r.getTime());a.setMonth(r.getMonth()+s+1,0);const i=a.getDate();return n>=i?a:(r.setFullYear(a.getFullYear(),a.getMonth(),n),r)}const N3=6048e5,Zje=864e5,y1=43200,jF=1440;let Jje={};function Ib(){return Jje}function up(e,s){const r=Ib(),n=s?.weekStartsOn??s?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=un(e),i=a.getDay(),o=(i<n?7:0)+i-n;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function Jx(e){return up(e,{weekStartsOn:1})}function jee(e){const s=un(e),r=s.getFullYear(),n=Nu(e,0);n.setFullYear(r+1,0,4),n.setHours(0,0,0,0);const a=Jx(n),i=Nu(e,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const o=Jx(i);return s.getTime()>=a.getTime()?r+1:s.getTime()>=o.getTime()?r:r-1}function zy(e){const s=un(e);return s.setHours(0,0,0,0),s}function Hy(e){const s=un(e),r=new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds()));return r.setUTCFullYear(s.getFullYear()),+e-+r}function Xh(e,s){const r=zy(e),n=zy(s),a=+r-Hy(r),i=+n-Hy(n);return Math.round((a-i)/Zje)}function eNe(e){const s=jee(e),r=Nu(e,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),Jx(r)}function jM(e,s){const r=s*7;return Ud(e,r)}function tNe(e,s){return kh(e,s*12)}function sNe(e){let s;return e.forEach(function(r){const n=un(r);(s===void 0||s<n||isNaN(Number(n)))&&(s=n)}),s||new Date(NaN)}function rNe(e){let s;return e.forEach(r=>{const n=un(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function mS(e,s){const r=un(e),n=un(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function nNe(e){return Nu(e,Date.now())}function yu(e,s){const r=zy(e),n=zy(s);return+r==+n}function S3(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function aNe(e){if(!S3(e)&&typeof e!="number")return!1;const s=un(e);return!isNaN(Number(s))}function qy(e,s){const r=un(e),n=un(s),a=r.getFullYear()-n.getFullYear(),i=r.getMonth()-n.getMonth();return a*12+i}function iNe(e,s,r){const n=up(e,r),a=up(s,r),i=+n-Hy(n),o=+a-Hy(a);return Math.round((i-o)/N3)}function oNe(e){return s=>{const n=(e?Math[e]:Math.trunc)(s);return n===0?0:n}}function lNe(e,s){return+un(e)-+un(s)}function cNe(e){const s=un(e);return s.setHours(23,59,59,999),s}function f_(e){const s=un(e),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function dNe(e){const s=un(e);return+cNe(s)==+f_(s)}function uNe(e,s){const r=un(e),n=un(s),a=mS(r,n),i=Math.abs(qy(r,n));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=mS(r,n)===-a;dNe(un(e))&&i===1&&mS(e,n)===1&&(l=!1),o=a*(i-Number(l))}return o===0?0:o}function mNe(e,s,r){const n=lNe(e,s)/1e3;return oNe(r?.roundingMethod)(n)}function ju(e){const s=un(e);return s.setDate(1),s.setHours(0,0,0,0),s}function Nee(e){const s=un(e),r=Nu(e,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function C3(e,s){const r=Ib(),n=s?.weekStartsOn??s?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=un(e),i=a.getDay(),o=(i<n?-7:0)+6-(i-n);return a.setDate(a.getDate()+o),a.setHours(23,59,59,999),a}function See(e){return C3(e,{weekStartsOn:1}
vendor: 17,069 bytes, line 291
291)}const hNe={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"}},pNe=(e,s,r)=>{let n;const a=hNe[e];return typeof a=="string"?n=a:s===1?n=a.one:n=a.other.replace("{{count}}",s.toString()),r?.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function CP(e){return(s={})=>{const r=s.width?String(s.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}const fNe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},gNe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},xNe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},vNe={date:CP({formats:fNe,defaultWidth:"full"}),time:CP({formats:gNe,defaultWidth:"full"}),dateTime:CP({formats:xNe,defaultWidth:"full"})},yNe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},bNe=(e,s,r,n)=>yNe[e];function yw(e){return(s,r)=>{const n=r?.context?String(r.context):"standalone";let a;if(n==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,l=r?.width?String(r.width):o;a=e.formattingValues[l]||e.formattingValues[o]}else{const o=e.defaultWidth,l=r?.width?String(r.width):e.defaultWidth;a=e.values[l]||e.values[o]}const i=e.argumentCallback?e.argumentCallback(s):s;return a[i]}}const wNe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},jNe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},NNe={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"]},SNe={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","Friday","Saturday"]},CNe={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"}},kNe={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"}},_Ne=(e,s)=>{const r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},PNe={ordinalNumber:_Ne,era:yw({values:wNe,defaultWidth:"wide"}),quarter:yw({values:jNe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:yw({values:NNe,defaultWidth:"wide"}),day:yw({values:SNe,defaultWidth:"wide"}),dayPeriod:yw({values:CNe,defaultWidth:"wide",formattingValues:kNe,defaultFormattingWidth:"wide"})};function bw(e){return(s,r={})=>{const n=r.width,a=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],i=s.match(a);if(!i)return null;const o=i[0],l=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(l)?TNe(l,p=>p.test(o)):ENe(l,p=>p.test(o));let d;d=e.valueCallback?e.valueCallback(c):c,d=r.valueCallback?r.valueCallback(d):d;const h=s.slice(o.length);return{value:d,rest:h}}}function ENe(e,s){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&s(e[r]))return r}function TNe(e,s){for(let r=0;r<e.length;r++)if(s(e[r]))return r}function ANe(e){return(s,r={})=>{const n=s.match(e.matchPattern);if(!n)return null;const a=n[0],i=s.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=s.slice(a.length);return{value:o,rest:l}}}const MNe=/^(\d+)(th|st|nd|rd)?/i,RNe=/\d+/i,INe={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},ONe={any:[/^b/i,/^(a|c)/i]},DNe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},LNe={any:[/1/i,/2/i,/3/i,/4/i]},$Ne={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},FNe={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]},BNe={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},UNe={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]},zNe={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},HNe={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}},qNe={ordinalNumber:ANe({matchPattern:MNe,parsePattern:RNe,valueCallback:e=>parseInt(e,10)}),era:bw({matchPatterns:INe,defaultMatchWidth:"wide",parsePatterns:ONe,defaultParseWidth:"any"}),quarter:bw({matchPatterns:DNe,defaultMatchWidth:"wide",parsePatterns:LNe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:bw({matchPatterns:$Ne,defaultMatchWidth:"wide",parsePatterns:FNe,defaultParseWidth:"any"}),day:bw({matchPatterns:BNe,defaultMatchWidth:"wide",parsePatterns:UNe,defaultParseWidth:"any"}),dayPeriod:bw({matchPatterns:zNe,defaultMatchWidth:"any",parsePatterns:HNe,defaultParseWidth:"any"})},k3={code:"en-US",formatDistance:pNe,formatLong:vNe,formatRelative:bNe,localize:PNe,match:qNe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function VNe(e){const s=un(e);return Xh(s,Nee(s))+1}function Cee(e){const s=un(e),r=+Jx(s)-+eNe(s);return Math.round(r/N3)+1}function kee(e,s){const r=un(e),n=r.getFullYear(),a=Ib(),i=s?.firstWeekContainsDate??s?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,o=Nu(e,0);o.setFullYear(n+1,0,i),o.setHours(0,0,0,0);const l=up(o,s),c=Nu(e,0);c.setFullYear(n,0,i),c.setHours(0,0,0,0);const d=up(c,s);return r.getTime()>=l.getTime()?n+1:r.getTime()>=d.getTime()?n:n-1}function WNe(e,s){const r=Ib(),n=s?.firstWeekContainsDate??s?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=kee(e,s),i=Nu(e,0);return i.setFullYear(a,0,n),i.setHours(0,0,0,0),up(i,s)}function _ee(e,s){const r=un(e),n=+up(r,s)-+WNe(r,s);return Math.round(n/N3)+1}function ni(e,s){const r=e<0?"-":"",n=Math.abs(e).toString().padStart(s,"0");return r+n}const Qf={y(e,s){const r=e.getFullYear(),n=r>0?r:1-r;return ni(s==="yy"?n%100:n,s.length)},M(e,s){const r=e.getMonth();return s==="M"?String(r+1):ni(r+1,2)},d(e,s){return ni(e.getDate(),s.length)},a(e,s){const r=e.getHours()/12>=1?"pm":"am";switch(s){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];default:return r==="am"?"a.m.":"p.m."}},h(e,s){return ni(e.getHours()%12||12,s.length)},H(e,s){return ni(e.getHours(),s.length)},m(e,s){return ni(e.getMinutes(),s.length)},s(e,s){return ni(e.getSeconds(),s.length)},S(e,s){const r=s.length,n=e.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return ni(a,s.length)}},Ov={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},NF={G:function(e,s,r){const n=e.getFullYear()>0?1:0;switch(s){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});default:return r.era(n,{width:"wide"})}},y:function(e,s,r){if(s==="yo"){const n=e.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return Qf.y(e,s)},Y:function(e,s,r,n){const a=kee(e,n),i=a>0?a:1-a;if(s==="YY"){const o=i%100;return ni(o,2)}return s==="Yo"?r.ordinalNumber(i,{unit:"year"}):ni(i,s.length)},R:function(e,s){const r=jee(e);return ni(r,s.length)},u:function(e,s){const r=e.getFullYear();return ni(r,s.length)},Q:function(e,s,r){const n=Math.ceil((e.getMonth()+1)/3);switch(s){case"Q":return String(n);case"QQ":return ni(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,s,r){const n=Math.ceil((e.getMonth()+1)/3);switch(s){case"q":return String(n);case"qq":return ni(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,s,r){const n=e.getMonth();switch(s){case"M":case"MM":return Qf.M(e,s);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,s,r){const n=e.getMonth();switch(s){case"L":return String(n+1);case"LL":return ni(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,s,r,n){const a=_ee(e,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):ni(a,s.length)},I:function(e,s,r){const n=Cee(e);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):ni(n,s.length)},d:function(e,s,r){return s==="do"?r.ordinalNumber(e.getDate(),{unit:"date"}):Qf.d(e,s)},D:function(e,s,r){const n=VNe(e);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):ni(n,s.length)},E:function(e,s,r){const n=e.getDay();switch(s){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,s,r,n){const a=e.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(s){case"e":return String(i);case"ee":return ni(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"});default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,s,r,n){const a=e.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(s){case"c":return String(i);case"cc":return ni(i,s.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"});default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,s,r){const n=e.getDay(),a=n===0?7:n;switch(s){case"i":return String(a);case"ii":return ni(a,s.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,s,r){const a=e.getHours()/12>=1?"pm":"am";switch(s){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"});default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,s,r){const n=e.getHours();let a;switch(n===12?a=Ov.noon:n===0?a=Ov.midnight:a=n/12>=1?"pm":"am",s){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"});default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,s,r){const n=e.getHours();let a;switch(n>=17?a=Ov.evening:n>=12?a=Ov.afternoon:n>=4?a=Ov.morning:a=Ov.night,s){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,s,r){if(s==="ho"){let n=e.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return Qf.h(e,s)},H:function(e,s,r){return s==="Ho"?r.ordinalNumber(e.getHours(),{unit:"hour"}):Qf.H(e,s)},K:function(e,s,r){const n=e.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):ni(n,s.length)},k:function(e,s,r){let n=e.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):ni(n,s.length)},m:function(e,s,r){return s==="mo"?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):Qf.m(e,s)},s:function(e,s,r){return s==="so"?r.ordinalNumber(e.getSeconds(),{unit:"second"}):Qf.s(e,s)},S:function(e,s){return Qf.S(e,s)},X:function(e,s,r){const n=e.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return CF(n);case"XXXX":case"XX":return yx(n);default:return yx(n,":")}},x:function(e,s,r){const n=e.getTimezoneOffset();switch(s){case"x":return CF(n);case"xxxx":case"xx":return yx(n);default:return yx(n,":")}},O:function(e,s,r){const n=e.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+SF(n,":");default:return"GMT"+yx(n,":")}},z:function(e,s,r){const n=e.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+SF(n,":");default:return"GMT"+yx(n,":")}},t:function(e,s,r){const n=Math.trunc(e.getTime()/1e3);return ni(n,s.length)},T:function(e,s,r){const n=e.getTime();return ni(n,s.length)}};function SF(e,s=""){const r=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),i=n%60;return i===0?r+String(a):r+String(a)+s+ni(i,2)}function CF(e,s){return e%60===0?(e>0?"-":"+")+ni(Math.abs(e)/60,2):yx(e,s)}function yx(e,s=""){const r=e>0?"-":"+",n=Math.abs(e),a=ni(Math.trunc(n/60),2),i=ni(n%60,2);return r+a+s+i}const kF=(e,s)=>{switch(e){case"P":return s.date({width:"short"});case"PP":return s.date({width:"medium"});case"PPP":return s.date({width:"long"});default:return s.date({width:"full"})}},Pee=(e,s)=>{switch(e){case"p":return s.time({width:"short"});case"pp":return s.time({width:"medium"});case"ppp":return s.time({width:"long"});default:return s.time({width:"full"})}},KNe=(e,s)=>{const r=e.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return kF(e,s);let i;switch(n){case"P":i=s.dateTime({width:"short"});break;case"PP":i=s.dateTime({width:"medium"});break;case"PPP":i=s.dateTime({width:"long"});break;default:i=s.dateTime({width:"full"});break}return i.replace("{{date}}",kF(n,s)).replace("{{time}}",Pee(a,s))},GNe={p:Pee,P:KNe},YNe=/^D+$/,QNe=/^Y+$/,XNe=["D","DD","YY","YYYY"];function ZNe(e){return YNe.test(e)}function JNe(e){return QNe.test(e)}function e1e(e,s,r){const n=t1e(e,s,r);if(console.warn(n),XNe.includes(e))throw new RangeError(n)}function t1e(e,s,r){const n=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${s}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const s1e=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,r1e=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,n1e=
291/^'([^]*?)'?$/,a1e=/''/g,i1e=/[a-zA-Z]/;function Bn(e,s,r){const n=Ib(),a=r?.locale??n.locale??k3,i=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,o=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,l=un(e);if(!aNe(l))throw new RangeError("Invalid time value");let c=s.match(r1e).map(h=>{const p=h[0];if(p==="p"||p==="P"){const g=GNe[p];return g(h,a.formatLong)}return h}).join("").match(s1e).map(h=>{if(h==="''")return{isToken:!1,value:"'"};const p=h[0];if(p==="'")return{isToken:!1,value:o1e(h)};if(NF[p])return{isToken:!0,value:h};if(p.match(i1e))throw new RangeError("Format string contains an unescaped latin alphabet character `"+p+"`");return{isToken:!1,value:h}});a.localize.preprocessor&&(c=a.localize.preprocessor(l,c));const d={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return c.map(h=>{if(!h.isToken)return h.value;const p=h.value;(!r?.useAdditionalWeekYearTokens&&JNe(p)||!r?.useAdditionalDayOfYearTokens&&ZNe(p))&&e1e(p,s,String(e));const g=NF[p[0]];return g(l,p,a.localize,d)}).join("")}function o1e(e){const s=e.match(n1e);return s?s[1].replace(a1e,"'"):e}function l1e(e,s,r){const n=Ib(),a=r?.locale??n.locale??k3,i=2520,o=mS(e,s);if(isNaN(o))throw new RangeError("Invalid time value");const l=Object.assign({},r,{addSuffix:r?.addSuffix,comparison:o});let c,d;o>0?(c=un(s),d=un(e)):(c=un(e),d=un(s));const h=mNe(d,c),p=(Hy(d)-Hy(c))/1e3,g=Math.round((h-p)/60);let v;if(g<2)return r?.includeSeconds?h<5?a.formatDistance("lessThanXSeconds",5,l):h<10?a.formatDistance("lessThanXSeconds",10,l):h<20?a.formatDistance("lessThanXSeconds",20,l):h<40?a.formatDistance("halfAMinute",0,l):h<60?a.formatDistance("lessThanXMinutes",1,l):a.formatDistance("xMinutes",1,l):g===0?a.formatDistance("lessThanXMinutes",1,l):a.formatDistance("xMinutes",g,l);if(g<45)return a.formatDistance("xMinutes",g,l);if(g<90)return a.formatDistance("aboutXHours",1,l);if(g<jF){const b=Math.round(g/60);return a.formatDistance("aboutXHours",b,l)}else{if(g<i)return a.formatDistance("xDays",1,l);if(g<y1){const b=Math.round(g/jF);return a.formatDistance("xDays",b,l)}else if(g<y1*2)return v=Math.round(g/y1),a.formatDistance("aboutXMonths",v,l)}if(v=uNe(d,c),v<12){const b=Math.round(g/y1);return a.formatDistance("xMonths",b,l)}else{const b=v%12,y=Math.trunc(v/12);return b<3?a.formatDistance("aboutXYears",y,l):b<9?a.formatDistance("overXYears",y,l):a.formatDistance("almostXYears",y+1,l)}}function Eee(e,s){return l1e(e,nNe(e),s)}function c1e(e){const s=un(e),r=s.getFullYear(),n=s.getMonth(),a=Nu(e,0);return a.setFullYear(r,n+1,0),a.setHours(0,0,0,0),a.getDate()}function d1e(e){return Math.trunc(+un(e)/1e3)}function u1e(e){const s=un(e),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(0,0,0,0),s}function m1e(e,s){return iNe(u1e(e),ju(e),s)+1}function NM(e,s){const r=un(e),n=un(s);return r.getTime()>n.getTime()}function Tee(e,s){const r=un(e),n=un(s);return+r<+n}function _3(e,s){const r=un(e),n=un(s);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()}function h1e(e,s){const r=un(e),n=un(s);return r.getFullYear()===n.getFullYear()}function kP(e,s){return Ud(e,-s)}function _P(e,s){const r=un(e),n=r.getFullYear(),a=r.getDate(),i=Nu(e,0);i.setFullYear(n,s,15),i.setHours(0,0,0,0);const o=c1e(i);return r.setMonth(s,Math.min(a,o)),r}function _F(e,s){const r=un(e);return isNaN(+r)?Nu(e,NaN):(r.setFullYear(s),r)}function Dv(e){if(!e)return"0 B";const s=["B","KB","MB","GB","TB"];let r=e,n=0;for(;r>=1024&&n<s.length-1;)r/=1024,n++;return`${r.toFixed(r>=100||n===0?0:1)} ${s[n]}`}const p1e=4e3;function f1e(){const{toast:e}=Hs(),[s,r]=u.useState("idle"),n=u.useRef(void 0),a=u.useRef(null),{data:i,isLoading:o,error:l,refetch:c,isFetching:d}=ze({queryKey:["/api/admin/backups"]}),h=s==="queued"||s==="running",{data:p}=ze({queryKey:["/api/admin/backups/status"],refetchInterval:()=>h?1500:!1,refetchIntervalInBackground:!0});u.useEffect(()=>{p&&n.current===void 0&&(n.current=p.lastFinishedAt??null)},[p]),u.useEffect(()=>{if(!p)return;
291const C=n.current;if(C===void 0)return;const k=p.lastFinishedAt&&p.lastFinishedAt!==C;if(p.running){r(S=>S==="running"?S:"running");return}if(k&&(s==="queued"||s==="running")){const S=p.lastStatus==="failed"?"failed":"success";r(S),n.current=p.lastFinishedAt,Je.invalidateQueries({queryKey:["/api/admin/backups"]}),e(S==="success"?{title:"Backup complete",description:"Manifest uploaded to GCS."}:{title:"Backup failed",description:p.lastError??"See server logs for details.",variant:"destructive"})}},[p,s,e]),u.useEffect(()=>{if(!(s!=="success"&&s!=="failed"))return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{r("idle"),a.current=null},p1e),()=>{a.current&&(clearTimeout(a.current),a.current=null)}},[s]),u.useEffect(()=>{if(s!=="queued")return;const C=setTimeout(()=>{r(k=>k==="queued"?"idle":k)},15e3);return()=>clearTimeout(C)},[s]);const g=Et({mutationFn:async()=>{const C=Je.getQueryData(["/api/admin/backups/status"]);return n.current=C?.lastFinishedAt??null,Ze("POST","/api/admin/backups/run")},onSuccess:()=>{r("queued"),e({title:"Backup queued",description:"Tracking progress live — this panel will update when it finishes."}),Je.invalidateQueries({queryKey:["/api/admin/backups/status"]})},onError:C=>{e({title:"Failed to start backup",description:String(C?.message??C),variant:"destructive"})}}),v=g.isPending||h,b=(()=>{if(g.isPending)return"Queuing…";switch(s){case"queued":return"Queued…";case"running":return p?.elapsedSeconds!=null?`Running… ${p.elapsedSeconds}s`:"Running…";case"success":return"Backup complete";case"failed":return"Backup failed";default:return"Run Backup Now"}})(),y=g.isPending||h?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):s==="success"?t.jsx(ar,{className:"w-4 h-4 mr-2 text-green-200"}):s==="failed"?t.jsx(rf,{className:"w-4 h-4 mr-2"}):t.jsx(_K,{className:"w-4 h-4 mr-2"}),w=i?.items??[],j=w.find(C=>C.manifest?.status==="success")??null,x=w[0]??null;return t.jsxs("div",{className:"p-4 sm:p-6 space-y-6","data-testid":"backups-panel",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-2xl font-semibold flex items-center gap-2",children:[t.jsx(pn,{className:"w-6 h-6"}),"Daily Backups"]}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Production PostgreSQL dump + source archive uploaded daily to"," ",t.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:["gs://",i?.bucket??"truvios-backups","/"]}),". Standard → Nearline at 7 days, deleted at 30 days."]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>c(),disabled:d,"data-testid":"button-refresh-backups",children:[t.jsx(tl,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]}),t.jsxs(L,{size:"sm",variant:s==="failed"?"destructive":"default",onClick:()=>g.mutate(),disabled:v,"data-testid":"button-run-backup-now","data-phase":s,children:[y,b]})]})]}),h&&t.jsx(ut,{"data-testid":"card-backup-progress",children:t.jsxs(mt,{className:"py-4 space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Fe,{className:"w-4 h-4 animate-spin text-muted-foreground shrink-0"}),t.jsx("span",{className:"font-medium truncate","data-testid":"text-backup-stage",children:p?.stageLabel??"Preparing…"}),p?.bytesTotal!=null&&p.bytesTotal>0&&t.jsxs("span",{className:"text-xs text-muted-foreground","data-testid":"text-backup-bytes",children:[Dv(p.bytesUploaded??0)," / ",Dv(p.bytesTotal)]})]}),t.jsxs("div",{className:"text-xs text-muted-foreground tabular-nums shrink-0",children:[p?.percent!=null&&t.jsxs("span",{"data-testid":"text-backup-percent",children:[p.percent,"%"]}),p?.elapsedSeconds!=null&&t.jsxs("span",{className:"ml-2",children:[p.elapsedSeconds,"s elapsed"]})]})]}),t.jsx(j3,{value:p?.percent??0,className:"h-2","data-testid":"progress-backup"})]})}),l&&t.jsxs(pu,{variant:"destructive","data-testid":"alert-backups-error",children:[t.jsx(Pn,{className:"w-4 h-4"}),t.jsx(Yu,{children:"Could not load backups"}),t.jsxs(fu,{children:[String(l?.message??l),t.jsx("br",{}),t.jsxs("span",{className:"text-xs",children:["Make sure the GCS service account key is configured under API Settings and that the ",t.jsx("code",{children:"truvios-backups"})," bucket exists (it is created automatically on the first run)."]})]})]}),o&&t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[t.jsx(Bt,{className:"h-32"}),t.jsx(Bt,{className:"h-32"})]}),!o&&!l&&t.jsxs(t.Fragment,{children:[t.jsx(w1e,{}),t.jsx(g1e,{}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[t.jsxs(ut,{"data-testid":"card-latest-backup",children:[t.jsx(xs,{className:"pb-3",children:t.jsxs(ys,{className:"text-base flex items-center gap-2",children:["Latest run",x?.manifest?.status==="success"&&t.jsxs(Ke,{variant:"default",className:"bg-green-600 hover:bg-green-600",children:[t.jsx(ar,{className:"w-3 h-3 mr-1"})," Success"]}),x?.manifest?.status==="failed"&&t.jsxs(Ke,{variant:"destructive",children:[t.jsx(rf,{className:"w-3 h-3 mr-1"})," Failed"]})]})}),t.jsx(mt,{className:"space-y-1 text-sm",children:x?.manifest?t.jsxs(t.Fragment,{children:[t.jsxs("div",{"data-testid":"text-latest-date",children:[t.jsx("span",{className:"text-muted-foreground",children:"Date:"})," ",x.date," (",Eee(new Date(x.manifest.startedAt),{addSuffix:!0}),")"]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Duration:"})," ",x.manifest.durationSeconds,"s"]}),x.manifest.gitCommit&&t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Commit:"})," ",t.jsx("code",{className:"text-xs",children:x.manifest.gitCommit.slice(0,12)}),x.manifest.gitBranch&&t.jsxs("span",{className:"text-muted-foreground",children:[" @ ",x.manifest.gitBranch]})]}),x.manifest.status==="failed"&&x.manifest.error&&t.jsx("div",{className:"text-destructive text-xs mt-2 break-all",children:x.manifest.error})]}):t.jsx("div",{className:"text-muted-foreground",children:"No backups yet — run one to get started."})})]}),t.jsxs(ut,{"data-testid":"card-last-success",children:[t.jsx(xs,{className:"pb-3",children:t.jsx(ys,{className:"text-base",children:"Last successful backup"})}),t.jsx(mt,{className:"space-y-2 text-sm",children:j?.manifest?t.jsxs(t.Fragment,{children:[t.jsxs("div",{"data-testid":"text-last-success-date",children:[t.jsx("span",{className:"text-muted-foreground",children:"Date:"})," ",j.date]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(mf,{className:"w-4 h-4 text-muted-foreground"}),t.jsxs("span",{"data-testid":"text-db-size",children:["DB dump: ",t.jsx("strong",{children:Dv(j.manifest.database.sizeBytes)})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Oce,{className:"w-4 h-4 text-muted-foreground"}),t.jsxs("span",{"data-testid":"text-source-size",children:["Source: ",t.jsx("strong",{children:Dv(j.manifest.source.sizeBytes)})]})]}),j.manifest.tableRowCounts&&Object.keys(j.manifest.tableRowCounts).length>0&&t.jsx("div",{className:"text-xs text-muted-foreground pt-1",children:Object.entries(j.manifest.tableRowCounts).slice(0,4).map(([C,k])=>`${C}
291: ${k}`).join(" · ")})]}):t.jsx("div",{className:"text-muted-foreground",children:"No successful backups recorded yet."})})]})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{className:"text-base",children:"Recent history"}),t.jsxs(Xs,{children:["Last ",w.length," runs (newest first)"]})]}),t.jsx(mt,{className:"p-0",children:t.jsxs("div",{className:"divide-y",children:[w.length===0&&t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No backup runs found."}),w.map(C=>t.jsxs("div",{className:"p-3 sm:p-4 flex items-start gap-3 text-sm","data-testid":`row-backup-${C.date}`,children:[C.manifest?.status==="success"?t.jsx(ar,{className:"w-4 h-4 text-green-600 mt-0.5 shrink-0"}):C.manifest?.status==="failed"?t.jsx(rf,{className:"w-4 h-4 text-destructive mt-0.5 shrink-0"}):t.jsx(Pn,{className:"w-4 h-4 text-muted-foreground mt-0.5 shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium",children:C.date}),C.manifest?t.jsxs("div",{className:"text-xs text-muted-foreground",children:[new Date(C.manifest.startedAt).toLocaleString()," · ",C.manifest.durationSeconds,"s",C.manifest.status==="success"&&t.jsxs(t.Fragment,{children:[" · ","DB ",Dv(C.manifest.database.sizeBytes)," · ","Source ",Dv(C.manifest.source.sizeBytes)]}),C.manifest.error&&t.jsxs("span",{className:"text-destructive",children:[" · ",C.manifest.error.slice(0,120)]})]}):t.jsx("div",{className:"text-xs text-muted-foreground",children:"Manifest unreadable"})]})]},C.path))]})})]})]})]})}function g1e(){const{toast:e}=Hs(),{can:s}=aN(),r=s("backups","write"),[n,a]=u.useState(""),[i,o]=u.useState(!1),{data:l}=ze({queryKey:["/api/admin/cloud-history/recover/status"],refetchInterval:v=>v.state.data?.running?2e3:!1}),c=l?.running??!1,d=l?.last??null,h=Et({mutationFn:async v=>Ze("POST","/api/admin/cloud-history/recover",{serial:v}),onSuccess:()=>{e({title:"Recovery started",description:"Re-importing cloud history from the latest backup. This panel updates live."}),Je.invalidateQueries({queryKey:["/api/admin/cloud-history/recover/status"]})},onError:v=>{e({title:"Failed to start recovery",description:String(v?.message??v),variant:"destructive"})}});if(!r)return null;const p=n.trim(),g=c||h.isPending||p.length===0;return t.jsxs(ut,{"data-testid":"card-recover-cloud-history",children:[t.jsxs(xs,{className:"pb-3",children:[t.jsxs(ys,{className:"text-base flex items-center gap-2",children:[t.jsx(e0,{className:"w-4 h-4"})," Recover Cloud History"]}),t.jsx(Xs,{children:"Restore a device's cloud recordings & segments that were lost when the device was removed/re-registered. Enter the device serial — the rows are re-imported from the most recent backup that still has them and re-pointed to the current device. Safe to re-run."})]}),t.jsxs(mt,{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:items-end",children:[t.jsxs("div",{className:"flex-1 space-y-1",children:[t.jsx(re,{htmlFor:"recover-serial",className:"text-xs",children:"Device serial"}),t.jsx(ke,{id:"recover-serial",placeholder:"e.g. TE-H2HHH2POY",value:n,onChange:v=>a(v.target.value),disabled:c,"data-testid":"input-recover-serial"})]}),t.jsxs(L,{onClick:()=>o(!0),disabled:g,"data-testid":"button-recover-cloud-history",children:[c||h.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(e0,{className:"w-4 h-4 mr-2"}),c?"Recovering…":"Recover"]})]}),d&&t.jsxs("div",{className:"rounded-md border p-3 text-sm space-y-1","data-testid":"text-recovery-result",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[d.status==="success"?t.jsxs(Ke,{variant:"default",className:"bg-green-600 hover:bg-green-600",children:[t.jsx(ar,{className:"w-3 h-3 mr-1"})," Success"]}):d.status==="failed"?t.jsxs(Ke,{variant:"destructive",children:[t.jsx(rf,{className:"w-3 h-3 mr-1"})," Failed"]}):t.jsxs(Ke,{variant:"secondary",children:[t.jsx(Fe,{className:"w-3 h-3 mr-1 animate-spin"})," Running"]}),t.jsx("span",{className:"text-muted-foreground",children:"serial"}),t.jsx("code",{className:"text-xs",children:d.serial})]}),d.status==="success"&&t.jsxs("div",{className:"text-muted-foreground",children:["Restored ",t.jsx("strong",{children:d.recordingsInserted??0})," recordings and"," ",t.jsx("strong",{children:d.segmentsInserted??0})," segments",d.backupObject&&t.jsxs(t.Fragment,{children:[" from ",t.jsx("code",{className:"text-xs",children:d.backupObject})]}),"."]}),d.status==="failed"&&d.error&&t.jsx("div",{className:"text-destructive text-xs break-all",children:d.error}),d.completedAt&&t.jsx("div",{className:"text-xs text-muted-foreground",children:Eee(new Date(d.completedAt),{addSuffix:!0})})]})]}),t.jsx(zd,{open:i,onOpenChange:o,children:t.jsxs(bd,{children:[t.jsxs(wd,{children:[t.jsxs(Nd,{children:["Recover cloud history for ",p||"this device","?"]}),t.jsxs(Sd,{children:["This re-imports cloud recordings and segments for serial"," ",t.jsx("strong",{children:p})," from the most recent backup that still contains them, and re-points them to the current device. Existing rows are left untouched (re-running is safe). It runs in the background and may take a couple of minutes."]})]}),t.jsxs(jd,{children:[t.jsx(Gc,{"data-testid":"button-recover-cancel",children:"Cancel"}),t.jsx(Cd,{onClick:()=>h.mutate(p),"data-testid":"button-recover-confirm",children:"Start recovery"})]})]})})]})}const x1e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function v1e(e,s,r,n,a,i){const o=Date.UTC(e,s-1,r,n,a),c=new Intl.DateTimeFormat("en-US",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(new Date(o)),d={};for(const g of c)g.type!=="literal"&&(d[g.type]=g.value);const p=Date.UTC(Number(d.year),Number(d.month)-1,Number(d.day),Number(d.hour)%24,Number(d.minute),Number(d.second||"0"))-o;return new Date(o-p)}function y1e(e,s){const n=new Intl.DateTimeFormat("en-US",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",weekday:"short",hour12:!1}).formatToParts(e),a={};
291for(const o of n)a[o.type]=o.value;const i={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return{year:Number(a.year),month:Number(a.month),day:Number(a.day),hour:Number(a.hour)%24,minute:Number(a.minute),weekday:i[a.weekday]??0}}function b1e(e){if(!e.enabled||e.daysOfWeek.length===0)return null;const s=new Date;for(let r=0;r<8;r++){const n=new Date(s.getTime()+r*24*3600*1e3);let a;try{a=y1e(n,e.timezone)}catch{return null}if(e.daysOfWeek.includes(a.weekday)&&!(r===0&&(a.hour>e.hour||a.hour===e.hour&&a.minute>=e.minute)))try{return v1e(a.year,a.month,a.day,e.hour,e.minute,e.timezone)}catch{return null}}return null}const PP=["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Phoenix","America/Anchorage","Pacific/Honolulu","UTC","Europe/London","Europe/Paris","Asia/Tokyo","Asia/Singapore","Australia/Sydney"];function w1e(){const{toast:e}=Hs(),{can:s}=aN(),r=s("backups","write"),{data:n,isLoading:a}=ze({queryKey:["/api/admin/backups/schedule"]}),[i,o]=u.useState(null);u.useEffect(()=>{n?.schedule&&i===null&&o(n.schedule)},[n,i]);const l=Et({mutationFn:async j=>(await Ze("PUT","/api/admin/backups/schedule",j)).json(),onSuccess:j=>{Je.invalidateQueries({queryKey:["/api/admin/backups/schedule"]}),o(j.schedule),e({title:"Schedule saved",description:j.nextRun?`Next run: ${j.nextRun}`:"Scheduler is disabled."})},onError:j=>{e({title:"Failed to save schedule",description:String(j?.message??j),variant:"destructive"})}});if(a||!i)return t.jsxs(ut,{"data-testid":"card-backup-schedule",children:[t.jsx(xs,{className:"pb-3",children:t.jsxs(ys,{className:"text-base flex items-center gap-2",children:[t.jsx(R5,{className:"w-4 h-4"})," Schedule"]})}),t.jsx(mt,{children:t.jsx(Bt,{className:"h-32 w-full"})})]});const c=JSON.stringify(i)!==JSON.stringify(n?.schedule),d=(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"local time"}})(),h=b1e(i),p=h?`${h.toLocaleString(void 0,{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})} (${d})`:i.enabled?"—":"Scheduler disabled",g=PP.includes(i.timezone)?PP:[i.timezone,...PP],v=j=>{r&&o(x=>{if(!x)return x;const C=new Set(x.daysOfWeek);return C.has(j)?C.delete(j):C.add(j),{...x,daysOfWeek:Array.from(C).sort((k,S)=>k-S)}})},b=j=>{if(!r)return;const x=j.match(/^(\d{1,2}):(\d{2})$/);if(!x)return;const C=Math.min(23,Math.max(0,parseInt(x[1],10))),k=Math.min(59,Math.max(0,parseInt(x[2],10)));o(S=>S&&{...S,hour:C,minute:k})},y=j=>String(j).padStart(2,"0"),w=`${y(i.hour)}:${y(i.minute)}`;return t.jsxs(ut,{"data-testid":"card-backup-schedule",children:[t.jsxs(xs,{className:"pb-3",children:[t.jsxs(ys,{className:"text-base flex items-center gap-2",children:[t.jsx(R5,{className:"w-4 h-4"})," Schedule"]}),t.jsx(Xs,{className:"text-xs",children:`The server runs daily backups in-process based on this schedule. Disable Replit's "Daily Backup" Scheduled Deployment so backups don't run twice.`})]}),t.jsxs(mt,{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx(re,{htmlFor:"schedule-enabled",className:"text-sm font-medium",children:"Scheduled backups"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:i.enabled?"Enabled — runs at the time below.":"Disabled — only manual runs will happen."})]}),t.jsx(sr,{id:"schedule-enabled",checked:i.enabled,disabled:!r,onCheckedChange:j=>o(x=>x&&{...x,enabled:j}),"data-testid":"switch-schedule-enabled"})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-sm font-medium",children:"Days of week"}),t.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:x1e.map((j,x)=>{const C=i.daysOfWeek.includes(x);return t.jsxs("label",{className:`flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-sm cursor-pointer hover-elevate ${C?"bg-primary/10 border-primary/40":""} ${r?"":"opacity-60 cursor-not-allowed"}`,"data-testid":`label-schedule-day-${x}`,children:[t.jsx(On,{checked:C,disabled:!r,onCheckedChange:()=>v(x),"data-testid":`checkbox-schedule-day-${x}`}),j]},x)})}),i.daysOfWeek.length===0&&t.jsx("p",{className:"text-xs text-destructive mt-2",children:"Select at least one day for the schedule to fire."})]}),t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx(re,{htmlFor:"schedule-time",className:"text-sm font-medium",children:"Time of day"}),t.jsx(ke,{id:"schedule-time",type:"time",value:w,onChange:j=>b(j.target.value),disabled:!r,className:"mt-1","data-testid":"input-schedule-time"})]}),t.jsxs("div",{children:[t.jsx(re,{htmlFor:"schedule-timezone",className:"text-sm font-medium",children:"Timezone"}),t.jsxs(Us,{value:i.timezone,onValueChange:j=>o(x=>x&&{...x,timezone:j}),disabled:!r,children:[t.jsx($s,{id:"schedule-timezone",className:"mt-1","data-testid":"select-schedule-timezone",children:t.jsx(zs,{})}),t.jsx(Fs,{children:g.map(j=>t.jsx(rt,{value:j,"data-testid":`option-timezone-${j}`,children:j},j))})]})]})]}),t.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[t.jsxs("div",{"data-testid":"text-next-run",children:[t.jsx("span",{className:"font-medium text-foreground",children:"Next run:"})," ",p,c&&t.jsx("span",{className:"ml-2 italic",children:"(preview — not saved yet)"})]}),n?.lastFiredSlot&&t.jsxs("div",{"data-testid":"text-last-fired",children:[t.jsx("span",{className:"font-medium text-foreground",children:"Last fired (this process):"})," ",n.lastFiredSlot]})]}),t.jsx("div",{className:"flex justify-end",children:t.jsxs(L,{size:"sm",onClick:()=>i&&l.mutate(i),disabled:!r||!c||l.isPending||i.daysOfWeek.length===0,"data-testid":"button-save-schedule",children:[l.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-2"}),"Save schedule"]})})]})]})}const EP=e=>`${(e/1e9).toFixed(2)} GB`;function j1e(){const{data:e,isLoading:s,isError:r}=ze({queryKey:["/api/admin/cloud-metadata-capacity"],refetchInterval:3e5,staleTime:0});return t.jsxs(ut,{children:[t.jsx(xs,{children:t.jsxs(ys,{className:"flex items-center gap-2 text-lg",children:[t.jsx(mf,{className:"h-5 w-5"})," Database capacity"]})}),t.jsx(mt,{className:"space-y-3",children:s?t.jsx("p",{children:"Loading c
291apacity status…"}):r||!e?t.jsx("p",{role:"alert",children:"Capacity status is unavailable. Check the server logs."}):t.jsxs(t.Fragment,{children:[e.level>0&&t.jsxs("p",{role:"alert",className:"flex items-start gap-2 text-amber-700 dark:text-amber-400 font-medium",children:[t.jsx(Pn,{className:"h-5 w-5 shrink-0"}),"Database allocation has passed ",e.level,"% of the 100 GB limit. Review capacity before it fills."]}),(!e.sampledAt||Date.now()-new Date(e.sampledAt).getTime()>7200*1e3)&&t.jsx("p",{role:"alert",className:"text-amber-700 dark:text-amber-400",children:"Capacity measurement is not current. Check the server logs."}),t.jsxs("p",{children:["Allocated database size: ",t.jsx("strong",{children:e.allocatedBytes==null?"Awaiting first sample":`${EP(e.allocatedBytes)} / ${EP(e.limitBytes)}`})]}),t.jsxs("p",{children:["Cleanup rows deleted: ",t.jsx("strong",{children:Number(e.deletedRows).toLocaleString()})," ",t.jsx("span",{className:"text-muted-foreground",children:"(since progress tracking began)"})]}),t.jsxs("p",{children:["Allocated bytes reclaimed: ",t.jsx("strong",{children:e.allocatedBytes==null||e.previousAllocatedBytes==null?"Not yet measured":EP(Math.max(0,e.previousAllocatedBytes-e.allocatedBytes))})," ",t.jsx("span",{className:"text-muted-foreground",children:"(net size decrease since the previous sample; not attributable to cleanup)"})]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Deleted rows free space for reuse but do not necessarily reduce allocated database size. Measurements are hourly. ",e.sampledAt&&`Last sampled ${new Date(e.sampledAt).toLocaleString()}.`]})]})})]})}const PF=[{id:"cloud_recordings",label:"Cloud recordings",detail:"Recording metadata and object references"},{id:"cloud_segments",label:"Cloud segments",detail:"Segment-level metadata"}],Lv=new Set(["queued","running","starting","processing"]),Op=e=>{if(!Number.isFinite(e))return"—";if(e<1024)return`${e.toLocaleString()} B`;const s=["KB","MB","GB","TB"];let r=e/1024,n=0;for(;r>=1024&&n<s.length-1;)r/=1024,n++;return`${r.toFixed(1)} ${s[n]}`},$v=e=>typeof e=="string"?e.replace(/[_-]/g," "):e==null?"Not reported":typeof e=="object"?JSON.stringify(e):String(e);async function Dp(e,s,r){return(await Ze(e,s,r)).json()}function N1e({canWrite:e}){const s=Su(),[r,n]=u.useState([]),[a,i]=u.useState(PF.map(H=>H.id)),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(!1),[g,v]=u.useState(""),[b,y]=u.useState(""),[w,j]=u.useState({cloud:"",database:""}),[x,C]=u.useState("cloud"),[k,S]=u.useState([]),[_,A]=u.useState(null),[T,M]=u.useState(""),R=ze({queryKey:["/api/admin/cloud-metadata/overview"],refetchInterval:6e4}),D=ze({queryKey:["/api/admin/cloud-metadata/jobs"],queryFn:()=>Dp("GET","/api/admin/cloud-metadata/jobs")});u.useEffect(()=>{try{l(localStorage.getItem("cloud-metadata-active-job")??""),d(localStorage.getItem("cloud-metadata-reclaim-job")??"")}catch{}},[]);const $=Et({mutationFn:H=>Dp("PUT","/api/admin/cloud-metadata/schedule",{enabled:H}),onSuccess:()=>s.invalidateQueries({queryKey:["/api/admin/cloud-metadata/overview"]})}),O=Et({mutationFn:H=>Dp("POST","/api/admin/cloud-metadata/jobs",H),onSuccess:({id:H})=>{l(H),S([]),v(""),y(""),A(null);try{localStorage.setItem("cloud-metadata-active-job",H)}catch{}s.invalidateQueries({queryKey:["/api/admin/cloud-metadata/jobs"]}),s.invalidateQueries({queryKey:["/api/admin/cloud-metadata/jobs",H]})}}),q=ze({queryKey:["/api/admin/cloud-metadata/jobs",o],enabled:!!o,queryFn:()=>Dp("GET",`/api/admin/cloud-metadata/jobs/${encodeURIComponent(o)}`),refetchInterval:H=>{const se=H.state.data?.job.state;return se&&Lv.has(se.toLowerCase())?1800:!1}}),V=ze({queryKey:["/api/admin/cloud-metadata/reclaim/preflight",x],queryFn:()=>Dp("GET",`/api/admin/cloud-metadata/reclaim/preflight?scope=${x}`),refetchInterval:3e4}),K=ze({queryKey:["/api/admin/cloud-metadata/reclaim/lock-diagnostic"],queryFn:()=>Dp("GET","/api/admin/cloud-metadata/reclaim/lock-diagnostic"),enabled:!1,retry:!1}),G=Et({mutationFn:({scope:H})=>Dp("POST","/api/admin/cloud-metadata/reclaim",{scope:H,confirmation:"RECLAIM",maintenanceWindowConfirmed:h}),onSuccess:({id:H})=>{d(H);try{localStorage.setItem("cloud-metadata-reclaim-job",H)}catch{}s.invalidateQueries({queryKey:["/api/admin/cloud-metadata/reclaim/preflight"]})}}),z=ze({queryKey:["/api/admin/cloud-metadata/reclaim",c],enabled:!!c,queryFn:()=>Dp("GET",`/api/admin/cloud-metadata/reclaim/${encodeURIComponent(c)}`),refetchInterval:H=>{const se=H.state.data,me=se?"job"in se?se.job.state:se.state:void 0;return me&&Lv.has(me.toLowerCase())?1800:!1}}),Z=z.data&&("job"in z.data?z.data.job:z.data);R.data?.sites.filter(H=>r.includes(H.id));const ee=u.useMemo(()=>{const H=q.data?.job;return!H||H.mode!=="dry-run"||!H.complete||Lv.has(H.state.toLowerCase())||["failed","cancelled","canceled"].includes(H.state.toLowerCase())?!1:[...H.siteIds].sort().join("\0")===[...r].sort().join("\0")&&[...H.tables].sort().join("\0")===[...a].sort().join("\0")},[q.data?.job,r,a]),Q=e&&ee&&g==="DELETE"&&r.length>0&&a.length>0,Y=e&&b==="DELETE WITHOUT PREVIEW"&&r.length>0&&a.length>0&&!!R.data;u.useEffect(()=>{q.data&&(A(q.data.nextCursor),M(""))},[q.data?.job.id]);const oe=(H,se)=>{n(me=>se?[...new Set([...me,H])]:me.filter(ge=>ge!==H)),v(""),y("")},he=(H,se)=>{i(me=>se?[...new Set([...me,H])]:me.filter(ge=>ge!==H)),v(""),y("")},je=H=>{!r.length||!a.length||O.mutate({siteIds:r,tables:a,mode:H,...H==="delete"?{previewId:q.data.job.id,confirmation:"DELETE"}:H==="direct-delete"?{confirmation:b}:{}})},pe=async()=>
291{if(!(!o||!_)){M("");try{const H=await Dp("GET",`/api/admin/cloud-metadata/jobs/${encodeURIComponent(o)}/entries?cursor=${encodeURIComponent(_)}`);S(se=>[...se,...H.entries]),A(H.nextCursor)}catch(H){M(String(H?.message??H))}}},le=async()=>{if(o)try{const se=await(await Ze("GET",`/api/admin/cloud-metadata/jobs/${encodeURIComponent(o)}/csv`)).blob(),me=URL.createObjectURL(se),ge=document.createElement("a");ge.href=me,ge.download=`cloud-metadata-job-${o}.csv`,document.body.appendChild(ge),ge.click(),ge.remove(),URL.revokeObjectURL(me)}catch(H){M(`CSV export failed: ${String(H?.message??H)}`)}},ue=async()=>{if(o)try{await Ze("POST",`/api/admin/cloud-metadata/jobs/${encodeURIComponent(o)}/cancel`),s.invalidateQueries({queryKey:["/api/admin/cloud-metadata/jobs",o]})}catch(H){M(`Could not cancel job: ${String(H?.message??H)}`)}},fe=!!V.data?.canRun&&e&&h;return t.jsxs("div",{className:"space-y-5",children:[t.jsxs("header",{className:"flex flex-col gap-3 border-b border-border/70 pb-4 sm:flex-row sm:items-end sm:justify-between",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"mb-1 flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:[t.jsx(mf,{className:"h-4 w-4"})," Operations / retention"]}),t.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Cloud metadata database"}),t.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:"Metadata expires by recording end time and the app’s saved retention policy. This does not check or delete Google Cloud files."})]}),t.jsxs(Ke,{variant:R.data?.scheduledEnabled?"default":"secondary",className:"w-fit gap-1.5 px-3 py-1",children:[t.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${R.data?.scheduledEnabled?"bg-current":"bg-muted-foreground"}`}),"Scheduler ",R.data?.scheduledEnabled?"on":"off"]})]}),R.isError&&t.jsxs(pu,{variant:"destructive",role:"alert",children:[t.jsx(Pn,{className:"h-4 w-4"}),t.jsx(Yu,{children:"Overview unavailable"}),t.jsxs(fu,{children:["Could not load metadata retention settings. ",t.jsx(L,{variant:"ghost",className:"h-auto p-0 text-inherit underline",onClick:()=>R.refetch(),children:"Retry"})]})]}),$.isError&&t.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not update scheduler: ",String($.error.message)]}),O.isError&&t.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not start job: ",String(O.error.message)]}),t.jsxs("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.25fr)_minmax(320px,0.75fr)]",children:[t.jsxs(ut,{className:"overflow-hidden",children:[t.jsx(xs,{className:"border-b border-border/60 bg-muted/25",children:t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(ys,{className:"text-base",children:"Scheduled cleanup"}),t.jsx(Xs,{className:"mt-1",children:"When enabled, delete expired metadata using each site’s effective app retention setting."})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(re,{htmlFor:"metadata-scheduler",className:"text-sm font-medium",children:R.data?.scheduledEnabled?"Enabled":"Disabled"}),t.jsx(sr,{id:"metadata-scheduler",checked:R.data?.scheduledEnabled??!1,disabled:!e||R.isLoading||$.isPending,onCheckedChange:H=>$.mutate(H),"aria-label":"Enable scheduled metadata cleanup"})]})]})}),t.jsx(mt,{className:"p-0",children:R.isLoading?t.jsxs("div",{className:"space-y-3 p-5","aria-label":"Loading site retention",children:[t.jsx(Bt,{className:"h-8 w-full"}),t.jsx(Bt,{className:"h-8 w-full"}),t.jsx(Bt,{className:"h-8 w-2/3"})]}):R.data?.sites.length?t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[t.jsx("thead",{className:"bg-muted/20 text-[11px] uppercase tracking-wider text-muted-foreground",children:t.jsxs("tr",{children:[t.jsx("th",{className:"w-10 px-4 py-3",children:t.jsx(On,{"aria-label":"Select all available sites",checked:r.length>0&&r.length===R.data.sites.filter(H=>!H.reason&&H.deviceId).length,onCheckedChange:H=>{n(H?R.data.sites.filter(se=>!se.reason&&se.deviceId).map(se=>se.id):[]),v(""),y("")}})}),t.jsx("th",{className:"px-3 py-3",children:"Site / company"}),t.jsx("th",{className:"px-3 py-3",children:"Device"}),t.jsx("th",{className:"px-3 py-3",children:"Configured"}),t.jsx("th",{className:"px-3 py-3",children:"Effective"}),t.jsx("th",{className:"px-3 py-3",children:"Policy status"})]})}),t.jsx("tbody",{className:"divide-y divide-border/60",children:R.data.sites.map(H=>t.jsxs("tr",{className:"align-top hover:bg-muted/20",children:[t.jsx("td",{className:"px-4 py-3",children:t.jsx(On,{checked:r.includes(H.id),disabled:!!H.reason||!H.deviceId,onCheckedChange:se=>oe(H.id,se===!0),"aria-label":`Select ${H.name}`})}),t.jsxs("td",{className:"px-3 py-3",children:[t.jsx("div",{className:"font-medium",children:H.name}),t.jsx("div",{className:"text-xs text-muted-foreground",children:H.companyName})]}),t.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted-foreground",children:H.deviceId||"—"}),t.jsx("td",{className:"px-3 py-3",children:H.configuredDays==null?"Not set":`${H.configuredDays} days`}),t.jsx("td",{className:"px-3 py-3 font-medium",children:H.retentionDays==null?"No retention":`${H.retentionDays} days`}),t.jsxs("td",{className:"max-w-[220px] px-3 py-3",children:[t.jsx(Ke,{variant:H.reason?"outline":"secondary",className:"mb-1",children:H.reason?"Review":"Configured"}),t.jsx("div",{className:"text-xs text-muted-foreground",children:H.reason||"Retention policy applies"})]})]},H.id))})]})}):t.jsxs("div",{className:"p-8 text-center",children:[t.jsx("div",{className:"mx-auto mb-2 grid h-10 w-10 place-items-center rounded-full bg-muted",children:t.jsx(Gce,{className:"h-5 w-5 text-muted-foreground"})}),t.jsx("p",{className:"font-medium",children:"No sites to evaluate"}),t.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Site retention plans will appear here when available."})]})})]}),t.jsxs("div",{className:"space-y-5",children:[t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{className:"text-base",children:"Run a scoped cleanup"}),t.jsx(Xs,{children:"Selection is exact. Preview first, or explicitly choose live deleti
291on without a preview."})]}),t.jsxs(mt,{className:"space-y-4",children:[t.jsxs("fieldset",{className:"space-y-2",children:[t.jsx("legend",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Metadata tables"}),PF.map(H=>t.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-md border border-border/70 p-3 has-[:checked]:border-primary/50 has-[:checked]:bg-primary/[0.035]",children:[t.jsx(On,{checked:a.includes(H.id),onCheckedChange:se=>he(H.id,se===!0)}),t.jsxs("span",{children:[t.jsx("span",{className:"block text-sm font-medium",children:H.label}),t.jsx("span",{className:"text-xs text-muted-foreground",children:H.detail})]})]},H.id))]}),t.jsxs("div",{className:"rounded-md bg-muted/35 p-3 text-xs text-muted-foreground",children:[t.jsx("strong",{className:"text-foreground",children:r.length})," sites selected · ",t.jsx("strong",{className:"text-foreground",children:a.length})," tables selected"]}),!e&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Read-only access. Ask a superadmin with Database write permission to run cleanup."}),t.jsxs(L,{className:"w-full",variant:"outline",disabled:!r.length||!a.length||O.isPending,onClick:()=>je("dry-run"),children:[O.isPending&&O.variables?.mode==="dry-run"?t.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}):t.jsx(vu,{className:"mr-2 h-4 w-4"}),"Run dry-run preview"]}),ee&&t.jsxs(pu,{className:"border-emerald-700/25 bg-emerald-700/[0.045]",children:[t.jsx(vi,{className:"h-4 w-4 text-emerald-700"}),t.jsx(Yu,{children:"Exact-scope preview completed"}),t.jsxs(fu,{children:[q.data?.job.eligible.toLocaleString()," eligible rows found. Preview ",q.data?.job.id," is ready for explicit live confirmation."]})]}),t.jsxs("div",{className:"space-y-2 rounded-md border border-destructive/20 bg-destructive/[0.025] p-3",children:[t.jsx(re,{htmlFor:"delete-confirmation",className:"text-xs font-semibold uppercase tracking-wider",children:"Live deletion confirmation"}),t.jsx(ke,{id:"delete-confirmation",value:g,disabled:!e,onChange:H=>v(H.target.value),placeholder:"Type DELETE after preview completes",autoComplete:"off","aria-describedby":"delete-gate"}),t.jsxs("p",{id:"delete-gate",className:"text-xs text-muted-foreground",children:["Enter DELETE for ",r.length," selected site(s) and ",a.join(", "),". Preview is a point-in-time estimate; every row is checked again before deletion. Live deletion stays blocked until a completed preview matches this exact scope."]}),t.jsxs(L,{variant:"destructive",className:"w-full",disabled:!Q||O.isPending,onClick:()=>je("delete"),children:[t.jsx(sa,{className:"mr-2 h-4 w-4"}),"Delete eligible metadata"]})]}),t.jsxs("div",{className:"space-y-2 rounded-md border border-destructive/40 bg-destructive/[0.045] p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[t.jsx(Pn,{className:"h-4 w-4 text-destructive"}),"Delete without preview"]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Immediately delete expired database metadata for the ",r.length," selected site(s) and ",a.join(", ")||"no tables",". You will not see an eligible count before deletion. Every row is rechecked against current retention and ownership; Google Cloud files are not deleted. You can cancel while the job runs, but committed deletions cannot be undone here."]}),t.jsx(re,{htmlFor:"direct-delete-confirmation",className:"text-xs font-semibold uppercase tracking-wider",children:"Type DELETE WITHOUT PREVIEW to confirm this scope"}),t.jsx(ke,{id:"direct-delete-confirmation",value:b,disabled:!e,onChange:H=>y(H.target.value),placeholder:"DELETE WITHOUT PREVIEW",autoComplete:"off"}),t.jsxs(L,{variant:"destructive",className:"w-full",disabled:!Y||O.isPending,onClick:()=>je("direct-delete"),children:[O.isPending&&O.variables?.mode==="direct-delete"?t.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}):t.jsx(sa,{className:"mr-2 h-4 w-4"}),"Delete now without preview"]})]})]})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{className:"text-base",children:"Current service status"}),t.jsx(Xs,{children:"Scheduler status reported by the metadata service."})]}),t.jsx(mt,{children:R.isLoading?t.jsx(Bt,{className:"h-14 w-full"}):R.data?.status&&Object.keys(R.data.status).length?t.jsx("dl",{className:"grid grid-cols-2 gap-x-3 gap-y-2 text-sm",children:Object.entries(R.data.status).map(([H,se])=>t.jsxs("div",{className:"min-w-0 border-b border-border/50 pb-2",children:[t.jsx("dt",{className:"text-xs capitalize text-muted-foreground",children:$v(H)}),t.jsx("dd",{className:"mt-0.5 break-words font-medium",children:$v(se)})]},H))}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional service status is available."})})]})]})]}),!!D.data?.jobs.length&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[t.jsx(re,{htmlFor:"metadata-job-history",children:"Recent jobs"}),t.jsxs(Us,{value:o,onValueChange:H=>{l(H),S([]),A(null);try{localStorage.setItem("cloud-metadata-active-job",H)}catch{}},children:[t.jsx($s,{id:"metadata-job-history",className:"w-full max-w-md",children:t.jsx(zs,{placeholder:"Choose a saved job"})}),t.jsx(Fs,{children:D.data.jobs.map(H=>t.jsxs(rt,{value:H.id,children:[H.mode," · ",new Date(H.createdAt).toLocaleStr
291ing()," · ",H.state]},H.id))})]})]}),o&&t.jsxs(ut,{className:"overflow-hidden",children:[t.jsx(xs,{className:"border-b border-border/60 bg-muted/20",children:t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ys,{className:"text-base",children:"Job results"}),q.data&&t.jsx(Ke,{variant:q.data.job.mode==="delete"?"destructive":"secondary",children:q.data.job.mode==="dry-run"?"Dry run":"Live deletion"})]}),t.jsxs(Xs,{className:"mt-1 font-mono text-xs",children:["Job ",o]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>q.refetch(),disabled:q.isFetching,children:[t.jsx(tl,{className:`mr-2 h-3.5 w-3.5 ${q.isFetching?"animate-spin":""}`}),"Refresh"]}),t.jsxs(L,{size:"sm",variant:"outline",onClick:le,disabled:!q.data,children:[t.jsx($ce,{className:"mr-2 h-3.5 w-3.5"}),"Download CSV"]}),e&&q.data&&Lv.has(q.data.job.state.toLowerCase())&&t.jsxs(L,{size:"sm",variant:"destructive",onClick:ue,children:[t.jsx(nO,{className:"mr-2 h-3.5 w-3.5"}),"Cancel job"]})]})]})}),t.jsxs(mt,{className:"space-y-4 p-4 sm:p-5",children:[q.isError&&t.jsxs(pu,{variant:"destructive",role:"alert",children:[t.jsx(Pn,{className:"h-4 w-4"}),t.jsx(Yu,{children:"Job status unavailable"}),t.jsxs(fu,{children:[String(q.error.message)," ",t.jsx(L,{variant:"ghost",className:"h-auto p-0 text-inherit underline",onClick:()=>q.refetch(),children:"Retry"})]})]}),q.isLoading?t.jsxs("div",{className:"space-y-2",children:[t.jsx(Bt,{className:"h-10 w-full"}),t.jsx(Bt,{className:"h-28 w-full"})]}):q.data&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap gap-x-5 gap-y-2 rounded-md bg-muted/30 px-3 py-3 text-sm",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Xce,{className:"h-4 w-4 text-muted-foreground"}),"State: ",t.jsx("strong",{className:"capitalize",children:$v(q.data.job.state)})," ",q.data.job.complete?"(complete)":"(partial)"]}),["inspected","eligible","deleted","skipped","failed"].map(H=>t.jsxs("span",{className:"text-muted-foreground capitalize",children:[$v(H)," ",t.jsx("strong",{className:"text-foreground",children:q.data.job[H].toLocaleString()})]},H)),Lv.has(q.data.job.state.toLowerCase())&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-primary",children:[t.jsx(Fe,{className:"h-3.5 w-3.5 animate-spin"}),"Updating live"]})]}),q.data.job.error&&t.jsxs(pu,{variant:"destructive",children:[t.jsx(Pn,{className:"h-4 w-4"}),t.jsx(Yu,{children:"Job reported an error"}),t.jsx(fu,{children:q.data.job.error})]}),t.jsx("div",{className:"overflow-x-auto rounded-md border border-border/70",children:t.jsxs("table",{className:"w-full min-w-[750px] text-left text-xs",children:[t.jsx("thead",{className:"bg-muted/50 text-[10px] uppercase tracking-wider text-muted-foreground",children:t.jsx("tr",{children:["Site","Table","Record","Camera / start","Retention","Action","Reason"].map(H=>t.jsx("th",{className:"px-3 py-2.5",children:H},H))})}),t.jsxs("tbody",{className:"divide-y divide-border/60",children:[[...q.data.entries,...k].map((H,se)=>t.jsxs("tr",{className:"hover:bg-muted/20",children:[t.jsxs("td",{className:"px-3 py-2.5",children:[t.jsx("div",{className:"font-medium",children:H.siteName}),t.jsx("div",{className:"text-[10px] text-muted-foreground",children:H.siteId})]}),t.jsx("td",{className:"px-3 py-2.5 font-mono",children:H.table}),t.jsx("td",{className:"px-3 py-2.5 font-mono",children:H.id}),t.jsxs("td",{className:"px-3 py-2.5",children:[H.camera||"—",H.start&&t.jsx("div",{className:"text-[10px] text-muted-foreground",children:new Date(typeof H.start=="number"?H.start*1e3:H.start).toLocaleString()})]}),t.jsx("td",{className:"px-3 py-2.5",children:H.retentionDays==null?"—":`${H.retentionDays}d`}),t.jsx("td",{className:"px-3 py-2.5",children:t.jsx(Ke,{variant:H.action==="deleted"||H.action==="eligible"?"destructive":"outline",children:$v(H.action)})}),t.jsx("td",{className:"max-w-[230px] px-3 py-2.5 text-muted-foreground",children:H.reason||"—"})]},`${H.siteId}:${H.table}:${H.id}:${se}`)),!q.data.entries.length&&!k.length&&t.jsx("tr",{children:t.jsx("td",{colSpan:7,className:"px-4 py-8 text-center text-muted-foreground",children:"No row results have been reported yet."})})]})]})}),T&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:T}),_&&t.jsx("div",{className:"text-center",children:t.jsxs(L,{variant:"outline",size:"sm",onClick:pe,children:[t.jsx(Xa,{className:"mr-2 h-4 w-4"}),"Load more results"]})})]})]})]}),t.jsxs(ut,{children:[t.jsx(xs,{className:"border-b border-border/60",children:t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx(ys,{className:"text-base",children:"Storage reclamation preflight"}),t.jsx(Xs,{className:"mt-1",children:"Check reclaim safety and method before starting an operation. Unsafe or downtime-required work is blocked here."})]}),t.jsxs(Us,{value:x,onValueChange:H=>C(H),children:[t.jsx($s,{className:"w-[180px]","aria-label":"Reclaim scope",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"cloud",children:"Cloud storage"}),t.jsx(rt,{value:"database",children:"Database"})]})]})]})}),t.jsxs(mt,{className:"space-y-4 p-4 sm:p-5",children:[V.isLoading?t.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[t.jsx(Bt,{className:"h-16"}),t.jsx(Bt,{className:"h-16"}),t.jsx(Bt,{className:"h-16"})]}):V.isError||!V.data?t.jsxs(pu,{variant:"destructive",role:"alert",children:[t.jsx(Pn,{className:"h-4 w-4"}),t.jsx(Yu,{children:"Preflight unavailable"}),t.jsxs(fu,{children:["Safety cannot be confirmed, so reclamation is disabled. ",t.jsx(L,{variant:"ghost",className:"h-auto p-0 text-inherit underline",onClick:()=>V.refetch(),children:"Retry"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"grid gap-px overflow-hidden rounded-md border border-border/70 bg-border/70 sm:grid-cols-3",children:[["Allocated",Op(V.data.allocatedBytes)],["Table / index",`${Op(V.data.tableBytes)} / ${Op(V.data.indexBytes)}`],["Required / available",`${Op(V.data.requiredBytes)} / ${Op(V.data.availableBytes)}`]].map(([H,se])=>t.jsxs("div",{className:"bg-card px-3 py-3",children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:H}),t.jsx("div",{className:"mt-1 font-mono text-sm font-medium",children:se})]},H))}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[t.jsx(Ke,{variant:V.data.canRun?"secondary":"destructive",children:V.data.canRun?"Capacity preflight clear":"Hard blocked"}),t.jsxs("span",{className:"text-muted-foreground",children:["Limit ",Op(V.data.limitBytes)," · Method: ",V.data.method]})]}),V.data.backupStatus&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Backup: ",V.data.backupStatus.ready?`verified ${new Date(V.data.backupStatus.latestSuccessfulAt).toLocaleStr
291ing()}`:V.data.backupStatus.reason]}),V.data.reason&&t.jsxs(pu,{variant:V.data.canRun?"default":"destructive",children:[t.jsx(Pn,{className:"h-4 w-4"}),t.jsx(Yu,{children:V.data.canRun?"Exclusive lock and maintenance window required":"Safety limits prevent this operation"}),t.jsx(fu,{children:V.data.reason})]}),t.jsxs("div",{className:"rounded-md border border-border/70 p-3 text-sm space-y-2",role:"region","aria-label":"Maintenance lock diagnostic",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"font-medium",children:"Primary database maintenance lock"}),t.jsx(L,{size:"sm",variant:"outline",disabled:K.isFetching,onClick:()=>K.refetch(),children:K.isFetching?"Checking…":"Check lock holders"})]}),K.isError&&t.jsx("p",{role:"alert",className:"text-destructive",children:"Lock status could not be verified. Do not attempt maintenance; retry or ask a database operator to inspect the primary database."}),!K.isError&&K.data&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("p",{children:["Checked ",new Date(K.data.checkedAt).toLocaleString(),": ",K.data.held?`${K.data.holders.length} holder(s) found.`:"No holder observed at this instant. A new operation may still start; preflight and start checks remain required."]}),K.data.holders.map(H=>t.jsxs("p",{className:"rounded bg-muted/40 p-2",children:["Backend ",H.pid," · ",H.mode," lock · ",H.reclaimInProgress?"VACUUM FULL is actively reclaiming":H.activity==="active"?"active database query (reclaim not verified)":H.activity==="idle"?"idle database session (not proof of an orphan)":H.activity==="monitoring_disabled"?"database activity monitoring disabled; cannot determine whether idle or active":"activity unknown",H.activitySince&&t.jsxs(t.Fragment,{children:[" · state since ",new Date(H.activitySince).toLocaleString()]}),H.sessionStartedAt&&t.jsxs(t.Fragment,{children:[" · session started ",new Date(H.sessionStartedAt).toLocaleString()]})]},`${H.pid}-${H.mode}`)),K.data.held&&t.jsx("p",{className:"text-muted-foreground",children:"Do not terminate a backend or bypass this lock while work may be active. If activity monitoring is disabled or unknown, have a database operator verify activity through provider tools before drawing conclusions. If an exclusive holder stays idle, first check running reclaim and cleanup jobs, recent application activity, and repeat this diagnostic after a suitable interval. Only if a database operator confirms the worker is gone and the lock is orphaned should they coordinate a maintenance window and release that specific backend using provider-approved procedures. Recheck the lock and run a fresh preflight afterward. This page never releases locks or terminates sessions."})]})]}),V.data.handoff&&t.jsxs("div",{className:"rounded-md border border-amber-600/40 bg-amber-500/5 p-4 text-sm",role:"region","aria-label":"Database recovery handoff",children:[t.jsx("h3",{className:"font-semibold",children:"Operator-led database recovery"}),t.jsx("p",{className:"mt-1",children:"No in-app whole-database rewrite or capacity override is available. Do not raise the 100 GB application limit unless the database provider has actually increased the limit and confirmed physical free space."}),t.jsxs("ol",{className:"mt-3 list-decimal space-y-2 pl-5",children:[t.jsxs("li",{children:["Arrange a maintenance window and a database operator. ",V.data.handoff.kind==="capacity"&&t.jsxs(t.Fragment,{children:["For cloud tables only, a provider-confirmed capacity expansion may allow a new preflight, provided the estimated rewrite (",(V.data.requiredBytes/1e9).toFixed(1)," GB plus existing allocation) fits. Otherwise, "]}),"provision a separate empty PostgreSQL destination with at least ",t.jsxs("strong",{children:[(V.data.handoff.recommendedDestinationBytes/1e9).toFixed(1)," GB"]})," of verified usable capacity and independent backup storage. This figure is a planning floor, not a filesystem check."]}),t.jsx("li",{children:"Verify a restorable backup and checksum, then stop application writes and take a fresh final dump. Keep the original database intact. Restore to the separate destination while writes remain stopped; test schema, row counts and application reads before cutover."}),t.jsxs("li",{children:["Measure ",t.jsx("code",{children:"pg_database_size(current_database())"})," on both source (at write freeze) and restored destination. ",t.jsx("strong",{children:"Only report reclaimed space if the destination’s allocated bytes are smaller."})," If it is not smaller, do not cut over as a shrink; revisit the plan."]}),t.jsx("li",{children:"Switch traffic only after validation; keep the old database untouched for rollback. If validation fails, reconnect to the original before reopening writes. After cutover, rollback requires pausing writes again and reconciling any new writes first."})]}),t.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Expect write downtime for the final dump, restore, validation and cutover. Cloud table VACUUM FULL remains blocked until a fresh preflight passes; this handoff does not start a migration."})]}),V.data.canRun&&t.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[t.jsx(On,{checked:h,onCheckedChange:H=>p(H===!0)}),t.jsx("span",{children:"I have confirmed a maintenance window and understand the cloud tables will be unavailable while they are rewritten."})]}),t.jsxs("div",{className:"flex flex-col gap-3 border-t border-border/60 pt-4 sm:flex-row sm:items-end sm:justify-between",children:[t.jsxs("div",{className:"w-full max-w-sm space-y-1.5",children:[t.jsx(re,{htmlFor:`reclaim-${x}`,className:"text-xs font-semibold uppercase tracking-wider",children:"Distinct authorization"}),t.jsx(ke,{id:`reclaim-${x}`,value:w[x],disabled:!e,onChange:H=>j(se=>({...se,[x]:H.target.value})),placeholder:"Type RECLAIM",autoComplete:"off"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"This confirmation is separate from row deletion."})]}),t.jsxs(L,{variant:"outline",disabled:!fe||w[x]!=="RECLAIM"||G.isPending,onClick:()=>G.mutate({scope:x}),children:[G.isPending?t.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}):t.jsx(mf,{className:"mr-2 h-4 w-4"}),"Start reclaim operation"]})]})]}),G.isError&&t.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Reclaim request failed: ",String(G.error.message)]}),Z&&t.jsxs("div",{className:"rounded-md border border-border/70 p-3 text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[t.jsx("span",{className:"capitalize",children:Z.state==="succeeded"&&(Z.beforeBytes==null||Z.afterBytes==null||Z.afterBytes>=Z.beforeBytes)?"Unverified":$v(Z.state)}),Z.state&&Lv.has(Z.state.toLowerCase())&&t.jsx(Fe,{className:"h-4 w-4 animate-spin"})]}),Z.error&&t.jsx("p",{role:"alert",className:"mt-1 text-destructive",children:Z.error}),Z.beforeBytes!=null&&t.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Before ",Op(Z.beforeBytes),Z.afterBytes!=null?` · after ${Op(Z.afterBytes)}`:""]}),Z.state==="succeeded"&&Z.beforeBytes!=null&&Z.afterBytes!=null&&Z.afterBytes<Z.beforeBytes&&t.jsxs("p",{className:"mt-1 text-xs",children:["Allocated database size decreased by ",Op(Z.beforeBytes-Z.afterBytes),"."]})]}),z.isError&&t.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Reclaim job status unavailable. ",t.jsx(L,{variant:"ghost",className:"h-auto p-0 text-inherit underline",onClick:()=>z.refetch(),children:"Retry"})]})]})]})]})}function TP(e){return e==null?"—":e>=1e3?`${(e/1e3).toFixed(2)} s`:`${Math.round(e)} ms`}function Fv(e){return`${(e*100).toFixed(1)}%`}function S1e(e){if(!e)return"—";
291try{return new Date(e).toLocaleString()}catch{return"—"}}function C1e(){const[e,s]=u.useState("7"),{data:r,isLoading:n}=ze({queryKey:["/api/admin/playback-telemetry/aggregate",e],queryFn:async()=>{const o=await fetch(`/api/admin/playback-telemetry/aggregate?days=${encodeURIComponent(e)}`);if(!o.ok)throw new Error(`Failed (${o.status})`);return o.json()},staleTime:3e4}),{data:a,isLoading:i}=ze({queryKey:["/api/admin/playback-telemetry/by-user",e],queryFn:async()=>{const o=await fetch(`/api/admin/playback-telemetry/by-user?days=${encodeURIComponent(e)}`);if(!o.ok)throw new Error(`Failed (${o.status})`);return o.json()},staleTime:3e4});return t.jsxs("div",{className:"space-y-4",children:[t.jsxs(ut,{"data-testid":"card-playback-health",children:[t.jsx(xs,{children:t.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(vc,{className:"w-5 h-5"}),"Playback Health"]}),t.jsxs(Xs,{children:["Real-world recording playback metrics collected from viewers. Time-to-first-frame, HLS error counts, stall rate, and how often the slow MP4 fallback fires per Edge device.",r?` Samples kept for ${r.retentionDays} days.`:""]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"Window"}),t.jsxs(Us,{value:e,onValueChange:s,children:[t.jsx($s,{className:"w-32","data-testid":"select-playback-window",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"1",children:"Last 24 hours"}),t.jsx(rt,{value:"7",children:"Last 7 days"}),t.jsx(rt,{value:"14",children:"Last 14 days"}),t.jsx(rt,{value:"30",children:"Last 30 days"})]})]})]})]})}),t.jsx(mt,{children:n?t.jsxs("div",{className:"space-y-2",children:[t.jsx(Bt,{className:"h-8 w-full"}),t.jsx(Bt,{className:"h-8 w-full"}),t.jsx(Bt,{className:"h-8 w-full"})]}):!r||r.rows.length===0?t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-playback-empty",children:"No playback samples in the selected window yet. Open a recording in the Recordings page to start collecting telemetry."}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border text-left text-muted-foreground",children:[t.jsx("th",{className:"py-2 pr-3 font-medium",children:"Edge device"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Samples"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Median TTFF"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"p95 TTFF"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Avg HLS errors"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Avg seeks"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Stall rate"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Fallback rate"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Failure rate"})]})}),t.jsx("tbody",{children:r.rows.map((o,l)=>{const c=o.edgeDeviceId??`unassigned-${l}`,d=o.serialNumber??(o.edgeDeviceId?o.edgeDeviceId.slice(0,8):"(unassigned)");return t.jsxs("tr",{className:"border-b border-border/50","data-testid":`row-playback-${c}`,children:[t.jsx("td",{className:"py-2 pr-3 font-mono","data-testid":`text-playback-device-${c}`,children:d}),t.jsx("td",{className:"py-2 pr-3 text-right","data-testid":`text-playback-samples-${c}`,children:o.sampleCount}),t.jsx("td",{className:"py-2 pr-3 text-right","data-testid":`text-playback-median-${c}`,children:TP(o.medianTtffMs)}),t.jsx("td",{className:"py-2 pr-3 text-right",children:TP(o.p95TtffMs)}),t.jsx("td",{className:"py-2 pr-3 text-right",children:o.avgHlsErrors.toFixed(2)}),t.jsx("td",{className:"py-2 pr-3 text-right","data-testid":`text-playback-seeks-${c}`,children:o.avgSeeks.toFixed(2)}),t.jsx("td",{className:"py-2 pr-3 text-right","data-testid":`text-playback-stall-${c}`,children:Fv(o.stallRate)}),t.jsx("td",{className:"py-2 pr-3 text-right","data-testid":`text-playback-fallback-${
291c}`,children:Fv(o.fallbackRate)}),t.jsx("td",{className:"py-2 pr-3 text-right",children:Fv(o.failureRate)})]},c)})})]})})})]}),t.jsxs(ut,{"data-testid":"card-playback-by-user",children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(Ba,{className:"w-5 h-5"}),"Who's watching recordings"]}),t.jsx(Xs,{children:"Per-user playback activity in the same window. Shows how many recordings each user opened, across how many devices and events, plus their playback quality."})]}),t.jsx(mt,{children:i?t.jsxs("div",{className:"space-y-2",children:[t.jsx(Bt,{className:"h-8 w-full"}),t.jsx(Bt,{className:"h-8 w-full"}),t.jsx(Bt,{className:"h-8 w-full"})]}):!a||a.rows.length===0?t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-playback-user-empty",children:"No per-user playback samples in the selected window yet."}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border text-left text-muted-foreground",children:[t.jsx("th",{className:"py-2 pr-3 font-medium",children:"User"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Sessions"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Devices"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Events"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Median TTFF"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Stall rate"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Fallback rate"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Failure rate"}),t.jsx("th",{className:"py-2 pr-3 font-medium text-right",children:"Last access"})]})}),t.jsx("tbody",{children:a.rows.map((o,l)=>{const c=o.userId??`anon-${l}`,d=o.userName||o.userEmail||(o.userId?o.userId.slice(0,8):"(unauthenticated)"),h=o.userName&&o.userEmail?o.userEmail:null;return t.jsxs("tr",{className:"border-b border-border/50","data-testid":`row-playback-user-${c}`,children:[t.jsxs("td",{className:"py-2 pr-3","data-testid":`text-playback-user-${c}`,children:[t.jsx("div",{className:"font-medium",children:d}),h&&t.jsx("div",{className:"text-xs text-muted-foreground",children:h})]}),t.jsx("td",{className:"py-2 pr-3 text-right","data-testid":`text-playback-user-samples-${c}`,children:o.sampleCount}),t.jsx("td",{className:"py-2 pr-3 text-right",children:o.distinctDevices}),t.jsx("td",{className:"py-2 pr-3 text-right",children:o.distinctEvents}),t.jsx("td",{className:"py-2 pr-3 text-right",children:TP(o.medianTtffMs)}),t.jsx("td",{className:"py-2 pr-3 text-right",children:Fv(o.stallRate)}),t.jsx("td",{className:"py-2 pr-3 text-right",children:Fv(o.fallbackRate)}),t.jsx("td",{className:"py-2 pr-3 text-right",children:Fv(o.failureRate)}),t.jsx("td",{className:"py-2 pr-3 text-right text-muted-foreground",children:S1e(o.lastAccessAt)})]},c)})})]})})})]})]})}function of(e,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e?.(a),r===!1||!a.defaultPrevented)return s?.(a)}}function SM(e){const s=k1e(e),r=u.forwardRef((n,a)=>{const{children:i,...o}=n,l=u.Children.toArray(i),c=l.find(P1e);if(c){const d=c.props.children,h=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return t.jsx(s,{...o,ref:a,children:u.isValidElement(d)?u.cloneElement(d,void 0,h):null})}return t.jsx(s,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function k1e(e){const s=u.forwardRef((r,n)=>{const{children:a,...i}=r;if(u.isValidElement(a)){const o=T1e(a),l=E1e(i,a.props);return a.type!==u.Fragment&&(l.ref=n?jf(n,o):o),u.cloneElement(a,l)}return u.Children.count(a)>1?u.Children.only(null):null});return s.displayName=`${e}.SlotClone`,s}var _1e=Symbol("radix.slottable");function P1e(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===_1e}function E1e(e,s){const r={...s};for(const n in s){const a=e[n],i=s[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}
vendor: 4,205 bytes, line 291
291:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function T1e(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function A1e(e){const s=e+"CollectionProvider",[r,n]=oo(s),[a,i]=r(s,{collectionRef:{current:null},itemMap:new Map}),o=y=>{const{scope:w,children:j}=y,x=Ne.useRef(null),C=Ne.useRef(new Map).current;return t.jsx(a,{scope:w,itemMap:C,collectionRef:x,children:j})};o.displayName=s;const l=e+"CollectionSlot",c=SM(l),d=Ne.forwardRef((y,w)=>{const{scope:j,children:x}=y,C=i(l,j),k=mr(w,C.collectionRef);return t.jsx(c,{ref:k,children:x})});d.displayName=l;const h=e+"CollectionItemSlot",p="data-radix-collection-item",g=SM(h),v=Ne.forwardRef((y,w)=>{const{scope:j,children:x,...C}=y,k=Ne.useRef(null),S=mr(w,k),_=i(h,j);return Ne.useEffect(()=>(_.itemMap.set(k,{ref:k,...C}),()=>{_.itemMap.delete(k)})),t.jsx(g,{[p]:"",ref:S,children:x})});v.displayName=h;function b(y){const w=i(e+"CollectionConsumer",y);return Ne.useCallback(()=>{const x=w.collectionRef.current;if(!x)return[];const C=Array.from(x.querySelectorAll(`[${p}]`));return Array.from(w.itemMap.values()).sort((_,A)=>C.indexOf(_.ref.current)-C.indexOf(A.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:d,ItemSlot:v},b,n]}var M1e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ob=M1e.reduce((e,s)=>{const r=SM(`Primitive.${s}`),n=u.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(c,{...l,ref:i})});return n.displayName=`Primitive.${s}`,{...e,[s]:n}},{}),R1e=bb[" useInsertionEffect ".trim().toString()]||da;function Aee({prop:e,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,i,o]=I1e({defaultProp:s,onChange:r}),l=e!==void 0,c=l?e:a;{const h=u.useRef(e!==void 0);u.useEffect(()=>{const p=h.current;p!==l&&console.warn(`${n} is changing from ${p?"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.`),h.current=l},[l,n])}const d=u.useCallback(h=>{if(l){const p=O1e(h)?h(e):h;p!==e&&o.current?.(p)}else i(h)},[l,e,i,o]);return[c,d]}function I1e({defaultProp:e,onChange:s}){const[r,n]=u.useState(e),a=u.useRef(r),i=u.useRef(s);return R1e(()=>{i.current=s},[s]),u.useEffect(()=>{a.current!==r&&(i.current?.(r),a.current=r)},[r,a]),[r,n,i]}function O1e(e){return typeof e=="function"}var AP="rovingFocusGroup.onEntryFocus",D1e={bubbles:!1,cancelable:!0},iN="RovingFocusGroup",[CM,Mee,L1e]=A1e(iN),[$1e,Ree]=oo(iN,[L1e]),[F1e,B1e]=$1e(iN),Iee=u.forwardRef((e,s)=>t.jsx(CM.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(CM.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(U1e,{...e,ref:s})})}));Iee.displayName=iN;var U1e=u.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:h=!1,...p}=e,g=u.useRef(null),v=mr(s,g),b=Og(i),[y,w]=Aee({prop:o,defaultProp:l??null,onChange:c,caller:iN}),[j,x]=u.useState(!1),C=Za(d),k=Mee(r),S=u.useRef(!1),[_,A]=u.useState(0);return u.useEffect(()=>{const T=g.current;if(T)return T.addEventListener(AP,C),()=>T.removeEventListener(AP,C)},[C]),t.jsx(F1e,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:y,onItemFocus:u.useCallback(T=>w(T),[w]),onItemShiftTab:u.useCallback(()=>x(!0),[]),onFocusableItemAdd:u.useCallback(()=>A(T=>T+1),[]),onFocusableItemRemove:u.useCallback(()=>A(T=>T-1),[]),children:t.jsx(Ob.div,{tabIndex:j||_===0?-1:0,"data-orientation":n,...p,ref:v,style:{outline:"none",...e.style},onMouseDown:of(e.onMouseDown,()=>{S.current=!0}),onFocus:of(e.onFocus,T=>{const M=!S.current;if(T.target===T.currentTarget&&M&&!j){const R=new CustomEvent(AP,D1e);if(T.currentTarget.dispatchEvent(R),!R.defaultPrevented){const D=k().filter(K=>K.focusable),$=D.find(K=>K.active),O=D.find(K=>
vendor: 4,735 bytes, line 291
291K.id===y),V=[$,O,...D].filter(Boolean).map(K=>K.ref.current);Lee(V,h)}}S.current=!1}),onBlur:of(e.onBlur,()=>x(!1))})})}),Oee="RovingFocusGroupItem",Dee=u.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:i,children:o,...l}=e,c=wu(),d=i||c,h=B1e(Oee,r),p=h.currentTabStopId===d,g=Mee(r),{onFocusableItemAdd:v,onFocusableItemRemove:b,currentTabStopId:y}=h;return u.useEffect(()=>{if(n)return v(),()=>b()},[n,v,b]),t.jsx(CM.ItemSlot,{scope:r,id:d,focusable:n,active:a,children:t.jsx(Ob.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...l,ref:s,onMouseDown:of(e.onMouseDown,w=>{n?h.onItemFocus(d):w.preventDefault()}),onFocus:of(e.onFocus,()=>h.onItemFocus(d)),onKeyDown:of(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){h.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const j=q1e(w,h.orientation,h.dir);if(j!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=g().filter(k=>k.focusable).map(k=>k.ref.current);if(j==="last")C.reverse();else if(j==="prev"||j==="next"){j==="prev"&&C.reverse();const k=C.indexOf(w.currentTarget);C=h.loop?V1e(C,k+1):C.slice(k+1)}setTimeout(()=>Lee(C))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:y!=null}):o})})});Dee.displayName=Oee;var z1e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function H1e(e,s){return s!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function q1e(e,s,r){const n=H1e(e.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return z1e[n]}function Lee(e,s=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function V1e(e,s){return e.map((r,n)=>e[(s+n)%e.length])}var W1e=Iee,K1e=Dee;function G1e(e,s){return u.useReducer((r,n)=>s[r][n]??r,e)}var $ee=e=>{const{present:s,children:r}=e,n=Y1e(s),a=typeof r=="function"?r({present:n.isPresent}):u.Children.only(r),i=mr(n.ref,Q1e(a));return typeof r=="function"||n.isPresent?u.cloneElement(a,{ref:i}):null};$ee.displayName="Presence";function Y1e(e){const[s,r]=u.useState(),n=u.useRef(null),a=u.useRef(e),i=u.useRef("none"),o=e?"mounted":"unmounted",[l,c]=G1e(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=b1(n.current);i.current=l==="mounted"?d:"none"},[l]),da(()=>{const d=n.current,h=a.current;if(h!==e){const g=i.current,v=b1(d);e?c("MOUNT"):v==="none"||d?.display==="none"?c("UNMOUNT"):c(h&&g!==v?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),da(()=>{if(s){let d;const h=s.ownerDocument.defaultView??window,p=v=>{const y=b1(n.current).includes(CSS.escape(v.animationName));if(v.target===s&&y&&(c("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",d=h.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},g=v=>{v.target===s&&(i.current=b1(n.current))};return s.addEventListener("animationstart",g),s.addEventListener("animationcancel",p),s.addEventListener("animationend",p),()=>{h.clearTimeout(d),s.removeEventListener("animationstart",g),s.removeEventListener("animationcancel",p),s.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{n.current=d?getComputedStyle(d):null,r(d)},[])}}function b1(e){return e?.animationName||"none"}function Q1e(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var g_="Tabs",[X1e]=oo(g_,[Ree]),Fee=Ree(),[Z1e,P3]=X1e(g_),Bee=u.forwardRef((e,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:l,activationMode:c="automatic",...d}=e,h=Og(l),[p,g]=Aee({prop:n,onChange:a,defaultProp:i??"",caller:g_});return t.jsx(Z1e,{scope:r,baseId:wu(),value:p,onValueChange:g,orientation:o,dir:h,activationMode:c,children:t.jsx(Ob.div,{dir:h,"data-orientation":o,...d,ref:s})})});Bee.displayName=g_;var Uee="TabsList",zee=u.forwardRef((e,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=e,i=P3(Uee,r),o=Fee(r);return t.jsx(W1e,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:n,children:t.jsx(Ob.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:s})})});zee.displayName=Uee;var Hee="TabsTrigger",qee=u.forwardRef((e,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...i}
291=e,o=P3(Hee,r),l=Fee(r),c=Kee(o.baseId,n),d=Gee(o.baseId,n),h=n===o.value;return t.jsx(K1e,{asChild:!0,...l,focusable:!a,active:h,children:t.jsx(Ob.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":d,"data-state":h?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...i,ref:s,onMouseDown:of(e.onMouseDown,p=>{!a&&p.button===0&&p.ctrlKey===!1?o.onValueChange(n):p.preventDefault()}),onKeyDown:of(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&o.onValueChange(n)}),onFocus:of(e.onFocus,()=>{const p=o.activationMode!=="manual";!h&&!a&&p&&o.onValueChange(n)})})})});qee.displayName=Hee;var Vee="TabsContent",Wee=u.forwardRef((e,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:i,...o}=e,l=P3(Vee,r),c=Kee(l.baseId,n),d=Gee(l.baseId,n),h=n===l.value,p=u.useRef(h);return u.useEffect(()=>{const g=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(g)},[]),t.jsx($ee,{present:a||h,children:({present:g})=>t.jsx(Ob.div,{"data-state":h?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!g,id:d,tabIndex:0,...o,ref:s,style:{...e.style,animationDuration:p.current?"0s":void 0},children:g&&i})})});Wee.displayName=Vee;function Kee(e,s){return`${e}-trigger-${s}`}function Gee(e,s){return`${e}-content-${s}`}var J1e=Bee,Yee=zee,Qee=qee,Xee=Wee;const _h=J1e,Dm=u.forwardRef(({className:e,...s},r)=>t.jsx(Yee,{ref:r,className:Cs("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...s}));Dm.displayName=Yee.displayName;const _n=u.forwardRef(({className:e,...s},r)=>t.jsx(Qee,{ref:r,className:Cs("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...s}));_n.displayName=Qee.displayName;const ea=u.forwardRef(({className:e,...s},r)=>t.jsx(Xee,{ref:r,className:Cs("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...s}));ea.displayName=Xee.displayName;function eSe(){const{toast:e}=Hs(),s=Su(),[r,n]=u.useState(!1),[a,i]=u.useState(null),[o,l]=u.useState(""),[c,d]=u.useState(""),{data:h,isLoading:p}=ze({queryKey:["/api/admin/blog/feeds"],queryFn:async()=>{const C=await fetch("/api/admin/blog/feeds",{credentials:"include"});if(!C.ok)throw new Error(`HTTP ${C.status}`);return C.json()}}),g=()=>s.invalidateQueries({queryKey:["/api/admin/blog/feeds"]}),v=Et({mutationFn:async C=>(await Ze("POST","/api/admin/blog/feeds",C)).json(),onSuccess:()=>{g(),n(!1),l(""),d(""),e({title:"Feed added"})},onError:C=>e({title:"Add failed",description:C.message,variant:"destructive"})}),b=Et({mutationFn:async({id:C,...k})=>(await Ze("PATCH",`/api/admin/blog/feeds/${C}`,k)).json(),onSuccess:()=>{g(),n(!1),i(null)},onError:C=>e({title:"Update failed",description:C.message,variant:"destructive"})}),y=Et({mutationFn:async C=>(await Ze("DELETE",`/api/admin/blog/feeds/${C}`)).json(),onSuccess:()=>{g(),e({title:"Feed deleted"})},onError:C=>e({title:"Delete failed",description:C.message,variant:"destructive"})}),w=()=>{i(null),l(""),d(""),n(!0)},j=C=>{i(C),l(C.label),d(C.url),n(!0)},x=()=>{if(!o.trim()||!c.trim()){e({title:"Label and URL are required",variant:"destructive"});return}a?b.mutate({id:a.id,label:o.trim(),url:c.trim()}):v.mutate({label:o.trim(),url:c.trim()})};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"RSS / Atom feeds used by the blog generator. Up to 5 newest items per feed are evaluated each run."}),t.jsxs(L,{size:"sm",onClick:w,"data-testid":"btn-add-blog-feed",children:[t.jsx(Fo,{className:"w-4 h-4 mr-1.5"})," Add feed"]})]}),p?t.jsx(Bt,{className:"h-24 w-full"}):!h||h.length===0?t.jsx(ut,{children:t.jsx(mt,{className:"py-8 text-center text-sm text-muted-foreground",children:"No feeds configured."})}):t.jsx("div",{className:"space-y-2",children:h.map(C=>t.jsx(ut,{"data-testid":`feed-row-${C.id}`,children:t.jsxs(mt,{className:"py-3 px-4 flex items-center gap-3",children:[t.jsx(t0,{className:`w-4 h-4 shrink-0 ${C.enabled?"text-primary":"text-muted-foreground"}`}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:"text-sm font-medium truncate","data-testid":`feed-label-${C.id}`,children:C.label}),!C.enabled&&t.jsx(Ke,{variant:"outline",className:"text-[10px]",children:"disabled"})]}),t.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",className:"text-[11px] text-muted-foreground hover:underline truncate block",children:C.url})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx(sr,{checked:C.enabled,onCheckedChange:k=>b.mutate({id:C.id,enabled:k}),"data-testid":`switch-feed-${C.id}`}),t.jsx(L,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>j(C),"data-testid":`btn-edit-feed-${C.id}`,children:t.jsx(ga,{className:"w-3.5 h-3.5"})}),t.jsx(L,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive",onClick:()=>{confirm(`Delete feed "${C.label}"?`)&&y.mutate(C.id)},"data-testid":`btn-delete-feed-${C.id}`,children:t.jsx(sa,{className:"w-3.5 h-3.5"})})]})]})},C.id))}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"max-w-md",children:[t.jsx(Zs,{children:t.jsx(Ks,{children:a?"Edit feed":"Add feed"})}),t.jsxs("div",{className:"space-y-3 py-2",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"feed-label",children:"Label"}),t.jsx(ke,{id:"feed-label",value:o,onChange:C=>l(C.target.value),placeholder:"e.g. SecurityWeek","data-testid":"input-feed-label"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"feed-url",children:"Feed URL"}),t.jsx(ke,{id:"feed-url",value:c,onChange:C=>d(C.target.value),placeholder:"https://example.com/feed.xml","data-testid":"input-feed-url"})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"ghost",onClick:()=>n(!1),children:"Cancel"}),t.jsxs(L,{onClick:x,disabled:v.isPending||b.isPending,"data-testid":"btn-save-feed",children:[v.isPending||b.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):null,a?"Save":"Add"]})]})]})})]})}const tSe={draft:"bg-amber-500/15 text-amber-700 dark:text-amber-400 border-amber-500/30",published:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-400 border-emerald-500/30",rejected:"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30"};function sSe({post:e,onStatusChange:s,onDelete:r}){const[n,a]=u.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx(ut,{className:"hover:border-border/80 transition-colors","data-testid":`blog-post-row-${e.id}`,children:t.jsx(mt,{className:"py-3 px-4",children:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold border ${tSe[e.status]}`,children:e.status}),e.category&&t.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-primary/10 text-primary border border-primary/20",children:e.category})]}),t.jsx("button",{className:"mt-1 text-sm font-semibold text-left hover:underline line-clamp-2 leading-snug",onClick:()=>a(!0),"data-testid":`blog-post-title-${e.id}`,children:e.title}),e.excerpt&&t.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1 mt-0.5",children:e.excerpt}),t.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-[11px] text-muted-foreground",children:[t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(cn,{className:"w-3 h-3"}),new Date(e.createdAt).toLocaleDateString()]}),e.sourceTitle&&t.jsxs("span",{className:"flex items-center gap-1 truncate max-w-[160px]",children:[t.jsx(Yp,{className:"w-3 h-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e.sourceTitle})]})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.status!=="published"&&t.jsxs(L,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-xs text-emerald-600 border-emerald-500/30 hover:bg-emerald-500/10",onClick:()=>s(e.id,"published"),"data-testid":`btn-publish-${e.id}`,children:[t.jsx(Ny,{className:"w-3.5 h-3.5 mr-1"}),"Publish"]}),e.status!=="rejected"&&t.jsxs(L,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-xs text-red-600 border-red-500/30 hover:bg-red-500/10",onClick:()=>s(e.id,"rejected"),"data-testid":`btn-reject-${e.id}`,children:[t.jsx(rf,{className:"w-3.5 h-3.5 mr-1"}),"Reject"]}),e.status==="published"&&t.jsx(L,{size:"sm",variant:"outline",className:"h-7 px-2 text-xs",onClick:()=>window.open(`/blog/${e.slug}`,"_blank"),"data-testid":`btn-view-live-${e.id}`,children:t.jsx(op,{className:"w-3.5 h-3.5"})}),t.jsx(L,{size:"sm",variant:"ghost",className:"h-7 px-2 text-muted-foreground hover:text-destructive",onClick:()=>r(e.id),"data-testid":`btn-delete-blog-${e.id}`,children:t.jsx(sa,{className:"w-3.5 h-3.5"})})]})]})})}),t.jsx(Ys,{open:n,onOpenChange:a,children:t.jsxs(Ws,{className:"max-w-2xl max-h-[85vh] flex flex-col overflow-hidden p-0",children:[t.jsx(Zs,{className:"px-6 pt-6 pb-3 border-b shrink-0",children:t.jsx(Ks,{className:"text-base leading-snug pr-6",children:e.title})}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-3","data-testid":"blog-preview-scroll",children:[e.excerpt&&t.jsx("p",{className:"text-sm text-muted-foreground italic border-l-2 border-primary/30 pl-3",children:e.excerpt}),t.jsx(Qh,{}),t.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none text-sm leading-relaxed",dangerouslySetInnerHTML:{__html:e.content}}),e.sourceUrl&&t.jsxs(t.Fragment,{children:[t.jsx(Qh,{}),t.jsxs("a",{href:e.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs text-primary hover:underline",children:[t.jsx(Yp,{className:"w-3.5 h-3.5"}),"Source: ",e.sourceTitle||e.sourceUrl]})]})]})]})})]})}function rSe(){const{toast:e}
291=Hs(),s=Su(),[r,n]=u.useState("draft"),[a,i]=u.useState("posts"),{data:o,isLoading:l,error:c,refetch:d}=ze({queryKey:["/api/admin/blog"],queryFn:async()=>{const w=await fetch("/api/admin/blog",{credentials:"include"});if(!w.ok)throw new Error(`HTTP ${w.status}: ${await w.text()}`);return w.json()},staleTime:0,refetchInterval:3e4}),h=Et({mutationFn:async({id:w,status:j})=>(await Ze("PATCH",`/api/admin/blog/${w}`,{status:j})).json(),onSuccess:()=>{s.invalidateQueries({queryKey:["/api/admin/blog"]}),e({title:"Post updated"})},onError:w=>e({title:"Error",description:w.message,variant:"destructive"})}),p=Et({mutationFn:async w=>(await Ze("DELETE",`/api/admin/blog/${w}`)).json(),onSuccess:()=>{s.invalidateQueries({queryKey:["/api/admin/blog"]}),e({title:"Post deleted"})},onError:w=>e({title:"Error",description:w.message,variant:"destructive"})}),g=Et({mutationFn:async()=>await(await Ze("POST","/api/admin/blog/generate",{force:!0})).json(),onSuccess:async w=>{await s.invalidateQueries({queryKey:["/api/admin/blog"]}),await d();const j=w.generated??0;e({title:j>0?`Generated ${j} new draft(s)`:"No drafts generated",description:j>0?void 0:"OpenAI returned no usable content — check server logs."})},onError:w=>e({title:"Generation failed",description:w.message,variant:"destructive"})}),v=w=>(o??[]).filter(j=>j.status===w),b={draft:v("draft").length,published:v("published").length,rejected:v("rejected").length},y=v(r);return t.jsxs("div",{className:"space-y-5 max-w-4xl",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[t.jsx(UK,{className:"w-5 h-5 text-primary"}),"Blog Management"]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Review AI-generated drafts, approve or reject, and trigger new generation runs."})]}),a==="posts"&&t.jsxs(L,{onClick:()=>g.mutate(),disabled:g.isPending,"data-testid":"btn-generate-blog",children:[g.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(tl,{className:"w-4 h-4 mr-2"}),"Generate Now"]})]}),t.jsxs(_h,{value:a,onValueChange:w=>i(w),children:[t.jsxs(Dm,{children:[t.jsx(_n,{value:"posts","data-testid":"tab-blog-posts",children:"Posts"}),t.jsxs(_n,{value:"feeds","data-testid":"tab-blog-feeds",children:[t.jsx(t0,{className:"w-3.5 h-3.5 mr-1.5"}),"Feeds"]})]}),t.jsx(ea,{value:"feeds",className:"mt-4",children:t.jsx(eSe,{})}),t.jsxs(ea,{value:"posts",className:"mt-4 space-y-4",children:[c&&t.jsx(ut,{className:"border-red-500/40 bg-red-500/5",children:t.jsxs(mt,{className:"py-3 px-4 text-sm text-red-600 dark:text-red-400",children:["Failed to load posts: ",c?.message||String(c)]})}),t.jsxs(_h,{value:r,onValueChange:w=>n(w),children:[t.jsxs(Dm,{children:[t.jsxs(_n,{value:"draft","data-testid":"tab-blog-draft",children:["Drafts",b.draft>0&&t.jsx("span",{className:"ml-1.5 px-1.5 py-0.5 rounded-full bg-amber-500 text-white text-[10px] font-bold leading-none",children:b.draft})]}),t.jsxs(_n,{value:"published","data-testid":"tab-blog-published",children:["Published",b.published>0&&t.jsx("span",{className:"ml-1.5 px-1.5 py-0.5 rounded-full bg-emerald-500 text-white text-[10px] font-bold leading-none",children:b.published})]}),t.jsx(_n,{value:"rejected","data-testid":"tab-blog-rejected",children:"Rejected"})]}),["draft","published","rejected"].map(w=>t.jsx(ea,{value:w,className:"mt-4 space-y-3",children:l?Array.from({length:3}).map((j,x)=>t.jsx(ut,{children:t.jsxs(mt,{className:"py-3 px-4",children:[t.jsx(Bt,{className:"h-4 w-3/4 mb-2"}),t.jsx(Bt,{className:"h-3 w-1/2"})]})},x)):y.length===0?t.jsx(ut,{children:t.jsxs(mt,{className:"py-12 text-center",children:[w==="draft"?t.jsx(tl,{className:"w-10 h-10 mx-auto mb-3 text-muted-foreground"}):w==="published"?t.jsx(Ny,{className:"w-10 h-10 mx-auto mb-3 text-muted-foreground"}):t.jsx(ta,{className:"w-10 h-10 mx-auto mb-3 text-muted-foreground"}),t.jsx("p",{className:"font-medium text-sm",children:w==="draft"?"No drafts — click Generate Now to fetch fresh posts":w==="published"?"No published posts yet":"No rejected posts"})]})}):y.map(j=>t.jsx(sSe,{post:j,onStatusChange:(x,C)=>h.mutate({id:x,status:C}),onDelete:x=>p.mutate(x)},j.id))},w))]})]})]})]})}const x_=["distribution","resellers","users","companies","subscriptions","support-requests","edge-devices","policies","cloud-storage","playback-health","api-settings","email-templates","edge-pricing","blog","branding","backups","ai-usage"],nSe={distribution:"Distribution",resellers:"Resellers",users:"Users",companies:"Companies / Sites",subscriptions:"Sales Orders","supp
291ort-requests":"Support Requests","edge-devices":"Edge Devices",policies:"Policies","cloud-storage":"Cloud Storage","playback-health":"Playback Health","api-settings":"API Settings","email-templates":"Email Templates","edge-pricing":"Edge Pricing",blog:"Blog",branding:"Branding",backups:"Backups","ai-usage":"AI Usage"},aSe=["read","write","delete"],EF=aSe;function iSe(){const e={};for(const s of x_)e[s]={read:!1,write:!1,delete:!1};return e}function TF(){const e={};for(const s of x_)e[s]={read:!0,write:!0,delete:!0};return e}function oSe(e){const s=iSe();if(!e||typeof e!="object")return s;const r=e;for(const n of x_){const a=r[n];a&&typeof a=="object"&&(s[n].read=!!a.read,s[n].write=!!a.write,s[n].delete=!!a.delete)}return s}function lSe(){const{toast:e}=Hs(),{data:s,isLoading:r}=ze({queryKey:["/api/admin/superadmins/permissions"]}),[n,a]=u.useState({}),i=ze({queryKey:["/api/admin/edge-launch-setting"]}),o=Et({mutationFn:async h=>await Ze("PUT","/api/admin/edge-launch-setting",{allowEdgeLaunch:h}),onSuccess:()=>{e({title:"Edge launch setting saved"}),Je.invalidateQueries({queryKey:["/api/admin/edge-launch-setting"]}),Je.invalidateQueries({queryKey:["/api/me/permissions"]})},onError:h=>{e({title:"Failed to save setting",description:String(h?.message??h),variant:"destructive"})}});function l(h){return h.isPrimary?TF():n[h.userId]??h.permissions??TF()}function c(h,p,g,v){if(h.isPrimary)return;const b=l(h),y=oSe({...b,[p]:{...b[p],[g]:v}});a(w=>({...w,[h.userId]:y}))}const d=Et({mutationFn:async({userId:h,permissions:p})=>await Ze("PUT",`/api/admin/superadmins/${h}/permissions`,{permissions:p}),onSuccess:(h,p)=>{e({title:"Permissions saved"}),a(g=>{const{[p.userId]:v,...b}=g;return b}),Je.invalidateQueries({queryKey:["/api/admin/superadmins/permissions"]}),Je.invalidateQueries({queryKey:["/api/me/permissions"]})},onError:h=>{e({title:"Failed to save permissions",description:String(h?.message??h),variant:"destructive"})}});return t.jsxs(ut,{"data-testid":"card-superadmin-permissions",className:"mb-4",children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(vi,{className:"w-5 h-5"}),"Superadmin Permissions"]}),t.jsx(Xs,{children:"Grant or revoke per-tab access for non-primary superadmins. The primary superadmin always retains full access and cannot be edited."})]}),t.jsxs(mt,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border rounded-lg p-4 mb-6","data-testid":"row-allow-edge-launch",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(op,{className:"w-4 h-4 mt-0.5 text-muted-foreground shrink-0"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-sm",children:"Allow Edge Launch button"}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"When off, the Launch Edge button is hidden from all superadmin users."})]})]}),t.jsx(sr,{checked:i.data?.allowEdgeLaunch!==!1,disabled:i.isLoading||o.isPending,onCheckedChange:h=>o.mutate(h),"data-testid":"switch-allow-edge-launch"})]}),r?t.jsxs("div",{className:"space-y-2",children:[t.jsx(Bt,{className:"h-12 w-full"}),t.jsx(Bt,{className:"h-12 w-full"})]}):!s||s.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No superadmins found."}):t.jsx("div",{className:"space-y-6",children:s.map(h=>{const p=l(h),g=!!n[h.userId];return t.jsxs("div",{className:"border rounded-lg p-4","data-testid":`row-superadmin-${h.userId}`,children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"font-medium flex items-center gap-2",children:[h.firstName||h.lastName?`${h.firstName??""} ${h.lastName??""}`.trim():h.email,h.isPrimary&&t.jsx(Ke,{variant:"default","data-testid":`badge-primary-${h.userId}`,children:"Primary"})]}),t.jsx("div",{className:"text-xs text-muted-foreground",children:h.email})]}),!h.isPrimary&&t.jsxs(L,{size:"sm",disabled:!g||d.isPending,onClick:()=>d.mutate({userId:h.userId,permissions:p}),"data-testid":`button-save-permissions-${h.userId}`,children:[t.jsx(Vl,{className:"w-4 h-4 mr-1"}),"Save"]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-muted-foreground",children:[t.jsx("th",{className:"py-1 pr-4 font-normal",children:"Tab"}),EF.map(v=>t.jsx("th",{className:"py-1 px-2 font-normal capitalize text-center",children:v},v))]})}),t.jsx("tbody",{children:x_.map(v=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"py-1.5 pr-4",children:nSe[v]}),EF.map(b=>t.jsx("td",{className:"py-1.5 px-2 text-center",children:t.jsx(On,{checked:!!p[v]?.[b],disabled:h.isPrimary,onCheckedChange:y=>c(h,v,b,!!y),"data-testid":`checkbox-perm-${h.userId}-${v}-${b}`})},b))]},v))})]})})]},h.userId)})})]})]})}function cSe({open:e,onOpenChange:s}){const{toast:r}=Hs(),[n,a]=u.useState(null),[i,o]=u.useState(!1),l=Et({mutationFn:async v=>await(await Ze("POST",`/api/admin/quick-connect-backfill?dryRun=${v?1:0}`)).json(),onSuccess:v=>{a(v),v.dryRun&&o(!0),r({title:v.dryRun?"Preview complete":"Backfill complete",description:`${v.camerasScanned} cameras scanned across ${v.devicesScanned} devices.`})},onError:v=>{r({title:"Backfill failed",description:v?.message||String(v),variant:"destructive"})}}),c=v=>{!v&&l.isPending||(v||(a(null),o(!1)),s(v))},d=l.isPending,h=n?n.matchedBrandAndModel+n.matchedBrandOnly:0,p=n?.devices.filter(v=>v.cameras?.some(b=>b.brand))??[],g=n?.devices.filter(v=>!v.ok)??[];return t.jsx(Ys,{open:e,onOpenChange:c,children:t.jsxs(Ws,{className:"max-w-3xl max-h-[85vh] overflow-y-auto","data-testid":"dialog-quick-connect-backfill",children:[t.jsxs(Zs,{children:[t.jsxs(Ks,{className:"flex items-center gap-2",children:[t.jsx(ZK,{className:"w-5 h-5"}),"Recover Camera Brand/Model"]}),t.jsx(cr,{children:"Scans every Edge device's camera configuration and reverse-matches each camera's RTSP URL against the Quick Connect catalog. Cameras saved before Quick Connect remembered the choice get their Brand/Model filled 
291in automatically. Existing values are never overwritten."})]}),!n&&!d&&t.jsxs(pu,{children:[t.jsx(Pn,{className:"h-4 w-4"}),t.jsx(Yu,{children:"Run a preview first"}),t.jsxs(fu,{children:["Start with ",t.jsx("strong",{children:"Preview (Dry Run)"})," to see what would change without writing anything. When the matches look right, click ",t.jsx("strong",{children:"Apply Changes"}),"."]})]}),d&&t.jsxs("div",{className:"flex items-center justify-center py-10 gap-3 text-muted-foreground","data-testid":"status-backfill-running",children:[t.jsx(Fe,{className:"w-5 h-5 animate-spin"}),t.jsx("span",{children:"Scanning every Edge device's camera configuration…"})]}),n&&!d&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs(pu,{variant:n.devicesFailed>0?"destructive":"default",children:[n.devicesFailed>0?t.jsx(Pn,{className:"h-4 w-4"}):t.jsx(ar,{className:"h-4 w-4"}),t.jsxs(Yu,{"data-testid":"text-backfill-result-title",children:[n.dryRun?"Preview":"Backfill complete",n.dryRun?" — nothing was saved":""]}),t.jsxs(fu,{children:["Scanned ",n.camerasScanned," cameras across ",n.devicesScanned," devices",n.devicesFailed>0?`, ${n.devicesFailed} device(s) failed`:"","."]})]}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[t.jsxs("div",{className:"rounded-md border p-3","data-testid":"stat-matched-full",children:[t.jsx("div",{className:"text-2xl font-semibold",children:n.matchedBrandAndModel}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Brand + Model matched"})]}),t.jsxs("div",{className:"rounded-md border p-3","data-testid":"stat-matched-brand-only",children:[t.jsx("div",{className:"text-2xl font-semibold",children:n.matchedBrandOnly}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Brand only matched"})]}),t.jsxs("div",{className:"rounded-md border p-3","data-testid":"stat-skipped",children:[t.jsx("div",{className:"text-2xl font-semibold",children:n.camerasSkippedAlreadySet}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Skipped (already set)"})]}),t.jsxs("div",{className:"rounded-md border p-3","data-testid":"stat-unmatched",children:[t.jsx("div",{className:"text-2xl font-semibold",children:n.unmatched}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Unmatched / ambiguous"})]})]}),g.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("h4",{className:"text-sm font-semibold",children:"Devices that failed to scan"}),t.jsx("div",{className:"space-y-1",children:g.map(v=>t.jsxs("div",{className:"text-xs border rounded p-2 bg-destructive/5","data-testid":`row-device-error-${v.edgeDeviceId}`,children:[t.jsx("span",{className:"font-mono font-semibold",children:v.serialNumber||v.edgeDeviceId}),t.jsx("span",{className:"text-destructive ml-2",children:v.error||"Unknown error"})]},v.edgeDeviceId))})]}),p.length>0?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("h4",{className:"text-sm font-semibold",children:["Per-device matches (",h,")"]}),t.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto pr-1",children:p.map(v=>{const b=(v.cameras||[]).filter(y=>y.brand);return t.jsxs("div",{className:"border rounded p-2","data-testid":`row-device-${v.edgeDeviceId}`,children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"font-mono text-sm font-semibold",children:v.serialNumber||v.edgeDeviceId}),t.jsxs(Ke,{variant:"outline",className:"text-xs",children:[b.length," camera",b.length===1?"":"s"]})]}),t.jsx("ul",{className:"text-xs space-y-0.5",children:b.map(y=>t.jsxs("li",{className:"flex items-center gap-2","data-testid":`row-camera-${v.edgeDeviceId}-${y.name}`,children:[t.jsx("span",{className:"font-mono text-muted-foreground",children:y.name}),t.jsx("span",{children:"→"}),t.jsx("span",{className:"font-medium",children:y.brand}),y.model&&t.jsxs("span",{className:"text-muted-foreground",children:["/ ",y.model]}),!y.updated&&n.dryRun&&t.jsx(Ke,{variant:"secondary",className:"text-[10px] py-0 px-1",children:"preview"})]},y.name))})]},v.edgeDeviceId)})})]}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"No cameras matched the catalog this run."})]}),t.jsxs(In,{className:"gap-2 sm:gap-2",children:[t.jsx(L,{variant:"outline",onClick:()=>c(!1),disabled:d,"data-testid":"button-backfill-close",children:"Close"}),t.jsxs(L,{variant:"secondary",onClick:()=>l.mutate(!0),disabled:d,"data-testid":"button-backfill-preview",children:[d&&l.variables===!0&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Preview (Dry Run)"]}),t.jsxs(L,{onClick:()=>l.mutate(!1),disabled:d||!i,"data-testid":"button-backfill-apply",title:i?void 0:"Run a preview first to enable Apply Changes",children:[d&&l.variables===!1&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Apply Changes"]})]})]})})}function dSe(e,s){return e==="superadmin"&&s===!0}const v_=[{tier:"eco",label:"1080p / 2MP",description:""},{tier:"standard",label:"4MP",description:"Up to 4MP resolution. Standard recording profile."},{tier:"5mp",label:"5MP",description:"Up to 5MP resolution."},{tier:"6mp",label:"6MP",description:"Up to 6MP resolution."},{tier:"4k",label:"4K / 8MP",description:"Up to 4K / 8MP resolution."}],uSe="Note: If a camera’s resolution exceeds the purchased tier during setup, it will default to a secondary stream, which may use a lower resolution.";function mSe(e){const s=e==="2mp"?"eco":e;return v_.find(r=>r.tier===s)?.label??null}function Zee(e){const s=v_.map(({label:n,description:a})=>[n,a]),r=e.length===4?[e[0],e[2],s[2],s[3],e[3]]:e;return s.map((n,a)=>{const i=r[a];return[i?.[0]?.trim()||n[0],i?.[1]?.trim()||n[1]]})}function hSe(e){const s=e.split(`
292`).map(n=>
292n.trim()).filter(Boolean);if(s.length!==4)return e;const r=s.map(n=>n.split("|").map(a=>a.trim()));return Zee(r).map(n=>n.join(" | ")).join(`
293`)}const y_={key:"edgeQuote",title:"Edge Quote Builder",group:"General",fields:[{key:"gate.title",label:"Gate title",def:"{productName} — Project Quote"},{key:"gate.description",label:"Gate description",def:`The Edge Quoting Tool is available to Customers.
294              Sign in as a customer to build a project quote.`,multiline:!0},{key:"gate.noPermission",label:"Gate no-permission message",def:"Your current account doesn't have permission to use the quoting tool."},{key:"gate.signInButton",label:"Gate sign-in button",def:"Sign In"},{key:"gate.backHomeButton",label:"Gate back-home button",def:"Back to {domain}"},{key:"header.reviseTitle",label:"Header title (revising)",def:"Revise Quote"},{key:"header.newTitle",label:"Header title (new quote)",def:"Project Quote"},{key:"steps.labels",label:"Step labels",def:["Project","Storage","Review"].join(`
295`),multiline:!0,help:"One label per line, in order (Step 1, Step 2, Step 3)."},{key:"step1.title",label:"Step 1 title",def:"Project"},{key:"step1.descriptionLocked",label:"Step 1 description (locked)",def:"Your business and contact info are prefilled from your account."},{key:"step1.descriptionEditable",label:"Step 1 description (editable)",def:"Enter the customer's project and contact details."},{key:"step1.locationNameLabel",label:"Location name label",def:"Location Name"},{key:"step1.locationNamePlaceholder",label:"Location name placeholder",def:"e.g. Acme Warehouse — Phase 1"},{key:"step1.businessNameLabel",label:"Business name label",def:"Business Name"},{key:"step1.businessNamePlaceholderLocked",label:"Business name placeholder (locked)",def:"—"},{key:"step1.businessNamePlaceholder",label:"Business name placeholder",def:"Acme Corp"},{key:"step1.customerNameLabel",label:"Customer name label",def:"Customer Name"},{key:"step1.customerNamePlaceholderLocked",label:"Customer name placeholder (locked)",def:"—"},{key:"step1.customerNamePlaceholder",label:"Customer name placeholder",def:"Jane Doe"},{key:"step1.customerEmailLabel",label:"Customer email label",def:"Customer Email"},{key:"step1.customerEmailPlaceholderLocked",label:"Customer email placeholder (locked)",def:"—"},{key:"step1.customerEmailPlaceholder",label:"Customer email placeholder",def:"[email protected]"},{key:"step1.existingCustomerLabel",label:"Existing-customer label",def:"Existing Customer"},{key:"step1.existingCustomerPlaceholder",label:"Existing-customer placeholder",def:"Select a customer to apply their distributor markup"},{key:"step1.perCustomerMarkupApplied",label:"Per-customer markup applied note",def:"Per-customer markup applied"},{key:"step1.distributorMarkupApplied",label:"Distributor markup applied note",def:"Distributor markup applied"},{key:"step1.noMarkupConfigured",label:"No markup configured note",def:"This customer has no distributor markup configured. Assign one in Customers to apply it automatically."},{key:"step1.currencyLabel",label:"Currency label",def:"Currency"},{key:"step1.nextButton",label:"Step 1 next button",def:"Next"},{key:"step2.title",label:"Step 2 title",def:"Storage"},{key:"step2.description",label:"Step 2 description",def:"Pick how recordings will be stored."},{key:"step2.cameraCountLabel",label:"Camera count label",def:"Number of Cameras"},{key:"step2.retentionTypeLabel",label:"Retention type label",def:"Retention Type"},{key:"step2.storageOptions",label:"Storage option cards",def:["Cloud only | Records to Google Cloud.","Local only | Records to Local Edge.","Hybrid | True Redundancy."].join(`
296`),multiline:!0,help:'One card per line: "Title | Description". Order: Cloud, Local, Hybrid. Icons are fixed per position.'},{key:"step2.remoteMonitoringTitle",label:"Remote monitoring title",def:"Remote monitoring of devices?"},{key:"step2.remoteMonitoringDescription",label:"Remote monitoring description",def:"Optional Plus Plan ({rate}/cam/mo) for device health monitoring of cameras and smart notifications.",help:"{rate} is the computed per-camera Plus Plan price."},{key:"step2.smartAlertsTitle",label:"Smart Alerts title",def:"Smart Alerts — AI Event Detection?"},{key:"step2.smartAlertsDescription",label:"Smart Alerts description",def:"AI-powered event detection subscription ({rate}/cam/mo). Enables rule-based alert rules with AI action classification.",help:"{rate} is the computed per-camera Smart Alerts price."},{key:"step2.smartAlertsCamerasLabel",label:"Smart Alerts cameras label",def:"Cameras covered"},{key:"step2.smartAlertsOfPrefix",label:"Smart Alerts 'of N' prefix",def:"of",help:"Rendered as 'of {cameraCount}'."},{key:"step2.resolutionTierLabel",label:"Resolution tier label",def:"Resolution Tier"},{key:"step2.resolutionOptions",label:"Resolution option cards",def:v_.map(({label:e,description:s})=>`${e} | ${s}`).join(`
297`),multiline:!0,help:'One card per line: "Title | Description". Order: 1080p / 2MP (Eco), 4MP (Standard), 5MP, 6MP, 4K / 8MP (4K).',editorValue:hSe},{key:"step2.resolutionFallbackNotice",label:"Resolution fallback notice",def:uSe}
297,{key:"step2.uploadBandwidthTitle",label:"Upload bandwidth recommendation title",def:"Recommended Client-Site Upload Bandwidth"},{key:"step2.uploadBandwidthDescription",label:"Upload bandwidth recommendation description",def:"{rate} Mbps per camera × {cameraCount} cameras.",help:"{total}, {rate}, and {cameraCount} are computed from the quote."},{key:"step2.uploadBandwidthUnit",label:"Upload bandwidth unit",def:"Mbps Upload"},{key:"step2.recordingModeLabel",label:"Recording mode label",def:"Recording Mode"},{key:"step2.recordingModeMotion",label:"Recording mode: motion",def:"Motion-triggered"},{key:"step2.recordingMode247",label:"Recording mode: 24/7",def:"24/7 continuous"},{key:"step2.recordingModeLocalNote",label:"Recording mode local note",def:"24/7 increases local TB requirement vs Motion."},{key:"step2.cloudRetentionLabel",label:"Cloud retention label",def:"Cloud Retention"},{key:"step2.localRetentionLabel",label:"Local retention label",def:"Local Retention (days)"},{key:"step2.localRetentionHybridNote",label:"Local retention note (hybrid)",def:"Hybrid local cache (default 30 days)."},{key:"step2.localRetentionNote",label:"Local retention note",def:"How long to keep recordings on the local appliance."},{key:"step2.backButton",label:"Step 2 back button",def:"Back"},{key:"step2.nextButton",label:"Step 2 next button",def:"Next"},{key:"step3.discountsTitle",label:"Discounts card title",def:"Discounts & Promotions"},{key:"step3.discountsDescription",label:"Discounts card description",def:"Optional adjustments to apply to this quote."},{key:"step3.promoCodeLabel",label:"Promo code label",def:"Promo Code"},{key:"step3.promoCodePlaceholder",label:"Promo code placeholder",def:"SUMMER25"},{key:"step3.promoApplyButton",label:"Promo apply button",def:"Apply"},{key:"step3.distributorMarkupLabel",label:"Distributor markup label",def:"Distributor Markup"},{key:"step3.perCustomerMarkupAuto",label:"Per-customer markup (auto)",def:"Per-customer markup applied automatically"},{key:"step3.distributorMarkupAuto",label:"Distributor markup (auto)",def:"Distributor markup applied automatically"},{key:"step3.msrpLabel",label:"MSRP label",def:"MSRP Pricing"},{key:"step3.msrpDescription",label:"MSRP description",def:"Apply an additional retail markup on top of any distributor markup."},{key:"step3.msrpHardwareLabel",label:"MSRP hardware markup label",def:"Hardware markup %"},{key:"step3.msrpSubscriptionLabel",label:"MSRP subscription markup label",def:"Subscription markup %"},{key:"step3.discountPercentLabel",label:"Discount % label",def:"Discount %"},{key:"step3.discountScopeLabel",label:"Discount scope label",def:"Scope"},{key:"step3.scopeHardware",label:"Scope: hardware",def:"Hardware"},{key:"step3.scopeSubscription",label:"Scope: subscription",def:"Subscription"},{key:"step3.scopeBoth",label:"Scope: both",def:"Both"},{key:"shipOverride.title",label:"Shipping override title",def:"Shipping Override"},{key:"shipOverride.amountLabel",label:"Shipping override amount label",def:"Shipping Amount",help:"Currency is appended, e.g. 'Shipping Amount (USD)'."},{key:"shipOverride.amountPlaceholder",label:"Shipping override amount placeholder",def:"Leave blank to use UPS / free-shipping rule"},{key:"shipOverride.reasonLabel",label:"Shipping override reason label",def:"Reason (optional)"},{key:"shipOverride.reasonPlaceholder",label:"Shipping override reason placeholder",def:"e.g. Negotiated freight rate"},{key:"shipping.title",label:"Shipping card title",def:"Shipping"},{key:"shipping.description",label:"Shipping card description",def:"Verify the line items, then save the quote as a Sales Order."},{key:"shipping.addressTitle",label:"Shipping address title",def:"Shipping Address"},{key:"shipping.addressDescriptionEditable",label:"Shipping address description (editable)",def:"Where the hardware will be delivered. Used to fetch a live UPS rate."},{key:"shipping.addressDescriptionLocked",label:"Shipping address description (locked)",def:"Hardware ships to your business address on file. Contact support to update."},{key:"shipping.loadFromCustomerLabel",label:"Load-from-customer label",def:"Load From Existing Customer"},{key:"shipping.loadFromCustomerPlaceholder",label:"Load-from-customer placeholder",def:"Select a customer to autofill business + address…"},{key:"shipping.businessNameLabel",label:"Ship business name label",def:"Business N
297ame"},{key:"shipping.businessNamePlaceholder",label:"Ship business name placeholder",def:"Acme Security LLC"},{key:"shipping.attnNameLabel",label:"Ship attention label",def:"Attention (Recipient)"},{key:"shipping.attnNamePlaceholder",label:"Ship attention placeholder",def:"Jane Doe"},{key:"shipping.address1Label",label:"Street address label",def:"Street Address"},{key:"shipping.address1Placeholder",label:"Street address placeholder",def:"123 Main St"},{key:"shipping.address2Label",label:"Suite/apt label",def:"Suite / Apt (optional)"},{key:"shipping.address2Placeholder",label:"Suite/apt placeholder",def:"Suite 400"},{key:"shipping.cityLabel",label:"City label",def:"City"},{key:"shipping.cityPlaceholder",label:"City placeholder",def:"Atlanta"},{key:"shipping.stateOptionalSuffix",label:"State optional suffix",def:" (optional)",help:"Appended after the country-specific state label when not required."},{key:"shipping.statePlaceholderUs",label:"US state placeholder",def:"Select a state"},{key:"shipping.countryLabel",label:"Country label",def:"Country"},{key:"shipping.serviceLabel",label:"UPS service label",def:"UPS Service"},{key:"shipping.requiredError",label:"Shipping required error",def:"Shipping country and postal code are required for hardware orders."},{key:"billing.frequencyLabel",label:"Billing frequency label",def:"Billing Frequency"},{key:"billing.frequencyOptions",label:"Billing frequency options",def:["Monthly | ","Quarterly | Billed every 3 months","Annually | Save 10%"].join(`
298`),multiline:!0,help:'One option per line: "Label | Note" (Note may be blank). Order: Monthly, Quarterly, Annually.'},{key:"finalPricing.title",label:"Final pricing title",def:"Billing & Final Pricing"},{key:"finalPricing.description",label:"Final pricing description",def:"Itemized hardware, subscriptions, and shipping totals."},{key:"finalPricing.viewPdfButton",label:"View PDF button",def:"View PDF"},{key:"finalPricing.emailQuoteButton",label:"Email quote button",def:"Email Quote"},{key:"finalPricing.updateButton",label:"Save/update button (revising)",def:"Update Quote"},{key:"finalPricing.saveButton",label:"Save/update button (new)",def:"Save Quote"},{key:"finalPricing.backButton",label:"Final pricing back button",def:"Back"},{key:"liveQuote.title",label:"Live Quote title",def:"Live Quote"},{key:"liveQuote.description",label:"Live Quote description",def:"Updates as you change inputs."},{key:"email.title",label:"Email dialog title",def:"Email Quote"},{key:"email.description",label:"Email dialog description",def:"The quote has been saved. Confirm the recipient and add an optional note."},{key:"email.recipientLabel",label:"Email recipient label",def:"Recipient email"},{key:"email.recipientPlaceholder",label:"Email recipient placeholder",def:"[email protected]"},{key:"email.messageLabel",label:"Email message label",def:"Message (optional)"},{key:"email.messagePlaceholder",label:"Email message placeholder",def:"Add a short note for the customer…"},{key:"email.cancelButton",label:"Email cancel button",def:"Cancel"},{key:"email.sendButton",label:"Email send button",def:"Send Email"},{key:"review.emptyPrompt",label:"Review empty prompt",def:"Enter a camera count to see pricing."},{key:"review.noLineItems",label:"Review no line items",def:"No line items yet."},{key:"review.enterpriseTierTitle",label:"Enterprise tier title",def:"Enterprise-tier storage required",help:"The '(N.N TB)' size is appended dynamically."},{key:"review.enterpriseTierBody",label:"Enterprise tier body (before email)",def:"This configuration exceeds 196 TB of local storage. Please contact ",help:"Followed by the sales-email link and a trailing sentence."},{key:"review.enterpriseTierBodyAfter",label:"Enterprise tier body (after email)",def:" for custom Enterprise-level hardware sizing and pricing."},{key:"review.sectionHardware",label:"Section: hardware",def:"One-Time Hardware"},{key:"review.noHardwareLineItems",label:"No hardware line items",def:"No hardware line items."},{key:"review.subtotal",label:"Subtotal label",def:"Subtotal"},{key:"review.sectionSubscriptions",label:"Section: subscriptions",def:"Subscriptions"},{key:"review.noSubscriptionLineItems",label:"No subscription line items",def:"No subscription line items."},{key:"review.sectionShipping",label:"Section: shipping",def:"Shipping"},{key:"review.shippingFreeBadge",label:"Shipping free badge",def:"Free"},{key:"review.shippingLoading",label:"Shipping loading text",def:"Fetching UPS rate…"},{key:"review.shippingUpsUnconfigured",label:"Shipping UPS unconfigured error",def:"UPS rates unavailable — shipping shown as estimate pending."},{key:"review.sectionAdjustments",label:"Section: adjustments",def:"Adjustments"},{key:"review.oneTimeTotal",label:"One-time total label",def:"One-time total"},{key:"review.recurringPrefix",label:"Recurring total prefix",def:"Recurring",help:"Followed by 'monthly'/'quarterly'/'annually'."},{key:"review.recurringMonthly",label:"Recurring: monthly",def:"monthly"},{key:"review.recurringQuarterly",label:"Recurring: quarterly",def:"quarterly"},{key:"review.recurringAnnually",label:"Recurring: annually",def:"annually"},{key:"review.grandTotalLabel",label:"Grand total label",def:"Grand Total Today"},{key:"review.annualDiscountNote",label:"Annual billing discount note",def:" Includes 10% annual billing discount."}]},Jee=[{value:14,label:"14 days"},{value:30,label:"30 days"},{value:90,label:"90 days"},{value:180,label:"180 days"},{value:365,label:"1 year"},{value:730,label:"2 years"},{value:1095,label:"3 years"},{value:1460,label:"4 years"},{value:1825,label:"5 years"}],ete={hardware:{8:699,16:899,32:1099,64:1799,128:2599},rackmountUplift:499,rackmount2UUplift:499,rackmount4UUplift:699,cloud:{motion:{14:1.99,30:2.49,90:3.49,180:4.25,365:4.49,730:5.49,1095:6.49,1460:
2987.49,1825:8.49},247:{14:5.99,30:7.49,90:8.49,180:9.25,365:9.49,730:10.49,1095:11.49,1460:12.49,1825:13.49}},fourKUplift:4.99,standardUplift:2.49,fiveMPUplift:3.49,sixMPUplift:4.24,plusPlanRate:.99,smartAlertsRate:49.99,localStoragePerTb:65,ecoCloudDiscount:.99,ecoLocalMultiplier:.67,freeShippingThresholdUsd:1500},AF=Gd({14:_r().nonnegative(),30:_r().nonnegative(),90:_r().nonnegative(),180:_r().nonnegative(),365:_r().nonnegative(),730:_r().nonnegative(),1095:_r().nonnegative(),1460:_r().nonnegative(),1825:_r().nonnegative()}),pSe=Gd({hardware:Gd({8:_r().nonnegative(),16:_r().nonnegative(),32:_r().nonnegative(),64:_r().nonnegative(),128:_r().nonnegative()}),rackmountUplift:_r().nonnegative(),rackmount2UUplift:_r().nonnegative().default(499),rackmount4UUplift:_r().nonnegative().default(699),cloud:Gd({motion:AF,247:AF}),fourKUplift:_r().nonnegative(),standardUplift:_r().nonnegative().default(2.49),fiveMPUplift:_r().nonnegative().default(3.49),sixMPUplift:_r().nonnegative().default(4.24),plusPlanRate:_r().nonnegative(),smartAlertsRate:_r().nonnegative().default(9.99),localStoragePerTb:_r().nonnegative(),ecoCloudDiscount:_r().nonnegative().default(.75),ecoLocalMultiplier:_r().positive().max(1).default(.67),freeShippingThresholdUsd:_r().nonnegative().default(1500)}),MP=[8,16,32,64,128],fSe=32,gSe=64,xSe=96;function vSe(e,s){return s?e>gSe?"4u":"2u":"nuc"}function ySe(e){return e==="4u"?"4U Rackmount":e==="2u"?"2U Rackmount":"Intel NUC"}function bSe(e,s){return e==="4u"?s.rackmount4UUplift??s.rackmountUplift??0:e==="2u"?s.rackmount2UUplift??s.rackmountUplift??0:0}const wSe=["USD","EUR","GBP","CAD","AUD","MXN"],jSe={USD:"$",EUR:"€",GBP:"£",CAD:"C$",AUD:"A$",MXN:"Mex$"},NSe={USD:1,EUR:.92,GBP:.79,CAD:1.36,AUD:1.5,MXN:17},tte=[{value:"03",label:"UPS Ground"},{value:"12",label:"UPS 3-Day Select"},{value:"02",label:"UPS 2nd Day Air"},{value:"01",label:"UPS Next Day Air"}],SSe=Object.fromEntries(tte.map(e=>[e.value,e.label])),MF=1e3,CSe={US:{label:"ZIP Code",placeholder:"30301"},CA:{label:"Postal Code",placeholder:"K1A 0B1"},MX:{label:"Código Postal",placeholder:"01000"},GB:{label:"Postcode",placeholder:"SW1A 1AA"},IE:{label:"Eircode",placeholder:"D02 AF30"},DE:{label:"PLZ",placeholder:"10115"},FR:{label:"Code Postal",placeholder:"75001"},ES:{label:"Código Postal",placeholder:"28001"},IT:{label:"CAP",placeholder:"00100"},NL:{label:"Postcode",placeholder:"1011 AA"},BE:{label:"Postcode",placeholder:"1000"},AU:{label:"Postcode",placeholder:"2000"},NZ:{label:"Postcode",placeholder:"6011"}};function kSe(e){return CSe[(e||"").toUpperCase()]??{label:"Postal Code",placeholder:""}}const _Se={US:{label:"State",placeholder:"GA",required:!0,uppercase:!0},CA:{label:"Province",placeholder:"ON",required:!0,uppercase:!0},MX:{label:"Estado",placeholder:"CDMX",required:!0,uppercase:!0},AU:{label:"State",placeholder:"NSW",required:!0,uppercase:!0},GB:{label:"County",placeholder:"Greater London",required:!1,uppercase:!1},IE:{label:"County",placeholder:"Dublin",required:!1,uppercase:!1},DE:{label:"Bundesland",placeholder:"Berlin",required:!1,uppercase:!1},FR:{label:"Region",placeholder:"Île-de-France",required:!1,uppercase:!1},ES:{label:"Provincia",placeholder:"Madrid",required:!1,uppercase:!1},IT:{label:"Provincia",placeholder:"Roma",required:!1,uppercase:!1},NL:{label:"Province",placeholder:"Noord-Holland",required:!1,uppercase:!1},BE:{label:"Province",placeholder:"Brussels",required:!1,uppercase:!1},NZ:{label:"Region",placeholder:"Auckland",required:!1,uppercase:!1}};function PSe(e){return _Se[(e||"").toUpperCase()]??{label:"State / Region",placeholder:"",required:!1,uppercase:!1}}const RF=[{code:"US",label:"United States"},{code:"CA",label:"Canada"},{code:"MX",label:"Mexico"},{code:"GB",label:"United Kingdom"},{code:"IE",label:"Ireland"},{code:"DE",label:"Germany"},{code:"FR",label:"France"},{code:"ES",label:"Spain"},{code:"IT",label:"Italy"},{code:"NL",label:"Netherlands"},{code:"BE",label:"Belgium"},{code:"AU",label:"Australia"},{code:"NZ",label:"New Zealand"}],IF=10;Gd({projectName:it().min(1).max(200),customerName:it().max(200).optional().nullable(),customerEmail:it().email().optional().nullable().or(Hu("")),businessName:it().max(200).optional().nullable(),cameraCount:_r().int().min(1),storageType:Wc(["local","cloud","hybrid"]),resolutionTier:Wc(["eco","2mp","standard","5mp","6mp","4k"]).optional(),recordingMode:Wc(["motion","247"]).optional(),cloudRetention:qk([Hu(14),Hu(30),Hu(90),Hu(180),Hu(365),Hu(730),Hu(1095),Hu(1460),Hu(1825)]).optional(),localRetentionDays:_r().int().min(1).max(3650).optional(),remoteMonitoring:nf().optional(),smartAlerts:nf().optional(),smartAlertsCameraCount:_r().int().min(1).optional(),discountPercent:_r().min(0).max(100).optional(),discountScope:Wc(["hardware","subscription","both","none"]).optional(),promoCode:it().max(64).optional().nullable(),promoDiscountPercent:_r().min(0).max(100).optional().nullable(),promoScope:Wc(["hardware","subscription","both"]).optional(),billingFrequency:Wc(["monthly","quarterly","annually"]).optional(),distributorHardwareMarkupPercent:_r().min(0).max(500).optional(),distributorSubscriptionMarkupPercent:_r().min(0).max(500).optional(),msrpEnabled:nf().optional(),msrpHardwareMarkupPercent:_r().min(0).max(500).optional(),msrpSubscriptionMarkupPercent:_r().min(0).max(500).optional(),quoteForResellerId:it().optional().nullable(),currency:Wc(["USD","EUR","GBP","CAD","AUD","MXN"]).optional(),shipCountry:it().length(2).optional().nullable(),shipPostalCode:it().max(24).optional().nullable(),shipService:Wc(["03","12","02","01"]).optional(),shipBusinessName:it().max(200).optional().nullable(),shipAttnName:it().max(200).optional().nullable(),shipAddress1:it().max(200).optional().nullable(),shipAddress2:it().max(200).optional().nullable(),shipCity:it().max(120).optional().nullable(),shipState:it().max(32).optional().nullable(),shippingAmount:_r().min(0).optional().nullable(),shippingAmountOverride:_r().min(0).optional().nullable(),shippingOverrideReason:it().max(500).optional().nullable()}).superRefine((e,s)=>{e.smartAlerts&&e.smartAlertsCameraCount!==void 0&&e.smartAlertsCameraCount>e.cameraCount&&s.addIssue({code:rs.custom,path:["smartAlertsCameraCount"],message:"Smart Alerts camera count cannot exceed total camera count"}),(e.storageType==="local"||e.storageType==="hybrid")&&(e.shipCountry||s.addIssue({code:rs.custom,path:["shipCountry"],message:"Ship-to country required for hardware orders"}),e.shipPostalCode||s.addIssue({code:rs.custom,path:["shipPostalCode"],message:"Ship-to postal code required for hardware orders"}))});function ESe(e,s,r,n,a=0){if(e<=0)return[];const i=MP[MP.length-1],o=MP.find(p=>p>=e)??i,l=Math.ceil(e/o),c=n?xSe:fSe,d=a>0?Math.ceil(a/Math.max(c,1)):0,h=Math.max(1,l,d);return[{size:o,count:h}]}function TSe(e,s,r,n){const a=e.cloud[s]?.[String(r)];if(typeof a!="number")throw new Error(`No cloud rate for mode=${s} retention=${r}`);return n==="4k"?a+e.fourKUplift:n==="6mp"?a+(e.sixMPUplift??4.24):n==="5mp"?a+(e.fiveMPUplift??3.49):n==="standard"?a+(e.standardUplift??0):a}const OF={eco:{247:.5,motion:.1},"2mp":{247:.5,motion:.1},standard:{247:.75,motion:.2},"5mp":{247:.875,motion:.35},"6mp":{247:.9375,motion:.425},"4k":{247:1,motion:.5}};function ASe(e){return e==="2mp"?"eco":e}const kM={eco:.5,"2mp":.5,standard:1.5,"5mp":2,"6mp":2.5,"4k":3.5};
298function MSe(e,s,r="standard"){if(s==="local")return null;const n=Math.max(0,Number.isFinite(e)?e:0),a=kM[r]??kM.standard;return n*a}function DF(e,s,r,n="247",a){const i=ASe(r),o=OF[i]?.[n]??OF.standard[n];return e*o*s/30}function LF(e,s,r){const n=(r?.productName??"").trim()||"Truvios Edge",a=[],i=e.storageType==="local"||e.storageType==="hybrid",o=i;let l=0,c=0;if(i){const M=e.resolutionTier??"standard",R=e.localRetentionDays??30,D=e.recordingMode??"motion",$=DF(e.cameraCount,R,M,D);c=$>=10?Math.floor($/10)*10:Math.ceil($*10)/10,l=c}const d=ESe(e.cameraCount,s.hardware,s.rackmountUplift,o,l);for(const M of d){if(M.count<=0)continue;const R=s.hardware[String(M.size)],D=M.count>0?l/M.count:0,$=vSe(D,o),O=bSe($,s),q=R+O;a.push({kind:"hardware",label:`${n} ${M.size}ch ${ySe($)}`,qty:M.count,unit:"unit",unitPrice:q,subtotal:q*M.count,recurring:!1})}if(e.storageType==="cloud"||e.storageType==="hybrid"){const M=e.resolutionTier??"standard",R=e.recordingMode??"motion",D=e.cloudRetention??30,$=TSe(s,R,D,M),O=Jee.find(V=>V.value===D)?.label??`${D}d`,q=R==="247"?"24/7":"Motion";a.push({kind:"cloud",label:`Cloud Storage — ${O} (${q})`,qty:e.cameraCount,unit:"cam/mo",unitPrice:$,subtotal:$*e.cameraCount,recurring:!0})}if(e.storageType==="local"&&e.remoteMonitoring&&a.push({kind:"plus",label:"Plus Plan — Remote Monitoring",qty:e.cameraCount,unit:"cam/mo",unitPrice:s.plusPlanRate,subtotal:s.plusPlanRate*e.cameraCount,recurring:!0}),e.smartAlerts){const M=s.smartAlertsRate??9.99,R=Math.min(e.cameraCount,Math.max(1,e.smartAlertsCameraCount??e.cameraCount));a.push({kind:"smart_alerts",label:"Smart Alerts — AI Event Detection",qty:R,unit:"cam/mo",unitPrice:M,subtotal:M*R,recurring:!0})}if(i){const M=e.resolutionTier??"standard",R=mSe(M);if(!R)throw new Error(`No Edge quote resolution label for tier=${M}`);const D=e.localRetentionDays??30,$=e.recordingMode??"motion",O=DF(e.cameraCount,D,M,$),q=O>=10?Math.floor(O/10)*10:Math.ceil(O*10)/10,V=q*s.localStoragePerTb,K=`, ${$==="247"?"24/7":"Motion"}`;a.push({kind:"local_storage",label:`Local Storage — ${q} TB (${e.cameraCount} cams × ${D}d, ${R}${K})`,qty:q,unit:"TB",unitPrice:s.localStoragePerTb,subtotal:V,recurring:!1})}{const M=Math.max(0,Math.min(500,e.distributorHardwareMarkupPercent??0)),R=Math.max(0,Math.min(500,e.distributorSubscriptionMarkupPercent??0));if(M>0||R>0){const D=1+M/100,$=1+R/100;for(const O of a)O.kind==="hardware"||O.kind==="local_storage"?(O.unitPrice=O.unitPrice*D,O.subtotal=O.subtotal*D):(O.kind==="cloud"||O.kind==="plus"||O.kind==="smart_alerts")&&(O.unitPrice=O.unitPrice*$,O.subtotal=O.subtotal*$)}}if(e.msrpEnabled){const M=Math.max(0,Math.min(500,e.msrpHardwareMarkupPercent??50)),R=Math.max(0,Math.min(500,e.msrpSubscriptionMarkupPercent??100)),D=1+M/100,$=1+R/100;for(const O of a)O.kind==="hardware"||O.kind==="local_storage"?(O.unitPrice=O.unitPrice*D,O.subtotal=O.subtotal*D):(O.kind==="cloud"||O.kind==="plus"||O.kind==="smart_alerts")&&(O.unitPrice=O.unitPrice*$,O.subtotal=O.subtotal*$)}const g=a.filter(M=>!M.recurring).reduce((M,R)=>M+R.subtotal,0),v=a.filter(M=>M.recurring).reduce((M,R)=>M+R.subtotal,0),b=Math.max(0,Math.min(100,e.discountPercent??0)),y=e.discountScope??"none",w=Math.max(0,Math.min(100,e.promoDiscountPercent??0)),j=e.promoScope??(e.promoCode?"both":void 0),x=M=>M==="hardware"||M==="both",C=M=>M==="subscription"||M==="both",k=[];function S(M,R,D,$){if(M<=0)return;let O=M;const q=R?C:x;if(b>0&&y!=="none"&&q(y)){const V=O*b/100,K=Math.min(V,O);K>0&&(k.push({kind:"discount",label:R?$:D,recurring:R,amount:-K}),O-=K)}if(w>0&&e.promoCode&&j&&q(j)){const V=O*w/100,K=Math.min(V,O);K>0&&(k.push({kind:"promo",label:R?`Promo (${e.promoCode}) — Subscription (${w}%)`:`Promo (${e.promoCode}) — Hardware (${w}%)`,recurring:R,amount:-K}),O-=K)}}S(g,!1,`Discount — Hardware (${b}%)`,`Discount — Subscription (${b}%)`),S(v,!0,`Discount — Hardware (${b}%)`,`Discount — Subscription (${b}%)`);for(const M of k)a.push({kind:M.kind,label:M.label,qty:1,unit:"adj",unitPrice:M.amount,subtotal:M.amount,recurring:M.recurring});if((e.billingFrequency??"monthly")==="annually"){const M=a.filter(R=>R.recurring).reduce((R,D)=>R+D.subtotal,0);if(M>0){const R=M*IF/100,D=Math.min(R,M);a.push({kind:"discount",label:`Annual Billing Discount (${IF}%)`,qty:1,unit:"adj",unitPrice:-D,subtotal:-D,recurring:!0})}}const _=a.filter(M=>!M.recurring&&M.kind!=="shipping").reduce((M,R)=>M+R.subtotal,0);{const M=(e.shipCountry||"US").toUpperCase(),R=e.shipService||"03",D=SSe[R]??"Shipping";let $=0,O="Shipping";const q=e.shippingAmountOverride;!e.shipCountry&&!e.shipPostalCode&&(e.shippingAmount===void 0||e.shippingAmount===null)&&(e.shippingAmountOverride===void 0||e.shippingAmountOverride===null)?($=0,O="Shipping — Free domestic"):typeof q=="number"&&q>=0?($=q,O=`Shipping — Manual override (${D})`):M==="US"&&R==="03"&&_>=(s.freeShippingThresholdUsd??MF)?($=0,O=`Shipping — Free over $${(s.freeShippingThresholdUsd??MF).toLocaleStr
298ing()} (${D})`):typeof e.shippingAmount=="number"&&e.shippingAmount>=0?($=e.shippingAmount,O=M==="US"?`Shipping — ${D}`:`Shipping — ${D} (${M})`):($=0,O=`Shipping — Estimate pending (${D})`),a.push({kind:"shipping",label:O,qty:1,unit:"ship",unitPrice:$,subtotal:$,recurring:!1})}const A=Math.max(0,a.filter(M=>!M.recurring).reduce((M,R)=>M+R.subtotal,0)),T=Math.max(0,a.filter(M=>M.recurring).reduce((M,R)=>M+R.subtotal,0));return{lineItems:a,oneTimeTotal:Math.round(A*100)/100,monthlyTotal:Math.round(T*100)/100,hardwareUnits:d.filter(M=>M.count>0)}}function kx(e,s="USD",r=1){const n=jSe[s]??"$",a=e*(r||1),i=a<0?"-":"",o=Math.abs(a);return`${i}${n}${o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}const _M=[{value:"new",label:"New",variant:"outline"},{value:"pending",label:"Pending",variant:"secondary"},{value:"active",label:"Active (Sold)",variant:"default"},{value:"lost",label:"Lost",variant:"secondary"},{value:"canceled",label:"Canceled",variant:"destructive"}];function ste(e){return e?new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"—"}function RSe(e){const s=_M.find(r=>r.value===e);return t.jsx(Ke,{variant:s?.variant||"outline","data-testid":`badge-status-${e}`,children:s?.label||e})}function ISe({isSuperAdmin:e,userId:s,onOpenDevice:r}){return t.jsxs("div",{className:"p-4 sm:p-6 space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(HK,{className:"w-5 h-5 text-primary"}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold","data-testid":"text-sales-orders-title",children:"Sales Orders"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:e?"All sales orders across customers.":"Your saved quotes and sales orders."})]})]}),t.jsxs(_h,{defaultValue:"all-orders",className:"w-full",children:[t.jsxs(Dm,{children:[t.jsx(_n,{value:"all-orders","data-testid":"tab-sales-all-orders",children:"Orders & Quotes"}),e&&t.jsx(_n,{value:"promo-codes","data-testid":"tab-sales-promo-codes",children:"Promo Codes"})]}),t.jsx(ea,{value:"all-orders",className:"space-y-3",children:t.jsx(DSe,{isSuperAdmin:e,onOpenDevice:r})}),e&&t.jsx(ea,{value:"promo-codes",className:"space-y-3",children:t.jsx(LSe,{userId:s})})]})]})}function OSe({order:e,onClose:s,onOpenDevice:r}){return t.jsx(Ys,{open:!!e,onOpenChange:n=>{n||s()},children:t.jsxs(Ws,{className:"max-w-2xl",children:[t.jsxs(Zs,{children:[t.jsxs(Ks,{"data-testid":"text-view-order-title",children:[e?.orderNumber||"Order"," — ",e?.projectName]}),t.jsxs(cr,{children:[e?.businessName?`${e.businessName} · `:"",e?.customerName?`${e.customerName} · `:"",e?.cameraCount," cameras · ",e?.storageType]})]}),e&&t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"divide-y divide-border text-sm",children:(Array.isArray(e.lineItems)?e.lineItems:[]).map((n,a)=>t.jsxs("div",{className:"py-2 flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-medium truncate",children:n.label}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[n.qty," × ",kx(n.unitPrice)," / ",n.unit]})]}),t.jsx("div",{className:"text-right text-sm whitespace-nowrap",children:t.jsxs("div",{className:"font-medium",children:[kx(n.subtotal),n.recurring?" / mo":""]})})]},a))}),t.jsxs("div",{className:"border-t pt-3 space-y-1 text-sm",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-muted-foreground",children:"One-time hardware"}),t.jsx("span",{className:"font-semibold",children:kx(e.oneTimeTotal)})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-muted-foreground",children:"Recurring monthly"}),t.jsxs("span",{className:"font-semibold",children:[kx(e.monthlyTotal)," / mo"]})]}),e.discountPercent>0&&t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[t.jsxs("span",{children:["Customer discount (",e.discountScope,")"]}),t.jsxs("span",{children:["-",e.discountPercent,"%"]})]}),e.promoCode&&t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[t.jsxs("span",{children:["Promo code: ",e.promoCode]}),t.jsxs("span",{children:["-",e.promoDiscountPercent??0,"%"]})]}),t.jsxs("div",{className:"text-xs text-muted-foreground pt-2",children:[t.jsx("span",{className:"font-medium",children:"Attached devices:"})," ",e.linkedDevices&&e.linkedDevices.length>0?e.linkedDevices.map(n=>
298n.serialNumber).join(", "):t.jsx("span",{className:"italic",children:"none yet"})]})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",asChild:!0,"data-testid":"button-view-pdf",children:t.jsxs("a",{href:e?`/api/sales-orders/${e.id}/pdf`:"#",target:"_blank",rel:"noopener noreferrer",children:[t.jsx(XI,{className:"w-4 h-4 mr-1"})," Download PDF"]})}),t.jsx(L,{onClick:s,"data-testid":"button-view-close",children:"Close"})]})]})})}function DSe({isSuperAdmin:e,onOpenDevice:s}){const{toast:r}=Hs(),[,n]=Ia(),[a,i]=u.useState("all"),[o,l]=u.useState(""),[c,d]=u.useState({open:!1,order:null,newStatus:"new"}),[h,p]=u.useState({open:!1,order:null}),[g,v]=u.useState(""),[b,y]=u.useState(""),[w,j]=u.useState(null),{data:x=[],isLoading:C}=ze({queryKey:["/api/sales-orders"]}),k=u.useMemo(()=>{const T=o.trim().toLowerCase();return x.filter(M=>a!=="all"&&M.status!==a?!1:T?[M.orderNumber,M.projectName,M.businessName,M.customerName,M.customerEmail,M.owner?.name,M.owner?.email].filter(Boolean).some(R=>String(R).toLowerCase().includes(T)):!0)},[x,a,o]),S=Et({mutationFn:async({id:T,status:M})=>(await Ze("PATCH",`/api/sales-orders/${T}`,{status:M})).json(),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/sales-orders"]}),d({open:!1,order:null,newStatus:"new"}),r({title:"Status updated"})},onError:T=>r({title:"Failed to update status",description:T.message,variant:"destructive"})}),_=Et({mutationFn:async T=>{await Ze("DELETE",`/api/sales-orders/${T}`)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/sales-orders"]}),r({title:"Order deleted"})},onError:T=>r({title:"Cannot delete",description:T.message,variant:"destructive"})}),A=Et({mutationFn:async({id:T,to:M,message:R})=>(await Ze("POST",`/api/sales-orders/${T}/email`,{to:M,message:R})).json(),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/sales-orders"]}),p({open:!1,order:null}),y(""),r({title:"Quote emailed"})},onError:T=>r({title:"Failed to email",description:T.message,variant:"destructive"})});return t.jsxs("div",{className:"space-y-3",children:[t.jsxs(ut,{children:[t.jsxs(xs,{className:"pb-3 flex flex-col gap-2 space-y-0 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{children:[t.jsx(ys,{className:"text-base",children:"All Orders"}),t.jsx(Xs,{children:e?"Across all customers":"Your orders"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1 sm:flex-none",children:[t.jsx(yc,{className:"w-4 h-4 text-muted-foreground absolute left-2.5 top-1/2 -translate-y-1/2 pointer-events-none"}),t.jsx(ke,{type:"text",value:o,onChange:T=>l(T.target.value),placeholder:"Search orders...",className:"w-full sm:w-[200px] pl-8","data-testid":"input-search-orders"})]}),t.jsx(qj,{className:"w-4 h-4 text-muted-foreground"}),t.jsxs(Us,{value:a,onValueChange:i,children:[t.jsx($s,{className:"w-[160px]","data-testid":"select-status-filter",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All statuses"}),_M.map(T=>t.jsx(rt,{value:T.value,children:T.label},T.value))]})]})]})]}),t.jsx(mt,{children:C?t.jsxs("div",{className:"space-y-2",children:[t.jsx(Bt,{className:"h-12 w-full"}),t.jsx(Bt,{className:"h-12 w-full"})]}):k.length===0?t.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center","data-testid":"text-no-orders",children:"No orders to show."}):t.jsx("div",{className:"divide-y divide-border",children:k.map(T=>{const M=T.status==="new"||T.status==="lost",R=T.status==="new"||T.status==="pending";return t.jsxs("div",{className:"py-3 flex flex-wrap items-center gap-3","data-testid":`row-order-${T.id}`,children:[t.jsxs("div",{className:"flex-1 min-w-[200px]",children:[t.jsxs("div",{className:"font-medium text-sm flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>j(T),className:"text-primary hover:underline focus:underline focus:outline-none","data-testid":`link-order-number-${T.id}`,children:T.orderNumber||"—"}),RSe(T.status)]}),t.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:[t.jsx("span",{"data-testid":`text-order-project-${T.id}`,children:T.projectName}),T.businessName?` · ${T.businessName}`:"",` · ${T.cameraCount} cams · ${T.storageType}`,T.createdAt?` · ${ste(T.createdAt)}`:""]}),e&&T.owner&&t.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5","data-testid":`text-order-owner-${T.
298id}`,children:["Owner: ",T.owner.name," ",t.jsxs("span",{className:"opacity-60",children:["(",T.owner.email,")"]})]})]}),t.jsxs("div",{className:"text-right text-sm",children:[t.jsx("div",{className:"font-medium","data-testid":`text-order-onetime-${T.id}`,children:kx(T.oneTimeTotal)}),t.jsxs("div",{className:"text-xs text-muted-foreground","data-testid":`text-order-monthly-${T.id}`,children:[kx(T.monthlyTotal)," / mo"]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>j(T),"data-testid":`button-order-view-${T.id}`,children:[t.jsx(Xr,{className:"w-3.5 h-3.5 mr-1"})," View"]}),t.jsx(L,{size:"sm",variant:"outline",asChild:!0,"data-testid":`button-order-pdf-${T.id}`,children:t.jsxs("a",{href:`/api/sales-orders/${T.id}/pdf`,target:"_blank",rel:"noopener noreferrer",children:[t.jsx(XI,{className:"w-3.5 h-3.5 mr-1"})," PDF"]})}),t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>{p({open:!0,order:T}),v(T.customerEmail||""),y("")},"data-testid":`button-order-email-${T.id}`,children:[t.jsx(qi,{className:"w-3.5 h-3.5 mr-1"})," Email"]}),R&&t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>n(`/edge-quote?revise=${T.id}`),"data-testid":`button-order-revise-${T.id}`,children:[t.jsx(vde,{className:"w-3.5 h-3.5 mr-1"})," Revise"]}),t.jsx(L,{size:"sm",variant:"outline",onClick:()=>d({open:!0,order:T,newStatus:T.status}),"data-testid":`button-order-edit-status-${T.id}`,children:"Edit Status"}),M&&t.jsx(L,{size:"sm",variant:"ghost",onClick:()=>{confirm(`Delete order ${T.orderNumber||T.projectName}?`)&&_.mutate(T.id)},"data-testid":`button-order-delete-${T.id}`,children:t.jsx(sa,{className:"w-3.5 h-3.5"})})]})]},T.id)})})})]}),t.jsx(Ys,{open:c.open,onOpenChange:T=>d(M=>({...M,open:T})),children:t.jsxs(Ws,{children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Edit Order Status"}),t.jsx(cr,{children:c.order?.orderNumber||c.order?.projectName})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsx(re,{children:"Status"}),t.jsxs(Us,{value:c.newStatus,onValueChange:T=>d(M=>({...M,newStatus:T})),children:[t.jsx($s,{"data-testid":"select-new-status",children:t.jsx(zs,{})}),t.jsx(Fs,{children:_M.map(T=>t.jsx(rt,{value:T.value,children:T.label},T.value))})]}),(c.newStatus==="active"||c.newStatus==="canceled")&&t.jsx("p",{className:"text-xs text-muted-foreground",children:c.newStatus==="active"?"Marking as Active (Sold) will stamp the activation date and trigger any linked-device cloud sync side-effects.":"Canceled orders stop any linked-device cloud sync side-effects."})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"ghost",onClick:()=>d({open:!1,order:null,newStatus:"new"}),"data-testid":"button-status-cancel",children:"Cancel"}),t.jsxs(L,{onClick:()=>c.order&&S.mutate({id:c.order.id,status:c.newStatus}),disabled:S.isPending,"data-testid":"button-status-save",children:[S.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Save"]})]})]})}),t.jsx(Ys,{open:h.open,onOpenChange:T=>p(M=>({...M,open:T})),children:t.jsxs(Ws,{children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Email Quote to Customer"}),t.jsx(cr,{children:"The PDF will be attached. Reply-To is set to your email."})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"email-to",children:"To"}),t.jsx(ke,{id:"email-to",type:"email",value:g,onChange:T=>v(T.target.value),placeholder:"[email protected]","data-testid":"input-email-to"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"email-message",children:["Message ",t.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),t.jsx(Nn,{id:"email-message",value:b,onChange:T=>y(T.target.value),rows:4,"data-testid":"input-email-message"})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"ghost",onClick:()=>p({open:!1,order:null}),"data-testid":"button-email-cancel",children:"Cancel"}),t.jsxs(L,{onClick:()=>h.order&&A.mutate({id:h.order.id,to:g,message:b}),disabled:A.isPending||!h.order,"data-testid":"button-email-send",children:[A.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}):t.jsx(qi,{className:"w-4 h-4 mr-1"}),"Send"]})]})]})}),t.jsx(OSe,{order:w,onClose:()=>j(null),onOpenDevice:s})]})}function LSe({userId:e}){const{toast:s}=Hs(),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState("both"),[h,p]=u.useState(""),[g,v]=u.useState(""),{data:b=[],isLoading:y}=ze({queryKey:["/api/promo-codes"]}),w=Et({mutationFn:async()=>{const x={code:a.trim().toUpperCase(),discountPercent:parseFloat(o),scope:c,notes:g||void 0};return h&&(x.expiresAt=new Date(h).toISOString()),(await Ze("POST","/api/promo-codes",x)).json()},onSuccess:()=>
298{Je.invalidateQueries({queryKey:["/api/promo-codes"]}),n(!1),i(""),l(""),d("both"),p(""),v(""),s({title:"Promo code created"})},onError:x=>s({title:"Failed to create code",description:x.message,variant:"destructive"})}),j=Et({mutationFn:async x=>{await Ze("DELETE",`/api/promo-codes/${x}`)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/promo-codes"]}),s({title:"Promo code deleted"})}});return t.jsxs(ut,{children:[t.jsxs(xs,{className:"pb-3 flex-row items-center justify-between gap-2 space-y-0",children:[t.jsxs("div",{children:[t.jsxs(ys,{className:"text-base flex items-center gap-2",children:[t.jsx(Py,{className:"w-4 h-4 text-primary"})," Promo Codes"]}),t.jsx(Xs,{children:"Shared across all admins. Admins apply them on the quote builder."})]}),t.jsxs(L,{size:"sm",onClick:()=>n(!0),"data-testid":"button-create-promo",children:[t.jsx(Fo,{className:"w-4 h-4 mr-1"})," New Code"]})]}),t.jsx(mt,{children:y?t.jsx(Bt,{className:"h-24 w-full"}):b.length===0?t.jsx("p",{className:"text-sm text-muted-foreground py-6 text-center","data-testid":"text-no-promo-codes",children:"No promo codes yet. Create one above to share it with your admins."}):t.jsx("div",{className:"divide-y divide-border",children:b.map(x=>{const C=x.expiresAt?new Date(x.expiresAt).getTime()<Date.now():!1;return t.jsxs("div",{className:"py-3 flex flex-wrap items-center gap-3","data-testid":`row-promo-${x.id}`,children:[t.jsxs("div",{className:"flex-1 min-w-[180px]",children:[t.jsx("div",{className:"font-mono font-semibold text-sm","data-testid":`text-promo-code-${x.id}`,children:x.code}),t.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{children:[x.discountPercent,"% off"]}),t.jsx(Ke,{variant:"outline",className:"text-xs capitalize",children:x.scope}),x.expiresAt&&t.jsxs("span",{className:`flex items-center gap-1 ${C?"text-destructive":""}`,children:[t.jsx(ro,{className:"w-3 h-3"})," ",C?"expired ":"expires ",ste(x.expiresAt)]}),!x.expiresAt&&t.jsx("span",{children:"Never expires"})]}),x.notes&&t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 italic",children:x.notes})]}),t.jsx(L,{size:"sm",variant:"ghost",onClick:()=>{confirm(`Delete promo code ${x.code}?`)&&j.mutate(x.id)},"data-testid":`button-promo-delete-${x.id}`,children:t.jsx(sa,{className:"w-3.5 h-3.5"})})]},x.id)})})}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Create Promo Code"}),t.jsx(cr,{children:"Codes are case-insensitive on lookup and stored uppercase."})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"promo-code-input",children:"Code"}),t.jsx(ke,{id:"promo-code-input",value:a,onChange:x=>i(x.target.value.toUpperCase()),placeholder:"LAUNCH10","data-testid":"input-promo-code"})]}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"promo-percent",children:"Discount %"}),t.jsx(ke,{id:"promo-percent",type:"number",step:"0.5",min:"0.5",max:"100",value:o,onChange:x=>l(x.target.value),placeholder:"10","data-testid":"input-promo-percent"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"Scope"}),t.jsxs(Us,{value:c,onValueChange:x=>d(x),children:[t.jsx($s,{"data-testid":"select-promo-scope",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"both",children:"Both (hardware + subscription)"}),t.jsx(rt,{value:"hardware",children:"Hardware only"}),t.jsx(rt,{value:"subscription",children:"Subscription only"})]})]})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"promo-expires",children:["Expires At ",t.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),t.jsx(ke,{id:"promo-expires",type:"date",value:h,onChange:x=>p(x.target.value),"data-testid":"input-promo-expires"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"promo-notes",children:["Notes ",t.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),t.jsx(ke,{id:"promo-notes",value:g,onChange:x=>
298v(x.target.value),placeholder:"Internal context","data-testid":"input-promo-notes"})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"ghost",onClick:()=>n(!1),"data-testid":"button-promo-cancel",children:"Cancel"}),t.jsxs(L,{onClick:()=>w.mutate(),disabled:w.isPending||!a.trim()||!o,"data-testid":"button-promo-save",children:[w.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Create"]})]})]})})]})}function $Se(){const{toast:e}=Hs(),{data:s,isLoading:r}=ze({queryKey:["/api/edge-pricing"]}),[n,a]=u.useState(null);u.useEffect(()=>{s?.pricing&&!n&&a(s.pricing)},[s,n]);const i=Et({mutationFn:async d=>(await Ze("PATCH","/api/edge-pricing",d)).json(),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/edge-pricing"]}),e({title:"Pricing saved"})},onError:d=>e({title:"Failed to save",description:d.message,variant:"destructive"})});if(r||!n)return t.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"Loading…"});const o=(d,h)=>{a(p=>{if(!p)return p;const g=JSON.parse(JSON.stringify(p));let v=g;for(let b=0;b<d.length-1;b++)v=v[d[b]];return v[d[d.length-1]]=h,g})},l=()=>{if(!n)return;const d=pSe.safeParse(n);if(!d.success){e({title:"Invalid values",description:d.error.errors[0]?.message||"Check your inputs",variant:"destructive"});return}i.mutate(d.data)},c=d=>Number.isFinite(d)?d:0;return t.jsx("div",{className:"space-y-4 max-w-4xl",children:t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{children:"Edge Pricing"}),t.jsx(Xs,{children:"Editable price book that drives the Edge Quoting Tool. Saved quotes preserve a snapshot of their line items and are not re-priced when these values change."})]}),t.jsxs(mt,{className:"space-y-6",children:[t.jsxs("section",{className:"space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Hardware (one-time, per unit)"}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3",children:["8","16","32","64","128"].map(d=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{className:"text-xs",children:[d,"-channel"]}),t.jsx(ke,{type:"number",min:0,value:n.hardware[d],onChange:h=>o(["hardware",d],c(parseFloat(h.target.value))),"data-testid":`input-hw-${d}`})]},d))})]}),t.jsxs("section",{className:"space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Local Storage Uplift"}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"Local Storage $ / TB"}),t.jsx(ke,{type:"number",min:0,value:n.localStoragePerTb,onChange:d=>o(["localStoragePerTb"],c(parseFloat(d.target.value))),"data-testid":"input-local-storage-per-tb"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"2U Chassis Uplift / unit"}),t.jsx(ke,{type:"number",min:0,value:n.rackmount2UUplift??n.rackmountUplift??0,onChange:d=>o(["rackmount2UUplift"],c(parseFloat(d.target.value))),"data-testid":"input-rackmount-2u-uplift"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"4U Chassis Uplift / unit"}),t.jsx(ke,{type:"number",min:0,value:n.rackmount4UUplift??n.rackmountUplift??0,onChange:d=>o(["rackmount4UUplift"],c(parseFloat(d.target.value))),"data-testid":"input-rackmount-4u-uplift"})]})]})]}),t.jsxs("section",{className:"space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Cloud Recording (per camera / month)"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"1080p / 2MP uses the base rate. Set the per-camera monthly uplift for 4MP, 5MP, 6MP, and 4K / 8MP cameras below."}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm border border-border rounded-md",children:[t.jsx("thead",{className:"bg-muted/50",children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left px-3 py-2",children:"Mode"}),[14,30,90,180,365,730,1095,1460,1825].map(d=>t.jsxs("th",{className:"px-2 py-2 text-xs",children:[d,"d"]},d))]})}),t.jsx("tbody",{children:["motion","247"].map(d=>t.jsxs("tr",{className:"border-t border-border",children:[t.jsx("td",{className:"px-3 py-2 font-medium",children:d==="247"?"24/7":"Motion"}),[14,30,90,180,365,730,1095,1460,1825].map(h=>t.jsx("td",{className:"px-1 py-1",children:t.jsx(ke,{type:"number",min:0,step:"0.01",value:n.cloud[d][String(h)],onChange:p=>o(["cloud",d,String(h)],c(parseFloat(p.target.value))),className:"h-8 text-xs","data-testid":`input-cloud-${d}-${h}`})},h))]},d))})]})}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 pt-2",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"4MP uplift / cam / mo"}),t.jsx(ke,{type:"number",min:0,step:"0.01",value:n.standardUplift,onCh
298ange:d=>o(["standardUplift"],c(parseFloat(d.target.value))),"data-testid":"input-4mp-uplift"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"5MP uplift / cam / mo"}),t.jsx(ke,{type:"number",min:0,step:"0.01",value:n.fiveMPUplift,onChange:d=>o(["fiveMPUplift"],c(parseFloat(d.target.value))),"data-testid":"input-5mp-uplift"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"6MP uplift / cam / mo"}),t.jsx(ke,{type:"number",min:0,step:"0.01",value:n.sixMPUplift,onChange:d=>o(["sixMPUplift"],c(parseFloat(d.target.value))),"data-testid":"input-6mp-uplift"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"4K / 8MP uplift / cam / mo"}),t.jsx(ke,{type:"number",min:0,step:"0.01",value:n.fourKUplift,onChange:d=>o(["fourKUplift"],c(parseFloat(d.target.value))),"data-testid":"input-4k-uplift"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"Plus Plan / cam / mo"}),t.jsx(ke,{type:"number",min:0,step:"0.01",value:n.plusPlanRate,onChange:d=>o(["plusPlanRate"],c(parseFloat(d.target.value))),"data-testid":"input-plus-plan-rate"})]})]})]}),t.jsxs("section",{className:"space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Smart Alerts"}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"Smart Alerts / cam / mo"}),t.jsx(ke,{type:"number",min:0,step:"0.01",value:n.smartAlertsRate??9.99,onChange:d=>o(["smartAlertsRate"],c(parseFloat(d.target.value))),"data-testid":"input-smart-alerts-rate"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"AI-powered event detection subscription add-on."})]})})]}),t.jsxs("section",{className:"space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Shipping"}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"Free Shipping Threshold (USD)"}),t.jsx(ke,{type:"number",min:0,step:"1",value:n.freeShippingThresholdUsd??1500,onChange:d=>o(["freeShippingThresholdUsd"],c(parseFloat(d.target.value))),"data-testid":"input-free-shipping-threshold"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"US orders with hardware subtotal at or above this amount ship free."})]})})]}),t.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[t.jsxs(L,{variant:"outline",onClick:()=>a(JSON.parse(JSON.stringify(ete))),"data-testid":"button-reset-defaults",children:[t.jsx(bh,{className:"w-4 h-4 mr-1"})," Reset to defaults"]}),t.jsxs(L,{onClick:l,disabled:i.isPending,"data-testid":"button-save-pricing",children:[i.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-1"}),"Save Pricing"]})]})]})]})})}const rte={key:"refer",title:"Refer a Friend",group:"General",fields:[{key:"hero.heading",label:"Hero heading",def:"Refer {productName}"},{key:"hero.subheading",label:"Hero subheading",def:"Know someone who could benefit from smarter surveillance? Enter their name and email below, and we'll send them a detailed overview of what {productName} can do.",multiline:!0},{key:"form.nameLabel",label:"Name label",def:"Recipient's Name"},{key:"form.namePlaceholder",label:"Name placeholder",def:"Jane Smith"},{key:"form.emailLabel",label:"Email label",def:"Recipient's Email"},{key:"form.emailPlaceholder",label:"Email placeholder",def:"[email protected]"},{key:"form.submitButton",label:"Submit button",def:"Send Referral"},{key:"form.sendingButton",label:"Sending button",def:"Sending..."},{key:"backButton",label:"Back button",def:"Back to Home"}]},nte={key:"blog",title:"Blog",group:"General",fields:[{key:"hero.badge",label:"Hero badge",def:"Blog"},{key:"hero.heading",label:"Hero heading",def:"Security Intelligence & Industry News"},{key:"hero.subheading",label:"Hero subheading",def:"Stay current on AI surveillance trends, security best practices, and the latest in video intelligence technology."},{key:"hero.rssLink",label:"RSS subscribe link",def:"Subscribe via RSS"},{key:"empty.message",label:"Empty-state message",def:"No posts yet — check back soon."},{key:"card.readMore",label:"Card read-more label",def:"Read more"}]},ate={key:"blogPost",title:"Blog Post",group:"General",fields:[{key:"breadcrumb.home",label:"Breadcrumb: home",def
298:"Home"},{key:"breadcrumb.blog",label:"Breadcrumb: blog",def:"Blog"},{key:"backButton",label:"Back button",def:"Back to Blog"},{key:"notFound.message",label:"Not-found message",def:"Post not found."},{key:"notFound.button",label:"Not-found button",def:"Back to Blog"},{key:"faq.heading",label:"FAQ heading",def:"Frequently Asked Questions"},{key:"source.label",label:"Original source label",def:"Original source"},{key:"related.heading",label:"Related posts heading",def:"Related Posts"}]},ite={key:"resetPassword",title:"Reset Password",group:"General",fields:[{key:"done.heading",label:"Done heading",def:"Password updated"},{key:"done.body",label:"Done body",def:"Your password has been reset successfully."},{key:"form.heading",label:"Form heading",def:"Set a new password"},{key:"form.subheadingHasToken",label:"Subheading (valid token)",def:"Choose a new password for your {productName} account."},{key:"form.subheadingNoToken",label:"Subheading (missing token)",def:'This reset link is missing or invalid. Use "Forgot password" on the sign-in page to request a fresh link.',multiline:!0},{key:"error.invalidLink",label:"Invalid/expired link fallback",def:"This link is invalid or has expired."},{key:"error.requestNewLink",label:"Error request-new-link button",def:"Request a new link"},{key:"done.signInButton",label:"Done sign-in button",def:"Sign In"},{key:"form.newPasswordLabel",label:"New password label",def:"New Password"},{key:"form.newPasswordPlaceholder",label:"New password placeholder",def:"At least 8 characters"},{key:"form.confirmPasswordLabel",label:"Confirm password label",def:"Confirm Password"},{key:"form.confirmPasswordPlaceholder",label:"Confirm password placeholder",def:"Repeat your new password"},{key:"form.submitButton",label:"Submit button",def:"Reset Password"},{key:"missing.requestNewLink",label:"Missing token request button",def:"Request a new link"},{key:"missing.goHome",label:"Missing token go-home button",def:"Go to Sign In"}]},ote={key:"notFound",title:"Not Found (404)",group:"General",fields:[{key:"code",label:"Error code",def:"404"},{key:"heading",label:"Heading",def:"Page Not Found"},{key:"body",label:"Body",def:"The page you're looking for doesn't exist or has been moved."},{key:"homeButton",label:"Home button",def:"Go to Dashboard"}]},lte={key:"solutions.cannabis",title:"Solutions: Cannabis",group:"Solutions",fields:[{key:"hero.badge",label:"Hero badge",def:"Solutions · Cannabis"},{key:"hero.heading",label:"Hero heading (lines)",def:`Compliance-Ready Surveillance
299for Cannabis Operators`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} helps cannabis operators meet state surveillance mandates, protect high-value inventory, and manage every facility from one centralized platform.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"trustedBy.heading",label:"Trusted-by heading",def:"Trusted By Cannabis & Regulated Industry Operators"},{key:"trustedBy.names",label:"Trusted-by names",def:["Fluent Cannabis","Planet Fitness","Vepo Solutions","Acadian Health"].join(`
300`),multiline:!0,help:"One company name per line."},{key:"challenges.eyebrow",label:"Challenges eyebrow",def:"The Problem"},{key:"challenges.heading",label:"Challenges heading",def:"What Cannabis Operators Deal With"},{key:"challenges.subheading",label:"Challenges subheading",def:"Regulatory pressure, high-value inventory, and multi-site complexity make surveillance a critical operational requirement — not an afterthought."},{key:"challenges.items",label:"Challenge cards",def:["Strict Regulatory Compliance | Cannabis operators must maintain continuous camera coverage at all entry points, vaults, sales floors, and grow rooms — with footage retained for months. Regulatory violations can result in license suspension.","High-Value Product Security | Cannabis and cash are prime targets for theft, both externally and internally. Without AI-assisted review and complete camera coverage, losses are often discovered long after the fact.","Multi-Location License Management | Each dispensary or cultivation facility operates under its own license with its own compliance requirements. Managing separate surveillance systems for each location is operationally unsustainable.","State Audit Readiness | Regulators can request footage access with little notice. Operators without reliable cloud storage or centralized access tools scramble to pull evidence — creating compliance gaps and delays."].join(`
301`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"challenges.icons",label:"Challenge card icons",def:["FileText","Lock","AlertTriangle","Eye"].join(`
302`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the challenge cards above."},{key:"features.eyebrow",label:"Features eyebrow",def:"The Solution"},{key:"features.heading",label:"Features heading",def:"Built for Regulated Cannabis Operations"},{key:"features.subheading",label:"Features subheading",def:"From single dispensaries to multi-state operators, {productName} keeps you compliant and in control."},{key:"features.items",label:"Feature cards",def:["AI Event Search | Search footage across every facility — dispensaries, grow rooms, and vaults — by person, vehicle, or object. Identify internal theft or policy violations instantly without manual review.","Full-Facility Live Monitoring | Watch every required camera zone — entries, exits, sales floors, vaults, and cultivation areas — simultaneously from a single compliance-ready dashboard.","Compliant Cloud Retention | Footage automatically syncs to Google Cloud Storage with retention periods configurable to meet your state's requirements — up to 5 years. Always audit-ready.","Instant Camera Down Alerts | Regulatory gaps start the moment a camera goes offline. Receive immediate alerts so you can restore coverage before a compliance event is triggered.","Role-Based Access by Location | Compliance managers see all facilities. Location managers see their own. Staff are locked to their zone. All configured centrally with a full access log for auditors.","Works With Existing Cameras | Already have cameras installed? {productName} integrates with any RTSP or ONVIF camera, NVR, or DVR — no replacement required to add cloud backup and AI capabilities."].join(`
303`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"features.icons",label:"Feature card icons",def:["Search","Eye","Cloud","Bell","Users","ShieldCheck"].join(`
304`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the feature cards above."},{key:"stats.items",label:"Stat highlights",def:["99.9% | Google Cloud Uptime","5 Years | Maximum Retention","24/7 | Automated Monitoring"].join(`
305`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"testimonial.quote",label:"Testimonial quote",def:"Our state requires 90 days of footage retention across all camera zones. With {productName}, we're covered automatically across all six of our dispensaries — and our last audit was the smoothest we've ever had.",multiline:!0}
305,{key:"testimonial.name",label:"Testimonial name",def:"Kevin M."},{key:"testimonial.role",label:"Testimonial role",def:"Director of Compliance"},{key:"testimonial.company",label:"Testimonial company",def:"Multi-State Cannabis Operator"},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Everything You Need From Day One"},{key:"included.items",label:"What's-included checklist",def:["Centralized multi-facility dashboard","Live view — sales floor, vaults, entries, grow rooms","Configurable cloud retention (up to 5 years)","AI search — person, vehicle, plates, objects","Full audit log of all camera access","Role-based access by facility","Instant camera offline alerts","Works with existing RTSP/ONVIF cameras","No port forwarding required","Dedicated support team"].join(`
306`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Ready to Stay Compliant & Secure?"},{key:"cta.subheading",label:"CTA subheading",def:"Join cannabis operators already meeting regulatory requirements and protecting inventory with {productName}.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your operation and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Describe your operation"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of facilities, license types, cameras, states operating in..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},cte={key:"solutions.commercialRealEstate",title:"Solutions: Commercial Real Estate",group:"Solutions",fields:[{key:"hero.badge",label:"Hero badge",def:"Solutions · Commercial Real Estate"},{key:"hero.heading",label:"Hero heading (lines)",def:`One Platform for Your
307Entire Property Portfolio`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} gives CRE operators centralized visibility across every property, AI-powered incident search, and long-term cloud evidence retention — protecting assets and reducing liability.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"trustedBy.heading",label:"Trusted-by heading",def:"Trusted By Leading Real Estate Organizations"},{key:"trustedBy.names",label:"Trusted-by names",def:["Douglas Elliman","Prana Investments","Bloomberg","Brenntag","Vepo Solutions"].join(`
308`),multiline:!0,help:"One company name per line."},{key:"challenges.eyebrow",label:"Challenges eyebrow",def:"The Problem"},{key:"challenges.heading",label:"Challenges heading",def:"CRE Security Challenges"},{key:"challenges.subheading",label:"Challenges subheading",def:"Commercial property operators face liability and security risks that fragmented systems aren't equipped to handle."},{key:"challenges.items",label:"Challenge cards",def:["Sprawling Multi-Property Portfolios | Managing security across office towers, retail centers, and mixed-use developments requires a unified platform. Fragmented systems mean blind spots, delayed responses, and higher liability.","Tenant & Visitor Safety Liability | Property owners are responsible for safety in common areas, lobbies, garages, and loading docks. Incidents that go unrecorded or unreviewed quickly become costly legal disputes.","After-Hours Access Violations | Unauthorized entry, tailgating, and after-hours intrusions are common in commercial properties. Without real-time alerts and cloud-backed footage, these events go undetected.","Multi-Tenant Access Complexity | Each tenant has different security needs and access levels. Managing separate systems for each tenant — or giving everyone full access — creates both friction and risk."].join(`
309`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"challenges.icons",label:"Challenge card icons",def:["MapPin","TrendingDown","Lock","Users"].join(`
310`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the challenge cards above."},{key:"features.eyebrow",label:"Features eyebrow",def:"The Solution"},{key:"features.heading",label:"Features heading",def:"Built for Portfolio-Scale Operations"},{key:"features.subheading",label:"Features subheading",def:"From single office buildings to nationwide mixed-use portfolios, {productName} adapts to your scale."},{key:"features.items",label:"Feature cards",def:["AI-Powered Incident Search | Search footage across every property by person, vehicle, license plate, or object. Find the exact moment of a tailgating incident, package theft, or access violation in seconds.","Portfolio-Wide Live View | Monitor all properties — lobbies, garages, loading docks, and common areas — from a single dashboard. Property managers have full visibility without being on-site.","Long-Term Cloud Evidence Retention | Footage is automatically backed up to Google Cloud Storage with up to 5 years of retention. Protect against slip-and-fall claims, lease disputes, and liability cases that surface months later.","Instant Camera Offline Alerts | Know immediately when any camera goes down at any property. Maintain continuous coverage across your entire portfolio without daily manual checks.","Property-Level Access Controls | Property managers see their building. Portfolio directors see everything. Tenants can be granted read-only access to their own floor footage. All permissions managed centrally.","Works With Existing Cameras | No capital expenditure to get started. {productName} connects to any RTSP or ONVIF-compatible camera, NVR, or DVR already installed across your properties."].join(`
311`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"features.icons",label:"Feature card icons",def:["Search","Eye","Cloud","Bell","Users","ShieldCheck"].join(`
312`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the feature cards above."},{key:"stats.items",label:"Stat highlights",def:["99.9% | Google Cloud Uptime","5 Years | Maximum Evidence Retention","<60s | Incident Clip Retrieval"].join(`
313`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"testimonial.quote",label:"Testimonial quote",def:"We manage 14 commercial properties and used to rely on individual building managers to pull footage. Now our team has instant access to every camera across the portfolio — it's transformed how 
313we handle incidents.",multiline:!0},{key:"testimonial.name",label:"Testimonial name",def:"Thomas W."},{key:"testimonial.role",label:"Testimonial role",def:"VP of Asset Management"},{key:"testimonial.company",label:"Testimonial company",def:"Commercial Real Estate Group"},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Everything You Need From Day One"},{key:"included.items",label:"What's-included checklist",def:["Portfolio-wide property dashboard","Live view — lobbies, garages, common areas","Cloud recording up to 5 years","AI search — person, vehicle, plates, objects","Property and tenant-level access controls","Instant camera offline alerts","Exportable clips for legal & insurance","Works with existing RTSP/ONVIF cameras","No port forwarding required","Dedicated support team"].join(`
314`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Ready to Protect Your Portfolio?"},{key:"cta.subheading",label:"CTA subheading",def:"Join commercial real estate operators already managing their entire portfolio on {productName}.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your properties and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Describe your portfolio"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of properties, asset types, cameras, current system..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},dte={key:"solutions.education",title:"Solutions: Education",group:"Solutions",fields:[{key:"hero.badge",label:"Hero badge",def:"Solutions · Education"},{key:"hero.heading",label:"Hero heading (lines)",def:`Smarter Campus Security
315for Schools & Universities`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} gives educational institutions AI-powered surveillance, centralized campus visibility, and cloud-backed evidence retention — keeping students, staff, and facilities safe.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"trustedBy.heading",label:"Trusted-by heading",def:"Trusted By Educational Institutions"},{key:"trustedBy.names",label:"Trusted-by names",def:["LaGuardia Community College","Housatonic Community College","North Castle Police Department","Bloomberg"].join(`
316`),multiline:!0,help:"One company name per line."},{key:"challenges.eyebrow",label:"Challenges eyebrow",def:"The Problem"},{key:"challenges.heading",label:"Challenges heading",def:"Security Challenges in Education"},{key:"challenges.subheading",label:"Challenges subheading",def:"Schools and universities face safety demands that traditional systems aren't equipped to meet."},{key:"challenges.items",label:"Challenge cards",def:["Campus Safety & Threat Response | Schools and universities must be able to respond to threats instantly. Delayed access to footage or miscommunication between departments can cost critical minutes during an active incident.","Large, Dispersed Campuses | Educational facilities span buildings, parking lots, athletic fields, and pedestrian areas. Without a unified platform, security gaps form at every disconnected system boundary.","After-Hours Intrusions & Vandalism | Campuses are frequent targets for theft, vandalism, and trespassing after hours. Footage that's been overwritten or stored on damaged local drives leaves schools with no evidence.","Multi-Department Access Coordination | Campus security, student affairs, athletics, and administration all have different visibility needs. Managing separate logins and systems creates friction and delays."].join(`
317`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"challenges.icons",label:"Challenge card icons",def:["AlertTriangle","MapPin","Lock","Users"].join(`
318`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the challenge cards above."},{key:"features.eyebrow",label:"Features eyebrow",def:"The Solution"},{key:"features.heading",label:"Features heading",def:"Built for Educational Campuses"},{key:"features.subheading",label:"Features subheading",def:"From K-12 schools to large universities, {productName} adapts to your campus layout and security requirements."},{key:"features.items",label:"Feature cards",def:["AI Event Search | Search for a person, vehicle, or object across every camera on campus in seconds. Identify suspects, track movement, and build a clear incident timeline without manual review.","Unified Campus Live View | Monitor every building, entrance, parking structure, and outdoor area from one screen. Security personnel have complete situational awareness at all times.","Cloud-Backed Evidence Retention | Footage syncs automatically to Google Cloud Storage. Even if on-site equipment is damaged or stolen, recordings remain safe for investigations and legal proceedings.","Instant Offline Alerts | Know immediately when any camera goes down — day or night. Maintain continuous coverage of every part of your campus without relying on daily manual checks.","Department-Level Access Controls | Campus security sees everything. Department heads see their buildings. Student affairs sees common areas. Permissions are customized and enforced automatically.","Works With Existing Cameras | No capital expenditure required to get started. {productName} integrates with any RTSP or ONVIF camera, NVR, or DVR already deployed on your campus."].join(`
319`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"features.icons",label:"Feature card icons",def:["Search","Eye","Cloud","Bell","Users","ShieldCheck"].join(`
320`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the feature cards above."},{key:"stats.items",label:"Stat highlights",def:["99.9% | Google Cloud Uptime","5 Years | Maximum Evidence Retention","<5 min | Average Incident Clip Time"].join(`
321`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"testimonial.quote",label:"Testimonial quote",def:"When an incident occurred in our parking structure, our security team pulled the footage, identified the vehicle, and had clips ready for police in under five minutes. That wouldn't have been possible before.",multiline:!0}
321,{key:"testimonial.name",label:"Testimonial name",def:"Angela R."},{key:"testimonial.role",label:"Testimonial role",def:"Director of Campus Safety"},{key:"testimonial.company",label:"Testimonial company",def:"Community College System"},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Everything You Need From Day One"},{key:"included.items",label:"What's-included checklist",def:["Unified campus-wide dashboard","Live view — buildings, lots, outdoor areas","Cloud recording up to 5 years","AI search — person, vehicle, plates, objects","Department-level access controls","Instant camera offline alerts","Exportable clips for law enforcement","Works with existing RTSP/ONVIF cameras","No port forwarding required","Dedicated support team"].join(`
322`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Ready to Secure Your Campus?"},{key:"cta.subheading",label:"CTA subheading",def:"Join educational institutions already protecting students and staff with {productName}.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your campus and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your campus"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of buildings, enrollment, cameras, current system..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},ute={key:"solutions.government",title:"Solutions: Government",group:"Solutions",fields:[{key:"hero.badge",label:"Hero badge",def:"Solutions · Government & Law Enforcement"},{key:"hero.heading",label:"Hero heading (lines)",def:`Surveillance Built for
323Public Safety & Government`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} gives government agencies and law enforcement centralized camera management, AI-assisted investigations, and long-term cloud evidence storage that meets retention mandates.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"trustedBy.heading",label:"Trusted-by heading",def:"Trusted By Government & Public Safety Organizations"},{key:"trustedBy.names",label:"Trusted-by names",def:["North Castle Police Department","Bloomberg","LaGuardia Community College","Housatonic Community College"].join(`
324`),multiline:!0,help:"One company name per line."},{key:"challenges.eyebrow",label:"Challenges eyebrow",def:"The Problem"},{key:"challenges.heading",label:"Challenges heading",def:"Challenges Facing Government & Law Enforcement"},{key:"challenges.subheading",label:"Challenges subheading",def:"Public safety agencies face evidence, retention, and coordination demands that consumer-grade systems cannot meet."},{key:"challenges.items",label:"Challenge cards",def:["Chain of Custody & Evidence Integrity | Law enforcement and government agencies require tamper-evident, audit-trailed footage for use in legal proceedings. Systems that lack secure cloud backup or logging create evidentiary risk.","Public Safety Incident Response | When a public safety incident occurs, agencies need to pull footage immediately — across multiple cameras, angles, and locations — and share it with the right personnel fast.","Long Retention Requirements | Government and law enforcement agencies often face retention mandates of years, not months. Local storage alone cannot meet these requirements reliably without significant infrastru
324cture cost.","Multi-Agency Coordination | Incidents frequently involve multiple jurisdictions and agencies. Without a centralized platform, sharing footage requires physical media transfers that add hours to investigations."].join(`
325`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"challenges.icons",label:"Challenge card icons",def:["Lock","AlertTriangle","Clock","Eye"].join(`
326`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the challenge cards above."},{key:"features.eyebrow",label:"Features eyebrow",def:"The Solution"},{key:"features.heading",label:"Features heading",def:"Purpose-Built for Public Sector Needs"},{key:"features.subheading",label:"Features subheading",def:"From municipal police departments to large government campuses, {productName} scales to your jurisdiction."},{key:"features.items",label:"Feature cards",def:["AI Event Search | Search footage by person description, vehicle make, license plate, or object across every camera in seconds. Build complete incident timelines without manual review.","Centralized Multi-Site Monitoring | Monitor all facilities — municipal buildings, parking areas, public spaces, and perimeters — from a single dashboard. Dispatchers and supervisors have instant situational awareness.","Long-Term Cloud Evidence Storage | Footage is automatically encrypted and backed up to Google Cloud Storage with up to 5 years of retention — meeting government record-keeping requirements without on-site infrastructure overhead.","Real-Time System Alerts | Receive immediate notifications if any camera or device goes offline. Ensure 100% coverage of critical locations with automated monitoring and alert escalation.","Tiered Access & Audit Logging | Grant role-specific access to investigators, supervisors, and administrators. Every access event is logged, creating a complete chain-of-custody record for evidentiary purposes.","Works With Existing Infrastructure | Integrate with cameras, NVRs, and DVRs already deployed across facilities — no costly equipment replacement required to modernize your surveillance capability."].join(`
327`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"features.icons",label:"Feature card icons",def:["Search","Eye","Cloud","Bell","Users","ShieldCheck"].join(`
328`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the feature cards above."},{key:"stats.items",label:"Stat highlights",def:["99.9% | Google Cloud Uptime","5 Years | Evidence Retention","24/7 | Automated Monitoring"].join(`
329`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"testimonial.quote",label:"Testimonial quote",def:"We can now pull footage from any camera in our jurisdiction, clip it, and send it securely to the DA's office — all from one platform. It's completely changed how we handle evidence.",multiline:!0},{key:"testimonial.name",label:"Testimonial name",def:"Chief R. Alvarez"},{key:"testimonial.role",label:"Testimonial role",def:"Chief of Police"},{key:"testimonial.company",label:"Testimonial company",def:"Municipal Police Department"},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Everything You Need From Day One"},{key:"included.items",label:"What's-included checklist",def:["Centralized multi-location dashboard","Live view across all facilities and public areas","Cloud recording with up to 5-year retention","AI search — person, vehicle, plates, objects","Access logging and audit trails","Granular role-based permissions","Exportable clips for legal & DA offices","Works with existing RTSP/ONVIF cameras","No port forwarding required","Dedicated support team"].join(`
330`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Ready to Modernize Your Surveillance?"},{key:"cta.subheading",label:"CTA subheading",def:"Join public safety agencies already improving response times and evidence management with {productName}.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your agency and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Describe your agency"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Agency type, number of locations, cameras, current system..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},mte={key:"solutions.healthcare",title:"Solutions: Healthcare",group:"Solutions",fields:[{key:"hero.badge",label:"Hero badge",def:"Solutions · Healthcare"},{key:"hero.heading",label:"Hero heading (lines)",def:`Protecting Patients,
331Staff & Facilities`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} gives healthcare operators centralized visibility across every campus, AI-powered incident retrieval, and secure cloud storage that meets the demands of a high-compl
331iance environment.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"trustedBy.heading",label:"Trusted-by heading",def:"Trusted By Healthcare & Medical Organizations"},{key:"trustedBy.names",label:"Trusted-by names",def:["Acadian Health","Bloomberg","Housatonic Community College","LaGuardia Community College"].join(`
332`),multiline:!0,help:"One company name per line."},{key:"challenges.eyebrow",label:"Challenges eyebrow",def:"The Problem"},{key:"challenges.heading",label:"Challenges heading",def:"Security Challenges in Healthcare"},{key:"challenges.subheading",label:"Challenges subheading",def:"Healthcare facilities face unique risks that demand purpose-built surveillance solutions."},{key:"challenges.items",label:"Challenge cards",def:["HIPAA & Compliance Requirements | Healthcare facilities must maintain strict access control and audit trails. Surveillance systems that lack role-based access and secure cloud storage create serious compliance exposure.","Workplace Violence & Patient Safety | Emergency rooms, psychiatric units, and pharmacies are high-risk areas. Security teams need real-time visibility and fast footage retrieval to respond to incidents effectively.","After-Hours Vulnerability | Hospitals operate 24/7, but security staffing doesn't always match. Automated alerts and remote monitoring fill the gaps when on-site personnel are stretched thin.","Multi-Building, Multi-Campus Complexity | Health systems often span multiple campuses, buildings, and parking structures. Managing these locations from separate systems creates gaps that attackers and thieves exploit."].join(`
333`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"challenges.icons",label:"Challenge card icons",def:["Lock","AlertTriangle","Clock","Eye"].join(`
334`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the challenge cards above."},{key:"features.eyebrow",label:"Features eyebrow",def:"The Solution"},{key:"features.heading",label:"Features heading",def:"Built for Complex Healthcare Environments"},{key:"features.subheading",label:"Features subheading",def:"From community clinics to multi-campus health systems, {productName} scales to your needs."},{key:"features.items",label:"Feature cards",def:["AI Event Search | Search footage by person, vehicle, or object across any building or campus instantly. Locate a specific incident in the parking garage or pharmacy without manual scrubbing.","Multi-Site Live View | Monitor all cameras across every building, floor, and campus from a single dashboard. Security directors get complete situational awareness without leaving their desk.","Secure Cloud Retention | Footage automatically backs up to Google Cloud Storage with up to 5 years of retention. Protects against hard drive failures and ensures footage is available for litigation and investigations.","Real-Time Camera Alerts | Receive immediate notifications when any camera or device goes offline. Maintain 100% coverage of your facility at all times, even across multiple campuses.","Granular Role-Based Access | Security personnel see their assigned zones. Department heads see their areas. Administrators see everything. Access is enforced automatically, reducing compliance risk.","Works With Existing Infrastructure | No rip-and-replace needed. {productName} integrates with any RTSP or ONVIF camera, DVR, or NVR already installed throughout your facility."].join(`
335`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"features.icons",label:"Feature card icons",def:["Search","Eye","Cloud","Bell","Users","ShieldCheck"].join(`
336`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the feature cards above."},{key:"stats.items",label:"Stat highlights",def:["99.9% | Google Cloud Uptime","5 Years | Maximum Retention","24/7 | Automated Monitoring & Alerts"].join(`
337`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"testimonial.quote",label:"Testimonial quote",def:"Our security team now monitors all three campuses from one screen. When an incident happens, we can pull footage and share it with law enforcement in minutes instead of hours.",multiline:!0}
337,{key:"testimonial.name",label:"Testimonial name",def:"Dr. Michael T."},{key:"testimonial.role",label:"Testimonial role",def:"Director of Facility Security"},{key:"testimonial.company",label:"Testimonial company",def:"Regional Health System"},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Everything You Need From Day One"},{key:"included.items",label:"What's-included checklist",def:["Centralized multi-campus dashboard","Live view — every building and floor","Cloud recording up to 5 years","AI search — person, vehicle, plates, objects","Granular role-based access controls","Instant camera offline alerts","Exportable clips for law enforcement & legal","Works with existing RTSP/ONVIF cameras","No port forwarding required","Dedicated support team"].join(`
338`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Ready to Secure Your Facility?"},{key:"cta.subheading",label:"CTA subheading",def:"Join healthcare organizations already protecting patients and staff with {productName}.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your facility and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Describe your facility"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of buildings, campuses, cameras, current system..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]}
338,hte={key:"solutions.hospitality",title:"Solutions: Hospitality",group:"Solutions",fields:[{key:"hero.badge",label:"Hero badge",def:"Solutions · Hospitality"},{key:"hero.heading",label:"Hero heading (lines)",def:`Enterprise Security for
339Hotels & Resorts`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} gives hospitality operators a single platform to monitor every property, review footage instantly, and stay ahead of incidents — without adding staff.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"trustedBy.heading",label:"Trusted-by heading",def:"Trusted By Leading Hospitality Brands"},{key:"trustedBy.names",label:"Trusted-by names",def:["The Ritz-Carlton","Hilton Garden Inn","Marriott","IHG Hotels & Resorts","Hertz","Prana Investments"].join(`
340`),multiline:!0,help:"One company name per line."},{key:"challenges.eyebrow",label:"Challenges eyebrow",def:"The Problem"},{key:"challenges.heading",label:"Challenges heading",def:"What Hospitality Teams Struggle With"},{key:"challenges.subheading",label:"Challenges subheading",def:"Security in hospitality isn't one problem — it's a dozen. {productName} is built to solve them all."},{key:"challenges.items",label:"Challenge cards",def:["Multiple Properties, One View | Managing security across dozens of hotel locations means dozens of login screens, DVRs, and control rooms. Without central visibility, incidents go unnoticed and response times suffer.","Guest & Staff Safety | Hotels are responsible for the safety of hundreds of guests and staff at any given moment. Gaps in surveillance coverage create liability and risk that operators cannot afford.","Incident Review Under Pressure | When a claim is filed or an incident occurs, security teams need fast access to footage — often hours or days old — across specific cameras, floors, and time ranges.","Remote Property Management | Regional security directors can't be on-site at every property. Without remote access tools, they rely on local staff to pull footage and relay information — adding delays and errors."].join(`
341`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"challenges.icons",label:"Challenge card icons",def:["Building2","Key","Clock","MapPin"].join(`
342`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the challenge cards above."},{key:"features.eyebrow",label:"Features eyebrow",def:"The Solution"},{key:"features.heading",label:"Features heading",def:"Built for Multi-Property Operators"},{key:"features.subheading",label:"Features subheading",def:"From boutique inns to global hotel chains, {productName} adapts to your scale."},{key:"features.items",label:"Feature cards",def:["Live View Across All Properties | Watch live feeds from any camera at any hotel — from the lobby to the parking garage — without switching systems. Multi-layout views let you monitor several locations simultaneously.","Cloud-Backed Footage Retention | Store months or years of footage securely in Google Cloud Storage. Even if local hardware fails, your recordings remain intact and accessible from anywhere.","Instant Incident Alerts | Get email notifications the moment a camera goes offline or a device becomes unreachable — before guests or staff are affected. Weekly health summaries keep your team informed.","AI-Powered Event Search | Search footage by person, vehicle, license plate, or object across any camera — in seconds. Find the exact moment you need without scrubbing hours of video manually.","Role-Based Access for Your Team | Give property managers view-only access to their own sites while corporate security teams have full visibility. Tiered access prevents unauthorized changes without limiting visibility.","Centralized Multi-Site Dashboard | One login. Every property. See device health, storage usage, event counts, and backup status at a glance — across your entire hotel portfolio."].join(`
343`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"features.icons",label:"Feature card icons",def:["Eye","Cloud","Bell","ShieldCheck","Users","Building2"].join(`
344`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the feature cards above."},{key:"stats.items",label:"Stat highlights",def:["99.9% | Google Cloud Uptime Guarantee","5 Years | Maximum Cloud Retention","<60s | Average Incident Search Time"].join(`
345`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"testimonial.quote",label:"Testimonial quote",def:"We went from managing 14 separate DVR systems to having every property visible in one place. The cloud backup feature alone has saved us three times when local drives failed at our properties.",multiline:!0}
345,{key:"testimonial.name",label:"Testimonial name",def:"David R."},{key:"testimonial.role",label:"Testimonial role",def:"Regional Director of Security"},{key:"testimonial.company",label:"Testimonial company",def:"Multi-Property Hotel Group"},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Everything You Need From Day One"},{key:"included.items",label:"What's-included checklist",def:["Centralized multi-property dashboard","Live view for any camera, any property","Cloud recording up to 5 years","AI search — person, vehicle, plates, objects","Role-based access (corporate vs. property)","Instant camera offline alerts","Weekly health & storage summaries","Works with any RTSP/ONVIF camera or NVR","Plug & play — no port forwarding required","Dedicated support team"].join(`
346`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Ready to Unify Your Hotel Security?"},{key:"cta.subheading",label:"CTA subheading",def:"Join leading hospitality brands already managing their entire portfolio on {productName}.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your properties and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"How many properties?"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Tell us about your setup — number of properties, cameras, current system..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},pte={key:"solutions.restaurants",title:"Solutions: Restaurants",group:"Solutions",fields:[{key:"hero.badge",label:"Hero badge",def:"Solutions · Restaurants & QSR"},{key:"hero.heading",label:"Hero heading (lines)",def:`Security Built for
347Food Service Operations`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"From single diners to national QSR chains, {productName} gives restaurant operators AI-powered surveillance, cloud evidence retention, and remote visibility across every location.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"trustedBy.heading",label:"Trusted-by heading",def:"Trusted By Leading Food Service Brands"},{key:"trustedBy.names",label:"Trusted-by names",def:["McDonald's","Burger King","Fazoli's","Foxwoods","Acadian Health"].join(`
348`),multiline:!0,help:"One company name per line."},{key:"challenges.eyebrow",label:"Challenges eyebrow",def:"The Problem"},{key:"challenges.heading",label:"Challenges heading",def:"What Restaurant Operators Struggle With"},{key:"challenges.subheading",label:"Challenges subheading",def:"High-volume, high-turnover environments create unique security challenges that generic systems weren't built to handle."},{key:"challenges.items",label:"Challenge cards",def:["Theft From Both Sides of the Counter | Employee theft and customer walkouts are among the top sources of loss in food service. Without AI-assisted review, identifying culprits means wat
348ching hours of footage manually.","High Staff Turnover, High Risk | Constantly changing staff creates gaps in accountability. Incidents involving cash handling, food safety violations, and workplace misconduct are hard to detect without continuous coverage.","Franchise Compliance Verification | Franchisors need proof that brand standards are being met across locations. Spot-checking in person is costly; remote verification with timestamped footage is far more efficient.","Drive-Through & Outdoor Blind Spots | Parking lots, drive-through lanes, and outdoor dining areas are high-risk zones often missed by indoor systems. Complete coverage requires a unified platform, not disconnected cameras."].join(`
349`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"challenges.icons",label:"Challenge card icons",def:["AlertTriangle","Clock","Lock","Eye"].join(`
350`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the challenge cards above."},{key:"features.eyebrow",label:"Features eyebrow",def:"The Solution"},{key:"features.heading",label:"Features heading",def:"Built for Multi-Unit Food Service"},{key:"features.subheading",label:"Features subheading",def:"Whether you run 3 locations or 300, {productName} gives your team the visibility they need."},{key:"features.items",label:"Feature cards",def:["AI Event Search | Search footage by person, object, or vehicle across any location. Find a specific incident at your drive-through or kitchen in seconds without scrubbing video.","Multi-Location Live View | Monitor all cameras at all locations simultaneously from one dashboard — kitchens, registers, entrances, and drive-throughs.","Cloud Footage Retention | Automatically back up footage to Google Cloud Storage for up to 5 years. Protect yourself against slip-and-fall claims and employment disputes that surface months later.","Camera Down Alerts | Know the moment a camera goes offline — before a shift starts with a blind spot. Instant alerts ensure your coverage is always complete.","Tiered Access by Role | Store managers see their location. Area supervisors see their district. Franchisors see the full network. All with one platform, zero IT overhead.","Works With Existing Cameras | No need to replace your current system. {productName} connects to any RTSP or ONVIF camera, NVR, or DVR already on-site."].join(`
351`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"features.icons",label:"Feature card icons",def:["Search","Eye","Cloud","Bell","Users","ShieldCheck"].join(`
352`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the feature cards above."},{key:"stats.items",label:"Stat highlights",def:["99.9% | Google Cloud Uptime","5 Years | Maximum Evidence Retention","<60s | Average Clip Retrieval Time"].join(`
353`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"testimonial.quote",label:"Testimonial quote",def:"We run 23 locations and used to spend a full day tracking down footage when something happened. Now I can pull a clip from any register at any location in under a minute.",multiline:!0},{key:"testimonial.name",label:"Testimonial name",def:"James P."},{key:"testimonial.role",label:"Testimonial role",def:"Director of Operations"},{key:"testimonial.company",label:"Testimonial company",def:"Multi-Unit QSR Operator"},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Everything You Need From Day One"},{key:"included.items",label:"What's-included checklist",def:["Centralized multi-location dashboard","Live view — kitchens, registers, drive-throughs","Cloud recording up to 5 years","AI search — person, vehicle, plates, objects","Role-based access by location, district, or brand","Instant camera offline alerts","Franchise compliance monitoring","Works with existing RTSP/ONVIF cameras","No port forwarding required","Dedicated support team"].join(`
354`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Ready to Secure Your Locations?"},{key:"cta.subheading",label:"CTA subheading",def:"Join food service operators who have already cut investigation time and protected their business with {productName}.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your locations and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"How many locations?"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Tell us about your setup..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},fte={key:"solutions.retail",title:"Solutions: Retail",group:"Solutions",fields:[{key:"hero.badge",label:"Hero badge",def:"Solutions · Retail"},{key:"hero.heading",label:"Hero heading (lines)",def:`Stop Shrinkage.
355Protect Every Location.`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} gives retail operators AI-powered surveillance, cloud-backed evidence retention, and centralized visibility across every store — without replacing existing cameras.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"trustedBy.heading",label:"Trusted-by heading",def:"Trusted By Leading Retail Brands"},{key:"trustedBy.names",label:"Trusted-by names",def:["Planet Fitness","Fluent Cannabis","Douglas Elliman","Brenntag","Vepo Solutions"].join(`
356`),multiline:!0,help:"One company name per line."},{key:"challenges.eyebrow",label:"Challenges eyebrow",def:"The Problem"},{key:"challenges.heading",label:"Challenges heading",def:"What Retailers Struggle With"},{key:"challenges.subheading",label:"Challenges subheading",def:"Theft, blind spots, and slow investigations are costing you more than you realize."},{key:"challenges.items",label:"Challenge cards",def:["Shrinkage & Theft | Retail shrinkage from shoplifting, employee theft, and organized retail crime costs the industry billions each year. Without AI-powered detection, incidents are only discovered after the fact.","Blind Spots Across 
356Locations | Multi-location retailers struggle to maintain consistent camera coverage. When a system goes down at one store, no one knows until a manager walks in — by then, footage is already lost.","No Central Visibility | Loss prevention and regional managers shouldn't need to call individual stores to pull footage. Traveling to review an incident takes hours and costs money that erodes your margins.","Evidence When You Need It | Slip-and-fall claims, disputes, and theft investigations require footage that can be days or weeks old. On-premise DVRs are often overwritten before anyone knows an incident occurred."].join(`
357`),multiline:!0,help:'One card per line: "Title | Description". Icons are set per position below.'},{key:"challenges.icons",label:"Challenge card icons",def:["TrendingDown","AlertTriangle","MapPin","Lock"].join(`
358`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the challenge cards above."},{key:"features.eyebrow",label:"Features eyebrow",def:"The Solution"},{key:"features.heading",label:"Features heading",def:"Built for Retail Loss Prevention"},{key:"features.subheading",label:"Features subheading",def:"From single storefronts to national chains, {productName} scales with your footprint."},{key:"features.items",label:"Feature cards",def:["AI Event Search | Search for a person, clothing color, license plate, or object across any camera at any store — in seconds. Find the exact frame without scrubbing hours of footage.","Multi-Store Live View | Watch any camera at any location in real time from one dashboard. Monitor high-risk areas like entrances, fitting rooms, and self-checkout simultaneously.","Cloud Storage Up to 5 Years | Footage syncs automatically to Google Cloud Storage. Even if a local drive is damaged or stolen, your recordings are safe and accessible for investigations and legal proceedings.","Instant Camera-Down Alerts | Get notified the moment any camera or device goes offline — before a blind spot becomes a liability. Automated alerts mean your loss prevention team always knows the system status.","Role-Based Access by Location | Store managers see only their own cameras. Regional directors see their district. Corporate loss prevention sees everything. Permissions are set once and enforced automatically.","Works With Your Existing Cameras | No rip-and-replace required. {productName} connects to any RTSP or ONVIF-compatible camera, DVR, or NVR already installed in your stores."].join(`
359`),multiline:!0,help:'One card per line: "Title | Description". Icons are set per position below.'},{key:"features.icons",label:"Feature card icons",def:["Search","Eye","Cloud","Bell","Users","ShieldCheck"].join(`
360`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the feature cards above."},{key:"stats.items",label:"Stat highlights",def:["99.9% | Google Cloud Uptime Guarantee","5 Years | Maximum Evidence Retention","<60s | Average Clip Retrieval Time"].join(`
361`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"testimonial.quote",label:"Testimonial quote",def:"We used to have a loss prevention team member drive to stores to pull footage. Now I can search any camera at any location from my desk and have a clip ready for law enforcement within minutes.",multiline:!0},{key:"testimonial.name",label:"Testimonial name",def:"Sandra K."},{key:"testimonial.role",label:"Testimonial role",def:"Director of Loss Prevention"},{key:"testimonial.company",label:"Testimonial company",def:"Multi-Location Retail Chain"},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Everything You Need From Day One"},{key:"included.items",label:"What's-included checklist",def:["Centralized multi-store dashboard","Live view for any camera at any location","Cloud recording up to 5 years","AI search — person, vehicle, plates, objects","Role-based access by store, district, or region","Instant camera offline alerts","Works with existing RTSP/ONVIF cameras","No port forwarding — plug & play setup","Exportable clips for law enforcement","Dedicated support team"].join(`
362`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Ready to Protect Your Stores?"},{key:"cta.subheading",label:"CTA subheading",def:"Join retail operators already cutting shrinkage and closing investigations faster with {productName}.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your stores and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"How many locations?"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Tell us about your setup — number of stores, cameras, current system..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},gte={key:"features.cloudVideoSurveillance",title:"Feature: Cloud Video Surveillance",group:"Feature Pages",fields:[{key:"hero.badge",label:"Hero badge",def:"Cloud Video Surveillance"},{key:"hero.heading",label:"Hero heading (lines)",def:`Your Footage, Safe in
363Google Cloud.`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} devices stream recordings directly to Google Cloud Storage — protecting your footage from hard drive failures, theft, and claims that surface months later.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"heroImage.alt",label:"Hero image alt text",def:"{productName} cloud storage powered by Google Cloud"},{key:"howItWorks.eyebrow",label:"How-it-works eyebrow",def:"How It Works"},{key:"howItWorks.heading",label:"How-it-works heading",def:"Recorded Locally. Backed Up to the Cloud."},{key:"howItWorks.subheading",label:"How-it-works subheading",def:"Every {productName} device pairs reliable on-site recording with secure, redundant cloud backup — automatically."},{key:"howItWorks.items",label:"How-it-works steps",def:["01 | Edge Device Records Locally | Your {productName} device records continuously to local storage, so live view, playback, and AI work even if the internet drops.","02 | Bandwidth Safe | The edge device processes camera streams locally and only uploads finished recordings — eliminating the heavy upload bandwidth normally required to stream every camera over the internet.","03 | Multi-Region Redundancy | Cloud copies live in Google's multi-region buckets with 99.9% uptime. Hard drive failures, theft, or on-site damage no longer mean lost footage.","04 | Retrieve From Anywhere | Play back, download, or AI-search cloud recordings from any browser. Configure retention from 14 days to 5 years per device."].join(`
364`),multiline:!0,help:'One step per line: "Step | Title | Description".'},{key:"useCases.eyebrow",label:"Use-cases eyebrow",def:"Why Cloud Storage"},{key:"useCases.heading",label:"Use-cases heading",def:"When On-Site Storage Isn't Enough"},{key:"useCases.items",label:"Use-case cards",def:["Liability & Legal Claims | Most slip-and-fall, workplace, and customer dispute claims surface months after the incident. Cloud retention keeps the footage available long after local drives have overwritten it.","Hard Drive Failure Protection | Local drives fail. Cloud recordings remain intact and instantly accessible — no truck roll, no on-site recovery, no missed evidence.","Multi-Site Operations | Manage footage from every location in one dashboard. No VPNs, no port forwarding, no per-site DVR logins — just sign in and search.","Compliance & Audit | Meet retention requirements for healthcare, cannabis, education, and government with configurable per-device retention policies and full audit logs."].join(`
365`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"useCases.icons",label:"Use-case card icons",def:["Scale","HardDrive","Building2","Briefcase"].join(`
366`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the use-case cards above."},{key:"stats.items",label:"Stat highlights",def:["99.9% | Google Cloud Uptime","Up to 5 Years | Cloud Retention","Multi-Region | Built-In Redundancy"].join(`
367`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"security.eyebrow",label:"Security eyebrow",def:"Security & Privacy"},{key:"security.heading",label:"Security heading",def:"Encrypted, Audited, and Yours"},{key:"security.items",label:"Security cards",def:["Encrypted End-to-End | Footage is encrypted in transit and at rest inside Google Cloud — only your authorized users can decrypt and view recordings.","Direct-to-Cloud Uploads | Edge devices upload to Google Cloud using signed URLs — your video bypasses our application servers entirely.","Multi-Region Resilience | Google's global infrastru
367cture replicates your footage across regions for 99.9% uptime and disaster resilience."].join(`
368`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"security.icons",label:"Security card icons",def:["Lock","ShieldCheck","Globe2"].join(`
369`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the security cards above."},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Everything You Need to Store, Search, and Retrieve"},{key:"included.items",label:"What's-included checklist",def:["Direct edge-to-Google Cloud Storage uploads","Multi-region redundancy with 99.9% uptime","Per-device retention from 14 days to 5 years","Encrypted in transit and at rest","Signed URLs — footage never touches our servers","Browser playback from anywhere — no VPN required","Cloud AI Text Search and Visual Comparisons","Audit log of every download and access event","Pay-as-you-go per-camera pricing","Works alongside or instead of local storage"].join(`
370`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Stop Worrying About Lost Footage"},{key:"cta.subheading",label:"CTA subheading",def:"Cloud Video Surveillance is included with every {productName} cloud-enabled subscription."},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your setup and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your setup"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of cameras, sites, retention needs..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},xte={key:"features.deviceNotifications",title:"Feature: Device Notifications",group:"Feature Pages",fields:[{key:"hero.badge",label:"Hero badge",def:"Device Notifications"},{key:"hero.heading",label:"Hero heading (lines)",def:`Know the Moment
371Something Goes Down.`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} continuously monitors every device and camera and emails you the instant something goes offline — so you find out before your customer does.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"heroImage.alt",label:"Hero image alt text",def:"{productName} device notifications"},{key:"howItWorks.eyebrow",label:"How-it-works eyebrow",def:"How It Works"},{key:"howItWorks.heading",label:"How-it-works heading",def:"Always Watching the Watchers."},{key:"howItWorks.subheading",label:"How-it-works subheading",def:"{productName} monitors device and camera health around the clock and alerts you the moment something needs attention."},{key:"howItWorks.items",label:"How-it-works steps",def:["01 | Continuous Health Monitoring | Every {productName} device and every connected camera is checked on a regular interval — uptime, reachability, recording status, and stream health are all tracked automatically.","02 | Instant Outage Alerts | If a device or camera goes offline, an email alert is sent within minutes — so you find out before your customer does.","03 | Automatic Recovery Notifications | When the device or camera comes back online, a recovery email is sent automatically. You always know the current state without checking the dashboard.","04 | Weekly Health Summary | A weekly digest summarizes uptime, outages, and recoveries across every device you manage — perfect for SLA reporting and proactive maintenance."].join(`
372`),multiline:!0,help:'One step per line: "Step | Title | Description".'},{key:"useCases.eyebrow",label:"Use-cases eyebrow",def:"Use Cases"},{key:"useCases.heading",label:"Use-cases heading",def:"Catch Problems Before They Cost You"},{key:"useCases.items",label:"Use-case cards",def:["Camera Disconnects | Get notified the moment a camera drops off the network — a cut cable, PoE switch failure, or unplugged camera is caught immediately, not days later.","Site Internet Outages | When an entire site loses connectivity, you're alerted right away. Combined with local recording, you know footage is safe even while you wait for the link to restore.","Recording Verification | Catch silent failures: a camera that streams live but isn't recording, or a device that's online but has stopped writing footage. Notifications surface these issues before they cost you evidence.","Proactive Maintenance | Weekly summaries surface recurring outages and flaky cameras so you can schedule maintenance before they become emergencie
372s."].join(`
373`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"useCases.icons",label:"Use-case card icons",def:["Camera","Wifi","ShieldCheck","Calendar"].join(`
374`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the use-case cards above."},{key:"stats.items",label:"Stat highlights",def:["24/7 | Continuous Monitoring","Email / SMS / Push | Per-User Alert Preferences","Weekly | Health Summary Digest"].join(`
375`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"alertTypes.eyebrow",label:"Alert-types eyebrow",def:"Alert Types"},{key:"alertTypes.heading",label:"Alert-types heading",def:"Every Event That Matters"},{key:"alertTypes.items",label:"Alert-type cards",def:["Outage Alerts | Emailed within minutes when a device or camera stops responding, so you can act before footage gaps form.","Recovery Alerts | An automatic follow-up when the device or camera comes back online — confirming the issue is resolved.","Weekly Summary | A digest of uptime, outages, and recoveries across every device — ideal for SLA reporting and reviews."].join(`
376`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"alertTypes.icons",label:"Alert-type card icons",def:["AlertTriangle","RefreshCw","Activity"].join(`
377`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the alert-type cards above."},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Monitoring You Don't Have to Think About"},{key:"included.items",label:"What's-included checklist",def:["Per-device online/offline monitoring","Per-camera stream health checks","Instant outage email alerts","Automatic recovery notifications","Weekly health summary digest","Per-user notification preferences","Configurable alert thresholds","Multi-site coverage in one dashboard","Works alongside Smart AI Alerts","No extra fees — included with every subscription"].join(`
378`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Never Be the Last to Know."},{key:"cta.subheading",label:"CTA subheading",def:"Device Notifications are included with every {productName} subscription."},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your setup and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your setup"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of cameras, sites, monitoring needs..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},vte={key:"features.facesPeople",title:"Feature: Faces & People",group:"Feature Pages",fields:[{key:"hero.badge",label:"Hero badge",def:"Features · Faces & People"},{key:"hero.heading",label:"Hero heading (lines)",def:`Know Who's There
379Before You Ask`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName}'s Faces & People feature lets you build a named library of individuals and automatically recognize them across every camera — alerting your team the moment a known face appears.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"heroImage.alt",label:"Hero image alt text",def:"Faces & People library showing enrolled persons with reference photos"},{key:"searchImage.alt",label:"Search image alt text",def:"AI Search results showing face recognition matches for Henry across multiple cameras"},{key:"howItWorks.eyebrow",label:"How-it-works eyebrow",def:"How It Works"},{key:"howItWorks.heading",label:"How-it-works heading",def:"Enroll Once. Recognize Everywhere."},{key:"howItWorks.subheading",label:"How-it-works subheading",def:"Add a person to your library and every camera across every site watches for them automatically."},{key:"howItWorks.items",label:"How-it-works steps",def:["01 | Build Your People Library | Upload 1–6 reference photos per person directly in {productName}. The system enrolls each face using InsightFace biometric embeddings — storing only the mathematical representation, never raw imagery on the device.","02 | Real-Time Recognition Across All Cameras | As footage streams in from every camera, {productName} compares detected faces against your enrolled library. Matches are scored by similarity, so you control how strict the threshold is per person.","03 | Smart Alert on Recognition | When a known person is identified — whether a VIP guest, a banned individual, or a key employee — your team receives an instant alert with the camera feed, matched name, and confidence score.","04 | Search by Name in Recordings | Use natural language search to find footage of a specific person across any date range. Type a name and the system retrieves every clip where that individual was identified — across all sites."].join(`
380`),multiline:!0,help:'One step per line: "Step | Title | Description".'},{key:"useCases.eyebrow",label:"Use-cases eyebrow",def:"Use Cases"},{key:"useCases.heading",label:"Use-cases heading",def:"Who You're Looking For"},{key:"useCases.items",label:"Use-case cards",def:["Banned Person Tracking | Enroll individuals who have been issued trespass notices. Receive an instant alert the moment they enter any of your locations — before your staff even makes contact.","VIP & Executive Recognition | Flag the arrival of key executives, high-value guests, or board members so the right team members are notified and waiting — without requiring check-in or badge scanning.","Employee & Contractor Verification | Confirm that only authorized personnel access restricted areas. When someone not in your approved list appears in a sensitive zone, your security team is alerted immediately.","Missing Persons & Child Safety | Schools and care facilities can enroll approved guardians and receive alerts when an unrecognized adult approaches a restricted zone — adding an intelligence layer to physical access controls."].join(`
381`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"useCases.icons",label:"Use-case card icons",def:["Lock","UserCheck","Shield","Building2"].join(`
382`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the use-case cards above."},{key:"stats.items",label:"Stat highlights",def:["6 | Reference Photos Per Person","512-D | Biometric Embedding Precision","<1s | Match Response Time"].join(`
383`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Identity-Aware Security at Scale"},{key:"included.items",label:"What's-included checklist",def:["Per-person face library with 1–6 reference photos","InsightFace buffalo_l biometric matching engine","Configurable match threshold per person","Instant alerts on recognition with snapshot","Search recordings by person name","Hybrid AI rout
383ing — face-rec first, OpenAI fallback","Admin-only library management","No biometrics stored on edge devices","Works across all sites and cameras simultaneously","Full audit log of all recognition events"].join(`
384`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Start Recognizing the People Who Matter"},{key:"cta.subheading",label:"CTA subheading",def:"Faces & People is included with AI+ on any {productName} subscription. No additional hardware required."},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your facility and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your setup"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of cameras, locations, use case..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},yte={key:"features.naturalTextSearch",title:"Feature: Natural Text Search",group:"Feature Pages",fields:[{key:"hero.badge",label:"Hero badge",def:"Features · Natural Text Search"},{key:"hero.heading",label:"Hero heading (lines)",def:`Search Your Footage
385Like You Search the Web`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"Describe what you're looking for in plain English and {productName} finds it — across every camera, every location, every recording. No timestamps. No camera names. No scrubbing.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"examples.heading",label:"Examples heading",def:"What You Can Search"},{key:"examples.items",label:"Example queries",def:["Man in red jacket near the entrance | Finds all matching clips across every camera, any date","Two people arguing in the parking lot | Surfaces incidents from motion events within seconds","Delivery driver dropping off packages | Identifies arrival times without scrubbing through hours of footage","Someone leaving without paying | Pulls timestamped clips to support loss prevention investigations"].join(`
386`),multiline:!0,help:'One example per line: "Query | Result".'},{key:"howItWorks.eyebrow",label:"How-it-works eyebrow",def:"How It Works"},{key:"howItWorks.heading",label:"How-it-works heading",def:"From Question to Footage in Seconds"},{key:"howItWorks.items",label:"How-it-works steps",def:["01 | Type What You're Looking For | Describe the event in plain language — exactly as you'd explain it to a colleague. No Boolean operators, no timestamps required, no camera names to memorize.","02 | AI Scans Your Footage Library | {productName} sends your query to GPT-4o Vision, which evaluates event thumbnails from your recordings to find visual matches — scanning thousands of clips in seconds.","03 | Results With Deep Links | Every matched result shows the thumbnail, camera name, site, and timestamp. One click opens the exact moment in your recordings player — local or cloud.","04 | Combine With Face Recognition | Mention a name from your Faces & People library in your search query and {brandName} automatically routes through face recognition first — no AI quota consumed until needed."].join(`
387`),multiline:!0,help:'One step per line: "Step | Title | Description".'},{key:"useCases.eyebrow",label:"Use-cases eyebrow",def:"Use Cases"},{key:"useCases.heading",label:"Use-cases heading",def:"Built for Investigations, Not Just Monitoring"},{key:"useCases.items",label:"Use-case cards",def:["Incident Investigation | Describe what happened and find the footage in under 60 seconds. Eliminate hours of manual scrubbing across multiple cameras and recorders.","Insurance & Legal Claims | Quickly produce timestamped footage that supports or refutes a claim. Search by incident description rather than hunting through camera-by-camera recordings.","Loss Prevention | Detect patterns — recurring behavior near high-value areas, unusual activity at specific times — by searching across weeks of footage in natural language.","Customer Experience Reviews | Hospital
387ity and retail teams can search for specific service interactions, verify procedures were followed, or audit how staff handled a situation."].join(`
388`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"useCases.icons",label:"Use-case card icons",def:["ShieldCheck","FileText","Building2","Eye"].join(`
389`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the use-case cards above."},{key:"stats.items",label:"Stat highlights",def:["<60s | Average Search Time","GPT-4o | Vision Model Powering Search","Cloud + Local | Searches Across Both Archives"].join(`
390`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Find What Happened, Fast"},{key:"included.items",label:"What's-included checklist",def:["Natural language search across all recordings","GPT-4o Vision for visual content matching","Search local edge archives and cloud storage","Thumbnail previews for every result","One-click deep link to exact footage moment","Hybrid routing with Faces & People recognition","Daily AI+ usage limits with audit log","Per-device AI+ enable/disable control","Works across all cameras and all sites","Results in seconds, not hours"].join(`
391`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Stop Scrubbing. Start Searching."},{key:"cta.subheading",label:"CTA subheading",def:"Natural Text Search is available with AI+ on any {productName} subscription. No additional hardware required."},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your setup and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your setup"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of cameras, sites, what you're investigating..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},bte={key:"features.objectDetection",title:"Feature: Object Detection",group:"Feature Pages",fields:[{key:"hero.badge",label:"Hero badge",def:"Features · Object Detection"},{key:"hero.heading",label:"Hero heading (lines)",def:`See Everything.
392Miss Nothing.`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} uses on-device AI to detect people, vehicles, packages, and more in real time — across every camera, every site, without sending a single frame to the cloud.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"detectable.eyebrow",label:"Detectable eyebrow",def:"What It Detects"},{key:"detectable.items",label:"Detectable chips",def:["People","Vehicles","Packages","Animals","Custom Objects"].join(`
393`),multiline:!0,help:"One label per line. Icons are fixed per position."},{key:"detectable.icons",label:"Detectable object icons",def:["Users","Car","Package","Eye","Eye"].join(`
394`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the detectable labels above."},{key:"howItWorks.eyebrow",label:"How-it-works eyebrow",def:"How It Works"},{key:"howItWorks.heading",label:"How-it-works heading",def:"On-Device AI, Zero Latency"},{key:"howItWorks.subheading",label:"How-it-works subheading",def:"Detection runs locally on your edge device. No footage ever leaves your site for analysis."},{key:"howItWorks.items",label:"How-it-works steps",def:["01 | Continuous Frame Analysis | Powered by our local AI inference engine, object detection runs directly on your edge device — processing every camera frame without sending footage to the cloud. Detection is instant, private, and reliable even without internet.","02 | Bounding Box & Classification | Every detected object is classified by type, confidence score, and location within the frame. The engine tracks object movement across frames, distinguishing genuine entries from stationary objects or camera artifacts.","03 | Configurable Per-Camera Rules | Set detection zones, object types, and confidence thresholds on a per-camera basis. Ignore the parking lot during business hours. Alert only when a person enter
394s the loading dock after midnight.","04 | Trigger Smart Alerts | Object detections feed directly into Smart AI Alerts. When a detection matches your rules — right object, right zone, right time — your team is notified instantly with a snapshot and clip."].join(`
395`),multiline:!0,help:'One step per line: "Step | Title | Description".'},{key:"useCases.eyebrow",label:"Use-cases eyebrow",def:"Use Cases"},{key:"useCases.heading",label:"Use-cases heading",def:"Intelligent Awareness for Any Environment"},{key:"useCases.items",label:"Use-case cards",def:["Vehicle Monitoring | Track vehicle arrivals, departures, and dwell times in parking lots, loading bays, and driveways. Alert on unauthorized vehicles in restricted zones after hours.","Package & Asset Tracking | Monitor loading docks and mailrooms for package arrivals, pickups, and abandoned items. Get alerted when a package remains in an area longer than expected.","Perimeter Intrusion | Define restricted zones and receive instant alerts when a person is detected inside them — whether a loading bay, server room, or property boundary.","Occupancy Counting | Use object detection data to understand foot traffic patterns, peak occupancy hours, and movement flows across your facility — without additional sensors."].join(`
396`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"useCases.icons",label:"Use-case card icons",def:["Car","Package","Users","Building2"].join(`
397`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the use-case cards above."},{key:"stats.items",label:"Stat highlights",def:["On-Device | AI Inference — No Cloud Required","50+ | Detectable Object Classes","Real-Time | Frame-by-Frame Analysis"].join(`
398`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Detection That Runs Itself"},{key:"included.items",label:"What's-included checklist",def:["Local AI inference on the edge device (no cloud required)","Person, vehicle, animal, and package detection","Configurable detection zones per camera","Confidence threshold control per object type","Object tracking across consecutive frames","Integration with Smart AI Alert rules","Detection events stored with thumbnail snapshots","Cloud backup of all detection clips","Works with any RTSP/ONVIF camera","No ongoing AI API costs for detection"].join(`
399`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Add AI Object Detection to Any Camera"},{key:"cta.subheading",label:"CTA subheading",def:"Object Detection is included with every {productName} subscription. No additional hardware or cloud fees for detection.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your setup and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your setup"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of cameras, sites, detection needs..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},wte={key:"features.ptzFisheye",title:"Feature: PTZ & Fisheye",group:"Feature Pages",fields:[{key:"hero.badge",label:"Hero badge",def:"PTZ & Fisheye Integration"},{key:"hero.heading",label:"Hero heading (lines)",def:`Pan, Tilt, Zoom —
400and See Every Angle.`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"Full ONVIF Profile S control for any PTZ camera, plus on-the-fly fisheye dewarping — all from one browser tab, no extra software required.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"howItWorks.eyebrow",label:"How-it-works eyebrow",def:"How It Works"},{key:"howItWorks.heading",label:"How-it-works heading",def:"Plug In. Discover. Control."},{key:"howItWorks.subheading",label:"How-it-works subheading",def:"{productName} detects PTZ and fisheye cameras automatically and gives every operator the controls they need — right where they're looking."},{key:"howItWorks.items",label:"How-it-works steps",def:["01 | Auto-Detect PTZ Cameras | During camera discovery, {productName} probes each camera over ONVIF Profile S and automatically identifies pan/tilt/zoom capability — no manual configuration required.","02 | Live On-Screen Controls | PTZ cameras get an on-screen control pad overlay in live and multi-view: 8-direction pan/tilt, zoom in/out, home, and presets — all driven from the browser.","03 | Save & Recall Presets | Save unlimited camera positions as 
400named presets. Operators can recall any preset with a single tap; admins control who can set or delete them.","04 | Fisheye Dewarping | Fisheye cameras get on-the-fly dewarping — view the full 360° panorama, split into four quadrants, or virtually pan and zoom within a single fisheye stream."].join(`
401`),multiline:!0,help:'One step per line: "Step | Title | Description".'},{key:"capabilities.eyebrow",label:"Capabilities eyebrow",def:"Capabilities"},{key:"capabilities.heading",label:"Capabilities heading",def:"Everything You Expect From a Pro NVR"},{key:"capabilities.items",label:"Capability cards",def:["Full ONVIF Profile S Control | Continuous pan/tilt with mousedown-and-hold, absolute and relative positioning, plus zoom in/out — all over the open ONVIF standard.","Unlimited Presets | Save any camera position as a named preset. Operators can jump to any preset instantly from the live view.","Fisheye Dewarping Views | Choose 360° panorama, quad-view, or virtual PTZ — one fisheye replaces four traditional cameras and lets you re-frame after the fact.","Home Position | Send the camera back to its default position with a single click — perfect for guarded entrances or patrol routes.","Multi-View Aware | PTZ controls appear on the selected cell in any grid layout — operate any camera in any view without leaving multi-view.","Permission Enforced | Camera-level permissions apply to every PTZ command. Restricted users can't move cameras they aren't allowed to see."].join(`
402`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"capabilities.icons",label:"Capability card icons",def:["Move","Star","Aperture","Compass","Layers","Eye"].join(`
403`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the capability cards above."},{key:"useCases.eyebrow",label:"Use-cases eyebrow",def:"Use Cases"},{key:"useCases.heading",label:"Use-cases heading",def:"Where PTZ & Fisheye Shine"},{key:"useCases.items",label:"Use-case cards",def:["Parking Lots & Yards | One PTZ camera covers a large area at low detail, then zooms in on demand for license plates, faces, or incidents.","Retail & Warehouses | A single fisheye covers an entire aisle or floor area, replacing several fixed cameras and providing full 360° awareness.","Guard-Tour Workflows | Pre-set positions for entrances, loading docks, and perimeter points let operators run a virtual patrol without leaving the dashboard.","Investigations & Evidence | Recall a preset to verify a known angle, or zoom in live during an incident — all controls are logged for audit."].join(`
404`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"useCases.icons",label:"Use-case card icons",def:["MapPin","Maximize2","RotateCw","ZoomIn"].join(`
405`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the use-case cards above."},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"A Full PTZ & Fisheye Toolkit"},{key:"included.items",label:"What's-included checklist",def:["Automatic PTZ detection via ONVIF Profile S","On-screen pan/tilt/zoom control pad","Continuous, absolute, and relative move","Unlimited named presets","Per-channel ONVIF credential storage","Fisheye dewarping (360°, quad, virtual PTZ)","PTZ in live and multi-view layouts","Permission-enforced for every command","Admin-only set/delete preset control","Works with any ONVIF Profile S camera"].join(`
406`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Cover More With Fewer Cameras."},{key:"cta.subheading",label:"CTA subheading",def:"PTZ & Fisheye integration is included with every {productName} device — no add-on licenses.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your setup and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your setup"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of cameras, sites, PTZ needs..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},jte={key:"features.smartAiAlerts",title:"Feature: Smart AI Alerts",group:"Feature Pages",fields:[{key:"hero.badge",label:"Hero badge",def:"Features · Smart AI Alerts"},{key:"hero.heading",label:"Hero heading (lines)",def:`The Right Alert,
407at the Right Moment`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"Smart AI Alerts combine object detection, face recognition, and AI vision into configurable rules that notify your team the instant something that matters happens — with the evidence attached.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"ruleTypes.eyebrow",label:"Rule-types eyebrow",def:"Rule Types"},{key:"ruleTypes.items",label:"Rule-type cards",def:["Object Detection | Person enter
407s restricted zone after hours. Vehicle present in loading bay for over 10 minutes.","Known Persons | Alert when a banned individual or recognized VIP is detected on any camera.","AI Action & Search | Alert when a visual event matches a natural language description — e.g. 'person climbing fence'.","Combined Rules | Trigger only when multiple conditions are met simultaneously — object + location + time window."].join(`
408`),multiline:!0,help:'One card per line: "Label | Description". Icons are fixed per position.'},{key:"ruleTypes.icons",label:"Rule-type card icons",def:["Eye","Users","Zap","Filter"].join(`
409`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the rule-type cards above."},{key:"howItWorks.eyebrow",label:"How-it-works eyebrow",def:"How It Works"},{key:"howItWorks.heading",label:"How-it-works heading",def:"Set It and Know Instantly"},{key:"howItWorks.subheading",label:"How-it-works subheading",def:"Define what matters. {productName} watches for it continuously and alerts you the moment it happens."},{key:"howItWorks.items",label:"How-it-works steps",def:["01 | Build a Rule in Minutes | Define what should trigger an alert: a specific object type, a detected face, an AI text match, or any combination. Scope it to specific cameras, time windows, and days of the week — no code required.","02 | Detection Triggers the Rule | As object detection, face recognition, or AI analysis events stream in, {productName} evaluates them against your active rules in real time. Cooldown periods and rate limits prevent alert fatigue.","03 | Instant Multi-Channel Notification | Matched events immediately push alerts to your configured channels — SMS, email, and in-app — with a thumbnail, camera name, site, detection label, and a direct link to the recording.","04 | Triage and Track in the Dashboard | All triggered events land in the Smart Alerts triage feed. Your team can mark events as Reviewed or Critical, add notes, and track response — building a complete incident audit trail."].join(`
410`),multiline:!0,help:'One step per line: "Step | Title | Description".'},{key:"useCases.eyebrow",label:"Use-cases eyebrow",def:"Use Cases"},{key:"useCases.heading",label:"Use-cases heading",def:"Alert on What Actually Matters"},{key:"useCases.items",label:"Use-case cards",def:["After-Hours Intrusion | Alert security the moment a person is detected inside a restricted zone outside business hours — before they've had time to cause damage.","Loading Dock Monitoring | Know instantly when a delivery arrives, how long a vehicle has been waiting, or when a zone has been occupied beyond the expected dwell time.","Behavioral Pattern Alerts | Use AI text-based rules to detect specific behaviors — loitering, tailgating, or crowds forming near high-value areas — with natural language precision.","Schedule-Aware Monitoring | Rules activate and deactivate automatically based on your custom schedule — no need to manually toggle alerts for shift changes, weekends, or holidays."].join(`
411`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"useCases.icons",label:"Use-case card icons",def:["AlertTriangle","Building2","ShieldCheck","Clock"].join(`
412`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the use-case cards above."},{key:"stats.items",label:"Stat highlights",def:["4 | Rule Types — Object, Face, AI, Combined","3-Channel | SMS · Email · In-App Alerts","Full Log | Every Event Triaged & Audited"].join(`
413`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Alerts Without the Noise"},{key:"included.items",label:"What's-included checklist",def:["Unlimited smart alert rules per device","Object, face, AI text, and combined rule types","Per-camera and per-zone rule scoping","Time-window and day-of-week scheduling","Configurable cooldown periods per rule","Rate limiting to prevent alert fatigue","SMS, email, and in-app notification channels","Thumbnail + deep link in every alert","Triage feed: Not Reviewed / Critical / Reviewed","Full audit log with reviewer attribution"].join(`
414`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Build Your First Alert Rule in Minutes"},{key:"cta.subheading",label:"CTA subheading",def:"Smart AI Alerts are included with every {productName} subscription. Advanced rule types require AI+.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your setup and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your setup"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of cameras, sites, alert use case..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},Nte={key:"features.visualComparisons",title:"Feature: Visual Comparisons",group:"Feature Pages",fields:[{key:"hero.badge",label:"Hero badge",def:"Features · Visual Comparisons"},{key:"hero.heading",label:"Hero heading (lines)",def:`Draw a Box.
415Find It Everywhere Else.`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"Draw a box around any person, vehicle, or object in your footage, and {productName} finds where else it appears across your other cameras at different times.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"howItWorks.eyebrow",label:"How-it-works eyebrow",def:"How It Works"},{key:"howItWorks.heading",label:"How-it-works heading",def:"Box It Once. Track It Everywhere."},{key:"howItWorks.subheading",label:"How-it-works subheading",def:"Visual Comparisons uses AI vision to find where your selection a
415ppears across every other camera and time range in seconds."},{key:"howItWorks.items",label:"How-it-works steps",def:["01 | Draw a Box Around Anything | While reviewing footage, simply draw a box around any person, vehicle, or object on screen. No uploads, no separate reference photos — your selection becomes the search query.","02 | AI Scans Your Other Cameras | GPT-4o Vision takes your boxed selection and compares it against recordings from every other camera and site, across whatever time range you choose.","03 | See Where Else It Appeared | Results are ranked by visual similarity, showing the camera, timestamp, and a thumbnail for each match — so you can confirm the right sighting at a glance.","04 | Jump Straight to the Moment | One click from any result opens the recording at the exact timestamp — in your cloud archive or local edge recordings, whichever holds the clip."].join(`
416`),multiline:!0,help:'One step per line: "Step | Title | Description".'},{key:"useCases.eyebrow",label:"Use-cases eyebrow",def:"Use Cases"},{key:"useCases.heading",label:"Use-cases heading",def:"From Investigations to Evidence"},{key:"useCases.items",label:"Use-case cards",def:["Clothing & Appearance Matching | Identify where a person in a specific outfit appeared across your site — tracking their path from entrance to exit, or across multiple visits on different days.","Vehicle Re-Identification | Match a specific vehicle by make, model, color, or partial license plate across cameras — even between sites. Trace routes, dwell times, and departure patterns.","Evidence Correlation | Spot a suspect or vehicle of interest on one camera, draw a box around them, and instantly surface every other time they appeared on your other cameras.","Insurance & Liability Support | When a claim involves a specific person or vehicle, visual comparison search produces the footage evidence needed for documentation, subrogation, or dispute resolution."].join(`
417`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"useCases.icons",label:"Use-case card icons",def:["Users","Building2","ShieldCheck","FileText"].join(`
418`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the use-case cards above."},{key:"stats.items",label:"Stat highlights",def:["GPT-4o | Vision Model for Comparison","Multi-Site | Search Across All Cameras","Box It | Person, Vehicle, or Object"].join(`
419`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"See What Matches. Act on It Fast."},{key:"included.items",label:"What's-included checklist",def:["Draw-a-box selection directly on any frame","Visual similarity matching via GPT-4o Vision","Cross-camera and cross-site search","Search across any date and time range","Ranked results by visual confidence","Thumbnail preview for every match","One-click deep link to exact recording moment","Searches local and cloud archives simultaneously","Admin-configurable daily AI+ usage limits","Full audit log of all search activity"].join(`
420`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Turn Any On-Screen Object Into a Search Query"},{key:"cta.subheading",label:"CTA subheading",def:"Visual Comparisons is available with AI+ on any {productName} subscription.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your setup and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your setup"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of cameras, sites, investigation needs..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},Ste={key:"features.weaponDetection",title:"Feature: Weapon Detection",group:"Feature Pages",fields:[{key:"hero.badge",label:"Hero badge",def:"Features · Weapon Detection"},{key:"hero.heading",label:"Hero heading (lines)",def:`AI Weapon Detection,
421Built Into Every Camera`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"{productName} analyzes live footage from every camera in real time — identifying firearms, blades, and other threats the moment they appear, and alerting your team before an incident escalates.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Get Started Free"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Talk to Sales"},{key:"howItWorks.eyebrow",label:"How-it-works eyebrow",def:"How It Works"},{key:"howItWorks.heading",label:"How-it-works heading",def:"From Detection to Alert in Seconds"},{key:"howItWorks.subheading",label:"How-it-works subheading",def:"The entire pipeline — from frame capture to security notification — runs continuously without human intervention."},{key:"howItWorks.items",label:"How-it-works steps",def:["01 | Continuous Frame Analysis | Every frame from every connected camera is analyzed in real time by {productName}'s AI engine, looking for the visual signature of firearms, blades, and other prohibited items — without storing biometrics or personally identifiable data.","02 | Instant Threat Classification | When a potential weapon is detected, the system classifies the threat type, confidence score, and camera location within milliseconds. False positives are minimized through multi-frame confirmation before an alert is triggered.","03 | Multi-Channel Alerting | Confirmed detections immediately push alerts to your security team via SMS, email, and in-app notifications — with a direct link to the live feed and a timestamped snapshot of the detection event.","04 | Automatic Clip Capture | The 30 seconds before and after a detection are automatically saved as a clip in your cloud archive, ensuring evidence is preserved even if the local device is tampered with or goes offline."].join(`
422`),multiline:!0,help:'One step per line: "Step | Title | Description".'},{key:"useCases.eyebrow",label:"Use-cases eyebrow",def:"Use Cases"},{key:"useCases.heading",label:"Use-cases heading",def:"Protecting Every Type of Facility"},{key:"useCases.items",label:"Use-case cards",def:["Schools & Universities | Protect students and staff by adding an AI detection layer across every entrance, hallway, and common area — without replacing your existing cameras.","Corporate Campuses | Secure office buildings, data centers, and restricted areas with automatic detection that escalates to security personnel the moment a threat appears.","Venues & Events | Supplement physical screening at stadiums, arenas, and convention centers with real-time video intelligence that monitors every angle simultaneously.","Retail & Hospital
422ity | Protect staff and customers with silent, non-intrusive detection that operates in the background and alerts security without causing public panic."].join(`
423`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"useCases.icons",label:"Use-case card icons",def:["Users","Lock","Radio","AlertTriangle"].join(`
424`),multiline:!0,icon:!0,help:"One lucide icon name per line, aligned with the use-case cards above."},{key:"stats.items",label:"Stat highlights",def:["<500ms | Alert Delivery Time","24/7 | Continuous Monitoring","99.9% | Cloud Clip Retention"].join(`
425`),multiline:!0,help:'One stat per line: "Value | Label".'},{key:"included.eyebrow",label:"What's-included eyebrow",def:"What's Included"},{key:"included.heading",label:"What's-included heading",def:"Everything You Need to Respond Faster"},{key:"included.items",label:"What's-included checklist",def:["Real-time weapon detection across all cameras","Multi-frame confirmation to reduce false positives","Instant SMS, email, and in-app alerts","Auto-captured 60-second evidence clips","Cloud-archived detection events with timestamps","Deep links to exact moment in recordings","Works with any existing RTSP/ONVIF camera","No biometric data stored or processed","Configurable alert groups by site or zone","Audit log of all detections and responses"].join(`
426`),multiline:!0,help:"One checklist item per line."},{key:"cta.heading",label:"CTA heading",def:"Add Weapon Detection to Your Existing Cameras"},{key:"cta.subheading",label:"CTA subheading",def:"No hardware replacement needed. {productName} works with any RTSP or ONVIF camera you already have installed.",multiline:!0},{key:"cta.primaryButton",label:"CTA primary button",def:"Get Started Free"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Talk to Sales"},{key:"contact.title",label:"Contact dialog title",def:"Talk to Sales"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your facility and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your facility"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of cameras, locations, current security setup..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},oN={key:"support.bluDocumentation",title:"Support: Blu Documentation",group:"Support",fields:[{key:"toc.title",label:"Mobile TOC title",def:"Table of Contents"},{key:"sidebar.manualLabel",label:"Sidebar manual label",def:"User Manual"},{key:"sidebar.manualSubtitle",label:"Sidebar manual subtitle",def:"Event Management Portal — v1.50"},{key:"box.importantLabel",label:"Important box label",def:"Important: "},{key:"box.warningLabel",label:"Warning box label",def:"Warning: "},{key:"box.noticeLabel",label:"Notice box label",def:"Notice: "},{key:"hero.badge",label:"Hero badge",def:"Support"},{key:"hero.heading",label:"Hero heading",def:"Blu Documentation"},{key:"hero.subheading",label:"Hero subheading",def:"User Manual for the Event Management Portal — v1.50 series."},{key:"hero.helpPrefix",label:"Hero help prefix",def:"Need help? Contact"},{key:"sections.labels",label:"TOC section labels",def:["Login & Dashboard","Event Retrieval","Live View","Pulse Monitoring","Companies","User Management","Device Configuration","Local Settings","Error Codes","Troubleshooting Tools"].join(`
427`),multiline:!0,help:"One TOC section (group) label per line, in order."},{key:"chapters.titles",label:"Chapter titles",def:["Login Screen","Main Navigational Menu","Dashboard Overview","Dashboard Main Section","Dashboard Search & Scrolling","Event Retrieval","Event Retrieval Basics","Player Functions","Mass Export Events","Live View","Live View Functions","Custom Layouts","Streaming, Bandwidth & Users","Pulse Monitoring","Pulse Monitoring Basics","Device Management","IP Camera Functions","Companies","Manage Companies","Dealer Information","Understanding User Roles","Change Login & Two-Factor Authentication","Change / Forgot Password","Manage Users & Roles","Device Configuration","Device Name & Company","Cloud Storage","Backup Frequency","Alert Notifications","Network & Storage","Device Information & Order","Advanced Settings","Activation Status","Local Settings","Preferences","Database Servers","Stored Credentials","Vault Portal Error Codes","Remote Reboot","Teamviewer Connect"].join(`
428`),multiline:!0,help:"One chapter title per line, in chapter-number order (1–40)."},{key:"player.functions",label:"Player function rows",def:["New Search or Export | Stops the player and starts a new event retrieval search.","Play | Resumes playing the video if paused. Clicking the video image also resumes.","Pause | Pauses the video if playing.","Loop | Repeats the event after fully played. Does not auto-load another event.","Next Event | Automatically loads the next available event after the current finishes.","Reduce Quality | Slightly reduces image quality. Auto-triggers when increasing speed to prioritize playback.","Decrease Speed | Plays an event slower: –2×, –4×, –8×, –16× range.","Increase Speed | Plays an event faster: 2×, 4×, 8×, 16× range.","Snapshot | Exports the current frame as a JPEG file. A save prompt will appear.","Store Event in Raw Format | Saves the event in its original format to a folder you choose."].join(`
429`),multiline:!0,help:'One row per line: "Label | Description". Icons are fixed per position.'},{key:"pulse.topMenuIcons",label:"Pulse top-menu icon rows",def:["Refresh | Manually refreshes the device status.","Preferences | Opens preferences for the application.","Activated | Shows activated bridges and devices only.","Deactivated | Shows deactivated bridges and devices only.","Update Changes | Applies all changes made to devices. Appears when devices have been added, edited, or removed."].join(`
430`),multiline:!0,help:'One row per line: "Label | Description". Icons are fixed per position.'},{key:"errorCodes.items",label:"Error code entries",def:["ER 01 | No Internet has been detected. Internet is required to install this application. | Check your internet connection on your workstation.","ER 02 | A connection error occurred when connecting to the server address. Please verify the address you entered is valid. | Check for a typo in the database server address — reinstalling the application can correct this. | Your firewall or antivirus may be blocking access. | Verify whether the database server is offline.","ER 03 | Could not val
430idate authentication file. | Check firewall or antivirus settings. | Check Windows permissions for the path: C:\\ProgramData\\Proactive-CCTV\\.","ER 04 | Connection denied on TCP port to server. | Check if your IP address is blacklisted. | Check for a temporary port connection issue.","ER 05 | Server authentication is invalid. | The encryption security information on file is incorrect.","ER 06 | Name denied on TCP port to server. | Port socket temporary error — try again.","ER 07 | Connection to the TCP port timed out. | Check firewall or antivirus settings for database server port access. | Check for a temporary port connection issue.","ER 08 | The account information you entered is incorrect. | Verify your email address or username. | Try again — the request may not have been received by the server.","ER 08.1 | The user account selected could not be loaded. | Wait a minute for the server to process recent changes, then try again.","ER 08.5 | The company selected could not be loaded. | Wait a minute for the server to process recent changes, then try again.","ER 09 | The email information is invalid. | Verify the email address or username entered.","ER 10 | The password is invalid. | Verify the password entered.","ER 11 | The account has been set as disabled within your organization. | Contact your administrator to enable the account.","ER 12 | The account has been set as suspended. | Contact administrator support for assistance.","ER 13 | The dealer ID could not be found. | Contact support or retry the request.","ER 14 | The dealer ID is invali
430d. | Contact support or retry the request.","ER 15 | You must be assigned as an administrator to install the client software. | Use an administrator account to install the Hybrid-PRO software.","ER 16 | You do not have any licenses left to activate a client workstation. | Contact {brandName} to purchase additional licenses.","ER 17 | This machine has already been associated with another dealer account. | Remove the bridge from the other dealer account before re-assigning it to this one.","ER 18 / ER 19 | The machine ID could not be found or is invalid. | Contact support or retry the request.","ER 20 | The serial code is incorrect. | Verify the serial code and try again.","ER 21 | The serial code is invalid. | Verify the code or use a new one, then retry the request.","ER 22 | The serial code has already been activated. | Use a new, unused serial code.","ER 23 / ER 24 | The address you have entered is already in the list. | This alert email address already exists — use a different address or remove the existing entry first.","ER 25 | You do not have permission to edit this user. | Request a higher user tier or access level from your administrator.","ER 26 | You do not have permission to manage this setting. | Request a higher user tier or access level from your administrator.","ER 27 | A server error occurred while accessing the manufacturer database. | Contact support.","ER 28 | Camera stream configuration failed to update. | Contact support.","ER 29 | The selected configuration cannot be modified. Copy the configuration to a 'User Live Stream' for editing. | Copy the stream to a User Live Stream bank before making edits.","ER 30 | The stream bank could not be modified. | Choose a different stream bank.","ER 31 | The stream bank could not be copied. | Choose a different target stream bank.","ER 32 | The stream bank could not be cleared. | This stream bank cannot be overwritten — select a different one.","ER 33 / ER 34 | No stream configuration exists. | Create a new camera configuration or import an existing one.","ER 35 | This configuration cannot be edited. | The stream configuration is reserved and cannot be modified.","ER 36 | The stream could not be initiated on the device. | Check the bridge status and ensure it is online. | Check available network bandwidth. | Check firewall settings for the streaming port.","ER 37 | Too many concurrent streams are already connected at once. | Reduce the number of active live view streams. | Remote reboot the unit if the issue persists.","ER 38 | Too many concurrent users are already connected at once. | Ask another user to disconnect. | Remote reboot the unit if the issue persists.","ER 39 | A layout name is required to save a new layout. | Enter a name for the layout before saving.","ER 40 | An existing layout with this name already exists. | Use a unique name, or delete the existing layout first.","ER 41 | Close out of other open menus to allow the layout menu to open. | Close any other active menus or dialogs in the portal, then try again."].join(`
431`),multiline:!0,help:'One error per line: "Code | Message | Fix1 | Fix2 | ...". First part is the code, second the message, the rest are fixes.'},{key:"s1.p1",label:"Ch 1 Paragraph 1",def:"**Username or Email:** Enter your user credentials. Using an email address provides better security — you'll receive login alerts and can reset your password."},{key:"s1.p2",label:"Ch 1 Paragraph 2",def:"**Password:** Enter your password for your account."},{key:"s1.p3",label:"Ch 1 Paragraph 3",def:"**Server Address:** This address is required to authenticate to your dashboard."},{key:"s1.p4",label:"Ch 1 Paragraph 4",def:"**Save Password:** Securely stores your password locally so you don't need to enter it each time."},{key:"s1.p5",label:"Ch 1 Paragraph 5",def:"**Forgot Password:** Reset your password via email with a two-factor authentication code. Only works if a valid email address is associated with your account."},{key:"s1.box1",label:"Ch 1 Callout 1",def:"The Save Password checkbox is not available when 'Stored Credentials' are enabled in your preferences. Stored Credentials are useful when you have multiple logins for different accounts."},{key:"s2.p1",label:"Ch 2 Paragraph 1",def:"**Dashboard:** View, access, and manage your backup bridges with a general overview of the status of your locations."},{key:"s2.p2",label:"Ch 2 Paragraph 2",def:"**User Management:** Create, edit and manage users who sign into the dashboard."}
431,{key:"s2.p3",label:"Ch 2 Paragraph 3",def:"**Pulse Monitoring:** Displays all devices and their status, including local storage drives, cameras, network devices, and the backup bridge. Manage alerting for devices that go offline."},{key:"s2.p4",label:"Ch 2 Paragraph 4",def:"**Companies:** Create, edit and manage companies. Each backup bridge and user is assigned to a company group. Non-admin users can only view bridges in their assigned company. Administrators have access to all bridges regardless of company."},{key:"s2.p5",label:"Ch 2 Paragraph 5",def:"**New Job Quote:** Submits a new job quote to the sales team for a new backup bridge location."},{key:"s2.p6",label:"Ch 2 Paragraph 6",def:"**Online Support:** Contains help documentation and support information."},{key:"s2.p7",label:"Ch 2 Paragraph 7",def:"**Local Settings:** Application preferences, database server connections, stored credentials and other local configuration."},{key:"s3.p1",label:"Ch 3 Paragraph 1",def:"**Switch Account:** Ends the current session to switch to another user account — useful if you have multiple logins."},{key:"s3.p2",label:"Ch 3 Paragraph 2",def:"**Display By:**"},{key:"s3.p3",label:"Ch 3 Paragraph 3",def:"**Sort By:**"},{key:"s3.list1",label:"Ch 3 List 1",def:["**Activated:** Shows bridges active with a subscription, operating normally.","**Pending Activation:** Active subscription but not yet fully installed. May operate for up to 90 days before the license expires.","**Deactivated:** Subscription canceled. Bridge remains suspended until reactivated."].join(`
432`),multiline:!0},{key:"s3.list2",label:"Ch 3 List 2",def:["**Total Storage:** Sorts by total accumulated storage since activation date.","**Name:** Sorts alphabetically by bridge name.","**Activity:** Sorts by most recent backup activity."].join(`
433`),multiline:!0},{key:"s4.p1",label:"Ch 4 Paragraph 1",def:"Left-clicking a bridge icon opens a pop-up menu for basic functions such as event retrieval and live viewing."},{key:"s4.p2",label:"Ch 4 Paragraph 2",def:"**Bridge Icon Status:**"},{key:"s4.p3",label:"Ch 4 Paragraph 3",def:"**Reasons for being offline or not backing up:**"},{key:"s4.p4",label:"Ch 4 Paragraph 4",def:"**Bridge Bar:**"},{key:"s4.p5",label:"Ch 4 Paragraph 5",def:"The bridge bar displays information based on the sorting parameter selected (e.g., Total Storage). The bar shows the total storage used vs. total storage available on the bridge."},{key:"s4.list1",label:"Ch 4 List 1",def:["**Powered down:** Bridge is powered off and needs to be turned on at the location.","**Network issue:** Bridge is no longer on the network.","**Camera/NVR Streaming issue:** No live cameras are streaming to the bridge.","**Credential Changes:** Username or password changed on the camera or NVR.","**Limited Motion Activity:** Insufficient motion activity in 24 hours.","**System Error:** Internal hardware or OS error on the bridge."].join(`
434`),multiline:!0},{key:"s4.row1",label:"Ch 4 Row 1",def:"**Online & Backing up:** Normal operation."},{key:"s4.row2",label:"Ch 4 Row 2",def:"**Online, but not backing up:** Communicating but a problem exists."},{key:"s4.row3",label:"Ch 4 Row 3",def:"**Offline & not backing up:** Not communicating or backing up."},{key:"s5.p1",label:"Ch 5 Paragraph 1",def:"Type into the search box to find a backup bridge. Bridges sort based on the sorting parameter you have selected."},{key:"s5.p2",label:"Ch 5 Paragraph 2",def:"**Scrolling:**"},{key:"s5.p3",label:"Ch 5 Paragraph 3",def:"Hold down the left mouse button and guide the mouse up or down to scroll. Release to stop."},{key:"s5.p4",label:"Ch 5 Paragraph 4",def:"**Quick Sorting:**"},{key:"s5.p5",label:"Ch 5 Paragraph 5",def:"Highlight line items in blue with the mouse; clicking when underlined will quickly sort."},{key:"s6.p1",label:"Ch 6 Paragraph 1",def:"At your dashboard, click your backup bridge icon (left of the bridge name):"},{key:"s6.p2",label:"Ch 6 Paragraph 2",def:"Select **Event Retrieval**:"},{key:"s6.p3",label:"Ch 6 Paragraph 3",def:"Choose your duration, camera selection, and select **Search**:"},{key:"s6.p4",label:"Ch 6 Paragraph 4",def:"Select a date, expand events, double-click an event to load it:"},{key:"s6.box1",label:"Ch 6 Callout 1",def:"Present day events may take up to 30 minutes to appear for local storage."},{key:"s7.p1",label:"Ch 7 Paragraph 1",def:"**Calendar Controls:**"},{key:"s7.p2",label:"Ch 7 Paragraph 2",def:"The calendar lets you select a specific date to load events. Bold dates indicate events are available. The arrow right moves back a month; arrow left moves forward a month."}
434,{key:"s7.p3",label:"Ch 7 Paragraph 3",def:"Clicking the month name lets you select a month in a given year. The arrows then navigate by year."},{key:"s7.p4",label:"Ch 7 Paragraph 4",def:"**Camera & Event Controls:**"},{key:"s7.p5",label:"Ch 7 Paragraph 5",def:"Expanding a camera by clicking the '+' button displays events for that date, sorted from start to end time. Double-clicking an event downloads and loads it into the player."},{key:"s7.p6",label:"Ch 7 Paragraph 6",def:"**Renaming a Camera:**"},{key:"s7.p7",label:"Ch 7 Paragraph 7",def:"If your role is Manager, Owner, or Administrator, you can rename cameras. Right-click on the camera name until it becomes editable, type the new name, then press Enter or click away."},{key:"s7.box1",label:"Ch 7 Callout 1",def:"Renaming a camera updates the name for all users."},{key:"s8.p1",label:"Ch 8 Paragraph 1",def:"**Event Player:**"},{key:"s8.p2",label:"Ch 8 Paragraph 2",def:"The event player loads any event from local or cloud storage. Icons and the trackbar at the bottom control basic operation. The player supports one camera per application instance."},{key:"s9.p1",label:"Ch 9 Paragraph 1",def:"From the dashboard, click your bridge icon, select **Event Retrieval**, then choose your duration, camera selection, check **Export Events**, and select **Search**:"},{key:"s9.p2",label:"Ch 9 Paragraph 2",def:"**Export Options:**"},{key:"s9.list1",label:"Ch 9 List 1",def:["**Destination Folder:** Where events will be exported. Default: `C:\\Users\\username\\Documents\\Proactive-Backup\\LocationName`. Can be changed under Local Settings → Preferences → Backup Event Folder Path.","**Retain original format and include recovery player:** Exports raw file with a standalone recovery player. Ideal for archiving or sharing on external media (USB).","**Burn event clip to AVI with Xvid compression:** Reduces file size with minimal quality loss. Ideal for distribution via USB, email, or cloud.","**Burn event clip to AVI without compression:** Very large files. Not recommended for distribution.","**No Subfolders / Create with channel subfolder:** Controls the export folder structure."].join(`
435`),multiline:!0},{key:"s10.p1",label:"Ch 10 Paragraph 1",def:"There are two ways to view live: **Quick View** and **Full Live View**."},{key:"s10.p2",label:"Ch 10 Paragraph 2",def:"Left-clicking the eye icon on the right of a bridge opens a side panel for Quick View. By default, when the application is maximized, Quick View launches on the right side. If the window isn't maximized, Full Live View opens in a separate window."},{key:"s10.p3",label:"Ch 10 Paragraph 3",def:"To launch **Full Live View** in a separate window, click your bridge icon and select **Live View**:"},{key:"s10.box1",label:"Ch 10 Callout 1",def:"Quick View only works when the application is maximized, and may not work on very low-resolution displays. If Quick View can't display, Full Live View will launch in a separate window instead."},{key:"s11.p1",label:"Ch 11 Paragraph 1",def:"Quick View and Full Live View share the same functionality, though icon positions differ. Quick View doesn't support full-monitor resizing."},{key:"s11.p2",label:"Ch 11 Paragraph 2",def:"**Quick View Layout:** Icon menu is primarily at the top."},{key:"s11.p3",label:"Ch 11 Paragraph 3",def:"**Full Live View Layout:** Icon menu is primarily on the left side."},{key:"s11.p4",label:"Ch 11 Paragraph 4",def:"**Camera Icons:** Each icon loads a group of 8 cameras. 16 groups support up to 128 cameras; maximum concurrent streams per application is 8."},{key:"s11.p5",label:"Ch 11 Paragraph 5",def:"**Camera Stream Functions** (hover over a camera to reveal):"},{key:"s11.row1",label:"Ch 11 Row 1",def:"**White Camera:** Cameras exist in this group."},{key:"s11.row2",label:"Ch 11 Row 2",def:"**Blue Camera:** Currently selected group showing live streams."},{key:"s11.row3",label:"Ch 11 Row 3",def:"**Grey Camera:** No cameras in this group."},{key:"s11.row4",label:"Ch 11 Row 4",def:"**Loop Groups:** Auto-advances to the next camera group every 15 seconds and loops."},{key:"s12.p1",label:"Ch 12 Paragraph 1",def:"Create layouts to group your favorite cameras and optionally load a specific layout automatically at startup."},{key:"s12.p2",label:"Ch 12 Paragraph 2",def:"**Creating a Custom Layout:**"}
435,{key:"s12.p3",label:"Ch 12 Paragraph 3",def:"**Deleting a Custom Layout:**"},{key:"s12.li1",label:"Ch 12 List item 1",def:"Click the layout manager icon."},{key:"s12.li2",label:"Ch 12 List item 2",def:"Select **Create New Layout...** to start fresh, or choose an existing layout from the dropdown to edit."},{key:"s12.li3",label:"Ch 12 List item 3",def:"Choose a camera in each stream channel."},{key:"s12.li4",label:"Ch 12 List item 4",def:"Enter a layout name when finished."},{key:"s12.li5",label:"Ch 12 List item 5",def:"Check the option to load this layout at startup if desired."},{key:"s12.li6",label:"Ch 12 List item 6",def:"Save the layout."},{key:"s12.li7",label:"Ch 12 List item 7",def:"Select a layout from the dropdown menu."},{key:"s12.li8",label:"Ch 12 List item 8",def:"Select **Delete Layout** and confirm when prompted."},{key:"s12.box1",label:"Ch 12 Callout 1",def:"Layouts are stored locally on your PC and not in the cloud."},{key:"s13.p1",label:"Ch 13 Paragraph 1",def:"Live view supports up to **5 concurrent streaming users** or **80 camera streams at once** per location. The bridge automatically throttles bandwidth by reducing FPS or quality based on concurrent load."},{key:"s13.p2",label:"Ch 13 Paragraph 2",def:"**Adjusting Stream Settings** (affects your session only, not other users):"},{key:"s13.p3",label:"Ch 13 Paragraph 3",def:"**Buffer Duration:** Increasing reduces buffering instances but adds delay. Decreasing provides a more real-time stream at the cost of potential buffering on slower connections."},{key:"s13.p4",label:"Ch 13 Paragraph 4",def:"**Use HD:** Requests high-definition resolution. Can substantially increase bandwidth during large window resizing."},{key:"s13.p5",label:"Ch 13 Paragraph 5",def:"**Camera Names:** Always show, or only show on hover."},{key:"s13.list1",label:"Ch 13 List 1",def:["**High Performance:** Bridge auto-adjusts for best performance.","**Maintain Stability:** Prioritizes stable streams.","**Reduce Bandwidth:** Drastically reduces bandwidth consumption.","**Very Limited Bandwidth:** Provides only the minimum required stream."].join(`
436`),multiline:!0},{key:"s14.p1",label:"Ch 14 Paragraph 1",def:"Pulse Monitoring is a centralized application designed to monitor devices connected to your backup bridge. Its primary function is to trigger alerts when a device has a problem and to notify when issues are resolved."},{key:"s14.p2",label:"Ch 14 Paragraph 2",def:"**Two ways to launch:**"},{key:"s14.li1",label:"Ch 14 List item 1",def:"**Main Menu Launch:** Shows all locations and devices."},{key:"s14.li2",label:"Ch 14 List item 2",def:"**From Pop-Up Menu:** Click your bridge icon from the dashboard and select **Pulse Monitoring** — shows only devices from that location."},{key:"s14.box1",label:"Ch 14 Callout 1",def:"Only administrators can make changes to devices in Pulse Monitoring. Other users can view only."},{key:"s15.p1",label:"Ch 15 Paragraph 1",def:"**Top Menu Icons:**"},{key:"s15.p2",label:"Ch 15 Paragraph 2",def:"**Preferences:**"},{key:"s15.list1",label:"Ch 15 List 1",def:["**Show Detailed Information In Device List:** Shows device name plus additional info such as days offline.","**Expand Device Tree:** Automatically opens all devices under the bridge icon.","**Keep Window Always On Top:** Application appears in front of all other windows.","**Monitor Frequency:** How long since last report before a device is shown as offline.","**Auto Refresh:** How often to automatically refresh the device status. Can be disabled for manual-only refreshing."].join(`
437`),multiline:!0},{key:"s16.p1",label:"Ch 16 Paragraph 1",def:"**Accessing the pop-up menu:** Double-click or right-click a device."},{key:"s16.p2",label:"Ch 16 Paragraph 2",def:"**Adding or Editing a Device:**"},{key:"s16.list1",label:"Ch 16 List 1",def:["**Add Device:** Click the backup bridge icon first, then add a device.","**Edit Device:** Edits an existing device and its properties.","**Remove Device:** Deletes an existing device (the bridge itself cannot be removed).","**Activate / Deactivate Pulse Monitoring:** Click the bridge icon to toggle monitoring on or off for all its devices.","**Refresh List:** Manually refreshes device status."].join(`
438`),multiline:!0},{key:"s16.list2",label:"Ch 16 List 2",def:["**Device Type:** Select the device category. For an NVR, use 'Other / Network Device'.","**Device Enabled/Disabled:** If unchecked, device shows but won't be monitored or alerted.","**Device Name:** Name of the device.","**Device Description:** Optional description.","**Alert Time:** When to trigger an alert (e.g., if offline for 30 minutes).","**TCP Port:** The port the device communicates on.","**IP Address:** Device IP address for monitoring."].join(`
439`),multiline:!0},{key:"s17.p1",label:"Ch 17 Paragraph 1",def:"To access IP Camera Functions, click the backup bridge icon first."},{key:"s17.p2",label:"Ch 17 Paragraph 2",def:"**Export IP Camera List (.csv):** Save the device list to a CSV file for editing in Excel or Google Sheets."}
439,{key:"s17.p3",label:"Ch 17 Paragraph 3",def:"**IP Camera Batch Import:** Import devices using an IP address range and port number."},{key:"s17.p4",label:"Ch 17 Paragraph 4",def:"**IP Camera File Import (.csv):** Import from a previously exported/edited CSV file."},{key:"s17.p5",label:"Ch 17 Paragraph 5",def:"**Remove All IP Cameras:** Deletes all IP cameras from Pulse Monitoring."},{key:"s17.row1",label:"Ch 17 Row 1",def:"**Update Changes:** After making all changes, click this to apply them to the device."},{key:"s18.p1",label:"Ch 18 Paragraph 1",def:"Each backup bridge and user is assigned to a company — essentially a group. Non-admin users can only view bridges in their assigned company. Administrators have access to all bridges regardless of company assignment."},{key:"s18.p2",label:"Ch 18 Paragraph 2",def:"**Managing Companies** (under the Companies section):"},{key:"s18.p3",label:"Ch 18 Paragraph 3",def:"**Assigning to Users** (under User Management):"},{key:"s18.p4",label:"Ch 18 Paragraph 4",def:"**Assigning to Devices** (under Device Configuration → Assign to a company):"},{key:"s18.box1",label:"Ch 18 Callout 1",def:"Only one company can be assigned to a user and backup bridge at a time."},{key:"s19.p1",label:"Ch 19 Paragraph 1",def:"From the Companies section, you can create, edit, and delete company groups."},{key:"s19.p2",label:"Ch 19 Paragraph 2",def:"**Create New Company:** Enter a company name and select **Create**."},{key:"s19.p3",label:"Ch 19 Paragraph 3",def:"**Edit Existing Company:** Select a company from the dropdown, edit the name, and select **Update**."},{key:"s19.p4",label:"Ch 19 Paragraph 4",def:"**Delete Company:** Select a company and choose **Delete Company**. You'll be prompted to confirm. Bridges and users assigned to this company will be unassigned."},{key:"s20.p1",label:"Ch 20 Paragraph 1",def:"Administrators can update their authorized dealer information, which appears in communication sent to end users."},{key:"s20.p2",label:"Ch 20 Paragraph 2",def:"Navigate to **Companies → Dealer Information** to edit your company name, contact information, and logo. Select **Update** when done."},{key:"s21.p1",label:"Ch 21 Paragraph 1",def:"Four tier roles exist in the Vault Portal. All roles have basic access to Event Retrieval, Live View, Pulse Monitoring, and the dashboard."},{key:"s21.p2",label:"Ch 21 Paragraph 2",def:"**1. Administrator (Dealer Level):** For customers and their technicians only. Administrators access all bridges across all company groups, with full rights to modify bridges, users, companies, and Pulse Monitoring devices."},{key:"s21.p3",label:"Ch 21 Paragraph 3",def:"**2. Owner (Top User Level):** Assigned to end-users who own or operate the business. Owners can:"},{key:"s21.p4",label:"Ch 21 Paragraph 4",def:"**3. Manager:** Can rename cameras and view all content. Cannot manage users or billing."},{key:"s21.p5",label:"Ch 21 Paragraph 5",def:"**4. User (Basic):** Read-only access to event retrieval, live view, and pulse monitoring. Cannot make any changes."},{key:"s21.list1",label:"Ch 21 List 1",def:["Rename their cameras","Manage users within their company group","Vie
439w event retrieval, live view, and pulse monitoring"].join(`
440`),multiline:!0},{key:"s21.box1",label:"Ch 21 Callout 1",def:"Do not assign an end-user (your customer) as an administrator — they will have access to all your other customers' data!"},{key:"s22.p1",label:"Ch 22 Paragraph 1",def:"Navigate to **User Management → Change Login & Two-Factor Authentication**:"},{key:"s22.p2",label:"Ch 22 Paragraph 2",def:"It is recommended you use a valid email address — this enables login security notifications, password recovery, and two-factor authentication."},{key:"s22.p3",label:"Ch 22 Paragraph 3",def:"Select **Update** when you've finished making changes."},{key:"s22.p4",label:"Ch 22 Paragraph 4",def:"**Enable Two-Factor Authentication:**"},{key:"s22.p5",label:"Ch 22 Paragraph 5",def:"Check **Two-Factor Authentication** to enable. On each login, you'll receive an email with a code required to complete sign-in."},{key:"s23.p1",label:"Ch 23 Paragraph 1",def:"Navigate to **User Management → Change My Password**. Enter your current password, then your new password. Select **Update**."},{key:"s23.p2",label:"Ch 23 Paragraph 2",def:"**Resetting Your Password (Forgotten):**"},{key:"s23.p3",label:"Ch 23 Paragraph 3",def:"From the login screen, select **Forgot Password**. You'll receive a code to your email — enter the code to access the password reset screen."},{key:"s23.box1",label:"Ch 23 Callout 1",def:"Your username must be a valid email address to use password reset. If you only have a username, contact your system administrator. Minimum password length is 8 characters."},{key:"s24.p1",label:"Ch 24 Paragraph 1",def:"Navigate to **User Management → Manage Users & Roles**."},{key:"s24.p2",label:"Ch 24 Paragraph 2",def:"**Add a New User:** Select **Create New User** and fill in the fields:"},{key:"s24.p3",label:"Ch 24 Paragraph 3",def:"**Editing an Existing User:** Select a user from the **Select Existing User** dropdown, make changes, and select **Update**."},{key:"s24.p4",label:"Ch 24 Paragraph 4",def:"**Deleting a User:** Select the user and click **Delete User**. You'll need to enter your password to confirm."},{key:"s24.list1",label:"Ch 24 List 1",def:["**User Enabled:** Allow login access.","**Two-Factor Authentication:** Require email code at login.","**Email CMS Instructions:** Send setup instructions to the user's email.","**Email / Username:** Login credential (email recommended).","**New/Verify Password:** Set the initial password.","**Assigned Company:** The company this user belongs to.","**User Role:** Select the appropriate tier level."].join(`
441`),multiline:!0},{key:"s25.p1",label:"Ch 25 Paragraph 1",def:"From the dashboard, click your bridge icon and select **Device Configuration**:"},{key:"s25.p2",label:"Ch 25 Paragraph 2",def:"Choose the setting area to modify:"},{key:"s25.box1",label:"Ch 25 Callout 1",def:"Changes made to the backup bridge may take several minutes or longer to take effect on the device."},{key:"s26.p1",label:"Ch 26 Paragraph 1",def:"Select **Update** when done. Some changes may require password approval."},{key:"s26.list1",label:"Ch 26 List 1",def:["**Device Name:** Changes the name of the backup bridge.","**Assigned Company:** Links the bridge to a company group."].join(`
442`),multiline:!0},{key:"s27.list1",label:"Ch 27 List 1",def:["**Cloud Storage:** Enables or disables cloud backup.","**Cloud Retention:** How long video events are stored before being purged from the cloud."].join(`
443`),multiline:!0},{key:"s27.box1",label:"Ch 27 Callout 1",def:"When modifying these settings, your billing charges will be subject to change, which can include an increase or decrease."},{key:"s28.list1",label:"Ch 28 List 1",def:['**Backup Frequency:** How often video events should be backed up. "On file modification" immediately backs up an event.',"**Backup Schedule:** What days and times backups should occur."].join(`
444`),multiline:!0},{key:"s28.box1",label:"Ch 28 Callout 1",def:"Unless you're restricting bandwidth at certain times, you should back up events immediately. Waiting several days risks overwriting events on the temporary buffer drive if many events are pending upload."},{key:"s29.list1",label:"Ch 29 List 1",def:["**Alert Messages:** Toggle all device alerts triggered by Pulse Monitoring on or off.","**Alert Format:** Email (HTML) or SMS (plain text).","**Add a New Email Address:** Enter an address and select **Add New Recipient**.","**Alert Group:** Select a recipient and click **Remove Recipient** to remove them."].join(`
445`),multiline:!0},{key:"s30.list1",label:"Ch 30 List 1",def:["**Local Storage Port:** The event retrieval port for local storage drives. May need to be port-forwarded for remote access outside the local network.","**Global Connection:** The primary method for connecting to local storage drives for event retrieval.","**Storage Routing:** Controls how video events are routed between local and cloud storage."].join(`
446`),multiline:!0},{key:"s31.p1",label:"Ch 31 Paragraph 1",def:"This section displays detailed information about the backup bridge — including its serial number, hardware specifications, firmware version, and license/subscription status."},{key:"s31.p2",label:"Ch 31 Paragraph 2",def:"The **Reference Order** links the device to its original purchase order."},{key:"s32.p1",label:"Ch 32 Paragraph 1",def:"Additional operational settings for the backup bridge. These settings should only be modified by your administrator or {brandName} technical staff, as incorrect values can affect normal bridge operation."},{key:"s33.list1",label:"Ch 33 List 1",def:["**Deactivate:** Suspends the bridge and its subscription. The bridge stops backing up but all stored data is preserved.","**Reactivate:** Restores a deactivated bridge to normal operation.","**Terminate Permanently:** Permanently removes the bridge from the system. This action cannot be undone and will delete all stored events."].join(`
447`),multiline:!0},{key:"s34.p1",label:"Ch 34 Paragraph 1",def:"Settings stored locally on your workstation. Access via the main menu."},{key:"s34.list1",label:"Ch 34 List 1",def:["**Preferences:** Dashboard settings and other user preferences.","**Database Servers:** Connects to a Vault Portal host server.","**Stored Credentials:** Allows multiple login accounts to be stored.","**Check For Softw
447are Update:** Manually checks for a new Vault Portal version.","**Export Event Retrieval Player to USB/Media:** Copies the recovery player for redistribution onto external media.","**Export Stored Connections:** Exports stored credentials for use on another workstation.","**Import Stored Connections:** Imports stored credentials from another workstation.","**Clear Cache:** Deletes temporary files. Saves storage space or resolves application errors without affecting operation.","**Default Preferences:** Resets all preferences to factory settings.","**Factory Reset:** Completely resets the Vault Portal for re-installation."].join(`
448`),multiline:!0},{key:"s34.box1",label:"Ch 34 Callout 1",def:"Some setting changes take effect immediately."},{key:"s35.p1",label:"Ch 35 Paragraph 1",def:"Key user preferences available:"},{key:"s35.list1",label:"Ch 35 List 1",def:["**Backup Event Folder Path:** Default export destination for events.","**Launch Quick View on Startup:** Automatically opens quick view when the dashboard loads.","**Theme:** Light or dark application theme.","**Notification Sound:** Enable or disable audio alerts for device notifications.","**Language:** Select the application language."].join(`
449`),multiline:!0},{key:"s36.p1",label:"Ch 36 Paragraph 1",def:"Connecting to a Vault Portal hosted database server. If your organization uses a dedicated database server (common for multi-company customer setups), enter the server address here to connect."},{key:"s36.p2",label:"Ch 36 Paragraph 2",def:"Select **Test Connection** to verify connectivity, then **Save** to apply."},{key:"s37.p1",label:"Ch 37 Paragraph 1",def:"Stored Credentials allow you to save multiple login accounts and switch between them easily at the login screen — without manually entering credentials each time."},{key:"s37.p2",label:"Ch 37 Paragraph 2",def:"**Adding a credential:** Enter the username, password, and server address, then select **Add**."},{key:"s37.p3",label:"Ch 37 Paragraph 3",def:"**Removing a credential:** Select the credential from the list and choose **Remove**."},{key:"s37.box1",label:"Ch 37 Callout 1",def:"When Stored Credentials are enabled, the 'Save Password' checkbox on the login screen is hidden."},{key:"s38.p1",label:"Ch 38 Paragraph 1",def:"When an error occurs, it displays at the top of the application with an error code. Use the table below to identify the cause and apply the recommended fix."},{key:"s39.p1",label:"Ch 39 Paragraph 1",def:"You can remotely reboot a backup bridge directly from the dashboard without physical access to the device."},{key:"s39.p2",label:"Ch 39 Paragraph 2",def:"From the dashboard, click your bridge icon and select **Remote Reboot**. A confirmation dialog will appear — select **Yes** to proceed."},{key:"s39.box1",label:"Ch 39 Callout 1",def:"The bridge will be temporarily offline during the reboot. A reboot typically takes 2–5 minutes. If the bridge does not come back online after 10 minutes, it may need to be physically power-cycled at the location."},{key:"s40.p1",label:"Ch 40 Paragraph 1",def:"TeamViewer allows remote desktop access to the backup bridge computer for advanced troubleshooting. This feature should only be used by administrators or authorized technicians."},{key:"s40.p2",label:"Ch 40 Paragraph 2",def:"From the dashboard, click your bridge icon and select **TeamViewer Connect**. The TeamViewer session ID and password for the device will be displayed."},{key:"s40.box1",label:"Ch 40 Callout 1",def:"TeamViewer must be installed on both your workstation and the backup bridge for this feature to work. Contact your {brandName} administrator if you need assistance establishing a remote session."}]},b_={key:"support.downloads",title:"Support: Downloads",group:"Support",fields:[{key:"hero.badge",label:"Hero badge",def:"Software Downloads"},{key:"hero.heading",label:"Hero heading",def:"Event Management Portal"},{key:"hero.subheading",label:"Hero subheading",def:"This software is for Blu Legacy product only. Download and install the desktop client for Windows. Choose the version that matches your account type.",multiline:!0},{key:"hero.latestLabel",label:"Latest label prefix",def:"Latest:"},{key:"whatsNew.heading",label:"What's New heading",def:"What's New in"}
449,{key:"chooseVersion.heading",label:"Choose Version heading",def:"Choose Your Version"},{key:"download.button",label:"Download button",def:"Download"},{key:"download.versionHistory",label:"Version history toggle",def:"Version History"},{key:"admin.title",label:"Admin card title",def:"Admin Version"},{key:"admin.subtitle",label:"Admin card subtitle",def:"Recommended for most users"},{key:"admin.description",label:"Admin card description",def:"Download & run the installer. Antivirus software may flag the installer — please allow exceptions to proceed.",multiline:!0},{key:"admin.note",label:"Admin card note",def:"This version requires your Windows user account to always run as an administrator.",multiline:!0},{key:"user.title",label:"User card title",def:"Standard User Version"},{key:"user.subtitle",label:"User card subtitle",def:"For non-admin environments"},{key:"user.description",label:"User card description",def:"Download & run the installer. Antivirus software may flag the installer — please allow exceptions to proceed.",multiline:!0},{key:"user.note",label:"User card note",def:"This version only requires the Windows user account to be run as an administrator once during installation.",multiline:!0},{key:"systemReq.heading",label:"System Requirements heading",def:"System Requirements"},{key:"systemReq.items",label:"System requirement rows",def:["Operating System | Windows 10, 11, or Server 2022+ (deprecated Windows versions also supported)","Account | Windows user account with administrator access","Internet | Required — minimum 5 Mbps download speed for live view","RAM | 2 GB system memory minimum","Display | 1024 × 768 resolution or greater"].join(`
450`),multiline:!0,help:'One requirement per line: "Label | Value". Icons are fixed per position.'}]},Cte={key:"support.edgeAppInstall",title:"Support: Edge App Install",group:"Support",fields:[{key:"hero.badge",label:"Hero badge",def:"Support"},{key:"hero.heading",label:"Hero heading",def:"Edge App Install"},{key:"hero.subheading",label:"Hero subheading",def:"Install {productName} on your phone in seconds. Adding it to your home screen gives you a full-screen app icon, faster access to live view and alerts, and a smoother experience than opening the site in a browser tab. No download from the App Store or Play Store required.",multiline:!0},{key:"hero.helpPrefix",label:"Hero help prefix",def:"Need help? Contact"},{key:"apple.title",label:"Apple guide title",def:"iPhone & iPad (Safari)"},{key:"apple.steps",label:"Apple step instructions",def:["Open `{domain}` in Safari and tap the **Share** button at the bottom of the screen.","Scroll down in the share sheet and tap **Add to Home Screen**.","Confirm the name **{productName}**, make sure **Open as Web App** is on, then tap **Add**."].join(`
451`),multiline:!0,help:"One step per line. Inline markup: **bold**, `code`. Tokens: {domain}, {productName}."},{key:"apple.step1Alt",label:"Apple step 1 image alt",def:"Safari with {domain} loaded showing the Share button at the bottom"},{key:"apple.step2Alt",label:"Apple step 2 image alt",def:"iOS share sheet with Add to Home Screen highlighted"},{key:"apple.step3Alt",label:"Apple step 3 image alt",def:"iOS Add to Home Screen confirmation with Open as Web App enabled"},{key:"android.title",label:"Android guide title",def:"Android (Chrome)"},{key:"android.steps",label:"Android step instructions",def:["Open `{domain}` in Chrome.","Tap the three-dot menu in the top right and choose **Add to Home screen**.","Confirm **{productName}** in the **Install app** dialog and tap **Install**."].join(`
452`),multiline:!0,help:"One step per line. Inline markup: **bold**, `code`. Tokens: {domain}, {productName}."},{key:"android.step1Alt",label:"Android step 1 image alt",def:"Chrome on Android with {domain} loaded"},{key:"android.step2Alt",label:"Android step 2 image alt",def:"Chrome menu on Android showing Add to Home screen option"},{key:"android.step3Alt",label:"Android step 3 image alt",def:"Android Install app dialog confirming {productName}"},{key:"tip.label",label:"Tip label",def:"Tip:"},{key:"tip.body",label:"Tip body",def:"After installing, open {productName} from your home screen and sign in once. You'll stay signed in for fast access the next time you open the app.",multiline:!0}]},w_={key:"support.submitTicket",title:"Support: Submit a Ticket",group:"Support",fields:[{key:"hero.badge",label:"Hero badge",def:"Support"},{key:"hero.heading",label:"Hero heading",def:"Submit a Ticket"},{key:"hero.subheading",label:"Hero subheading",def:"Choose the type of request below and fill in the details. We'll respond as soon as possible.",multiline:!0},{key:"types.items",label:"Ticket types",def:["Footage Request | Request specific video footage from a date/time range.","Activation | Activate a new device with order and camera credentials.","Support Ticket | Report a problem or request general assistance."].join(`
453`),multiline:!0,help:'One type per line: "Label | Description". Icons are fixed per position.'},{key:"contactSection.heading",label:"Contact section heading",def:"Contact Information"},{key:"contact.nameLabel",label:"Name label",def:"Full Name"},{key:"contact.namePlaceholder",label:"Name placeholder",def:"Jane Smith"},{key:"contact.businessLabel",label:"Business label",def:"Business N
453ame"},{key:"contact.businessPlaceholder",label:"Business placeholder",def:"Acme Corp"},{key:"contact.phoneLabel",label:"Phone label",def:"Phone Number"},{key:"contact.phonePlaceholder",label:"Phone placeholder",def:"(555) 123-4567"},{key:"contact.emailLabel",label:"Email label",def:"Email Address"},{key:"contact.emailPlaceholder",label:"Email placeholder",def:"[email protected]"},{key:"contact.fromAccount",label:"Email from-account prefix",def:"From your account —"},{key:"contact.changeLink",label:"Email change link",def:"change"},{key:"footageDetails.heading",label:"Footage details heading",def:"Footage Details"},{key:"activationDetails.heading",label:"Activation details heading",def:"Activation Details"},{key:"problemDescription.heading",label:"Problem description heading",def:"Problem Description"},{key:"footage.startDateLabel",label:"Start date label",def:"Start Date"},{key:"footage.endDateLabel",label:"End date label",def:"End Date"},{key:"footage.startTimeLabel",label:"Start time label",def:"Start Time"},{key:"footage.endTimeLabel",label:"End time label",def:"End Time"},{key:"footage.additionalLabel",label:"Additional info label",def:"Additional Information"},{key:"footage.additionalPlaceholder",label:"Additional info placeholder",def:"Camera location, specific events to look for, or any other details that may help...",multiline:!0},{key:"activation.soLabel",label:"SO / order number label",def:"SO / Order Number"},{key:"activation.soPlaceholder",label:"SO / order number placeholder",def:"SO-12345"},{key:"activation.edgeLabel",label:"Edge serial number label",def:"Edge Serial Number"},{key:"activation.edgePlaceholder",label:"Edge serial number placeholder",def:"TE-XXXX-XXXX"},{key:"activation.eitherHint",label:"Activation either-or hint",def:"Provide either the SO order number or the Edge serial number (or both)."},{key:"activation.credentialsLabel",label:"Credentials file label",def:"Camera Credentials File"},{key:"activation.credentialsHint",label:"Credentials file hint",def:"Upload a CSV or Excel file with columns: IP Address, Username, Password (one camera per row)."},{key:"activation.uploadPrompt",label:"Upload prompt",def:"Click to upload file"},{key:"activation.uploadFormats",label:"Upload formats hint",def:"CSV, Excel, PDF, Word, or TXT · Max 10MB"},{key:"support.descriptionLabel",label:"Support description label",def:"Describe the Problem"},{key:"support.descriptionPlaceholder",label:"Support description placeholder",def:"Please describe the issue in as much detail as possible. Include any error messages, when it started, and steps to reproduce if applicable...",multiline:!0},{key:"media.label",label:"Attachments label",def:"Attachments"},{key:"media.optional",label:"Attachments optional note",def:"(optional · up to {max} files)",help:"{max} is the max file count."},{key:"media.hint",label:"Attachments hint",def:"Attach photos, screenshots, or short video clips that help illustrate your request."},{key:"media.emptyPrompt",label:"Attachments empty prompt",def:"Click to attach files"},{key:"media.morePrompt",label:"Attachments add-more prompt",def:"Add more files"},{key:"media.formats",label:"Attachments formats hint",def:"Images, videos, PDFs · Max 100MB each · {remaining} remaining",help:"{remaining} is the remaining file count."},{key:"encryptionNotice",label:"Encryption notice",def:"Your submission is encrypted and secure. Files are only accessible to {brandName} Support.",multiline:!0},{key:"submit.button",label:"Submit button",def:"Submit Ticket"},{key:"submit.sending",label:"Submit sending label",def:"Submitting…"},{key:"footer.note",label:"Footer note (before phone)",def:"By submitting, you'll receive a confirmation email.  Please check your spam folder if you don't see it. You can also call us at",multiline:!0,help:"Static copy that precedes the phone link."},{key:"success.heading",label:"Success heading",def:"Ticket Submitted"},{key:"success.refLabel",label:"Success ref label",def:"Your ticket reference number is:"},{key:"success.confirmationPrefix",label:"Success confirmation prefix",def:"A confirmation has been sent to"},{key:"success.confirmationSuffix",label:"Success confirmation suffix",def:". Our team will be in touch shortly."},{key:"success.submitAnother",label:"Submit another button",def:"Submit Another"},{key:"success.goHome",label:"Go home button",def:"Go Home"},{key:"validation.nameRequired",label:"Validation: name required",def:"Name is required"},{key:"validation.businessRequired",label:"Validation: business required",def:"Business name is required"},{key:"validation.phoneRequired",label:"Validation: phone required",def:"Phone number is required"},{key:"validation.emailRequired",label:"Validation: email required",def:"Email is required"},{key:"validation.emailInvalid",label:"Validation: email invalid",def:"Enter a valid email address"},{key:"validation.footageStartRequired",label:"Validation: footage start date required",def:"Start date is required"},{key:"validation.footageEndRequired",label:"Validation: footage end date required",def:"End date is required"}]},kte={key:"resources.oemBranding",title:"Resources: OEM Branding",group:"Resources",fields:[{key:"hero.badge",label:"Hero badge",def:"OEM Branding"},{key:"hero.heading",label:"Hero heading (lines)",def:`Your Brand.
454Your Platform. Your Customers.`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"Launch a fully branded video surveillance platform with dedicated private hosting — built for customers and integrators who want to own the entire customer experience.",multiline:!0},{key:"hero.primaryButton",label:"Hero primary button",def:"Request OEM Quote"},{key:"hero.secondaryButton",label:"Hero secondary button",def:"Become a Customer"},{key:"package.eyebrow",label:"Package eyebrow",def:"What's Included"}
454,{key:"package.heading",label:"Package heading",def:"The OEM Package"},{key:"package.subheading",label:"Package subheading",def:"Two pillars: complete brand ownership and dedicated infrastructure."},{key:"package.items",label:"Package checklist",def:["Full OEM Branding — your logo & company info, zero {brandName} mentions","Mobile App installs with your logo and application name","Customize all outbound alerting to your customers","Full control of your Edge Platform","Dedicated Private Hosting — only your customers on the server, with a custom domain of your choice","Dedicated Private Google Cloud Storage hosting","Customize pricing and sales-order control","White-glove onboarding and support"].join(`
455`),multiline:!0,help:"One checklist item per line."},{key:"branding.eyebrow",label:"Branding eyebrow",def:"Branding"},{key:"branding.heading",label:"Branding heading",def:"Make It Yours, End to End"},{key:"branding.subheading",label:"Branding subheading",def:"Every customer touchpoint — web, mobile, email — wears your brand exclusively."},{key:"branding.items",label:"Branding feature cards",def:["Full OEM Branding | Display your own logo and company information throughout the entire platform — no mention of {brandName} anywhere your customers will see.","Your Mobile App | The mobile app installs with your logo and application name. Your customers experience your brand from the moment they install.","Custom Outbound Alerts | Every email, alert, and notification sent to your customers is fully customized with your brand, sender address, and messaging.","Full Platform Control | Complete control of your Edge Platform — manage features, pricing, customers, and configurations from your own dedicated admin."].join(`
456`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"hosting.eyebrow",label:"Hosting eyebrow",def:"Private Hosting"},{key:"hosting.heading",label:"Hosting heading",def:"Your Server. Your Storage. Your Rules."},{key:"hosting.subheading",label:"Hosting subheading",def:"Dedicated infrastructure with no shared tenancy — true isolation for serious customers."},{key:"hosting.items",label:"Hosting feature cards",def:["Dedicated Private Hosting | Your own isolated server environment. Only your customers reside on the server — no shared tenancy with other customers or operators. Includes a custom domain name of your choice.","Private Google Cloud Storage | Dedicated GCS hosting for all cloud recordings — full data isolation, your own bucket, your own region of choice.","Custom Pricing & Sales Orders | Set your own per-camera pricing tiers, promo codes, and sales-order workflows. Operate the way your business runs.","Your Customers, Your Data | Customer accounts, devices, and footage live exclusively in your environment — built for customers who need true data sovereignty."].join(`
457`),multiline:!0,help:'One card per line: "Title | Description". Icons are fixed per position.'},{key:"cta.heading",label:"CTA heading",def:"Ready to Launch Your Own Platform?"},{key:"cta.subheading",label:"CTA subheading",def:"Let's talk about your branding, pricing, and infrastructure needs."},{key:"cta.primaryButton",label:"CTA primary button",def:"Request OEM Quote"},{key:"cta.secondaryButton",label:"CTA secondary button",def:"Become a Customer"},{key:"contact.title",label:"Contact dialog title",def:"Request OEM Quote"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your business and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.phoneLabel",label:"Contact phone label",def:"Phone (optional)"},{key:"contact.phonePlaceholder",label:"Contact phone placeholder",def:"(555) 000-0000"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your business"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Estimated # of customers, cameras, target market..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Inquiry"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]},_te={key:"resources.supportedDevices",title:"Resources: Supported Devices",group:"Resources",fields:[{key:"hero.badge",label:"Hero badge",def:"Resources"},{key:"hero.heading",label:"Hero heading",def:"Supported Devices"},{key:"hero.subheading",label:"Hero subheading",def:"{productName} works with any camera, NVR, or DVR that supports ONVIF or RTSP. Below is a reference of known-compatible devices with their RTSP URL patterns. Use the search and filters to find your hardware.",multiline:!0},{key:"hero.statDevicesSuffix",label:"Hero devices stat suffix",def:"devices listed",help:"Follows the device count."},{key:"hero.statBrandsSuffix",label:"Hero brands stat suffix",def:"brands",help:"Follows the brand count."},{key:"toolbar.searchPlaceholder",label:"Search placeholder",def:"Search brand, model, RTSP URL…"},{key:"toolbar.filtersButton",label:"Filters button",def:"Filters"},{key:"toolbar.resultSingular",label:"Result label (singular)",def:"result",help:'Used as "N result".'},{key:"toolbar.resultPlural",label:"Result label (plural)",def:"results",help:'Used as "N results".'},{key:"toolbar.allBrands",label:"All-brands option",def:"All Brands"},{key:"toolbar.onvifOnly",label:"ONVIF-only checkbox",def:"ONVIF only"},{key:"toolbar.clearFilters",label:"Clear-filters button",def:"Clear filters"},{key:"table.empty",label:"Empty state",def:"No devices match your search."},{key:"table.brand",label:"Column: Brand",def:"Brand"},{key:"table.series",label:"Column: Series / Line",def:"Series / Line"}
457,{key:"table.model",label:"Column: Model",def:"Model"},{key:"table.type",label:"Column: Type",def:"Type"},{key:"table.onvif",label:"Column: ONVIF",def:"ONVIF"},{key:"table.rtspMain",label:"Column: RTSP Main Stream",def:"RTSP Main Stream"},{key:"table.rtspSub",label:"Column: RTSP Sub Stream",def:"RTSP Sub Stream"},{key:"table.port",label:"Column: Port",def:"Port"},{key:"table.notes",label:"Column: Notes",def:"Notes"},{key:"table.onvifYes",label:"ONVIF yes cell",def:"✓ Yes"},{key:"table.onvifNo",label:"ONVIF no cell",def:"RTSP only"},{key:"footnote.replacePrefix",label:"Footnote: replace prefix",def:"Replace "},{key:"footnote.replaceSuffix",label:"Footnote: after code tokens",def:" with your device's credentials, IP address, and channel number. Default RTSP port is 554 unless otherwise noted. This list is provided as a reference guide — RTSP paths can vary by firmware version. If your device is ONVIF-compliant, {productName} can auto-discover the correct stream URL.",multiline:!0,help:"Follows the inline [user], [pass], [ip], [ch] code tokens."}]},Pte={key:"resources.whitePaper",title:"Resources: White Paper",group:"Resources",fields:[{key:"hero.badge",label:"Hero badge",def:"White Paper"},{key:"hero.byline",label:"Hero byline",def:"{brandName} · 2026"},{key:"hero.heading",label:"Hero heading (lines)",def:`From Storage to Intelligence:
458Rethinking Video Surveillance Architecture`,multiline:!0,help:"One line per row."},{key:"hero.subheading",label:"Hero subheading",def:"How the shift from capacity-first thinking to retention, retrieval, and resilience is reshaping surveillance infrastructure — and what it means for the integrators and operators who deploy it.",multiline:!0},{key:"hero.downloadButton",label:"Download button",def:"Download PDF"},{key:"hero.demoButton",label:"Demo button",def:"Schedule a Demo"},{key:"intro.label",label:"Intro section label",def:"Introduction"},{key:"intro.heading",label:"Intro heading",def:"The Shift from Capacity to Intelligence"},{key:"intro.p1",label:"Intro paragraph 1",def:"Traditionally, video surveillance systems were assessed by capacity. How many cameras were used? How much footage was captured? How many terabytes were available before storage ran out? When capacity ran short, the solution was simple: buy more drives to extend retention as far as the budget allowed.",multiline:!0},{key:"intro.p2",label:"Intro paragraph 2",def:"That approach isn't working anymore."},{key:"intro.p3",label:"Intro paragraph 3",def:"Today, surveillance environments are assessed by three core parameters:"},{key:"intro.list",label:"Intro list",def:["Can you keep it?","Can you find it?","Will it stand up to scrutiny?"].join(`
459`),multiline:!0,help:"One list item per line."},{key:"intro.p4",label:"Intro paragraph 4",def:"Security and IT teams are less concerned with how much video is captured and more concerned with whether it can be retained and retrieved when it matters. If required footage isn't available or takes too long to find, the system has effectively failed. Even a brief gap can lead to regulatory scrutiny, operational disruption, or liability.",multiline:!0},{key:"intro.callout",label:"Intro callout",def:"Video surveillance storage spending is expected to climb from about $9.5 billion in 2024 to over $12 billion by 2029 — driven by longer retention windows, multi-site environments, and compliance demands.",multiline:!0},{key:"intro.p5",label:"Intro paragraph 5",def:"Storage design is no longer a back-end specification. It directly affects customer trust, service commitments, and long-term system viability. A system that records but can't retain reliably — or retrieve quickly — becomes a liability for both the end user and the partner who deployed it.",multiline:!0},{key:"intro.p6",label:"Intro paragraph 6",def:"Storage has become an architectural decision. The way it is designed now determines whether a surveillance system scales, holds up against compliance inquiry, and delivers footage when it's needed most.",multiline:!0},{key:"landscape.label",label:"Landscape section label",def:"Current Landscape"},{key:"landscape.heading",label:"Landscape heading",def:"Where Current Surveillance Systems Break Down"},{key:"landscape.p1",label:"Landscape paragraph 1",def:"Many integrators don't design from a blank slate. Most deployments today rely on either local NVR infrastru
459cture or fully cloud-based platforms. Both solve parts of the storage problem — but each comes with trade-offs that become harder to manage as deployments scale.",multiline:!0},{key:"landscape.tableFeature",label:"Comparison column: Feature",def:"Feature"},{key:"landscape.tableNvr",label:"Comparison column: Legacy NVR",def:"Legacy NVR"},{key:"landscape.tableCloud",label:"Comparison column: Cloud-Only",def:"Cloud-Only"},{key:"landscape.tableHybrid",label:"Comparison column: Hybrid",def:"Hybrid"},{key:"landscape.comparisonRows",label:"Comparison table rows",def:["Retention | Limited by drive capacity | Flexible but internet-dependent | Flexible, local + cloud","Bandwidth | Minimal | High (continuous streaming) | Moderate","Hardware dependency | High (per site) | Low (centralized) | Medium","Compliance / reliability | Gaps, manual review | Centralized, but latency and outages possible | Better balance","Cost predictability | Hard to forecast | Monthly costs scale with usage | More controllable"].join(`
460`),multiline:!0,help:'One row per line: "Feature | Legacy NVR | Cloud-Only | Hybrid".'},{key:"landscape.nvrHeading",label:"Legacy NVR sub-heading",def:"Legacy NVR Reality"},{key:"landscape.nvrIntro",label:"Legacy NVR intro",def:"For many deployments, the NVR remains the core of the system. It records locally, sits in a rack, and stores footage until the drives fill. The model is familiar, and it works — up to a point.",multiline:!0},{key:"landscape.nvrItems",label:"Legacy NVR items",def:["Remote access is the first limitation. | Traditional NVRs are installed at each site. Off-site access primarily depends on VPN configurations, port forwarding, or static IP management. For a couple of locations, that's fairly manageable. For multi-location deployments, using NVRs becomes an infrastructure overhead. Logging into separate recorders, maintaining credentials, and troubleshooting remote connectivity consumes time that's often not accounted for in the original project scope.","Capacity pressure follows quickly. | Add cameras. Increase resolution. Extend retention. Before long, this combination quickly exhausts available storage. Expanding space usually means replacing drives, upgrading hardware, or adding new recorders. Each site introduces another device that requires configuration and maintenance. The environment becomes fragmented, with limited centralized visibility.","Hardware failure is part of the reality. | NVRs depend on physical components that fail: drives degrade, systems overheat, and network connections drop. When an NVR goes down, footage may be lost or unavailable until someone fixes it. In warehouses, retail sites, or outdoor environments, those failures tend to happen more often. And when video is missing, the failure isn't just technical — it carries compliance implications and potential liability.","Cost perception can be misleading. | Local recorders may appear economical at purchase. Ongoing maintenance, firmware updates, disk replacements, network configuration, and downtime are less visible line items. Over multi-year deployments, total ownership often exceeds initial expectations.","Security exposure remains a constant concern. | On-site NVRs frequently operate outside centralized IT oversight. Firmware updates lag, open ports stay exposed. Enforcing encryption standards and access policies across every location becomes difficult without unified controls. In regulated industries, that gap becomes a serious concern."].join(`
461`),multiline:!0,help:'One item per line: "Title | Description".'},{key:"landscape.cloudHeading",label:"Cloud-Only sub-heading",def:"Cloud-Only Trade-offs"},{key:"landscape.cloudIntro",label:"Cloud-Only intro",def:"Cloud-native surveillance platforms address several of the limitations associated with local recorders. Storage scales without adding hardware at each site. Access is remote by default. Updates and management are centralized. For distributed organizations, that simplicity is appealing.",multiline:!0},{key:"landscape.cloudRisk",label:"Cloud-Only risk line",def:"However, the operational risk shifts."},{key:"landscape.cloudItems",label:"Cloud-Only items",def:["Cloud-only environments depend on stable internet connectivity. | When connections degrade or drop entirely, recording can lag, live views freeze, and access to footage may be delayed. In some configurations, outages interrupt recording altogether. For sites in areas with inconsistent connectivity, internet dependency becomes a practical concern.","Bandwidth consumption is another variable. | Continuous high-definition streaming requires sustained upload capacity. As camera counts increase, so does network load. Other business systems share that same network connection. When bandwidth is constrained, performance suffers — whether in video quality or in broader network operations.","Cost dynamics change over time. | Cloud lowers upfront costs, but the monthly fees aren't fixed. Longer retention, higher resolution, and more cameras mean a more expensive bill. What looks manageable at one site can scale quickly across twenty. Over time, partners are the ones explaining those increases.","Flexibility can be limited in tightly integrated ecosystems. | Some cloud platforms tie together hardware, softw
461are, and storage in a single package. That can streamline procurement in new deployments. It becomes restrictive in environments where existing cameras, hybrid networks, or third-party systems are already in place.","Latency is another operational factor. | While platforms promote real-time access, video transmitted over public networks introduces buffering and transmission delay. In normal situations, the delay isn't a concern. But in high-security or time-sensitive events, every second matters."].join(`
462`),multiline:!0,help:'One item per line: "Title | Description".'},{key:"hybrid.label",label:"Hybrid section label",def:"Architecture"},{key:"hybrid.heading",label:"Hybrid heading",def:"Why Hybrid Cloud Keeps Showing Up in Real Deployments"},{key:"hybrid.diagramTitle",label:"Hybrid diagram title",def:"Reliable and Scalable Hybrid Video Architecture"},{key:"hybrid.diagramColumns",label:"Hybrid diagram columns",def:["Edge Recording | Local recording | Works offline | Real-time processing","Selective Cloud Sync | Long-term storage | Remote access and search | Centralized management","Centralized Management | Event-based uploads | Metadata over full streams | Sync after outages"].join(`
463`),multiline:!0,help:'One column per line: "Title | Bullet 1 | Bullet 2 | Bullet 3".'},{key:"hybrid.p1",label:"Hybrid paragraph 1",def:"As surveillance environments expand, many organizations settle into a hybrid model for practical reasons. It combines on-site recording with cloud-based retention and management. The architecture is more about separating responsibilities within the system, and less about trend adoption.",multiline:!0},{key:"hybrid.p2",label:"Hybrid paragraph 2",def:"Cameras continue capturing footage locally, independent of internet stability. If connectivity drops, the video doesn't stop. When service is restored, selected footage can synchronize to the cloud. This mitigates the single point of failure inherent in full internet dependency and reduces the urgency around transient outages.",multiline:!0},{key:"hybrid.p3",label:"Hybrid paragraph 3",def:"Cloud resources are used more selectively. Instead of continuously streaming every frame at full resolution, hybrid systems can transmit metadata, prioritized clips, or event-driven footage. Higher bandwidth is used when users actively retrieve or review video. That changes how networks behave under load — business systems are less likely to compete with surveillance traffic for capacity.",multiline:!0},{key:"hybrid.p4",label:"Hybrid paragraph 4",def:"Processing becomes more balanced as well. Time-sensitive tasks — such as real-time recording and initial analytics — can occur locally, close to the camera. Long-term storage, remote search, and centralized management occur in the cloud. The system distributes workload rather than concentrating it in one place.",multiline:!0},{key:"hybrid.p5",label:"Hybrid paragraph 5",def:"Scalability becomes more deliberate. New sites can be added without replicating identical infrastructure patterns at every location. Edge devices handle immediate recording needs, while cloud capacity expands in parallel. Growth doesn't require replacing everything that already works.",multiline:!0},{key:"hybrid.callout",label:"Hybrid callout",def:"Hybrid architecture persists because it reflects operational reality. Retention expectations are rising, and bandwidth remains finite. Compliance exposure is real, and systems must remain accessible during outages. Separating edge performance from cloud retention gives teams flexibility instead of forcing a single dependency.",multiline:!0},{key:"approach.label",label:"Approach section label",def:"{brandName} Approach"},{key:"approach.heading",label:"Approach heading",def:"How {brandName} Thinks About Video Storage"},{key:"approach.p1",label:"Approach paragraph 1",def:"{brandName} approaches video storage as the foundation of the surveillance system rather than as an extension of it. The focus begins with retention. How long can footage be preserved? How securely is it stored? How predictable are costs as they scale over time?",multiline:!0},{key:"approach.tiersTitle",label:"Retention tiers title",def:"Risk-Based Retention Tiers"},{key:"approach.tiers",label:"Retention tiers",def:["High-Risk Areas | Entrances, cash handling, loading docks | 30+ days","Standard Coverage | Hallways, office
463s, general monitoring | 14 days","Low-Risk Areas | Storage rooms, low-traffic zones | 7 days"].join(`
464`),multiline:!0,help:'One tier per line: "Label | Description | Days". Colors are fixed per position.'},{key:"approach.storageHeading",label:"Storage sub-heading",def:"Storage Comes First"},{key:"approach.storageP1",label:"Storage paragraph 1",def:"Long-term retention is built into the design. Instead of asking customers to replace existing recorders or discard functioning infrastructure, {brandName} layers cloud storage alongside on-site systems. Cameras and recorders already in place can continue operating.",multiline:!0},{key:"approach.storageP2",label:"Storage paragraph 2",def:"Storage is structured in tiers according to risk and compliance exposure. Not every camera requires identical retention. High-liability areas — such as entrances, cash handling zones, and loading docks — may warrant extended archival periods. Lower-risk zones may not. Aligning retention policies with operational exposure helps control long-term costs while meeting regulatory requirements.",multiline:!0},{key:"approach.storageP3",label:"Storage paragraph 3",def:"Behind the scenes, {brandName} applies its patented Tru-Two compression to reduce the footprint of stored video. Bandwidth and storage requirements decrease without reducing resolution. For partners managing multi-site deployments, compression directly affects recurring cloud cost and network stability.",multiline:!0},{key:"approach.storageP4",label:"Storage paragraph 4",def:"Google Cloud supports {brandName}' cloud storage infrastructure, which provides geographic redundancy and durability. Edge and hybrid options remain available where internet conditions or local policy require them.",multiline:!0},{key:"approach.usableHeading",label:"Usable sub-heading",def:"Making Video Easier to Use"},{key:"approach.usableP1",label:"Usable paragraph 1",def:"Retention alone doesn't solve operational disruptions. Footage must be retrievable quickly and in a usable form. {brandName} integrates AI-driven event management into its storage layer. Instead of relying exclusively on motion-based alerts, the platform supports object and event search across defined time ranges. Investigations can begin with specific criteria instead of searching through a broad timeline review.",multiline:!0},{key:"approach.usableP2",label:"Usable paragraph 2",def:"For integrators, that changes the retrieval experience. When an incident occurs, a search can identify key footage more quickly. In high-camera-density settings, that reduction in review time is significant.",multiline:!0},{key:"approach.runningHeading",label:"Running sub-heading",def:"Keeping Systems Running"},{key:"approach.runningCards",label:"Running feature cards",def:["Smart Search | Find footage faster","Tru-Two Compression | Lower storage and bandwidth costs","Failover Recording | Continuous recording during disruptions","Centralized Monitoring | Simplified multi-site management"].join(`
465`),multiline:!0,help:'One card per line: "Title | Description".'},{key:"approach.runningP1",label:"Running paragraph 1",def:"{brandName} supports failover recording across edge and cloud layers. If hardware or network disruption occurs, recording will continue on an available layer of infrastructure. This means that in a distributed environment, {brandName} reduces the risk of losing recording because of a single site failure.",multiline:!0},{key:"approach.runningP2",label:"Running paragraph 2",def:"System monitoring is centralized. Camera health, storage status, and connectivity can be viewed across locations from a single dashboard. Security controls are embedded into the platform. Encryption is on by default, and updates are handled centrally instead of site by site.",multiline:!0},{key:"useCases.label",label:"Use Cases section label",def:"Use Cases"},{key:"useCases.heading",label:"Use Cases heading",def:"Use Cases That Actually Come Up in Sales Calls"},{key:"useCases.intro",label:"Use Cases intro",def:"Architecture decisions seem like a non-urgent issue until an incident exposes a limitation. The following scenarios happen repeatedly in partner conversations because they reflect day-to-day operational pressure.",multiline:!0},{key:"useCases.items",label:"Use case cards",def:["Slip-and-fall disputes in property management | Slip-and-fall claims usually transpire weeks after the incident. Insurance carriers or legal teams may request footage long after standard 30-day retention periods have expired. By that point, the video may no longer exist. | Extending retention across every camera can inflate storage costs unnecessarily. A more targeted approach allows high-liability areas — like entrances, stairwells, and parking structures — to maintain longer archival windows without increasing retention across low-risk zones. | Multi-property management groups face an additional challenge. Investigations may require searching footage across several buildings. Centralized retrieval reduces the need to access separate systems site by site, reducing response time and strengthening documentation.","Campus incidents that need fast review | When altercations, unauthorized access, or safety concerns arise in schools or universities, administrators need to review footage immediately. | High camera density makes manual timeline review inefficient. Event-based search narrows results without relying solely on motion alerts, trimming down the time required to locate relevant activity. | Retention requirements can also shift during the search. Policies may require preservation beyond standard windows. Hybrid storage allows campuses to maintain accessible local recording while archiving footage for longer-term compliance needs.","Hotels tracking activity without over-monitoring | Hospital
465ity environments use video for more than security events. Accessing specific footage also happens during guest disputes, service complaints, or internal reviews. | Bandwidth in hotels is normally shared between surveillance systems and guest Wi-Fi networks. Non-stop full-resolution upload can negatively affect connectivity, especially during peak occupancy. Prioritizing local recording while synchronizing selected footage reduces network impact. | For multi-property brands, centralized oversight provides visibility across locations while allowing individual sites to maintain operational autonomy.","Warehouses needing more visibility, not more cameras | Logistics and warehouse facilities continue expanding camera coverage as automation increases. The main challenge is managing what already exists, rather than simply adding more devices. | Inventory discrepancies may come up days after goods move through a facility. Extended retention combined with event-based search reduces the need to manually review continuous footage. | As facilities expand, replicating full hardware stacks at every expansion point increases maintenance burden. A hybrid model allows recording to remain close to operational zones while centralizing retention and monitoring.","Franchises trying to standardize across locations | Franchise networks often inherit uneven infrastructure. Some locations operate newer systems; others rely on legacy hardware. Internet reliability varies by region. | Assigning a single deployment model for all sites can harm the system. Flexibility in storage architecture enables retention policies to be imposed centrally while still preserving local recording where there are bandwidth constraints. | For franchise owners, consistency is the priority without overhauling all sites at once. Hybrid deployment's gradual alignment supports this goal."].join(`
466`),multiline:!0,help:'One card per line: "Title | Paragraph 1 | Paragraph 2 | Paragraph 3".'},{key:"partners.label",label:"Partners section label",def:"For Partners"},{key:"partners.heading",label:"Partners heading",def:"What This Means for Partners"},{key:"partners.intro",label:"Partners intro",def:"Architecture decisions show up later in contracts, pricing, and customer retention — and not just in storage specs.",multiline:!0},{key:"partners.tableArea",label:"Partner column: Area",def:"Area"},{key:"partners.tableSystem",label:"Partner column: What the system does",def:"What the system does"},{key:"partners.tablePartner",label:"Partner column: What it means for partners",def:"What it means for partners"},{key:"partners.rows",label:"Partner table rows",def:["Hardware and upgrades | Keeps existing cameras while adding cloud layers | No replacements; easier upgrades; preserves investment","Upgrade cycle | Allows incremental changes instead of full replacements | Less project volatility; upgrades can be phased based on budget and risk","Cost control | Uses tiered retention and compression | More control over cloud costs; pricing tied to risk exposure","Forecasting | Keeps bandwidth and upload behavior predictable | Easier to support long-term contracts; fewer unexpected costs and disputes","Monitoring and visibility | Centralized view of camera health, storage, connectivity | Issues can be addressed proactively","Support efficiency | Reduces need for reactive service calls | Fewer emergency visits; lower support costs; more stable margins","Service role | Enables event search and long-term retention | Partners become part of ongoing operations (not just installation)","Positioning | Shifts focus from hardware to system oversight | Partners are tied to reliability, documentation, and continuity"].join(`
467`),multiline:!0,help:'One row per line: "Area | What the system does | What it means for partners".'},{key:"partners.swapHeading",label:"No forced swaps heading",def:"No Forced Hardware Swaps"},{key:"partners.swapP1",label:"No forced swaps paragraph 1",def:"Hybrid storage reduces the pressure to replace functioning systems simply to extend retention or add search capabilities. Cameras and recorders that still meet operational needs can remain in place while cloud retention and monitoring layers are added alongside them.",multiline:!0},{key:"partners.swapP2",label:"No forced swaps paragraph 2",def:"That is as important financially as it is for customer relationships. Customers are less resistant to upgrades when prior investments are preserved. Integrators avoid awkward conversations about scrapping equipment that's not yet at the end of its life.",multiline:!0}
467,{key:"partners.swapP3",label:"No forced swaps paragraph 3",def:"It also changes upgrade cycles. Instead of forklift replacements every few years, architecture can evolve incrementally. That reduces project volatility and allows partners to phase improvements according to budget and risk exposure.",multiline:!0},{key:"partners.costHeading",label:"Cost/value heading",def:"Easier Conversations Around Cost and Value"},{key:"partners.costP1",label:"Cost/value paragraph 1",def:"Storage often becomes contentious when costs rise unexpectedly. Uniform retention policies across all cameras can inflate cloud spend quickly, especially at higher resolutions.",multiline:!0},{key:"partners.costP2",label:"Cost/value paragraph 2",def:"Tiered retention and compression introduce more control. Partners can tie longer archival periods to high-liability zones and demonstrate how bandwidth and storage efficiency affect recurring fees. Pricing becomes tied to operational exposure rather than blanket assumptions.",multiline:!0},{key:"partners.recurringHeading",label:"Recurring services heading",def:"A Platform That Supports Recurring Services"},{key:"partners.recurringP1",label:"Recurring services paragraph 1",def:"Hybrid storage creates a cohesive, ongoing operation. Centralized monitoring allows partners to see different features across multiple sites — camera health, storage status, and connectivity. Issues can be tackled before customers notice the gaps.",multiline:!0},{key:"partners.recurringP2",label:"Recurring services paragraph 2",def:"Event search and long-term retention also shift the nature of support. When customers rely on partners to retrieve footage for disputes or compliance reviews, the integrator becomes part of operational continuity rather than just installation.",multiline:!0},{key:"conclusion.label",label:"Conclusion section label",def:"Conclusion"},{key:"conclusion.heading",label:"Conclusion heading",def:"Designing for Retention and Resilience"},{key:"conclusion.p1",label:"Conclusion paragraph 1",def:"It's uncommon for surveillance systems to fail all at once. Constraints show themselves gradually — retention windows tighten, bandwidth strain increases, retrieval slows, and compliance requests expand. Over time, storage design becomes the limitation that shapes everything else.",multiline:!0},{key:"conclusion.p2",label:"Conclusion paragraph 2",def:"Hybrid storage offers a practical path forward because it separates responsibilities within the system. Recording remains stable at the edge. Long-term retention and oversight reside in the cloud. Each layer handles the tasks it's best suited to manage. That separation reduces dependency on any single infrastructure element.",multiline:!0},{key:"conclusion.p3",label:"Conclusion paragraph 3",def:"Reliability is more than just uptime. It's also about documentation and traceability. Footage must be complete, accessible, and defensible when it's given to insurance carriers, regulatory bodies, or internal reviewers. Architecture that preserves retention integrity across distributed sites lowers exposure during audits and investigations.",multiline:!0},{key:"conclusion.callout",label:"Conclusion callout",def:"The value of hybrid storage is practical. It reduces fragility, extends retention intelligently, and supports oversight without forcing uniformity. {brandName} applies that model in a way that aligns storage design with operational reality. As compliance pressure and data volume continue to rise, that steadiness becomes a measurable advantage.",multiline:!0},{key:"download.eyebrow",label:"Download eyebrow",def:"Get the Full Document"},{key:"download.heading",label:"Download heading",def:"Download the White Paper"},{key:"download.subheading",label:"Download subheading",def:"The complete PDF includes all figures, the comparison tables, and the partner reference guide. Save it or share it with your team.",multiline:!0},{key:"download.downloadButton",label:"Download button",def:"Download PDF"},{key:"download.demoButton",label:"Demo button",def:"Schedule a Demo"},{key:"contact.title",label:"Contact dialog title",def:"Schedule a Demo"},{key:"contact.description",label:"Contact dialog description",def:"Tell us about your environment and we'll reach out within one business day."},{key:"contact.sentTitle",label:"Contact sent title",def:"Message Sent!"},{key:"contact.sentBody",label:"Contact sent body",def:"We'll be in touch within one business day."},{key:"contact.nameLabel",label:"Contact name label",def:"Name"},{key:"contact.namePlaceholder",label:"Contact name placeholder",def:"Your name"},{key:"contact.emailLabel",label:"Contact email label",def:"Email"},{key:"contact.emailPlaceholder",label:"Contact email placeholder",def:"[email protected]"},{key:"contact.messageLabel",label:"Contact message label",def:"Tell us about your setup"},{key:"contact.messagePlaceholder",label:"Contact message placeholder",def:"Number of sites, cameras, current system..."},{key:"contact.sendButton",label:"Contact send button",def:"Send Message"},{key:"contact.sendingButton",label:"Contact sending button",def:"Sending…"}]}
467,Ete={key:"resources.events",title:"Resources: Events",group:"Resources",fields:[{key:"hero.badge",label:"Hero badge",def:"Events"},{key:"hero.heading",label:"Hero heading",def:"Connect, Learn, and Meet Us"},{key:"hero.subheading",label:"Hero subheading",def:"Join us at upcoming events and discover what is next in video surveillance.",multiline:!0},{key:"empty.heading",label:"Empty-state heading",def:"No upcoming events"},{key:"empty.description",label:"Empty-state description",def:"Check back soon for announcements about upcoming events.",multiline:!0},{key:"card.dateLabel",label:"Card date label",def:"Event date"},{key:"card.locationLabel",label:"Card location label",def:"Location"},{key:"card.websiteLinkLabel",label:"Card website link label",def:"Visit event website"}]},Tte={key:"privacyPolicy",title:"Privacy Policy",group:"Legal",fields:[{key:"title",label:"Page title",def:"Privacy Policy"},{key:"lastUpdated",label:"Last updated",def:"Last updated: July 13, 2025"},{key:"intro",label:"Intro paragraph",def:"{domain} (“{brandName},” “we,” “us,” or “our”) is committed to protecting your privacy. This Privacy Policy describes how we collect, use, disclose, and safeguard your information when you visit our website and use our cloud-based surveillance storage and AI-powered event search services (collectively, the “Services”). Please read this policy carefully. If you do not agree with its terms, please discontinue use of the Services.",multiline:!0},{key:"s1.title",label:"1. Title",def:"Information We Collect"},{key:"s1.intro",label:"1. Intro",def:"We may collect the following categories of information:"},{key:"s1.items",label:"1. Items",def:["Contact Information. | When you register or use certain features, we may collect your name, email address, mailing address, and phone number.","Billing Information. | Payment method details and billing address are collected and processed via secure third-party payment processors. We do not store full payment card numbers on our servers.","Log Data. | We automatically collect information your browser or device sends when you access the Services, including IP address, browser type and version, pages visited, referral URLs, access times, and device identifiers.","Usage Data. | We may collect information about how you interact with the Services, such as features used, session duration, and configuration preferences."].join(`
468`),multiline:!0,help:'One list item per line: "Bold lead | Rest of text". Leave the second part blank for plain items.'},{key:"s2.title",label:"2. Title",def:"How We Use Your Information"},{key:"s2.intro",label:"2. Intro",def:"We use the information we collect to:"},{key:"s2.items",label:"2. Items",def:["Provide, operate, and maintain the Services.","Process transactions and send related information, including purchase confirmations and invoices.","Send administrative communications, such as updates, security alerts, and support messages.","Respond to comments and questions and provide customer support.","Analyze usage trends to improve and personalize the Services.","Comply with legal obligations and enforce our Terms & Conditions."].join(`
469`),multiline:!0,help:"One list item per line."},{key:"s3.title",label:"3. Title",def:"Sharing Your Information"},{key:"s3.intro",label:"3. Intro",def:"We do not sell, trade, or rent your personal information to third parties. We may share your information in the following limited circumstances:"},{key:"s3.items",label:"3. Items",def:["Service Providers. | We may share information with third-party vendors who assist us in operating the Services (e.g., payment processors, cloud hosting providers), subject to confidentiality obligations.","Legal Requirements. | We may disclose your information if required to do so by law or in response to valid legal process (e.g., a court order or subpoena).","Business Transfers. | In connection with a merger, acquisition, or sale of assets, your information may be transferred as part of that transaction.","Protection of Rights. | We may disclose information where we believe it is necessary to investigate, prevent, or take action regarding illegal activities, fraud, or threats to the safety of any person."].join(`
470`),multiline:!0,help:'One list item per line: "Bold lead | Rest of text".'},{key:"s4.title",label:"4. Title",def:"Cookies & Tracking Technologies"},{key:"s4.intro",label:"4. Intro",def:"We use cookies and similar tracking technologies to collect information about your interactions with the Services. You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent; however, some features of the Services may not function properly without cookies."},{key:"s4.items",label:"4. Items",def:["Session Cookies. | Used to operate the Services and keep you logged in.","Preference Cookies. | Used to remember your settings and preferences.","Analytics Co
470okies. | Used to understand how visitors interact with the Services."].join(`
471`),multiline:!0,help:'One list item per line: "Bold lead | Rest of text".'},{key:"s5.title",label:"5. Title",def:"Data Retention"},{key:"s5.body",label:"5. Body",def:"We retain your personal information for as long as your account is active or as needed to provide the Services. When data is no longer required for those purposes, we will securely delete or anonymize it in accordance with applicable law.",multiline:!0},{key:"s6.title",label:"6. Title",def:"Data Security"},{key:"s6.body",label:"6. Body",def:"We implement reasonable administrative, technical, and physical safeguards designed to protect your information from unauthorized access, disclosure, alteration, or destruction. However, no method of transmission over the Internet or electronic storage is 100% secure, and we cannot guarantee absolute security.",multiline:!0},{key:"s7.title",label:"7. Title",def:"International Data Transfers"},{key:"s7.body",label:"7. Body",def:"{brandName} is based in the United States. If you access the Services from outside the U.S., please be aware that your information will be transferred to, processed, and stored in the United States. We take appropriate measures to ensure that such transfers comply with applicable data protection laws and that your information remains protected.",multiline:!0},{key:"s8.title",label:"8. Title",def:"Children's Privacy"},{key:"s8.body",label:"8. Body",def:"Our Services are intended for users aged 18 and over. We do not knowingly collect personal information from children under 16. If you believe we have inadvertently collected information from a child under 16, please contact us immediately and we will take steps to delete that information.",multiline:!0},{key:"s9.title",label:"9. Title",def:"Your Rights & Choices"},{key:"s9.intro",label:"9. Intro",def:"Depending on your jurisdiction, you may have the following rights with respect to your personal information:"},{key:"s9.items",label:"9. Items",def:["Access. | Request a copy of the personal information we hold about you.","Correction. | Request that we correct inaccurate or incomplete information.","Deletion. | Request that we delete your personal information, subject to certain legal exceptions.","Objection / Restriction. | Object to or request restriction of certain processing activities.","Withdrawal of Consent. | Where processing is based on your consent, you may withdraw it at any time without affecting the lawfulness of prior processing."].join(`
472`),multiline:!0,help:'One list item per line: "Bold lead | Rest of text".'},{key:"s9.outroPre",label:"9. Outro (before email)",def:"To exercise any of these rights, please contact us at"},{key:"s10.title",label:"10. Title",def:"Third-Party Links"},{key:"s10.body",label:"10. Body",def:"The Services may contain links to third-party websites or services that are not operated by us. We have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party sites. We encourage you to review the privacy policy of every site you visit.",multiline:!0},{key:"s11.title",label:"11. Title",def:"Changes to This Policy"},{key:"s11.body",label:"11. Body",def:"We may update this Privacy Policy from time to time. When we do, we will revise the “Last updated” date at the top of this page and, where appropriate, notify you by email or via a notice on the Services before changes take effect. Your continued use of the Services after any changes constitutes your acceptance of the updated policy.",multiline:!0},{key:"s12.title",label:"12. Title",def:"Contact Us"},{key:"s12.intro",label:"12. Intro",def:"If you have any questions or concerns about this Privacy Policy or our data practices, please contact us at:"},{key:"s12.emailLabel",label:"12. Email label",def:"Email:"},{key:"s12.phoneLabel",label:"12. Phone label",def:"Phone:"},{key:"s12.addressLabel",label:"12. Address label",def:"Address:"}]},Ate={key:"termsConditions",title:"Terms & Conditions",group:"Legal",fields:[{key:"title",label:"Page title",def:"Terms & Conditions"},{key:"lastUpdated",label:"Last updated",def:"Last updated: July 13, 2025"},{key:"intro",label:"Intro paragraph",def:"These Terms and Conditions (“Terms”) govern your access to and use of {domain} (the “Site”) and any related services, features, content, or applications offered by {domain} (“{brandName},” “we,” “us,” or “our”). By accessing or using the Site or our services (collectively, the “Services”), you agree to be bound by these Terms. If you do not agree with these Terms, do not access or use the Services.",multiline:!0},{key:"s1.title",label:"1. Title",def:"Acceptance of Terms"},{key:"s1.body",label:"1. Body",def:"By registering for an account or using our Services in any manner, you agree to these Terms and our Privacy Policy. We may update these Terms at any time; changes will be effective upon posting. Your continued use after changes constitutes acceptance.",multiline:!0},{key:"s2.title",label:"2. Title",def:"Eligibility"},{key:"s2.body",label:"2. Body",def:"You must be at least 18 years old and capable of forming a binding contract to use the Services. By agreeing, you represent that you meet these requirements.",multiline:!0},{key:"s3.title",label:"3. Title",def:"Account Registration"},{key:"s3.items",label:"3. Items",def:["Account Information. | You agree to provide accurate, current, and complete information when creating an account and to keep it updated.","Credentials. | You are responsible for safeguarding your username, password, and any access credentials. You assume all risk for any activities conducted under your account.","Security. | Notify us immediately of any unauthorized use or security breach."].join(`
473`),multiline:!0,help:'One list item per line: "Bold lead | Rest of text".'},{key:"s4.title",label:"4. Title",def:"Services & License"},{key:"s4.items",label:"4. Items",def:["Provision. | We grant you a limited, non-exclusive, non-transferable, revocable license to access and use the Services solely in accordance with these Terms.","Scope. | You may use the Services only for lawful purposes and in compliance with all applicable laws and regulations."].join(`
474`),multiline:!0,help:'One list item per line: "Bold lead | Rest of text".'},{key:"s5.title",label:"5. Title",def:"Acceptable Use"},{key:"s5.intro",label:"5. Intro",def:"You agree not to:"},{key:"s5.items",label:"5. Items",def:["Reverse engineer, decompile, or disassemble any portion of the Services.","Use the Services to upload, post, or transmit any content that is unlawful, infringing, libelous, or otherwise objectionable.","Interfere with or disrupt the integrity or performance of the Services.","Attempt to gain unauthorized access to any part of the Services or related systems."].join(`
475`),multiline:!0,help:"One list item per line."},{key:"s6.title",label:"6. Title",def:"Fees & Payment"},{key:"s6.items",label:"6. Items",def:["Subscription Plans. | Certain features require payment of fees. All fees are stated on the Site and are exclusive of taxes.","Billing. | You authorize us (or our payment processor) to charge your chosen payment method.","Refunds. | Unless otherwise specified, all fees are non-refundable."].join(`
476`),multiline:!0,help:'One list item per line: "Bold lead | Rest of text".'},{key:"s7.title",label:"7. Title",def:"Intellectual Property"},{key:"s7.items",label:"7. Items",def:["Our Content. | All trademarks, service marks, logos, text, graphics, and other content on the Services are owned by or licensed to {brandName} and protected by law.","Your Content. | You retain ownership of any data or content you upload but grant us a worldwide, royalty-free license to use, host, store, and display it as necessary to provide the Services."].join(`
477`),multiline:!0,help:'One list item per line: "Bold lead | Rest of text".'},{key:"s8.title",label:"8. Title",def:"Confidentiality & Data Protection"},{key:"s8.items",label:"8. Items",def:["We will handle your personal and business data in accordance with our Privacy Policy.","You agree to keep confidential any non-public information regarding the Services or business operations of {brandName}."].join(`
478`),multiline:!0,help:"One list item per line."},{key:"s9.title",label:"9. Title",def:"Warranties & Disclaimers"},{key:"s9.items",label:"9. Items",def:["“AS IS.” | TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SERVICES ARE PROVIDED “AS IS” AND “AS AVAILABLE,” WITHOUT WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED.","NO GUARANTEE. | We do not guarantee uninterrupted or error-free operation of the Services."].join(`
479`),multiline:!0,help:'One list item per line: "Bold lead | Rest of text".'},{key:"s10.title",label:"10. Title",def:"Limitation of Liability"},{key:"s10.bodyPre",label:"10. Body (before brand)",def:"TO THE EXTENT PERMITTED BY LAW,"},{key:"s10.bodyPost",label:"10. Body (after brand)",def:"SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO YOUR USE OF THE SERVICES. OUR AGGREGATE LIABILITY SHALL NOT EXCEED THE AMOUNTS PAID BY YOU TO US IN THE SIX MONTHS PRECEDING THE EVENT GIVING RISE TO LIABILITY.",multiline:!0},{key:"s11.title",label:"11. Title",def:"Indemnification"},{key:"s11.body",label:"11. Body",def:"You agree to indemnify and hold harmless {brandName} and its officers, directors, employees, and agents from and against any claims, damages, losses, liabilities, and expenses (including reasonable attorneys’ fees) arising out of or related to your use of the Services or any breach of these Terms.",multiline:!0},{key:"s12.title",label:"12. Title",def:"Termination"},{key:"s12.items",label:"12. Items",def:["By You. | You may close your account at any time through your account settings.","By Us. | We may suspend or terminate your access for violation of these Terms or for any other reason, with or without notice.","Effect. | Upon termination, your right to use the Services immediately ceases. Sections 5–13 and any other provisions that by their nature should survive will remain in effect."].join(`
480`),multiline:!0,help:'One list item per line: "Bold lead | Rest of text".'},{key:"s13.title",label:"13. Title",def:"Governing Law & Dispute Resolution"},{key:"s13.body",label:"13. Body",def:"These Terms and any disputes arising out of or related to them will be governed by the laws of the State of New York, without regard to conflict of law principles. You agree to submit to the exclusive jurisdiction of the state and federal courts located in New York County, New York.",multiline:!0},{key:"s14.title",label:"14. Title",def:"Entire Agreement"},{key:"s14.body",label:"14. Body",def:"These Terms, together with the Privacy Policy and any other legal notices published by us on the Services, constitute the entire agreement between you and {brandName} regarding the Services and supersede any prior agreements.",multiline:!0},{key:"s15.title",label:"15. Title",def:"Severability"},{key:"s15.body",label:"15. Body",def:"If any provision of these Terms is held invali
480d or unenforceable, the remaining provisions will continue in full force and effect.",multiline:!0},{key:"s16.title",label:"16. Title",def:"Contact Information"},{key:"s16.intro",label:"16. Intro",def:"If you have questions or concerns about these Terms, please contact us at:"},{key:"s16.emailLabel",label:"16. Email label",def:"Email:"},{key:"s16.phoneLabel",label:"16. Phone label",def:"Phone:"},{key:"s16.addressLabel",label:"16. Address label",def:"Address:"}]},Mte={key:"sharedExport",title:"Shared Video Export",group:"General",fields:[{key:"title",label:"Card title",def:"Shared video export"},{key:"error.unavailable",label:"Link-unavailable fallback",def:"This link is not available."},{key:"error.verificationFailed",label:"Verification-failed fallback",def:"Verification failed."},{key:"error.generic",label:"Generic error fallback",def:"Something went wrong. Please try again."},{key:"clip.singular",label:"Clip count word (singular)",def:"clip"},{key:"clip.plural",label:"Clip count word (plural)",def:"clips"},{key:"availableUntilPrefix",label:"Expiry prefix (before date)",def:"Available until"},{key:"accessCodeLabel",label:"Access-code field label",def:"Access code"},{key:"accessCodePlaceholder",label:"Access-code placeholder",def:"Enter the code you were given"},{key:"downloadButton",label:"Download button",def:"Download"}]},w1=[nQ,aQ,rte,y_,nte,ate,ite,ote,iQ,Mte,sQ,rQ,lte,cte,dte,ute,mte,hte,pte,fte,gte,xte,vte,yte,bte,wte,jte,Nte,Ste,oN,b_,Cte,w_,kte,_te,Pte,Ete,Tte,Ate];function $F(e){const s=[e.firstName,e.lastName].filter(Boolean).join(" ").trim();return s&&e.email?`${s} (${e.email})`:s||e.email||e.id}function FSe(){const{toast:e}=Hs(),{data:s,isLoading:r}=ze({queryKey:["/api/admin/demo-account"]}),{data:n,isLoading:a}=ze({queryKey:["/api/admin/demo-account/eligible-users"]}),[i,o]=u.useState(!1),[l,c]=u.useState(null);u.useEffect(()=>{s&&(o(s.enabled),c(s.userId))},[s]);const d=n?.users??[],h=!l||d.some(b=>b.id===l),p=!!s?.userId&&!s?.valid,g=Et({mutationFn:async b=>(await Ze("PUT","/api/admin/demo-account",b)).json(),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/demo-account"]}),Je.invalidateQueries({queryKey:["/api/demo-account/availability"]}),e({title:"Demo account saved",description:"Live Demo settings have been applied."})},onError:b=>{e({title:"Save failed",description:b?.message||"Could not save demo account",variant:"destructive"})}}),v=()=>{if(i&&!l){e({title:"Pick a demo user",description:"Select a standard user account before enabling the Live Demo.",variant:"destructive"});return}g.mutate({enabled:i,userId:l||null})};return t.jsxs(ut,{"data-testid":"card-demo-account",children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"text-base flex items-center gap-2",children:[t.jsx(_K,{className:"w-4 h-4 text-primary"}),"Demo Account"]}),t.jsx(Xs,{children:`When enabled with a linked account, a "Live Demo" button appears on the public site that logs visitors directly into that user's dashboard. Only standard (non-admin) user accounts can be used.`})]}),t.jsx(mt,{className:"space-y-4",children:r?t.jsx("div",{className:"flex items-center justify-center py-6",children:t.jsx(Fe,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx(re,{htmlFor:"demo-enabled",className:"text-sm font-medium",children:"Enable Live Demo"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:'Show the public "Live Demo" button.'})]}),t.jsx(sr,{id:"demo-enabled",checked:i,onCheckedChange:o,"data-testid":"switch-demo-enabled"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{className:"text-sm font-medium",children:"Demo user account"}),t.jsxs(Us,{value:l??"",onValueChange:b=>c(b||null),disabled:a,children:[t.jsx($s,{"data-testid":"select-demo-user",children:t.jsx(zs,{placeholder:a?"Loading users…":"Select a standard user…"})}),t.jsxs(Fs,{children:[!h&&l?t.jsxs(rt,{value:l,"data-testid":"option-demo-user-current",children:[s?.user?$F(s.user):l," (unavailable)"]}):null,d.length===0&&h?t.jsx(rt,{value:"__none__",disabled:!0,children:"No standard user accounts found"}):null,d.map(b=>t.jsx(rt,{value:b.id,"data-testid":`option-demo-user-${b.id}`,children:$F(b)},b.id))]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Owners, Admins, Super Admins, and disabled accounts are not eligible."})]}),p?t.jsxs(pu,{variant:"destructive","data-testid":"alert-demo-invalid",children:[t.jsx(Pn,{className:"h-4 w-4"}),t.jsx(fu,{children:"The linked account is no longer a valid standard user (it may have been promoted, disabled, or deleted). The Live Demo button is hidden until you link a valid user."})]}):null,t.jsx("div",{className:"flex justify-end",children:t.jsxs(L,{onClick:v,disabled:g.isPending,"data-testid":"button-demo-save",children:[g.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Save demo settings"]})})]})})]})}function BSe({form:e}){const{toast:s}=Hs(),[r,n]=u.useState(!1),[a,i]=u.useState("onboarding"),[o,l]=u.useState("user"),[c,d]=u.useState(!0),[h,p]=u.useState(!1),{data:g,isLoading:v,error:b}=ze({queryKey:["/api/admin/branding/email-preview",a,o,c,c?e:null],queryFn:async()=>c?(await Ze("POST","/api/admin/branding/email-preview",{kind:a,role:o,branding:e})).json():(await Ze("GET",`/api/admin/branding/email-preview?kind=${a}&role=${o}`)).json(),enabled:r}),y=async()=>{p(!0);try{const j=await(await Ze("POST","/api/admin/branding/email-preview/sen
480d",{kind:a,role:o,...c?{branding:e}:{}})).json();s({title:"Test email sent",description:`Sent to ${j?.to||"your email"}.`})}catch(w){s({title:"Send failed",description:w?.message||"Could not send test email",variant:"destructive"})}finally{p(!1)}};return t.jsxs(Ys,{open:r,onOpenChange:n,children:[t.jsx(_fe,{asChild:!0,children:t.jsxs(L,{variant:"outline",size:"sm","data-testid":"button-email-preview",children:[t.jsx(qi,{className:"w-4 h-4 mr-2"}),"Preview welcome email"]})}),t.jsxs(Ws,{className:"max-w-3xl h-[85vh] flex flex-col",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Welcome email preview"}),t.jsx(cr,{children:c?"Rendered with your current edits — including unsaved changes, so you can check them before saving. Sample name, email, and credentials are used.":"Rendered with the last-saved branding only. Unsaved edits are not shown. Sample name, email, and credentials are used."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(Us,{value:a,onValueChange:w=>i(w),children:[t.jsx($s,{className:"w-[220px]","data-testid":"select-email-preview-kind",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"onboarding",children:"Welcome (with password)"}),t.jsx(rt,{value:"invite",children:"Invite link (set password)"})]})]}),t.jsxs(Us,{value:o,onValueChange:w=>l(w),children:[t.jsx($s,{className:"w-[140px]","data-testid":"select-email-preview-role",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"user",children:"User"}),t.jsx(rt,{value:"owner",children:"Owner"}),t.jsx(rt,{value:"admin",children:"Admin"})]})]}),t.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border px-3 py-1.5",children:[t.jsx(sr,{id:"email-preview-use-edits",checked:c,onCheckedChange:d,"data-testid":"switch-email-preview-use-edits"}),t.jsx(re,{htmlFor:"email-preview-use-edits",className:"text-xs cursor-pointer whitespace-nowrap",children:c?"Current edits (unsaved)":"Saved branding"})]}),t.jsx("div",{className:"flex-1"}),t.jsxs(L,{variant:"outline",size:"sm",onClick:y,disabled:h||v,"data-testid":"button-email-preview-send-test",children:[h?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Ja,{className:"w-4 h-4 mr-2"}),"Send test to myself"]})]}),g?.subject?t.jsxs("p",{className:"text-xs text-muted-foreground truncate","data-testid":"text-email-preview-subject",children:["Subject: ",g.subject]}):null,t.jsx("div",{className:"flex-1 min-h-0 rounded-md border border-border overflow-hidden bg-white",children:v?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(Fe,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):b?t.jsx("div",{className:"flex items-center justify-center h-full p-6",children:t.jsx("p",{className:"text-sm text-destructive",children:b?.message||"Could not load the email preview"})}):t.jsx("iframe",{title:"Welcome email preview",srcDoc:g?.html||"",sandbox:"",className:"w-full h-full border-0","data-testid":"iframe-email-preview"})})]})]})}function USe(){const{data:e,isLoading:s}=nY(),{toast:r}=Hs(),n=Su(),[a,i]=u.useState(Iy),[o,l]=u.useState(!1);u.useEffect(()=>{e&&i(e)},[e]);const c=(p,g)=>i(v=>({...v,[p]:g})),d=async()=>{const p=US.shape.landingHeroCustomButtonUrl.safeParse(a.landingHeroCustomButtonUrl);if(!p.success||a.landingHeroCustomButtonEnabled==="true"&&!p.data){r({title:"Invalid custom button link",description:"Enter a complete http:// or https:// URL before enabling the custom homepage button.",variant:"destructive"});return}const g=US.shape.landingHeroSecondaryButtonUrl.safeParse(a.landingHeroSecondaryButtonUrl);if(!g.success){r({title:"Invalid Learn More link",description:"Enter a complete http:// or https:// URL, or leave the link blank to open the Contact Us form.",variant:"destructive"});return}for(const v of a.events){if(!v.eventDate.trim()||!v.location.trim()||!v.description.trim()){r({title:"Complete each event",description:"Event date, location, and description are required.",variant:"destructive"});return}if(v.websiteUrl.trim()){try{new URL(v.websiteUrl)}catch{r({title:"Invalid event website",description:"Enter a complete website URL, including https://.",variant:"destructive"});return}if(!v.websiteTitle.trim()){r({title:"Website title required",description:"Add a title for the event website link.",variant:"destructive"});return}}}l(!0);try{await Ze("PUT","/api/admin/branding",{...a,landingHeroSecondaryButtonUrl:g.data}),await n.invalidateQueries({queryKey:["/api/branding"]}
480),Je.invalidateQueries({queryKey:["/api/branding"]}),r({title:"Branding saved",description:"Your branding changes have been applied."})}catch(v){r({title:"Save failed",description:v?.message||"Could not save branding",variant:"destructive"})}finally{l(!1)}},h=()=>i(Iy);return s&&!e?t.jsx("div",{className:"flex items-center justify-center py-16",children:t.jsx(Fe,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold","data-testid":"text-oem-branding-title",children:"OEM Branding"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"White-label the platform. Blank fields fall back to the built-in defaults."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(BSe,{form:a}),t.jsxs(L,{variant:"outline",size:"sm",onClick:h,disabled:o,"data-testid":"button-branding-reset",children:[t.jsx(bh,{className:"w-4 h-4 mr-2"}),"Reset to defaults"]}),t.jsxs(L,{onClick:d,disabled:o,"data-testid":"button-branding-save",children:[o?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Save changes"]})]})]}),W$.filter(p=>p.title!=="Live Demo").map(p=>t.jsx(FF,{group:p,form:a,setField:c},p.title)),t.jsx(zSe,{events:a.events,onChange:p=>i(g=>({...g,events:p})),onUpdateEvent:(p,g)=>i(v=>({...v,events:v.events.map(b=>b.id===p?{...b,...g}:b)}))}),t.jsx(HSe,{value:a.pageText,onChange:p=>c("pageText",p)}),t.jsx(FSe,{}),W$.filter(p=>p.title==="Live Demo").map(p=>t.jsx(FF,{group:p,form:a,setField:c},p.title)),t.jsx("div",{className:"flex justify-end",children:t.jsxs(L,{onClick:d,disabled:o,"data-testid":"button-branding-save-bottom",children:[o?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Save changes"]})})]})}function zSe({events:e,onChange:s,onUpdateEvent:r}){const{toast:n}=Hs(),[a,i]=u.useState(null),o=(p,g)=>s(e.map(v=>v.id===p?{...v,...g}:v)),l=()=>s([...e,{id:crypto.randomUUID(),imageUrl:"",eventDate:"",location:"",websiteTitle:"",websiteUrl:"",description:""}]),c=p=>s(e.filter(g=>g.id!==p)),d=(p,g)=>{const v=p+g;if(v<0||v>=e.length)return;const b=[...e];[b[p],b[v]]=[b[v],b[p]],s(b)},h=async(p,g)=>{if(!["image/png","image/jpeg","image/webp"].includes(g.type)){n({title:"Upload failed",description:"Use a PNG, JPEG, or WebP image.",variant:"destructive"});return}if(g.size>6*1024*1024){n({title:"Upload failed",description:"Event images must be 6 MB or smaller.",variant:"destructive"});return}i(p.id);try{const b=await(await Ze("POST","/api/admin/branding/event-image",{imageBase64:await Rte(g),contentType:g.type})).json();if(!b?.url)throw new Error(b?.message||"No image URL returned");r(p.id,{imageUrl:b.url}),n({title:"Event image uploaded",description:"Remember to save changes."})}catch(v){n({title:"Upload failed",description:v?.message||"Could not upload event image",variant:"destructive"})}finally{i(null)}};return t.jsxs(ut,{"data-testid":"card-branding-events",children:[t.jsxs(xs,{children:[t.jsx(ys,{className:"text-base",children:"Events"}),t.jsx(Xs,{children:"Manage the events shown on the public Resources → Events page. Save changes after editing."})]}),t.jsxs(mt,{className:"space-y-5",children:[e.length===0?t.jsx("p",{className:"rounded-md border border-dashed border-border p-6 text-center text-sm text-muted-foreground",children:"No events added yet."}):null,e.map((p,g)=>t.jsxs("div",{className:"space-y-4 rounded-lg border border-border p-4","data-testid":`branding-event-${p.id}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("p",{className:"font-medium",children:["Event ",g+1]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(L,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(g,-1),disabled:g===0,"aria-label":"Move event up",children:"↑"}),t.jsx(L,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(g,1),disabled:g===e.length-1,"aria-label":"Move event down",children:"↓"}),t.jsx(L,{type:"button",variant:"ghost",size:"icon",onClick:()=>c(p.id),"aria-label":"Remove event",children:t.jsx(va,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1.5 md:col-span-2",children:[t.jsx(re,{children:"Event image"}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"h-20 w-32 overflow-hidden rounded border border-border bg-muted/30",children:p.imageUrl?t.jsx("img",{src:p.imageUrl,alt:"",className:"h-full w-full object-cover"}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-muted-foreground",children:"No image"})}),t.jsx("input",{id:`event-image-${p.id}`,type:"file",accept:"image/png,image/jpeg,image/webp",className:"hidden",onChange:v=>{const b=v.target.files?.[0];v.target.value="",b&&h(p,b)}}),t.jsxs(L,{type:"button",variant:"outline",onClick:()=>document.getElementById(`event-image-${p.id}`)?.click(),disabled:a!==null,children:[a===p.id?t.jsx(Fe,{className:"mr-2 h-4 w-4 animate-spin"}):t.jsx(Om,{className:"mr-2 h-4 w-4"})," Upload image"]}),p.imageUrl?t.jsx(L,{type:"button",variant:"ghost",onClick:()=>o(p.id,{imageUrl:""}),children:"Clear"}):null]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:`event-date-${p.id}`,children:"Event date"}),t.jsx(ke,{id:`event-date-${p.id}`,value:p.eventDate,onChange:v=>o(p.id,{eventDate:v.target.value}),placeholder:"October 14–16, 2026"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:`event-location-${p.id}`,children:"Event location"}),t.jsx(ke,{id:`event-location-${p.id}`,value:p.location,onChange:v=>o(p.id,{location:v.target.value})})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:`event-website-title-${p.id}`,children:"Website title"}),t.jsx(ke,{id:`event-website-title-${p.id}`,value:p.websiteTitle,onChange:v=>o(p.id,{websiteTitle:v.target.value}),placeholder:"Learn more"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:`event-website-url-${p.id}`,children:"Website URL"}),t.jsx(ke,{id:`event-website-url-${p.id}`,type:"url",value:p.websiteUrl,onChange:v=>o(p.id,{websiteUrl:v.target.value}),placeholder:"https://example.com/event"})]}),t.jsxs("div",{className:"space-y-1.5 md:col-span-2",children:[t.jsx(re,{htmlFor:`event-description-${p.id}`,children:"Event description"}),t.jsx(Nn,{id:`event-description-${p.id}`,value:p.description,onChange:v=>o(p.id,{description:v.target.value}),rows:4})]})]})]}
480,p.id)),t.jsx(L,{type:"button",variant:"outline",onClick:l,children:"Add event"})]})]})}function HSe({value:e,onChange:s}){const r=Array.from(new Set(w1.map(h=>h.group))),[n,a]=u.useState(w1[0]?.key??""),i=w1.find(h=>h.key===n),o=JY(e),l=h=>h.fields.filter(p=>(o[`${h.key}.${p.key}`]??"").trim()!=="").length,c=(h,p)=>{const g={...o},v=`${n}.${h}`;p.trim()===""?delete g[v]:g[v]=p,s(u6(g))},d=()=>{if(!i)return;const h={...o};for(const p of i.fields)delete h[`${i.key}.${p.key}`];s(u6(h))};return t.jsxs(ut,{"data-testid":"card-page-content",children:[t.jsxs(xs,{children:[t.jsx(ys,{className:"text-base",children:"Page Content"}),t.jsxs(Xs,{children:["Customize the copy on every public page — headings, paragraphs, cards, and button labels. Blank fields use the built-in default (shown as the placeholder). ","{productName}",","," ","{brandName}",", ","{phone}",", ","{supportEmail}",", ","{salesEmail}",", and ","{domain}"," tokens are replaced with your branding values. Remember to save changes."]})]}),t.jsxs(mt,{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs(Us,{value:n,onValueChange:a,children:[t.jsx($s,{className:"w-[320px]","data-testid":"select-page-content-page",children:t.jsx(zs,{placeholder:"Select a page…"})}),t.jsx(Fs,{children:r.map(h=>t.jsxs("div",{children:[t.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground",children:h}),w1.filter(p=>p.group===h).map(p=>{const g=l(p);return t.jsxs(rt,{value:p.key,"data-testid":`option-page-content-${p.key}`,children:[p.title,g>0?` (${g} customized)`:""]},p.key)})]},h))})]}),i&&l(i)>0?t.jsxs(L,{variant:"outline",size:"sm",onClick:d,"data-testid":"button-page-content-reset-page",children:[t.jsx(bh,{className:"w-4 h-4 mr-2"}),"Reset this page"]}):null]}),i?t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:i.fields.map(h=>t.jsx(qSe,{pageKey:i.key,field:h,value:Vfe(h,o[`${i.key}.${h.key}`]??""),onChange:p=>c(h.key,p)},h.key))}):null]})]})}function qSe({pageKey:e,field:s,value:r,onChange:n}){const a=`input-pagetext-${e}.${s.key}`,i=s.multiline||s.def.includes(`
481`)||s.def.length>120,o=s.icon===!0;return t.jsxs("div",{className:`space-y-1.5 ${i||o?"md:col-span-2":""}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(re,{htmlFor:a,children:s.label}),r.trim()!==""?t.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground underline",onClick:()=>n(""),"data-testid":`button-pagetext-reset-${e}.${s.key}`,children:"Reset to default"}):null]}),o?t.jsx(VSe,{pageKey:e,field:s,value:r,onChange:n}):i?t.jsx(Nn,{id:a,value:r,onChange:l=>n(l.target.value),placeholder:s.def,rows:Math.min(8,Math.max(2,s.def.split(`
482`).length)),"data-testid":a}):t.jsx(ke,{id:a,value:r,onChange:l=>n(l.target.value),placeholder:s.def,"data-testid":a}),s.help?t.jsx("p",{className:"text-xs text-muted-foreground",children:s.help}):null]})}function VSe({pageKey:e,field:s,value:r,onChange:n}){const a=s.def.split(`
483`).map(p=>p.trim()),i=r.trim()===""?[]:r.split(`
484`).map(p=>p.trim()),o=a.length,l=p=>{const g=i[p];return g&&g.trim()!==""?g.trim():a[p]??""},c=p=>{const g=p.every((v,b)=>v===(a[b]??""));n(g?"":p.join(`
485`))},d=(p,g)=>{const v=[];for(let b=0;b<o;b++)v.push(b===p?g:l(b));c(v)},h=({name:p})=>{const g=tQ(p,Z5.Star);return t.jsx(g,{className:"w-4 h-4 shrink-0 text-muted-foreground"})};return t.jsx("div",{className:"space-y-2",children:Array.from({length:o}).map((p,g)=>{const v=l(g),b=i[g],y=b!==void 0&&b.trim()!==""&&!Zfe(b.trim()),w=`select-pageicon-${e}.${s.key}-${g}`;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-muted-foreground w-6 shrink-0 text-right",children:[g+1,"."]}),t.jsxs(Us,{value:v,onValueChange:j=>d(g,j),children:[t.jsx($s,{className:"flex-1","data-testid":w,children:t.jsx(zs,{children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(h,{name:v}),t.jsx("span",{children:v})]})})}),t.jsx(Fs,{children:Jfe.map(j=>{const x=Z5[j];return t.jsx(rt,{value:j,"data-testid":`${w}-option-${j}`,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(x,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{children:j})]})},j)})})]})]}),y?t.jsxs("div",{className:"ml-8 flex items-center gap-1.5 text-xs text-amber-600 dar
485k:text-amber-400","data-testid":`${w}-stale-warning`,children:[t.jsx(Pn,{className:"w-3.5 h-3.5 shrink-0"}),t.jsxs("span",{children:["Unknown icon “",b.trim(),"” — using default"]})]}):null]},g)})})}function FF({group:e,form:s,setField:r}){return t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{className:"text-base",children:e.title}),e.description?t.jsx(Xs,{children:e.description}):null]}),t.jsx(mt,{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:e.fields.map(n=>t.jsx(WSe,{field:n,value:s[n.key],onChange:a=>r(n.key,a),showValue:n.showKey?s[n.showKey]:void 0,onShowChange:n.showKey?a=>r(n.showKey,a):void 0},n.key))})]})}function WSe({field:e,value:s,onChange:r,showValue:n,onShowChange:a}){const i=`input-branding-${e.key}`;if(e.type==="image")return t.jsx(KSe,{field:e,value:s,onChange:r,showValue:n,onShowChange:a});if(e.type==="toggle"){const o=s!=="false";return t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-border px-3 py-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(re,{htmlFor:i,className:"cursor-pointer",children:e.label}),e.help?t.jsx("p",{className:"text-xs text-muted-foreground",children:e.help}):null]}),t.jsx(sr,{id:i,checked:o,onCheckedChange:l=>r(l?"true":"false"),"data-testid":i})]})}return e.type==="color"?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:i,children:e.label}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"color",value:/^#[0-9a-fA-F]{6}$/.test(s)?s:"#000000",onChange:o=>r(o.target.value),className:"h-9 w-12 rounded border border-input bg-background cursor-pointer","data-testid":`${i}-swatch`,"aria-label":`${e.label} color picker`}),t.jsx(ke,{id:i,value:s,onChange:o=>r(o.target.value),placeholder:"#000000","data-testid":i})]}),e.help?t.jsx("p",{className:"text-xs text-muted-foreground",children:e.help}):null]}):e.type==="textarea"?t.jsxs("div",{className:"space-y-1.5 md:col-span-2",children:[t.jsx(re,{htmlFor:i,children:e.label}),t.jsx(Nn,{id:i,value:s,onChange:o=>r(o.target.value),rows:3,"data-testid":i}),e.help?t.jsx("p",{className:"text-xs text-muted-foreground",children:e.help}):null]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:i,children:e.label}),t.jsx(ke,{id:i,type:e.type==="email"?"email":e.type==="url"?"url":"text",value:s,onChange:o=>r(o.target.value),"data-testid":i}),e.help?t.jsx("p",{className:"text-xs text-muted-foreground",children:e.help}):null]})}function Rte(e){return new Promise((s,r)=>{const n=new FileReader;n.onload=()=>{const a=String(n.result||""),i=a.indexOf(",");s(i>=0?a.slice(i+1):a)},n.onerror=()=>r(new Error("Could not read file")),n.readAsDataURL(e)})}function KSe({field:e,value:s,onChange:r,showValue:n,onShowChange:a}){const{toast:i}=Hs(),o=u.useRef(null),[l,c]=u.useState(!1),d=`input-branding-${e.key}`,h=async p=>{const g=p.target.files?.[0];if(p.target.value="",!!g){c(!0);try{if(g.size>6*1024*1024)throw new Error("Image too large (max 6 MB)");const v=await Rte(g),y=await(await Ze("POST","/api/admin/branding/logo",{imageBase64:v,contentType:g.type||"application/octet-stream"})).json();if(!y?.url)throw new Error("No URL returned");r(y.url),i({title:"Image uploaded",description:`${e.label} uploaded. Remember to save changes.`})}catch(v){i({title:"Upload failed",description:v?.message||"Could not upload image",variant:"destructive"})}finally{c(!1)}}};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:e.label}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"h-12 w-12 shrink-0 rounded border border-border bg-muted/40 flex items-center justify-center overflow-hidden",children:s?t.jsx("img",{src:s,alt:e.label,className:"h-full w-full object-contain","data-testid":`img-branding-${e.key}`}):t.jsx("span",{className:"text-[10px] text-muted-foreground text-center px-1",children:"Default"})}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx(ke,{value:s,onChange:p=>r(p.target.value),placeholder:"Paste a URL or upload","data-testid":d})}),t.jsx("input",{ref:o,type:"file",accept:"image/*",onChange:h,className:"hidden"}),t.jsx(L,{type:"button",variant:"outline",size:"icon",onClick:()=>o.current?.click(),disabled:l,"data-testid":`button-branding-upload-${e.key}`,title:`Upload ${e.label}`,children:l?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):t.jsx(Om,{className:"w-4 h-4"})}),s?t.jsx(L,{type:"button",variant:"ghost",size:"icon",onClick:()=>r(""),"data-testid":`button-branding-clear-${e.key}`,title:"Clear (use default)",children:t.jsx(va,{className:"w-4 h-4"})}):null]}),a?t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-border px-3 py-1.5",children:[t.jsx(re,{htmlFor:`${d}-show`,className:"cursor-pointer text-xs text-muted-foreground",children:"Show on page"}),t.jsx(sr,{id:`${d}-show`,checked:n!=="false",onCheckedChange:p=>a(p?"true":"false"),"data-testid":`switch-branding-${e.key}-show`})]}):null]})}function RP(e,s){return`${(e||"")[0]||""}${(s||"")[0]||""}`.toUpperCase()||"?"}function Ite(e,s){const r=e.split(".").map(Number),n=s.split(".").map(Number);for(let a=0;a<Math.max(r.length,n.length);a++){const i=(r[a]||0)-(n[a]||0);if(i!==0)return i>0}return!0}function l0(e){if(e===0)return"0 B";const s=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,r)).toFixed(r>0?1:0)} ${s[r]}`}function GSe({device:e}){const[s,r]=u.useState(!1),[n,a]=u.useState(!1),[i,o]=u.useState(null),[l,c]=u.useState(null),[d,h]=u.useState(!1),p=window.location.origin,[g,v]=u.useState(p),[b,y]=u.useState(!1),[w,j]=u.useState("8971"),{toast:x}=Hs(),C=Et({mutationFn:async({domain:_,frigatePort:A})=>(await Ze("POST",`/api/edge-devices/${e.id}/generate-sync-key`,{domain:_,frigatePort:parseInt(A,10)||5e3})).json(),onSuccess:_=>
485{o(_.apiKey),c(_.installerToken),a(!0),h(!1),Je.invalidateQueries({queryKey:["/api/edge-devices"]}),x({title:"API Key Generated",description:"Run the install command on your edge device."})},onError:()=>{x({title:"Failed to generate key",variant:"destructive"})}}),k=Et({mutationFn:async()=>{await Ze("DELETE",`/api/edge-devices/${e.id}/sync-key`)},onSuccess:()=>{o(null),a(!1),Je.invalidateQueries({queryKey:["/api/edge-devices"]}),x({title:"API Key Revoked"})},onError:()=>{x({title:"Failed to revoke key",variant:"destructive"})}}),S=!!e.hasEdgeSyncKey;return t.jsxs("div",{className:"mt-3 border-t pt-3",children:[t.jsxs("button",{onClick:()=>r(!s),className:"flex items-center gap-2 text-sm font-medium w-full text-left","data-testid":`button-toggle-edge-sync-${e.id}`,children:[t.jsx(pn,{className:"w-4 h-4 text-primary"}),t.jsx("span",{children:"Edge Sync"}),S?t.jsx(Ke,{variant:"secondary",className:"text-xs no-default-active-elevate ml-1",children:"Key Active"}):t.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"Not configured"}),s?t.jsx(Ig,{className:"w-4 h-4 ml-auto text-muted-foreground"}):t.jsx(Xa,{className:"w-4 h-4 ml-auto text-muted-foreground"})]}),s&&t.jsxs("div",{className:"mt-3 space-y-3",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable edge-side cloud sync so this device uploads recordings directly to GCS, bypassing the server."}),i&&n&&t.jsxs("div",{className:"p-3 rounded-md bg-muted/50 border",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(yg,{className:"w-3.5 h-3.5 text-primary"}),t.jsx("span",{className:"text-xs font-medium",children:"Edge Sync Ready"})]}),l&&t.jsxs("div",{className:"space-y-2 mb-3",children:[t.jsx("p",{className:"text-xs font-medium text-foreground",children:"Run this on the edge device (link expires in 15 min):"}),t.jsx("div",{className:"relative",children:t.jsxs("code",{className:"block text-xs bg-background/50 p-2 rounded break-all select-all","data-testid":`text-install-cmd-${e.id}`,children:["curl -fsS ",window.location.origin,"/api/edge-sync/setup/",l," -o setup-edge-sync.sh && sudo bash setup-edge-sync.sh"]})}),t.jsx(L,{variant:"outline",size:"sm",onClick:()=>{const _=`curl -fsS ${window.location.origin}/api/edge-sync/setup/${l} -o setup-edge-sync.sh && sudo bash setup-edge-sync.sh`;navigator.clipboard.writeText(_),x({title:"Install command copied"})},"data-testid":`button-copy-install-${e.id}`,children:"Copy Install Command"})]}),t.jsxs("div",{className:"text-xs text-muted-foreground pt-2 border-t mt-2",children:[t.jsx("p",{className:"font-medium mb-1",children:"API Key (for reference):"}),t.jsx("code",{className:"text-xs break-all select-all block","data-testid":`text-api-key-${e.id}`,children:i})]})]}),t.jsx(Ys,{open:d,onOpenChange:h,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Edge Sync Setup"}),t.jsxs(cr,{children:["Configure the connection for device ",e.serialNumber]})]}),t.jsxs("div",{className:"space-y-4 py-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:`domain-${e.id}`,children:"Server Domain"}),t.jsx(ke,{id:`domain-${e.id}`,placeholder:"https://trudev1.com",value:b?g:p,onChange:_=>v(_.target.value),readOnly:!b,className:b?"":"bg-muted/50","data-testid":`input-domain-${e.id}`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{id:`custom-domain-${e.id}`,checked:b,onCheckedChange:_=>{y(_),_||v(p)},"data-testid":`checkbox-custom-domain-${e.id}`}),t.jsx("label",{htmlFor:`custom-domain-${e.id}`,className:"text-sm text-muted-foreground cursor-pointer select-none",children:"Use a custom domain"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:`port-${e.id}`,children:"Edge Device Port"}),t.jsx(ke,{id:`port-${e.id}`,placeholder:"8971",value:w,onChange:_=>j(_.target.value),"data-testid":`input-port-${e.id}`}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Local port on the Edge device (default: 8971)"})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),t.jsxs(L,{onClick:()=>C.mutate({domain:b?g:p,frigatePort:w}),disabled:C.isPending||!(b?g:p).trim(),"data-testid":`button-confirm-generate-${e.id}`,children:[C.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):t.jsx(yg,{className:"w-3.5 h-3.5 mr-1.5"}),"Generate & Create Installer"]})]})]})}),t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:S?t.jsxs(t.Fragment,{children:[t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>h(!0),disabled:C.isPending,"data-testid":`button-regenerate-key-${e.id}`,children:[C.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):t.jsx(tl,{className:"w-3.5 h-3.5 mr-1.5"}),"Regenerate"]}),t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>k.mutate(),disabled:k.isPending,"data-testid":`button-revoke-key-${e.id}`,children:[k.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):t.jsx(ES,{className:"w-3.5 h-3.5 mr-1.5"}),"Revoke"]})]}):t.jsxs(L,{size:"sm",onClick:()=>h(!0),disabled:C.isPending,"data-testid":`button-generate-key-${e.id}`,children:[C.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):t.jsx(yg,{className:"w-3.5 h-3.5 mr-1.5"}),"Generate API Key"]})}),S&&t.jsx(QSe,{deviceId:e.id,serialNumber:e.serialNumber})]})]})}const YSe={"1.3.17":"Minimum clip duration: null end_time fallback increased to 120s; all clips enforced to at least 60s.","1.3.15":"Motion segment aggregation fix: low-motion segments were being skipped instead of terminating merged events.","1.3.7":"Base edge sync with basic event upload and GCS signed-URL flow."};function QSe({deviceId:e,serialNumber:s}){const{toast:r}=Hs(),[n,a]=u.useState("latest"),i=ze({queryKey:["/api/edge-sync/versions"],queryFn:async()=>{const h=await fetch("/api/edge-sync/versions",{credentials:"include"});if(!h.ok)throw new Error("Failed to fetch versions");return h.json()},staleTime:6e4}),o=ze({queryKey:["/api/edge-devices",e,"commands"],queryFn:async()=>{const h=await fetch(`/api/edge-devices/${e}/commands`,{credentials:"include"});if(!h.ok)throw new Error("Failed to fetch commands");return h.json()},refetchInterval:5e3}),l=Et({mutationFn:async()=>{const h=n!=="latest"?{version:n}:void 0;return(await Ze("POST",`/api/edge-devices/${e}/deploy-edge-sync`,h)).json()},onSuccess:h=>
485{Je.invalidateQueries({queryKey:["/api/edge-devices",e,"commands"]});const p=n==="latest"?"latest":`v${n}`;r({title:"Update queued",description:`${p} — Command ${h.commandId} will run on next check-in.`})},onError:()=>{r({title:"Failed to queue update",variant:"destructive"})}}),c=Et({mutationFn:async({type:h,payload:p})=>(await Ze("POST",`/api/edge-devices/${e}/commands`,{type:h,payload:p})).json(),onSuccess:h=>{Je.invalidateQueries({queryKey:["/api/edge-devices",e,"commands"]}),r({title:"Command queued",description:"Will run on next check-in."})},onError:()=>{r({title:"Failed to queue command",variant:"destructive"})}}),d=(o.data?.commands||[]).slice(-5).reverse();return t.jsxs("div",{className:"mt-3 pt-3 border-t space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D5,{className:"w-3.5 h-3.5 text-primary"}),t.jsx("span",{className:"text-xs font-medium",children:"Remote Commands"})]}),i.data?.publishWarning&&t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-2 text-[11px] text-amber-700 dark:text-amber-400","data-testid":`warning-unpublished-version-${e}`,children:[t.jsx(ta,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),t.jsxs("span",{children:[t.jsxs("span",{className:"font-medium",children:["edge-sync v",i.data?.currentVersion," is not published."]})," ","The newest snapshot is v",i.data?.latestPublished||"none",", so devices won't auto-update to it. Add"," ",t.jsxs("code",{className:"font-mono",children:["scripts/versions/edge-sync-v",i.data?.currentVersion,".js"]})," to publish it."]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("select",{value:n,onChange:h=>a(h.target.value),className:"h-8 px-2 text-xs rounded-md border border-input bg-background","data-testid":`select-version-${e}`,children:[t.jsxs("option",{value:"latest",children:["Latest (v",i.data?.currentVersion||"...",")"]}),i.data?.versions?.filter(h=>!h.current).map(h=>t.jsxs("option",{value:h.version,children:["v",h.version]},h.version))]}),t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>l.mutate(),disabled:l.isPending,"data-testid":`button-deploy-update-${e}`,children:[l.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):t.jsx(Om,{className:"w-3.5 h-3.5 mr-1.5"}),"Push Update"]}),t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>c.mutate({type:"restart_service"}),disabled:c.isPending,"data-testid":`button-restart-service-${e}`,children:[c.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):t.jsx(bh,{className:"w-3.5 h-3.5 mr-1.5"}),"Restart Service"]})]}),(()=>{const h=n==="latest"?i.data?.currentVersion:n,p=h?YSe[h]:null;return p?t.jsxs("p",{className:"text-[11px] text-muted-foreground px-0.5","data-testid":`version-note-${e}`,children:[t.jsxs("span",{className:"font-medium",children:["v",h,":"]})," ",p]}):null})()]}),d.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"Recent Commands"}),d.map(h=>t.jsxs("div",{className:"flex items-start gap-2 text-xs p-1.5 rounded bg-muted/30",children:[t.jsx(Ke,{variant:h.status==="completed"?"default":h.status==="failed"||h.status==="unrecoverable"?"destructive":"secondary",className:`text-[10px] shrink-0 no-default-active-elevate ${h.status==="completed"?"bg-emerald-600 hover:bg-emerald-600":h.status==="retrying"?"bg-amber-600 hover:bg-amber-600 text-white":h.status==="running"?"bg-blue-600 hover:bg-blue-600":""}`,children:h.status}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"font-medium",children:h.type.replace(/_/g," ")}),h.completedAt&&t.jsx("span",{className:"text-muted-foreground ml-1.5",children:new Date(h.completedAt).toLocaleTimeString()}),h.status==="pending"&&t.jsx("span",{className:"text-muted-foreground ml-1.5",children:"waiting for device check-in..."}),h.status==="retrying"&&t.jsxs("span",{className:"text-muted-foreground ml-1.5",children:["retry ",Math.min((h.attemptCount||0)+1,h.maxAttempts||5)," of ",h.maxAttempts||5,h.nextAttemptAt?` after ${new Date(h.nextAttemptAt).toLocaleTimeString()}`:""]}),h.status==="running"&&t.jsxs("span",{className:"text-muted-foreground ml-1.5",children:["executing on device",h.attemptCount?` (attempt ${h.attemptCount} of ${h.maxAttempts||5})`:"..."]}),h.status==="unrecoverable"&&t.jsx("span",{className:"text-muted-foreground ml-1.5",children:"local footage is no longer available"}),h.result&&t.jsx("pre",{className:"mt-1 text-[10px] text-muted-foreground whitespace-pre-wrap break-all max-h-20 overflow-auto",children:h.result.substring(0,500)})]})]}
485,h.id))]})]})}function BF(e,s){const r=e.split(".").map(a=>parseInt(a,10)||0),n=s.split(".").map(a=>parseInt(a,10)||0);for(let a=0;a<Math.max(r.length,n.length);a++){const i=r[a]||0,o=n[a]||0;if(i!==o)return i-o}return 0}function XSe({devices:e,statusData:s}){const[r,n]=u.useState(!1),a=ze({queryKey:["/api/edge-sync/versions"],queryFn:async()=>{const y=await fetch("/api/edge-sync/versions",{credentials:"include"});if(!y.ok)throw new Error("Failed to fetch versions");return y.json()},staleTime:6e4}),o=(a.data?.versions||[]).map(y=>y.version)[0]||a.data?.currentVersion||null,l=(e||[]).map(y=>{const w=y.edgeSyncScriptVersion||null,j=!!(w&&o&&BF(w,o)<0);return{id:y.id,serialNumber:y.serialNumber,version:w,lastSyncAt:y.edgeSyncLastSyncAt||null,online:s?.[y.id]===!0,outdated:j}}),c=new Map;for(const y of l){const w=y.version||"Unknown";c.set(w,(c.get(w)||0)+1)}const d=Array.from(c.entries()).sort((y,w)=>y[0]==="Unknown"?1:w[0]==="Unknown"?-1:BF(w[0],y[0])),h=l.length,p=l.filter(y=>o&&y.version===o).length,g=l.filter(y=>y.outdated).length,v=l.filter(y=>!y.version).length,b=y=>{if(!y)return"Never";const w=new Date(y);return isNaN(w.getTime())?"Never":w.toLocaleString()};return t.jsx(ut,{className:"mb-4","data-testid":"card-edge-sync-fleet",children:t.jsxs(mt,{className:"py-4",children:[t.jsxs("button",{type:"button",onClick:()=>n(y=>!y),className:"w-full flex items-center justify-between gap-3 text-left","data-testid":"button-toggle-edge-sync-fleet",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(uf,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx("span",{className:"font-semibold text-sm",children:"Edge-Sync Versions"}),o&&t.jsxs(Ke,{variant:"outline",className:"text-xs no-default-active-elevate","data-testid":"badge-latest-version",children:["Latest v",o]}),h>0&&t.jsxs("span",{className:"text-xs text-muted-foreground truncate","data-testid":"text-fleet-summary",children:[p,"/",h," on latest",g>0?` · ${g} outdated`:"",v>0?` · ${v} unknown`:""]})]}),r?t.jsx(Ig,{className:"w-4 h-4 shrink-0"}):t.jsx(Xa,{className:"w-4 h-4 shrink-0"})]}),r&&t.jsxs("div",{className:"mt-4 space-y-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Version distribution"}),t.jsx("div",{className:"flex flex-wrap gap-2","data-testid":"fleet-distribution",children:d.length===0?t.jsx("span",{className:"text-xs text-muted-foreground",children:"No devices"}):d.map(([y,w])=>{const j=y===o,x=y==="Unknown";return t.jsxs(Ke,{variant:j?"default":x?"outline":"secondary",className:`text-xs no-default-active-elevate ${j?"bg-emerald-600 hover:bg-emerald-600":""}`,"data-testid":`badge-dist-${y}`,children:[x?"Unknown":`v${y}`,": ",w]},y)})})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-muted-foreground border-b",children:[t.jsx("th",{className:"py-1.5 pr-3 font-medium",children:"Device"}),t.jsx("th",{className:"py-1.5 pr-3 font-medium",children:"Version"}),t.jsx("th",{className:"py-1.5 pr-3 font-medium",children:"Status"}),t.jsx("th",{className:"py-1.5 pr-3 font-medium",children:"Last sync"})]})}),t.jsx("tbody",{children:l.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:4,className:"py-3 text-center text-muted-foreground",children:"No Edge devices"})}):l.slice().sort((y,w)=>Number(w.outdated)-Number(y.outdated)).map(y=>t.jsxs("tr",{className:"border-b last:border-b-0","data-testid":`row-fleet-${y.id}`,children:[t.jsx("td",{className:"py-1.5 pr-3 font-mono","data-testid":`text-fleet-serial-${y.id}`,children:y.serialNumber}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"font-mono","data-testid":`text-fleet-version-${y.id}`,children:y.version?`v${y.version}`:"Unknown"}),y.outdated?t.jsxs(Ke,{variant:"secondary",className:"text-[10px] no-default-active-elevate bg-amber-500/15 text-amber-700 dark:text-amber-400","data-testid":`badge-fleet-outdated-${y.id}`,children:[t.jsx(ta,{className:"w-3 h-3 mr-0.5"}),"Outdated"]}):y.version?t.jsxs(Ke,{variant:"secondary",className:"text-[10px] no-default-active-elevate bg-emerald-500/15 text-emerald-700 dark:text-emerald-400","data-testid":`badge-fleet-latest-${y.id}`,children:[t.jsx(ar,{className:"w-3 h-3 mr-0.5"}),"Latest"]}):null]})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":`text-fleet-status-${y.id}`,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${y.online?"bg-green-500":"bg-muted-foreground
485/40"}`}),y.online?"Online":"Offline"]})}),t.jsx("td",{className:"py-1.5 pr-3 text-muted-foreground","data-testid":`text-fleet-lastsync-${y.id}`,children:b(y.lastSyncAt)})]},y.id))})]})})]})]})})}function ZSe({device:e,isOnline:s,isSuperadmin:r=!1}){const n=Er(),a=T=>T.replace(/frigate/gi,(n.brandName||"Truvios").toLowerCase()),[i,o]=u.useState(!1),[l,c]=u.useState(!1),{toast:d}=Hs(),h=Su(),p=Et({mutationFn:async T=>(await Ze("PATCH",`/api/edge-devices/${e.id}/offline-diagnostics`,{allowDiagnosticsIfOffline:T})).json(),onSuccess:T=>{h.setQueryData(["/api/edge-devices"],M=>M?.map(R=>R.id===e.id?{...R,allowDiagnosticsIfOffline:T.allowDiagnosticsIfOffline}:R)),d({title:T.allowDiagnosticsIfOffline?"Offline Diagnostics enabled":"Offline Diagnostics disabled"})},onError:T=>d({title:"Unable to update Diagnostics access",description:T?.message,variant:"destructive"})}),g=ze({queryKey:["/api/edge-devices",e.id,"stats"],queryFn:async()=>{const T=await fetch(`/api/edge-devices/${e.id}/stats`,{credentials:"include"});if(!T.ok)throw new Error("Failed to fetch stats");return T.json()},enabled:i,refetchInterval:i?1e3:!1}),v=Et({mutationFn:async()=>{const T=await fetch(`/api/edge-devices/${e.id}/restart`,{method:"POST",credentials:"include"});if(!T.ok)throw new Error("Failed to restart");return T.json()},onSuccess:()=>{d({title:"Restart command sent",description:"The Edge device is restarting. It may take a minute to come back online."})},onError:()=>{d({title:"Restart failed",description:"Could not send restart command to the device.",variant:"destructive"})}}),b=g.data,y=b?.cpu_usages?Object.entries(b.cpu_usages):[],w=y.length>0?Math.max(...y.map(([,T])=>parseFloat(T?.cpu||T?.cpu_percent||"0"))).toFixed(1):null,j=b?.gpu_usages?Object.entries(b.gpu_usages):[],x=b?.cameras?Object.entries(b.cameras):[],C=b?.detectors?Object.entries(b.detectors):[],k=b?.service?.storage?Object.entries(b.service.storage):[],S=b?.service?.uptime!=null?(()=>{const T=b.service.uptime,M=Math.floor(T/86400),R=Math.floor(T%86400/3600),D=Math.floor(T%3600/60);return M>0?`${M}d ${R}h ${D}m`:R>0?`${R}h ${D}m`:`${D}m`})():null,_=b?.service?.version||null,A=b?.service?.temperatures?Object.entries(b.service.temperatures):[];return t.jsxs("div",{className:"mt-3 border-t pt-3",children:[t.jsxs("button",{onClick:()=>s&&o(!i),className:`flex items-center gap-2 text-sm font-medium w-full text-left ${s?"":"opacity-50 cursor-not-allowed"}`,disabled:!s,"data-testid":`button-toggle-stats-${e.id}`,children:[t.jsx(vc,{className:`w-4 h-4 ${s?"text-primary":"text-muted-foreground"}`}),t.jsx("span",{children:"Edge System Status"}),s?i?t.jsx(Ig,{className:"w-4 h-4 ml-auto text-muted-foreground"}):t.jsx(Xa,{className:"w-4 h-4 ml-auto text-muted-foreground"}):t.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"Offline"})]}),i&&t.jsx("div",{className:"mt-3 space-y-4",children:g.isLoading?t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[t.jsx(Fe,{className:"w-4 h-4 animate-spin"}),"Fetching system stats..."]}):g.isError?t.jsx("div",{className:"text-sm text-destructive py-2",children:"Failed to fetch stats. The device may be offline or unreachable."}):b?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[_&&t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Version"}),t.jsx("span",{className:"text-sm font-medium","data-testid":`text-version-${e.id}`,children:_})]}),S&&t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Uptime"}),t.jsx("span",{className:"text-sm font-medium","data-testid":`text-uptime-${e.id}`,children:S})]}),w!==null&&t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Peak CPU"}),t.jsxs("span",{className:"text-sm font-medium","data-testid":`text-cpu-${e.id}`,children:[w,"%"]})]}),b?.service?.memory&&t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Memory"}),t.jsx("span",{className:"text-sm font-medium","data-testid":`text-memory-${e.id}`,children:typeof b.service.memory=="object"?`${(b.service.memory.used/b.service.memory.total*100).toFixed(1)}%`:`${b.service.memory}%`})]})]}),A.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(Rde,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Temperatures"})]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:A.map(([T,M])=>t.jsxs("div",{className:"flex items-center justify-between gap-2 bg-muted/50 rounded-md px-3 py-1.5",children:[t.jsx("span",{className:"text-xs truncate",children:T}),t.jsxs("span",{className:`text-xs font-medium ${Number(M)>80?"text-destructive":Number(M)>60?"text-amber-500":""}`,"data-testid":`text-temp-${T}-${e.id}`,children:[Number(M).toFixed(1),"°C"]}
485)]},T))})]}),j.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(gde,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"GPU"})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:j.map(([T,M])=>t.jsxs("div",{className:"bg-muted/50 rounded-md px-3 py-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-xs font-medium truncate",children:T}),t.jsx("span",{className:"text-xs","data-testid":`text-gpu-usage-${T}-${e.id}`,children:M?.gpu!=null?`${M.gpu}%`:"N/A"})]}),M?.mem!=null&&t.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:"Memory"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[M.mem,"%"]})]})]},T))})]}),y.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(uf,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"CPU Processes"})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b",children:[t.jsx("th",{className:"text-left py-1.5 pr-4 font-medium text-muted-foreground",children:"Process"}),t.jsx("th",{className:"text-right py-1.5 px-2 font-medium text-muted-foreground",children:"CPU %"}),t.jsx("th",{className:"text-right py-1.5 pl-2 font-medium text-muted-foreground",children:"Memory %"})]})}),t.jsx("tbody",{children:y.sort(([,T],[,M])=>parseFloat(M?.cpu||M?.cpu_percent||"0")-parseFloat(T?.cpu||T?.cpu_percent||"0")).map(([T,M])=>{const R=parseFloat(M?.cpu||M?.cpu_percent||"0"),D=M?.mem||M?.mem_percent,$=M?.cmdline||"",O=$?$.split(" ")[0].split("/").pop()?.substring(0,30)||`PID ${T}`:`PID ${T}`,q=a(O);return t.jsxs("tr",{className:"border-b border-muted/50",children:[t.jsx("td",{className:"py-1.5 pr-4 truncate max-w-[200px]",title:a($||`PID ${T}`),children:q}),t.jsxs("td",{className:"text-right py-1.5 px-2",children:[R.toFixed(1),"%"]}),t.jsx("td",{className:"text-right py-1.5 pl-2",children:D?`${parseFloat(D).toFixed(1)}%`:"-"})]},T)})})]})})]}),C.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(hf,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Detectors"})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:C.map(([T,M])=>t.jsxs("div",{className:"bg-muted/50 rounded-md px-3 py-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[t.jsx("span",{className:"text-xs font-medium",children:T}),t.jsx(Ke,{variant:"secondary",className:"text-[10px] no-default-active-elevate",children:M?.type||"unknown"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:"Inference"}),t.jsxs("span",{className:"text-right","data-testid":`text-detector-inference-${T}-${e.id}`,children:[M?.inference_speed?.toFixed(1)||"-"," ms"]}),t.jsx("span",{children:"PID"}),t.jsx("span",{className:"text-right",children:M?.pid||"-"})]})]},T))})]}),x.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(wo,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Camera FPS"})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b",children:[t.jsx("th",{className:"text-left py-1.5 pr-4 font-medium text-muted-foreground",children:"Camera"}),t.jsx("th",{className:"text-right py-1.5 px-2 font-medium text-muted-foreground",children:"Input"}),t.jsx("th",{className:"text-right py-1.5 px-2 font-medium text-muted-foreground",children:"Detect"}),t.jsx("th",{className:"text-right py-1.5 px-2 font-medium text-muted-foreground",children:"Process"}),t.jsx("th",{className:"text-right py-1.5 pl-2 font-medium text-muted-foreground",children:"Skipped"})]})}),t.jsx("tbody",{children:x.sort(([T],[M])=>T.localeCompare(M)).map(([T,M])=>t.jsxs("tr",{className:"border-b border-muted/50",children:[t.jsx("td",{className:"py-1.5 pr-4 font-medium truncate max-w-[150px]","data-testid":`text-camera-name-${T}-${e.id}`,children:T}),t.jsx("td",{className:"text-right py-1.5 px-2","data-testid":`text-camera-fps-${T}-${e.id}`,children:M?.camera_fps?.toFixed(1)||"0"}),t.jsx("td",{className:"text-right py-1.5 px-2",children:M?.detection_fps?.toFixed(1)||"0"}),t.jsx("td",{className:"text-right py-1.5 px-2",children:M?.process_fps?.toFixed(1)||"0"}),t.jsx("td",{className:"text-right py-1.5 pl-2",children:M?.skipped_fps?.toFixed(1)||"0"})]},T))})]})})]}),k.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(mf,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Storage"})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:k.map(([T,M])=>{const R=M?.total?(M.used/M.total*100).toFixed(1):null;return t.jsxs("div",{className:"bg-muted/50 rounded-md px-3 py-2",children:[t.jsx("div",{className:"text-xs font-medium truncate mb-1",title:T,children:T}),t.jsxs("div",{className:"grid grid-cols-3 gap-1 text-xs text-muted-foreground",children:[t.jsxs("div",{children:[t.jsx("span",{className:"block",children:"Used"}),t.jsx("span",{className:"font-medium text-foreground",children:M?.used!=null?l0(M.used*1048576):"-"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"block",children:"Total"}),t.jsx("span",{className:"font-medium text-foreground",children:M?.total!=null?l0(M.total*1048576):"-"})]}),t.jsxs("div",{children:[t.jsx("span",{className:"block",children:"Free"}),t.jsx("span",{className:"font-medium text-foreground",children:M?.free!=null?l0(M.free*1048576):"-"})]})]}),R&&t.jsxs("div",{className:"mt-1.5",children:[t.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:t.jsx("div",{className:`h-full rounded-full ${Number(R)>90?"bg-destructive":Number(R)>70?"bg-amber-500":"bg-primary"}`,style:{width:`${Math.min(Number(R),100)}%`}})}),t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[R,"% used"]})]})]},T)})})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4 pt-2 border-t",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(tl,{className:`w-3 h-3 ${g.isFetching?"animate-spin":""}`}),t.jsx("span",{children:"Auto-refreshes every 1s"})]}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs(L,{variant:"destructive",size:"sm",onClick:()=>c(!0),disabled:v.isPending,"data-testid":`button-restart-nvr-${e.id}`,children:[v.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):t.jsx(bh,{className:"w-3.5 h-3.5 mr-1.5"}),"Restart Edge"]})})]})]}):null}),r&&t.jsxs("div",{className:"mt-3 border-t pt-3 flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Allow Diagnostics if offline"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow superadmins to open Diagnostics when this device is offline."})]}),t.jsx(sr,{checked:!!e.allowDiagnosticsIfOffline,disabled:p.isPending,onCheckedChange:T=>p.mutate(T),"data-testid":`switch-offline-diagnostics-${e.id}`})]}),t.jsx(Ys,{open:l,onOpenChange:c,children:t.jsxs(Ws,{children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Restart Edge Device"}),t.jsxs(cr,{children:["Are you sure you want to restart this Edge device (",e.serialNumber,")? It will be unavailable for about a minute while it reboots."]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>c(!1),"data-testid":`button-cancel-restart-${e.id}`,children:"Cancel"}),t.jsxs(L,{variant:"destructive",onClick:()=>{v.mutate(),c(!1)},"data-testid":`button-confirm-restart-${e.id}`,children:[t.jsx(bh,{className:"w-3.5 h-3.5 mr-1.5"}),"Restart Edge"]})]})]})})]})}function JSe({device:e,siteName:s,syncEnabled:r,syncMode:n,syncIntervalMinutes:a,retentionDays:i,lastSyncAt:o,lastEdgeSyncAt:l,deviceStorageClass:c,bandwidthStatus:d,avgUploadBytesPerSec:h,saveCloudSettingsMutation:p,syncDeviceMutation:g,isSuperAdmin:v,isEdgeSync:b,edgeSyncScriptVersion:y,currentServerVersion:w}){const[j,x]=u.useState(!1),[C,k]=u.useState(!1),[S,_]=u.useState(!1),{data:A}=ze({queryKey:["/api/cloud-storage/stats",e.id],enabled:r,staleTime:6e4,gcTime:5*6e4}),{data:T}
485=ze({queryKey:["/api/cloud-sync-progress",e.id],enabled:r,refetchInterval:V=>{const K=V.state.data;return K&&(K.status==="fetching"||K.status==="syncing")?2e3:15e3}}),{data:M=[]}=ze({queryKey:["/api/cloud-sync-logs",e.id],enabled:S,staleTime:0}),{data:R}=ze({queryKey:["/api/cloud-storage/daily-history",e.id],enabled:r&&(j||C),staleTime:5*6e4,gcTime:10*6e4}),{data:D}=ze({queryKey:["/api/subscription-plans","wholesale"],queryFn:async()=>{const V=await fetch("/api/subscription-plans?scope=wholesale",{credentials:"include"});return V.ok?V.json():[]},enabled:v&&C}),{data:$}=ze({queryKey:["/api/device-notifications/status","camera-count",e.id],queryFn:async()=>{const V=await fetch("/api/device-notifications/status",{credentials:"include"});return V.ok?(await V.json()).filter(z=>z.edgeDeviceId===e.id&&z.cameraName!=null&&z.cameraName!=="").length:0},enabled:v&&C}),O=u.useRef();u.useEffect(()=>{const V=O.current,K=T?.status;(K==="complete"&&V!=="complete"||K==="idle"&&(V==="syncing"||V==="fetching"))&&(Je.invalidateQueries({queryKey:["/api/cloud-storage/stats",e.id]}),Je.invalidateQueries({queryKey:["/api/cloud-storage/daily-history",e.id]})),O.current=K},[T?.status,e.id]);const q=V=>{p.mutate({edgeDeviceId:e.id,settings:{syncEnabled:r,syncMode:n,syncIntervalMinutes:a,retentionDays:i,...V}})};return t.jsxs(ut,{"data-testid":`card-cloud-${e.id}`,children:[t.jsxs(xs,{className:"pb-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Fa,{className:"w-5 h-5 text-muted-foreground"}),t.jsx("div",{children:t.jsx(ys,{className:"text-base",children:e.serialNumber})})]}),t.jsx("div",{className:"flex items-center gap-2",children:b?t.jsxs(t.Fragment,{children:[t.jsxs(Ke,{variant:"default",className:"text-xs bg-emerald-600 hover:bg-emerald-600","data-testid":`badge-edge-sync-${e.id}`,children:[t.jsx(uf,{className:"w-3 h-3 mr-1"}),"Edge Sync Active"]}),l&&t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Last: ",new Date(l).toLocaleString()]})]}):t.jsxs(t.Fragment,{children:[t.jsx(sr,{checked:r,onCheckedChange:V=>q({syncEnabled:V}),disabled:!v,"data-testid":`switch-cloud-sync-${e.id}`}),t.jsx(Ke,{variant:r?"default":"secondary",className:"text-xs",children:r?"Sync On":"Sync Off"})]})})]}),(s||e.orderNumber||v&&e.resellerName)&&t.jsxs("div",{className:"flex items-center gap-x-4 gap-y-1 flex-wrap mt-2 ml-8 text-xs text-muted-foreground",children:[s&&t.jsxs("span",{"data-testid":`text-cloud-site-${e.id}`,children:["Site: ",t.jsx("span",{className:"text-foreground font-medium",children:s})]}),e.orderNumber&&t.jsxs("span",{"data-testid":`text-order-${e.id}`,children:["Order: ",t.jsx("span",{className:"text-foreground",children:e.orderNumber})]}),v&&e.resellerName&&t.jsxs("span",{"data-testid":`text-reseller-${e.id}`,children:["Customer: ",t.jsx("span",{className:"text-foreground",children:e.resellerName})]})]})]}),t.jsxs(mt,{children:[b&&t.jsxs("div",{className:"mb-4 p-3 bg-emerald-50 dark:bg-emerald-950/30 border border-emerald-200 dark:border-emerald-800 rounded-lg space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-700 dark:text-emerald-400",children:[t.jsx(uf,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{children:"Uploads recordings directly to cloud storage from the edge device."})]}),t.jsx("div",{className:"flex items-center gap-2 text-xs ml-6",children:y?Ite(y,w||"")?t.jsxs("span",{className:"flex items-center gap-1 text-emerald-600 dark:text-emerald-400","data-testid":`text-edge-version-${e.id}`,children:[t.jsx(ar,{className:"w-3.5 h-3.5"}),"Agent v",y," (up to date)"]}):t.jsxs("span",{className:"flex items-center gap-1 text-amber-600 dark:text-amber-400","data-testid":`text-edge-version-${e.id}`,children:[t.jsx(ta,{className:"w-3.5 h-3.5"}),"Agent v",y," — update available (v",w,"). Use Push Update to upgrade."]}):t.jsx("span",{className:"text-muted-foreground","data-testid":`text-edge-version-${e.id}`,children:"Agent version unknown — waiting for device to check in"})})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Sync Mode"}),t.jsxs(Us,{value:n,onValueChange:V=>q({syncMode:V}),disabled:!v||b,children:[t.jsx($s,{"data-testid":`select-sync-mode-${e.id}`,children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"events",children:"All Events (Motion)"}),t.jsx(rt,{value:"continuous",children:"24/7 Continuous"})]})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Sync Interval"}),t.jsxs(Us,{value:String(a),onValueChange:V=>q({syncIntervalMinutes:parseInt(V)}),disabled:!v||b,children:[t.jsx($s,{"data-testid":`select-sync-interval-${e.id}`,children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"1",children:"Every 1 min"}),t.jsx(rt,{value:"2",children:"Every 2 min"}),t.jsx(rt,{value:"5",children:"Every 5 min"}),t.jsx(rt,{value:"15",children:"Every 15 min"}),t.jsx(rt,{value:"30",children:"Every 30 min"}),t.jsx(rt,{value:"60",children:"Every 60 min"})]})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Retention Period"}),t.jsxs(Us,{value:String(i),onValueChange:V=>q({retentionDays:parseInt(V)}),disabled:!0,children:[t.jsx($s,{"data-testid":`select-retention-${e.id}`,children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"14",children:"14 Days"}),t.jsx(rt,{value:"30",children:"30 Days"}),t.jsx(rt,{value:"60",children:"60 Days"}),t.jsx(rt,{value:"90",children:"90 Days"}),t.jsx(rt,{value:"180",children:"6 Months"}),t.jsx(rt,{value:"365",children:"1 Year"}),t.jsx(rt,{value:"730",children:"2 Years"}),t.jsx(rt,{value:"1095",children:"3 Years"})]})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:b?"Last Edge Sync":"Last Synced"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("p",{className:"text-sm","data-testid":`text-last-sync-${e.id}
485`,children:b?l?new Date(l).toLocaleString():"Waiting for first sync":o?new Date(o).toLocaleString():"Never"}),!b&&t.jsx(L,{variant:"ghost",size:"icon",disabled:g.isPending||!v,onClick:()=>g.mutate(e.id),"data-testid":`button-sync-${e.id}`,children:t.jsx(tl,{className:`w-4 h-4 ${g.isPending?"animate-spin":""}`})})]})]})]}),r&&A&&t.jsxs("div",{className:"mt-4 pt-3 border-t border-border",children:[t.jsxs("div",{className:"flex items-center gap-6 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(mf,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"Storage:"}),t.jsx("span",{className:"text-sm font-medium","data-testid":`text-storage-size-${e.id}`,children:l0(A.totalSize)})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(pn,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"Videos:"}),t.jsx("span",{className:"text-sm font-medium","data-testid":`text-video-count-${e.id}`,children:A.videoCount})]}),v&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Dde,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"Class:"}),t.jsx(Ke,{variant:"outline",className:"text-xs","data-testid":`badge-storage-class-${e.id}`,children:c})]}),d&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_de,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"Bandwidth:"}),t.jsx(Ke,{variant:d==="excellent"?"default":d==="good"?"secondary":"destructive",className:"text-xs","data-testid":`badge-bandwidth-${e.id}`,children:d==="excellent"?"Excellent":d==="good"?"Good":"Poor"}),h!=null&&t.jsxs("span",{className:"text-xs text-muted-foreground","data-testid":`text-bandwidth-speed-${e.id}`,children:["(",h>=1048576?`${(h/1048576).toFixed(1)} MB/s`:`${(h/1024).toFixed(0)} KB/s`,")"]})]}),t.jsxs(L,{variant:"ghost",size:"sm",onClick:()=>x(!j),"data-testid":`button-daily-history-${e.id}`,children:[t.jsx(ro,{className:"w-4 h-4 mr-1"}),j?"Hide":"Daily"," History"]})]}),T&&T.status!=="idle"&&t.jsxs("div",{className:"mt-3 p-3 rounded-md bg-muted/50","data-testid":`section-sync-progress-${e.id}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[T.stalled?t.jsx(ta,{className:"w-3.5 h-3.5 text-amber-500"}):t.jsxs(t.Fragment,{children:[(T.status==="fetching"||T.status==="syncing")&&t.jsx(tl,{className:"w-3.5 h-3.5 animate-spin text-primary"}),T.status==="complete"&&T.errors===0&&t.jsx(ar,{className:"w-3.5 h-3.5 text-green-500"}),T.status==="complete"&&T.errors>0&&t.jsx(ta,{className:"w-3.5 h-3.5 text-amber-500"})]}),t.jsx("span",{className:"text-sm font-medium",children:T.stalled?`Sync stalled — last update ${Math.round((T.ageMs||0)/6e4)} min ago`:T.status==="fetching"?"Checking for new events...":T.status==="syncing"?`Uploading ${T.synced} of ${T.newToSync} events`:T.errors>0?`${T.synced} uploaded, ${T.errors} failed`:T.synced>0?`${T.synced} events uploaded`:"All files up to date"}),T.errors>0&&t.jsxs("button",{type:"button",onClick:()=>_(!0),className:"text-xs text-destructive underline underline-offset-2 hover:text-destructive/80","data-testid":"button-view-sync-errors",children:["(",T.errors," failed - view logs)"]})]}),T.completedAt&&T.status==="complete"&&t.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(T.completedAt).toLocaleTimeString()})]}),T.status==="syncing"&&T.newToSync>0&&t.jsx("div",{className:"mt-2",children:t.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-500",style:{width:`${Math.round(T.synced/T.newToSync*100)}%`}})})})]}),j&&t.jsx("div",{className:"mt-3","data-testid":`section-daily-history-${e.id}`,children:R&&R.length>0?t.jsx("div",{className:"rounded-md border border-border overflow-hidden",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"bg-muted/50",children:[t.jsx("th",{className:"text-left px-3 py-2 text-xs font-medium text-muted-foreground",children:"Date"}),t.jsx("th",{className:"text-right px-3 py-2 text-xs font-medium text-muted-foreground",children:"Videos"}),t.jsx("th",{className:"text-right px-3 py-2 text-xs font-medium text-muted-foreground",children:"Stored"})]})}),t.jsx("tbody",{children:R.map(V=>t.jsxs("tr",{className:"border-t border-border","data-testid":`row-daily-${e.id}-${V.date}`,children:[t.jsx("td",{className:"px-3 py-1.5 text-foreground",children:new Date(V.date+"T00:00:00").toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"})}),t.jsx("td",{className:"px-3 py-1.5 text-right text-muted-foreground",children:V.videoCount}),t.jsx("td",{className:"px-3 py-1.5 text-right font-medium text-foreground",children:l0(V.totalSize)})]},V.date))})]})}):R?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No daily history available yet."}):t.jsx(Bt,{className:"h-20 w-full"})}),!1]})]}),t.jsx(Ys,{open:S,onOpenChange:_,children:t.jsxs(Ws,{className:"max-w-2xl max-h-[80vh]",children:[t.jsxs(Zs,{children:[t.jsxs(Ks,{children:["Sync Logs - ",e.serialNumber]}),t.jsx(cr,{children:"Recent sync activity and error details for this device"})]}),t.jsx("div",{className:"overflow-y-auto max-h-[60vh] space-y-1 font-mono text-xs",children:M.length===0?t.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No sync logs available. Logs are generated during sync operations."}):M.map((V,K)=>t.jsxs("div",{className:`flex gap-2 px-2 py-1.5 rounded ${V.level==="error"?"bg-destructive/10 text-destructive":V.level==="warn"?"bg-amber-500/10 text-amber-700 dark:text-amber-400":"text-muted-foreground"}`,"data-testid":`sync-log-entry-${K}`,children:[t.jsx("span",{className:"shrink-0 text-muted-foreground
485/70 tabular-nums",children:new Date(V.timestamp).toLocaleTimeString()}),t.jsx(Ke,{variant:V.level==="error"?"destructive":V.level==="warn"?"outline":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:V.level.toUpperCase()}),t.jsx(Ke,{variant:"outline",className:"shrink-0 text-[10px] px-1.5 py-0",children:V.phase}),V.camera&&t.jsx(Ke,{variant:"outline",className:"shrink-0 text-[10px] px-1.5 py-0",children:V.camera}),t.jsx("span",{className:"break-all",children:V.message})]},K))})]})})]})}function eCe(e){switch(e){case"superadmin":return t.jsx(Ke,{variant:"default","data-testid":"badge-role-superadmin",children:"DB Admin"});case"admin":return t.jsx(Ke,{variant:"secondary","data-testid":"badge-role-admin",children:"Administrator"});case"owner":return t.jsx(Ke,{variant:"outline","data-testid":"badge-role-owner",children:"Owner"});default:return t.jsx(Ke,{variant:"outline","data-testid":"badge-role-user",children:"User"})}}const UF={footage_request:"Footage Request",activation:"Activation",support:"Support Ticket"},ux={new:{label:"New",color:"bg-blue-500/10 text-blue-400 border-blue-500/30"},in_progress:{label:"In Progress",color:"bg-yellow-500/10 text-yellow-400 border-yellow-500/30"},closed:{label:"Closed",color:"bg-muted text-muted-foreground border-border"}};function tCe(){const e=Su(),{data:s=[],isLoading:r}=ze({queryKey:["/api/support/tickets"]}),[n,a]=u.useState(null),[i,o]=u.useState("all"),[l,c]=u.useState(""),[d,h]=u.useState(!1),[p,g]=u.useState(!1),{toast:v}=Hs(),b=i==="all"?s:s.filter(k=>k.status===i),y={all:s.length,new:s.filter(k=>k.status==="new").length,in_progress:s.filter(k=>k.status==="in_progress").length,closed:s.filter(k=>k.status==="closed").length};async function w(k,S){h(!0);try{const _=await fetch(`/api/support/tickets/${k}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)});if(!_.ok)throw new Error("Failed to update");const A=await _.json();e.setQueryData(["/api/support/tickets"],T=>(T||[]).map(M=>M.id===k?A:M)),a(A),v({title:"Ticket updated",description:`Status set to ${ux[A.status]?.label||A.status}.`})}catch{v({title:"Update failed",variant:"destructive"})}finally{h(!1)}}async function j(k){h(!0);try{if(!(await fetch(`/api/support/tickets/${k}`,{method:"DELETE"})).ok)throw new Error("Failed to delete");e.setQueryData(["/api/support/tickets"],_=>(_||[]).filter(A=>A.id!==k)),a(null),g(!1),v({title:"Ticket deleted"})}catch{v({title:"Delete failed",variant:"destructive"})}finally{h(!1)}}async function x(k){await w(k,{internalNotes:l})}function C(k){a(k),c(k.internalNotes||"")}return r?t.jsxs("div",{className:"flex items-center justify-center h-40 text-muted-foreground",children:[t.jsx(Fe,{className:"w-5 h-5 animate-spin mr-2"}),"Loading tickets…"]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Support Requests"}),t.jsx("div",{className:"flex gap-2 flex-wrap",children:["all","new","in_progress","closed"].map(k=>t.jsxs("button",{onClick:()=>o(k),className:`px-3 py-1 rounded-full text-xs font-medium border transition-colors ${i===k?"bg-primary text-primary-foreground border-primary":"border-border text-muted-foreground hover:border-primary/50"}`,"data-testid":`filter-tickets-${k}`,children:[k==="all"?"All":ux[k]?.label," (",y[k],")"]},k))})]}),b.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:[t.jsx(k0,{className:"w-8 h-8 mb-3 opacity-40"}),t.jsxs("p",{className:"text-sm",children:["No ",i==="all"?"":ux[i]?.label+" ","tickets found."]})]}):t.jsx("div",{className:"space-y-2",children:b.map(k=>{const S=ux[k.status]||ux.new;return t.jsxs("div",{"data-testid":`ticket-row-${k.id}`,onClick:()=>C(k),className:"rounded-xl border border-border bg-muted/10 hover:border-primary/40 hover:bg-muted/20 transition-colors cursor-pointer px-4 py-3 flex items-center gap-4",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["#",k.id.slice(0,8).toUpperCase()]}),t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ${S.color}`,children:S.label}
485),t.jsx("span",{className:"text-xs text-muted-foreground/60",children:UF[k.ticketType]||k.ticketType}),k.assignedTo&&t.jsxs("span",{className:"text-xs text-yellow-400/80 hidden sm:inline",children:["· ",k.assignedTo]})]}),t.jsxs("div",{className:"font-medium text-sm text-foreground truncate mt-0.5",children:[k.name," ",t.jsxs("span",{className:"text-muted-foreground",children:["— ",k.business]})]}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[k.email," · ",k.phone]})]}),t.jsxs("div",{className:"text-xs text-muted-foreground shrink-0 hidden sm:block",children:[t.jsx(cn,{className:"w-3 h-3 inline mr-1"}),k.createdAt?new Date(k.createdAt).toLocaleDateString():"—"]}),t.jsx(Xa,{className:"w-4 h-4 text-muted-foreground shrink-0 -rotate-90"})]},k.id)})}),t.jsx(Ys,{open:!!n,onOpenChange:k=>{k||(a(null),g(!1))},children:t.jsx(Ws,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:n&&(()=>{const k=ux[n.status]||ux.new;return t.jsxs(t.Fragment,{children:[t.jsx(Zs,{children:t.jsxs(Ks,{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{children:["Ticket #",n.id.slice(0,8).toUpperCase()]}),t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ${k.color}`,children:k.label}),t.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:UF[n.ticketType]||n.ticketType})]})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Name"}),t.jsx("div",{className:"font-medium",children:n.name})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Business"}),t.jsx("div",{className:"font-medium",children:n.business})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Email"}),t.jsx("div",{className:"font-medium break-all",children:n.email})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Phone"}),t.jsx("div",{className:"font-medium",children:n.phone})]}),n.createdAt&&t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Submitted"}),t.jsx("div",{className:"font-medium",children:new Date(n.createdAt).toLocaleString()})]}),n.assignedTo&&t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Assigned To"}),t.jsx("div",{className:"font-medium text-yellow-400",children:n.assignedTo})]}),n.closedAt&&t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Closed"}),t.jsxs("div",{className:"font-medium",children:[new Date(n.closedAt).toLocaleString()," by ",n.closedBy]})]})]}),n.ticketType==="footage_request"&&(n.footageDateFrom||n.footageDateTo)&&t.jsxs("div",{className:"rounded-lg border border-border bg-muted/10 p-3 text-sm space-y-1",children:[t.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"Footage Details"}),t.jsxs("div",{className:"flex gap-6 flex-wrap",children:[n.footageDateFrom&&t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Start Date: "}),t.jsx("span",{className:"font-medium",children:n.footageDateFrom})]}),n.footageDateTo&&t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"End Date: "}),t.jsx("span",{className:"font-medium",children:n.footageDateTo})]}),n.footageTimeFrom&&t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Start Time: "}),t.jsx("span",{className:"font-medium",children:n.footageTimeFrom})]}),n.footageTimeTo&&t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"End Time: "}),t.jsx("span",{className:"font-medium",children:n.footageTimeTo})]})]})]}),n.ticketType==="activation"&&(n.soOrderNumber||n.edgeSerialNumber||n.attachmentFilename)&&t.jsxs("div",{className:"rounded-lg border border-border bg-muted/10 p-3 text-sm space-y-1",children:[t.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"Activation Details"}),n.soOrderNumber&&t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"SO / Order #: "}),t.jsx("span",{className:"font-medium",children:n.soOrderNumber})]}),n.edgeSerialNumber&&t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Edge Serial #: "}),t.jsx("span",{className:"font-medium",children:n.edgeSerialNumber})]}),n.attachmentFilename&&t.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.jsx("span",{className:"text-muted-foreground text-xs",children:"Attachment:"}),t.jsxs("a",{href:`/api/support/tickets/${n.id}/attachment`,className:"text-primary hover:underline text-xs flex items-center gap-1",target:"_blank",rel:"noreferrer","data-testid":"link-download-attachment",children:[t.jsx(ya,{className:"w-3 h-3"}),n.attachmentFilename]})]})]}),n.description&&t.jsxs("div",{className:"rounded-lg border border-border bg-muted/10 p-3 text-sm",children:[t.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:"Description"}
485),t.jsx("p",{className:"whitespace-pre-wrap text-foreground/90",children:n.description})]}),n.attachmentPaths&&(()=>{let S=[],_=[];try{S=JSON.parse(n.attachmentPaths)}catch{}try{_=JSON.parse(n.attachmentFilenames||"[]")}catch{}return S.length===0?null:t.jsxs("div",{className:"rounded-lg border border-border bg-muted/10 p-3 text-sm",children:[t.jsxs("p",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-2",children:["Attachments (",S.length,")"]}),t.jsx("div",{className:"space-y-1.5",children:S.map((A,T)=>t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs("a",{href:`/api/support/tickets/${n.id}/attachments/${T}`,className:"text-primary hover:underline text-xs flex items-center gap-1",target:"_blank",rel:"noreferrer","data-testid":`link-download-media-${T}`,children:[t.jsx(ya,{className:"w-3 h-3"}),_[T]||`File ${T+1}`]})},T))})]})})(),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium",children:"Internal Notes"}),t.jsx(Nn,{value:l,onChange:S=>c(S.target.value),placeholder:"Add internal notes (included in closure email)…",rows:3,"data-testid":"textarea-internal-notes"}),t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>x(n.id),disabled:d,"data-testid":"button-save-notes",children:[d?t.jsx(Fe,{className:"w-3 h-3 animate-spin mr-1"}):t.jsx(qx,{className:"w-3 h-3 mr-1"}),"Save Notes"]})]}),t.jsxs("div",{className:"flex gap-2 flex-wrap items-center pt-2 border-t border-border",children:[t.jsx("span",{className:"text-sm text-muted-foreground mr-1",children:"Status:"}),n.status!=="in_progress"&&t.jsxs(L,{size:"sm",variant:"outline",disabled:d,onClick:()=>w(n.id,{status:"in_progress",internalNotes:l}),"data-testid":"button-set-in-progress",children:[d?t.jsx(Fe,{className:"w-3 h-3 animate-spin mr-1"}):null,"Mark In Progress"]}),n.status!=="closed"&&t.jsxs(L,{size:"sm",variant:"destructive",disabled:d,onClick:()=>w(n.id,{status:"closed",internalNotes:l}),"data-testid":"button-close-ticket",children:[d?t.jsx(Fe,{className:"w-3 h-3 animate-spin mr-1"}):null,"Close Ticket"]}),n.status==="closed"&&t.jsx(L,{size:"sm",variant:"outline",disabled:d,onClick:()=>w(n.id,{status:"new",internalNotes:l}),"data-testid":"button-reopen-ticket",children:"Reopen"}),t.jsx("div",{className:"ml-auto",children:p?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-destructive font-medium",children:"Delete permanently?"}),t.jsxs(L,{size:"sm",variant:"destructive",disabled:d,onClick:()=>j(n.id),"data-testid":"button-confirm-delete-ticket",children:[d?t.jsx(Fe,{className:"w-3 h-3 animate-spin mr-1"}):null,"Yes, Delete"]}),t.jsx(L,{size:"sm",variant:"ghost",onClick:()=>g(!1),"data-testid":"button-cancel-delete-ticket",children:"Cancel"})]}):t.jsxs(L,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>g(!0),"data-testid":"button-delete-ticket",children:[t.jsx(sa,{className:"w-3 h-3 mr-1"}),"Delete"]})})]})]})]})})()})})]})}function sCe({initialValues:e,onSave:s,onCancel:r,isSaving:n}){const a=Er(),[i,o]=u.useState(e),[l,c]=u.useState(!1),d=v=>o(b=>({...b,...v})),p={mfa_verification:"MFA Verification Code",new_device_login:"New Device Login Alert",device_alert:"Device Offline Alert",device_recovery:"Device Online Alert",device_weekly_summary:"Device Weekly Summary",subscription_activated:"Subscription Activated",subscription_canceled:"Subscription Canceled",reseller_registration_alert:"Customer Registration Alert",reseller_registration_confirmation:"Customer Registration Confirmation",reseller_approval_welcome:"Customer Approval — Welcome to Applicant",reseller_approval_alert:"Customer Approval — Internal Alert",contact_form_internal:"Contact Form — Internal Notification",contact_form_confirmation:"Contact Form — Sender Confirmation",password_reset:"Password Reset",support_ticket_confirmation:"Support Ticket — Submitter Confirmation",support_ticket_staff_notification:"Support Ticket — Staff Notification",support_ticket_closed:"Support Ticket — Closure Notice",video_export_ready:"Video Export Ready"}[i.templateKey]||i.templateKey,g=i.templateKey==="new_device_login"?"{{DEVICE}}, {{BROWSER}}, {{IP}}, {{LOCATION}}, {{TIME}}":i.templateKey==="device_alert"||i.templateKey==="device_recovery"?"{{GREETING}}, {{STATUS_TABLE}}":i.templateKey==="device_weekly_summary"?"{{GREETING}}, {{DATE}}, {{SUMMARY_STATS}}, {{STATUS_TABLE}}":i.templateKey==="subscription_activated"||i.templateKey==="subscription_canceled"?"{{SITE_NAME}}, {{COMPANY_NAME}}, {{SERIAL_NUMBER}}, {{PLAN_DETAILS}}, {{INITIATED_BY_NAME}}, {{INITIATED_BY_EMAIL}}, {{TIMESTAMP}}":i.templateKey==="password_reset"?"{{RESET_URL}}":i.templateKey==="video_export_ready"?"{{NAME}}, {{FORMAT}}, {{CLIPS}}, {{SIZE}}
485, {{DOWNLOAD_URL}}":"{{CODE}}";return t.jsxs(t.Fragment,{children:[t.jsxs(ut,{className:"mt-4",children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"text-base flex items-center gap-2",children:[t.jsx(ga,{className:"w-4 h-4"}),"Edit Template: ",p]}),t.jsxs(Xs,{children:["Available placeholders: ",g]})]}),t.jsx(mt,{children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Subject Line"}),t.jsx(ke,{value:i.subject,onChange:v=>d({subject:v.target.value}),placeholder:"Email subject","data-testid":"input-template-subject"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Sender Name"}),t.jsx(ke,{value:i.fromName,onChange:v=>d({fromName:v.target.value}),placeholder:`e.g. ${a.brandName}`,"data-testid":"input-template-from-name"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Header HTML"}),t.jsx(Nn,{value:i.headerHtml,onChange:v=>d({headerHtml:v.target.value}),placeholder:"HTML for the email header (logo, branding, etc.)",rows:3,className:"font-mono text-xs","data-testid":"input-template-header"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Body HTML"}),t.jsx(Nn,{value:i.bodyHtml,onChange:v=>d({bodyHtml:v.target.value}),placeholder:"HTML for the email body.",rows:8,className:"font-mono text-xs","data-testid":"input-template-body"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Footer HTML"}),t.jsx(Nn,{value:i.footerHtml,onChange:v=>d({footerHtml:v.target.value}),placeholder:"HTML for the email footer (copyright, links, etc.)",rows:3,className:"font-mono text-xs","data-testid":"input-template-footer"})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(L,{onClick:()=>s(i),disabled:n||!i.subject||!i.bodyHtml,"data-testid":"button-save-template",children:[n?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-2"}),"Save Template"]}),t.jsx(L,{variant:"outline",onClick:r,"data-testid":"button-cancel-edit-template",children:"Cancel"}),t.jsxs(L,{variant:"outline",onClick:()=>c(!0),"data-testid":"button-preview-template",children:[t.jsx(Xr,{className:"w-4 h-4 mr-2"}),"Preview"]})]})]})})]}),t.jsx(Ys,{open:l,onOpenChange:c,children:t.jsxs(Ws,{className:"sm:max-w-2xl max-h-[85vh] overflow-y-auto",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Email Preview"}),t.jsx(cr,{children:"Preview of the email template with sample data"})]}),t.jsx("div",{className:"border border-border rounded-md overflow-hidden",children:t.jsx("div",{dangerouslySetInnerHTML:{__html:`<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; background-color: #0a1929;">
486                ${i.headerHtml}
487                ${i.bodyHtml.replace(/\{\{CODE\}\}/g,"123456").replace(/\{\{DEVICE\}\}/g,"Desktop").replace(/\{\{BROWSER\}\}/g,"Chrome").replace(/\{\{IP\}\}/g,"203.0.113.42").replace(/\{\{LOCATION\}\}/g,"New York, United States").replace(/\{\{TIME\}\}/g,"Feb 7, 2025, 3:45 PM UTC")}
488                ${i.footerHtml}
489              </div>`}})}),t.jsx(In,{children:t.jsx(L,{variant:"outline",onClick:()=>c(!1),children:"Close"})})]})})]})}function rCe(){const[,e]=Ia(),{user:s}=Gi(),{data:r}=ze({queryKey:["/api/user/role"],enabled:!!s}),{toast:n}=Hs(),a=Er(),o=new URLSearchParams(window.location.search).get("tab")||"users",[l,c]=u.useState(o),[d,h]=u.useState(""),[p,g]=u.useState(!1),[v,b]=u.useState(null),[y,w]=u.useState(!1),[j,x]=u.useState(null),[C,k]=u.useState(!1),[S,_]=u.useState(null),[A,T]=u.useState(""),[M,R]=u.useState(!1),[D,$]=u.useState(null),[O,q]=u.useState(null),[V,K]=u.useState(!1),[G,z]=u.useState(null),[Z,ee]=u.useState(null),[Q,Y]=u.useState(null),[oe,he]=u.useState(null),[je,pe]=u.useState(null),[le,ue]=u.useState(!1),[fe,H]=u.useState(!1),[se,me]=u.useState(!1),[ge,be]=u.useState(null),[ce,Pe]=u.useState("pending"),[et,$e]=u.useState(""),[bt,Ae]=u.useState(!1),[Be,J]=u.useState(null),[ae,we]=u.useState(!1),[Qe,ye]=u.useState(null),[te,Ue]=u.useState(null),[We,St]=u.useState(!0),[It,ns]=u.useState(!0),[dt,Qt]=u.useState(!1),[Re,pt]=u.useState(!1),[Ft,Es]=u.useState(!1),[Ge,ft]=u.useState(null),[He,zt]=u.useState({serialNumber:"",host:"",port:"443",apiUsername:"",apiPassword:"",orderNumber:"",defaultPlanId:"",salesOrderId:"",includeAiPlus:!1,maxCameras:"8"}),[fs,Ce]=u.useState(!1),[Dt,ne]=u.useState(null),[Oe,De]=u.useState({email:"",firstName:"",lastName:"",password:"",role:"user",companyIds:[],resellerId:"",deliveryMode:"email"}),[jt,Ct]=u.useState({targetUserId:"",businessName:"",contactName:"",email:"",ph
489one:"",address:"",city:"",state:"",zip:"",notes:"",distributorId:"",hardwareMarkupOverridePercent:"",subscriptionMarkupOverridePercent:"",hideOrdersQuotes:!1}),[Lt,xr]=u.useState({role:"user",companyIds:[],siteIds:[],resellerId:""}),[qe,Xt]=u.useState({}),[Ut,gt]=u.useState({templateKey:"",subject:"",headerHtml:"",bodyHtml:"",footerHtml:"",fromName:""}),[es,br]=u.useState(!1),[fr,xn]=u.useState(!1),[Br,Pi]=u.useState({senderName:"",senderEmail:""}),[Qn,ii]=u.useState(!1),[ua,Ua]=u.useState({senderName:"",senderEmail:"",staffEmail:""}),[Ln,Ir]=u.useState(!1),[Hr,lt]=u.useState({senderName:"",senderEmail:""}),[Rt,At]=u.useState(!1),[Ht,vr]=u.useState(""),[mn,hr]=u.useState(!1),[Sn,Sr]=u.useState(""),[Os,ur]=u.useState(!1),[nr,qr]=u.useState({key:"",value:"",label:"",description:""}),[So,Xn]=u.useState(null),[Jr,vn]=u.useState(null),[Mn,Dr]=u.useState(!1),[en,Co]=u.useState(!1),[Oa,ku]=u.useState(null),[ma,lo]=u.useState(!1),[Cn,Lr]=u.useState(null),[Vr,Nc]=u.useState(""),{data:Ds,isLoading:nl,error:co}=ze({queryKey:["/api/admin/users"],staleTime:0,refetchOnMount:"always"}),{data:fn}=ze({queryKey:["/api/admin/mfa-bypass-status"],enabled:Ds?.callerRole==="superadmin",staleTime:0,refetchOnMount:"always",refetchInterval:3e4}),{data:bi,isLoading:Sc}=ze({queryKey:["/api/admin/resellers"]}),{data:ra}=ze({queryKey:["/api/admin/distributors"],enabled:!!Ds&&Ds?.callerRole==="superadmin",retry:!1}),{data:za,isLoading:Xl}=ze({queryKey:["/api/reseller-applications"],enabled:Ds?.callerRole==="superadmin"}),{data:Ei}=ze({queryKey:["/api/companies"]}),{data:na,isLoading:Ur}=ze({queryKey:["/api/edge-devices"],enabled:Ds?.callerRole==="superadmin"||Ds?.callerRole==="admin",staleTime:0,refetchOnMount:"always"}),{data:Da}=ze({queryKey:["/api/edge-devices/status"],enabled:Ds?.callerRole==="superadmin",refetchInterval:3e4}),{data:Xc}=ze({queryKey:["/api/sales-orders"]}),oi=(Xc||[]).filter(U=>U.status==="active"),{data:Zl}=ze({queryKey:["/api/subscription-plans","wholesale-for-devices"],queryFn:async()=>{const U=await fetch("/api/subscription-plans?scope=wholesale",{credentials:"include"});return U.ok?U.json():[]},enabled:Ds?.callerRole==="superadmin"}),{data:al,isLoading:Zc}=ze({queryKey:["/api/admin/email-templates"],enabled:Ds?.callerRole==="superadmin"}),{data:il}=ze({queryKey:["/api/admin/email-outbound"],enabled:Ds?.callerRole==="superadmin"}),{data:Jl}=ze({queryKey:["/api/admin/support-ticket-outbound"],enabled:Ds?.callerRole==="superadmin"}),{data:Uo}=ze({queryKey:["/api/admin/smart-alerts-outbound"],enabled:Ds?.callerRole==="superadmin"}),{data:Cc}=ze({queryKey:["/api/admin/billing-notification-email"],enabled:Ds?.callerRole==="superadmin"}),{data:Ti}=ze({queryKey:["/api/admin/contact-notification-email"],enabled:Ds?.callerRole==="superadmin"}),{data:oa}=ze({queryKey:["/api/twilio/status"]}),{data:ja=[],isLoading:Tr}=ze({queryKey:["/api/admin/api-settings"],enabled:Ds?.callerRole==="superadmin"}),{data:zo}=ze({queryKey:["/api/admin/google-maps-key-status"],enabled:Ds?.callerRole==="superadmin"}),ha=Et({mutationFn:async()=>{const U=await fetch("/api/admin/places/check",{credentials:"include"});if(!U.ok)throw U.status===401?new Error("Your session has expired. Sign in and try again."):U.status===403?new Error("This account does not have permission to read API Settings."):U.status===404?new Error("The Places check is not available on this server yet. Try again after the app restarts."):new Error(`The Places check failed (HTTP ${U.status}). Please try again later.`);return U.json()}}),{data:Jc=[],isLoading:ol}=ze({queryKey:["/api/cloud-storage/settings"],enabled:Ds?.callerRole==="superadmin"||Ds?.callerRole==="admin",staleTime:0,refetchOnMount:"always",refetchInterval:3e4}),{data:zn}=ze({queryKey:[`/api/admin/reseller-policy/${s?.id}`],enabled:!!s?.id&&Ds?.callerRole!=="superadmin"}),{data:ll}=ze({queryKey:["/api/admin/reseller-policies"],enabled:Ds?.callerRole==="superadmin"}),{data:yn}=ze({queryKey:["/api/admin/reseller-policy/superadmin"],enabled:Ds?.callerRole==="superadmin"}),{data:cl=[],isLoading:ko}=ze({queryKey:["/api/admin/users",Cn,"trusted-devices"],queryFn:async()=>{const U=await fetch(`/api/admin/users/${Cn}/trusted-devices`);if(!U.ok)throw new Error(`Failed to fetch trusted devices: ${U.status}`);return U.json()},enabled:!!Cn&&ma,staleTime:0,retry:!1}),dl=Et({mutationFn:async({userId:U,deviceId:_e})=>{await Ze("DELETE",`/api/admin/users/${U}/trusted-devices/${_e}`)},onSuccess:()=>
489{Je.invalidateQueries({queryKey:["/api/admin/users",Cn,"trusted-devices"]}),n({title:"Device removed",description:"Trusted device has been revoked"})},onError:()=>{n({title:"Error",description:"Failed to revoke device",variant:"destructive"})}}),Cl=Et({mutationFn:async U=>{await Ze("DELETE",`/api/admin/users/${U}/trusted-devices`)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/users",Cn,"trusted-devices"]}),n({title:"All devices removed",description:"All trusted devices have been revoked"})},onError:()=>{n({title:"Error",description:"Failed to revoke devices",variant:"destructive"})}}),Ho=Et({mutationFn:async({userId:U,role:_e,companyIds:qt,siteIds:Zt,resellerId:Rs})=>{await Ze("PATCH",`/api/admin/users/${U}/role`,{role:_e,companyIds:qt,siteIds:Zt,resellerId:Rs})},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),Je.invalidateQueries({queryKey:["/api/admin/resellers"],refetchType:"all"}),w(!1),n({title:"Role updated"})},onError:U=>{const _e=U?.message||"Failed to update role",qt=_e.match(/^(\d{3}):\s*(.*)$/s),Zt=qt?parseInt(qt[1],10):void 0,Rs=qt?qt[2]:_e;let ir=Rs;try{const Ns=JSON.parse(Rs);Ns&&typeof Ns.message=="string"&&(ir=Ns.message)}catch{}n({title:Zt===409?"Cannot change role":"Error",description:ir,variant:"destructive"})}}),Ha=Et({mutationFn:async U=>{await Ze("DELETE",`/api/admin/users/${U}`)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),Je.invalidateQueries({queryKey:["/api/admin/resellers"],refetchType:"all"}),K(!1),n({title:"User deleted"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),Ai=Et({mutationFn:async({userId:U,newPassword:_e})=>{await Ze("POST",`/api/admin/users/${U}/reset-password`,{newPassword:_e})},onSuccess:()=>{k(!1),T(""),_(null),n({title:"Password reset",description:"The password has been updated successfully."})},onError:U=>{n({title:"Error",description:U.message||"Failed to reset password.",variant:"destructive"})}}),Bs=Et({mutationFn:async U=>(await Ze("POST",`/api/admin/users/${U}/resend-onboarding`,{})).json(),onSuccess:U=>{U.emailSent?(R(!1),$(null),q(null),n({title:"Onboarding email sent",description:"A new password was generated and emailed with the getting-started guide."})):q({error:U.emailError||"Failed to send onboarding email",generatedPassword:U.generatedPassword})},onError:U=>{n({title:"Error",description:U.message||"Failed to resend onboarding email.",variant:"destructive"})}}),ti=Et({mutationFn:async U=>(await Ze("POST",`/api/admin/users/${U}/resend-invite`)).json(),onSuccess:U=>{Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),U?.emailSent?n({title:"Invite re-sent",description:"A fresh set-your-password link has been emailed. Previous links no longer work."}):U?.inviteUrl?(navigator.clipboard?.writeText(U.inviteUrl).catch(()=>{}),n({title:"Email failed — invite link copied",description:U?.emailError?`${U.emailError}. The new invite link was copied to your clipboard so you can share it manually.`:"The new invite link was copied to your clipboard so you can share it manually.",variant:"destructive"})):n({title:"Invite re-send failed",description:U?.emailError||"Unknown error",variant:"destructive"})},onError:U=>{n({title:"Error",description:U.message||"Failed to re-send invite.",variant:"destructive"})}}),ec=Et({mutationFn:async U=>(await Ze("POST",`/api/admin/users/${U}/revoke-invite`)).json(),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),n({title:"Invite revoked",description:"Outstanding invite links no longer work. The account stays locked until you re-send an invite or set a password."})},onError:U=>{n({title:"Error",description:U.message||"Failed to revoke invite.",variant:"destructive"})}}),uo=Et({mutationFn:async U=>{v?await Ze("PATCH",`/api/admin/resellers/${v.userId}`,U):await Ze("POST","/api/admin/resellers",U)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/resellers"],refetchType:"all"}),Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),g(!1),b(null),Um(),n({title:v?"Customer updated":"Customer created"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),Na=Et({mutationFn:async U=>{await Ze("DELETE",`/api/admin/resellers/${U}`)},onSuccess:()=>
489{Je.invalidateQueries({queryKey:["/api/admin/resellers"],refetchType:"all"}),Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),K(!1),n({title:"Customer removed"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),La=Et({mutationFn:async U=>await Ze("POST",`/api/reseller-applications/${U}/approve`,{}),onSuccess:U=>{Je.invalidateQueries({queryKey:["/api/reseller-applications"],refetchType:"all"}),Je.invalidateQueries({queryKey:["/api/admin/resellers"],refetchType:"all"}),Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),n({title:"Application Approved",description:"Account created. A welcome email has been sent to the applicant."})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),kc=Et({mutationFn:async({id:U,reason:_e})=>await Ze("POST",`/api/reseller-applications/${U}/reject`,{reason:_e}),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/reseller-applications"]}),me(!1),be(null),$e(""),n({title:"Application Rejected"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),_c=Et({mutationFn:async({userId:U,disabled:_e})=>{await Ze("PATCH",`/api/admin/users/${U}/disable`,{disabled:_e})},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),n({title:"User status updated"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),tn=Et({mutationFn:async({resellerId:U,..._e})=>{await Ze("PUT",`/api/admin/reseller-policy/${U}`,_e)},onSettled:()=>{Je.invalidateQueries({queryKey:["/api/user/role"]})},onSuccess:()=>{Je.invalidateQueries({queryKey:[`/api/admin/reseller-policy/${s?.id}`]}),Je.invalidateQueries({queryKey:["/api/admin/reseller-policies"]}),Je.invalidateQueries({queryKey:["/api/admin/reseller-policy/superadmin"]}),n({title:"Policy updated",description:"Policy has been saved"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),qo=Et({mutationFn:async U=>(await Ze("POST",`/api/edge-devices/${U}/locate`)).json(),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/edge-devices"]}),n({title:"Device located",description:"Location has been updated"})},onError:U=>{n({title:"Location unavailable",description:U.message||"Could not determine device location",variant:"destructive"})}}),Hn=Et({mutationFn:async U=>{await Ze("PUT",`/api/admin/email-templates/${U.templateKey}`,U)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/email-templates"]}),n({title:"Template saved",description:"Email template has been updated"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),mo=Et({mutationFn:async U=>{await Ze("PUT","/api/admin/email-outbound",U)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/email-outbound"]}),ii(!1),n({title:"Outbound settings saved",description:"Sender name and email have been updated"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),qn=Et({mutationFn:async U=>{await Ze("PUT","/api/admin/support-ticket-outbound",U)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/support-ticket-outbound"]}),Ir(!1),n({title:"Support ticket settings saved",description:"Support ticket email settings have been updated"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),_o=Et({mutationFn:async U=>{await Ze("PUT","/api/admin/smart-alerts-outbound",U)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/smart-alerts-outbound"]}),At(!1),n({title:"Smart alerts settings saved",description:"Smart alert email sender has been updated"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),tm=Et({mutationFn:async U=>{await Ze("PUT","/api/admin/billing-notification-email",{email:U})},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/billing-notification-email"]}),hr(!1),n({title:"Billing email saved",description:"Billing notification email has been updated"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),Pd=Et({mutationFn:async U=>{await Ze("PUT","/api/admin/contact-notification-email",{email:U})},onSuccess:()=>
489{Je.invalidateQueries({queryKey:["/api/admin/contact-notification-email"]}),ur(!1),n({title:"Contact email saved",description:"Contact notification email has been updated"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),wi=Et({mutationFn:async U=>{await Ze("PUT",`/api/admin/api-settings/${U.key}`,{value:U.value,label:U.label,description:U.description})},onSuccess:(U,_e)=>{(_e.key==="google_places_api_key"||_e.key==="google_maps_server_key")&&ha.reset(),Je.invalidateQueries({queryKey:["/api/admin/api-settings"]}),Xn(null),qr({key:"",value:"",label:"",description:""}),n({title:"API key saved",description:"The API key has been updated"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),tc=Et({mutationFn:async U=>{await Ze("DELETE",`/api/admin/api-settings/${U}`)},onSuccess:(U,_e)=>{(_e==="google_places_api_key"||_e==="google_maps_server_key")&&ha.reset(),Je.invalidateQueries({queryKey:["/api/admin/api-settings"]}),n({title:"API key removed",description:"The API key has been cleared"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),ul=Et({mutationFn:async({key:U,enabled:_e})=>{await Ze("PATCH",`/api/admin/api-settings/${U}/toggle`,{enabled:_e})},onSuccess:(U,{key:_e})=>{(_e==="google_places_api_key"||_e==="google_maps_server_key")&&ha.reset(),Je.invalidateQueries({queryKey:["/api/admin/api-settings"]})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),Pc=Et({mutationFn:async U=>{await Ze("PUT","/api/admin/api-settings/outbound_email_provider",{value:U,label:"Outbound Email Provider",description:"The single provider used for all outbound application email."})},onSuccess:(U,_e)=>{Je.invalidateQueries({queryKey:["/api/admin/api-settings"]}),n({title:"Email provider updated",description:`${_e==="postmark"?"Postmark":"SendGrid"} will be used for future outbound email.`})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),_u=Et({mutationFn:async U=>{await Ze("PUT","/api/admin/api-settings/direct_lan_enabled",{value:U?"1":"0",label:"Direct LAN Live View",description:"Master switch for direct-LAN routing of live video."})},onSuccess:(U,_e)=>{Je.invalidateQueries({queryKey:["/api/admin/api-settings"]}),n({title:_e?"Direct LAN Live View enabled":"Direct LAN Live View disabled",description:_e?"On-network viewers may now connect directly to edge devices.":"Direct-LAN routing is off. All viewers use the standard proxied path."})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),Ec=Et({mutationFn:async()=>await(await Ze("POST","/api/edge-devices/push-tls-all")).json(),onSuccess:U=>{n({title:"TLS certificate queued",description:`Queued for ${U.pushed} device(s)${U.skipped?`, skipped ${U.skipped} without edge sync`:""}. Devices apply it on their next poll.`})},onError:U=>{n({title:"Push failed",description:U.message,variant:"destructive"})}}),Tc=Et({mutationFn:async({edgeDeviceId:U,settings:_e})=>{await Ze("PUT",`/api/cloud-storage/settings/${U}`,_e)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/cloud-storage/settings"]}),n({title:"Cloud storage settings saved"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),Ea=Et({mutationFn:async U=>(await Ze("POST",`/api/cloud-storage/sync/${U}`)).json(),onSuccess:U=>{Je.invalidateQueries({queryKey:["/api/cloud-storage/settings"]}),n({title:"Sync complete",description:U.message||`Synced ${U.synced} recordings`})},onError:U=>{n({title:"Sync failed",description:U.message,variant:"destructive"})}}),Ac=Et({mutationFn:async U=>{await Ze("DELETE",`/api/companies/${U}`)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/companies"],refetchType:"all"}),Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),K(!1),n({title:"Company deleted"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),Ed=Et({mutationFn:async U=>(await Ze("POST","/api/admin/users",U)).json(),onSuccess:U=>{Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),Qt(!1),De({email:"",firstName:"",lastName:"",password:"",role:"user",companyIds:[],resellerId:"",deliveryMode:"email"}),U?.emailSent?n({title:"User created",description:`Onboarding instructions emailed to ${U.email}.`}):U?.deliveryMode==="invite_link"&&U?.inviteUrl?n({title:"User created — email failed",description:`The invite email could not be sent. Share this set-password link securely with the user (expires in 72 hours): ${U.inviteUrl}`,variant:"destructive",duration:3e4}):U?.deliveryMode==="invite"&&U?.generatedPassword?n({title:"User created — email failed",description:`The invite email could not be sent. Temporary password: ${U.generatedPassword} — share it securely and ask the user to change it.`,variant:"destructive",duration:3e4}):U?.emailError?n({title:"User created — email failed",description:"The onboarding email could not be sent. You'll need to share the login details with the user yourself.",variant:"destructive"}):n({title:"User created"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),ed=Et({mutationFn:async U=>{await Ze("DELETE",`/api/sites/${U}`)},onSuccess:()=>
489{Je.invalidateQueries({queryKey:["/api/companies"],refetchType:"all"}),Je.invalidateQueries({queryKey:["/api/admin/users"],refetchType:"all"}),K(!1),n({title:"Site deleted"})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),Ah=Et({mutationFn:async()=>(await Ze("POST","/api/edge-devices/generate-serial")).json(),onSuccess:U=>{zt(_e=>({..._e,serialNumber:U.serialNumber}))}}),td=Et({mutationFn:async U=>{Ge?await Ze("PATCH",`/api/edge-devices/${Ge.id}`,U):await Ze("POST","/api/edge-devices",U)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/edge-devices"]}),Je.invalidateQueries({queryKey:["/api/cloud-storage/settings"]}),Je.invalidateQueries({queryKey:["/api/subscriptions"]}),Je.invalidateQueries({queryKey:["/api/subscription-summary"]}),Je.invalidateQueries({queryKey:["/api/sites"]}),pt(!1),ft(null),nn(),n({title:Ge?"Device updated":"Device registered"})},onError:U=>{const _e=U?.message||"";let qt="";try{qt=JSON.parse(_e.match(/\{.*\}/s)?.[0]||"{}")?.message||""}catch{}_e.includes("409")?n({title:"Serial already registered",description:qt||"A device with this serial number is already registered. Delete the existing device first, then re-register the same serial.",variant:"destructive"}):_e.includes("422")?n({title:"Validation Failed",description:qt||"Device connection or credential check failed. Verify the host, port, and credentials are correct.",variant:"destructive"}):n({title:"Error",description:qt||"Failed to save device",variant:"destructive"})}}),Vo=Et({mutationFn:async U=>{await Ze("DELETE",`/api/edge-devices/${U}`)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/edge-devices"]}),Je.invalidateQueries({queryKey:["/api/companies"]}),K(!1),n({title:"Device deleted",description:"The device and its linked site have been removed."})},onError:U=>{n({title:"Error",description:U.message,variant:"destructive"})}}),nn=()=>{zt({serialNumber:"",host:"",port:"443",apiUsername:"",apiPassword:"",orderNumber:"",defaultPlanId:"",salesOrderId:"",includeAiPlus:!1,maxCameras:"8"}),ne(null)};function Um(){Ct({targetUserId:"",businessName:"",contactName:"",email:"",phone:"",address:"",city:"",state:"",zip:"",notes:"",distributorId:"",hardwareMarkupOverridePercent:"",subscriptionMarkupOverridePercent:"",hideOrdersQuotes:!1})}function Pu(){Um(),b(null),g(!0)}function sd(U){b(U),Ct({targetUserId:U.userId,businessName:U.businessName||"",contactName:U.contactName||"",email:U.email||"",phone:U.phone||"",address:U.address||"",city:U.city||"",state:U.state||"",zip:U.zip||"",notes:U.notes||"",distributorId:U.distributorId||"",hardwareMarkupOverridePercent:U.hardwareMarkupOverridePercent!=null?String(U.hardwareMarkupOverridePercent):"",subscriptionMarkupOverridePercent:U.subscriptionMarkupOverridePercent!=null?String(U.subscriptionMarkupOverridePercent):"",hideOrdersQuotes:!!U.hideOrdersQuotes}),g(!0)}function sc(U){x(U);const _e=U.companyIds||[],qt=nh(U,kl),Rs=kl.find(ir=>qt.includes(ir.id))?.resellerId||"";xr({role:U.role||"user",companyIds:_e,siteIds:U.siteIds||[],resellerId:Rs}),Xt({}),w(!0)}u.useEffect(()=>{if(!V||G?.type!=="site"){ee(null);return}let U=!1;return ee(null),(async()=>{try{const qt=await(await Ze("POST","/api/admin/access-impact-preview",{kind:"site_delete",siteId:G.id})).json();U||ee(qt.affectedOwners||[])}catch{U||ee([])}})(),()=>{U=!0}},[V,G]),u.useEffect(()=>{if(!V||G?.type!=="company"){Y(null),he(null);return}if((hl.find(qt=>qt.id===G.id)?.sites?.length||0)>0){Y([]),he([]);return}let _e=!1;return Y(null),he(null),(async()=>{try{const Zt=await(await Ze("POST","/api/admin/access-impact-preview",{kind:"company_delete",companyId:G.id})).json();_e||(Y(Zt.affectedOwners||[]),he(Zt.strandedUsers||[]))}catch{_e||(Y([]),he([]))}})(),()=>{_e=!0}},[V,G,Ds]);const Wo=(Lt.role==="owner"||Lt.role==="user")&&!(Ds?.callerRole==="superadmin"&&Lt.resellerId)&&Lt.companyIds.length===0&&Lt.siteIds.length===0;async function Mh(){if(!j||Wo)return;if(!(j.role==="owner")){Ho.mutate({userId:j.id,role:Lt.role,companyIds:Lt.companyIds,siteIds:Lt.siteIds,resellerId:Lt.resellerId||void 0});return}H(!0);try{const Zt=(await(await Ze("POST","/api/admin/access-impact-preview",{kind:"user_companies_set",userId:j.id,companyIds:Lt.companyIds,siteIds:Lt.siteIds})).json()).affectedOwners||[];if(Zt.length>0){pe(Zt),ue(!0),H(!1);return}}catch{}H(!1),Ho.mutate({userId:j.id,role:Lt.role,companyIds:Lt.companyIds,siteIds:Lt.siteIds,resellerId:Lt.resellerId||void 0})}function Td(){G&&(G.type==="user"?Ha.mutate(G.id):G.type==="reseller"?Na.mutate(G.id):G.type==="company"?Ac.mutate(G.id):G.type==="site"?ed.mutate(G.id):G.type==="edge-device"&&Vo.mutate(G.id))}const qa=Ds?.callerRole||"user",Qs=qa==="superadmin",rc=qa==="owner",{data:Eu}=ze({queryKey:["/api/user/role"]}),Po=qa==="admin"&&!!Eu?.hideOrdersQuotes,{can:la,isPrimary:Rh,isLoading:ml,allowEdgeLaunch:rd}=aN(),Mc="Settings",Mi={users:"users",resellers:"resellers",companies:"companies",policies:"policies","email-templates":"email-templates","api-settings":"api-settings","edge-devices":"edge-devices",subscriptions:"subscriptions","cloud-storage":"cloud-storage","support-requests":"support-requests",backups:"backups","edge-pricing":"edge-pricing","playback-health":"playback-health","oem-branding":"branding"};u.useEffect(()=>{if(ml||qa!=="superadmin")return;const U=Mi[l];if(U&&!la(U,"read")){const _e=Object.entries(Mi).find(([,qt])=>la(qt,"read"))?.[0]??"users";c(_e)}},[l,qa,ml,la]);const nc=Ds?.users||[],kl=Ei||[],Ri=bi||[],ho={superadmin:4,admin:3,owner:2,user:1};function ac(U,_e){return _e?!1:qa==="superadmin"&&U==="superadmin"?Rh:(ho[qa]||0)>(ho[U]||0)}function tr(U,_e){return ac(U,_e)}function _l(U,_e){return ac(U,_e)}const nd=nc.filter(U=>U.role!=="superadmin"&&!U.resellerProfile),hl=Ds?.companies||[],Rc=nc.filter(U=>{if(!d)return!0;const _e=d.toLowerCase();return(U.firstName||"").toLowerCase().includes(_e)||(U.lastName||"").toLowerCase().includes(_e)||(U.email||"").toLowerCase().includes(_e)||(U.role||"").toLowerCase().includes(_e)}),sm=Ri.filter(U=>{if(!d)return!0;const _e=d.toLowerCase();return(U.businessName||"").toLowerCase().includes(_e)||(U.contactName||"").toLowerCase().includes(_e)||(U.email||"").toLowerCase().includes(_e)||(U.user?.firstName||"").toLowerCase().includes(_e)||(U.user?.lastName||"").toLowerCase().includes(_e)}).sort((U,_e)=>zi(U.businessName,_e.businessName)),Eo=Qs?kl:hl,pl=Eo.filter(U=>{if(!d)return!0;const _e=d.toLowerCase();return(U.name||"").toLowerCase().includes(_e)});return co?t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>e("/"),"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(uc,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold",children:Mc})]}),t.jsx(qd,{showDashboardLink:!0})]})})}),t.jsx("main",{className:"max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:t.jsx(ut,{children:t.jsxs(mt,{className:"py-12 text-center",children:[t.jsx(uc,{className:"w-12 h-12 mx-auto text-destructive mb-4"}),t.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Access Denied"}),t.jsx("p",{className:"text-muted-foreground",children:"You do not have permission to access the admin control panel."}),t.jsx(L,{variant:"outline",className:"mt-4",onClick:()=>e("/"),"data-testid":"button-go-home",children:"Return to Dashboard"})]})})})]}):nl||Sc?t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>e("/"),"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(uc,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold",children:Mc})]}),t.jsx(qd,{showDashboardLink:!0})]})})}),t.jsx("main",{className:"max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Bt,{className:"h-10 w-full"}),t.jsx(Bt,{className:"h-64 w-full"})]})})]}):t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>e("/"),"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(uc,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold",children:Mc})]}),t.jsx(qd,{showDashboardLink:!0})]})})}),dSe(qa,fn?.enabled)&&t.jsx("div",{className:"px-4 sm:px-6 lg:px-8 pt-4",children:t.jsxs(pu,{variant:"destructive",className:"border-destructive bg-destructive/10","data-testid":"alert-global-2fa-bypass",children:[t.jsx(iO,{className:"h-5 w-5"}),t.jsx(Yu,{children:"Global 2FA bypass is active"}),t.jsx(fu,{children:"Two-factor authentication enforcement is currently disabled for all logins. Review the database setting and disable the bypass when the emergency or staging need has ended."})]})}),t.jsx("main",{className:"flex flex-col sm:flex-row flex-1 min-h-0 overflow-hidden",style:{height:"calc(100vh - 4rem)"},children:t.jsxs(_h,{value:l,onValueChange:c,className:"flex flex-col sm:flex-row w-full min-h-0 h-full",children:[t.jsx("div",{className:"shrink-0 border-b sm:border-b-0 sm:border-r border-border bg-muted/30 overflow-x-auto sm:overflow-x-visible sm:overflow-y-auto sm:w-56 sm:p-3",children:t.jsxs(Dm,{className:"flex sm:flex-col items-stretch h-auto bg-transparent gap-0.5 sm:gap-1 px-1.5 py-1.5 
489sm:p-0 justify-start sm:justify-start w-max sm:w-auto","data-testid":"admin-tabs",children:[Rh&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"tab-permissions",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-tab-permissions",children:[t.jsx(uc,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"SA Permissions"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"SA Permissions"})]}),Qs&&la("distribution","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"distribution",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-distribution",children:[t.jsx(cg,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Distribution"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Distribution"})]}),Qs&&la("resellers","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"resellers",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-resellers",children:[t.jsx(oh,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Customers"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Customers"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"users",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-users",children:[t.jsx(Ba,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Users"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Users"})]}),(!Qs||la("companies","read"))&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"companies",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-companies",children:[t.jsx(xi,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Companies / Sites"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Companies / Sites"})]}),(Qs||qa==="admin")&&(!Qs||la("subscriptions","read"))&&!Po&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"subscriptions",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-sales-orders",children:[t.jsx(HK,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Sales Orders"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Sales Orders"})]}),Qs&&la("support-requests","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"support-requests",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-support-requests",children:[t.jsx(k0,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Support Requests"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Support"})]}),Qs&&la("edge-devices","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"edge-devices",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-edge-devices",children:[t.jsx(Fa,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Edge Devices"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Edge Devices"})]}),!rc&&(!Qs||la("policies","read"))&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"policies",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-policies",children:[t.jsx(uc,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Policies"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Policies"})]}),!rc&&(!Qs||la("cloud-storage","read"))&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"cloud-storage",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-cloud-storage",children:[t.jsx(pn,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Cloud Storage"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Cloud"})]}),Qs&&la("playback-health","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"playback-health",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-playback-health",children:[t.jsx(vc,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Playback Health"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Playback"})]}),Qs&&la("api-settings","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"api-settings",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-api-settings",children:[t.jsx(yg,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"API Settings"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"API"})]}),Qs&&la("email-templates","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"email-templates",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-email-templates",children:[t.jsx(qi,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Email Templates"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Email"})]}),Qs&&la("edge-pricing","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"edge-pricing",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-edge-pricing",children:[t.jsx(S0,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Edge Pricing"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Edge Pricing"})]}),Qs&&la("blog","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"blog",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-blog",children:[t.jsx(UK,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Blog"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Blog"})]}),Qs&&la("branding","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"oem-branding",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-oem-branding",children:[t.jsx(rO,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Branding"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Branding"})]}),Qs&&la("backups","read")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(_n,{value:"backups",className:"justify-center sm:justify-start gap-2 px-2 sm:px-3","data-testid":"tab-backups",children:[t.jsx(mf,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:"Database"})]})}),t.jsx(Yt,{side:"bottom",className:"sm:hidden",children:"Database"})]})]})}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden",children:[["users","resellers","edge-devices","companies"].includes(l)&&t.jsx("div",{className:"sticky top-0 z-10 bg-background/95 backdrop-blur border-b border-border px-4 sm:px-6 py-3",children:t.jsxs("div",{className:"relative w-full max-w-sm",children:[t.jsx(yc,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t.jsx(ke,{placeholder:"Search...",value:d,onChange:U=>h(U.target.value),className:"pl-9","data-testid":"input-search"})]})}),t.jsxs("div",{className:"p-4 sm:p-6",children:[t.jsxs(ea,{value:"resellers",children:[Qs&&t.jsxs("div",{className:"mb-8",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Customer Applications"}),za&&za.filter(U=>U.status==="pending").length>0&&t.jsxs(Ke,{variant:"destructive",className:"text-xs",children:[za.filter(U=>U.status==="pending").length," new"]})]}),t.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-md p-1 self-start sm:self-auto",children:[t.jsx(L,{size:"sm",variant:ce==="pending"?"default":"ghost",className:"h-7 px-3 text-xs",onClick:()=>Pe("pending"),"data-testid":"button-filter-pending",children:"Pending"}),t.jsx(L,{size:"sm",variant:ce==="approved"?"default":"ghost",className:"h-7 px-3 text-xs",onClick:()=>Pe("approved"),"data-testid":"button-filter-approved",children:"Approved"})]})]}),Xl?t.jsx("div",{className:"space-y-3",children:[1,2].map(U=>t.jsx(Bt,{className:"h-24 w-full"},U))}):!za||za.filter(U=>U.status===ce).length===0?t.jsx(ut,{children:t.jsxs(mt,{className:"py-8 text-center",children:[t.jsx(xu,{className:"w-10 h-10 mx-auto text-muted-foreground mb-3"}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["No ",ce," applications"]})]})}):t.jsx("div",{className:"grid gap-3",children:za.filter(U=>U.status===ce).sort((U,_e)=>zi(U.companyName,_e.companyName)).map(U=>t.jsx(ut,{"data-testid":`card-application-${U.id}`,children:t.jsx(mt,{className:"py-4",children:t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[t.jsx("span",{className:"font-medium text-foreground",children:U.companyName}),t.jsx(Ke,{variant:U.status==="approved"?"default":U.status==="rejected"?"destructive":"secondary",children:U.status})]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[U.principalContact," · ",U.billingEmail," · ",U.principalPhone]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Tech Contact: ",U.techFirstName," ",U.techLastName," — ",U.techEmail]}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[U.addressLine1,U.addressLine2?`, ${U.addressLine2}`:"",", ",U.city,", ",U.state," ",U.postalCode,", ",U.country]}),U.federalTaxId&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tax ID: ",U.federalTaxId]}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Submitted: ",new Date(U.createdAt).toLocaleDateString(),U.reviewedAt&&t.jsxs("span",{className:"ml-2",children:["· Approved: ",new Date(U.reviewedAt).toLocaleDateString()]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[U.status==="pending"&&t.jsxs(t.Fragment,{children:[t.jsxs(L,{size:"sm",onClick:()=>La.mutate(U.id),disabled:La.isPending,"data-testid":`button-approve-${U.id}`,children:[La.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):t.jsx(Ny,{className:"w-3.5 h-3.5 mr-1"}),"Approve"]}),t.jsxs(L,{size:"sm",variant:"destructive",onClick:()=>{be(U),$e(""),me(!0)},"data-testid":`button-reject-${U.id}`,children:[t.jsx(ES,{className:"w-3.5 h-3.5 mr-1"}),"Reject"]})]}),t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>window.open(`/api/reseller-applications/${U.id}/pdf`,"_blank"),"data-testid":`button-download-pdf-${U.id}`,children:[t.jsx(ya,{className:"w-3.5 h-3.5 mr-1"}),"PDF"]})]})]})})},U.id))})]}),t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Customer Accounts"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage administrator/customer accounts and their business information"})]}),t.jsxs(L,{onClick:Pu,className:"shrink-0 self-start sm:self-auto","data-testid":"button-add-reseller",children:[t.jsx(ny,{className:"w-4 h-4 mr-2"}),"Add Customer"]})]}),sm.length===0?t.jsx(ut,{children:t.jsxs(mt,{className:"py-12 text-center",children:[t.jsx(oh,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:d?"No customers match your search":"No customer accounts yet"}),!d&&t.jsxs(L,{variant:"outline",className:"mt-4",onClick:Pu,"data-testid":"button-add-reseller-empty",children:[t.jsx(ny,{className:"w-4 h-4 mr-2"}),"Add First Customer"]})]})}):t.jsx("div",{className:"grid gap-4",children:sm.map(U=>t.jsx(ut,{"data-testid":`card-reseller-${U.userId}`,children:t.jsx(mt,{className:"py-4",children:t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs(cy,{className:"w-10 h-10",children:[t.jsx(dy,{src:U.user?.profileImageUrl||void 0}),t.jsx(uy,{className:"bg-primary text-primary-foreground text-sm",children:RP(U.user?.firstName,U.user?.lastName)})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:"font-medium","data-testid":`text-reseller-business-${U.userId}`,children:Vp(U.businessName)}),t.jsx(Ke,{variant:"secondary",children:"Administrator"})]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[U.contactName||`${U.user?.firstName||""} ${U.user?.lastName||""}`,U.email&&` - ${U.email}`]}),t.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground mt-1",children:[U.phone&&t.jsx("span",{children:U.phone}),U.city&&U.state&&t.jsxs("span",{children:[U.city,", ",U.state," ",U.zip]})]})]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>sd(U),"data-testid":`button-edit-reseller-${U.userId}`,children:t.jsx(ga,{className:"w-4 h-4"})}),t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{z({type:"reseller",id:U.userId,name:U.businessName}),K(!0)},"data-testid":`button-delete-reseller-${U.userId}`,children:t.jsx(sa,{className:"w-4 h-4 text-destructive"})})]})]})})},U.id))})]}),t.jsxs(ea,{value:"users",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:Qs?"All Users":"Your Users"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:Qs?"View and manage user roles and company assignments":"Users assigned to your companies"})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap self-start sm:self-auto",children:[Qs&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{id:"group-by-reseller",checked:It,onCheckedChange:ns,"data-testid":"switch-group-by-reseller"}),t.jsx("label",{htmlFor:"group-by-reseller",className:"text-sm text-muted-foreground cursor-pointer select-none whitespace-nowrap",children:"Group by customer"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{id:"group-by-company",checked:We,onCheckedChange:St,"data-testid":"switch-group-by-company"}),t.jsx("label",{htmlFor:"group-by-company",className:"text-sm text-muted-foreground cursor-pointer select-none whitespace-nowrap",children:"Group by company"})]}),t.jsxs(L,{onClick:()=>Qt(!0),className:"shrink-0","data-testid":"button-add-user",children:[t.jsx(ny,{className:"w-4 h-4 mr-2"}),"Add User"]})]})]}),Rc.length===0?t.jsx(ut,{children:t.jsxs(mt,{className:"py-12 text-center",children:[t.jsx(Ba,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:"No users found"})]})}):(()=>{const U=Qs?kl:hl,_e=qa==="superadmin"?Rc.filter(tt=>tt.role==="superadmin"):[],qt=Rc.filter(tt=>tt.role!=="superadmin"),Zt=tt=>{const $t=tt.id===s?.id,Wn=nh(tt,U).map(zr=>U.find($n=>
489$n.id===zr)).filter(Boolean);return t.jsx(ut,{"data-testid":`card-user-${tt.id}`,children:t.jsx(mt,{className:"py-3",children:t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(cy,{className:"w-9 h-9",children:[t.jsx(dy,{src:tt.profileImageUrl||void 0}),t.jsx(uy,{className:"bg-primary text-primary-foreground text-xs",children:RP(tt.firstName,tt.lastName)})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"font-medium text-sm","data-testid":`text-user-name-${tt.id}`,children:[tt.firstName||""," ",tt.lastName||""]}),eCe(tt.role),$t&&t.jsx(Ke,{variant:"outline",children:"You"}),tt.disabled&&t.jsx(Ke,{variant:"destructive","data-testid":`badge-disabled-${tt.id}`,children:"Disabled"}),tt.invitePending&&t.jsx(Ke,{variant:"outline",className:"border-amber-500/60 text-amber-600 dark:text-amber-400","data-testid":`badge-invite-pending-${tt.id}`,children:"Invite pending"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[t.jsx("span",{children:tt.email}),!We&&Wn.length>0&&Wn.map(zr=>t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(xi,{className:"w-3 h-3"}),zr.name]},zr.id))]})]})]}),!$t&&t.jsxs("div",{className:"flex items-center gap-1",children:[tr(tt.role,tt.isPrimary)&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>_c.mutate({userId:tt.id,disabled:!tt.disabled}),disabled:_c.isPending,"data-testid":`button-toggle-disable-${tt.id}`,children:tt.disabled?t.jsx(Ny,{className:"w-4 h-4 text-green-600"}):t.jsx(ES,{className:"w-4 h-4 text-muted-foreground"})}),t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{Lr(tt.id),Nc(`${tt.firstName||""} ${tt.lastName||""}`.trim()||tt.email||"User"),lo(!0)},"data-testid":`button-trusted-devices-${tt.id}`,children:t.jsx(Yc,{className:"w-4 h-4 text-muted-foreground"})}),tt.invitePending&&(Qs||qa==="admin"||qa==="owner")&&t.jsxs(t.Fragment,{children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>ti.mutate(tt.id),disabled:ti.isPending||ec.isPending,"data-testid":`button-resend-invite-${tt.id}`,children:t.jsx(qi,{className:"w-4 h-4 text-muted-foreground"})})}),t.jsx(Yt,{children:"Re-send invite link"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>ec.mutate(tt.id),disabled:ti.isPending||ec.isPending,"data-testid":`button-revoke-invite-${tt.id}`,children:t.jsx(va,{className:"w-4 h-4 text-destructive"})})}),t.jsx(Yt,{children:"Revoke pending invite"})]})]}),!tt.invitePending&&(Qs||qa==="admin")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{$(tt),q(null),R(!0)},"data-testid":`button-resend-onboarding-${tt.id}`,children:t.jsx(qi,{className:"w-4 h-4 text-muted-foreground"})})}),t.jsx(Yt,{children:"Resend onboarding email"})]}),(Qs||qa==="admin")&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{_(tt),T(""),k(!0)},"data-testid":`button-reset-password-${tt.id}`,children:t.jsx(yg,{className:"w-4 h-4 text-muted-foreground"})})}),t.jsx(Yt,{children:"Reset password"})]}),_l(tt.role,tt.isPrimary)&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>sc(tt),"data-testid":`button-edit-role-${tt.id}`,children:t.jsx(ga,{className:"w-4 h-4"})}),_l(tt.role,tt.isPrimary)&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{z({type:"user",id:tt.id,name:`${tt.firstName||""} ${tt.lastName||""}`.trim()||tt.email||"User"}),K(!0)},"data-testid":`button-delete-user-${tt.id}`,children:t.jsx(sa,{className:"w-4 h-4 text-destructive"})})]})]})})},tt.id)},Rs=(tt,$t)=>t.jsxs("div",{className:"ml-4 border-l pl-4","data-testid":`section-company-${tt.id}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(xi,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:tt.name}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",$t.length,")"]})]}),t.jsx("div",{className:"grid gap-2",children:$t.map(Zt)})]},tt.id),ir=_e.length>0?t.jsxs("div",{"data-testid":"section-management",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx(vi,{className:"w-4 h-4 text-primary"}),t.jsxs("h3",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:[a.productName," Management"]}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",_e.length," user",_e.length!==1?"s":"",")"]})]}),t.jsx("div",{className:"grid gap-2",children:_e.map(Zt)})]}):null;if(!We&&!(Qs&&It))return t.jsxs("div",{className:"flex flex-col gap-6",children:[ir,qt.length>0&&t.jsx("div",{className:"grid gap-3",children:qt.map(Zt)})]});if(!Qs||!It){const tt=qt.filter(zr=>zr.role==="admin"),$t=qt.filter(zr=>zr.role!=="admin"),kr=U.map(zr=>({id:zr.id,name:zr.name,users:$t.filter($n=>nh($n,U).includes(zr.id))})).filter(zr=>zr.users.length>0).sort((zr,$n)=>zi(zr.name,$n.name)),Wn=$t.filter(zr=>nh(zr,U).length===0);return t.jsxs("div",{className:"flex flex-col gap-6",children:[ir,tt.length>0&&t.jsxs("div",{"data-testid":"section-admins",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(oh,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Administrators"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",tt.length,")"]})]}),t.jsx("div",{className:"grid gap-2",children:tt.map(Zt)})]}),kr.map(zr=>t.jsxs("div",{"data-testid":`section-company-${zr.id}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(xi,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:zr.name}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",zr.users.length,")"]})]}),t.jsx("div",{className:"grid gap-2",children:zr.users.map(Zt)})]},zr.id)),Wn.length>0&&t.jsxs("div",{"data-testid":"section-unassigned-users",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(Ba,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"No Company Assigned"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",Wn.length,")"]})]}),t.jsx("div",{className:"grid gap-2",children:Wn.map(Zt)})]})]})}const Vn=new Map;for(const tt of U){const $t=tt.resellerId||"__none__";Vn.has($t)||Vn.set($t,[]),Vn.get($t).push(tt)}const Ns=Ri.map(tt=>{const $t=(Vn.get(tt.userId)||[]).sort((Wn,zr)=>zi(Wn.name,zr.name)),kr=qt.filter(Wn=>nh(Wn,U).some(zr=>$t.some($n=>$n.id===zr)));return{reseller:tt,companies:$t,users:kr}}).filter(tt=>tt.users.length>0).sort((tt,$t)=>zi(tt.reseller.businessName,$t.reseller.businessName)),or=new Set(Ns.flatMap(tt=>tt.users.map($t=>$t.id))),os=qt.filter(tt=>!or.has(tt.id)),nt=(Vn.get("__none__")||[]).sort((tt,$t)=>zi(tt.name,$t.name));return t.jsxs("div",{className:"flex flex-col gap-6",children:[ir,Ns.map(tt=>t.jsxs("div",{"data-testid":`section-reseller-${tt.reseller.userId}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx(oh,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:Vp(tt.reseller.businessName)}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",tt.users.length," user",tt.users.length!==1?"s":"",")"]})]}),We?t.jsxs("div",{className:"flex flex-col gap-4",children:[(()=>{const $t=tt.users.filter(kr=>kr.role==="admin");return $t.length>0?t.jsx("div",{className:"grid gap-2","data-testid":`section-reseller-${tt.reseller.userId}-admins`,children:$t.map(Zt)}):null})(),tt.companies.filter($t=>tt.users.some(kr=>kr.role!=="admin"&&nh(kr,U).includes($t.id))).map($t=>{const kr=tt.users.filter(Wn=>Wn.role!=="admin"&&nh(Wn,U).includes($t.id));return Rs($t,kr)}),(()=>{const $t=tt.users.filter(kr=>kr.role!=="admin"&&nh(kr,U).length===0);return $t.length>0?t.jsxs("div",{className:"ml-4 border-l pl-4","data-testid":`section-reseller-${tt.reseller.userId}-unassigned`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(Ba,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"No Company Assigned"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",$t.length,")"]})]}),t.jsx("div",{className:"grid gap-2",children:$t.map(Zt)})]}):null})()]}):t.jsx("div",{className:"grid gap-2",children:tt.users.map(Zt)})]}
489,tt.reseller.userId)),os.length>0&&t.jsxs("div",{"data-testid":"section-no-reseller",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx(Ba,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"No Linked Customer"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",os.length," user",os.length!==1?"s":"",")"]})]}),We&&nt.length>0?t.jsxs("div",{className:"flex flex-col gap-4",children:[(()=>{const tt=os.filter($t=>$t.role==="admin");return tt.length>0?t.jsx("div",{className:"grid gap-2","data-testid":"section-no-reseller-admins",children:tt.map(Zt)}):null})(),nt.filter(tt=>os.some($t=>$t.role!=="admin"&&nh($t,U).includes(tt.id))).map(tt=>{const $t=os.filter(kr=>kr.role!=="admin"&&nh(kr,U).includes(tt.id));return Rs(tt,$t)}),(()=>{const tt=os.filter($t=>$t.role!=="admin"&&nh($t,U).length===0);return tt.length>0?t.jsxs("div",{className:"ml-4 border-l pl-4","data-testid":"section-no-reseller-unassigned",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(Ba,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"No Company Assigned"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",tt.length,")"]})]}),t.jsx("div",{className:"grid gap-2",children:tt.map(Zt)})]}):null})()]}):t.jsx("div",{className:"grid gap-2",children:os.map(Zt)})]})]})})()]}),t.jsxs(ea,{value:"companies",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Companies & Sites"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage all companies and their associated sites"})]}),!rc&&t.jsxs(L,{onClick:()=>{J(null),Ae(!0)},className:"shrink-0 self-start sm:self-auto","data-testid":"button-add-company",children:[t.jsx(Fo,{className:"w-4 h-4 mr-2"}),"Add Company"]})]}),pl.length===0?t.jsx(ut,{children:t.jsxs(mt,{className:"py-12 text-center",children:[t.jsx(xi,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:d?"No companies match your search":"No companies yet"})]})}):t.jsx("div",{className:"grid gap-4",children:pl.map(U=>t.jsxs(ut,{"data-testid":`card-company-${U.id}`,children:[t.jsx(xs,{className:"pb-3",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs(ys,{className:"text-base flex items-center gap-2 flex-wrap",children:[t.jsx(xi,{className:"w-4 h-4 text-muted-foreground shrink-0"}),t.jsx("span",{"data-testid":`text-company-name-${U.id}`,children:U.name}),t.jsxs(Ke,{variant:"outline",children:[U.sites?.length||0," sites"]})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[U.description&&t.jsx(Xs,{children:U.description}),!rc&&U.resellerId&&t.jsxs(Ke,{variant:"secondary",className:"max-w-full","data-testid":`badge-reseller-${U.id}`,children:[t.jsx(oh,{className:"w-3 h-3 mr-1 shrink-0"}),t.jsx("span",{className:"truncate",children:Vp(Ri.find(_e=>_e.userId===U.resellerId)?.businessName)||"Unknown Customer"})]}),!rc&&!U.resellerId&&t.jsx(Ke,{variant:"outline",className:"text-muted-foreground","data-testid":`badge-no-reseller-${U.id}`,children:"No Customer"})]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{J(U),Ae(!0)},"data-testid":`button-edit-company-${U.id}`,children:t.jsx(ga,{className:"w-4 h-4"})}),t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{Ue(U.id),ye(null),we(!0)},"data-testid":`button-add-site-${U.id}`,children:t.jsx(Fo,{className:"w-4 h-4"})}),!rc&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{z({type:"company",id:U.id,name:U.name}),K(!0)},"data-testid":`button-delete-company-${U.id}`,children:t.jsx(sa,{className:"w-4 h-4 text-destructive"})})]})]})}),U.sites&&U.sites.length>0&&t.jsx(mt,{className:"pt-0",children:t.jsx("div",{className:"grid gap-2",children:U.sites.map(_e=>t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 sm:gap-4 roun
489ded-md border border-border p-3","data-testid":`card-site-${_e.id}`,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t.jsx(ql,{className:"w-4 h-4 text-muted-foreground shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"text-sm font-medium","data-testid":`text-site-name-${_e.id}`,children:_e.name}),_e.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate","data-testid":`text-site-description-${_e.id}`,children:_e.description.length>50?`${_e.description.slice(0,50)}...`:_e.description})]})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0 pl-6 sm:pl-0",children:[_e.serialNumber&&t.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1 font-mono truncate max-w-[120px] sm:max-w-none",children:[t.jsx(Fa,{className:"w-3 h-3 shrink-0"}),t.jsx("span",{className:"truncate",children:_e.serialNumber})]}),t.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${_e.isOnline?"bg-green-500":"bg-muted-foreground/40"}`,"data-testid":`status-site-${_e.id}`}),t.jsx("span",{className:`text-xs ${_e.isOnline?"text-foreground":"text-muted-foreground"}`,children:_e.isOnline?"Online":"Offline"})]}),t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{Ue(U.id),ye(_e),we(!0)},"data-testid":`button-edit-site-${_e.id}`,children:t.jsx(ga,{className:"w-4 h-4"})}),!rc&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{z({type:"site",id:_e.id,name:_e.name}),K(!0)},"data-testid":`button-delete-site-${_e.id}`,children:t.jsx(sa,{className:"w-4 h-4 text-destructive"})})]})]},_e.id))})}),(!U.sites||U.sites.length===0)&&t.jsx(mt,{className:"pt-0",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"No sites configured"})})]},U.id))})]}),t.jsxs(ea,{value:"edge-devices",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold","data-testid":"text-edge-devices-title",children:"Edge Devices"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Register and manage Edge devices"})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap self-start sm:self-auto",children:[Qs&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{id:"device-group-by-reseller",checked:It,onCheckedChange:ns,"data-testid":"switch-device-group-by-reseller"}),t.jsx("label",{htmlFor:"device-group-by-reseller",className:"text-sm text-muted-foreground cursor-pointer select-none whitespace-nowrap",children:"Group by customer"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{id:"device-group-by-company",checked:We,onCheckedChange:St,"data-testid":"switch-device-group-by-company"}),t.jsx("label",{htmlFor:"device-group-by-company",className:"text-sm text-muted-foreground cursor-pointer select-none whitespace-nowrap",children:"Group by company"})]}),(qa==="admin"||Qs||rc)&&t.jsxs(L,{variant:"outline",onClick:()=>Es(!0),className:"shrink-0","data-testid":"button-recover-camera-brand-model",title:"Scan all Edge devices and recover Brand/Model for legacy cameras",children:[t.jsx(ZK,{className:"w-4 h-4 mr-2"}),"Recover Brand/Model"]}),t.jsxs(L,{onClick:()=>{ft(null),nn(),pt(!0)},className:"shrink-0","data-testid":"button-add-edge-device",children:[t.jsx(Fo,{className:"w-4 h-4 mr-2"}),"Register Device"]})]})]}),!Ur&&na&&na.length>0&&t.jsx(XSe,{devices:na,statusData:Da}),Ur?t.jsx("div",{className:"space-y-3",children:[1,2,3].map(U=>t.jsx(Bt,{className:"h-20 w-full"},U))}):!na||na.length===0?t.jsx(ut,{children:t.jsx(mt,{className:"py-12 text-center",children:t.jsx("p",{className:"text-muted-foreground",children:"No Edge devices registered yet"})})}):(()=>{const U=Qs?kl:hl,_e=new Map;for(const nt of U)for(const tt of nt.sites||[])_e.set(tt.serialNumber,{siteName:tt.name,companyId:nt.id,companyName:nt.name,companyResellerId:nt.resellerId});const qt=(na||[]).filter(nt=>!d||nt.serialNumber?.toLowerCase().includes(d.toLowerCase())||nt.host?.toLowerCase().includes(d.toLowerCase())||nt.orderNumber?.toLowerCase().includes(d.toLowerCase())),Zt=nt=>{const tt=_e.get(nt.serialNumber),$t=nt.recordingsDiscovery?.status,kr=nt.recordingsDiscoveryStale===!0,Wn=kr||$t&&$t!=="selected",zr=(nt.segmentTempCleanup?.consecutiveFailures??0)>=3,$n=$t==="ambiguous"?"Multiple recording directories were found.":$t==="scan-capped"?"The safe directory scan limit was reached.":$t==="explicit-invalid"?"The configured override is not a valid recordings directory.":"No valid recordings directory was found.";return t.jsx(ut,{"data-testid":`card-edge-device-${nt.id}`,children:t.jsxs(mt,{className:"py-4",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[t.jsx("div",{className:"flex items-center justify-center w-9 h-9 sm:w-10 sm:h-10 rounded bg-primary/10 text-primary shrink-0",children:t.jsx(Fa,{className:"w-4 h-4 sm:w-5 sm:h-5"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${Da?.[nt.id]===!0?"bg-green-500":Da?.[nt.id]===!1?"bg-muted-foreground
489/40":"bg-amber-400 animate-pulse"}`,"data-testid":`status-device-${nt.id}`}),t.jsx("p",{className:"font-mono font-semibold text-sm sm:text-base","data-testid":`text-serial-${nt.id}`,children:nt.serialNumber})]}),nt.registeredToResellerId||nt.linkedSiteId?t.jsx(Ke,{variant:"secondary",className:"text-xs no-default-active-elevate max-w-[200px] sm:max-w-none","data-testid":`badge-registered-${nt.id}`,children:t.jsxs("span",{className:"truncate",children:["Registered",nt.resellerName?` - ${nt.resellerName}`:""]})}):t.jsx(Ke,{variant:"outline",className:"text-xs no-default-active-elevate","data-testid":`badge-available-${nt.id}`,children:"Available"})]}),tt&&t.jsxs("p",{className:"text-xs text-muted-foreground truncate","data-testid":`text-site-name-${nt.id}`,children:["Site: ",t.jsx("span",{className:"text-foreground font-medium",children:tt.siteName})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[t.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["Order: ",nt.orderNumber]}),nt.defaultPlanId&&(()=>{const Va=(Zl||[]).find(Qi=>Qi.id===nt.defaultPlanId);if(!Va)return null;if(Va.storageType==="none")return t.jsx(Ke,{variant:"secondary",className:"text-xs no-default-active-elevate","data-testid":`badge-plan-${nt.id}`,children:"No Subscription"});const Yi=Va.storageType==="local"?"Local":Va.storageType==="cloud_blu"?"Cloud Blu":"Cloud",Ii=Va.retentionDays?` ${Va.retentionDays}d`:"",To=Va.interval==="monthly"?"/mo":Va.interval==="quarterly"?"/qtr":"/yr";return t.jsxs(Ke,{variant:"secondary",className:"text-xs no-default-active-elevate","data-testid":`badge-plan-${nt.id}`,children:[Yi,Ii," ",To]})})(),nt.orderAttachment&&t.jsxs("a",{href:nt.orderAttachment,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary flex items-center gap-1 shrink-0",onClick:Va=>Va.stopPropagation(),"data-testid":`link-attachment-${nt.id}`,children:[t.jsx(xde,{className:"w-3 h-3"}),"View"]})]}),(nt.city||nt.region||nt.ipAddress)&&t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx(ql,{className:"w-3 h-3 text-muted-foreground shrink-0"}),t.jsxs("p",{className:"text-xs text-muted-foreground truncate","data-testid":`text-device-location-${nt.id}`,children:[[nt.city,nt.region].filter(Boolean).join(", "),nt.ipAddress&&` (${nt.ipAddress})`]})]}),nt.hasEdgeSyncKey&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx(uf,{className:"w-3 h-3 text-muted-foreground shrink-0"}),nt.edgeSyncScriptVersion?Ite(nt.edgeSyncScriptVersion,nt.currentServerVersion)?t.jsxs("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 flex items-center gap-1","data-testid":`text-agent-version-${nt.id}`,children:[t.jsx(ar,{className:"w-3 h-3"}),"Agent v",nt.edgeSyncScriptVersion]}):t.jsxs("span",{className:"text-xs text-amber-600 dark:text-amber-400 flex items-center gap-1","data-testid":`text-agent-version-${nt.id}`,children:[t.jsx(ta,{className:"w-3 h-3"}),"Agent v",nt.edgeSyncScriptVersion," — update to v",nt.currentServerVersion]}):t.jsx("span",{className:"text-xs text-muted-foreground","data-testid":`text-agent-version-${nt.id}`,children:"Agent version unknown"})]}),Wn&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-500/50 bg-amber-500/10 p-2.5 text-xs text-amber-700 dark:text-amber-300","data-testid":`warning-recordings-drive-${nt.id}`,children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Pn,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("div",{children:kr?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"font-medium",children:"Recordings drive health is stale"}),t.jsx("p",{children:"The last drive-health report is no longer current. The Edge agent must check in before this recordings-drive health can be trusted."})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"font-medium",children:"Recordings drive unavailable"}),t.jsxs("p",{children:[$n," Check the mounted recordings drive or set"," ",t.jsx("code",{className:"font-mono",children:"TRUVIOS_RECORDINGS_DIR"})," to the valid recordings path on this device. Recording-history uploads remain paused until the directory is available."]})]})})]})}),zr&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-500/50 bg-amber-500/10 p-2.5 text-xs text-amber-700 dark:text-amber-300","data-testid":`warning-temp-cleanup-${nt.id}`,children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Pn,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Temporary bundle cleanup is failing"}),t.jsx("p",{children:"The Edge device could not free temporary cloud-bundle storage after repeated attempts. Check filesystem permissions and available disk health on the device."})]})]})})]})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0 self-end sm:self-auto",children:[rd&&nt.linkedSiteId&&Da?.[nt.id]===!0&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>window.open(`/api/edge-login/${nt.linkedSiteId}?admin=1`,"_blank"),"data-testid":`button-launch-device-${nt.id}`,children:t.jsx(op,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Launch Edge"})]}),t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>qo.mutate(nt.id),disabled:qo.isPending,title:"Locate device","data-testid":`button-locate-device-${nt.id}`,children:qo.isPending?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):t.jsx(ql,{className:"w-4 h-4"})}),t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{ft(nt),zt({serialNumber:nt.serialNumber,host:nt.host,port:String(nt.port),apiUsername:nt.apiUsername,apiPassword:nt.apiPassword,orderNumber:nt.orderNumber||"",defaultPlanId:nt.defaultPlanId||"",salesOrderId:nt.salesOrderId||"",includeAiPlus:nt.includeAiPlus??!1,maxCameras:String(nt.maxCameras??8)}),ne(nt.orderAttachment?{name:"Order Document",objectPath:nt.orderAttachment}:null),pt(!0)},"data-testid":`button-edit-device-${nt.id}`,children:t.jsx(ga,{className:"w-4 h-4"})}),t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{z({type:"edge-device",id:nt.id,name:nt.serialNumber}),K(!0)},"data-testid":`button-delete-device-${nt.id}`,children:t.jsx(sa,{className:"w-4 h-4"})})]})]}),t.jsx(GSe,{device:nt}),t.jsx(ZSe,{device:nt,isOnline:Da?.[nt.id]===!0,isSuperadmin:r?.role==="superadmin"})]})}
489,nt.id)},Rs=(nt,tt)=>t.jsxs("div",{className:"ml-4 border-l pl-4","data-testid":`section-device-company-${nt.id}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(xi,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:nt.name}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",tt.length,")"]})]}),t.jsx("div",{className:"space-y-2",children:tt.map(Zt)})]},nt.id);if(!We&&!(Qs&&It))return t.jsx("div",{className:"space-y-3",children:qt.map(Zt)});if(!Qs||!It){const nt=U.map($t=>({id:$t.id,name:$t.name,devices:qt.filter(kr=>_e.get(kr.serialNumber)?.companyId===$t.id)})).filter($t=>$t.devices.length>0).sort(($t,kr)=>zi($t.name,kr.name)),tt=qt.filter($t=>!_e.has($t.serialNumber));return t.jsxs("div",{className:"flex flex-col gap-6",children:[nt.map($t=>t.jsxs("div",{"data-testid":`section-device-company-${$t.id}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(xi,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:$t.name}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",$t.devices.length,")"]})]}),t.jsx("div",{className:"space-y-2",children:$t.devices.map(Zt)})]},$t.id)),tt.length>0&&t.jsxs("div",{"data-testid":"section-device-unassigned",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(Fa,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Unassigned"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",tt.length,")"]})]}),t.jsx("div",{className:"space-y-2",children:tt.map(Zt)})]})]})}const ir=new Map;for(const nt of U){const tt=nt.resellerId||"__none__";ir.has(tt)||ir.set(tt,[]),ir.get(tt).push(nt)}const Vn=Ri.map(nt=>{const tt=(ir.get(nt.userId)||[]).sort((kr,Wn)=>zi(kr.name,Wn.name)),$t=qt.filter(kr=>tt.some(Wn=>Wn.id===_e.get(kr.serialNumber)?.companyId));return{reseller:nt,companies:tt,devices:$t}}).filter(nt=>nt.devices.length>0).sort((nt,tt)=>zi(nt.reseller.businessName,tt.reseller.businessName)),Ns=new Set(Vn.flatMap(nt=>nt.devices.map(tt=>tt.id))),or=qt.filter(nt=>!Ns.has(nt.id)),os=(ir.get("__none__")||[]).sort((nt,tt)=>zi(nt.name,tt.name));return t.jsxs("div",{className:"flex flex-col gap-6",children:[Vn.map(nt=>t.jsxs("div",{"data-testid":`section-device-reseller-${nt.reseller.userId}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx(oh,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:Vp(nt.reseller.businessName)}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",nt.devices.length," device",nt.devices.length!==1?"s":"",")"]})]}),We?t.jsxs("div",{className:"flex flex-col gap-4",children:[nt.companies.filter(tt=>nt.devices.some($t=>_e.get($t.serialNumber)?.companyId===tt.id)).map(tt=>{const $t=nt.devices.filter(kr=>_e.get(kr.serialNumber)?.companyId===tt.id);return Rs(tt,$t)}),(()=>{const tt=nt.devices.filter($t=>!_e.has($t.serialNumber));return tt.length>0?Rs({id:`__unassigned_${nt.reseller.userId}`,name:"Unassigned"},tt):null})()]}):t.jsx("div",{className:"space-y-2",children:nt.devices.map(Zt)})]},nt.reseller.userId)),or.length>0&&t.jsxs("div",{"data-testid":"section-device-no-reseller",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx(Fa,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"No Linked Customer"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",or.length," device",or.length!==1?"s":"",")"]})]}),We&&os.length>0?t.jsxs("div",{className:"flex flex-col gap-4",children:[os.filter(nt=>or.some(tt=>_e.get(tt.serialNumber)?.companyId===nt.id)).map(nt=>{const tt=or.filter($t=>_e.get($t.serialNumber)?.companyId===nt.id);return Rs(nt,tt)}),(()=>{const nt=or.filter(tt=>!_e.has(tt.serialNumber));return nt.length>0?Rs({id:"__unassigned_noreseller",name:"Unassigned"},nt):null})()]}):t.jsx("div",{className:"space-y-2",children:or.map(Zt)})]})]})})()]}),t.jsxs(ea,{value:"policies",children:[t.jsxs("div",{className:"mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Security Policies"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage security settings for users under your account"}),t.jsx("p",{className:"text-xs text-orange-500 dark:text-orange-400 mt-1",children:"Note: Some policy changes may require users to sign out and back in to take effect."})]}),Qs?t.jsxs("div",{className:"space-y-4",children:[t.jsx(ut,{children:t.jsxs(mt,{className:"py-6",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[t.jsx(vi,{className:"w-5 h-5 text-primary"}),t.jsx("p",{className:"font-medium",children:"DB Admin 2FA"})]}),t.jsx("p",{className:"text-sm text-muted-foreground ml-8",children:"Your 2FA is always enforced as a DB Admin."})]})}),t.jsx(ut,{children:t.jsx(mt,{className:"py-6",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[t.jsx(ql,{className:"w-5 h-5 text-primary"}),t.jsx("p",{className:"font-medium",children:"DB Admin Location Policy"})]}),t.jsx("p",{className:"text-sm text-muted-foreground ml-8",children:"Controls dashboard location visibility for DB Admin users."})]}),t.jsxs(L,{variant:yn?.locationPrivacy===!1?"default":"outline",className:yn?.locationPrivacy===!1?"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate":"",onClick:()=>{tn.mutate({resellerId:"superadmin",locationPrivacy:yn?.locationPrivacy===!1})},disabled:tn.isPending,"data-testid":"button-superadmin-location-toggle",children:[tn.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):yn?.locationPrivacy===!1?t.jsx(Yp,{className:"w-4 h-4 mr-2"}):t.jsx(Xr,{className:"w-4 h-4 mr-2"}),yn?.locationPrivacy===!1?"Visible":"Hidden"]})]})})}),t.jsx(ut,{children:t.jsx(mt,{className:"py-6",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[t.jsx(xu,{className:"w-5 h-5 text-primary"}),t.jsx("p",{className:"font-medium",children:"Display DB Admin Audits"})]}),t.jsx("p",{className:"text-sm text-muted-foreground ml-8",children:"Include DB Admin (superadmin) activity in the Audit Reporting section."})]}),t.jsxs(L,{variant:yn?.displayDbAdminAudits?"default":"outline",className:yn?.displayDbAdminAudits?"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate":"",onClick:()=>{tn.mutate({resellerId:"superadmin",displayDbAdminAudits:!yn?.displayDbAdminAudits})},disabled:tn.isPending,"data-testid":"button-superadmin-db-audits-toggle",children:[tn.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Xr,{className:"w-4 h-4 mr-2"}),yn?.displayDbAdminAudits?"Displayed":"Hidden"]})]})})}),t.jsx(ut,{className:"mt-4","data-testid":"card-global-live-monitoring-policy",children:t.jsxs(mt,{className:"py-4 space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Global Live Monitoring"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Master switch for live monitoring across all superadmin accounts."})]}),t.jsx(L,{variant:yn?.liveMonitoringEnabled!==!1?"default":"outline",className:yn?.liveMonitoringEnabled!==!1?"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate":"",onClick:()=>tn.mutate({resellerId:"superadmin",liveMonitoringEnabled:yn?.liveMonitoringEnabled===!1}),disabled:tn.isPending,"data-testid":"button-global-live-monitoring-toggle",children:yn?.liveMonitoringEnabled!==!1?"Enabled":"Disabled"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap border-t pt-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Monitor superadmin activity"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls whether superadmin sessions appear in global live monitoring."})]}),t.jsx(L,{variant:yn?.liveMonitorSuperadmins?"default":"outline",className:yn?.liveMonitorSuperadmins?"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate":"",onClick:()=>tn.mutate({resellerId:"superadmin",liveMonitorSuperadmins:!yn?.liveMonitorSuperadmins}),disabled:tn.isPending,"data-testid":"button-global-monitor-superadmins-toggle",children:yn?.liveMonitorSuperadmins?"Included":"Excluded"})]}),t.jsxs("div",{className:"border-t pt-3",children:[t.jsx("p",{className:"font-medium mb-2",children:"Activity categories"}),t.jsx("div",{className:"flex gap-2 flex-wrap",children:[{field:"liveMonitorLiveView",label:"Live view",enabled:yn?.liveMonitorLiveView??!0},{field:"liveMonitorPlayback",label:"Playback",enabled:yn?.liveMonitorPlayback??!0},{field:"liveMonitorDeviceChanges",label:"Device changes",enabled:yn?.liveMonitorDeviceChanges??!0},{field:"liveMonitorAiTerms",label:"AI terms",enabled:yn?.liveMonitorAiTerms??!0},{field:"liveMonitorOther",label:"Other activity",enabled:yn?.liveMonitorOther??!0}].map(U=>t.jsxs(L,{size:"sm",variant:U.enabled?"default":"outline",className:U.enabled?"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate":"",onClick:()=>tn.mutate({resellerId:"superadmin",[U.field]:!U.enabled}),disabled:tn.isPending,"data-testid":`button-global-${U.field}`,children:[U.label,": ",U.enabled?"On":"Off"]},U.field))})]})]})}),t.jsx("h3",{className:"text-base font-semibold mt-6",children:"Customer Policies"}),t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Enable or disable 2FA enforcement, location visibility, auditing, and live monitoring for each customer account"}),Ri.length===0?t.jsx(ut,{children:t.jsxs(mt,{className:"py-8 text-center",children:[t.jsx(oh,{className:"w-10 h-10 mx-auto text-muted-foreground mb-3"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:"No customer accounts configured yet"})]})}):t.jsx("div",{className:"grid gap-3",children:Ri.map(U=>{const _e=(ll||[]).find(Ns=>Ns.resellerId===U.userId),qt=_e?.enforce2fa||!1,Zt=_e?.locationPrivacy||!1,Rs=_e?.disableAuditing||!1,ir=_e?.liveMonitoringEnabled??!Rs,Vn=[{field:"liveMonitorAdmins",label:"Admin activity",enabled:_e?.liveMonitorAdmins??!0},{field:"liveMonitorLiveView",label:"Live view",enabled:_e?.liveMonitorLiveView??!0},{field:"liveMonitorPlayback",label:"Playback",enabled:_e?.liveMonitorPlayback??!0},{field:"liveMonitorDeviceChanges",label:"Device changes",enabled:_e?.liveMonitorDeviceChanges??!0},{field:"liveMonitorAiTerms",label:"AI terms",enabled:_e?.liveMonitorAiTerms??!0},{field:"liveMonitorOther",label:"Other activity",enabled:_e?.liveMonitorOther??!0}];return t.jsx(ut,{"data-testid":`card-reseller-policy-${U.userId}`,children:t.jsxs(mt,{className:"py-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(cy,{className:"w-9 h-9",children:[t.jsx(dy,{src:U.user?.profileImageUrl||void 0}),t.jsx(uy,{className:"bg-primary text-primary-foreground text-xs",children:RP(U.user?.firstName,U.user?.lastName)})]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium text-sm","data-testid":`text-reseller-policy-name-${U.userId}`,children:Vp(U.businessName)}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[U.user?.firstName||""," ",U.user?.lastName||"",U.email&&` - ${U.email}`]})]})]}),t.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:(()=>{const Ns=tn.isPending&&tn.variables?.resellerId===U.userId;return t.jsxs(t.Fragment,{children:[t.jsxs(L,{size:"sm",variant:qt?"default":"outline",onClick:()=>tn.mutate({resellerId:U.userId,enforce2fa:!qt}),disabled:Ns,"data-testid":`button-policy-2fa-${U.userId}`,children:[Ns?t.jsx(Fe,{className:"w-3 h-3 mr-1 animate-spin"}):qt?t.jsx(vi,{className:"w-3 h-3 mr-1"}):t.jsx(uc,{className:"w-3 h-3 mr-1"}
489),qt?"2FA Enforced":"2FA Not Enforced"]}),t.jsxs(L,{size:"sm",variant:Zt?"outline":"default",className:Zt?"":"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate",onClick:()=>tn.mutate({resellerId:U.userId,locationPrivacy:!Zt}),disabled:Ns,"data-testid":`button-location-policy-${U.userId}`,children:[Ns?t.jsx(Fe,{className:"w-3 h-3 mr-1 animate-spin"}):Zt?t.jsx(Xr,{className:"w-3 h-3 mr-1"}):t.jsx(Yp,{className:"w-3 h-3 mr-1"}),Zt?"Location Hidden":"Location Visible"]}),t.jsxs(L,{size:"sm",variant:Rs?"outline":"default",className:Rs?"":"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate",onClick:()=>tn.mutate({resellerId:U.userId,disableAuditing:!Rs}),disabled:Ns,"data-testid":`button-auditing-policy-${U.userId}`,children:[Ns?t.jsx(Fe,{className:"w-3 h-3 mr-1 animate-spin"}):Rs?t.jsx(Gp,{className:"w-3 h-3 mr-1"}):t.jsx(Xr,{className:"w-3 h-3 mr-1"}),Rs?"Auditing Off":"Auditing On"]})]})})()})]}),t.jsxs("div",{className:"mt-4 border-t pt-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap mb-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-sm",children:"Live Monitoring"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Customer master switch and monitored activity types."})]}),t.jsx(L,{size:"sm",variant:ir?"default":"outline",className:ir?"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate":"",onClick:()=>tn.mutate({resellerId:U.userId,liveMonitoringEnabled:!ir}),disabled:Rs||tn.isPending&&tn.variables?.resellerId===U.userId,"data-testid":`button-live-monitoring-master-${U.userId}`,children:ir?"Monitoring On":"Monitoring Off"})]}),Rs&&t.jsx("p",{className:"text-xs text-muted-foreground mb-3","data-testid":`text-live-monitoring-auditing-off-${U.userId}`,children:"Live monitoring controls are disabled while audit tracking is off. Turn auditing back on to change these settings."}),t.jsx("div",{className:"flex gap-2 flex-wrap",children:Vn.map(Ns=>t.jsxs(L,{size:"sm",variant:Ns.enabled?"default":"outline",className:Ns.enabled?"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate":"",onClick:()=>tn.mutate({resellerId:U.userId,[Ns.field]:!Ns.enabled}),disabled:Rs||tn.isPending&&tn.variables?.resellerId===U.userId,"data-testid":`button-${Ns.field}-${U.userId}`,children:[Ns.label,": ",Ns.enabled?"On":"Off"]},Ns.field))})]})]})},U.userId)})})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(vi,{className:"w-5 h-5"}),"Two-Factor Authentication Policy"]}),t.jsx(Xs,{children:"When enabled, all users assigned to your companies will be required to have 2FA enabled and will not be able to disable it."})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Enforce 2FA for all users"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Users under your account will not be able to disable two-factor authentication"})]}),t.jsxs(L,{variant:zn?.enforce2fa?"default":"outline",onClick:()=>{s?.id&&tn.mutate({resellerId:s.id,enforce2fa:!zn?.enforce2fa})},disabled:tn.isPending,className:"toggle-elevate","data-testid":"button-toggle-enforce-2fa",children:[tn.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):zn?.enforce2fa?t.jsx(vi,{className:"w-4 h-4 mr-2"}):t.jsx(uc,{className:"w-4 h-4 mr-2"}),zn?.enforce2fa?"Enforced":"Not Enforced"]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(ql,{className:"w-5 h-5"}),"Location Privacy"]}),t.jsx(Xs,{children:"When enabled, IP addresses and location details of edge devices will be hidden from owners and users viewing your sites."})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Show device location for all users"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls whether device location is visible on the dashboard for owners and users under your customer account"})]}),t.jsxs(L,{variant:zn?.locationPrivacy?"outline":"default",className:zn?.locationPrivacy?"":"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate",onClick:()=>{s?.id&&tn.mutate({resellerId:s.id,locationPrivacy:!zn?.locationPrivacy})},disabled:tn.isPending,"data-testid":"button-toggle-location-privacy",children:[tn.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):zn?.locationPrivacy?t.jsx(Xr,{className:"w-4 h-4 mr-2"}):t.jsx(Yp,{className:"w-4 h-4 mr-2"}),zn?.locationPrivacy?"Hidden":"Visible"]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(xu,{className:"w-5 h-5"}),"Display Admin Audits"]}),t.jsx(Xs,{children:"When enabled, your own admin-level activity is included in the Audit Reporting section."})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Show my admin activity in audits"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls whether your admin actions appear in your audit reports"})]}
489),t.jsxs(L,{variant:zn?.displayAdminAudits?"default":"outline",className:zn?.displayAdminAudits?"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate":"",onClick:()=>{s?.id&&tn.mutate({resellerId:s.id,displayAdminAudits:!zn?.displayAdminAudits})},disabled:tn.isPending,"data-testid":"button-toggle-display-admin-audits",children:[tn.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Xr,{className:"w-4 h-4 mr-2"}),zn?.displayAdminAudits?"Displayed":"Hidden"]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(xu,{className:"w-5 h-5"}),"Auditing"]}),t.jsx(Xs,{children:"When turned off, no audit activity is tracked for your account and the Audit Reporting page is hidden for you and your users."})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Track audit activity"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Turn off to stop recording audits and hide the Audit Reporting page and its icon"})]}),t.jsxs(L,{variant:zn?.disableAuditing?"outline":"default",className:zn?.disableAuditing?"":"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate",onClick:()=>{s?.id&&tn.mutate({resellerId:s.id,disableAuditing:!zn?.disableAuditing})},disabled:tn.isPending,"data-testid":"button-toggle-disable-auditing",children:[tn.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):zn?.disableAuditing?t.jsx(Gp,{className:"w-4 h-4 mr-2"}):t.jsx(Xr,{className:"w-4 h-4 mr-2"}),zn?.disableAuditing?"Off":"On"]})]})})]}),t.jsxs(ut,{"data-testid":"card-customer-live-monitoring-policy",children:[t.jsxs(xs,{children:[t.jsx(ys,{children:"Live Monitoring"}),t.jsx(Xs,{children:"Control live monitoring for your customer account and choose which activity types can be monitored. Turning auditing off also turns this master switch off."})]}),t.jsx(mt,{className:"space-y-4",children:(()=>{const U=zn?.liveMonitoringEnabled??!zn?.disableAuditing,_e=!!zn?.disableAuditing,qt=[{field:"liveMonitorAdmins",label:"Admin activity",enabled:zn?.liveMonitorAdmins??!0},{field:"liveMonitorLiveView",label:"Live view",enabled:zn?.liveMonitorLiveView??!0},{field:"liveMonitorPlayback",label:"Playback",enabled:zn?.liveMonitorPlayback??!0},{field:"liveMonitorDeviceChanges",label:"Device changes",enabled:zn?.liveMonitorDeviceChanges??!0},{field:"liveMonitorAiTerms",label:"AI terms",enabled:zn?.liveMonitorAiTerms??!0},{field:"liveMonitorOther",label:"Other activity",enabled:zn?.liveMonitorOther??!0}];return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Customer monitoring master switch"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Default is on while audit tracking is enabled."})]}),t.jsx(L,{variant:U?"default":"outline",onClick:()=>s?.id&&tn.mutate({resellerId:s.id,liveMonitoringEnabled:!U}),disabled:_e||tn.isPending,"data-testid":"button-customer-live-monitoring-master",children:U?"Enabled":"Disabled"})]}),_e&&t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-customer-live-monitoring-auditing-off",children:"Live monitoring controls are disabled while audit tracking is off. Turn auditing back on to change these settings."}),t.jsx("div",{className:"flex gap-2 flex-wrap",children:qt.map(Zt=>t.jsxs(L,{size:"sm",variant:Zt.enabled?"default":"outline",className:Zt.enabled?"bg-blue-600 hover:bg-blue-700 text-white border-blue-600 no-default-hover-elevate":"",onClick:()=>s?.id&&tn.mutate({resellerId:s.id,[Zt.field]:!Zt.enabled}),disabled:_e||tn.isPending,"data-testid":`button-customer-${Zt.field}`,children:[Zt.label,": ",Zt.enabled?"On":"Off"]},Zt.field))})]})})()})]})]})]}),Qs&&t.jsxs(ea,{value:"email-templates",children:[t.jsxs("div",{className:"mb-4",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Email Templates"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Customize the email templates used for verification codes and notifications"})]}
489),t.jsxs(ut,{className:"mb-6","data-testid":"card-outbound-settings",children:[t.jsx(xs,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsx(ys,{className:"text-base",children:"Outbound Email Settings"}),t.jsx(Xs,{className:"mt-1",children:"Configure the sender name and email address used for all outgoing emails"})]}),!Qn&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{Pi({senderName:il?.senderName||a.brandName,senderEmail:il?.senderEmail||a.noreplyEmail}),ii(!0)},"data-testid":"button-edit-outbound",children:t.jsx(ga,{className:"w-4 h-4"})})]})}),t.jsx(mt,{children:Qn?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Sender Name"}),t.jsx(ke,{value:Br.senderName,onChange:U=>Pi(_e=>({..._e,senderName:U.target.value})),placeholder:`e.g. ${a.brandName}`,"data-testid":"input-outbound-sender-name"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Sender Email"}),t.jsx(ke,{value:Br.senderEmail,onChange:U=>Pi(_e=>({..._e,senderEmail:U.target.value})),placeholder:`e.g. ${a.noreplyEmail}`,"data-testid":"input-outbound-sender-email"})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(L,{onClick:()=>mo.mutate(Br),disabled:mo.isPending||!Br.senderName||!Br.senderEmail,"data-testid":"button-save-outbound",children:[mo.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-2"}),"Save Settings"]}),t.jsx(L,{variant:"outline",onClick:()=>ii(!1),"data-testid":"button-cancel-outbound",children:"Cancel"})]})]}):t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Sender Name"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-outbound-sender-name",children:il?.senderName||a.brandName})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Sender Email"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-outbound-sender-email",children:il?.senderEmail||a.noreplyEmail})]})]})})]}),t.jsxs(ut,{className:"mb-6","data-testid":"card-support-ticket-outbound",children:[t.jsx(xs,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsx(ys,{className:"text-base",children:"Support Ticket Email Settings"}),t.jsx(Xs,{className:"mt-1",children:"Sender display name and staff inbox for all support ticket emails. Emails are sent from the verified address configured in Outbound Email Settings above."})]}),!Ln&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{Ua({senderName:Jl?.senderName||`${a.brandName} Support`,senderEmail:Jl?.senderEmail||a.supportEmail,staffEmail:Jl?.staffEmail||a.supportEmail}),Ir(!0)},"data-testid":"button-edit-support-ticket-outbound",children:t.jsx(ga,{className:"w-4 h-4"})})]})}),t.jsx(mt,{children:Ln?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Sender Display Name"}),t.jsx(ke,{value:ua.senderName,onChange:U=>Ua(_e=>({..._e,senderName:U.target.value})),placeholder:`e.g. ${a.brandName} Support`,"data-testid":"input-support-ticket-sender-name"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Staff Notification Email"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"New ticket alerts are sent here. Submitters' confirmation emails include this as the reply-to address."}),t.jsx(ke,{value:ua.staffEmail,onChange:U=>Ua(_e=>({..._e,staffEmail:U.target.value})),placeholder:`e.g. ${a.supportEmail}`,"data-testid":"input-support-ticket-staff-email"})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(L,{onClick:()=>qn.mutate(ua),disabled:qn.isPending||!ua.senderName||!ua.staffEmail,"data-testid":"button-save-support-ticket-outbound",children:[qn.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-2"}),"Save Settings"]}),t.jsx(L,{variant:"outline",onClick:()=>Ir(!1),"data-testid":"button-cancel-support-ticket-outbound",children:"Cancel"})]})]}):t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Sender Display Name"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-support-ticket-sender-name",children:Jl?.senderName||`${a.brandName} Support`})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Staff Notification 
489Email"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-support-ticket-staff-email",children:Jl?.staffEmail||a.supportEmail})]})]})})]}),t.jsxs(ut,{className:"mb-6","data-testid":"card-smart-alerts-outbound",children:[t.jsx(xs,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsx(ys,{className:"text-base",children:"Smart Alerts Email Settings"}),t.jsx(Xs,{className:"mt-1",children:"Sender display name and address used for Smart Alert notification emails. Leave defaults for the global outbound sender."})]}),!Rt&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{lt({senderName:Uo?.senderName||`${a.brandName} Alerts`,senderEmail:Uo?.senderEmail||a.alertsEmail}),At(!0)},"data-testid":"button-edit-smart-alerts-outbound",children:t.jsx(ga,{className:"w-4 h-4"})})]})}),t.jsx(mt,{children:Rt?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Sender Display Name"}),t.jsx(ke,{value:Hr.senderName,onChange:U=>lt(_e=>({..._e,senderName:U.target.value})),placeholder:`e.g. ${a.brandName} Alerts`,"data-testid":"input-smart-alerts-sender-name"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Sender Email"}),t.jsx(ke,{value:Hr.senderEmail,onChange:U=>lt(_e=>({..._e,senderEmail:U.target.value})),placeholder:`e.g. ${a.alertsEmail}`,"data-testid":"input-smart-alerts-sender-email"})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(L,{onClick:()=>_o.mutate(Hr),disabled:_o.isPending||!Hr.senderName||!Hr.senderEmail,"data-testid":"button-save-smart-alerts-outbound",children:[_o.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-2"}),"Save Settings"]}),t.jsx(L,{variant:"outline",onClick:()=>At(!1),"data-testid":"button-cancel-smart-alerts-outbound",children:"Cancel"})]})]}):t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Sender Display Name"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-smart-alerts-sender-name",children:Uo?.senderName||`${a.brandName} Alerts`})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Sender Email"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-smart-alerts-sender-email",children:Uo?.senderEmail||a.alertsEmail})]})]})})]}),t.jsxs(ut,{className:"mb-6","data-testid":"card-billing-notification-email",children:[t.jsx(xs,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsx(ys,{className:"text-base",children:"Billing Notification Email"}),t.jsx(Xs,{className:"mt-1",children:"Email address that receives subscription activation, cancellation, and customer registration notifications"})]}),!mn&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{vr(Cc?.email||a.billingEmail),hr(!0)},"data-testid":"button-edit-billing-email",children:t.jsx(ga,{className:"w-4 h-4"})})]})}),t.jsx(mt,{children:mn?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Notification Email"}),t.jsx(ke,{value:Ht,onChange:U=>vr(U.target.value),placeholder:`e.g. ${a.billingEmail}`,"data-testid":"input-billing-notification-email"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"This address will receive emails whenever a subscription is activated or canceled."})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(L,{onClick:()=>tm.mutate(Ht),disabled:tm.isPending||!Ht,"data-testid":"button-save-billing-email",children:[tm.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-2"}),"Save"]}),t.jsx(L,{variant:"outline",onClick:()=>hr(!1),"data-testid":"button-cancel-billing-email",children:"Cancel"})]})]}):t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Notification 
489Email"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-billing-notification-email",children:Cc?.email||a.billingEmail})]})})]}),t.jsxs(ut,{className:"mb-6","data-testid":"card-contact-notification-email",children:[t.jsx(xs,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsx(ys,{className:"text-base",children:"Contact Notification Email"}),t.jsx(Xs,{className:"mt-1",children:"Email address that receives contact form submissions from the website"})]}),!Os&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{Sr(Ti?.email||a.infoEmail),ur(!0)},"data-testid":"button-edit-contact-email",children:t.jsx(ga,{className:"w-4 h-4"})})]})}),t.jsx(mt,{children:Os?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Notification Email"}),t.jsx(ke,{value:Sn,onChange:U=>Sr(U.target.value),placeholder:`e.g. ${a.infoEmail}`,"data-testid":"input-contact-notification-email"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"This address will receive emails whenever someone submits the contact form."})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(L,{onClick:()=>Pd.mutate(Sn),disabled:Pd.isPending||!Sn,"data-testid":"button-save-contact-email",children:[Pd.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-2"}),"Save"]}),t.jsx(L,{variant:"outline",onClick:()=>ur(!1),"data-testid":"button-cancel-contact-email",children:"Cancel"})]})]}):t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"Notification Email"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-contact-notification-email",children:Ti?.email||a.infoEmail})]})})]}),fr&&Ut.templateKey?t.jsx(sCe,{initialValues:Ut,isSaving:Hn.isPending,onSave:U=>Hn.mutate(U),onCancel:()=>{xn(!1),gt({templateKey:"",subject:"",headerHtml:"",bodyHtml:"",footerHtml:"",fromName:""})}},Ut.templateKey):Zc?t.jsx("div",{className:"space-y-4",children:t.jsx(Bt,{className:"h-32 w-full"})}):(al||[]).length===0?t.jsx(ut,{children:t.jsxs(mt,{className:"py-12 text-center",children:[t.jsx(qi,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("p",{className:"text-muted-foreground",children:"No email templates configured yet"})]})}):t.jsx("div",{className:"space-y-4",children:(al||[]).map(U=>t.jsx(ut,{"data-testid":`card-template-${U.templateKey}`,children:t.jsx(xs,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsx(ys,{className:"text-base",children:U.templateKey==="mfa_verification"?"MFA Verification Code":U.templateKey==="new_device_login"?"New Device Login Alert":U.templateKey==="device_alert"?"Device Offline Alert":U.templateKey==="device_recovery"?"Device Online Alert":U.templateKey==="device_weekly_summary"?"Device Weekly Summary":U.templateKey==="subscription_activated"?"Subscription Activated":U.templateKey==="subscription_canceled"?"Subscription Canceled":U.templateKey==="reseller_registration_alert"?"Reseller Registration Alert":U.templateKey==="reseller_registration_confirmation"?"Reseller Registration Confirmation":U.templateKey==="reseller_approval_welcome"?"Reseller Approval — Welcome to Applicant":U.templateKey==="reseller_approval_alert"?"Reseller Approval — Internal Alert":U.templateKey==="contact_form_internal"?"Contact Form — Internal Notification":U.templateKey==="contact_form_confirmation"?"Contact Form — Sender Confirmation":U.templateKey==="password_reset"?"Password Reset":U.templateKey==="support_ticket_confirmation"?"Support Ticket — Submitter Confirmation":U.templateKey==="support_ticket_staff_notification"?"Support Ticket — Staff Notification":U.templateKey==="support_ticket_closed"?"Support Ticket — Closure Notice":U.templateKey==="smart_alert_notification"?"Smart Alert Notification":U.templateKey}),t.jsxs(Xs,{className:"mt-1",children:["Subject: ",U.subject]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{br(!0),gt({templateKey:U.templateKey,subject:U.subject,headerHtml:U.headerHtml||"",bodyHtml:U.bodyHtml,footerHtml:U.footerHtml||"",fromName:U.fromName||""})},"data-testid":`button-preview-template-${U.templateKey}`,children:t.jsx(Xr,{className:"w-4 h-4"})}),t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{gt({templateKey:U.templateKey,subject:U.subject,headerHtml:U.headerHtml||"",bodyHtml:U.bodyHtml,footerHtml:U.footerHtml||"",fromName:U.fromName||""}),xn(!0)},"data-testid":`button-edit-template-${U.templateKey}`,children:t.jsx(ga,{className:"w-4 h-4"})})]})]})})},U.id))})]}),Qs&&t.jsxs(ea,{value:"api-settings",children:[t.jsxs("div",{className:"mb-6",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"API Settings"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys and credentials for external services."})]}),(()=>{const _e=ja.find(qt=>qt.settingKey==="direct_lan_enabled")?.settingValue==="1";return t.jsxs(ut,{className:"mb-8","data-testid":"card-direct-lan",children:[t.jsx(xs,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(cg,{className:"w-5 h-5 text-muted-foreground"}),t.jsx(ys,{className:"text-base",children:"Direct LAN Live View"}),t.jsx(Ke,{variant:_e?"default":"secondary",className:"text-xs","data-testid":"badge-direct-lan-status",children:_e?"Enabled":"Disabled"})]}),t.jsx(Xs,{className:"mt-1",children:"When on, viewers on the same local network as an edge device can stream live video directly from it, instead of through the cloud relay. This only enables direct-LAN routing — it does not change how off-network viewers connect; they continue to use the standard proxied path. Off by default."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:_e?"Enabled":"Disabled"}),t.jsx(sr,{checked:_e,onCheckedChange:qt=>_u.mutate(qt),disabled:_u.isPending,"data-testid":"switch-direct-lan"})]})]})}),t.jsx(mt,{className:"pt-0",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap rounded-md border p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium",children:"Wildcard TLS certificate"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"After saving the certificate below (and after every renewal), push it to all edge devices so they can serve HTTPS on the local network. Devices apply it on their next poll."})]}),t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>{confirm("Push the saved wildcard TLS certificate to every edge device that has edge sync configured?")&&Ec.mutate()},disabled:Ec.isPending,"data-testid":"button-push-tls-all",children:[Ec.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Push TLS to all devices"]})]})})]})})(),(()=>{const U=[{groupLabel:"Email & Geolocation",groupDescription:"Choose one outbound email provider, configure its credentials, and manage device geolocation.",groupIcon:qi,services:[{key:"sendgrid_api_key",label:"SendGrid API Key",description:"Used only when SendGrid is the selected outbound email provider. Get your key from sendgrid.com."},{key:"postmark_server_token",label:"Postmark Server Token",description:"Used only when Postmark is the selected outbound email provider. Find it under API Tokens in your Postmark server."},{key:"postmark_message_stream",label:"Postmark Message Stream",description:"Transactional message stream used for outbound email. Defaults to outbound when this value is not configured.",inputType:"text",inputLabel:"Message Stream",inputPlaceholder:"outbound",displayLabel:"Message Stream"},{key:"abstractapi_api_key",label:"IP Geolocation API Key (Abstract API)",description:"Used for device location lookup and edge device geolocation. Get your key from abstractapi.com."}]},{groupLabel:"Google Cloud Storage",groupDescription:"Buckets are auto-created per edge device (truvios-{serial}). Storage class is set based on retention period.",groupIcon:pn,services:[{key:"gcs_service_account_key",label:"Service Account Key (JSON)",description:"Service account JSON key with Storage Admin role (needed to create/manage per-device buckets). Download from console.cloud.google.com/iam-admin/serviceaccounts.",inputType:"textarea",inputLabel:"JSON Key",inputPlaceholder:"Paste your service account JSON key here",displayLabel:"Credentials"},{key:"gcs_backup_service_account_key",label:"Backup-Only Service Account Key (JSON)",description:"Optional least-privilege JSON key used exclusively for writing system backups to the backup bucket below. Recommended IAM: roles/storage.objectCreator scoped to that bucket only. If unset or disabled, backups fall back to the primary Service Account Key above.",inputType:"textarea",inputLabel:"JSON Key",inputPlaceholder:"Paste your backup-only service account JSON key here",displayLabel:"Credentials"},{key:"gcs_backup_bucket",label:"Backup Bucket Name",description:"Globally-unique GCS bucket this instance writes system backups to. Each deployment must use its own bucket (GCS bucket names are unique across all of Google Cloud). If unset or disabled, defaults to truvios-backups.",inputType:"text",inputLabel:"Bucket Name",inputPlaceholder:"e.g. livelion-backups",displayLabel:"Bucket"}]},{groupLabel:"Google Maps",groupDescription:"Map View uses a browser key, address geocoding uses a server key, and address suggestions use a Places key. Enable billing and the corresponding APIs in Google Cloud. When no Places key is saved, suggestions use the Maps server key; disabling a saved Places key turns suggestions off.",groupIcon:ql,services:[{key:"google_maps_browser_key",label:"Google Maps Browser Key",description:"Shown to signed-in browsers to load Map View and Street View. Restrict this key to your app's website domains and Maps JavaScript API in Google Cloud."},{key:"google_maps_server_key",label:"Google Maps Server Key",description:"Used only by the server to locate site addresses. Enable Geocoding API and restrict this key to that API. Never use your browser key here."},{key:"google_places_api_key",label:"Google Places API Key",description:"Used only by the server for site address suggestions. Enable billing and Places API (New) in Google Cloud; restrict this key to Places API (New). If unset, suggestions use the Google Maps Server Key. Disabling this saved key turns suggestions off."}]},{groupLabel:"AI+ Features (OpenAI)",groupDescription:"Powers Visual Search (AI+ gated). Requires an OpenAI API key with GPT-4o access.",groupIcon:Do,services:[{key:"openai_api_key",label:"OpenAI API Key",description:"API key for OpenAI GPT-4o Vision. Get your key from platform.openai.com/api-keys."}]},{groupLabel:"Shipping (UPS)",groupDescription:"Used by the Edge Quote shipping rate lookup. Empty rows fall back to the corresponding environment secret. Get credentials from developer.ups.com.",groupIcon:cO,services:[{key:"ups_client_id",label:"UPS Client ID",description:"OAuth client ID from your UPS Developer Portal app."},{key:"ups_client_secret",label:"UPS Client Secret",description:"OAuth client secret from your UPS Developer Portal app."},{key:"ups_origin_postal_code",label:"Origin Postal Code",description:"ZIP / postal code shipments originate from. Defaults to 30301 (Atlanta) if unset.",inputType:"text"}]},{groupLabel:"SMS Notifications (Twilio)",groupDescription:"Credentials for sending SMS smart alerts and MFA codes. Use Account SID + Auth Token from console.twilio.com. All three fields must be saved here to enable SMS options across the app.",groupIcon:qx,services:[{key:"twilio_account_sid",label:"Account SID",description:"Your Twilio Account SID — starts with 'AC'. Found on the main dashboard at console.twilio.com.",inputType:"text"},{key:"twilio_auth_token",label:"Auth Token",description:"Your Twilio Auth Token — found next to the Account SID on the console dashboard."},{key:"twilio_from_number",label:"From Phone Number",description:"Your Twilio phone number in E164 format (e.g. +18554001234). Found under Phone Numbers → Manage in the Twilio console.",inputType:"text"}]},{groupLabel:"Face Recognition (InsightFace Sidecar)",groupDescription:"Self-hosted biometric face matching used by AI Text Search. Deploy the FastAPI service in sidecar/face-recognition/ (see its README) to a Reserved VM, then paste the URL and shared API key here. AI Text Search falls back to OpenAI-only when this is empty or unreachable.",groupIcon:Do,services:[{key:"insightface_url",label:"InsightFace URL",description:"HTTPS URL of the deployed face-rec sidecar (e.g. https://truvios-face-rec.<user>.repl.co). No trailing slash needed.",inputType:"text"},{key:"insightface_api_key",label:"InsightFace API Key",description:"Shared bearer token. Must equal FACE_REC_API_KEY on the sidecar. Leave empty only if the sidecar is on a private network in open mode."}]},{groupLabel:"Live Chat (Tawk.to)",groupDescription:"Embeds the Tawk.to live chat widget on all public-facing pages. Paste your Property ID from the Tawk.to embed snippet (Administration → Chat Widget). Toggle off to disable the widget without remov
489ing the ID.",groupIcon:qx,services:[{key:"tawk_property_id",label:"Tawk.to Chat URL",description:"Paste the Direct Chat Link from Tawk.to Dashboard → Administration → Chat Widget. It looks like https://embed.tawk.to/chat/XXXXX/YYYYY — any tawk.to URL format works.",inputType:"text"}]},{groupLabel:"Google Tag (Analytics & Ads)",groupDescription:"Injects the Google tag (gtag.js) into every page for Google Analytics 4 and Google Ads conversion tracking. Paste your Measurement ID from Google Analytics (Admin → Data Streams) or your Google Ads tag. Toggle off to disable tracking without removing the ID.",groupIcon:QI,services:[{key:"google_tag_id",label:"Measurement / Tag ID",description:"Paste your Google tag ID, e.g. G-XXXXXXXXXX (Analytics) or AW-XXXXXXXXX (Ads). You can also paste the full gtag.js snippet — the ID is extracted automatically.",inputType:"text"}]},{groupLabel:"Direct LAN TLS Certificate",groupDescription:`Wildcard certificate for *.<LAN domain> (default *.local.truvios.io), issued via Let's Encrypt DNS-01 on your delegated DNS responder host. Paste the PEM contents here, then use "Push TLS to all devices" in the Direct LAN card above. Re-paste and re-push after each renewal (~every 60–90 days).`,groupIcon:cg,services:[{key:"lan_tls_domain",label:"LAN Domain",description:"Base domain the certificate covers and that edge hostnames live under. Defaults to local.truvios.io.",inputType:"text",inputLabel:"Domain",inputPlaceholder:"local.truvios.io",displayLabel:"Domain"},{key:"lan_tls_cert",label:"Certificate (fullchain.pem)",description:"The full certificate chain. Paste the contents of /etc/letsencrypt/live/<domain>/fullchain.pem.",inputType:"textarea",inputLabel:"Certificate PEM",inputPlaceholder:"-----BEGIN CERTIFICATE-----",displayLabel:"Certificate"},{key:"lan_tls_key",label:"Private Key (privkey.pem)",description:"The certificate private key. Paste the contents of /etc/letsencrypt/live/<domain>/privkey.pem. Stored server-side only and never sent back to the browser.",inputType:"textarea",inputLabel:"Private Key PEM",inputPlaceholder:"-----BEGIN PRIVATE KEY-----",displayLabel:"Private Key"},{key:"lan_tls_ca",label:"CA Chain (optional)",description:"Optional separate CA/issuer chain. Usually not needed — fullchain.pem already includes the intermediates.",inputType:"textarea",inputLabel:"CA PEM",inputPlaceholder:"-----BEGIN CERTIFICATE-----",displayLabel:"CA Chain"}]}];return t.jsx("div",{className:"space-y-8",children:U.map(_e=>{const qt=_e.groupIcon,Zt=ja.find(Ls=>Ls.settingKey==="gcs_service_account_key"),Rs=_e.groupLabel==="Google Cloud Storage",ir=Rs&&Zt?.enabled,Vn=_e.groupLabel==="Face Recognition (InsightFace Sidecar)",Ns=ja.find(Ls=>Ls.settingKey==="insightface_url"),or=ja.find(Ls=>Ls.settingKey==="insightface_api_key"),os=!!Ns?.enabled&&!!or?.enabled&&!!Ns?.settingValue,nt=_e.groupLabel==="SMS Notifications (Twilio)",tt=oa?.configured??!1,$t=_e.groupLabel==="Live Chat (Tawk.to)",kr=ja.find(Ls=>Ls.settingKey==="tawk_property_id"),Wn=!!kr?.enabled&&!!kr?.settingValue,zr=_e.groupLabel==="Google Tag (Analytics & Ads)",$n=ja.find(Ls=>Ls.settingKey==="google_tag_id"),Va=!!$n?.enabled&&!!$n?.settingValue,Yi=_e.groupLabel==="Email & Geolocation",Ii=ja.find(Ls=>Ls.settingKey==="outbound_email_provider")?.settingValue==="postmark"?"postmark":"sendgrid",To=ja.find(Ls=>Ls.settingKey===(Ii==="postmark"?"postmark_server_token":"sendgrid_api_key")),Qi=Ii==="sendgrid"?!!To?.enabled||!To:!!To?.enabled;return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap mb-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qt,{className:"w-5 h-5 text-muted-foreground"}),t.jsx("h3",{className:"text-base font-semibold","data-testid":`heading-api-group-${_e.groupLabel.toLowerCase().replace(/\s+/g,"-")}`,children:_e.groupLabel}),Rs&&ir&&t.jsx(Ke,{variant:"default",className:"text-xs",children:"Active"}),Vn&&t.jsx(Ke,{variant:os?"default":"secondary",className:"text-xs","data-testid":"badge-facerec-status",children:os?"Active":"Inactive"}),nt&&t.jsx(Ke,{variant:tt?"default":"secondary",className:"text-xs","data-testid":"badge-twilio-status",children:tt?"Active":"Inactive"}),$t&&t.jsx(Ke,{variant:Wn?"default":"secondary",className:"text-xs","data-testid":"badge-tawk-status",children:Wn?"Active":"Inactive"}),zr&&t.jsx(Ke,{variant:Va?"default":"secondary",className:"text-xs","data-testid":"badge-google-tag-status",children:Va?"Active":"Inactive"}),Yi&&t.jsx(Ke,{variant:Qi?"default":"secondary",className:"text-xs","data-testid":"badge-email-provider-status",children:Ii==="postmark"?"Postmark":"SendGrid"}),Vn&&Jr&&t.jsx(Ke,{variant:Jr.ok?"default":"destructive",className:"text-xs","data-testid":"badge-facerec-ping",children:Jr.ok?`Reachable${Jr.model?` · ${Jr.model}`:""}`:`Unreachable: ${Jr.message}`})]}),Vn&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Oa&&t.jsxs(Ke,{variant:Oa.failed>0?"destructive":"default",className:"text-xs","data-testid":"badge-facerec-reembed-result",children:["Re-embedded ",Oa.embedded,"/",Oa.total,Oa.rejected>0?` · ${Oa.rejected} rejected`:"",Oa.failed>0?` · ${Oa.failed} failed`:""]}),t.jsx(L,{size:"sm",variant:"outline",disabled:Mn||!os,onClick:async()=>{Dr(!0),vn(null);try{const Or=await(await Ze("GET","/api/admin/face-rec/ping")).json();vn({ok:!!Or.ok,message:Or.message||(Or.ok?"OK":"Failed"),model:Or.model})}catch(Ls){vn({ok:!1,message:Ls?.message||"Request failed"})}finally{Dr(!1)}},"data-testid":"button-test-facerec",children:Mn?"Testing…":"Test Connection"}),t.jsx(L,{size:"sm",variant:"outline",disabled:en||!os,onClick:async()=>
489{if(confirm("Re-embed every reference photo on all devices you administer? This downloads each photo, calls the face-rec sidecar, and overwrites stored embeddings. May take several minutes.")){Co(!0),ku(null);try{const Or=await(await Ze("POST","/api/admin/face-rec/reembed")).json();ku({total:Or.total??0,embedded:Or.embedded??0,rejected:Or.rejected??0,failed:Or.failed??0}),n({title:"Re-embed complete",description:`${Or.embedded}/${Or.total} embedded${Or.rejected?`, ${Or.rejected} rejected`:""}${Or.failed?`, ${Or.failed} failed`:""}`})}catch(Ls){n({title:"Re-embed failed",description:Ls?.message||"Unknown error",variant:"destructive"})}finally{Co(!1)}}},"data-testid":"button-reembed-facerec",children:en?"Re-embedding…":"Re-embed All Faces"})]}),Rs&&Zt&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:ir?"Enabled":"Disabled"}),t.jsx(sr,{checked:!!ir,onCheckedChange:Ls=>{Zt&&ul.mutate({key:"gcs_service_account_key",enabled:Ls})},disabled:ul.isPending,"data-testid":"switch-gcs-group-toggle"})]})]}),_e.groupDescription&&t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:_e.groupDescription}),t.jsxs("div",{className:"space-y-3",children:[Yi&&t.jsxs(ut,{"data-testid":"card-outbound-email-provider",children:[t.jsxs(xs,{children:[t.jsx(ys,{className:"text-base",children:"Outbound Email Provider"}),t.jsx(Xs,{children:"Exactly one provider handles all future application email. Stored credentials for the inactive provider are retained but never used."})]}),t.jsx(mt,{children:t.jsxs("div",{className:"max-w-sm space-y-2",children:[t.jsx(re,{htmlFor:"select-outbound-email-provider",children:"Provider"}),t.jsxs(Us,{value:Ii,onValueChange:Ls=>Pc.mutate(Ls),disabled:Pc.isPending,children:[t.jsx($s,{id:"select-outbound-email-provider","data-testid":"select-outbound-email-provider",children:t.jsx(zs,{placeholder:"Choose an email provider"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"sendgrid",children:"SendGrid"}),t.jsx(rt,{value:"postmark",children:"Postmark"})]})]}),!Qi&&t.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400","data-testid":"warning-email-provider-not-configured",children:"Save credentials for the selected provider before sending email."})]})})]}),_e.services.map(Ls=>{const Or=ja.find(Di=>Di.settingKey===Ls.key),Pl=!Or&&(Ls.key==="google_maps_browser_key"?zo?.browserWorkspaceSecret:Ls.key==="google_maps_server_key"?zo?.serverWorkspaceSecret:!1),Oi=So===Ls.key,ad="inputType"in Ls&&Ls.inputType==="textarea",ji="inputType"in Ls&&Ls.inputType==="text",Wa="inputLabel"in Ls?Ls.inputLabel:"API Key",Ic="inputPlaceholder"in Ls?Ls.inputPlaceholder:"Enter API key",Tu="displayLabel"in Ls?Ls.displayLabel:"Key",id=Ls.key==="gcs_service_account_key"||Ls.key==="gcs_backup_service_account_key"||Ls.key==="postmark_server_token"||Ls.key==="google_maps_server_key"||Ls.key==="google_places_api_key",El=Ls.key==="sendgrid_api_key"||Ls.key==="postmark_server_token"||Ls.key==="postmark_message_stream";return t.jsxs(ut,{"data-testid":`card-api-${Ls.key}`,children:[t.jsx(xs,{children:t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsx(ys,{className:"text-base",children:Ls.label}),t.jsx(Xs,{className:"mt-1",children:Ls.description})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[Or&&!Oi&&!Ls.key.startsWith("lan_tls_")&&!El&&t.jsx(sr,{checked:Or.enabled,onCheckedChange:Di=>ul.mutate({key:Ls.key,enabled:Di}),disabled:ul.isPending,"data-testid":`switch-api-${Ls.key}`}),Or&&!Oi&&t.jsx(Ke,{variant:"outline",className:"text-xs",children:"Configured"}),Or&&!Oi&&!Ls.key.startsWith("lan_tls_")&&!El&&t.jsx(Ke,{variant:Or.enabled?"default":"secondary",className:"text-xs",children:Or.enabled?"Enabled":"Disabled"}),!Or&&!Oi&&t.jsx(Ke,{variant:Pl?"default":"secondary",className:"text-xs",children:Pl?"Workspace secret active":"Not Configured"}),!Oi&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>{Xn(Ls.key),qr({key:Ls.key,value:"",label:Ls.label,description:Ls.description})},"data-testid":`button-edit-api-${Ls.key}`,children:t.jsx(ga,{className:"w-4 h-4"})})]})]})}),Oi?t.jsx(mt,{children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:Wa}),ad?t.jsx(Nn,{value:nr.value,onChange:Di=>qr(Xi=>({...Xi,value:Di.target.value})),placeholder:Or?"Paste new key to replace existing":Ic,rows:6,className:"font-mono text-xs","data-testid":`input-api-key-${Ls.key}`}):t.jsx(ke,{type:ji?"text":"password",value:nr.value,onChange:Di=>qr(Xi=>({...Xi,value:Di.target.value})),placeholder:Or?"Enter new value to replace existing":Ic,"data-testid":`input-api-key-${Ls.key}`}),Or&&!id&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: ",Or.settingValue]}),Or&&id&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Current: Credential configured"})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(L,{onClick:()=>wi.mutate(nr),disabled:wi.isPending||!nr.value,"data-testid":`button-save-api-${Ls.key}`,children:[wi.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-2"}),"Save"]}),t.jsx(L,{variant:"outline",onClick:()=>{Xn(null),qr({key:"",value:"",label:"",description:""})},"data-testid":`button-cancel-api-${Ls.key}`,children:"Cancel"}),Or&&t.jsxs(L,{variant:"destructive",onClick:()=>tc.mutate(Ls.key),disabled:tc.isPending,"data-testid":`button-delete-api-${Ls.key}`,children:[tc.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(sa,{className:"w-4 h-4 mr-2"}),"Remove"]})]})]})}):Or?t.jsx(mt,{children:t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:Tu}),t.jsx("p",{className:"text-sm font-mono","data-testid":`text-api-value-${Ls.key}`,children:id?"Credential configured":Or.settingValue})]})}):Pl?t.jsx(mt,{children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"A workspace secret is in use. Enter a key here to manage it from API Settings."})}):null]},Ls.key)}),_e.groupLabel==="Google Maps"&&t.jsxs(ut,{"data-testid":"card-places-check",children:[t.jsxs(xs,{children:[t.jsx(ys,{className:"text-base",children:"Site address suggestions"}),t.jsx(Xs,{children:"Check the effective Places key (or Maps server key fallback) with a sample address. This does not change a key or save a site address. Map View and Geocoding are separate checks."})]}),t.jsxs(mt,{className:"space-y-3",children:[t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>ha.mutate(),disabled:ha.isPending||wi.isPending||tc.isPending||ul.isPending,"data-testid":"button-check-places",children:[ha.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),ha.isPending?"Checking…":"Check Places access"]}),ha.data&&t.jsxs(pu,{variant:ha.data.status==="working"?"default":"destructive","data-testid":"result-check-places",children:[t.jsx(Yu,{children:{working:"Places access works",missing:"No effective Places key",rejected:"Google rejected Places access",unavailable:"Places check unavailable"}[ha.data.status]}),t.jsx(fu,{children:ha.data.message})]}),ha.isError&&t.jsxs(pu,{variant:"destructive","data-testid":"result-check-places",children:[t.jsx(Yu,{children:"Could not run the Places check"}),t.jsx(fu,{children:ha.error instanceof Error?ha.error.message:"Please try again later."})]})]})]})]})]},_e.groupLabel)})})})()]}),t.jsx(ea,{value:"cloud-storage",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold",children:"Cloud Storage"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure cloud recording sync per edge device. Retention ranges from 14 days to 3 years."})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap self-start",children:[Qs&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{id:"cloud-group-by-reseller",checked:It,onCheckedChange:ns,"data-testid":"switch-cloud-group-by-reseller"}),t.jsx("label",{htmlFor:"cloud-group-by-reseller",className:"text-sm text-muted-foreground cursor-pointer select-none whitespace-nowrap",children:"Group by customer"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{id:"cloud-group-by-company",checked:We,onCheckedChange:St,"data-testid":"switch-cloud-group-by-company"}),t.jsx("label",{htmlFor:"cloud-group-by-company",className:"text-sm text-muted-foreground cursor-pointer select-none whitespace-nowrap",children:"Group by company"})]})]})]}),Ur||ol?t.jsx(ut,{children:t.jsxs(mt,{className:"py-12 flex items-center justify-center text-muted-foreground",children:[t.jsx(Fe,{className:"w-5 h-5 animate-spin mr-2"}),"Loading cloud storage settings…"]})}):!na||na.length===0?t.jsx(ut,{children:t.jsx(mt,{className:"py-8 text-center text-muted-foreground",children:"No edge devices found. Register devices first to configure cloud storage."})}):(()=>{const U=Qs?kl:hl,_e=new Map;for(const os of U)for(const nt of os.sites||[])nt.serialNumber&&_e.set(nt.serialNumber,{siteName:nt.name,companyId:os.id,companyName:os.name,companyResellerId:os.resellerId});const qt=os=>
489{const nt=_e.get(os.serialNumber),tt=!!nt,$t=Jc.find(Wa=>Wa.edgeDeviceId===os.id),kr=$t?.syncEnabled??!1,Wn=$t?.syncMode??"events",zr=$t?.syncIntervalMinutes??1,$n=os.salesOrderId?(Xc||[]).find(Wa=>Wa.id===os.salesOrderId):null,Yi=($n&&$n.status==="active"&&typeof $n.cloudRetentionDays=="number"?$n.cloudRetentionDays:null)??$t?.retentionDays??14,Ii=$t?.lastSyncAt,To=$t?.lastEdgeSyncAt||null,Qi=$t?.latestSegmentAt||null,Ls=(()=>{const Wa=To?new Date(To).getTime():0,Ic=Qi?new Date(Qi).getTime():0;return Wa===0&&Ic===0?null:new Date(Math.max(Wa,Ic)).toISOString()})(),Or=$t?.storageClass||"STANDARD",Pl=$t?.bandwidthStatus||null,Oi=$t?.avgUploadBytesPerSec||null,ad=os.hasEdgeSyncKey&&$t?.syncProvider==="edge",ji=nt?.siteName;return tt?t.jsx(JSe,{device:os,siteName:ji,syncEnabled:ad?!0:kr,syncMode:Wn,syncIntervalMinutes:zr,retentionDays:Yi,lastSyncAt:Ii,lastEdgeSyncAt:Ls,deviceStorageClass:Or,bandwidthStatus:Pl,avgUploadBytesPerSec:Oi,saveCloudSettingsMutation:Tc,syncDeviceMutation:Ea,isSuperAdmin:Qs,isEdgeSync:ad,edgeSyncScriptVersion:$t?.edgeSyncScriptVersion||null,currentServerVersion:$t?.currentServerVersion||null},os.id):t.jsx(ut,{className:"opacity-50","data-testid":`cloud-device-inactive-${os.id}`,children:t.jsx(mt,{className:"py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Fa,{className:"w-5 h-5 text-muted-foreground"}),t.jsx("div",{children:t.jsx("div",{className:"font-medium",children:os.serialNumber})})]}),t.jsx(Ke,{variant:"outline",className:"text-muted-foreground",children:"No Active Site"})]})})},os.id)},Zt=(os,nt)=>t.jsxs("div",{className:"ml-4 border-l pl-4","data-testid":`section-cloud-company-${os.id}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(xi,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:os.name}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",nt.length,")"]})]}),t.jsx("div",{className:"grid grid-cols-1 gap-4",children:nt.map(qt)})]},os.id);if(!We&&!(Qs&&It))return t.jsx("div",{className:"grid grid-cols-1 gap-4",children:na.map(qt)});if(!Qs||!It){const os=U.map(tt=>({id:tt.id,name:tt.name,devices:na.filter($t=>_e.get($t.serialNumber)?.companyId===tt.id)})).filter(tt=>tt.devices.length>0).sort((tt,$t)=>zi(tt.name,$t.name)),nt=na.filter(tt=>!_e.has(tt.serialNumber));return t.jsxs("div",{className:"flex flex-col gap-6",children:[os.map(tt=>t.jsxs("div",{"data-testid":`section-cloud-company-${tt.id}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(xi,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:tt.name}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",tt.devices.length,")"]})]}),t.jsx("div",{className:"grid grid-cols-1 gap-4",children:tt.devices.map(qt)})]},tt.id)),nt.length>0&&t.jsxs("div",{"data-testid":"section-cloud-unassigned",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(Fa,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide",children:"Unassigned"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",nt.length,")"]})]}),t.jsx("div",{className:"grid grid-cols-1 gap-4",children:nt.map(qt)})]})]})}const Rs=new Map;for(const os of U){const nt=os.resellerId||"__none__";Rs.has(nt)||Rs.set(nt,[]),Rs.get(nt).push(os)}const ir=Ri.map(os=>{const nt=(Rs.get(os.userId)||[]).sort(($t,kr)=>zi($t.name,kr.name)),tt=na.filter($t=>nt.some(kr=>kr.id===_e.get($t.serialNumber)?.companyId));return{reseller:os,companies:nt,devices:tt}}).filter(os=>os.devices.length>0).sort((os,nt)=>zi(os.reseller.businessName,nt.reseller.businessName)),Vn=new Set(ir.flatMap(os=>os.devices.map(nt=>nt.id))),Ns=na.filter(os=>!Vn.has(os.id)),or=(Rs.get("__none__")||[]).sort((os,nt)=>zi(os.name,nt.name));return t.jsxs("div",{className:"flex flex-col gap-6",children:[ir.map(os=>t.jsxs("div",{"data-testid":`section-cloud-reseller-${os.reseller.userId}`,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx(oh,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:Vp(os.reseller.businessName)}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",os.devices.length," device",os.devices.length!==1?"s":"",")"]})]}),We?t.jsxs("div",{className:"flex flex-col gap-4",children:[os.companies.filter(nt=>os.devices.some(tt=>_e.get(tt.serialNumber)?.companyId===nt.id)).map(nt=>{const tt=os.devices.filter($t=>_e.get($t.serialNumber)?.companyId===nt.id);return Zt(nt,tt)}),(()=>{const nt=os.devices.filter(tt=>!_e.has(tt.serialNumber));return nt.length>0?Zt({id:`__unassigned_${os.reseller.userId}`,name:"Unassigned"},nt):null})()]}):t.jsx("div",{className:"grid grid-cols-1 gap-4",children:os.devices.map(qt)})]}
489,os.reseller.userId)),Ns.length>0&&t.jsxs("div",{"data-testid":"section-cloud-no-reseller",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx(Fa,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"No Linked Customer"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",Ns.length," device",Ns.length!==1?"s":"",")"]})]}),We&&or.length>0?t.jsxs("div",{className:"flex flex-col gap-4",children:[or.filter(os=>Ns.some(nt=>_e.get(nt.serialNumber)?.companyId===os.id)).map(os=>{const nt=Ns.filter(tt=>_e.get(tt.serialNumber)?.companyId===os.id);return Zt(os,nt)}),(()=>{const os=Ns.filter(nt=>!_e.has(nt.serialNumber));return os.length>0?Zt({id:"__unassigned_noreseller",name:"Unassigned"},os):null})()]}):t.jsx("div",{className:"grid grid-cols-1 gap-4",children:Ns.map(qt)})]})]})})()]})}),(Qs||qa==="admin")&&!Po&&t.jsx(ea,{value:"subscriptions",children:t.jsx(ISe,{isSuperAdmin:Qs,userId:s?.id||"",onOpenDevice:U=>{const _e=(na||[]).find(qt=>qt.id===U);if(!_e){n({title:"Device not found",description:"It may have been removed.",variant:"destructive"});return}c("edge-devices"),ft(_e),zt({serialNumber:_e.serialNumber,host:_e.host,port:String(_e.port),apiUsername:_e.apiUsername,apiPassword:_e.apiPassword,orderNumber:_e.orderNumber||"",defaultPlanId:_e.defaultPlanId||"",salesOrderId:_e.salesOrderId||"",includeAiPlus:_e.includeAiPlus??!1,maxCameras:String(_e.maxCameras??8)}),pt(!0)}})}),Qs&&t.jsx(ea,{value:"support-requests",className:"p-4 sm:p-6",children:t.jsx(tCe,{})}),Rh&&t.jsx(ea,{value:"tab-permissions",className:"p-4 sm:p-6",children:t.jsx(lSe,{})}),Qs&&la("backups","read")&&t.jsxs(ea,{value:"backups",className:"space-y-4",children:[t.jsx("div",{className:"p-4 sm:p-6 pb-0",children:t.jsx(N1e,{canWrite:la("backups","write")})}),t.jsx(j1e,{}),t.jsx(f1e,{})]}),Qs&&t.jsx(ea,{value:"edge-pricing",className:"p-4 sm:p-6",children:t.jsx($Se,{})}),Qs&&la("distribution","read")&&t.jsx(ea,{value:"distribution",className:"p-4 sm:p-6",children:t.jsx(nCe,{canWrite:la("distribution","write"),canDelete:la("distribution","delete")})}),Qs&&t.jsx(ea,{value:"playback-health",className:"p-4 sm:p-6",children:t.jsx(C1e,{})}),Qs&&la("blog","read")&&t.jsx(ea,{value:"blog",className:"p-4 sm:p-6",children:t.jsx(rSe,{})}),Qs&&la("branding","read")&&t.jsx(ea,{value:"oem-branding",className:"p-4 sm:p-6",children:t.jsx(USe,{})})]})]})]})}),t.jsx(Ys,{open:es,onOpenChange:br,children:t.jsxs(Ws,{className:"sm:max-w-2xl max-h-[85vh] overflow-y-auto",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Email Preview"}),t.jsx(cr,{children:"Preview of the email template with sample data"})]}),t.jsx("div",{className:"border border-border rounded-md overflow-hidden",children:t.jsx("div",{dangerouslySetInnerHTML:{__html:`<div style="font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; background-color: #0a1929;">
490                  ${Ut.headerHtml}
491                  ${Ut.bodyHtml.replace(/\{\{CODE\}\}/g,"123456").replace(/\{\{DEVICE\}\}/g,"Desktop").replace(/\{\{BROWSER\}\}/g,"Chrome").replace(/\{\{IP\}\}/g,"203.0.113.42").replace(/\{\{LOCATION\}\}/g,"New York, United States").replace(/\{\{TIME\}\}/g,"Feb 7, 2025, 3:45 PM UTC")}
492                  ${Ut.footerHtml}
493                </div>`}})}),t.jsx(In,{children:t.jsx(L,{variant:"outline",onClick:()=>br(!1),children:"Close"})})]})}),t.jsx(Ys,{open:p,onOpenChange:g,children:t.jsxs(Ws,{className:"sm:max-w-lg max-h-[85vh] overflow-y-auto",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:v?"Edit Reseller":"Add Reseller"}),t.jsx(cr,{children:v?"Update the reseller's business information":"Promote a user to administrator and add their business details"})]}),t.jsxs("div",{className:"grid gap-4 py-2",children:[!v&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Select User"}),t.jsxs(Us,{value:jt.targetUserId,onValueChange:U=>Ct({...jt,targetUserId:U}),children:[t.jsx($s,{"data-testid":"select-reseller-user",children:t.jsx(zs,{placeholder:"Choose a user to promote..."})}),t.jsx(Fs,{children:nd.map(U=>t.jsxs(rt,{value:U.id,children:[U.firstName||""," ",U.lastName||""," (",U.email,")"]},U.id))})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Business N
493ame *"}),t.jsx(ke,{value:jt.businessName,onChange:U=>Ct({...jt,businessName:U.target.value}),placeholder:"Company or business name","data-testid":"input-reseller-business-name"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Contact Name"}),t.jsx(ke,{value:jt.contactName,onChange:U=>Ct({...jt,contactName:U.target.value}),placeholder:"Primary contact","data-testid":"input-reseller-contact-name"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Phone"}),t.jsx(ke,{value:jt.phone,onChange:U=>Ct({...jt,phone:U.target.value}),placeholder:"(555) 555-5555","data-testid":"input-reseller-phone"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Email"}),t.jsx(ke,{value:jt.email,onChange:U=>Ct({...jt,email:U.target.value}),placeholder:"[email protected]","data-testid":"input-reseller-email"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Address"}),t.jsx(ke,{value:jt.address,onChange:U=>Ct({...jt,address:U.target.value}),placeholder:"Street address","data-testid":"input-reseller-address"})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"City"}),t.jsx(ke,{value:jt.city,onChange:U=>Ct({...jt,city:U.target.value}),placeholder:"City","data-testid":"input-reseller-city"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"State"}),t.jsx(ke,{value:jt.state,onChange:U=>Ct({...jt,state:U.target.value}),placeholder:"State","data-testid":"input-reseller-state"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"ZIP"}),t.jsx(ke,{value:jt.zip,onChange:U=>Ct({...jt,zip:U.target.value}),placeholder:"ZIP","data-testid":"input-reseller-zip"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Notes"}),t.jsx(Nn,{value:jt.notes,onChange:U=>Ct({...jt,notes:U.target.value}),placeholder:"Additional notes...",className:"resize-none","data-testid":"input-reseller-notes"})]}),t.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-md border p-3",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsx(re,{htmlFor:"switch-hide-orders-quotes",children:"Hide Orders & Quotes"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When on, standard admins on this account can't create quotes, see Edge/Blu pricing, or view Sales Orders. Super admins are unaffected."})]}),t.jsx(sr,{id:"switch-hide-orders-quotes",checked:jt.hideOrdersQuotes,onCheckedChange:U=>Ct({...jt,hideOrdersQuotes:U}),"data-testid":"switch-reseller-hide-orders-quotes"})]}),la("distribution","write")&&t.jsxs("div",{className:"space-y-3 border-t pt-3",children:[t.jsx("div",{className:"text-sm font-medium",children:"Distribution"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Distributor"}),t.jsxs(Us,{value:jt.distributorId||"__none__",onValueChange:U=>Ct({...jt,distributorId:U==="__none__"?"":U}),children:[t.jsx($s,{"data-testid":"select-reseller-distributor",children:t.jsx(zs,{placeholder:"No distributor"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"__none__",children:"No distributor"}),ra?.map(U=>t.jsxs(rt,{value:U.id,children:[U.name," (",U.defaultHardwareMarkupPercent,"% HW / ",U.defaultSubscriptionMarkupPercent,"% Sub)"]},U.id))]})]})]}),(()=>{const U=ra?.find(ir=>ir.id===jt.distributorId),_e=U?.defaultHardwareMarkupPercent,qt=U?.defaultSubscriptionMarkupPercent,Zt=!jt.hardwareMarkupOverridePercent.trim(),Rs=!jt.subscriptionMarkupOverridePercent.trim();return t.jsxs(t.Fragment,{children:[U&&t.jsxs("div",{className:"rounded-md border border-border bg-muted/40 p-3 text-xs space-y-1","data-testid":"info-inherited-markup",children:[t.jsxs("div",{className:"font-medium text-foreground",children:["Inherited from ",U.name]}),t.jsxs("div",{className:"text-muted-foreground",children:["Hardware: ",Zt?t.jsxs(Ke,{variant:"secondary","data-testid":"badge-inherited-hw",children:[_e,"% (inherited)"]}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"line-through",children:[_e,"%"]})," ",t.jsxs(Ke,{"data-testid":"badge-override-hw",children:[jt.hardwareMarkupOverridePercent,"% (override)"]})]})]}),t.jsxs("div",{className:"text-muted-foreground",children:["Subscription: ",Rs?t.jsxs(Ke,{variant:"secondary","data-testid":"badge-inherited-sub",children:[qt,"% (inherited)"]}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"line-through",children:[qt,"%"]})," ",t.jsxs(Ke,{"data-testid":"badge-override-sub",children:[jt.subscriptionMarkupOverridePercent,"% (override)"]})]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Hardware Markup %"}),t.jsx(ke,{type:"number",min:"0",max:"500",step:"0.1",value:jt.hardwareMarkupOverridePercent,onChange:ir=>Ct({...jt,hardwareMarkupOverridePercent:ir.target.value}),placeholder:U?`inherit (${_e}%)`:"inherit","data-testid":"input-reseller-hw-markup"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Subscription Markup %"}),t.jsx(ke,{type:"number",min:"0",max:"500",step:"0.1",value:jt.subscriptionMarkupOverridePercent,onChange:ir=>Ct({...jt,subscriptionMarkupOverridePercent:ir.target.value}),placeholder:U?`inherit (${qt}%)`:"inherit","data-testid":"input-reseller-sub-markup"})]})]})]})})(),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave overrides blank to inherit from the distributor. Priority: override → distributor → none."})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>{g(!1),b(null)},"data-testid":"button-reseller-cancel",children:"Cancel"}),t.jsx(L,{onClick:()=>uo.mutate(jt),disabled:uo.isPending||!v&&!jt.targetUserId||!jt.businessName,"data-testid":"button-reseller-save",children:uo.isPending?"Saving...":v?"Update":"Create Customer"})]})]})}),t.jsx(Ys,{open:le,onOpenChange:U=>{ue(U),U||pe(null)},children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Confirm device access change"}),t.jsxs(cr,{children:["Saving this change will revoke Device Settings access from the following owner",(je?.length??0)===1?"":"s","."]})]}),t.jsx("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3 text-sm space-y-2","data-testid":"warning-role-change-impact",children:t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:(je||[]).map(U=>
493{const _e=[U.firstName,U.lastName].filter(Boolean).join(" ").trim(),qt=_e||U.email||U.userId,Zt=U.lostDeviceSerials&&U.lostDeviceSerials.length>0?U.lostDeviceSerials.join(", "):`${U.lostDeviceIds.length} device${U.lostDeviceIds.length===1?"":"s"}`;return t.jsxs("li",{"data-testid":`text-role-impact-owner-${U.userId}`,children:[t.jsx("span",{className:"font-medium",children:qt}),U.email&&_e?t.jsxs("span",{className:"text-muted-foreground",children:[" (",U.email,")"]}):null,t.jsxs("span",{className:"text-muted-foreground",children:[" — loses access to ",Zt]})]},U.userId)})})}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>{ue(!1),pe(null)},"data-testid":"button-role-impact-cancel",children:"Cancel"}),t.jsx(L,{variant:"destructive",onClick:()=>{j&&(ue(!1),pe(null),Ho.mutate({userId:j.id,role:Lt.role,companyIds:Lt.companyIds,siteIds:Lt.siteIds,resellerId:Lt.resellerId||void 0}))},disabled:Ho.isPending,"data-testid":"button-role-impact-confirm",children:"Revoke access & save"})]})]})}),t.jsx(Ys,{open:y,onOpenChange:w,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Edit User Role"}),t.jsxs(cr,{children:["Change the role for ",j?.firstName," ",j?.lastName]})]}),t.jsxs("div",{className:"grid gap-4 py-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Role"}),t.jsxs(Us,{value:Lt.role,onValueChange:U=>xr({...Lt,role:U}),children:[t.jsx($s,{"data-testid":"select-role",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"user",children:"User (Basic)"}),t.jsx(rt,{value:"owner",children:"Owner (Company Owner)"}),Qs&&t.jsx(rt,{value:"admin",children:"Administrator (Customer)"}),Qs&&t.jsx(rt,{value:"superadmin",children:"DB Admin (Full Access)"})]})]})]}),Qs&&Lt.role!=="superadmin"&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Assigned Customer"}),t.jsxs(Us,{value:Lt.resellerId||"__none__",onValueChange:U=>{const _e=U==="__none__"?"":U,qt=Zt=>{const Rs=kl.find(ir=>ir.id===Zt);return Rs?.resellerId===_e||!Rs?.resellerId&&!_e};xr(Zt=>({...Zt,resellerId:_e,companyIds:Zt.companyIds.filter(Rs=>qt(Rs)),siteIds:Zt.siteIds.filter(Rs=>{const ir=kl.find(Vn=>(Vn.sites||[]).some(Ns=>Ns.id===Rs));return qt(ir?.id)})}))},children:[t.jsx($s,{"data-testid":"select-reseller",children:t.jsx(zs,{placeholder:"No customer (direct)"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"__none__",children:"No customer (direct)"}),[...Ri].sort((U,_e)=>zi(U.businessName,_e.businessName)).map(U=>t.jsx(rt,{value:U.userId,children:Vp(U.businessName)},U.userId))]})]})]}),(Lt.role==="owner"||Lt.role==="user")&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Assigned Companies & Sites"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Check a company to grant access to all its sites (including ones added later), or expand it to grant only specific sites."}),t.jsx("div",{className:"border rounded-md p-2 max-h-64 overflow-y-auto space-y-1","data-testid":"company-checklist",children:(()=>{const U=Qs?Eo.filter(_e=>Lt.resellerId?_e.resellerId===Lt.resellerId:!_e.resellerId):Eo;return U.length===0?t.jsx("p",{className:"text-sm text-muted-foreground p-2",children:Qs&&Lt.resellerId?"No companies under this customer":"No companies available"}):U.map(_e=>{const qt=_e.sites||[],Zt=Lt.companyIds.includes(_e.id),Rs=qt.filter(or=>Lt.siteIds.includes(or.id)).map(or=>or.id),ir=!Zt&&Rs.length>0,Vn=!!qe[_e.id],Ns=()=>{const or=new Set(qt.map(os=>os.id));xr(os=>{const nt=!os.companyIds.includes(_e.id);return{...os,companyIds:nt?[...os.companyIds,_e.id]:os.companyIds.filter(tt=>tt!==_e.id),siteIds:os.siteIds.filter(tt=>!or.has(tt))}})};return t.jsxs("div",{className:"rounded",children:[t.jsxs("div",{className:"flex items-center gap-1.5 p-1.5 rounded hover-elevate",children:[qt.length>0?t.jsx("button",{type:"button",onClick:()=>Xt(or=>({...or,[_e.id]:!or[_e.id]})),className:"p-0.5 text-muted-foreground","data-testid":`button-expand-company-${_e.id}`,"aria-label":Vn?"Collapse":"Expand",children:t.jsx(Xa,{className:`w-4 h-4 transition-transform ${Vn?"":"-rotate-90"}`})}):t.jsx("span",{className:"w-5"}),t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer flex-1","data-testid":`check-company-${_e.id}`,children:[t.jsx("input",{type:"checkbox",checked:Zt,ref:or=>{or&&(or.indeterminate=ir)},onChange:Ns,className:"rounded border-input"}),t.jsx("span",{className:"text-sm font-medium",children:_e.name})]}),Zt&&t.jsx(Ke,{variant:"secondary",className:"text-xs",children:"All sites"}),ir&&t.jsxs(Ke,{variant:"outline",className:"text-xs",children:[Rs.length," site",Rs.length===1?"":"s"]})]}),Vn&&qt.length>0&&t.jsx("div",{className:"ml-7 space-y-1 pb-1",children:qt.map(or=>{const os=Zt||Lt.siteIds.includes(or.id);return t.jsxs("label",{className:"flex items-center gap-2 p-1 rounded hover-elevate cursor-pointer","data-testid":`check-site-${or.id}`,children:[t.jsx("input",{type:"checkbox",checked:os,disabled:Zt,onChange:()=>{xr(nt=>({...nt,siteIds:nt.siteIds.includes(or.id)?nt.siteIds.filter(tt=>tt!==or.id):[...nt.siteIds,or.id]}))},className:"rounded border-input"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:or.name})]},or.id)})})]},_e.id)})})()}),(Lt.companyIds.length>0||Lt.siteIds.length>0)&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[Lt.companyIds.length," whole compan",Lt.companyIds.length===1?"y":"ies",Lt.siteIds.length>0&&`, ${Lt.siteIds.length} specific site${Lt.siteIds.length===1?"":"s"}`]}),Wo&&t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-2 text-xs text-amber-700 dark:text-amber-400","data-testid":"warning-no-company-access",children:[t.jsx(ta,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),t.jsx("span",{children:"This user would be left with no company or site access and won't be able to see anything. Keep at least one company or site assigned."})]})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>w(!1),"data-testid":"button-role-cancel",children:"Cancel"}),t.jsx(L,{onClick:Mh,disabled:Ho.isPending||fe||Wo,"data-testid":"button-role-save",children:Ho.isPending?"Saving...":fe?"Checking...":"Update Role"})]})]})}),t.jsx(Ys,{open:C,onOpenChange:U=>{k(U),U||T("")},children:t.jsxs(Ws,{className:"sm:max-w-sm",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Reset Password"}),t.jsxs(cr,{children:["Set a new password for ",S?.firstName||""," ",S?.lastName||""," (",S?.email,")."]})]}),t.jsxs("div",{className:"space-y-2 py-2",children:[t.jsx(re,{htmlFor:"reset-password-input",children:"New Password"}),t.jsx(ke,{id:"reset-password-input",type:"password",value:A,onChange:U=>T(U.target.value),placeholder:"Min. 6 characters","data-testid":"input-reset-password",onKeyDown:U=>{U.key==="Enter"&&A.length>=6&&!Ai.isPending&&Ai.mutate({userId:S.id,newPassword:A})}})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>k(!1),"data-testid":"button-cancel-reset-password",children:"Cancel"}),t.jsx(L,{onClick:()=>Ai.mutate({userId:S.id,newPassword:A}),disabled:Ai.isPending||A.length<6||!S,"data-testid":"button-confirm-reset-password",children:Ai.isPending?"Resetting...":"Reset Password"})]})]})}),t.jsx(Ys,{open:M,onOpenChange:U=>{R(U),U||($(null),q(null))},children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Resend Onboarding Email"}),t.jsxs(cr,{children:["This will generate a new password for ",D?.firstName||""," ",D?.lastName||""," (",D?.email,") and email them their login details with the getting-started guide. Their current password will stop working."]})]}),O&&t.jsxs("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3 text-sm space-y-2","data-testid":"resend-onboarding-failure",children:[t.jsxs("p",{className:"font-medium text-destructive",children:["Email could not be sent: ",O.error]}),O.generatedPassword&&t.jsxs("div",{children:[t.jsx("p",{className:"mb-1",children:"The password was already reset. Share this new password with the user directly:"}),t.jsx("code",{className:"block text-xs bg-background/50 p-2 rounded break-all select-all","data-testid":"text-resend-generated-password",children:O.generatedPassword})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>R(!1),"data-testid":"button-cancel-resend-onboarding",children:O?"Close"
493:"Cancel"}),!O&&t.jsx(L,{onClick:()=>Bs.mutate(D.id),disabled:Bs.isPending||!D,"data-testid":"button-confirm-resend-onboarding",children:Bs.isPending?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-1.5 animate-spin"}),"Sending..."]}):"Reset Password & Send"})]})]})}),t.jsx(Ys,{open:V,onOpenChange:K,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Confirm Delete"}),t.jsx(cr,{children:(()=>{if(G?.type==="company"){const _e=hl.find(qt=>qt.id===G.id)?.sites?.length||0;if(_e>0)return`Cannot delete "${G.name}" because it has ${_e} site${_e>1?"s":""}. Please move or delete all sites first.`}if(G?.type==="edge-device"){const U=na?.find(_e=>_e.id===G.id);if(U?.linkedSiteId){const qt=hl.flatMap(Zt=>Zt.sites||[]).find(Zt=>Zt.id===U.linkedSiteId)?.name||"its linked site";return`Are you sure you want to delete edge device "${G.name}"? This will also permanently delete the linked site "${qt}". This action cannot be undone.`}}return`Are you sure you want to delete ${G?.type==="reseller"?"customer account":G?.type==="site"?"site":G?.type} "${G?.name}"? This action cannot be undone.`})()})]}),G?.type==="site"&&Z&&Z.length>0&&t.jsxs("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3 text-sm space-y-2","data-testid":"warning-site-delete-impact",children:[t.jsx("div",{className:"font-semibold text-destructive flex items-center gap-2",children:t.jsxs("span",{children:["⚠ This will remove device access for ",Z.length," owner",Z.length===1?"":"s",":"]})}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:Z.map(U=>{const _e=[U.firstName,U.lastName].filter(Boolean).join(" ").trim(),qt=_e||U.email||U.userId,Zt=U.lostDeviceSerials&&U.lostDeviceSerials.length>0?U.lostDeviceSerials.join(", "):`${U.lostDeviceIds.length} device${U.lostDeviceIds.length===1?"":"s"}`;return t.jsxs("li",{"data-testid":`text-impact-owner-${U.userId}`,children:[t.jsx("span",{className:"font-medium",children:qt}),U.email&&_e?t.jsxs("span",{className:"text-muted-foreground",children:[" (",U.email,")"]}):null,t.jsxs("span",{className:"text-muted-foreground",children:[" — loses access to ",Zt]})]},U.userId)})})]}),G?.type==="site"&&Z===null&&t.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"text-impact-loading",children:"Checking which owners depend on this site…"}),G?.type==="company"&&Q&&Q.length>0&&t.jsxs("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3 text-sm space-y-2","data-testid":"warning-company-delete-impact",children:[t.jsx("div",{className:"font-semibold text-destructive flex items-center gap-2",children:t.jsxs("span",{children:["⚠ This will remove device access for ",Q.length," owner",Q.length===1?"":"s",":"]})}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:Q.map(U=>{const _e=[U.firstName,U.lastName].filter(Boolean).join(" ").trim(),qt=_e||U.email||U.userId,Zt=U.lostDeviceSerials&&U.lostDeviceSerials.length>0?U.lostDeviceSerials.join(", "):`${U.lostDeviceIds.length} device${U.lostDeviceIds.length===1?"":"s"}`;return t.jsxs("li",{"data-testid":`text-company-impact-owner-${U.userId}`,children:[t.jsx("span",{className:"font-medium",children:qt}),U.email&&_e?t.jsxs("span",{className:"text-muted-foreground",children:[" (",U.email,")"]}):null,t.jsxs("span",{className:"text-muted-foreground",children:[" — loses access to ",Zt]})]},U.userId)})})]}),G?.type==="company"&&oe&&oe.length>0&&t.jsxs("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3 text-sm space-y-2","data-testid":"warning-company-delete-stranded",children:[t.jsx("div",{className:"font-semibold text-destructive flex items-center gap-2",children:t.jsxs("span",{children:["⚠ Cannot delete: this is the last company assignment for ",oe.length," account",oe.length===1?"":"s",":"]})}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:oe.map(U=>{const _e=[U.firstName,U.lastName].filter(Boolean).join(" ").trim(),qt=_e||U.email||U.userId;return t.jsxs("li",{"data-testid":`text-company-stranded-user-${U.userId}`,children:[t.jsx("span",{className:"font-medium",children:qt}),U.email&&_e?t.jsxs("span",{className:"text-muted-foreground",children:[" (",U.email,")"]}):null,t.jsxs("span",{className:"text-muted-foreground",children:[" — ",U.role]}
493)]},U.userId)})}),t.jsx("p",{className:"text-muted-foreground",children:"Reassign these accounts to another company (or delete them) first."})]}),G?.type==="company"&&Q===null&&t.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"text-company-impact-loading",children:"Checking which owners depend on this company…"}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>K(!1),"data-testid":"button-delete-cancel",children:"Cancel"}),(()=>{const U=G?.type==="company"&&(hl.find(ir=>ir.id===G.id)?.sites?.length||0)>0,_e=G?.type==="site"&&Z===null,qt=G?.type==="company"&&!U&&Q===null,Zt=_e||qt,Rs=G?.type==="company"&&(oe?.length||0)>0;return t.jsx(L,{variant:"destructive",onClick:Td,disabled:U||Zt||Rs||Ha.isPending||Na.isPending||Ac.isPending||ed.isPending||Vo.isPending,"data-testid":"button-delete-confirm",children:Ha.isPending||Na.isPending||Ac.isPending||ed.isPending||Vo.isPending?"Deleting...":Zt?"Checking...":"Delete"})})()]})]})}),t.jsx(Ys,{open:se,onOpenChange:me,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Reject Application"}),t.jsxs(cr,{children:["Reject the application from ",t.jsx("strong",{children:ge?.companyName}),". An email will be sent to ",ge?.techEmail,"."]})]}),t.jsxs("div",{className:"space-y-2 py-2",children:[t.jsx(re,{htmlFor:"reject-reason",children:"Reason (optional)"}),t.jsx(Nn,{id:"reject-reason",placeholder:"Provide a reason for rejection...",value:et,onChange:U=>$e(U.target.value),rows:3,"data-testid":"textarea-reject-reason"})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>me(!1),children:"Cancel"}),t.jsxs(L,{variant:"destructive",onClick:()=>kc.mutate({id:ge?.id,reason:et}),disabled:kc.isPending,"data-testid":"button-confirm-reject",children:[kc.isPending?t.jsx(Fe,{className:"w-4 h-4 animate-spin mr-2"}):null,"Reject Application"]})]})]})}),t.jsx(Ys,{open:dt,onOpenChange:Qt,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Create New User"}),t.jsx(cr,{children:"Add a new user account with login credentials"})]}),t.jsxs("div",{className:"space-y-4 py-2",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"First Name"}),t.jsx(ke,{value:Oe.firstName,onChange:U=>De(_e=>({..._e,firstName:U.target.value})),placeholder:"First name","data-testid":"input-create-user-firstname"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Last Name"}),t.jsx(ke,{value:Oe.lastName,onChange:U=>De(_e=>({..._e,lastName:U.target.value})),placeholder:"Last name","data-testid":"input-create-user-lastname"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Email"}),t.jsx(ke,{type:"email",value:Oe.email,onChange:U=>De(_e=>({..._e,email:U.target.value})),placeholder:"[email protected]",required:!0,"data-testid":"input-create-user-email"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Account Setup"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>De(U=>({...U,deliveryMode:"email"})),className:`rounded-md border p-2.5 text-left text-sm transition-colors ${Oe.deliveryMode==="email"?"border-primary bg-primary/10":"border-border hover-elevate"}`,"data-testid":"button-delivery-mode-email",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsx(yg,{className:"w-3.5 h-3.5"})," Set Password"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"You choose the password. Instructions are emailed to the user."})]}),t.jsxs("button",{type:"button",onClick:()=>De(U=>({...U,deliveryMode:"invite",password:""})),className:`rounded-md border p-2.5 text-left text-sm transition-colors ${Oe.deliveryMode==="invite"?"border-primary bg-primary/10":"border-border hover-elevate"}`,"data-testid":"button-delivery-mode-invite",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsx(qi,{className:"w-3.5 h-3.5"})," Invite"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"A secure password is generated and emailed with instructions."})]}),t.jsxs("button",{type:"button",onClick:()=>De(U=>({...U,deliveryMode:"invite_link",password:""})),className:`col-span-2 rounded-md border p-2.5 text-left text-sm transition-colors ${Oe.deliveryMode==="invite_link"?"border-primary bg-primary/10":"border-border hover-elevate"}`,"data-testid":"button-delivery-mode-invite-link",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsx(vi,{className:"w-3.5 h-3.5"})," Invite Link (most secure)"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"No password is generated or emailed. The user receives a secure link (expires in 72 hours) to set their own password."})]})]})]}),Oe.deliveryMode==="email"&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Password"}),t.jsx(ke,{type:"password",value:Oe.password,onChange:U=>De(_e=>({..._e,password:U.target.value})),placeholder:"Minimum 6 characters",required:!0,"data-testid":"input-create-user-password"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Role"}),t.jsxs(Us,{value:Oe.role,onValueChange:U=>De(_e=>({..._e,role:U})),children:[t.jsx($s,{"data-testid":"select-create-user-role",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[Qs&&t.jsx(rt,{value:"superadmin",children:"DB Admin"}),(Qs||qa==="admin")&&t.jsx(rt,{value:"admin",children:"Administrator"}),t.jsx(rt,{value:"owner",children:"Owner"}),t.jsx(rt,{value:"user",children:"User"})]})]})]}),Oe.role==="superadmin"&&t.jsx("div",{className:"rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-700 dark:text-amber-300","data-testid":"text-superadmin-warning",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(uc,{className:"w-4 h-4 mt-0.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Internal Use Only"}),t.jsxs("p",{className:"mt-1 text-xs opacity-80",children:["DB Admin accounts should only be created for internal ",a.brandName," employees. This role has full system access. 2FA will be automatically enabled via email."]})]})]})}),Oe.role==="admin"&&!Qs&&t.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"text-create-admin-scope-hint",children:"The new administrator will inherit your customer account's company access."}),Oe.role==="admin"&&Qs&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Customer Account"}),t.jsxs(Us,{value:Oe.resellerId,onValueChange:U=>De(_e=>({..._e,resellerId:U})),children:[t.jsx($s,{"data-testid":"select-create-user-reseller",children:t.jsx(zs,{placeholder:"Select a customer account..."})}),t.jsx(Fs,{children:(bi||[]).map(U=>t.jsx(rt,{value:U.userId,children:U.businessName},U.userId))})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"The new administrator will inherit this customer's company access."})]}),(Oe.role==="owner"||Oe.role==="user")&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Assign Companies"}),t.jsx("div",{className:"max-h-32 overflow-y-auto border border-border rounded-md p-2 space-y-1",children:(Qs?kl:hl).map(U=>t.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:Oe.companyIds.includes(U.id),onChange:_e=>{De(qt=>({...qt,companyIds:_e.target.checked?[...qt.companyIds,U.id]:qt.companyIds.filter(Zt=>Zt!==U.id)}))}}),t.jsx("span",{children:U.name})]},U.id))}),Oe.companyIds.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"text-create-user-company-hint",children:"Select at least one company"})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>Qt(!1),"data-testid":"button-create-user-cancel",children:"Cancel"}),t.jsx(L,{onClick:()=>Ed.mutate(Oe),disabled:Ed.isPending||!Oe.email||Oe.deliveryMode==="email"&&!Oe.password||Oe.role==="admin"&&Qs&&!Oe.resellerId||(Oe.role==="user"||Oe.role==="owner")&&Oe.companyIds.length===0,"data-testid":"button-create-user-submit",children:Ed.isPending?"Creating...":"Create User"})]})]})}),t.jsx(u3,{open:bt,onOpenChange:U=>{Ae(U),U||J(null)},company:Be,resellers:Ri.map(U=>({userId:U.userId,businessName:U.businessName}))}),t.jsx(yJ,{open:ae,onOpenChange:U=>{we(U),U||(ye(null),Ue(null))},companyId:te,site:Qe,isAdmin:Qs||qa==="admin",companyName:Ei?.find(U=>U.id===Qe?.companyId)?.name}),t.jsx(cSe,{open:Ft,onOpenChange:Es}),t.jsx(Ys,{open:Re,onOpenChange:pt,children:t.jsxs(Ws,{className:"sm:max-w-lg max-h-[85vh] overflow-y-auto",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:Ge?"Edit Edge Device":"Register Edge Device"}
493),t.jsx(cr,{children:Ge?"Update the Edge device configuration":"Register a new Edge device with its connection and credential details"})]}),t.jsxs("div",{className:"grid gap-4 py-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Serial Number"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ke,{value:He.serialNumber,onChange:U=>zt({...He,serialNumber:U.target.value.toUpperCase()}),placeholder:"TE-XXXXXXXXX",className:"font-mono",disabled:!!Ge,"data-testid":"input-device-serial"}),!Ge&&t.jsx(L,{type:"button",variant:"outline",onClick:()=>Ah.mutate(),disabled:Ah.isPending,"data-testid":"button-generate-serial",children:"Generate"})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Host / IP Address"}),t.jsx(ke,{value:He.host,onChange:U=>zt({...He,host:U.target.value}),placeholder:"192.168.1.100 or site.ddns.net","data-testid":"input-device-host"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Port"}),t.jsx(ke,{type:"number",value:He.port,onChange:U=>zt({...He,port:U.target.value}),placeholder:"443","data-testid":"input-device-port"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Hardware Capacity (cameras)"}),t.jsx(ke,{type:"number",min:1,max:128,step:1,value:He.maxCameras,onChange:U=>zt({...He,maxCameras:U.target.value}),onBlur:U=>{const _e=Math.floor(Number(U.target.value)),qt=Number.isFinite(_e)?Math.max(1,Math.min(128,_e)):8;zt(Zt=>({...Zt,maxCameras:String(qt)}))},placeholder:"8","data-testid":"input-device-max-cameras"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Maximum number of cameras this NVR can support (1–128). Determines how many chNN slots are offered when assigning cameras."})]}),t.jsx("div",{className:"space-y-1.5",children:t.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"API Credentials (for admin operations)"})}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"API Username"}),t.jsx(ke,{value:He.apiUsername,onChange:U=>zt({...He,apiUsername:U.target.value}),placeholder:"admin",autoComplete:"off","data-testid":"input-device-api-username"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"API Password"}),t.jsx(ke,{type:"password",value:He.apiPassword,onChange:U=>zt({...He,apiPassword:U.target.value}),placeholder:"Enter password",autoComplete:"off","data-testid":"input-device-api-password"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs(re,{children:["Order Number ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{value:He.orderNumber,onChange:U=>zt({...He,orderNumber:U.target.value}),placeholder:"e.g. ORD-2025-0001","data-testid":"input-device-order-number"})]}),Ge&&He.defaultPlanId&&!He.salesOrderId&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Wholesale Plan (legacy)"}),t.jsxs(Us,{value:He.defaultPlanId,onValueChange:U=>zt({...He,defaultPlanId:U}),children:[t.jsx($s,{"data-testid":"select-device-plan",children:t.jsx(zs,{placeholder:"Select a wholesale plan"})}),t.jsx(Fs,{children:(()=>{const U=(Zl||[]).filter(Rs=>Rs.active),_e=U.find(Rs=>Rs.storageType==="none"),qt=U.filter(Rs=>Rs.storageType!=="none"),Zt=[];_e&&Zt.push(t.jsx(rt,{value:_e.id,children:"No Subscription (Free)"},_e.id));for(const Rs of qt){const ir=Rs.storageType==="local"?"Local":Rs.storageType==="cloud_blu"?"Cloud Blu":"Cloud",Vn=Rs.retentionDays?` ${Rs.retentionDays}d`:"",Ns=Rs.recordingMode==="continuous"?" Cont.":Rs.recordingMode==="events_only"?" Events":"",or=Rs.interval==="monthly"?"/mo":Rs.interval==="quarterly"?"/qtr":"/yr",os=`$${(Rs.pricePerCamera/100).toFixed(2)}`;Zt.push(t.jsxs(rt,{value:Rs.id,children:[ir,Vn,Ns," — ",os,"/cam",or]},Rs.id))}return Zt})()})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Subscription plan activated when a site is created with this device"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Sales Order (optional)"}),t.jsxs(Us,{value:He.salesOrderId||"__none__",onValueChange:U=>zt({...He,salesOrderId:U==="__none__"?"":U}),children:[t.jsx($s,{"data-testid":"select-device-sales-order",children:t.jsx(zs,{placeholder:"Not linked"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"__none__",children:"— Not linked —"}),oi.map(U=>{const _e=[U.orderNumber,U.businessName?`· ${U.businessName}`:null,`(${U.status}
493)`].filter(Boolean);return t.jsx(rt,{value:U.id,children:_e.join(" ")},U.id)})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When linked, the order's status controls cloud sync and notifications. Active orders with cloud or Plus Plan enable monitoring; canceled or non-active orders pause sync (recordings are never deleted)."})]}),t.jsxs("div",{className:"flex items-center justify-between border rounded-md p-2.5 bg-muted/30",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Do,{className:"w-4 h-4 text-amber-500"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Include AI+ Features"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable Visual Search and AI-powered features for this device"})]})]}),t.jsx(sr,{checked:He.includeAiPlus,onCheckedChange:U=>zt({...He,includeAiPlus:U}),"data-testid":"switch-device-ai-plus"})]})]}),t.jsxs(In,{className:"gap-2",children:[t.jsx(L,{variant:"outline",onClick:()=>pt(!1),"data-testid":"button-cancel-device",children:"Cancel"}),t.jsx(L,{onClick:async()=>{const U={serialNumber:He.serialNumber,host:He.host,port:parseInt(He.port)||443,apiUsername:He.apiUsername,apiPassword:He.apiPassword,orderNumber:He.orderNumber,salesOrderId:He.salesOrderId||null,includeAiPlus:He.includeAiPlus,maxCameras:parseInt(He.maxCameras)||8};Ge&&He.defaultPlanId&&!He.salesOrderId&&(U.defaultPlanId=He.defaultPlanId),td.mutate(U)},disabled:td.isPending||!He.serialNumber||!He.host||!He.apiUsername||!He.apiPassword||!He.orderNumber,"data-testid":"button-save-device",children:td.isPending?"Saving...":Ge?"Update":"Register"})]})]})}),t.jsx(Ys,{open:ma,onOpenChange:U=>{lo(U),U||Lr(null)},children:t.jsxs(Ws,{children:[t.jsxs(Zs,{children:[t.jsxs(Ks,{className:"flex items-center gap-2",children:[t.jsx(Yc,{className:"w-5 h-5"}),"Trusted Devices"]}),t.jsxs(cr,{children:["Manage trusted devices for ",Vr]})]}),t.jsx("div",{className:"space-y-3",children:ko?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):cl.length===0?t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-admin-no-trusted-devices",children:"No trusted devices"}):t.jsxs(t.Fragment,{children:[cl.map(U=>{const _e=U.deviceType==="Mobile"?Yc:U.deviceType==="Tablet"?KK:Vx,qt=[U.city,U.region].filter(Boolean),Zt=qt.length>0?qt.join(", "):null;return t.jsxs("div",{className:"flex items-center justify-between gap-4 p-3 rounded-md border","data-testid":`admin-trusted-device-${U.id}`,children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx(_e,{className:"w-5 h-5 text-muted-foreground flex-shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"text-sm font-medium","data-testid":`text-admin-device-browser-${U.id}`,children:[U.browser||"Unknown Browser"," on ",U.deviceType||"Unknown Device"]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5",children:[U.ipAddress&&t.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":`text-admin-device-ip-${U.id}`,children:["IP: ",U.ipAddress]}),Zt&&t.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1","data-testid":`text-admin-device-location-${U.id}`,children:[t.jsx(Yp,{className:"w-3 h-3"}),Zt]})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Trusted ",new Date(U.createdAt).toLocaleDateString()," · Expires ",new Date(U.expiresAt).toLocaleDateString()]})]})]}),t.jsx(L,{size:"icon",variant:"ghost",onClick:()=>Cn&&dl.mutate({userId:Cn,deviceId:U.id}),disabled:dl.isPending,"data-testid":`button-admin-revoke-device-${U.id}`,children:t.jsx(sa,{className:"w-4 h-4 text-destructive"})})]},U.id)}),cl.length>1&&Cn&&t.jsxs(L,{variant:"destructive",onClick:()=>Cl.mutate(Cn),disabled:Cl.isPending,"data-testid":"button-admin-revoke-all-devices",children:[Cl.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Revoke All Devices"]})]})})]})})]})}function nCe({canWrite:e,canDelete:s}){const{toast:r}=Hs(),{data:n,isLoading:a}=ze({queryKey:["/api/admin/distributors"]}),{data:i}=ze({queryKey:["/api/admin/resellers"]}),[o,l]=u.useState(!1),[c,d]=u.useState(null),[h,p]=u.useState({name:"",contactName:"",email:"",ph
493one:"",notes:"",defaultHardwareMarkupPercent:"33",defaultSubscriptionMarkupPercent:"50"});function g(){d(null),p({name:"",contactName:"",email:"",phone:"",notes:"",defaultHardwareMarkupPercent:"33",defaultSubscriptionMarkupPercent:"50"}),l(!0)}function v(j){d(j),p({name:j.name||"",contactName:j.contactName||"",email:j.email||"",phone:j.phone||"",notes:j.notes||"",defaultHardwareMarkupPercent:String(j.defaultHardwareMarkupPercent??0),defaultSubscriptionMarkupPercent:String(j.defaultSubscriptionMarkupPercent??0)}),l(!0)}const b=Et({mutationFn:async()=>{const j={name:h.name.trim(),contactName:h.contactName||null,email:h.email||null,phone:h.phone||null,notes:h.notes||null,defaultHardwareMarkupPercent:parseFloat(h.defaultHardwareMarkupPercent)||0,defaultSubscriptionMarkupPercent:parseFloat(h.defaultSubscriptionMarkupPercent)||0};c?await Ze("PATCH",`/api/admin/distributors/${c.id}`,j):await Ze("POST","/api/admin/distributors",j)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/distributors"]}),l(!1),r({title:c?"Distributor updated":"Distributor created"})},onError:j=>r({title:"Save failed",description:j.message,variant:"destructive"})}),y=Et({mutationFn:async j=>Ze("DELETE",`/api/admin/distributors/${j}`),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/admin/distributors"]}),Je.invalidateQueries({queryKey:["/api/admin/resellers"]}),r({title:"Distributor deleted"})},onError:j=>r({title:"Delete failed",description:j.message,variant:"destructive"})}),w=u.useMemo(()=>{const j={};return(i||[]).forEach(x=>{x.distributorId&&(j[x.distributorId]=(j[x.distributorId]||0)+1)}),j},[i]);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Distributors"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Set default markup % per distributor. Customers inherit unless they have a per-customer override."})]}),e&&t.jsxs(L,{onClick:g,"data-testid":"button-add-distributor",children:[t.jsx(Fo,{className:"w-4 h-4 mr-1"})," Add Distributor"]})]}),t.jsx(ut,{children:t.jsx(mt,{className:"p-0",children:a?t.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"Loading..."}):(n||[]).length===0?t.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"No distributors yet."}):t.jsxs(Fy,{children:[t.jsx(By,{children:t.jsxs(hu,{children:[t.jsx(fa,{children:"Name"}),t.jsx(fa,{children:"Contact"}),t.jsx(fa,{children:"HW Markup %"}),t.jsx(fa,{children:"Sub Markup %"}),t.jsx(fa,{children:"Customers"}),t.jsx(fa,{className:"text-right",children:"Actions"})]})}),t.jsx(Uy,{children:(n||[]).map(j=>t.jsxs(hu,{"data-testid":`row-distributor-${j.id}`,children:[t.jsx(ia,{className:"font-medium",children:j.name}),t.jsxs(ia,{className:"text-sm text-muted-foreground",children:[j.contactName||"—",j.email?t.jsx("div",{className:"text-xs",children:j.email}):null]}),t.jsxs(ia,{children:[j.defaultHardwareMarkupPercent,"%"]}),t.jsxs(ia,{children:[j.defaultSubscriptionMarkupPercent,"%"]}),t.jsx(ia,{children:w[j.id]||0}),t.jsxs(ia,{className:"text-right space-x-2",children:[e&&t.jsx(L,{variant:"ghost",size:"sm",onClick:()=>v(j),"data-testid":`button-edit-distributor-${j.id}`,children:"Edit"}),s&&t.jsx(L,{variant:"ghost",size:"sm",onClick:()=>{confirm(`Delete distributor "${j.name}"? Linked resellers will be unlinked.`)&&y.mutate(j.id)},"data-testid":`button-delete-distributor-${j.id}`,children:"Delete"})]})]},j.id))})]})})}),t.jsx(Ys,{open:o,onOpenChange:l,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:c?"Edit Distributor":"Add Distributor"}),t.jsx(cr,{children:"Markup applies to all linked resellers unless overridden."})]}),t.jsxs("div",{className:"grid gap-3 py-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Name *"}),t.jsx(ke,{value:h.name,onChange:j=>p({...h,name:j.target.value}),"data-testid":"input-distributor-name"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Contact Name"}),t.jsx(ke,{value:h.contactName,onChange:j=>p({...h,contactName:j.target.value}),"data-testid":"input-distributor-contact"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Phone"}),t.jsx(ke,{value:h.phone,onChange:j=>p({...h,phone:j.target.value}),"data-testid":"input-distributor-phone"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Email"}),t.jsx(ke,{value:h.email,onChange:j=>p({...h,email:j.target.value}),"data-testid":"input-distributor-email"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Hardware Markup %"}),t.jsx(ke,{type:"number",min:"0",max:"500",step:"0.1",value:h.defaultHardwareMarkupPercent,onChange:j=>p({...h,defaultHardwareMarkupPercent:j.target.value}),"data-testid":"input-distributor-hw-markup"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Subscription Markup %"}),t.jsx(ke,{type:"number",min:"0",max:"500",step:"0.1",value:h.defaultSubscriptionMarkupPercent,onChange:j=>p({...h,defaultSubscriptionMarkupPercent:j.target.value}),"data-testid":"input-distributor-sub-markup"})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:"Notes"}),t.jsx(Nn,{value:h.notes,onChange:j=>p({...h,notes:j.target.value}),className:"resize-none","data-testid":"input-distributor-notes"})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),t.jsx(L,{onClick:()=>b.mutate(),disabled:!h.name.trim()||b.isPending,"data-testid":"button-save-distributor",children:b.isPending?"Saving...":c?"Update":"Create"})]})]})})]})}const aCe="modulepreload",iCe=function(e){return"/"+e},zF={}
493,fg=function(s,r,n){let a=Promise.resolve();if(r&&r.length>0){let c=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");a=c(r.map(d=>{if(d=iCe(d),d in zF)return;zF[d]=!0;const h=d.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":aCe,h||(g.as="script"),g.crossOrigin="",g.href=d,l&&g.setAttribute("nonce",l),document.head.appendChild(g),h)return new Promise((v,b)=>{g.addEventListener("load",v),g.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${d}`)))})}))}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 s().catch(i)})};function X0(e,s){if(!e)return;const r=s||e.querySelector("video"),n=()=>{const i=r;if(i&&typeof i.webkitEnterFullscreen=="function")try{i.webkitEnterFullscreen()}catch{}},a=e;if(typeof e.requestFullscreen=="function")try{const i=e.requestFullscreen();i&&typeof i.catch=="function"&&i.catch(n)}catch{n()}else if(typeof a.webkitRequestFullscreen=="function")try{a.webkitRequestFullscreen()}catch{n()}else n()}function c0(e){const s=new Set,r=[];for(const n of e){if(n.recordingType!=="motion"||!n.endTime)continue;const a=new Date(n.startTime).getTime(),i=new Date(n.endTime).getTime();!Number.isFinite(a)||!Number.isFinite(i)||i<=a||r.push({id:n.id,cam:n.cameraName,site:n.siteId??null,sMs:a,eMs:i,dur:i-a})}if(r.length<2)return s;for(const n of r)if(!(n.dur<3e4)){for(const a of r)if(a.id!==n.id&&a.cam===n.cam&&!(n.site&&a.site&&n.site!==a.site)&&!(a.dur>=n.dur)&&a.sMs>=n.sMs&&a.eMs<=n.eMs){s.add(n.id);break}}return s}function oCe(e){const[s,r]=u.useState({blobUrl:null,progress:0,bytesDownloaded:0,isLoading:!1,error:null,hasContentLength:!1}),n=u.useRef(null),a=u.useRef(null);return u.useEffect(()=>{n.current&&n.current.abort(),a.current&&(URL.revokeObjectURL(a.current),a.current=null);{r({blobUrl:null,progress:0,bytesDownloaded:0,isLoading:!1,error:null,hasContentLength:!1});return}},[e]),s}function lCe(e){return ze({queryKey:["/api/sites",e,"my-permissions"],enabled:!!e,staleTime:6e4})}function cCe(e){return e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function d0({videoRef:e,resetKey:s,fetchProgress:r,bytesDownloaded:n,isFetchLoading:a,hasFetchContentLength:i}){const[o,l]=u.useState(!1),[c,d]=u.useState(0),[h,p]=u.useState(!0),g=u.useRef(null),v=u.useRef(!1),b=a!==void 0,y=b?a||!1:o,w=b?r??0:c,j=b?!i&&(r??0)<100:h;if(u.useEffect(()=>{if(b)return;const C=e.current;if(!C)return;const k=C.closest(".clip-reveal");g.current=k,v.current=!1,k&&(k.dataset.ready="false");let S=null;const _=()=>{S&&clearTimeout(S),!v.current&&(l(!0),d(0),p(!0),g.current&&(g.current.dataset.ready="false"))},A=()=>{const D=e.current;if(!D||!D.duration||D.buffered.length===0)return;const $=D.buffered.end(D.buffered.length-1)/D.duration*100;p(!1),d(Math.min(Math.round($),99))},T=()=>{v.current=!0,p(!1),d(100),g.current&&(g.current.dataset.ready="true"),S=setTimeout(()=>l(!1),500)},M=()=>{l(!1),g.current&&(g.current.dataset.ready="true")},R=()=>{v.current||(d(0),p(!0))};return C.addEventListener("loadstart",_),C.addEventListener("progress",A),C.addEventListener("canplay",T),C.addEventListener("canplaythrough",T),C.addEventListener("error",M),C.addEventListener("emptied",R),()=>{S&&clearTimeout(S),C.removeEventListener("loadstart",_),C.removeEventListener("progress",A),C.removeEventListener("canplay",T),C.removeEventListener("canplaythrough",T),C.removeEventListener("error",M),C.removeEventListener("emptied",R)}},[e,s,b]),!y)return null;const x=w>=100?"Ready":i&&w>0?`Retrieving clip… ${w}%`:!i&&n&&n>0?`Retrieving clip… ${cCe(n)}`:"Retrieving clip…";return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"absolute top-0 left-0 right-0 z-30 rounded-t-md overflow-hidden",style:{height:"3px"},children:[t.jsx("div",{className:"absolute inset-0 bg-black/20"}),j?t.jsx("div",{className:"absolute top-0 bottom-0 bg-primary",style:{width:"35%",animation:"clip-progress-slide 1.4s ease-in-out infinite"}}):t.jsx("div",{className:"absolute top-0 left-0 bottom-0 bg-primary transition-all duration-300 ease-out",style:{width:`${w}%`}})]}),t.jsx("div",{className:"absolute top-3 left-1/2 z-30 -translate-x-1/2 pointer-events-none",children:t.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-black/60 backdrop-blur-sm text-white text-xs font-medium whitespace-nowrap",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse shrink-0"}),x]})})]})}const dCe=[.25,.5,1,1.5,2,4],uCe=3e3;function HF(e){if(!isFinite(e)||e<0)return"0:00";
493const s=Math.floor(e%60),r=Math.floor(e/60%60),n=Math.floor(e/3600),a=n>0?String(r).padStart(2,"0"):String(r),i=String(s).padStart(2,"0");return n>0?`${n}:${a}:${i}`:`${a}:${i}`}function u0({videoRef:e,resetKey:s,audioRestricted:r,hidden:n,fullscreenTargetRef:a,testIdPrefix:i="vc"}){const[o,l]=u.useState(!1),[c,d]=u.useState(0),[h,p]=u.useState(0),[g,v]=u.useState(0),[b,y]=u.useState(!!r),[w,j]=u.useState(1),[x,C]=u.useState(!0),[k,S]=u.useState(!1),[_,A]=u.useState(!1),T=u.useRef(1);T.current=w;const M=u.useRef(null),R=u.useRef(!1),D=u.useRef(null),$=u.useRef(null),O=u.useCallback(()=>e.current,[e]);u.useEffect(()=>{const H=O();if(!H)return;H.playbackRate=T.current,r&&(H.muted=!0,H.volume=0);const se=()=>{l(!H.paused&&!H.ended),d(H.currentTime||0),p(isFinite(H.duration)?H.duration:0),y(r?!0:H.muted)},me=()=>{R.current||d(H.currentTime||0)},ge=()=>{p(isFinite(H.duration)?H.duration:0),H.playbackRate=T.current},be=()=>{try{const $e=H.buffered;$e.length>0?v($e.end($e.length-1)):v(0)}catch{v(0)}},ce=()=>{l(!0)},Pe=()=>{l(!1),C(!0)},et=()=>y(r?!0:H.muted);return H.addEventListener("timeupdate",me),H.addEventListener("durationchange",ge),H.addEventListener("loadedmetadata",ge),H.addEventListener("progress",be),H.addEventListener("play",ce),H.addEventListener("playing",ce),H.addEventListener("pause",Pe),H.addEventListener("ended",Pe),H.addEventListener("volumechange",et),se(),be(),C(!0),()=>{H.removeEventListener("timeupdate",me),H.removeEventListener("durationchange",ge),H.removeEventListener("loadedmetadata",ge),H.removeEventListener("progress",be),H.removeEventListener("play",ce),H.removeEventListener("playing",ce),H.removeEventListener("pause",Pe),H.removeEventListener("ended",Pe),H.removeEventListener("volumechange",et)}},[s,r]),u.useEffect(()=>{const H=()=>A(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",H),()=>document.removeEventListener("fullscreenchange",H)},[]);const q=u.useCallback(()=>{M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{const H=O();H&&!H.paused&&!H.ended&&!R.current&&(C(!1),S(!1))},uCe)},[O]),V=u.useCallback(()=>{C(!0),q()},[q]);u.useEffect(()=>(o?q():(M.current&&clearTimeout(M.current),C(!0)),()=>{M.current&&clearTimeout(M.current)}),[o,q]);const K=u.useCallback(()=>{const H=O();H&&(H.paused||H.ended?H.play().catch(()=>{}):H.pause())},[O]),G=u.useCallback(H=>{const se=O();if(!se)return;const me=isFinite(se.duration)?se.duration:1/0;se.currentTime=Math.max(0,Math.min(se.currentTime+H,me-.1)),V()},[O,V]),z=u.useCallback(H=>{j(H);const se=O();se&&(se.playbackRate=H),S(!1),V()},[O,V]),Z=u.useCallback(()=>{if(r)return;const H=O();H&&(H.muted=!H.muted,!H.muted&&H.volume===0&&(H.volume=1),V())},[r,O,V]),ee=u.useCallback(()=>{if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}const H=a?.current||O()?.closest(".fs-player-container")||O()?.parentElement||null;H&&X0(H,O()),V()},[a,O,V]),Q=u.useCallback(H=>{const se=D.current,me=O();if(!se||!me)return;const ge=se.getBoundingClientRect(),be=Math.max(0,Math.min(1,(H-ge.left)/ge.width)),ce=isFinite(me.duration)?me.duration:0;ce>0&&(me.currentTime=be*ce,d(be*ce))},[O]),Y=u.useCallback(H=>{H.stopPropagation(),R.current=!0;try{H.currentTarget.setPointerCapture(H.pointerId)}catch{}Q(H.clientX)},[Q]),oe=u.useCallback(H=>{R.current&&Q(H.clientX)},[Q]),he=u.useCallback(H=>{R.current&&(R.current=!1,Q(H.clientX),V())},[Q,V]),je=u.useRef(!1),pe=u.useCallback(()=>{if(je.current&&!x){V();return}K(),V()},[x,V,K]);if(n)return null;const le=h>0?c/h*100:0,ue=h>0?Math.min(100,g/h*100):0,fe="flex items-center justify-center w-9 h-9 sm:w-8 sm:h-8 rounded-md text-white/90 hover:text-white hover:bg-white/10 transition-colors cursor-pointer select-none";return t.jsxs("div",{ref:$,className:"absolute inset-0 z-[15]",style:{cursor:x?void 0:"none"},onPointerMove:H=>{je.current=H.pointerType==="touch",V()},onPointerDown:H=>{je.current=H.pointerType==="touch"},"data-testid":`${i}-root`,children:[t.jsx("div",{className:"absolute inset-0",onClick:pe}),!o&&t.jsx("button",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex items-center justify-center w-16 h-16 rounded-full bg-black/60 hover:bg-black/75 text-white transition-colors",onClick:H=>{H.stopPropagation(),K()},"data-testid":`${i}-center-play`,"aria-label":"Play",children:t.jsx(vu,{className:"w-8 h-8 ml-1",fill:"currentColor"})}),t.jsx("div",{className:`absolute inset-x-0 bottom-0 transition-opacity duration-200 ${x?"opacity-100":"opacity-0 pointer-events-none"}`,onClick:H=>
493H.stopPropagation(),"data-video-zoom-ignore":!0,children:t.jsxs("div",{className:"bg-gradient-to-t from-black/85 via-black/55 to-transparent pt-8 pb-1.5 px-2 sm:px-3",children:[t.jsx("div",{ref:D,className:"group h-6 flex items-center cursor-pointer touch-none",style:{position:"relative"},onPointerDown:Y,onPointerMove:oe,onPointerUp:he,onPointerCancel:()=>{R.current=!1},"data-testid":`${i}-scrubber`,children:t.jsxs("div",{className:"w-full h-1 group-hover:h-1.5 rounded-full bg-white/25 transition-all",style:{position:"relative"},children:[t.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full bg-white/40",style:{width:`${ue}%`}}),t.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full bg-sky-400",style:{width:`${le}%`}}),t.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-3 h-3 rounded-full bg-sky-400 shadow opacity-0 group-hover:opacity-100 transition-opacity",style:{left:`${le}%`}})]})}),t.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1",children:[t.jsx("button",{className:fe,onClick:K,"data-testid":`${i}-play`,"aria-label":o?"Pause":"Play",children:o?t.jsx(nO,{className:"w-5 h-5",fill:"currentColor"}):t.jsx(vu,{className:"w-5 h-5 ml-0.5",fill:"currentColor"})}),t.jsxs("button",{className:fe,style:{position:"relative"},onClick:()=>G(-10),"data-testid":`${i}-back10`,"aria-label":"Back 10 seconds",children:[t.jsx(bh,{className:"w-5 h-5"}),t.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[7px] font-bold mt-[3px]",children:"10"})]}),t.jsxs("button",{className:fe,style:{position:"relative"},onClick:()=>G(10),"data-testid":`${i}-fwd10`,"aria-label":"Forward 10 seconds",children:[t.jsx(aO,{className:"w-5 h-5"}),t.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-[7px] font-bold mt-[3px]",children:"10"})]}),t.jsxs("span",{className:"text-[11px] sm:text-xs text-white/90 tabular-nums px-1 whitespace-nowrap","data-testid":`${i}-time`,children:[HF(c)," / ",HF(h)]}),t.jsx("div",{className:"flex-1"}),t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("button",{className:`${fe} w-auto px-1.5 gap-1`,onClick:()=>{S(H=>!H),V()},"data-testid":`${i}-speed`,"aria-label":"Playback speed",children:[t.jsx(hf,{className:"w-4 h-4"}),t.jsx("span",{className:"text-[11px] font-semibold",children:w===1?"1x":`${w}x`})]}),k&&t.jsx("div",{className:"absolute bottom-full right-0 mb-2 rounded-md bg-black/90 border border-white/15 py-1 min-w-[92px] shadow-lg",children:dCe.map(H=>t.jsx("button",{className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-white/10 ${H===w?"text-sky-400 font-semibold":"text-white/90"}`,onClick:()=>z(H),"data-testid":`${i}-speed-${H}`,children:H===1?"Normal":`${H}x`},H))})]}),!r&&t.jsx("button",{className:fe,onClick:Z,"data-testid":`${i}-mute`,"aria-label":b?"Unmute":"Mute",children:b?t.jsx(M$,{className:"w-5 h-5"}):t.jsx(XK,{className:"w-5 h-5"})}),r&&t.jsx("span",{className:`${fe} opacity-40 cursor-not-allowed`,title:"Audio is restricted for your account","data-testid":`${i}-mute-locked`,children:t.jsx(M$,{className:"w-5 h-5"})}),t.jsx("button",{className:fe,onClick:ee,"data-testid":`${i}-fullscreen`,"aria-label":"Fullscreen",children:_?t.jsx(C0,{className:"w-5 h-5"}):t.jsx(pf,{className:"w-5 h-5"})})]})]})})]})}const PM="truvios_event_debug",j_="truvios:event-debug",mCe=200,m0=[];function Z0(){if(typeof window>"u")return!1;try{return localStorage.getItem(PM)==="true"}catch{return!1}}function hCe(e){if(!(typeof window>"u")){try{e?localStorage.setItem(PM,"true"):localStorage.removeItem(PM)}catch{}window.dispatchEvent(new CustomEvent(j_,{detail:{type:"toggle",enabled:e}}))}}function $o(e,s,r){if(!Z0())return;const n={ts:Date.now(),scope:e,message:s,data:r};m0.push(n),m0.length>mCe&&m0.shift();try{console.log(`[EventDebug:${e}]`,s,r??"")}catch{}typeof window<"u"&&window.dispatchEvent(new CustomEvent(j_,{detail:{type:"entry",entry:n}}))}function IP(){return m0.slice()}function pCe(){m0.length=0,typeof window<"u"&&window.dispatchEvent(new CustomEvent(j_,{detail:{type:"clear"}}))}const qF=j_;
493async function pC(e,s,r,n){if(!Z0())return fetch(r,n);const a=performance.now();$o(e,`${s} → fetch`,{url:r});try{const i=await fetch(r,n),o=Math.round(performance.now()-a);return $o(e,`${s} ← ${i.status} ${i.statusText} (${o}ms)`,{url:r}),i}catch(i){const o=Math.round(performance.now()-a);throw $o(e,`${s} ✗ network error (${o}ms): ${i?.message||i}`,{url:r}),i}}function Ote(){const[e,s]=u.useState(Z0()),[r,n]=u.useState(IP()),[a,i]=u.useState(!0);if(u.useEffect(()=>{const l=d=>{const h=d.detail;h?.type==="toggle"&&s(h.enabled),n(IP())},c=()=>s(Z0());return window.addEventListener(qF,l),window.addEventListener("storage",c),()=>{window.removeEventListener(qF,l),window.removeEventListener("storage",c)}},[]),!e)return null;const o=l=>l==="cloud"?"#3b82f6":l==="local"?"#10b981":"#f59e0b";return t.jsxs("div",{className:"fixed bottom-4 right-4 z-[60] w-96 max-w-[calc(100vw-2rem)] rounded-lg border border-border bg-background/95 backdrop-blur shadow-lg","data-testid":"panel-event-debug",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(jy,{className:"h-4 w-4 text-amber-500 shrink-0"}),t.jsx("span",{className:"text-sm font-semibold",children:"Event Debug"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:r.length})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(L,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:()=>pCe(),"data-testid":"button-event-debug-clear",title:"Clear log",children:t.jsx(sa,{className:"h-3.5 w-3.5"})}),t.jsx(L,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:()=>i(l=>!l),"data-testid":"button-event-debug-toggle",title:a?"Collapse":"Expand",children:a?t.jsx(Xa,{className:"h-3.5 w-3.5"}):t.jsx(Ig,{className:"h-3.5 w-3.5"})})]})]}),a&&t.jsx("div",{className:"max-h-72 overflow-auto p-2 space-y-1 text-xs font-mono","data-testid":"list-event-debug",children:r.length===0?t.jsx("div",{className:"text-muted-foreground italic px-2 py-3 text-center",children:"Waiting for events…"}):r.slice().reverse().map((l,c)=>t.jsxs("div",{className:"border-l-2 pl-2 py-0.5",style:{borderColor:o(l.scope)},"data-testid":`entry-event-debug-${c}`,children:[t.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsx("span",{className:"text-muted-foreground",children:new Date(l.ts).toLocaleTimeString()}),t.jsx("span",{className:"uppercase text-[10px] px-1 rounded",style:{backgroundColor:o(l.scope),color:"white"},children:l.scope})]}),t.jsx("div",{className:"break-all whitespace-pre-wrap",children:l.message}),l.data&&t.jsx("div",{className:"text-muted-foreground break-all whitespace-pre-wrap",children:(()=>{try{return JSON.stringify(l.data)}catch{return String(l.data)}})()})]},`${l.ts}-${c}`))})]})}let EM=0;const VF=1500;if(typeof document<"u"){const e=()=>{EM=Date.now()};document.addEventListener("pointerdown",e,{capture:!0,passive:!0}),document.addEventListener("keydown",e,{capture:!0,passive:!0})}function N_(e,s=""){let r=-1,n=0,a=0,i=!1,o=-1,l=0;const d=setInterval(()=>{if(!e.isConnected)return;if(e.paused||e.ended||e.seeking||e.readyState===0){n=0;return}const b=e.currentTime;if(Math.abs(b-r)>.05){r>=0&&(i=!0),r=b,n=0,a=0,l=0;return}if(r<0&&(r=b),!i||(n++,n<2))return;n=0;const y=Number.isFinite(e.duration)?e.duration:0;if(y>0&&b>=y-.5){console.log(`[StallRecovery]${s} stalled at end (${b.toFixed(2)}/${y.toFixed(2)}) — finishing clip`);try{e.currentTime=y}catch{}return}const w=e.buffered;for(let x=0;x<w.length;x++){const C=w.start(x);if(C>b+.1&&C-b<30){const k=Math.min(C+.1,y>0?y:C+.1);console.log(`[StallRecovery]${s} jumping buffer gap ${b.toFixed(2)}s → ${k.toFixed(2)}s`);try{e.currentTime=k}catch{}return}}if(e.networkState===HTMLMediaElement.NETWORK_LOADING){l=0;return}const j=w.length>0?w.end(w.length-1):0;if(j>o+.05){o=j,l=0;return}if(o=j,l++,!(l<3)&&a<6){a++;const x=y>0?Math.min(b+.4,y):b+.4;console.log(`[StallRecovery]${s} nudge #${a} ${b.toFixed(2)}s → ${x.toFixed(2)}s`);try{e.currentTime=x}catch{}}},1e3);let h=0,p=null;const g=()=>{if(!i||e.ended||e.seeking||document.hidden||Date.now()-EM<VF)return;const b=Number.isFinite(e.duration)?e.duration:0;b>0&&e.currentTime>=b-.5||h>=3||(p&&clearTimeout(p),p=setTimeout(()=>{p=null,!(!e.isConnected||!e.paused||e.ended)&&(document.hidden||Date.now()-EM<VF||(h++,console.log(`[StallRecovery]${s} spontaneous pause at ${e.currentTime.toFixed(2)}s — auto-resuming (#${h})`),e.play().catch(()=>{})))},400))},v=()=>{h=0};return e.addEventListener("pause",g),e.addEventListener("playing",v),()=>{clearInterval(d),p&&clearTimeout(p),e.removeEventListener("pause",g),e.removeEventListener("playing",v)}}function fCe(e,s){u.useEffect(()=>{if(!e)return;const r=n=>{n.key==="Escape"&&(n.preventDefault(),s())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,s])}function fC({videoRef:e,onCrop:s,onCancel:r,active:n}){fCe(n,r);const a=u.useRef(null),i=u.useRef(null),[o,l]=u.useState(!1),[c,d]=u.useState(null),[h,p]=u.useState(null),g=u.useRef(!1),v=u.useRef(r);v.current=r,u.useEffect(()=>{if(!n){g.current=!1,l(!1),d(null),p(null);return}const x=e.current,C=i.current;if(!x||!C){console.warn("[CropOverlay] No video or frameCanvas ref, cancelling"),v.current();return}const k=x.videoWidth||x.clientWidth,S=x.videoHeight||x.clientHeight;if(!k||!S){console.warn("[CropOverlay] Video has no dimensions, cancelling"),v.current();return}C.width=k,C.height=S;const _=C.getContext("2d");if(_)try{_.drawImage(x,0,0,C.width,C.height),g.current=!0}catch(A){console.error("[CropOverlay] drawImage failed:",A),v.current();return}},[n,e]),u.useEffect(()=>{const x=a.current;if(!x||!n)return;const C=x.getContext("2d");if(!C)return;const k=x.getBoundingClientRect();if(x.width=k.width,x.height=k.height,C.clearRect(0,0,x.width,x.height),C.fillStyle="rgba(0, 0, 0, 0.4)",C.fillRect(0,0,x.width,x.height),c&&h){const S=Math.min(c.x,h.x),_=Math.min(c.y,h.y),A=Math.abs(h.x-c.x),T=
493Math.abs(h.y-c.y);C.clearRect(S,_,A,T),C.setLineDash([6,4]),C.strokeStyle="#ffffff",C.lineWidth=2,C.strokeRect(S,_,A,T),C.setLineDash([]),C.strokeStyle="rgba(59, 130, 246, 0.8)",C.lineWidth=2,C.strokeRect(S,_,A,T)}},[n,c,h]);const b=u.useCallback(x=>{const C=a.current;if(!C)return{x:0,y:0};const k=C.getBoundingClientRect(),S="touches"in x?x.touches[0]?.clientX??x.changedTouches[0]?.clientX??0:x.clientX,_="touches"in x?x.touches[0]?.clientY??x.changedTouches[0]?.clientY??0:x.clientY;return{x:S-k.left,y:_-k.top}},[]),y=u.useCallback(x=>{x.preventDefault();const C=b(x);d(C),p(C),l(!0)},[b]),w=u.useCallback(x=>{o&&(x.preventDefault(),p(b(x)))},[o,b]),j=u.useCallback(x=>{if(!o||!c||!h)return;x.preventDefault(),l(!1);const C=a.current,k=i.current;if(!C||!k||!g.current){console.warn("[CropOverlay] handleEnd: missing canvas or frame not captured");return}const S=C.getBoundingClientRect();if(!S.width||!S.height){console.warn("[CropOverlay] handleEnd: canvas has zero dimensions");return}const _=k.width,A=k.height,T=Math.min(S.width/_,S.height/A),M=_*T,R=A*T,D=(S.width-M)/2,$=(S.height-R)/2,O=Math.max(Math.min(c.x,h.x),D),q=Math.max(Math.min(c.y,h.y),$),V=Math.min(Math.max(c.x,h.x),D+M),K=Math.min(Math.max(c.y,h.y),$+R),G=(O-D)/M*_,z=(q-$)/R*A,Z=(V-O)/M*_,ee=(K-q)/R*A;if(Z<10||ee<10){d(null),p(null);return}try{const Y=Math.round(Z),oe=Math.round(ee),he=Math.max(Y,oe),je=he>1024?1024/he:1,pe=Math.max(1,Math.round(Y*je)),le=Math.max(1,Math.round(oe*je)),ue=document.createElement("canvas");ue.width=pe,ue.height=le;const fe=ue.getContext("2d");if(!fe)return;fe.drawImage(k,Math.round(G),Math.round(z),Y,oe,0,0,pe,le);const H=ue.toDataURL("image/jpeg",.85);console.log(`[CropOverlay] crop ${Y}x${oe} -> ${pe}x${le}, ~${Math.round(H.length/1024)}KB base64`),s(H)}catch(Q){console.error("[CropOverlay] crop extraction failed:",Q?.name,Q?.message,Q),r()}d(null),p(null)},[o,c,h,s,r]);return n?t.jsxs(t.Fragment,{children:[t.jsx("canvas",{ref:i,style:{display:"none"}}),t.jsx("canvas",{ref:a,className:"absolute inset-0 w-full h-full cursor-crosshair",style:{zIndex:20,touchAction:"none"},onMouseDown:y,onMouseMove:w,onMouseUp:j,onMouseLeave:x=>{o&&j(x)},onTouchStart:y,onTouchMove:w,onTouchEnd:j,"data-testid":"crop-overlay-canvas"}),t.jsx("div",{className:"absolute bottom-2 left-1/2 -translate-x-1/2 pointer-events-none select-none",style:{zIndex:21},children:t.jsx("span",{className:"text-[11px] sm:text-xs text-white bg-black/70 px-2.5 sm:px-3 py-1 sm:py-1.5 rounded-full whitespace-nowrap",children:"Draw a box around what you want to find"})})]}):null}const OP=3600*1e3,WF=900*1e3,gCe=250;function xCe(){const[e,s]=u.useState(!1);return u.useEffect(()=>{const r=window.matchMedia("(max-width: 640px)"),n=window.matchMedia("(pointer: coarse)"),a=()=>s(r.matches||n.matches);return a(),r.addEventListener("change",a),n.addEventListener("change",a),()=>{r.removeEventListener("change",a),n.removeEventListener("change",a)}},[]),e}function gC({events:e,currentEventId:s,onEventSelect:r,compact:n,loadedStartMs:a,loadedEndMs:i,onPanRequestMore:o,isLoadingBefore:l,isLoadingAfter:c,atStartCap:d,atEndCap:h}){const p=u.useRef(null),g=u.useRef(null),[v,b]=u.useState(null),[y,w]=u.useState(0),j=u.useRef(null),x=u.useRef(!1),C=xCe(),k=u.useRef(null),S=u.useRef({before:null,after:null});u.useEffect(()=>{w(0),S.current={before:null,after:null}},[s]),u.useEffect(()=>{S.current={before:null,after:null}},[a,i]),u.useEffect(()=>()=>{k.current&&clearTimeout(k.current)},[]);const{sortedEvents:_,windowStartMs:A,windowEndMs:T,totalMs:M}=u.useMemo(()=>{if(e.length===0)return{sortedEvents:[],windowStartMs:0,windowEndMs:0,totalMs:0};const pe=[...e].sort((H,se)=>H.startMs-se.startMs),le=s?pe.find(H=>H.id===s)?.startMs??pe[0].startMs:pe[0].startMs,ue=le-OP/2+y,fe=le+OP/2+y;return{sortedEvents:pe,windowStartMs:ue,windowEndMs:fe,totalMs:fe-ue}},[e,s,y]),R=u.useMemo(()=>{if(M<=0)return[];const pe=[],le=new Date(A);le.setMinutes(0,0,0);let ue=le.getTime();const fe=9e5;for(ue<A&&(ue+=fe);ue<=T;){const H=(ue-A)/M*100;if(H>=0&&H<=100){const se=new Date(ue),me=se.getHours(),ge=se.getMinutes(),be=me>=12?"p":"a",ce=me===0?12:me>12?me-12:me,Pe=ge===0?`${ce}${be}`:`${ce}:${ge.toString().padStart(2,"0")}`;pe.push({label:Pe,pct:H})}ue+=fe}return pe},[A,T,M]);u.useEffect(()=>{if(g.current&&p.current){const pe=p.current,le=g.current,ue=pe.getBoundingClientRect(),fe=le.getBoundingClientRect(),H=fe.left-ue.left+pe.scrollLeft-ue.width/2+fe.width/2;pe.scrollTo({left:Math.max(0,H),behavior:"smooth"})}},[s]);const D=u.useCallback(pe=>{const le=p.current;if(!le)return null;const ue=le.getBoundingClientRect(),H=(pe-ue.left)/ue.width,se=A+H*M;let me=null,ge=1/0;for(const ce of _){if(ce.unavailable)continue;const Pe=(ce.startMs+ce.endMs)/2,et=Math.abs(Pe-se);et<ge&&(ge=et,me=ce)}return me&&ge<M*(C?.12:.05)?me:null},[_,A,M,C]),$=u.useCallback(pe=>{if(x.current)return;const le=D(pe.clientX);le&&r(le.id)},[D,r]),O=u.useCallback(pe=>{if(C||j.current)return;const le=D(pe.clientX);if(le){const ue=p.current?.getBoundingClientRect();if(ue){const fe=pe.clientX-ue.left;b({event:le,x:fe})}}else b(null)},[D,C]),q=u.useCallback(()=>b(null),[]),V=u.useCallback(pe=>{if(!x.current&&pe.changedTouches.length>0){const le=pe.changedTouches[0],ue=D(le.clientX);ue&&(pe.preventDefault(),r(ue.id))}},[D,r]),K=u.useRef(0),G=u.useCallback(pe=>{try{pe.currentTarget.setPointerCapture(pe.pointerId)}catch{}j.current={startX:pe.clientX,startOffset:y,totalDist:0},K.current=pe.clientX,x.current=!1,b(null)},[y]),z=u.useCallback(()=>
493{if(!o||a==null||i==null||M<=0)return;const pe=A+M/2;if(pe-a<=WF){if(S.current.before===a)return;S.current.before=a,o({direction:"before",centerMs:pe})}else if(i-pe<=WF){if(S.current.after===i)return;S.current.after=i,o({direction:"after",centerMs:pe})}},[o,a,i,A,M]),Z=u.useCallback(pe=>{if(!j.current)return;j.current.totalDist+=Math.abs(pe.clientX-K.current),K.current=pe.clientX;const le=p.current;if(!le)return;const ue=le.getBoundingClientRect(),fe=j.current.startX-pe.clientX,H=OP/ue.width;w(j.current.startOffset+fe*H),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{z()},gCe)},[z]),ee=u.useCallback(pe=>{try{pe.currentTarget?.releasePointerCapture?.(pe.pointerId)}catch{}j.current&&j.current.totalDist>5&&(x.current=!0,setTimeout(()=>{x.current=!1},0)),j.current=null,k.current&&(clearTimeout(k.current),k.current=null),z()},[z]);if(_.length===0||M<=0)return null;const Q=_.filter(pe=>pe.endMs>A&&pe.startMs<T),Y=n?"h-8":C?"h-10":"h-6",oe=n?"top-[4px] bottom-[4px]":C?"top-[5px] bottom-[5px]":"top-[3px] bottom-[3px]",he=C?"8px":"4px",je=n?"text-[8px] text-white/40":C?"text-[11px] text-muted-foreground/60 font-medium":"text-[9px] text-muted-foreground/50";return t.jsx("div",{className:"w-full select-none","data-testid":"player-mini-timeline",children:t.jsxs("div",{className:"relative",children:[!C&&!n&&v&&t.jsx("div",{className:"absolute bottom-full z-50 pointer-events-none mb-2",style:{left:`${v.x}px`,transform:"translateX(-50%)"},children:t.jsxs("div",{className:"rounded-md border bg-card shadow-lg overflow-hidden",style:{width:"180px"},children:[v.event.thumbnailUrl&&t.jsx("img",{src:v.event.thumbnailUrl,alt:"",className:"w-full h-auto object-cover",style:{maxHeight:"100px"},onError:pe=>{pe.target.style.display="none"}}),t.jsxs("div",{className:"px-2 py-1 text-[10px]",children:[v.event.label&&t.jsx("div",{className:"font-medium truncate",children:v.event.label}),t.jsx("div",{className:"text-muted-foreground",children:Bn(new Date(v.event.startMs),"h:mm:ss a")})]})]})}),C&&!n&&v&&t.jsxs("div",{className:"flex items-center justify-center gap-2 pb-1",children:[v.event.label&&t.jsx("span",{className:"text-[11px] font-medium",children:v.event.label}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:Bn(new Date(v.event.startMs),"h:mm:ss a")})]}),t.jsx("div",{className:`relative ${n?"h-4":"h-5"} flex items-center px-1`,children:R.map(pe=>t.jsx("span",{className:`absolute ${je} -translate-x-1/2 leading-none`,style:{left:`${pe.pct}%`,top:"1px"},children:pe.label},pe.pct))}),t.jsxs("div",{ref:p,className:`relative ${Y} rounded-md bg-muted/30 cursor-grab active:cursor-grabbing border border-border/20 select-none`,style:{touchAction:"none"},onClick:$,onMouseMove:O,onMouseLeave:q,onTouchEnd:V,onPointerDown:G,onPointerMove:Z,onPointerUp:ee,onPointerCancel:ee,children:[R.map(pe=>t.jsx("div",{className:"absolute top-0 bottom-0 border-l border-border/15",style:{left:`${pe.pct}%`}},pe.pct)),(l||d)&&t.jsx("div",{className:"absolute left-0 top-0 bottom-0 flex items-center justify-center pointer-events-none z-20",style:{width:"14px"},"data-testid":l?"mini-timeline-loading-before":"mini-timeline-cap-before",children:l?t.jsx(Fe,{className:"h-3 w-3 animate-spin text-foreground/70"}):t.jsx("div",{className:"h-full w-[2px] rounded-full bg-foreground
493/25",title:"End of available range"})}),(c||h)&&t.jsx("div",{className:"absolute right-0 top-0 bottom-0 flex items-center justify-center pointer-events-none z-20",style:{width:"14px"},"data-testid":c?"mini-timeline-loading-after":"mini-timeline-cap-after",children:c?t.jsx(Fe,{className:"h-3 w-3 animate-spin text-foreground/70"}):t.jsx("div",{className:"h-full w-[2px] rounded-full bg-foreground/25",title:"End of available range"})}),Q.map(pe=>{const le=Math.max(0,Math.min(100,(pe.startMs-A)/M*100)),ue=Math.max(0,Math.min(100,(pe.endMs-A)/M*100)),fe=Math.max(.3,ue-le),H=pe.id===s,se=v?.event.id===pe.id;return pe.unavailable?t.jsx("div",{className:`absolute ${oe} rounded-[3px] pointer-events-none opacity-40`,style:{left:`${le}%`,width:`${fe}%`,minWidth:he,backgroundColor:"transparent",border:`1px solid ${pe.color}`,backgroundImage:`repeating-linear-gradient(45deg, ${pe.color} 0, ${pe.color} 1px, transparent 1px, transparent 4px)`},title:"Local footage temporarily unavailable (device offline)","data-testid":`mini-event-unavailable-${pe.id}`},pe.id):t.jsx("div",{ref:H?g:void 0,className:`absolute ${oe} rounded-[3px] cursor-pointer transition-all ${H?"ring-1 ring-white/80 z-10 brightness-125 shadow-sm":se?"brightness-125 opacity-100 z-[5]":"opacity-60 hover:opacity-90"}`,style:{left:`${le}%`,width:`${fe}%`,minWidth:he,backgroundColor:pe.color,boxShadow:H||se?void 0:"inset -1px 0 0 0 rgba(0,0,0,0.55)"},onClick:me=>{me.stopPropagation(),x.current||r(pe.id)},"data-testid":`mini-event-${pe.id}`},pe.id)})]})]})})}var sn=function(){return sn=Object.assign||function(s){for(var r,n=1,a=arguments.length;n<a;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(s[i]=r[i])}return s},sn.apply(this,arguments)};function vCe(e,s){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&s.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)s.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r}function Dte(e,s,r){for(var n=0,a=s.length,i;n<a;n++)(i||!(n in s))&&(i||(i=Array.prototype.slice.call(s,0,n)),i[n]=s[n]);return e.concat(i||Array.prototype.slice.call(s))}function lN(e){return e.mode==="multiple"}function cN(e){return e.mode==="range"}function S_(e){return e.mode==="single"}var yCe={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function bCe(e,s){return Bn(e,"LLLL y",s)}function wCe(e,s){return Bn(e,"d",s)}function jCe(e,s){return Bn(e,"LLLL",s)}function NCe(e){return"".concat(e)}function SCe(e,s){return Bn(e,"cccccc",s)}function CCe(e,s){return Bn(e,"yyyy",s)}var kCe=Object.freeze({__proto__:null,formatCaption:bCe,formatDay:wCe,formatMonthCaption:jCe,formatWeekNumber:NCe,formatWeekdayName:SCe,formatYearCaption:CCe}),_Ce=function(e,s,r){return Bn(e,"do MMMM (EEEE)",r)},PCe=function(){return"Month: "},ECe=function(){return"Go to next month"},TCe=function(){return"Go to previous month"}
493,ACe=function(e,s){return Bn(e,"cccc",s)},MCe=function(e){return"Week n. ".concat(e)},RCe=function(){return"Year: "},ICe=Object.freeze({__proto__:null,labelDay:_Ce,labelMonthDropdown:PCe,labelNext:ECe,labelPrevious:TCe,labelWeekNumber:MCe,labelWeekday:ACe,labelYearDropdown:RCe});function OCe(){var e="buttons",s=yCe,r=k3,n={},a={},i=1,o={},l=new Date;return{captionLayout:e,classNames:s,formatters:kCe,labels:ICe,locale:r,modifiersClassNames:n,modifiers:a,numberOfMonths:i,styles:o,today:l,mode:"default"}}function DCe(e){var s=e.fromYear,r=e.toYear,n=e.fromMonth,a=e.toMonth,i=e.fromDate,o=e.toDate;return n?i=ju(n):s&&(i=new Date(s,0,1)),a?o=f_(a):r&&(o=new Date(r,11,31)),{fromDate:i?zy(i):void 0,toDate:o?zy(o):void 0}}var Lte=u.createContext(void 0);function LCe(e){var s,r=e.initialProps,n=OCe(),a=DCe(r),i=a.fromDate,o=a.toDate,l=(s=r.captionLayout)!==null&&s!==void 0?s:n.captionLayout;l!=="buttons"&&(!i||!o)&&(l="buttons");var c;(S_(r)||lN(r)||cN(r))&&(c=r.onSelect);var d=sn(sn(sn({},n),r),{captionLayout:l,classNames:sn(sn({},n.classNames),r.classNames),components:sn({},r.components),formatters:sn(sn({},n.formatters),r.formatters),fromDate:i,labels:sn(sn({},n.labels),r.labels),mode:r.mode||n.mode,modifiers:sn(sn({},n.modifiers),r.modifiers),modifiersClassNames:sn(sn({},n.modifiersClassNames),r.modifiersClassNames),onSelect:c,styles:sn(sn({},n.styles),r.styles),toDate:o});return t.jsx(Lte.Provider,{value:d,children:e.children})}function _i(){var e=u.useContext(Lte);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function $te(e){var s=_i(),r=s.locale,n=s.classNames,a=s.styles,i=s.formatters.formatCaption;return t.jsx("div",{className:n.caption_label,style:a.caption_label,"aria-live":"polite",role:"presentation",id:e.id,children:i(e.displayMonth,{locale:r})})}function $Ce(e){return t.jsx("svg",sn({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:t.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function Fte(e){var s,r,n=e.onChange,a=e.value,i=e.children,o=e.caption,l=e.className,c=e.style,d=_i(),h=(r=(s=d.components)===null||s===void 0?void 0:s.IconDropdown)!==null&&r!==void 0?r:$Ce;return t.jsxs("div",{className:l,style:c,children:[t.jsx("span",{className:d.classNames.vhidden,children:e["aria-label"]}),t.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:d.classNames.dropdown,style:d.styles.dropdown,value:a,onChange:n,children:i}),t.jsxs("div",{className:d.classNames.caption_label,style:d.styles.caption_label,"aria-hidden":"true",children:[o,t.jsx(h,{className:d.classNames.dropdown_icon,style:d.styles.dropdown_icon})]})]})}function FCe(e){var s,r=_i(),n=r.fromDate,a=r.toDate,i=r.styles,o=r.locale,l=r.formatters.formatMonthCaption,c=r.classNames,d=r.components,h=r.labels.labelMonthDropdown;if(!n)return t.jsx(t.Fragment,{});if(!a)return t.jsx(t.Fragment,{});var p=[];if(h1e(n,a))for(var g=ju(n),v=n.getMonth();v<=a.getMonth();v++)p.push(_P(g,v));else for(var g=ju(new Date),v=0;v<=11;v++)p.push(_P(g,v));var b=function(w){var j=Number(w.target.value),x=_P(ju(e.displayMonth),j);e.onChange(x)},y=(s=d?.Dropdown)!==null&&s!==void 0?s:Fte;return t.jsx(y,{name:"months","aria-label":h(),className:c.dropdown_month,style:i.dropdown_month,onChange:b,value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:o}),children:p.map(function(w){return t.jsx("option",{value:w.getMonth(),children:l(w,{locale:o})},w.getMonth())})})}function BCe(e){var s,r=e.displayMonth,n=_i(),a=n.fromDate,i=n.toDate,o=n.locale,l=n.styles,c=n.classNames,d=n.components,h=n.formatters.formatYearC
493aption,p=n.labels.labelYearDropdown,g=[];if(!a)return t.jsx(t.Fragment,{});if(!i)return t.jsx(t.Fragment,{});for(var v=a.getFullYear(),b=i.getFullYear(),y=v;y<=b;y++)g.push(_F(Nee(new Date),y));var w=function(x){var C=_F(ju(r),Number(x.target.value));e.onChange(C)},j=(s=d?.Dropdown)!==null&&s!==void 0?s:Fte;return t.jsx(j,{name:"years","aria-label":p(),className:c.dropdown_year,style:l.dropdown_year,onChange:w,value:r.getFullYear(),caption:h(r,{locale:o}),children:g.map(function(x){return t.jsx("option",{value:x.getFullYear(),children:h(x,{locale:o})},x.getFullYear())})})}function UCe(e,s){var r=u.useState(e),n=r[0],a=r[1],i=s===void 0?n:s;return[i,a]}function zCe(e){var s=e.month,r=e.defaultMonth,n=e.today,a=s||r||n||new Date,i=e.toDate,o=e.fromDate,l=e.numberOfMonths,c=l===void 0?1:l;if(i&&qy(i,a)<0){var d=-1*(c-1);a=kh(i,d)}return o&&qy(a,o)<0&&(a=o),ju(a)}function HCe(){var e=_i(),s=zCe(e),r=UCe(s,e.month),n=r[0],a=r[1],i=function(o){var l;if(!e.disableNavigation){var c=ju(o);a(c),(l=e.onMonthChange)===null||l===void 0||l.call(e,c)}};return[n,i]}function qCe(e,s){for(var r=s.reverseMonths,n=s.numberOfMonths,a=ju(e),i=ju(kh(a,n)),o=qy(i,a),l=[],c=0;c<o;c++){var d=kh(a,c);l.push(d)}return r&&(l=l.reverse()),l}function VCe(e,s){if(!s.disableNavigation){var r=s.toDate,n=s.pagedNavigation,a=s.numberOfMonths,i=a===void 0?1:a,o=n?i:1,l=ju(e);if(!r)return kh(l,o);var c=qy(r,e);if(!(c<i))return kh(l,o)}}function WCe(e,s){if(!s.disableNavigation){var r=s.fromDate,n=s.pagedNavigation,a=s.numberOfMonths,i=a===void 0?1:a,o=n?i:1,l=ju(e);if(!r)return kh(l,-o);var c=qy(l,r);if(!(c<=0))return kh(l,-o)}}var Bte=u.createContext(void 0);function KCe(e){var s=_i(),r=HCe(),n=r[0],a=r[1],i=qCe(n,s),o=VCe(n,s),l=WCe(n,s),c=function(p){return i.some(function(g){return _3(p,g)})},d=function(p,g){c(p)||(g&&Tee(p,g)?a(kh(p,1+s.numberOfMonths*-1)):a(p))},h={currentMonth:n,displayMonths:i,goToMonth:a,goToDate:d,previousMonth:l,nextMonth:o,isDateDisplayed:c};return t.jsx(Bte.Provider,{value:h,children:e.children})}function dN(){var e=u.useContext(Bte);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function KF(e){var s,r=_i(),n=r.classNames,a=r.styles,i=r.components,o=dN().goToMonth,l=function(h){o(kh(h,e.displayIndex?-e.dis
493playIndex:0))},c=(s=i?.CaptionLabel)!==null&&s!==void 0?s:$te,d=t.jsx(c,{id:e.id,displayMonth:e.displayMonth});return t.jsxs("div",{className:n.caption_dropdowns,style:a.caption_dropdowns,children:[t.jsx("div",{className:n.vhidden,children:d}),t.jsx(FCe,{onChange:l,displayMonth:e.displayMonth}),t.jsx(BCe,{onChange:l,displayMonth:e.displayMonth})]})}function GCe(e){return t.jsx("svg",sn({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:t.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function YCe(e){return t.jsx("svg",sn({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:t.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var xC=u.forwardRef(function(e,s){var r=_i(),n=r.classNames,a=r.styles,i=[n.button_reset,n.button];e.className&&i.push(e.className);var o=i.join(" "),l=sn(sn({},a.button_reset),a.button);return e.style&&Object.assign(l,e.style),t.jsx("button",sn({},e,{ref:s,type:"button",className:o,style:l}))});function QCe(e){var s,r,n=_i(),a=n.dir,i=n.locale,o=n.classNames,l=n.styles,c=n.labels,d=c.labelPrevious,h=c.labelNext,p=n.components;if(!e.nextMonth&&!e.previousMonth)return t.jsx(t.Fragment,{});var g=d(e.previousMonth,{locale:i}),v=[o.nav_button,o.nav_button_previous].join(" "),b=h(e.nextMonth,{locale:i}),y=[o.nav_button,o.nav_button_next].join(" "),w=(s=p?.IconRight)!==null&&s!==void 0?s:YCe,j=(r=p?.IconLeft)!==null&&r!==void 0?r:GCe;return t.jsxs("div",{className:o.nav,style:l.nav,children:[!e.hidePrevious&&t.jsx(xC,{name:"previous-month","aria-label":g,className:v,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:a==="rtl"?t.jsx(w,{className:o.nav_icon,style:l.nav_icon}):t.jsx(j,{className:o.nav_icon,style:l.nav_icon})}),!e.hideNext&&t.jsx(xC,{name:"next-month","aria-label":b,className:y,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:a==="rtl"?t.jsx(j,{className:o.nav_icon,style:l.nav_icon}):t.jsx(w,{className:o.nav_icon,style:l.nav_icon})})]})}function GF(e){var s=_i().numberOfMonths,r=dN(),n=r.previousMonth,a=r.nextMonth,i=r.goToMonth,o=r.displayMonths,l=o.findIndex(function(b){return _3(e.displayMonth,b)}),c=l===0,d=l===o.length-1,h=s>1&&(c||!d),p=s>1&&(d||!c),g=function(){n&&i(n)},v=function(){a&&i(a)};return t.jsx(QCe,{displayMonth:e.displayMonth,hideNext:h,hidePrevious:p,nextMonth:a,previousMonth:n,onPreviousClick:g,onNextClick:v})}function XCe(e){var s,r=_i(),n=r.classNames,a=r.disableNavigation,i=r.styles,o=r.captionLayout,l=r.components,c=(s=l?.CaptionLabel)!==null&&s!==void 0?s:$te,d;return a?d=t.jsx(c,{id:e.id,displayMonth:e.displayMonth}):o==="dropdown"?d=t.jsx(KF,{displayMonth:e.displayMonth,id:e.id}):o==="dropdown-buttons"?d=t.jsxs(t.Fragment,{children:[t.jsx(KF,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),t.jsx(GF,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):d=t.jsxs(t.Fragment,{children:[t.jsx(c,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),t.jsx(GF,{displayMonth:e.displayMonth,id:e.id})]}),t.jsx("div",{className:n.caption,style:i.caption,children:d})}function ZCe(e){var s=_i(),r=s.footer,n=s.styles,a=s.classNames.tfoot;return r?t.jsx("tfoot",{className:a,style:n.tfoot,children:t.jsx("tr",{children:t.jsx("td",{colSpan:8,children:r})})}):t.jsx(t.Fragment,{})}function JCe(e,s,r){for(var n=r?Jx(new Date):up(new Date,{locale:e,weekStartsOn:s}),a=[],i=0;i<7;i++){var o=Ud(n,i);a.push(o)}return a}function eke(){var e=_i(),s=e.classNames,r=e.styles,n=e.showWeekNumber,a=e.locale,i=e.weekStartsOn,o=e.ISOWeek,l=e.formatters.formatWeekdayName,c=e.labels.labelWeekday,d=JCe(a,i,o);return t.jsxs("tr",{style:r.head_row,className:s.head_row,children:[n&&t.jsx("td",{style:r.head_cell,className:s.head_cell}),d.map(function(h,p){return t.jsx("th",{scope:"col",className:s.head_cell,style:r.head_cell,"aria-label":c(h,{locale:a}),children:l(h,{locale:a})},p)})]})}function tke(){var e,s=_i(),r=s.classNames,n=s.styles,a=s.components,i=(e=a?.HeadRow)!==null&&e!==void 0?e:eke;return t.jsx("thead",{style:n.head,className:r.head,children:t.jsx(i,{})})}function ske(e){var s=_i(),r=s.locale,n=s.formatters.formatDay;return t.jsx(t.Fragment,{children:n(e.date,{locale:r})})}var E3=u.createContext(void 0);function rke(e){if(!lN(e.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return t.jsx(E3.Provider,{value:s,children:e.children})}return t.jsx(nke,{initialProps:e.initialProps,children:e.children})}function nke(e){var s=e.initialProps,r=e.children,n=s.selected,a=s.min,i=s.max,o=function(d,h,p){var g,v;
493(g=s.onDayClick)===null||g===void 0||g.call(s,d,h,p);var b=!!(h.selected&&a&&n?.length===a);if(!b){var y=!!(!h.selected&&i&&n?.length===i);if(!y){var w=n?Dte([],n):[];if(h.selected){var j=w.findIndex(function(x){return yu(d,x)});w.splice(j,1)}else w.push(d);(v=s.onSelect)===null||v===void 0||v.call(s,w,d,h,p)}}},l={disabled:[]};n&&l.disabled.push(function(d){var h=i&&n.length>i-1,p=n.some(function(g){return yu(g,d)});return!!(h&&!p)});var c={selected:n,onDayClick:o,modifiers:l};return t.jsx(E3.Provider,{value:c,children:r})}function T3(){var e=u.useContext(E3);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function ake(e,s){var r=s||{},n=r.from,a=r.to;return n&&a?yu(a,e)&&yu(n,e)?void 0:yu(a,e)?{from:a,to:void 0}:yu(n,e)?void 0:NM(n,e)?{from:e,to:a}:{from:n,to:e}:a?NM(e,a)?{from:a,to:e}:{from:e,to:a}:n?Tee(e,n)?{from:e,to:n}:{from:n,to:e}:{from:e,to:void 0}}var A3=u.createContext(void 0);function ike(e){if(!cN(e.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return t.jsx(A3.Provider,{value:s,children:e.children})}return t.jsx(oke,{initialProps:e.initialProps,children:e.children})}function oke(e){var s=e.initialProps,r=e.children,n=s.selected,a=n||{},i=a.from,o=a.to,l=s.min,c=s.max,d=function(v,b,y){var w,j;(w=s.onDayClick)===null||w===void 0||w.call(s,v,b,y);var x=ake(v,n);(j=s.onSelect)===null||j===void 0||j.call(s,x,v,b,y)},h={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(h.range_start=[i],o?(h.range_end=[o],yu(i,o)||(h.range_middle=[{after:i,before:o}])):h.range_end=[i]):o&&(h.range_start=[o],h.range_end=[o]),l&&(i&&!o&&h.disabled.push({after:kP(i,l-1),before:Ud(i,l-1)}),i&&o&&h.disabled.push({after:i,before:Ud(i,l-1)}),!i&&o&&h.disabled.push({after:kP(o,l-1),before:Ud(o,l-1)})),c){if(i&&!o&&(h.disabled.push({before:Ud(i,-c+1)}),h.disabled.push({after:Ud(i,c-1)})),i&&o){var p=Xh(o,i)+1,g=c-p;h.disabled.push({before:kP(i,g)}),h.disabled.push({after:Ud(o,g)})}!i&&o&&(h.disabled.push({before:Ud(o,-c+1)}),h.disabled.push({after:Ud(o,c-1)}))}return t.jsx(A3.Provider,{value:{selected:n,onDayClick:d,modifiers:h},children:r})}function M3(){var e=u.useContext(A3);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function hS(e){return Array.isArray(e)?Dte([],e):e!==void 0?[e]:[]}function lke(e){var s={};return Object.entries(e).forEach(function(r){var n=r[0],a=r[1];s[n]=hS(a)}),s}var Ph;(function(e){e.Outside="outside",e.Disabled="disabled",e.Selected="selected",e.Hidden="hidden",e.Today="today",e.RangeStart="range_start",e.RangeEnd="range_end",e.RangeMiddle="range_middle"})(Ph||(Ph={}));var cke=Ph.Selected,Lp=Ph.Disabled,dke=Ph.Hidden,uke=Ph.Today,DP=Ph.RangeEnd,LP=Ph.RangeMiddle,$P=Ph.RangeStart,mke=Ph.Outside;function hke(e,s,r){var n,a=(n={},n[cke]=hS(e.selected),n[Lp]=hS(e.disabled),n[dke]=hS(e.hidden),n[uke]=[e.today],n[DP]=[],n[LP]=[],n[$P]=[],n[mke]=[],n);return e.fromDate&&a[Lp].push({before:e.fromDate}),e.toDate&&a[Lp].push({after:e.toDate}),lN(e)?a[Lp]=a[Lp].concat(s.modifiers[Lp]):cN(e)&&(a[Lp]=a[Lp].concat(r.modifiers[Lp]),a[$P]=r.modifiers[$P],a[LP]=r.modifiers[LP],a[DP]=r.modifiers[DP]),a}var Ute=u.createContext(void 0);function pke(e){var s=_i(),r=T3(),n=M3(),a=hke(s,r,n),i=lke(s.modifiers),o=sn(sn({},a),i);return t.jsx(Ute.Provider,{value:o,children:e.children})}function zte(){var e=u.useContext(Ute);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function fke(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function gke(e){return!!(e&&typeof e=="object"&&"from"in e)}function xke(e){return!!(e&&typeof e=="object"&&"after"in e)}function vke(e){return!!(e&&typeof e=="object"&&"before"in e)}function yke(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function bke(e,s){var r,n=s.from,a=s.to;if(n&&a){var i=Xh(a,n)<0;i&&(r=[a,n],n=r[0],a=r[1]);var o=Xh(e,n)>=0&&Xh(a,e)>=0;return o}return a?yu(a,e):n?yu(n,e):!1}function wke(e){return S3(e)}function jke(e){return Array.isArray(e)&&e.every(S3)}function Nke(e,s){return s.some(function(r){if(typeof r=="boolean")return r;if(wke(r))return yu(e,r);if(jke(r))return r.includes(e);if(gke(r))return bke(e,r);if(yke(r))return r.dayOfWeek.includes(e.getDay());if(fke(r)){var n=Xh(r.before,e),a=Xh(r.after,e),i=n>0,o=a<0,l=NM(r.before,r.after);return l?o&&i:i||o}return xke(r)?Xh(e,r.after)>0:vke(r)?Xh(r.before,e)>0:typeof r=="function"?r(e):!1})}function R3(e,s,r){var n=Object.keys(s).reduce(function(i,o){var l=s[o];return Nke(e,l)&&i.push(o),i},[]),a={};
493return n.forEach(function(i){return a[i]=!0}),r&&!_3(e,r)&&(a.outside=!0),a}function Ske(e,s){for(var r=ju(e[0]),n=f_(e[e.length-1]),a,i,o=r;o<=n;){var l=R3(o,s),c=!l.disabled&&!l.hidden;if(!c){o=Ud(o,1);continue}if(l.selected)return o;l.today&&!i&&(i=o),a||(a=o),o=Ud(o,1)}return i||a}var Cke=365;function Hte(e,s){var r=s.moveBy,n=s.direction,a=s.context,i=s.modifiers,o=s.retry,l=o===void 0?{count:0,lastFocused:e}:o,c=a.weekStartsOn,d=a.fromDate,h=a.toDate,p=a.locale,g={day:Ud,week:jM,month:kh,year:tNe,startOfWeek:function(w){return a.ISOWeek?Jx(w):up(w,{locale:p,weekStartsOn:c})},endOfWeek:function(w){return a.ISOWeek?See(w):C3(w,{locale:p,weekStartsOn:c})}},v=g[r](e,n==="after"?1:-1);n==="before"&&d?v=sNe([d,v]):n==="after"&&h&&(v=rNe([h,v]));var b=!0;if(i){var y=R3(v,i);b=!y.disabled&&!y.hidden}return b?v:l.count>Cke?l.lastFocused:Hte(v,{moveBy:r,direction:n,context:a,modifiers:i,retry:sn(sn({},l),{count:l.count+1})})}var qte=u.createContext(void 0);function kke(e){var s=dN(),r=zte(),n=u.useState(),a=n[0],i=n[1],o=u.useState(),l=o[0],c=o[1],d=Ske(s.displayMonths,r),h=a??(l&&s.isDateDisplayed(l))?l:d,p=function(){c(a),i(void 0)},g=function(w){i(w)},v=_i(),b=function(w,j){if(a){var x=Hte(a,{moveBy:w,direction:j,context:v,modifiers:r});yu(a,x)||(s.goToDate(x,a),g(x))}},y={focusedDay:a,focusTarget:h,blur:p,focus:g,focusDayAfter:function(){return b("day","after")},focusDayBefore:function(){return b("day","before")},focusWeekAfter:function(){return b("week","after")},focusWeekBefore:function(){return b("week","before")},focusMonthBefore:function(){return b("month","before")},focusMonthAfter:function(){return b("month","after")},focusYearBefore:function(){return b("year","before")},focusYearAfter:function(){return b("year","after")},focusStartOfWeek:function(){return b("startOfWeek","before")},focusEndOfWeek:function(){return b("endOfWeek","after")}};return t.jsx(qte.Provider,{value:y,children:e.children})}function I3(){var e=u.useContext(qte);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function _ke(e,s){var r=zte(),n=R3(e,r,s);return n}var O3=u.createContext(void 0);function Pke(e){if(!S_(e.initialProps)){var s={selected:void 0};return t.jsx(O3.Provider,{value:s,children:e.children})}return t.jsx(Eke,{initialProps:e.initialProps,children:e.children})}function Eke(e){var s=e.initialProps,r=e.children,n=function(i,o,l){var c,d,h;if((c=s.onDayClick)===null||c===void 0||c.call(s,i,o,l),o.selected&&!s.required){(d=s.onSelect)===null||d===void 0||d.call(s,void 0,i,o,l);return}(h=s.onSelect)===null||h===void 0||h.call(s,i,i,o,l)},a={selected:s.selected,onDayClick:n};return t.jsx(O3.Provider,{value:a,children:r})}function Vte(){var e=u.useContext(O3);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function Tke(e,s){var r=_i(),n=Vte(),a=T3(),i=M3(),o=I3(),l=o.focusDayAfter,c=o.focusDayBefore,d=o.focusWeekAfter,h=o.focusWeekBefore,p=o.blur,g=o.focus,v=o.focusMonthBefore,b=o.focusMonthAfter,y=o.focusYearBefore,w=o.focusYearAfter,j=o.focusStartOfWeek,x=o.focusEndOfWeek,C=function(G){var z,Z,ee,Q;S_(r)?(z=n.onDayClick)===null||z===void 0||z.call(n,e,s,G):lN(r)?(Z=a.onDayClick)===null||Z===void 0||Z.call(a,e,s,G):cN(r)?(ee=i.onDayClick)===null||ee===void 0||ee.call(i,e,s,G):(Q=r.onDayClick)===null||Q===void 0||Q.call(r,e,s,G)},k=function(G){var z;g(e),(z=r.onDayFocus)===null||z===void 0||z.call(r,e,s,G)},S=function(G){var z;p(),(z=r.onDayBlur)===null||z===void 0||z.call(r,e,s,G)},_=function(G){var z;(z=r.onDayMouseEnter)===null||z===void 0||z.call(r,e,s,G)},A=function(G){var z;(z=r.onDayMouseLeave)===null||z===void 0||z.call(r,e,s,G)},T=function(G){var z;(z=r.onDayPointerEnter)===null||z===void 0||z.call(r,e,s,G)},M=function(G){var z;(z=r.onDayPointerLeave)===null||z===void 0||z.call(r,e,s,G)},R=function(G){var z;(z=r.onDayTouchCancel)===null||z===void 0||z.call(r,e,s,G)},D=function(G){var z;(z=r.onDayTouchEnd)===null||z===void 0||z.call(r,e,s,G)},$=function(G){var z;(z=r.onDayTouchMove)===null||z===void 0||z.call(r,e,s,G)},O=function(G){var z;(z=r.onDayTouchStart)===null||z===void 0||z.call(r,e,s,G)},q=function(G){var z;(z=r.onDayKeyUp)===null||z===void 0||z.call(r,e,s,G)},V=function(G){var z;switch(G.key){case"ArrowLeft":G.preventDefault(),G.stopPropagation(),r.dir==="rtl"?l(
493):c();break;case"ArrowRight":G.preventDefault(),G.stopPropagation(),r.dir==="rtl"?c():l();break;case"ArrowDown":G.preventDefault(),G.stopPropagation(),d();break;case"ArrowUp":G.preventDefault(),G.stopPropagation(),h();break;case"PageUp":G.preventDefault(),G.stopPropagation(),G.shiftKey?y():v();break;case"PageDown":G.preventDefault(),G.stopPropagation(),G.shiftKey?w():b();break;case"Home":G.preventDefault(),G.stopPropagation(),j();break;case"End":G.preventDefault(),G.stopPropagation(),x();break}(z=r.onDayKeyDown)===null||z===void 0||z.call(r,e,s,G)},K={onClick:C,onFocus:k,onBlur:S,onKeyDown:V,onKeyUp:q,onMouseEnter:_,onMouseLeave:A,onPointerEnter:T,onPointerLeave:M,onTouchCancel:R,onTouchEnd:D,onTouchMove:$,onTouchStart:O};return K}function Ake(){var e=_i(),s=Vte(),r=T3(),n=M3(),a=S_(e)?s.selected:lN(e)?r.selected:cN(e)?n.selected:void 0;return a}function Mke(e){return Object.values(Ph).includes(e)}function Rke(e,s){var r=[e.classNames.day];return Object.keys(s).forEach(function(n){var a=e.modifiersClassNames[n];if(a)r.push(a);else if(Mke(n)){var i=e.classNames["day_".concat(n)];i&&r.push(i)}}),r}function Ike(e,s){var r=sn({},e.styles.day);return Object.keys(s).forEach(function(n){var a;r=sn(sn({},r),(a=e.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function Oke(e,s,r){var n,a,i,o=_i(),l=I3(),c=_ke(e,s),d=Tke(e,c),h=Ake(),p=!!(o.onDayCl
493ick||o.mode!=="default");u.useEffect(function(){var _;c.outside||l.focusedDay&&p&&yu(l.focusedDay,e)&&((_=r.current)===null||_===void 0||_.focus())},[l.focusedDay,e,r,p,c.outside]);var g=Rke(o,c).join(" "),v=Ike(o,c),b=!!(c.outside&&!o.showOutsideDays||c.hidden),y=(i=(a=o.components)===null||a===void 0?void 0:a.DayContent)!==null&&i!==void 0?i:ske,w=t.jsx(y,{date:e,displayMonth:s,activeModifiers:c}),j={style:v,className:g,children:w,role:"gridcell"},x=l.focusTarget&&yu(l.focusTarget,e)&&!c.outside,C=l.focusedDay&&yu(l.focusedDay,e),k=sn(sn(sn({},j),(n={disabled:c.disabled,role:"gridcell"},n["aria-selected"]=c.selected,n.tabIndex=C||x?0:-1,n)),d),S={isButton:p,isHidden:b,activeModifiers:c,selectedDays:h,buttonProps:k,divProps:j};return S}function Dke(e){var s=u.useRef(null),r=Oke(e.date,e.displayMonth,s);return r.isHidden?t.jsx("div",{role:"gridcell"}):r.isButton?t.jsx(xC,sn({name:"day",ref:s},r.buttonProps)):t.jsx("div",sn({},r.divProps))}function Lke(e){var s=e.number,r=e.dates,n=_i(),a=n.onWeekNumberClick,i=n.styles,o=n.classNames,l=n.locale,c=n.labels.labelWeekNumber,d=n.formatters.formatWeekNumber,h=d(Number(s),{locale:l});if(!a)return t.jsx("span",{className:o.weeknumber,style:i.weeknumber,children:h});var p=c(Number(s),{locale:l}),g=function(v){a(s,r,v)};return t.jsx(xC,{name:"week-number","aria-label":p,className:o.weeknumber,style:i.weeknumber,onClick:g,children:h})}function $ke(e){var s,r,n=_i(),a=n.styles,i=n.classNames,o=n.showWeekNumber,l=n.components,c=(s=l?.Day)!==null&&s!==void 0?s:Dke,d=(r=l?.WeekNumber)!==null&&r!==void 0?r:Lke,h;return o&&(h=t.jsx("td",{className:i.cell,style:a.cell,children:t.jsx(d,{number:e.weekNumber,dates:e.dates})})),t.jsxs("tr",{className:i.row,style:a.row,children:[h,e.dates.map(function(p){return t.jsx("td",{className:i.cell,style:a.cell,role:"presentation",children:t.jsx(c,{displayMonth:e.displayMonth,date:p})},d1e(p))})]})}function YF(e,s,r){for(var n=r?.ISOWeek?See(s):C3(s,r),a=r?.ISOWeek?Jx(e):up(e,r),i=Xh(n,a),o=[],l=0;l<=i;l++)o.push(Ud(a,l));var c=o.reduce(function(d,h){var p=r?.ISOWeek?Cee(h):_ee(h,r),g=d.find(function(v){return v.weekNumber===p});return g?(g.dates.push(h),d):(d.push({weekNumber:p,dates:[h]}),d)},[]);return c}function Fke(e,s){var r=YF(ju(e),f_(e),s);if(s?.useFixedWeeks){var n=m1e(e,s);if(n<6){var a=r[r.length-1],i=a.dates[a.dates.length-1],o=jM(i,6-n),l=YF(jM(i,1),o,s);r.push.apply(r,l)}}return r}function Bke(e){var s,r,n,a=_i(),i=a.locale,o=a.classNames,l=a.styles,c=a.hideHead,d=a.fixedWeeks,h=a.components,p=a.weekStartsOn,g=a.firstWeekContainsDate,v=a.ISOWeek,b=Fke(e.displayMonth,{useFixedWeeks:!!d,ISOWeek:v,locale:i,weekStartsOn:p,firstWeekContainsDate:g}),y=(s=h?.Head)!==null&&s!==void 0?s:tke,w=(r=h?.Row)!==null&&r!==void 0?r:$ke,j=(n=h?.Footer)!==null&&n!==void 0?n:ZCe;return t.jsxs("table",{id:e.id,className:o.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!c&&t.jsx(y,{}),t.jsx("tbody",{className:o.tbody,style:l.tbody,children:b.map(function(x){return t.jsx(w,{displayMonth:e.displayMonth,dates:x.dates,weekNumber:x.weekNumber},x.weekNumber)})}),t.jsx(j,{displayMonth:e.displayMonth})]})}function Uke(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var zke=Uke()?u.useLayoutEffect:u.useEffect,FP=!1,Hke=0;function QF(){return"react-day-picker-".concat(++Hke)}function qke(e){var s,r=e??(FP?QF():null),n=u.useState(r),a=n[0],i=n[1];return zke(function(){a===null&&i(QF())},[]),u.useEffect(function(){FP===!1&&(FP=!0)},[]),(s=e??a)!==null&&s!==void 0?s:void 0}function Vke(e){var s,r,n=_i(),a=n.dir,i=n.classNames,o=n.styles,l=n.components,c=dN().displayMonths,d=qke(n.id?"".concat(n.id,"-").concat(e.displayIndex):void 0),h=n.id?"".concat(n.id,"-grid-").concat(e.displayIndex):void 0,p=[i.month],g=o.month,v=e.displayIndex===0,b=e.displayIndex===c.length-1,y=!v&&!b;a==="rtl"&&(s=[v,b],b=s[0],v=s[1]),v&&(p.push(i.caption_start),g=sn(sn({},g),o.caption_start)),b&&(p.push(i.caption_end),g=sn(sn({},g),o.caption_end)),y&&(p.push(i.caption_between),g=sn(sn({},g),o.caption_between));var w=(r=l?.Caption)!==null&&r!==void 0?r:XCe;return t.jsxs("div",{className:p.join(" "),style:g,children:[t.jsx(w,{id:d,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),t.jsx(Bke,{id:h,"aria-labelledby":d,displayMonth:e.displayMonth})]},e.displayIndex)}function Wke(e){var s=_i(),r=s.classNames,n=s.styles;return t.jsx("div",{className:r.months,style:n.months,children:e.children})}function Kke(e){var s,r,n=e.initialProps,a=_i(),i=I3(),o=dN(),l=u.useState(!1),c=l[0],d=l[1];u.useEffect(function(){a.initialFocus&&i.focusTarget&&(c||(i.focus(i.focusTarget),d(!0)))},[a.initialFocus,c,i.focus,i.focusTarget,i]);var h=[a.classNames.root,a.className];a.numberOfMonths>1&&h.push(a.classNames.multiple_months),a.showWeekNumber&&h.push(a.classNames.with_weeknumber);var p=sn(sn({},a.styles.root),a.style),g=Object.keys(n).filter(function(b){return b.startsWith("data-")}).reduce(function(b,y){var w;return sn(sn({},b),(w={},w[y]=n[y],w))},{}),v=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:Wke;return t.jsx("div",sn({className:h.join(" "),style:p,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},g,{children:t.jsx(v,{children:o.displayMonths.map(function(b,y){return t.jsx(Vke,{displayIndex:y,displayMonth:b},y)})})}))}function Gke(e){var s=e.children,r=vCe(e,["children"]);return t.jsx(LCe,{initialProps:r,children:t.jsx(KCe,{children:t.jsx(Pke,{initialProps:r,children:t.jsx(rke,{initialProps:r,children:t.jsx(ike,{initialProps:r,children:t.jsx(pke,{children:t.jsx(kke,{children:s})})})})})})})}function Yke(e){return t.jsx(Gke,sn({},e,{children:t.jsx(Kke,{initialProps:e})}))}function _m({className:e,classNames:s,showOutsideDays:r=!0,...n}){return t.jsx(Yke,{showOutsideDays:r,className:Cs("p-3",e),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:sp
493ace-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Cs(H0({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Cs(H0({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...s},components:{IconLeft:({className:a,...i})=>t.jsx(Kl,{className:Cs("h-4 w-4",a),...i}),IconRight:({className:a,...i})=>t.jsx(hi,{className:Cs("h-4 w-4",a),...i})},...n})}_m.displayName="Calendar";function Wte(e,s,r,n=1){const a=Math.max(1,e),i=s==="cloud"?a<=1?100:a<=2?175:a<=4?275:a<=8?375:a<=12?450:500:a<=1?60:a<=2?90:a<=4?140:a<=8?200:a<=12?240:300,o=Math.max(1,Math.min(5,r)),l=Math.min(1,Math.max(.1,n));return Math.max(25,Math.round(i*o*l))}function Kte(e,s,r=1,n){const a=e==="cloud"?30:40,i=n&&n>0?Math.max(.25,n/3600):2,o=Math.min(1,i/4),l=Math.max(5,Math.round(a*o)),c=Math.max(1,Math.min(5,s)),d=Math.min(1,Math.max(.1,r));return Math.max(5,Math.round(l*c*d))}function vC(e){return e<=0?0:Math.max(1,Math.ceil(e/25))}function Gte(e){let s=1;return e.totalCameras>0&&e.selectedCameras>0&&e.selectedCameras<e.totalCameras&&(s*=Math.max(.15,e.selectedCameras/e.totalCameras)),e.selectedSeverity&&e.selectedSeverity!=="all"&&(s*=.6),e.selectedLabels&&e.selectedLabels.length>0&&(s*=.75),s}var BP,XF;function Cu(){if(XF)return BP;XF=1;var e=Array.isArray;return BP=e,BP}var UP,ZF;function Yte(){if(ZF)return UP;ZF=1;var e=typeof XN=="object"&&XN&&XN.Object===Object&&XN;return UP=e,UP}var zP,JF;function gp(){if(JF)return zP;JF=1;var e=Yte(),s=typeof self=="object"&&self&&self.Object===Object&&self,r=e||s||Function("return this")();return zP=r,zP}var HP,eB;function uN(){if(eB)return HP;eB=1;var e=gp(),s=e.Symbol;return HP=s,HP}var qP,tB;function Qke(){if(tB)return qP;tB=1;var e=uN(),s=Object.prototype,r=s.hasOwnProperty,n=s.toString,a=e?e.toStringTag:void 0;function i(o){var l=r.call(o,a),c=o[a];try{o[a]=void 0;var d=!0}catch{}var h=n.call(o);return d&&(l?o[a]=c:delete o[a]),h}return qP=i,qP}var VP,sB;function Xke(){if(sB)return VP;sB=1;var e=Object.prototype,s=e.toString;function r(n){return s.call(n)}return VP=r,VP}var WP,rB;function Cf(){if(rB)return WP;rB=1;var e=uN(),s=Qke(),r=Xke(),n="[object Null]",a="[object Undefined]",i=e?e.toStringTag:void 0;function o(l){return l==null?l===void 0?a:n:i&&i in Object(l)?s(l):r(l)}return WP=o,WP}var KP,nB;function kf(){if(nB)return KP;nB=1;function e(s){return s!=null&&typeof s=="object"}return KP=e,KP}var GP,aB;function Db(){if(aB)return GP;aB=1;var e=Cf(),s=kf(),r="[object Symbol]";function n(a){return typeof a=="symbol"||s(a)&&e(a)==r}return GP=n,GP}var YP,iB;function D3(){if(iB)return YP;iB=1;var e=Cu(),s=Db(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function a(i,o){if(e(i))return!1;var l=typeof i;return l=="number"||l=="symbol"||l=="boolean"||i==null||s(i)?!0:n.test(i)||!r.test(i)||o!=null&&i in Object(o)}return YP=a,YP}var QP,oB;function Fg(){if(oB)return QP;oB=1;function e(s){var r=typeof s;return s!=null&&(r=="object"||r=="function")}return QP=e,QP}var XP,lB;function L3(){if(lB)return XP;lB=1;var e=Cf(),s=Fg(),r="[object AsyncFunction]",n="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function o(l){if(!s(l))return!1;var c=e(l);return c==n||c==a||c==r||c==i}return XP=o,XP}
vendor: 7,041 bytes, line 493
493var ZP,cB;function Zke(){if(cB)return ZP;cB=1;var e=gp(),s=e["__core-js_shared__"];return ZP=s,ZP}var JP,dB;function Jke(){if(dB)return JP;dB=1;var e=Zke(),s=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!s&&s in n}return JP=r,JP}var eE,uB;function Qte(){if(uB)return eE;uB=1;var e=Function.prototype,s=e.toString;function r(n){if(n!=null){try{return s.call(n)}catch{}try{return n+""}catch{}}return""}return eE=r,eE}var tE,mB;function e_e(){if(mB)return tE;mB=1;var e=L3(),s=Jke(),r=Fg(),n=Qte(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,o=Function.prototype,l=Object.prototype,c=o.toString,d=l.hasOwnProperty,h=RegExp("^"+c.call(d).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(g){if(!r(g)||s(g))return!1;var v=e(g)?h:i;return v.test(n(g))}return tE=p,tE}var sE,hB;function t_e(){if(hB)return sE;hB=1;function e(s,r){return s?.[r]}return sE=e,sE}var rE,pB;function mv(){if(pB)return rE;pB=1;var e=e_e(),s=t_e();function r(n,a){var i=s(n,a);return e(i)?i:void 0}return rE=r,rE}var nE,fB;function C_(){if(fB)return nE;fB=1;var e=mv(),s=e(Object,"create");return nE=s,nE}var aE,gB;function s_e(){if(gB)return aE;gB=1;var e=C_();function s(){this.__data__=e?e(null):{},this.size=0}return aE=s,aE}var iE,xB;function r_e(){if(xB)return iE;xB=1;function e(s){var r=this.has(s)&&delete this.__data__[s];return this.size-=r?1:0,r}return iE=e,iE}var oE,vB;function n_e(){if(vB)return oE;vB=1;var e=C_(),s="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function a(i){var o=this.__data__;if(e){var l=o[i];return l===s?void 0:l}return n.call(o,i)?o[i]:void 0}return oE=a,oE}var lE,yB;function a_e(){if(yB)return lE;yB=1;var e=C_(),s=Object.prototype,r=s.hasOwnProperty;function n(a){var i=this.__data__;return e?i[a]!==void 0:r.call(i,a)}return lE=n,lE}var cE,bB;function i_e(){if(bB)return cE;bB=1;var e=C_(),s="__lodash_hash_undefined__";function r(n,a){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&a===void 0?s:a,this}return cE=r,cE}var dE,wB;function o_e(){if(wB)return dE;wB=1;var e=s_e(),s=r_e(),r=n_e(),n=a_e(),a=i_e();function i(o){var l=-1,c=o==null?0:o.length;for(this.clear();++l<c;){var d=o[l];this.set(d[0],d[1])}}return i.prototype.clear=e,i.prototype.delete=s,i.prototype.get=r,i.prototype.has=n,i.prototype.set=a,dE=i,dE}var uE,jB;function l_e(){if(jB)return uE;jB=1;function e(){this.__data__=[],this.size=0}return uE=e,uE}var mE,NB;function $3(){if(NB)return mE;NB=1;function e(s,r){return s===r||s!==s&&r!==r}return mE=e,mE}var hE,SB;function k_(){if(SB)return hE;SB=1;var e=$3();function s(r,n){for(var a=r.length;a--;)if(e(r[a][0],n))return a;return-1}return hE=s,hE}var pE,CB;function c_e(){if(CB)return pE;CB=1;var e=k_(),s=Array.prototype,r=s.splice;function n(a){var i=this.__data__,o=e(i,a);if(o<0)return!1;var l=i.length-1;return o==l?i.pop():r.call(i,o,1),--this.size,!0}return pE=n,pE}var fE,kB;function d_e(){if(kB)return fE;kB=1;var e=k_();function s(r){var n=this.__data__,a=e(n,r);return a<0?void 0:n[a][1]}return fE=s,fE}var gE,_B;function u_e(){if(_B)return gE;_B=1;var e=k_();function s(r){return e(this.__data__,r)>-1}return gE=s,gE}var xE,PB;function m_e(){if(PB)return xE;PB=1;var e=k_();function s(r,n){var a=this.__data__,i=e(a,r);return i<0?(++this.size,a.push([r,n])):a[i][1]=n,this}return xE=s,xE}var vE,EB;function __(){if(EB)return vE;EB=1;var e=l_e(),s=c_e(),r=d_e(),n=u_e(),a=m_e();function i(o){var l=-1,c=o==null?0:o.length;for(this.clear();++l<c;){var d=o[l];this.set(d[0],d[1])}}return i.prototype.clear=e,i.prototype.delete=s,i.prototype.get=r,i.prototype.has=n,i.prototype.set=a,vE=i,vE}var yE,TB;function F3(){if(TB)return yE;TB=1;var e=mv(),s=gp(),r=e(s,"Map");return yE=r,yE}var bE,AB;function h_e(){if(AB)return bE;AB=1;var e=o_e(),s=__(),r=F3();function n(){this.size=0,this.__data__={hash:new e,map:new(r||s),string:new e}}return bE=n,bE}var wE,MB;function p_e(){if(MB)return wE;MB=1;function e(s){var r=typeof s;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?s!=="__proto__":s===null}return wE=e,wE}var jE,RB;function P_(){if(RB)return jE;RB=1;var e=p_e();function s(r,n){var a=r.__data__;return e(n)?a[typeof n=="string"?"string":"hash"]:a.map}return jE=s,jE}var NE,IB;function f_e(){if(IB)return NE;IB=1;var e=P_();function s(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return NE=s,NE}var SE,OB;function g_e(){if(OB)return SE;OB=1;var e=P_();function s(r){return e(this,r).get(r)}return SE=s,SE}var CE,DB;function x_e(){if(DB)return CE;DB=1;var e=P_();function s(r){return e(this,r).has(r)}return CE=s,CE}var kE,LB;function v_e(){if(LB)return kE;LB=1;var e=P_();function s(r,n){var a=e(this,r),i=a.size;return a.set(r,n),this.size+=a.size==i?0:1,this}return kE=s,kE}var _E,$B;function B3(){if($B)return _E;$B=1;var e=h_e(),s=f_e(),r=g_e(),n=x_e(),a=v_e();function i(o){var l=-1,c=o==null?0:o.length;for(this.clear();++l<c;){var d=o[l];this.set(d[0],d[1])}}return i.prototype.clear=e,i.prototype.delete=s,i.prototype.get=r,i.prototype.has=n,i.prototype.set=a,_E=i,_E}var PE,FB;function Xte(){if(FB)return PE;FB=1;var e=B3(),s="Expected a function";function r(n,a){if(typeof n!="function"||a!=null&&typeof a!="function")throw new TypeError(s);var i=function(){var o=arguments,l=a?a.apply(this,o):o[0],c=i.cache;if(c.has(l))return c.get(l);var d=n.apply(this,o);return i.cache=c.set(l,d)||c,d};return i.cache=new(r.Cache||e),i}return r.Cache=e,PE=r,PE}var EE,BB;function y_e(){if(BB)return EE;BB=1;var e=Xte(),s=500;function r(n){var a=e(n,function(o){return i.size===s&&i.clear(),o}),i=a.cache;return a}return EE=r,EE}var TE,UB;function b_e(){if(UB)return TE;UB=1;var e=y_e(),s=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(a){var i=[];return a.charCodeAt(0)===46&&i.push(""),a.replace(s,function(o,l,c,d){i.push(c?d.replace(r,"$1"):l||o)}),i});return TE=n,TE}var AE,zB;function U3(){if(zB)return AE;zB=1;function e(s,r){for(var n=-1,a=s==null?0:s.length,i=Array(a);++n<a;)i[n]=r(s[n],n,s);return i}return AE=e,AE}var ME,HB;function w_e(){if(HB)return ME;HB=1;var e=uN(),s=U3(),r=Cu(),n=Db(),a=e?e.prototype:void 0,i=a?a.toString:void 0;function o(l){if(typeof l=="string")return l;if(r(l))return s(l,o)+"";if(n(l))return i?i.call(l):"";var c=l+"";return c=="0"&&1/l==-1/0?"-0":c}return ME=o,ME}var RE,qB;function Zte(){if(qB)return RE;qB=1;var e=w_e();function s(r){return r==null?"":e(r)}return RE=s,RE}var IE,VB;function Jte(){if(VB)return IE;VB=1;var e=Cu(),s=D3(),r=b_e(),n=Zte();function a(i,o){return e(i)?i:s(i,o)?[i]:r(n(i))}return IE=a,IE}var OE,WB;function E_(){if(WB)return OE;WB=1;var e=Db();function s(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return OE=s,OE}var DE,KB;function z3(){if(KB)return DE;KB=1;var e=Jte(),s=E_();function r(n,a){a=e(a,n);for(var i=0,o=a.length;n!=null&&i<o;)n=n[s(a[i++])];return i&&i==o?n:void 0}return DE=r,DE}var LE,GB;
vendor: 5,587 bytes, line 493
493function ese(){if(GB)return LE;GB=1;var e=z3();function s(r,n,a){var i=r==null?void 0:e(r,n);return i===void 0?a:i}return LE=s,LE}var j_e=ese();const em=ei(j_e);var $E,YB;function N_e(){if(YB)return $E;YB=1;function e(s){return s==null}return $E=e,$E}var S_e=N_e();const Tn=ei(S_e);var FE,QB;function C_e(){if(QB)return FE;QB=1;var e=Cf(),s=Cu(),r=kf(),n="[object String]";function a(i){return typeof i=="string"||!s(i)&&r(i)&&e(i)==n}return FE=a,FE}var k_e=C_e();const mN=ei(k_e);var __e=L3();const Qr=ei(__e);var P_e=Fg();const Lb=ei(P_e);var BE={exports:{}},Ga={};var XB;function E_e(){if(XB)return Ga;XB=1;var e=Symbol.for("react.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.server_context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),b;b=Symbol.for("react.module.reference");function y(w){if(typeof w=="object"&&w!==null){var j=w.$$typeof;switch(j){case e:switch(w=w.type,w){case r:case a:case n:case d:case h:return w;default:switch(w=w&&w.$$typeof,w){case l:case o:case c:case g:case p:case i:return w;default:return j}}case s:return j}}}return Ga.ContextConsumer=o,Ga.ContextProvider=i,Ga.Element=e,Ga.ForwardRef=c,Ga.Fragment=r,Ga.Lazy=g,Ga.Memo=p,Ga.Portal=s,Ga.Profiler=a,Ga.StrictMode=n,Ga.Suspense=d,Ga.SuspenseList=h,Ga.isAsyncMode=function(){return!1},Ga.isConcurrentMode=function(){return!1},Ga.isContextConsumer=function(w){return y(w)===o},Ga.isContextProvider=function(w){return y(w)===i},Ga.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===e},Ga.isForwardRef=function(w){return y(w)===c},Ga.isFragment=function(w){return y(w)===r},Ga.isLazy=function(w){return y(w)===g},Ga.isMemo=function(w){return y(w)===p},Ga.isPortal=function(w){return y(w)===s},Ga.isProfiler=function(w){return y(w)===a},Ga.isStrictMode=function(w){return y(w)===n},Ga.isSuspense=function(w){return y(w)===d},Ga.isSuspenseList=function(w){return y(w)===h},Ga.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===r||w===a||w===n||w===d||w===h||w===v||typeof w=="object"&&w!==null&&(w.$$typeof===g||w.$$typeof===p||w.$$typeof===i||w.$$typeof===o||w.$$typeof===c||w.$$typeof===b||w.getModuleId!==void 0)},Ga.typeOf=y,Ga}var ZB;function T_e(){return ZB||(ZB=1,BE.exports=E_e()),BE.exports}var A_e=T_e(),UE,JB;function tse(){if(JB)return UE;JB=1;var e=Cf(),s=kf(),r="[object Number]";function n(a){return typeof a=="number"||s(a)&&e(a)==r}return UE=n,UE}var zE,e8;function M_e(){if(e8)return zE;e8=1;var e=tse();function s(r){return e(r)&&r!=+r}return zE=s,zE}var R_e=M_e();const $b=ei(R_e);var I_e=tse();const O_e=ei(I_e);var Vd=function(s){return s===0?0:s>0?1:-1},_x=function(s){return mN(s)&&s.indexOf("%")===s.length-1},bs=function(s){return O_e(s)&&!$b(s)},Gl=function(s){return bs(s)||mN(s)},D_e=0,Fb=function(s){var r=++D_e;return"".concat(s||"").concat(r)},Wd=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!bs(s)&&!mN(s))return n;var i;if(_x(s)){var o=s.indexOf("%");i=r*parseFloat(s.slice(0,o))/100}else i=+s;return $b(i)&&(i=n),a&&i>r&&(i=r),i},ug=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},L_e=function(s){if(!Array.isArray(s))return!1;for(var r=s.length,n={},a=0;a<r;a++)if(!n[s[a]])n[s[a]]=!0;else return!0;return!1},gu=function(s,r){return bs(s)&&bs(r)?function(n){return s+n*(r-s)}:function(){return r}};function yC(e,s,r){return!e||!e.length?null:e.find(function(n){return n&&(typeof s=="function"?s(n):em(n,s))===r})}function fy(e,s){for(var r in e)if({}.hasOwnProperty.call(e,r)&&(!{}.hasOwnProperty.call(s,r)||e[r]!==s[r]))return!1;for(var n in s)if({}.hasOwnProperty.call(s,n)&&!{}.hasOwnProperty.call(e,n))return!1;return!0}function TM(e){"@babel/helpers - typeof";return TM=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},TM(e)}var $_e=["viewBox","children"],F_e=["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
493dering","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"],t8=["points","pathLength"],HE={svg:$_e,polygon:t8,polyline:t8},H3=["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
493Capture","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"],bC=function(s,r){if(!s||typeof s=="function"||typeof s=="boolean")return null;var n=s;if(u.isValidElement(s)&&(n=s.props),!Lb(n))return null;var a={};return Object.keys(n).forEach(function(i){H3.includes(i)&&(a[i]=r||function(o){return n[i](n,o)})}),a},B_e=function(s,r,n){return function(a){return s(r,n,a),null}},ev=function(s,r,n){if(!Lb(s)||TM(s)!=="object")return null;var a=null;return Object.keys(s).forEach(function(i){var o=s[i];H3.includes(i)&&typeof o=="function"&&(a||(a={}),a[i]=B_e(o,r,n))}),a},U_e=["children"],z_e=["children"];function s8(e,s){if(e==null)return{};var r=H_e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function H_e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function AM(e){"@babel/helpers - typeof";return AM=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},AM(e)}var r8={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"},lf=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},n8=null,qE=null,q3=function e(s){if(s===n8&&Array.isArray(qE))return qE;var r=[];return u.Children.forEach(s,function(n){Tn(n)||(A_e.isFragment(n)?r=r.concat(e(n.props.children)):r.push(n))}),qE=r,n8=s,r};function Rm(e,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return lf(a)}):n=[lf(s)],q3(e).forEach(function(a){var i=em(a,"type.displayName")||em(a,"type.name");n.indexOf(i)!==-1&&r.push(a)}),r}function Wu(e,s){var r=Rm(e,s);return r&&r[0]}var a8=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!bs(n)||n<=0||!bs(a)||a<=0)},q_e=["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"],V_e=function(s){return s&&s.type&&mN(s.type)&&q_e.indexOf(s.type)>=0},W_e=function(s){return s&&AM(s)==="object"&&"clipDot"in s},K_e=function(s,r,n,a){var i,o=(i=HE?.[a])!==null&&i!==void 0?i:[];return r.startsWith("data-")||!Qr(s)&&(a&&o.includes(r)||F_e.includes(r))||n&&H3.includes(r)},Mr=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(u.isValidElement(s)&&(a=s.props),!Lb(a))return null;var i={};
vendor: 4,244 bytes, line 493
493return Object.keys(a).forEach(function(o){var l;K_e((l=a)===null||l===void 0?void 0:l[o],o,r,n)&&(i[o]=a[o])}),i},MM=function e(s,r){if(s===r)return!0;var n=u.Children.count(s);if(n!==u.Children.count(r))return!1;if(n===0)return!0;if(n===1)return i8(Array.isArray(s)?s[0]:s,Array.isArray(r)?r[0]:r);for(var a=0;a<n;a++){var i=s[a],o=r[a];if(Array.isArray(i)||Array.isArray(o)){if(!e(i,o))return!1}else if(!i8(i,o))return!1}return!0},i8=function(s,r){if(Tn(s)&&Tn(r))return!0;if(!Tn(s)&&!Tn(r)){var n=s.props||{},a=n.children,i=s8(n,U_e),o=r.props||{},l=o.children,c=s8(o,z_e);return a&&l?fy(i,c)&&MM(a,l):!a&&!l?fy(i,c):!1}return!1},o8=function(s,r){var n=[],a={};return q3(s).forEach(function(i,o){if(V_e(i))n.push(i);else if(i){var l=lf(i.type),c=r[l]||{},d=c.handler,h=c.once;if(d&&(!h||!a[l])){var p=d(i,l,o);n.push(p),a[l]=!0}}}),n},G_e=function(s){var r=s&&s.type;return r&&r8[r]?r8[r]:null},Y_e=function(s,r){return q3(r).indexOf(s)},Q_e=["children","width","height","viewBox","className","style","title","desc"];function RM(){return RM=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},RM.apply(this,arguments)}function X_e(e,s){if(e==null)return{};var r=Z_e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Z_e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function IM(e){var s=e.children,r=e.width,n=e.height,a=e.viewBox,i=e.className,o=e.style,l=e.title,c=e.desc,d=X_e(e,Q_e),h=a||{width:r,height:n,x:0,y:0},p=An("recharts-surface",i);return Ne.createElement("svg",RM({},Mr(d,!0,"svg"),{className:p,width:r,height:n,style:o,viewBox:"".concat(h.x," ").concat(h.y," ").concat(h.width," ").concat(h.height)}),Ne.createElement("title",null,l),Ne.createElement("desc",null,c),s)}var J_e=["children","className"];function OM(){return OM=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},OM.apply(this,arguments)}function e2e(e,s){if(e==null)return{};var r=t2e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function t2e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}var wa=Ne.forwardRef(function(e,s){var r=e.children,n=e.className,a=e2e(e,J_e),i=An("recharts-layer",n);return Ne.createElement("g",OM({className:i},Mr(a,!0),{ref:s}),r)}),yh=function(s,r){for(var n=arguments.length,a=new Array(n>2?n-2:0),i=2;i<n;i++)a[i-2]=arguments[i]},VE,l8;function s2e(){if(l8)return VE;l8=1;function e(s,r,n){var a=-1,i=s.length;r<0&&(r=-r>i?0:i+r),n=n>i?i:n,n<0&&(n+=i),i=r>n?0:n-r>>>0,r>>>=0;for(var o=Array(i);++a<i;)o[a]=s[a+r];return o}return VE=e,VE}var WE,c8;function r2e(){if(c8)return WE;c8=1;var e=s2e();function s(r,n,a){var i=r.length;return a=a===void 0?i:a,!n&&a>=i?r:e(r,n,a)}return WE=s,WE}var KE,d8;function sse(){if(d8)return KE;d8=1;var e="\\ud800-\\udfff",s="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=s+r+n,i="\\ufe0e\\ufe0f",o="\\u200d",l=RegExp("["+o+e+a+i+"]");function c(d){return l.test(d)}return KE=c,KE}var GE,u8;function n2e(){if(u8)return GE;u8=1;function e(s){return s.split("")}return GE=e,GE}var YE,m8;function a2e(){if(m8)return YE;m8=1;var e="\\ud800-\\udfff",s="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=s+r+n,i="\\ufe0e\\ufe0f",o="["+e+"]",l="["+a+"]",c="\\ud83c[\\udffb-\\udfff]",d="(?:"+l+"|"+c+")",h="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",b=d+"?",y="["+i+"]?",w="(?:"+v+"(?:"+[h,p,g].join("|")+")"+y+b+")*",j=y+b+w,x="(?:"+[h+l+"?",l,p,g,o].join("|")+")",C=RegExp(c+"(?="+c+")|"+x+j,"g");function k(S){return S.match(C)||[]}return YE=k,YE}var QE,h8;
493function i2e(){if(h8)return QE;h8=1;var e=n2e(),s=sse(),r=a2e();function n(a){return s(a)?r(a):e(a)}return QE=n,QE}var XE,p8;function o2e(){if(p8)return XE;p8=1;var e=r2e(),s=sse(),r=i2e(),n=Zte();function a(i){return function(o){o=n(o);var l=s(o)?r(o):void 0,c=l?l[0]:o.charAt(0),d=l?e(l,1).join(""):o.slice(1);return c[i]()+d}}return XE=a,XE}var ZE,f8;function l2e(){if(f8)return ZE;f8=1;var e=o2e(),s=e("toUpperCase");return ZE=s,ZE}var c2e=l2e();const T_=ei(c2e);function Ci(e){return function(){return e}}const rse=Math.cos,wC=Math.sin,Th=Math.sqrt,jC=Math.PI,A_=2*jC,DM=Math.PI,LM=2*DM,bx=1e-6,d2e=LM-bx;function nse(e){this._+=e[0];for(let s=1,r=e.length;s<r;++s)this._+=arguments[s]+e[s]}function u2e(e){let s=Math.floor(e);if(!(s>=0))throw new Error(`invalid digits: ${e}`);if(s>15)return nse;const r=10**s;return function(n){this._+=n[0];for(let a=1,i=n.length;a<i;++a)this._+=Math.round(arguments[a]*r)/r+n[a]}}class m2e{constructor(s){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=s==null?nse:u2e(s)}moveTo(s,r){this._append`M${this._x0=this._x1=+s},${this._y0=this._y1=+r}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(s,r){this._append`L${this._x1=+s},${this._y1=+r}`}quadraticCurveTo(s,r,n,a){this._append`Q${+s},${+r},${this._x1=+n},${this._y1=+a}`}bezierCurveTo(s,r,n,a,i,o){this._append`C${+s},${+r},${+n},${+a},${this._x1=+i},${this._y1=+o}`}arcTo(s,r,n,a,i){if(s=+s,r=+r,n=+n,a=+a,i=+i,i<0)throw new Error(`negative radius: ${i}`);let o=this._x1,l=this._y1,c=n-s,d=a-r,h=o-s,p=l-r,g=h*h+p*p;if(this._x1===null)this._append`M${this._x1=s},${this._y1=r}`;else if(g>bx)if(!(Math.abs(p*c-d*h)>bx)||!i)this._append`L${this._x1=s},${this._y1=r}`;else{let v=n-o,b=a-l,y=c*c+d*d,w=v*v+b*b,j=Math.sqrt(y),x=Math.sqrt(g),C=i*Math.tan((DM-Math.acos((y+g-w)/(2*j*x)))/2),k=C/x,S=C/j;Math.abs(k-1)>bx&&this._append`L${s+k*h},${r+k*p}`,this._append`A${i},${i},0,0,${+(p*v>h*b)},${this._x1=s+S*c},${this._y1=r+S*d}`}}arc(s,r,n,a,i,o){if(s=+s,r=+r,n=+n,o=!!o,n<0)throw new Error(`negative radius: ${n}`);let l=n*Math.cos(a),c=n*Math.sin(a),d=s+l,h=r+c,p=1^o,g=o?a-i:i-a;this._x1===null?this._append`M${d},${h}`:(Math.abs(this._x1-d)>bx||Math.abs(this._y1-h)>bx)&&this._append`L${d},${h}`,n&&(g<0&&(g=g%LM+LM),g>d2e?this._append`A${n},${n},0,1,${p},${s-l},${r-c}A${n},${n},0,1,${p},${this._x1=d},${this._y1=h}`:g>bx&&this._append`A${n},${n},0,${+(g>=DM)},${p},${this._x1=s+n*Math.cos(i)},${this._y1=r+n*Math.sin(i)}`)}rect(s,r,n,a){this._append`M${this._x0=this._x1=+s},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function V3(e){let s=3;return e.digits=function(r){if(!arguments.length)return s;if(r==null)s=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);s=n}return e},()=>new m2e(s)}function W3(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ase(e){this._context=e}ase.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,s){switch(e=+e,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,s):this._context.moveTo(e,s);break;case 1:this._point=2;default:this._context.lineTo(e,s);break}}};function M_(e){return new ase(e)}function ise(e){return e[0]}function ose(e){return e[1]}function lse(e,s){var r=Ci(!0),n=null,a=M_,i=null,o=V3(l);e=typeof e=="function"?e:e===void 0?ise:Ci(e),s=typeof s=="function"?s:s===void 0?ose:Ci(s);function l(c){var d,h=(c=W3(c)).length,p,g=!1,v;for(n==null&&(i=a(v=o())),d=0;d<=h;++d)!(d<h&&r(p=c[d],d,c))===g&&((g=!g)?i.lineStart():i.lineEnd()),g&&i.point(+e(p,d,c),+s(p,d,c));if(v)return i=null,v+""||null}return l.x=function(c){return arguments.length?(e=typeof c=="function"?c:Ci(+c),l):e},l.y=function(c){return arguments.length?(s=typeof c=="function"?c:Ci(+c),l):s},l.defined=function(c){return arguments.length?(r=typeof c=="function"?c:Ci(!!c),l):r},l.curve=function(c){return arguments.length?(a=c,n!=null&&(i=a(n)),l):a},l.context=function(c){return arguments.length?(c==null?n=i=null:i=a(n=c),l):n},l}function j1(e,s,r){var n=null,a=Ci(!0),i=null,o=M_,l=null,c=V3(d);e=typeof e=="function"?e:e===void 0?ise:Ci(+e),s=typeof s=="function"?s:Ci(s===void 0?0:+s),r=typeof r=="function"?r:r===void 0?ose:Ci(+r);function d(p){var g,v,b,y=(p=W3(p)).length,w,j=!1,x,C=new Array(y),k=new Array(y);for(i==null&&(l=o(x=c())),g=0;g<=y;++g){if(!(g<y&&a(w=p[g],g,p))===j)if(j=!j)v=g,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),b=g-1;b>=v;--b)l.point(C[b],k[b]);l.lineEnd(),l.areaEnd()}j&&(C[g]=+e(w,g,p),k[g]=+s(w,g,p),l.point(n?+n(w,g,p):C[g],r?+r(w,g,p):k[g]))}if(x)return l=null,x+""||null}function h(){return lse().defined(a).curve(o).context(i)}return d.x=function(p){return arguments.length?(e=typeof p=="function"?p:Ci(+p),n=null,d):e},d.x0=function(p){return arguments.length?(e=typeof p=="function"?p:Ci(+p),d):e},d.x1=function(p){return arguments.length?(n=p==null?null:typeof p=="function"?p:Ci(+p),d):n},d.y=function(p){return arguments.length?(s=typeof p=="function"?p:Ci(+p),r=null,d):s},d.y0=function(p){return arguments.length?(s=typeof p=="function"?p:Ci(+p),d):s},d.y1=function(p){return arguments.length?(r=p==null?null:typeof p=="function"?p:Ci(+p),d):r},d.lineX0=d.lineY0=function(){return h().x(e).y(s)},d.lineY1=function(){return h().x(e).y(r)},d.lineX1=function(){return h().x(n).y(s)},d.defined=function(p){return arguments.length?(a=typeof p=="function"?p:Ci(!!p),d):a},d.curve=function(p){return arguments.length?(o=p,i!=null&&(l=o(i)),d):o},d.context=function(p){return arguments.length?(p==null?i=l=null:l=o(i=p),d):i},d}class cse{constructor(s,r){this._context=s,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(s,r){switch(s=+s,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(s,r):this._context.moveTo(s,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+s)/2,this._y0,this._x0,r,s,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,s,this._y0,s,r);break}}this._x0=s,this._y0=r}}function h2e(e){return new cse(e,!0)}function p2e(e){return new cse(e,!1)}const K3={draw(e,s){const r=Th(s/jC);e.moveTo(r,0),e.arc(0,0,r,0,A_)}},f2e={draw(e,s){const r=Th(s/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()}},dse=Th(1/3),g2e=dse*2,x2e={draw(e,s){const r=Th(s/g2e),n=r*dse;e.moveTo(0,-r),e.lineTo(n,0),e.lineTo(0,r),e.lineTo(-n,0),e.closePath()}},v2e={draw(e,s){const r=Th(s),n=-r/2;e.rect(n,n,r,r)}},y2e=.8908130915292852,use=wC(jC/10)/wC(7*jC/10),b2e=wC(A_/10)*use,w2e=-rse(A_/10)*use,j2e={draw(e,s){const r=Th(s*y2e),n=b2e*r,a=w2e*r;e.moveTo(0,-r),e.lineTo(n,a);for(let i=1;i<5;++i){const o=A_*i/5,l=rse(o),c=wC(o);e.lineTo(c*r,-l*r),e.lineTo(l*n-c*a,c*n+l*a)}e.closePath()}},JE=Th(3),N2e={draw(e,s){const r=-Th(s/(JE*3));e.moveTo(0,r*2),e.lineTo(-JE*r,-r),e.lineTo(JE*r,-r),e.closePath()}},hm=-.5,pm=Th(3)/2,$M=1/Th(12),S2e=($M/2+1)*3,C2e={draw(e,s){const r=Th(s/S2e),n=r/2,a=r*$M,i=n,o=r*$M+r,l=-i,c=o;e.moveTo(n,a),e.lineTo(i,o),e.lineTo(l,c),e.lineTo(hm*n-pm*a,pm*n+hm*a),e.lineTo(hm*i-pm*o,pm*i+hm*o),e.lineTo(hm*l-pm*c,pm*l+hm*c),e.lineTo(hm*n+pm*a,hm*a-pm*n),e.lineTo(hm*i+pm*o,hm*o-pm*i),e.lineTo(hm*l+pm*c,hm*c-pm*l),e.closePath()}};function k2e(e,s){let r=null,n=V3(a);e=typeof e=="function"?e:Ci(e||K3),s=typeof s=="function"?s:Ci(s===void 0?64:+s);function a(){let i;if(r||(r=i=n()),e.apply(this,arguments).draw(r,+s.apply(this,arguments)),i)return r=null,i+""||null}return a.type=function(i){return arguments.length?(e=typeof i=="function"?i:Ci(i),a):e},a.size=function(i){return arguments.length?(s=typeof i=="function"?i:Ci(+i),a):s},a.context=function(i){return arguments.length?(r=i??null,a):r},a}function NC(){}function SC(e,s,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+s)/6,(e._y0+4*e._y1+r)/6)}function mse(e){this._context=e}mse.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:SC(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,s){switch(e=+e,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,s):this._context.moveTo(e,s);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:SC(this,e,s);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=s}};function _2e(e){return new mse(e)}function hse(e){this._context=e}hse.prototype={areaStart:NC,areaEnd:NC,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,s){switch(e=+e,s=+s,this._point){case 0:this._point=1,this._x2=e,this._y2=s;break;case 1:this._point=2,this._x3=e,this._y3=s;break;case 2:this._point=3,this._x4=e,this._y4=s,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+s)/6);break;default:SC(this,e,s);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=s}};function P2e(e){return new hse(e)}function pse(e){this._context=e}pse.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,s){switch(e=+e,s=+s,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,n=(this._y0+4*this._y1+s)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:SC(this,e,s);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=s}};function E2e(e){return new pse(e)}function fse(e){this._context=e}fse.prototype={areaStart:NC,areaEnd:NC,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,s){e=+e,s=+s,this._point?this._context.lineTo(e,s):(this._point=1,this._context.moveTo(e,s))}};function T2e(e){return new fse(e)}function g8(e){return e<0?-1:1}function x8(e,s,r){var n=e._x1-e._x0,a=s-e._x1,i=(e._y1-e._y0)/(n||a<0&&-0),o=(r-e._y1)/(a||n<0&&-0),l=(i*a+o*n)/(n+a);return(g8(i)+g8(o))*Math.min(Math.abs(i),Math.abs(o),.5*Math.abs(l))||0}function v8(e,s){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-s)/2:s}function eT(e,s,r){var n=e._x0,a=e._y0,i=e._x1,o=e._y1,l=(i-n)/3;e._context.bezierCurveTo(n+l,a+l*s,i-l,o-l*r,i,o)}function CC(e){this._context=e}CC.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:eT(this,this._t0,v8(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,s){var r=NaN;if(e=+e,s=+s,!(e===this._x1&&s===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,s):this._context.moveTo(e,s);break;case 1:this._point=2;break;case 2:this._point=3,eT(this,v8(this,r=x8(this,e,s)),r);break;default:eT(this,this._t0,r=x8(this,e,s));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=s,this._t0=r}}};function gse(e){this._context=new xse(e)}(gse.prototype=Object.create(CC.prototype)).point=function(e,s){CC.prototype.point.call(this,s,e)};function xse(e){this._context=e}xse.prototype={moveTo:function(e,s){this._context.moveTo(s,e)},closePath:function(){this._context.closePath()},lineTo:function(e,s){this._context.lineTo(s,e)},bezierCurveTo:function(e,s,r,n,a,i){this._context.bezierCurveTo(s,e,n,r,i,a)}};function A2e(e){return new CC(e)}function M2e(e){return new gse(e)}function vse(e){this._context=e}vse.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,s=this._y,r=e.length;if(r)if(this._line?this._context.lineTo(e[0],s[0]):this._context.moveTo(e[0],s[0]),r===2)this._context.lineTo(e[1],s[1]);else for(var n=y8(e),a=y8(s),i=0,o=1;o<r;++i,++o)this._context.bezierCurveTo(n[0][i],a[0][i],n[1][i],a[1][i],e[o],s[o]);(this._line||this._line!==0&&r===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,s){this._x.push(+e),this._y.push(+s)}};function y8(e){var s,r=e.length-1,n,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],s=1;s<r-1;++s)a[s]=1,i[s]=4,o[s]=4*e[s]+2*e[s+1];for(a[r-1]=2,i[r-1]=7,o[r-1]=8*e[r-1]+e[r],s=1;s<r;++s)n=a[s]/i[s-1],i[s]-=n,o[s]-=n*o[s-1];for(a[r-1]=o[r-1]/i[r-1],s=r-2;s>=0;--s)a[s]=(o[s]-a[s+1])/i[s];for(i[r-1]=(e[r]+a[r-1])/2,s=0;s<r-1;++s)i[s]=2*e[s+1]-a[s+1];return[a,i]}function R2e(e){return new vse(e)}function R_(e,s){this._context=e,this._t=s}R_.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,s){switch(e=+e,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,s):this._context.moveTo(e,s);break;case 1:this._point=2;
vendor: 17,555 bytes, lines 493-496
493default:{if(this._t<=0)this._context.lineTo(this._x,s),this._context.lineTo(e,s);else{var r=this._x*(1-this._t)+e*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,s)}break}}this._x=e,this._y=s}};function I2e(e){return new R_(e,.5)}function O2e(e){return new R_(e,0)}function D2e(e){return new R_(e,1)}function Vy(e,s){if((o=e.length)>1)for(var r=1,n,a,i=e[s[0]],o,l=i.length;r<o;++r)for(a=i,i=e[s[r]],n=0;n<l;++n)i[n][1]+=i[n][0]=isNaN(a[n][1])?a[n][0]:a[n][1]}function FM(e){for(var s=e.length,r=new Array(s);--s>=0;)r[s]=s;return r}function L2e(e,s){return e[s]}function $2e(e){const s=[];return s.key=e,s}function F2e(){var e=Ci([]),s=FM,r=Vy,n=L2e;function a(i){var o=Array.from(e.apply(this,arguments),$2e),l,c=o.length,d=-1,h;for(const p of i)for(l=0,++d;l<c;++l)(o[l][d]=[0,+n(p,o[l].key,d,i)]).data=p;for(l=0,h=W3(s(o));l<c;++l)o[h[l]].index=l;return r(o,h),o}return a.keys=function(i){return arguments.length?(e=typeof i=="function"?i:Ci(Array.from(i)),a):e},a.value=function(i){return arguments.length?(n=typeof i=="function"?i:Ci(+i),a):n},a.order=function(i){return arguments.length?(s=i==null?FM:typeof i=="function"?i:Ci(Array.from(i)),a):s},a.offset=function(i){return arguments.length?(r=i??Vy,a):r},a}function B2e(e,s){if((n=e.length)>0){for(var r,n,a=0,i=e[0].length,o;a<i;++a){for(o=r=0;r<n;++r)o+=e[r][a][1]||0;if(o)for(r=0;r<n;++r)e[r][a][1]/=o}Vy(e,s)}}function U2e(e,s){if((a=e.length)>0){for(var r=0,n=e[s[0]],a,i=n.length;r<i;++r){for(var o=0,l=0;o<a;++o)l+=e[o][r][1]||0;n[r][1]+=n[r][0]=-l/2}Vy(e,s)}}function z2e(e,s){if(!(!((o=e.length)>0)||!((i=(a=e[s[0]]).length)>0))){for(var r=0,n=1,a,i,o;n<i;++n){for(var l=0,c=0,d=0;l<o;++l){for(var h=e[s[l]],p=h[n][1]||0,g=h[n-1][1]||0,v=(p-g)/2,b=0;b<l;++b){var y=e[s[b]],w=y[n][1]||0,j=y[n-1][1]||0;v+=w-j}c+=p,d+=v*p}a[n-1][1]+=a[n-1][0]=r,c&&(r-=d/c)}a[n-1][1]+=a[n-1][0]=r,Vy(e,s)}}function J0(e){"@babel/helpers - typeof";return J0=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},J0(e)}var H2e=["type","size","sizeType"];function BM(){return BM=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},BM.apply(this,arguments)}function b8(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function w8(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?b8(Object(r),!0).forEach(function(n){q2e(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b8(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function q2e(e,s,r){return s=V2e(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function V2e(e){var s=W2e(e,"string");return J0(s)=="symbol"?s:s+""}function W2e(e,s){if(J0(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(J0(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function K2e(e,s){if(e==null)return{};var r=G2e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function G2e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}var yse={symbolCircle:K3,symbolCross:f2e,symbolDiamond:x2e,symbolSquare:v2e,symbolStar:j2e,symbolTriangle:N2e,symbolWye:C2e},Y2e=Math.PI/180,Q2e=function(s){var r="symbol".concat(T_(s));return yse[r]||K3},X2e=function(s,r,n){if(r==="area")return s;switch(n){case"cross":return 5*s*s/9;case"diamond":return .5*s*s/Math.sqrt(3);case"square":return s*s;case"star":{var a=18*Y2e;return 1.25*s*s*(Math.tan(a)-Math.tan(a*2)*Math.pow(Math.tan(a),2))}case"triangle":return Math.sqrt(3)*s*s/4;case"wye":return(21-10*Math.sqrt(3))*s*s/8;default:return Math.PI*s*s/4}},Z2e=function(s,r){yse["symbol".concat(T_(s))]=r},G3=function(s){var r=s.type,n=r===void 0?"circle":r,a=s.size,i=a===void 0?64:a,o=s.sizeType,l=o===void 0?"area":o,c=K2e(s,H2e),d=w8(w8({},c),{},{type:n,size:i,sizeType:l}),h=function(){var w=Q2e(n),j=k2e().type(w).size(X2e(i,l,n));return j()},p=d.className,g=d.cx,v=d.cy,b=Mr(d,!0);return g===+g&&v===+v&&i===+i?Ne.createElement("path",BM({},b,{className:An("recharts-symbols",p),transform:"translate(".concat(g,", ").concat(v,")"),d:h()})):null};G3.registerSymbol=Z2e;function Wy(e){"@babel/helpers - typeof";return Wy=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Wy(e)}function UM(){return UM=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},UM.apply(this,arguments)}function j8(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function J2e(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?j8(Object(r),!0).forEach(function(n){ej(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j8(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ePe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function tPe(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,wse(n.key),n)}}function sPe(e,s,r){return s&&tPe(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function rPe(e,s,r){return s=kC(s),nPe(e,bse()?Reflect.construct(s,r||[],kC(e).constructor):s.apply(e,r))}function nPe(e,s){if(s&&(Wy(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return aPe(e)}function aPe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function bse(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(bse=function(){return!!e})()}function kC(e){return kC=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},kC(e)}function iPe(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&zM(e,s)}function zM(e,s){return zM=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},zM(e,s)}function ej(e,s,r){return s=wse(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function wse(e){var s=oPe(e,"string");return Wy(s)=="symbol"?s:s+""}function oPe(e,s){if(Wy(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Wy(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var fm=32,Y3=(function(e){function s(){return ePe(this,s),rPe(this,s,arguments)}return iPe(s,e),sPe(s,[{key:"renderIcon",value:function(n){var a=this.props.inactiveColor,i=fm/2,o=fm/6,l=fm/3,c=n.inactive?a:n.color;if(n.type==="plainline")return Ne.createElement("line",{strokeWidth:4,fill:"none",stroke:c,strokeDasharray:n.payload.strokeDasharray,x1:0,y1:i,x2:fm,y2:i,className:"recharts-legend-icon"});if(n.type==="line")return Ne.createElement("path",{strokeWidth:4,fill:"none",stroke:c,d:"M0,".concat(i,"h").concat(l,`
494            A`).concat(o,",").concat(o,",0,1,1,").concat(2*l,",").concat(i,`
495            H`).concat(fm,"M").concat(2*l,",").concat(i,`
496            A`).concat(o,",").concat(o,",0,1,1,").concat(l,",").concat(i),className:"recharts-legend-icon"});if(n.type==="rect")return Ne.createElement("path",{stroke:"none",fill:c,d:"M0,".concat(fm/8,"h").concat(fm,"v").concat(fm*3/4,"h").concat(-fm,"z"),className:"recharts-legend-icon"});if(Ne.isValidElement(n.legendIcon)){var d=J2e({},n);return delete d.legendIcon,Ne.cloneElement(n.legendIcon,d)}return Ne.createElement(G3,{fill:c,cx:i,cy:i,size:fm,sizeType:"diameter",type:n.type})}},{key:"renderItems",value:function(){var n=this,a=this.props,i=a.payload,o=a.iconSize,l=a.layout,c=a.formatter,d=a.inactiveColor,h={x:0,y:0,width:fm,height:fm},p={display:l==="horizontal"?"inline-block":"block",marginRight:10},g={display:"inline-block",verticalAlign:"middle",marginRight:4};return i.map(function(v,b){var y=v.formatter||c,w=An(ej(ej({"recharts-legend-item":!0},"legend-item-".concat(b),!0),"inactive",v.inactive));if(v.type==="none")return null;var j=Qr(v.value)?null:v.value;yh(!Qr(v.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 x=v.inactive?d:v.color;return Ne.createElement("li",UM({className:w,style:p,key:"legend-item-".concat(b)},ev(n.props,v,b)),Ne.createElement(IM,{width:o,height:o,viewBox:h,style:g},n.renderIcon(v)),Ne.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y?y(j,v,b):j))})}},{key:"render",value:function(){var n=this.props,a=n.payload,i=n.layout,o=n.align;if(!a||!a.length)return null;var l={padding:0,margin:0,textAlign:i==="horizontal"?o:"left"};return Ne.createElement("ul",{className:"recharts-default-legend",style:l},this.renderItems())}}])})(u.PureComponent);ej(Y3,"displayName","Legend");ej(Y3,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var tT,N8;function lPe(){if(N8)return tT;N8=1;var e=__();function s(){this.__data__=new e,this.size=0}return tT=s,tT}var sT,S8;function cPe(){if(S8)return sT;S8=1;function e(s){var r=this.__data__,n=r.delete(s);return this.size=r.size,n}return sT=e,sT}var rT,C8;function dPe(){if(C8)return rT;C8=1;function e(s){return this.__data__.get(s)}return rT=e,rT}var nT,k8;function uPe(){if(k8)return nT;k8=1;function e(s){return this.__data__.has(s)}return nT=e,nT}var aT,_8;function mPe(){if(_8)return aT;_8=1;var e=__(),s=F3(),r=B3(),n=200;function a(i,o){var l=this.__data__;if(l instanceof e){var c=l.__data__;if(!s||c.length<n-1)return c.push([i,o]),this.size=++l.size,this;l=this.__data__=new r(c)}return l.set(i,o),this.size=l.size,this}return aT=a,aT}var iT,P8;function jse(){if(P8)return iT;P8=1;var e=__(),s=lPe(),r=cPe(),n=dPe(),a=uPe(),i=mPe();function o(l){var c=this.__data__=new e(l);this.size=c.size}return o.prototype.clear=s,o.prototype.delete=r,o.prototype.get=n,o.prototype.has=a,o.prototype.set=i,iT=o,iT}var oT,E8;function hPe(){if(E8)return oT;E8=1;var e="__lodash_hash_undefined__";function s(r){return this.__data__.set(r,e),this}return oT=s,oT}var lT,T8;function pPe(){if(T8)return lT;T8=1;function e(s){return this.__data__.has(s)}return lT=e,lT}var cT,A8;function Nse(){if(A8)return cT;A8=1;var e=B3(),s=hPe(),r=pPe();function n(a){var i=-1,o=a==null?0:a.length;for(this.__data__=new e;++i<o;)this.add(a[i])}return n.prototype.add=n.prototype.push=s,n.prototype.has=r,cT=n,cT}var dT,M8;function Sse(){if(M8)return dT;M8=1;function e(s,r){for(var n=-1,a=s==null?0:s.length;++n<a;)if(r(s[n],n,s))return!0;return!1}return dT=e,dT}var uT,R8;function Cse(){if(R8)return uT;R8=1;function e(s,r){return s.has(r)}return uT=e,uT}var mT,I8;function kse(){if(I8)return mT;I8=1;var e=Nse(),s=Sse(),r=Cse(),n=1,a=2;function i(o,l,c,d,h,p){var g=c&n,v=o.length,b=l.length;if(v!=b&&!(g&&b>v))return!1;var y=p.get(o),w=p.get(l);if(y&&w)return y==l&&w==o;var j=-1,x=!0,C=c&a?new e:void 0;for(p.set(o,l),p.set(l,o);++j<v;){var k=o[j],S=l[j];if(d)var _=g?d(S,k,j,l,o,p):d(k,S,j,o,l,p);if(_!==void 0){if(_)continue;x=!1;break}if(C){if(!s(l,function(A,T){if(!r(C,T)&&(k===A||h(k,A,c,d,p)))return C.push(T)})){x=!1;break}}else if(!(k===S||h(k,S,c,d,p))){x=!1;break}}return p.delete(o),p.delete(l),x}return mT=i,mT}var hT,O8;function fPe(){if(O8)return hT;O8=1;var e=gp(),s=e.Uint8Array;return hT=s,hT}var pT,D8;function gPe(){if(D8)return pT;D8=1;function e(s){var r=-1,n=Array(s.size);return s.forEach(function(a,i){n[++r]=[i,a]}),n}return pT=e,pT}var fT,L8;function Q3(){if(L8)return fT;L8=1;function e(s){var r=-1,n=Array(s.size);return s.forEach(function(a){n[++r]=a}),n}return fT=e,fT}var gT,$8;function xPe(){if($8)return gT;$8=1;var e=uN(),s=fPe(),r=$3(),n=kse(),a=gPe(),i=Q3(),o=1,l=2,c="[object Boolean]",d="[object Date]",h="[object Error]",p="[object Map]",g="[object Number]",v="[object RegExp]",b="[object Set]",y="[object String]",w="[object Symbol]",j="[object ArrayBuffer]",x="[object DataView]",C=e?e.prototype:void 0,k=C?C.valueOf:void 0;function S(_,A,T,M,R,D,$){switch(T){case x:if(_.byteLength!=A.byteLength||_.byteOffset!=A.byteOffset)return!1;_=_.buffer,A=A.buffer;case j:return!(_.byteLength!=A.byteLength||!D(new s(_),new s(A)));case c:case d:case g:return r(+_,+A);case h:return _.name==A.name&&_.message==A.message;case v:case y:return _==A+"";case p:var O=a;case b:var q=M&o;if(O||(O=i),_.size!=A.size&&!q)return!1;var V=$.get(_);if(V)return V==A;M|=l,$.set(_,A);var K=n(O(_),O(A),M,R,D,$);return $.delete(_),K;case w:if(k)return k.call(_)==k.call(A)}return!1}return gT=S,gT}var xT,F8;function _se(){if(F8)return xT;F8=1;function e(s,r){for(var n=-1,a=r.length,i=s.length;++n<a;)s[i+n]=r[n];return s}return xT=e,xT}var vT,B8;function vPe(){if(B8)return vT;B8=1;var e=_se(),s=Cu();function r(n,a,i){var o=a(n);return s(n)?o:e(o,i(n))}return vT=r,vT}var yT,U8;function yPe(){if(U8)return yT;U8=1;function e(s,r){for(var n=-1,a=s==null?0:s.length,i=0,o=[];++n<a;){var l=s[n];r(l,n,s)&&(o[i++]=l)}return o}return yT=e,yT}var bT,z8;function bPe(){if(z8)return bT;z8=1;function e(){return[]}return bT=e,bT}var wT,H8;function wPe(){if(H8)return wT;H8=1;var e=yPe(),s=bPe(),r=Object.prototype,n=r.propertyIsEnumerable,a=Object.getOwnPropertySymbols,i=a?function(o){return o==null?[]:(o=Object(o),e(a(o),function(l){return n.call(o,l)}))}:s;return wT=i,wT}var jT,q8;function jPe(){if(q8)return jT;q8=1;function e(s,r){for(var n=-1,a=Array(s);++n<s;)a[n]=r(n);return a}return jT=e,jT}var NT,V8;function NPe(){if(V8)return NT;V8=1;var e=Cf(),s=kf(),r="[object Arguments]";function n(a){return s(a)&&e(a)==r}return NT=n,NT}var ST,W8;function X3(){if(W8)return ST;W8=1;var e=NPe(),s=kf(),r=Object.prototype,n=r.hasOwnProperty,a=r.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(o){return s(o)&&n.call(o,"callee")&&!a.call(o,"callee")};return ST=i,ST}var qw={exports:{}},CT,K8;function SPe(){if(K8)return CT;K8=1;function e(){return!1}return CT=e,CT}qw.exports;var G8;function Pse(){return G8||(G8=1,(function(e,s){var r=gp(),n=SPe(),a=s&&!s.nodeType&&s,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||n;e.exports=d})(qw,qw.exports)),qw.exports}var kT,Y8;function Z3(){if(Y8)return kT;Y8=1;var e=9007199254740991,s=/^(?:0|[1-9]\d*)$/;function r(n,a){var i=typeof n;return a=a??e,!!a&&(i=="number"||i!="symbol"&&s.test(n))&&n>-1&&n%1==0&&n<a}return kT=r,kT}var _T,Q8;function J3(){if(Q8)return _T;Q8=1;var e=9007199254740991;function s(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return _T=s,_T}var PT,X8;function CPe(){if(X8)return PT;X8=1;var e=Cf(),s=J3(),r=kf(),n="[object Arguments]",a="[object Array]",i="[object Boolean]",o="[object Date]",l="[object Error]",c="[object Function]",d="[object Map]",h="[object Number]",p="[object Object]",g="[object RegExp]",v="[object Set]",b="[object String]",y="[object WeakMap]",w="[object ArrayBuffer]",j="[object DataView]",x="[object Float32Array]",C="[object Float64Array]",k="[object Int8Array]",S="[object Int16Array]",_="[object Int32Array]",A="[object Uint8Array]",T="[object Uint8ClampedArray]",M="[object Uint16Array]",R="[object Uint32Array]",D={};D[x]=D[C]=D[k]=D[S]=D[_]=D[A]=D[T]=D[M]=D[R]=!0,D[n]=D[a]=D[w]=D[i]=D[j]=D[o]=D[l]=D[c]=D[d]=D[h]=D[p]=D[g]=D[v]=D[b]=D[y]=!1;function $(O){return r(O)&&s(O.length)&&!!D[e(O)]}return PT=$,PT}var ET,Z8;function Ese(){if(Z8)return ET;Z8=1;function e(s){return function(r){return s(r)}}return ET=e,ET}var Vw={exports:{}};Vw.exports;var J8;function kPe(){return J8||(J8=1,(function(e,s){var r=Yte(),n=s&&!s.nodeType&&s,a=n&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===n,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})(Vw,Vw.exports)),Vw.exports}var TT,eU;function Tse(){if(eU)return TT;eU=1;var e=CPe(),s=Ese(),r=kPe(),n=r&&r.isTypedArray,a=n?s(n):e;return TT=a,TT}var AT,tU;function _Pe(){if(tU)return AT;tU=1;var e=jPe(),s=X3(),r=Cu(),n=Pse(),a=Z3(),i=Tse(),o=Object.prototype,l=o.hasOwnProperty;function c(d,h){var p=r(d),g=!p&&s(d),v=!p&&!g&&n(d),b=!p&&!g&&!v&&i(d),y=p||g||v||b,w=y?e
vendor: 3,369 bytes, line 496
496(d.length,String):[],j=w.length;for(var x in d)(h||l.call(d,x))&&!(y&&(x=="length"||v&&(x=="offset"||x=="parent")||b&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||a(x,j)))&&w.push(x);return w}return AT=c,AT}var MT,sU;function PPe(){if(sU)return MT;sU=1;var e=Object.prototype;function s(r){var n=r&&r.constructor,a=typeof n=="function"&&n.prototype||e;return r===a}return MT=s,MT}var RT,rU;function Ase(){if(rU)return RT;rU=1;function e(s,r){return function(n){return s(r(n))}}return RT=e,RT}var IT,nU;function EPe(){if(nU)return IT;nU=1;var e=Ase(),s=e(Object.keys,Object);return IT=s,IT}var OT,aU;function TPe(){if(aU)return OT;aU=1;var e=PPe(),s=EPe(),r=Object.prototype,n=r.hasOwnProperty;function a(i){if(!e(i))return s(i);var o=[];for(var l in Object(i))n.call(i,l)&&l!="constructor"&&o.push(l);return o}return OT=a,OT}var DT,iU;function hN(){if(iU)return DT;iU=1;var e=L3(),s=J3();function r(n){return n!=null&&s(n.length)&&!e(n)}return DT=r,DT}var LT,oU;function I_(){if(oU)return LT;oU=1;var e=_Pe(),s=TPe(),r=hN();function n(a){return r(a)?e(a):s(a)}return LT=n,LT}var $T,lU;function APe(){if(lU)return $T;lU=1;var e=vPe(),s=wPe(),r=I_();function n(a){return e(a,r,s)}return $T=n,$T}var FT,cU;function MPe(){if(cU)return FT;cU=1;var e=APe(),s=1,r=Object.prototype,n=r.hasOwnProperty;function a(i,o,l,c,d,h){var p=l&s,g=e(i),v=g.length,b=e(o),y=b.length;if(v!=y&&!p)return!1;for(var w=v;w--;){var j=g[w];if(!(p?j in o:n.call(o,j)))return!1}var x=h.get(i),C=h.get(o);if(x&&C)return x==o&&C==i;var k=!0;h.set(i,o),h.set(o,i);for(var S=p;++w<v;){j=g[w];var _=i[j],A=o[j];if(c)var T=p?c(A,_,j,o,i,h):c(_,A,j,i,o,h);if(!(T===void 0?_===A||d(_,A,l,c,h):T)){k=!1;break}S||(S=j=="constructor")}if(k&&!S){var M=i.constructor,R=o.constructor;M!=R&&"constructor"in i&&"constructor"in o&&!(typeof M=="function"&&M instanceof M&&typeof R=="function"&&R instanceof R)&&(k=!1)}return h.delete(i),h.delete(o),k}return FT=a,FT}var BT,dU;function RPe(){if(dU)return BT;dU=1;var e=mv(),s=gp(),r=e(s,"DataView");return BT=r,BT}var UT,uU;function IPe(){if(uU)return UT;uU=1;var e=mv(),s=gp(),r=e(s,"Promise");return UT=r,UT}var zT,mU;function Mse(){if(mU)return zT;mU=1;var e=mv(),s=gp(),r=e(s,"Set");return zT=r,zT}var HT,hU;function OPe(){if(hU)return HT;hU=1;var e=mv(),s=gp(),r=e(s,"WeakMap");return HT=r,HT}var qT,pU;function DPe(){if(pU)return qT;pU=1;var e=RPe(),s=F3(),r=IPe(),n=Mse(),a=OPe(),i=Cf(),o=Qte(),l="[object Map]",c="[object Object]",d="[object Promise]",h="[object Set]",p="[object WeakMap]",g="[object DataView]",v=o(e),b=o(s),y=o(r),w=o(n),j=o(a),x=i;return(e&&x(new e(new ArrayBuffer(1)))!=g||s&&x(new s)!=l||r&&x(r.resolve())!=d||n&&x(new n)!=h||a&&x(new a)!=p)&&(x=function(C){var k=i(C),S=k==c?C.constructor:void 0,_=S?o(S):"";if(_)switch(_){case v:return g;case b:return l;case y:return d;case w:return h;case j:return p}return k}),qT=x,qT}var VT,fU;function LPe(){if(fU)return VT;fU=1;var e=jse(),s=kse(),r=xPe(),n=MPe(),a=DPe(),i=Cu(),o=Pse(),l=Tse(),c=1,d="[object Arguments]",h="[object Array]",p="[object Object]",g=Object.prototype,v=g.hasOwnProperty;function b(y,w,j,x,C,k){var S=i(y),_=i(w),A=S?h:a(y),T=_?h:a(w);A=A==d?p:A,T=T==d?p:T;var M=A==p,R=T==p,D=A==T;if(D&&o(y)){if(!o(w))return!1;S=!0,M=!1}if(D&&!M)return k||(k=new e),S||l(y)?s(y,w,j,x,C,k):r(y,w,A,j,x,C,k);if(!(j&c)){var $=M&&v.call(y,"__wrapped__"),O=R&&v.call(w,"__wrapped__");
vendor: 5,078 bytes, line 496
496if($||O){var q=$?y.value():y,V=O?w.value():w;return k||(k=new e),C(q,V,j,x,k)}}return D?(k||(k=new e),n(y,w,j,x,C,k)):!1}return VT=b,VT}var WT,gU;function eD(){if(gU)return WT;gU=1;var e=LPe(),s=kf();function r(n,a,i,o,l){return n===a?!0:n==null||a==null||!s(n)&&!s(a)?n!==n&&a!==a:e(n,a,i,o,r,l)}return WT=r,WT}var KT,xU;function $Pe(){if(xU)return KT;xU=1;var e=jse(),s=eD(),r=1,n=2;function a(i,o,l,c){var d=l.length,h=d,p=!c;if(i==null)return!h;for(i=Object(i);d--;){var g=l[d];if(p&&g[2]?g[1]!==i[g[0]]:!(g[0]in i))return!1}for(;++d<h;){g=l[d];var v=g[0],b=i[v],y=g[1];if(p&&g[2]){if(b===void 0&&!(v in i))return!1}else{var w=new e;if(c)var j=c(b,y,v,i,o,w);if(!(j===void 0?s(y,b,r|n,c,w):j))return!1}}return!0}return KT=a,KT}var GT,vU;function Rse(){if(vU)return GT;vU=1;var e=Fg();function s(r){return r===r&&!e(r)}return GT=s,GT}var YT,yU;function FPe(){if(yU)return YT;yU=1;var e=Rse(),s=I_();function r(n){for(var a=s(n),i=a.length;i--;){var o=a[i],l=n[o];a[i]=[o,l,e(l)]}return a}return YT=r,YT}var QT,bU;function Ise(){if(bU)return QT;bU=1;function e(s,r){return function(n){return n==null?!1:n[s]===r&&(r!==void 0||s in Object(n))}}return QT=e,QT}var XT,wU;function BPe(){if(wU)return XT;wU=1;var e=$Pe(),s=FPe(),r=Ise();function n(a){var i=s(a);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(o){return o===a||e(o,a,i)}}return XT=n,XT}var ZT,jU;function UPe(){if(jU)return ZT;jU=1;function e(s,r){return s!=null&&r in Object(s)}return ZT=e,ZT}var JT,NU;function zPe(){if(NU)return JT;NU=1;var e=Jte(),s=X3(),r=Cu(),n=Z3(),a=J3(),i=E_();function o(l,c,d){c=e(c,l);for(var h=-1,p=c.length,g=!1;++h<p;){var v=i(c[h]);if(!(g=l!=null&&d(l,v)))break;l=l[v]}return g||++h!=p?g:(p=l==null?0:l.length,!!p&&a(p)&&n(v,p)&&(r(l)||s(l)))}return JT=o,JT}var eA,SU;function HPe(){if(SU)return eA;SU=1;var e=UPe(),s=zPe();function r(n,a){return n!=null&&s(n,a,e)}return eA=r,eA}var tA,CU;function qPe(){if(CU)return tA;CU=1;var e=eD(),s=ese(),r=HPe(),n=D3(),a=Rse(),i=Ise(),o=E_(),l=1,c=2;function d(h,p){return n(h)&&a(p)?i(o(h),p):function(g){var v=s(g,h);return v===void 0&&v===p?r(g,h):e(p,v,l|c)}}return tA=d,tA}var sA,kU;function Bb(){if(kU)return sA;kU=1;function e(s){return s}return sA=e,sA}var rA,_U;function VPe(){if(_U)return rA;_U=1;function e(s){return function(r){return r?.[s]}}return rA=e,rA}var nA,PU;function WPe(){if(PU)return nA;PU=1;var e=z3();function s(r){return function(n){return e(n,r)}}return nA=s,nA}var aA,EU;function KPe(){if(EU)return aA;EU=1;var e=VPe(),s=WPe(),r=D3(),n=E_();function a(i){return r(i)?e(n(i)):s(i)}return aA=a,aA}var iA,TU;function xp(){if(TU)return iA;TU=1;var e=BPe(),s=qPe(),r=Bb(),n=Cu(),a=KPe();function i(o){return typeof o=="function"?o:o==null?r:typeof o=="object"?n(o)?s(o[0],o[1]):e(o):a(o)}return iA=i,iA}var oA,AU;function Ose(){if(AU)return oA;AU=1;function e(s,r,n,a){for(var i=s.length,o=n+(a?1:-1);a?o--:++o<i;)if(r(s[o],o,s))return o;return-1}return oA=e,oA}var lA,MU;function GPe(){if(MU)return lA;MU=1;function e(s){return s!==s}return lA=e,lA}var cA,RU;function YPe(){if(RU)return cA;RU=1;function e(s,r,n){for(var a=n-1,i=s.length;++a<i;)if(s[a]===r)return a;return-1}return cA=e,cA}var dA,IU;function QPe(){if(IU)return dA;IU=1;var e=Ose(),s=GPe(),r=YPe();function n(a,i,o){return i===i?r(a,i,o):e(a,s,o)}return dA=n,dA}var uA,OU;function XPe(){if(OU)return uA;OU=1;var e=QPe();function s(r,n){var a=r==null?0:r.length;return!!a&&e(r,n,0)>-1}return uA=s,uA}var mA,DU;function ZPe(){if(DU)return mA;DU=1;function e(s,r,n){for(var a=-1,i=s==null?0:s.length;++a<i;)if(n(r,s[a]))return!0;return!1}return mA=e,mA}var hA,LU;function JPe(){if(LU)return hA;LU=1;function e(){}return hA=e,hA}var pA,$U;function eEe(){if($U)return pA;$U=1;var e=Mse(),s=JPe(),r=Q3(),n=1/0,a=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:s;return pA=a,pA}var fA,FU;function tEe(){if(FU)return fA;FU=1;var e=Nse(),s=XPe(),r=ZPe(),n=Cse(),a=eEe(),i=Q3(),o=200;function l(c,d,h){var p=-1,g=s,v=c.length,b=!0,y=[],w=y;if(h)b=!1,g=r;else if(v>=o){var j=d?null:a(c);if(j)return i(j);b=!1,g=n,w=new e}else w=d?[]:y;e:for(;++p<v;){var x=c[p],C=d?d(x):x;if(x=h||x!==0?x:0,b&&C===C){for(var k=w.length;k--;)if(w[k]===C)continue e;d&&w.push(C),y.push(x)}else g(w,C,h)||(w!==y&&w.push(C),y.push(x))}return y}return fA=l,fA}var gA,BU;function sEe(){if(BU)return gA;BU=1;var e=xp(),s=tEe();function r(n,a){return n&&n.length?s(n,e(a,2)):[]}return gA=r,gA}var rEe=sEe();const UU=ei(rEe);function Dse(e,s,r){return s===!0?UU(e,r):Qr(s)?UU(e,s):e}function Ky(e){"@babel/helpers - typeof";return Ky=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Ky(e)}var nEe=["ref"];function zU(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function $p(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};
496s%2?zU(Object(r),!0).forEach(function(n){O_(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):zU(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function aEe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function HU(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,$se(n.key),n)}}function iEe(e,s,r){return s&&HU(e.prototype,s),r&&HU(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function oEe(e,s,r){return s=_C(s),lEe(e,Lse()?Reflect.construct(s,r||[],_C(e).constructor):s.apply(e,r))}function lEe(e,s){if(s&&(Ky(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return cEe(e)}function cEe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Lse(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Lse=function(){return!!e})()}
vendor: 38,035 bytes, lines 496-503
496function _C(e){return _C=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},_C(e)}function dEe(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&HM(e,s)}function HM(e,s){return HM=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},HM(e,s)}function O_(e,s,r){return s=$se(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function $se(e){var s=uEe(e,"string");return Ky(s)=="symbol"?s:s+""}function uEe(e,s){if(Ky(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Ky(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function mEe(e,s){if(e==null)return{};var r=hEe(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function hEe(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function pEe(e){return e.value}function fEe(e,s){if(Ne.isValidElement(e))return Ne.cloneElement(e,s);if(typeof e=="function")return Ne.createElement(e,s);s.ref;var r=mEe(s,nEe);return Ne.createElement(Y3,r)}var qU=1,gy=(function(e){function s(){var r;aEe(this,s);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return r=oEe(this,s,[].concat(a)),O_(r,"lastBoundingBox",{width:-1,height:-1}),r}return dEe(s,e),iEe(s,[{key:"componentDidMount",value:function(){this.updateBBox()}},{key:"componentDidUpdate",value:function(){this.updateBBox()}},{key:"getBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var n=this.wrapperNode.getBoundingClientRect();return n.height=this.wrapperNode.offsetHeight,n.width=this.wrapperNode.offsetWidth,n}return null}},{key:"updateBBox",value:function(){var n=this.props.onBBoxUpdate,a=this.getBBox();a?(Math.abs(a.width-this.lastBoundingBox.width)>qU||Math.abs(a.height-this.lastBoundingBox.height)>qU)&&(this.lastBoundingBox.width=a.width,this.lastBoundingBox.height=a.height,n&&n(a)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,n&&n(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?$p({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,i=a.layout,o=a.align,l=a.verticalAlign,c=a.margin,d=a.chartWidth,h=a.chartHeight,p,g;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(o==="center"&&i==="vertical"){var v=this.getBBoxSnapshot();p={left:((d||0)-v.width)/2}}else p=o==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(l==="middle"){var b=this.getBBoxSnapshot();g={top:((h||0)-b.height)/2}}else g=l==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return $p($p({},p),g)}},{key:"render",value:function(){var n=this,a=this.props,i=a.content,o=a.width,l=a.height,c=a.wrapperStyle,d=a.payloadUniqBy,h=a.payload,p=$p($p({position:"absolute",width:o||"auto",height:l||"auto"},this.getDefaultPosition(c)),c);return Ne.createElement("div",{className:"recharts-legend-wrapper",style:p,ref:function(v){n.wrapperNode=v}},fEe(i,$p($p({},this.props),{},{payload:Dse(h,d,pEe)})))}}],[{key:"getWithHeight",value:function(n,a){var i=$p($p({},this.defaultProps),n.props),o=i.layout;return o==="vertical"&&bs(n.props.height)?{height:n.props.height}:o==="horizontal"?{width:n.props.width||a}:null}}])})(u.PureComponent);O_(gy,"displayName","Legend");O_(gy,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var xA,VU;function gEe(){if(VU)return xA;VU=1;var e=uN(),s=X3(),r=Cu(),n=e?e.isConcatSpreadable:void 0;function a(i){return r(i)||s(i)||!!(n&&i&&i[n])}return xA=a,xA}var vA,WU;function Fse(){if(WU)return vA;WU=1;var e=_se(),s=gEe();function r(n,a,i,o,l){var c=-1,d=n.length;for(i||(i=s),l||(l=[]);++c<d;){var h=n[c];a>0&&i(h)?a>1?r(h,a-1,i,o,l):e(l,h):o||(l[l.length]=h)}return l}return vA=r,vA}var yA,KU;function xEe(){if(KU)return yA;KU=1;function e(s){return function(r,n,a){for(var i=-1,o=Object(r),l=a(r),c=l.length;c--;){var d=l[s?c:++i];if(n(o[d],d,o)===!1)break}return r}}return yA=e,yA}var bA,GU;function vEe(){if(GU)return bA;GU=1;var e=xEe(),s=e();return bA=s,bA}var wA,YU;function Bse(){if(YU)return wA;YU=1;var e=vEe(),s=I_();function r(n,a){return n&&e(n,a,s)}return wA=r,wA}var jA,QU;function yEe(){if(QU)return jA;QU=1;var e=hN();function s(r,n){return function(a,i){if(a==null)return a;if(!e(a))return r(a,i);for(var o=a.length,l=n?o:-1,c=Object(a);(n?l--:++l<o)&&i(c[l],l,c)!==!1;);return a}}return jA=s,jA}var NA,XU;function tD(){if(XU)return NA;XU=1;var e=Bse(),s=yEe(),r=s(e);return NA=r,NA}var SA,ZU;function Use(){if(ZU)return SA;ZU=1;var e=tD(),s=hN();function r(n,a){var i=-1,o=s(n)?Array(n.length):[];return e(n,function(l,c,d){o[++i]=a(l,c,d)}),o}return SA=r,SA}var CA,JU;function bEe(){if(JU)return CA;JU=1;function e(s,r){var n=s.length;for(s.sort(r);n--;)s[n]=s[n].value;return s}return CA=e,CA}var kA,ez;function wEe(){if(ez)return kA;ez=1;var e=Db();function s(r,n){if(r!==n){var a=r!==void 0,i=r===null,o=r===r,l=e(r),c=n!==void 0,d=n===null,h=n===n,p=e(n);if(!d&&!p&&!l&&r>n||l&&c&&h&&!d&&!p||i&&c&&h||!a&&h||!o)return 1;if(!i&&!l&&!p&&r<n||p&&a&&o&&!i&&!l||d&&a&&o||!c&&o||!h)return-1}return 0}return kA=s,kA}var _A,tz;function jEe(){if(tz)return _A;tz=1;var e=wEe();function s(r,n,a){for(var i=-1,o=r.criteria,l=n.criteria,c=o.length,d=a.length;++i<c;){var h=e(o[i],l[i]);if(h){if(i>=d)return h;var p=a[i];return h*(p=="desc"?-1:1)}}return r.index-n.index}return _A=s,_A}var PA,sz;function NEe(){if(sz)return PA;sz=1;var e=U3(),s=z3(),r=xp(),n=Use(),a=bEe(),i=Ese(),o=jEe(),l=Bb(),c=Cu();function d(h,p,g){p.length?p=e(p,function(y){return c(y)?function(w){return s(w,y.length===1?y[0]:y)}:y}):p=[l];var v=-1;p=e(p,i(r));var b=n(h,function(y,w,j){var x=e(p,function(C){return C(y)});return{criteria:x,index:++v,value:y}});return a(b,function(y,w){return o(y,w,g)})}return PA=d,PA}var EA,rz;function SEe(){if(rz)return EA;rz=1;function e(s,r,n){switch(n.length){case 0:return s.call(r);case 1:return s.call(r,n[0]);case 2:return s.call(r,n[0],n[1]);case 3:return s.call(r,n[0],n[1],n[2])}return s.apply(r,n)}return EA=e,EA}var TA,nz;function CEe(){if(nz)return TA;nz=1;var e=SEe(),s=Math.max;function r(n,a,i){return a=s(a===void 0?n.length-1:a,0),function(){for(var o=arguments,l=-1,c=s(o.length-a,0),d=Array(c);++l<c;)d[l]=o[a+l];l=-1;for(var h=Array(a+1);++l<a;)h[l]=o[l];return h[a]=i(d),e(n,this,h)}}return TA=r,TA}var AA,az;function kEe(){if(az)return AA;az=1;function e(s){return function(){return s}}return AA=e,AA}var MA,iz;function zse(){if(iz)return MA;iz=1;var e=mv(),s=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return MA=s,MA}var RA,oz;function _Ee(){if(oz)return RA;oz=1;var e=kEe(),s=zse(),r=Bb(),n=s?function(a,i){return s(a,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return RA=n,RA}var IA,lz;function PEe(){if(lz)return IA;lz=1;var e=800,s=16,r=Date.now;function n(a){var i=0,o=0;return function(){var l=r(),c=s-(l-o);if(o=l,c>0){if(++i>=e)return arguments[0]}else i=0;return a.apply(void 0,arguments)}}return IA=n,IA}var OA,cz;function EEe(){if(cz)return OA;cz=1;var e=_Ee(),s=PEe(),r=s(e);return OA=r,OA}var DA,dz;function TEe(){if(dz)return DA;dz=1;var e=Bb(),s=CEe(),r=EEe();function n(a,i){return r(s(a,i,e),a+"")}return DA=n,DA}var LA,uz;function D_(){if(uz)return LA;uz=1;var e=$3(),s=hN(),r=Z3(),n=Fg();function a(i,o,l){if(!n(l))return!1;var c=typeof o;return(c=="number"?s(l)&&r(o,l.length):c=="string"&&o in l)?e(l[o],i):!1}return LA=a,LA}var $A,mz;function AEe(){if(mz)return $A;mz=1;var e=Fse(),s=NEe(),r=TEe(),n=D_(),a=r(function(i,o){if(i==null)return[];var l=o.length;return l>1&&n(i,o[0],o[1])?o=[]:l>2&&n(o[0],o[1],o[2])&&(o=[o[0]]),s(i,e(o,1),[])});return $A=a,$A}var MEe=AEe();const sD=ei(MEe);function tj(e){"@babel/helpers - typeof";return tj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},tj(e)}function qM(){return qM=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},qM.apply(this,arguments)}function REe(e,s){return LEe(e)||DEe(e,s)||OEe(e,s)||IEe()}function IEe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
497In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function OEe(e,s){if(e){if(typeof e=="string")return hz(e,s);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 hz(e,s)}}function hz(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function DEe(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function LEe(e){if(Array.isArray(e))return e}function pz(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function FA(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?pz(Object(r),!0).forEach(function(n){$Ee(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pz(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function $Ee(e,s,r){return s=FEe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function FEe(e){var s=BEe(e,"string");return tj(s)=="symbol"?s:s+""}function BEe(e,s){if(tj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(tj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function UEe(e){return Array.isArray(e)&&Gl(e[0])&&Gl(e[1])?e.join(" ~ "):e}var zEe=function(s){var r=s.separator,n=r===void 0?" : ":r,a=s.contentStyle,i=a===void 0?{}:a,o=s.itemStyle,l=o===void 0?{}:o,c=s.labelStyle,d=c===void 0?{}:c,h=s.payload,p=s.formatter,g=s.itemSorter,v=s.wrapperClassName,b=s.labelClassName,y=s.label,w=s.labelFormatter,j=s.accessibilityLayer,x=j===void 0?!1:j,C=function(){if(h&&h.length){var $={padding:0,margin:0},O=(g?sD(h,g):h).map(function(q,V){if(q.type==="none")return null;var K=FA({display:"block",paddingTop:4,paddingBottom:4,color:q.color||"#000"},l),G=q.formatter||p||UEe,z=q.value,Z=q.name,ee=z,Q=Z;if(G&&ee!=null&&Q!=null){var Y=G(z,Z,q,V,h);if(Array.isArray(Y)){var oe=REe(Y,2);ee=oe[0],Q=oe[1]}else ee=Y}return Ne.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(V),style:K},Gl(Q)?Ne.createElement("span",{className:"recharts-tooltip-item-name"},Q):null,Gl(Q)?Ne.createElement("span",{className:"recharts-tooltip-item-separator"},n):null,Ne.createElement("span",{className:"recharts-tooltip-item-value"},ee),Ne.createElement("span",{className:"recharts-tooltip-item-unit"},q.unit||""))});return Ne.createElement("ul",{className:"recharts-tooltip-item-list",style:$},O)}return null},k=FA({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},i),S=FA({margin:0},d),_=!Tn(y),A=_?y:"",T=An("recharts-default-tooltip",v),M=An("recharts-tooltip-label",b);_&&w&&h!==void 0&&h!==null&&(A=w(y,h));var R=x?{role:"status","aria-live":"assertive"}:{};return Ne.createElement("div",qM({className:T,style:k},R),Ne.createElement("p",{className:M,style:S},Ne.isValidElement(A)?A:"".concat(A)),C())};function sj(e){"@babel/helpers - typeof";return sj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},sj(e)}function N1(e,s,r){return s=HEe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function HEe(e){var s=qEe(e,"string");return sj(s)=="symbol"?s:s+""}function qEe(e,s){if(sj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(sj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var ww="recharts-tooltip-wrapper",VEe={visibility:"hidden"};function WEe(e){var s=e.coordinate,r=e.translateX,n=e.translateY;return An(ww,N1(N1(N1(N1({},"".concat(ww,"-right"),bs(r)&&s&&bs(s.x)&&r>=s.x),"".concat(ww,"-left"),bs(r)&&s&&bs(s.x)&&r<s.x),"".concat(ww,"-bottom"),bs(n)&&s&&bs(s.y)&&n>=s.y),"".concat(ww,"-top"),bs(n)&&s&&bs(s.y)&&n<s.y))}function fz(e){var s=e.allowEscapeViewBox,r=e.coordinate,n=e.key,a=e.offsetTopLeft,i=e.position,o=e.reverseDirection,l=e.tooltipDimension,c=e.viewBox,d=e.viewBoxDimension;if(i&&bs(i[n]))return i[n];var h=r[n]-l-a,p=r[n]+a;if(s[n])return o[n]?h:p;if(o[n]){var g=h,v=c[n];return g<v?Math.max(p,c[n]):Math.max(h,c[n])}var b=p+l,y=c[n]+d;return b>y?Math.max(h,c[n]):Math.max(p,c[n])}function KEe(e){var s=e.translateX,r=e.translateY,n=e.useTranslate3d;return{transform:n?"translate3d(".concat(s,"px, ").concat(r,"px, 0)"):"translate(".concat(s,"px, ").concat(r,"px)")}}function GEe(e){var s=e.allowEscapeViewBox,r=e.coordinate,n=e.offsetTopLeft,a=e.position,i=e.reverseDirection,o=e.tooltipBox,l=e.useTranslate3d,c=e.viewBox,d,h,p;return o.height>0&&o.width>0&&r?(h=fz({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:i,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),p=fz({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:i,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),d=KEe({translateX:h,translateY:p,useTranslate3d:l})):d=VEe,{cssProperties:d,cssClasses:WEe({translateX:h,translateY:p,coordinate:r})}}function Gy(e){"@babel/helpers - typeof";return Gy=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Gy(e)}function gz(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function xz(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?gz(Object(r),!0).forEach(function(n){WM(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):gz(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function YEe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function QEe(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,qse(n.key),n)}}function XEe(e,s,r){return s&&QEe(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function ZEe(e,s,r){return s=PC(s),JEe(e,Hse()?Reflect.construct(s,r||[],PC(e).constructor):s.apply(e,r))}function JEe(e,s){if(s&&(Gy(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return eTe(e)}function eTe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Hse(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Hse=function(){return!!e})()}function PC(e){return PC=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},PC(e)}function tTe(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&VM(e,s)}function VM(e,s){return VM=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},VM(e,s)}function WM(e,s,r){return s=qse(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function qse(e){var s=sTe(e,"string");return Gy(s)=="symbol"?s:s+""}function sTe(e,s){if(Gy(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Gy(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var vz=1,rTe=(function(e){function s(){var r;YEe(this,s);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return r=ZEe(this,s,[].concat(a)),WM(r,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0},lastBoundingBox:{width:-1,height:-1}}),WM(r,"handleKeyDown",function(o){if(o.key==="Escape"){var l,c,d,h;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=(h=r.props.coordinate)===null||h===void 0?void 0:h.y)!==null&&d!==void 0?d:0}})}}),r}return tTe(s,e),XEe(s,[{key:"updateBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var n=this.wrapperNode.getBoundingClientRect();(Math.abs(n.width-this.state.lastBoundingBox.width)>vz||Math.abs(n.height-this.state.lastBoundingBox.height)>vz)&&this.setState({lastBoundingBox:{width:n.width,height:n.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 n,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.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 n=this,a=this.props,i=a.active,o=a.allowEscapeViewBox,l=a.animationDuration,c=a.animationEasing,d=a.children,h=a.coordinate,p=a.hasPayload,g=a.isAnimationActive,v=a.offset,b=a.position,y=a.reverseDirection,w=a.useTranslate3d,j=a.viewBox,x=a.wrapperStyle,C=GEe({allowEscapeViewBox:o,coordinate:h,offsetTopLeft:v,position:b,reverseDirection:y,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:j}),k=C.cssClasses,S=C.cssProperties,_=xz(xz({transition:g&&i?"transform ".concat(l,"ms ").concat(c):void 0},S),{},{pointerEvents:"none",visibility:!this.state.dismissed&&i&&p?"visible":"hidden",position:"absolute",top:0,left:0},x);return Ne.createElement("div",{tabIndex:-1,className:k,style:_,ref:function(T){n.wrapperNode=T}},d)}}])})(u.PureComponent),nTe=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},hv={isSsr:nTe()};function Yy(e){"@babel/helpers - typeof";return Yy=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Yy(e)}function yz(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function bz(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?yz(Object(r),!0).forEach(function(n){rD(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):yz(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function aTe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function iTe(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Wse(n.key),n)}}function oTe(e,s,r){return s&&iTe(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function lTe(e,s,r){return s=EC(s),cTe(e,Vse()?Reflect.construct(s,r||[],EC(e).constructor):s.apply(e,r))}function cTe(e,s){if(s&&(Yy(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return dTe(e)}function dTe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Vse(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Vse=function(){return!!e})()}function EC(e){return EC=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},EC(e)}function uTe(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&KM(e,s)}function KM(e,s){return KM=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},KM(e,s)}function rD(e,s,r){return s=Wse(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Wse(e){var s=mTe(e,"string");return Yy(s)=="symbol"?s:s+""}function mTe(e,s){if(Yy(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Yy(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function hTe(e){return e.dataKey}function pTe(e,s){return Ne.isValidElement(e)?Ne.cloneElement(e,s):typeof e=="function"?Ne.createElement(e,s):Ne.createElement(zEe,s)}var uh=(function(e){function s(){return aTe(this,s),lTe(this,s,arguments)}return uTe(s,e),oTe(s,[{key:"render",value:function(){var n=this,a=this.props,i=a.active,o=a.allowEscapeViewBox,l=a.animationDuration,c=a.animationEasing,d=a.content,h=a.coordinate,p=a.filterNull,g=a.isAnimationActive,v=a.offset,b=a.payload,y=a.payloadUniqBy,w=a.position,j=a.reverseDirection,x=a.useTranslate3d,C=a.viewBox,k=a.wrapperStyle,S=b??[];p&&S.length&&(S=Dse(b.filter(function(A){return A.value!=null&&(A.hide!==!0||n.props.includeHidden)}),y,hTe));var _=S.length>0;return Ne.createElement(rTe,{allowEscapeViewBox:o,animationDuration:l,animationEasing:c,isAnimationActive:g,active:i,coordinate:h,hasPayload:_,offset:v,position:w,reverseDirection:j,useTranslate3d:x,viewBox:C,wrapperStyle:k},pTe(d,bz(bz({},this.props),{},{payload:S})))}}])})(u.PureComponent);rD(uh,"displayName","Tooltip");rD(uh,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!hv.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 BA,wz;function fTe(){if(wz)return BA;wz=1;var e=gp(),s=function(){return e.Date.now()};return BA=s,BA}var UA,jz;function gTe(){if(jz)return UA;jz=1;var e=/\s/;function s(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return UA=s,UA}var zA,Nz;function xTe(){if(Nz)return zA;Nz=1;var e=gTe(),s=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(s,"")}return zA=r,zA}var HA,Sz;function Kse(){if(Sz)return HA;Sz=1;var e=xTe(),s=Fg(),r=Db(),n=NaN,a=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,l=parseInt;function c(d){if(typeof d=="number")return d;if(r(d))return n;if(s(d)){var h=typeof d.valueOf=="function"?d.valueOf():d;d=s(h)?h+"":h}if(typeof d!="string")return d===0?d:+d;d=e(d);var p=i.test(d);return p||o.test(d)?l(d.slice(2),p?2:8):a.test(d)?n:+d}return HA=c,HA}var qA,Cz;function vTe(){if(Cz)return qA;Cz=1;var e=Fg(),s=fTe(),r=Kse(),n="Expected a function",a=Math.max,i=Math.min;function o(l,c,d){var h,p,g,v,b,y,w=0,j=!1,x=!1,C=!0;if(typeof l!="function")throw new TypeError(n);c=r(c)||0,e(d)&&(j=!!d.leading,x="maxWait"in d,g=x?a(r(d.maxWait)||0,c):g,C="trailing"in d?!!d.trailing:C);function k(O){var q=h,V=p;return h=p=void 0,w=O,v=l.apply(V,q),v}function S(O){return w=O,b=setTimeout(T,c),j?k(O):v}function _(O){var q=O-y,V=O-w,K=c-q;return x?i(K,g-V):K}function A(O){var q=O-y,V=O-w;return y===void 0||q>=c||q<0||x&&V>=g}function T(){var O=s();if(A(O))return M(O);b=setTimeout(T,_(O))}function M(O){return b=void 0,C&&h?k(O):(h=p=void 0,v)}function R(){b!==void 0&&clearTimeout(b),w=0,h=y=p=b=void 0}function D(){return b===void 0?v:M(s())}function $(){var O=s(),q=A(O);if(h=arguments,p=this,y=O,q){if(b===void 0)return S(y);if(x)return clearTimeout(b),b=setTimeout(T,c),k(y)}return b===void 0&&(b=setTimeout(T,c)),v}return $.cancel=R,$.flush=D,$}return qA=o,qA}var VA,kz;function yTe(){if(kz)return VA;kz=1;var e=vTe(),s=Fg(),r="Expected a function";function n(a,i,o){var l=!0,c=!0;if(typeof a!="function")throw new TypeError(r);return s(o)&&(l="leading"in o?!!o.leading:l,c="trailing"in o?!!o.trailing:c),e(a,i,{leading:l,maxWait:i,trailing:c})}return VA=n,VA}var bTe=yTe();const Gse=ei(bTe);function rj(e){"@babel/helpers - typeof";return rj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},rj(e)}function _z(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function S1(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?_z(Object(r),!0).forEach(function(n){wTe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_z(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function wTe(e,s,r){return s=jTe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function jTe(e){var s=NTe(e,"string");return rj(s)=="symbol"?s:s+""}function NTe(e,s){if(rj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(rj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function STe(e,s){return PTe(e)||_Te(e,s)||kTe(e,s)||CTe()}function CTe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
498In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kTe(e,s){if(e){if(typeof e=="string")return Pz(e,s);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 Pz(e,s)}}function Pz(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function _Te(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function PTe(e){if(Array.isArray(e))return e}var nD=u.forwardRef(function(e,s){var r=e.aspect,n=e.initialDimension,a=n===void 0?{width:-1,height:-1}:n,i=e.width,o=i===void 0?"100%":i,l=e.height,c=l===void 0?"100%":l,d=e.minWidth,h=d===void 0?0:d,p=e.minHeight,g=e.maxHeight,v=e.children,b=e.debounce,y=b===void 0?0:b,w=e.id,j=e.className,x=e.onResize,C=e.style,k=C===void 0?{}:C,S=u.useRef(null),_=u.useRef();_.current=x,u.useImperativeHandle(s,function(){return Object.defineProperty(S.current,"current",{get:function(){return console.warn("The usage of ref.current.current is deprecated and will no longer be supported."),S.current},configurable:!0})});var A=u.useState({containerWidth:a.width,containerHeight:a.height}),T=STe(A,2),M=T[0],R=T[1],D=u.useCallback(function(O,q){R(function(V){var K=Math.round(O),G=Math.round(q);return V.containerWidth===K&&V.containerHeight===G?V:{containerWidth:K,containerHeight:G}})},[]);u.useEffect(function(){var O=function(Z){var ee,Q=Z[0].contentRect,Y=Q.width,oe=Q.height;D(Y,oe),(ee=_.current)===null||ee===void 0||ee.call(_,Y,oe)};y>0&&(O=Gse(O,y,{trailing:!0,leading:!1}));var q=new ResizeObserver(O),V=S.current.getBoundingClientRect(),K=V.width,G=V.height;return D(K,G),q.observe(S.current),function(){q.disconnect()}},[D,y]);var $=u.useMemo(function(){var O=M.containerWidth,q=M.containerHeight;if(O<0||q<0)return null;yh(_x(o)||_x(c),`The width(%s) and height(%s) are both fixed numbers,
499       maybe you don't need to use a ResponsiveContainer.`,o,c),yh(!r||r>0,"The aspect(%s) must be greater than zero.",r);var V=_x(o)?O:o,K=_x(c)?q:c;r&&r>0&&(V?K=V/r:K&&(V=K*r),g&&K>g&&(K=g)),yh(V>0||K>0,`The width(%s) and height(%s) of chart should be greater than 0,
500       please check the style of container, or the props width(%s) and height(%s),
501       or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
502       height and width.`,V,K,o,c,h,p,r);var G=!Array.isArray(v)&&lf(v.type).endsWith("Chart");return Ne.Children.map(v,function(z){return Ne.isValidElement(z)?u.cloneElement(z,S1({width:V,height:K},G?{style:S1({height:"100%",width:"100%",maxHeight:K,maxWidth:V},z.props.style)}:{})):z})},[r,v,c,g,p,h,M,o]);return Ne.createElement("div",{id:w?"".concat(w):void 0,className:An("recharts-responsive-container",j),style:S1(S1({},k),{},{width:o,height:c,minWidth:h,minHeight:p,maxHeight:g}),ref:S},$)}),nj=function(s){return null};nj.displayName="Cell";function aj(e){"@babel/helpers - typeof";return aj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},aj(e)}function Ez(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function GM(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Ez(Object(r),!0).forEach(function(n){ETe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ez(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ETe(e,s,r){return s=TTe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function TTe(e){var s=ATe(e,"string");return aj(s)=="symbol"?s:s+""}function ATe(e,s){if(aj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(aj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var Bv={widthCache:{},cacheCount:0},MTe=2e3,RTe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},Tz="recharts_measurement_span";function ITe(e){var s=GM({},e);return Object.keys(s).forEach(function(r){s[r]||delete s[r]}),s}var h0=function(s){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||hv.isSsr)return{width:0,height:0};var n=ITe(r),a=JSON.stringify({text:s,copyStyle:n});if(Bv.widthCache[a])return Bv.widthCache[a];try{var i=document.getElementById(Tz);i||(i=document.createElement("span"),i.setAttribute("id",Tz),i.setAttribute("aria-hidden","true"),document.body.appendChild(i));var o=GM(GM({},RTe),n);Object.assign(i.style,o),i.textContent="".concat(s);var l=i.getBoundingClientRect(),c={width:l.width,height:l.height};return Bv.widthCache[a]=c,++Bv.cacheCount>MTe&&(Bv.cacheCount=0,Bv.widthCache={}),c}catch{return{width:0,height:0}}},OTe=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};function ij(e){"@babel/helpers - typeof";return ij=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},ij(e)}function TC(e,s){return FTe(e)||$Te(e,s)||LTe(e,s)||DTe()}function DTe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
503In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function LTe(e,s){if(e){if(typeof e=="string")return Az(e,s);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 Az(e,s)}}function Az(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function $Te(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function FTe(e){if(Array.isArray(e))return e}function BTe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function Mz(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,zTe(n.key),n)}}function UTe(e,s,r){return s&&Mz(e.prototype,s),r&&Mz(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function zTe(e){var s=HTe(e,"string");return ij(s)=="symbol"?s:s+""}function HTe(e,s){if(ij(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(ij(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Rz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Iz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,qTe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,VTe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,Yse={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},WTe=Object.keys(Yse),Xv="NaN";function KTe(e,s){return e*Yse[s]}var C1=(function(){function e(s,r){BTe(this,e),this.num=s,this.unit=r,this.num=s,this.unit=r,Number.isNaN(s)&&(this.unit=""),r!==""&&!qTe.test(r)&&(this.num=NaN,this.unit=""),WTe.includes(r)&&(this.num=KTe(s,r),this.unit="px")}return UTe(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 n,a=(n=VTe.exec(r))!==null&&n!==void 0?n:[],i=TC(a,3),o=i[1],l=i[2];return new e(parseFloat(o),l??"")}}])})();function Qse(e){if(e.includes(Xv))return Xv;for(var s=e;s.includes("*")||s.includes("/");){var r,n=(r=Rz.exec(s))!==null&&r!==void 0?r:[],a=TC(n,4),i=a[1],o=a[2],l=a[3],c=C1.parse(i??""),d=C1.parse(l??""),h=o==="*"?c.multiply(d):c.divide(d);if(h.isNaN())return Xv;s=s.replace(Rz,h.toString())}for(;s.includes("+")||/.-\d+(?:\.\d+)?/.test(s);){var p,g=(p=Iz.exec(s))!==null&&p!==void 0?p:[],v=TC(g,4),b=v[1],y=v[2],w=v[3],j=C1.parse(b??""),x=C1.parse(w??""),C=y==="+"?j.add(x):j.subtract(x);if(C.isNaN())return Xv;s=s.replace(Iz,C.toString())}return s}var Oz=/\(([^()]*)\)/;function GTe(e){for(var s=e;s.includes("(");){var r=Oz.exec(s),n=TC(r,2),a=n[1];s=s.replace(Oz,Qse(a))}return s}function YTe(e){var s=e.replace(/\s+/g,"");return s=GTe(s),s=Qse(s),s}function QTe(e){try{return YTe(e)}catch{return Xv}}function WA(e){var s=QTe(e.slice(5,-1));return s===Xv?"":s}var XTe=["x","y","lineHeight","capHeight","scaleToFit","textAnchor","verticalAnchor","fill"],ZTe=["dx","dy","angle","className","breakAll"];function YM(){return YM=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];
503for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},YM.apply(this,arguments)}function Dz(e,s){if(e==null)return{};var r=JTe(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function JTe(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Lz(e,s){return rAe(e)||sAe(e,s)||tAe(e,s)||eAe()}function eAe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
504In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tAe(e,s){if(e){if(typeof e=="string")return $z(e,s);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 $z(e,s)}}function $z(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function sAe(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function rAe(e){if(Array.isArray(e))return e}var Xse=/[ \f\n\r\t\v\u2028\u2029]+/,Zse=function(s){var r=s.children,n=s.breakAll,a=s.style;try{var i=[];Tn(r)||(n?i=r.toString().split(""):i=r.toString().split(Xse));var o=i.map(function(c){return{word:c,width:h0(c,a).width}}),l=n?0:h0(" ",a).width;return{wordsWithComputedWidth:o,spaceWidth:l}}catch{return null}},nAe=function(s,r,n,a,i){var o=s.maxLines,l=s.children,c=s.style,d=s.breakAll,h=bs(o),p=l,g=function(){var V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return V.reduce(function(K,G){var z=G.word,Z=G.width,ee=K[K.length-1];if(ee&&(a==null||i||ee.width+Z+n<Number(a)))ee.words.push(z),ee.width+=Z+n;else{var Q={words:[z],width:Z};K.push(Q)}return K},[])},v=g(r),b=function(V){return V.reduce(function(K,G){return K.width>G.width?K:G})};if(!h)return v;for(var y="…",w=function(V){var K=p.slice(0,V),G=Zse({breakAll:d,style:c,children:K+y}).wordsWithComputedWidth,z=g(G),Z=z.length>o||b(z).width>Number(a);return[Z,z]},j=0,x=p.length-1,C=0,k;j<=x&&C<=p.length-1;){var S=Math.floor((j+x)/2),_=S-1,A=w(_),T=Lz(A,2),M=T[0],R=T[1],D=w(S),$=Lz(D,1),O=$[0];if(!M&&!O&&(j=S+1),M&&O&&(x=S-1),!M&&O){k=R;break}C++}return k||v},Fz=function(s){var r=Tn(s)?[]:s.toString().split(Xse);return[{words:r}]},aAe=function(s){var r=s.width,n=s.scaleToFit,a=s.children,i=s.style,o=s.breakAll,l=s.maxLines;if((r||n)&&!hv.isSsr){var c,d,h=Zse({breakAll:o,children:a,style:i});if(h){var p=h.wordsWithComputedWidth,g=h.spaceWidth;c=p,d=g}else return Fz(a);return nAe({breakAll:o,children:a,maxLines:l,style:i},c,d,r,n)}return Fz(a)},Bz="#808080",tv=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,i=a===void 0?0:a,o=s.lineHeight,l=o===void 0?"1em":o,c=s.capHeight,d=c===void 0?"0.71em":c,h=s.scaleToFit,p=h===void 0?!1:h,g=s.textAnchor,v=g===void 0?"start":g,b=s.verticalAnchor,y=b===void 0?"end":b,w=s.fill,j=w===void 0?Bz:w,x=Dz(s,XTe),C=u.useMemo(function(){return aAe({breakAll:x.breakAll,children:x.children,maxLines:x.maxLines,scaleToFit:p,style:x.style,width:x.width})},[x.breakAll,x.children,x.maxLines,p,x.style,x.width]),k=x.dx,S=x.dy,_=x.angle,A=x.className,T=x.breakAll,M=Dz(x,ZTe);if(!Gl(n)||!Gl(i))return null;var R=n+(bs(k)?k:0),D=i+(bs(S)?S:0),$;switch(y){case"start":$=WA("calc(".concat(d,")"));break;case"middle":$=WA("calc(".concat((C.length-1)/2," * -").concat(l," + (").concat(d," / 2))"));break;default:$=WA("calc(".concat(C.length-1," * -").concat(l,")"));break}var O=[];if(p){var q=C[0].width,V=x.width;O.push("scale(".concat((bs(V)?V/q:1)/q,")"))}return _&&O.push("rotate(".concat(_,", ").concat(R,", ").concat(D,")")),O.length&&(M.transform=O.join(" ")),Ne.createElement("text",YM({},Mr(M,!0),{x:R,y:D,className:An("recharts-text",A),textAnchor:v,fill:j.includes("url")?Bz:j}),C.map(function(K,G){var z=K.words.join(T?"":" ");return Ne.createElement("tspan",{x:R,dy:G===0?$:l,key:"".concat(z,"-").concat(G)},z)}))};function Ng(e,s){return e==null||s==null?NaN:e<s?-1:e>s?1:e>=s?0:NaN}function iAe(e,s){return e==null||s==null?NaN:s<e?-1:s>e?1:s>=e?0:NaN}function aD(e){let s,r,n;e.length!==2?(s=Ng,r=(l,c)=>Ng(e(l),c),n=(l,c)=>e(l)-c):(s=e===Ng||e===iAe?e:oAe,r=e,n=e);function a(l,c,d=0,h=l.length){if(d<h){if(s(c,c)!==0)return h;do{const p=d+h>>>1;r(l[p],c)<0?d=p+1:h=p}while(d<h)}return d}function i(l,c,d=0,h=l.length){if(d<h){if(s(c,c)!==0)return h;do{const p=d+h>>>1;r(l[p],c)<=0?d=p+1:h=p}while(d<h)}return d}function o(l,c,d=0,h=l.length){const p=a(l,c,d,h-1);return p>d&&n(l[p-1],c)>-n(l[p],c)?p-1:p}return{left:a,center:o,right:i}}function oAe(){return 0}function Jse(e){return e===null?NaN:+e}function*lAe(e,s){for(let r of e)r!=null&&(r=+r)>=r&&(yield r)}const cAe=aD(Ng),pN=cAe.right;aD(Jse).center;class Uz extends Map{constructor(s,r=mAe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),s!=null)for(const[n,a]of s)this.set(n,a)}get(s){return super.get(zz(this,s))}has(s){return super.has(zz(this,s))}set(s,r){return super.set(dAe(this,s),r)}delete(s){return super.delete(uAe(this,s))}}function zz({_intern:e,_key:s},r){const n=s(r);return e.has(n)?e.get(n):r}function dAe({_intern:e,_key:s},r){const n=s(r);return e.has(n)?e.get(n):(e.set(n,r),r)}function uAe({_intern:e,_key:s},r){const n=s(r);return e.has(n)&&(r=e.get(n),e.delete(n)),r}function mAe(e){return e!==null&&typeof e=="object"?e.valueOf():e}function hAe(e=Ng){if(e===Ng)return ere;if(typeof e!="function")throw new TypeError("compare is not a function");return(s,r)=>{const n=e(s,r);return n||n===0?n:(e(r,r)===0)-(e(s,s)===0)}}function ere(e,s){return(e==null||!(e>=e))-(s==null||!(s>=s))||(e<s?-1:e>s?1:0)}const pAe=Math.sqrt(50),fAe=Math.sqrt(10),gAe=Math.sqrt(2);function AC(e,s,r){const n=(s-e)/Math.max(0,r),a=Math.floor(Math.log10(n)),i=n/Math.pow(10,a),o=i>=pAe?10:i>=fAe?5:i>=gAe?2:1;let l,c,d;return a<0?(d=Math.pow(10,-a)/o,l=Math.round(e*d),c=Math.round(s*d),l/d<e&&++l,c/d>s&&--c,d=-d):(d=Math.pow(10,a)*o,l=Math.round(e/d),c=Math.round(s/d),l*d<e&&++l,c*d>s&&--c),c<l&&.5<=r&&r<2?AC(e,s,r*2):[l,c,d]}function QM(e,s,r){if(s=+s,e=+e,r=+r,!(r>0))return[];if(e===s)return[e];const n=s<e,[a,i,o]=n?AC(s,e,r):AC(e,s,r);if(!(i>=a))return[];const l=i-a+1,c=new Array(l);if(n)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 XM(e,s,r){return s=+s,e=+e,r=+r,AC(e,s,r)[2]}function ZM(e,s,r){s=+s,e=+e,r=+r;const n=s<e,a=n?XM(s,e,r):XM(e,s,r);return(n?-1:1)*(a<0?1/-a:a)}function Hz(e,s){let r;for(const n of e)n!=null&&(r<n||r===void 0&&n>=n)&&(r=n);return r}function qz(e,s){let r;for(const n of e)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function tre(e,s,r=0,n=1/0,a){if(s=Math.floor(s),r=Math.floor(Math.max(0,r)),n=Math.floor(Math.min(e.length-1,n)),!(r<=s&&s<=n))return e;for(a=a===void 0?ere:hAe(a);n>r;){if(n-r>600){const c=n-r+1,d=s-r+1,h=Math.log(c),p=.5*Math.exp(2*h/3),g=.5*Math.sqrt(h*p*(c-p)/c)*(d-c/2<0?-1:1),v=Math.max(r,Math.floor(s-d*p/c+g)),b=Math.min(n,Math.floor(s+(c-d)*p/c+g));tre(e,s,v,b,a)}const i=e[s];let o=r,l=n;for(jw(e,r,s),a(e[n],i)>0&&jw(e,r,n);o<l;){for(jw(e,o,l),++o,--l;a(e[o],i)<0;)++o;for(;a(e[l],i)>0;)--l}a(e[r],i)===0?jw(e,r,l):(++l,jw(e,l,n)),l<=s&&(r=l+1),s<=l&&(n=l-1)}return e}function jw(e,s,r){const n=e[s];e[s]=e[r],e[r]=n}function xAe(e,s,r){if(e=Float64Array.from(lAe(e)),!(!(n=e.length)||isNaN(s=+s))){if(s<=0||n<2)return qz(e);if(s>=1)return Hz(e);var n,a=(n-1)*s,i=Math.floor(a),o=Hz(tre(e,i).subarray(0,i+1)),l=qz(e.subarray(i+1));return o+(l-o)*(a-i)}}function vAe(e,s,r=Jse){if(!(!(n=e.length)||isNaN(s=+s))){if(s<=0||n<2)return+r(e[0],0,e);if(s>=1)return+r(e[n-1],n-1,e);var n,a=(n-1)*s,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 yAe(e,s,r){e=+e,s=+s,r=(a=arguments.length)<2?(s=e,e=0,1):a<3?1:+r;for(var n=-1,a=Math.max(0,Math.ceil((s-e)/r))|0,i=new Array(a);++n<a;)i[n]=e+n*r;return i}function Fm(e,s){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(s).domain(e);break}return this}function _f(e,s){switch(arguments.length){case 0:break;case 1:{typeof e=="function"?this.interpolator(e):this.range(e);break}default:{this.domain(e),typeof s=="function"?this.interpolator(s):this.range(s);break}}return this}
vendor: 11,376 bytes, line 504
504const JM=Symbol("implicit");function iD(){var e=new Uz,s=[],r=[],n=JM;function a(i){let o=e.get(i);if(o===void 0){if(n!==JM)return n;e.set(i,o=s.push(i)-1)}return r[o%r.length]}return a.domain=function(i){if(!arguments.length)return s.slice();s=[],e=new Uz;for(const o of i)e.has(o)||e.set(o,s.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?(n=i,a):n},a.copy=function(){return iD(s,r).unknown(n)},Fm.apply(a,arguments),a}function oj(){var e=iD().unknown(void 0),s=e.domain,r=e.range,n=0,a=1,i,o,l=!1,c=0,d=0,h=.5;delete e.unknown;function p(){var g=s().length,v=a<n,b=v?a:n,y=v?n:a;i=(y-b)/Math.max(1,g-c+d*2),l&&(i=Math.floor(i)),b+=(y-b-i*(g-c))*h,o=i*(1-c),l&&(b=Math.round(b),o=Math.round(o));var w=yAe(g).map(function(j){return b+i*j});return r(v?w.reverse():w)}return e.domain=function(g){return arguments.length?(s(g),p()):s()},e.range=function(g){return arguments.length?([n,a]=g,n=+n,a=+a,p()):[n,a]},e.rangeRound=function(g){return[n,a]=g,n=+n,a=+a,l=!0,p()},e.bandwidth=function(){return o},e.step=function(){return i},e.round=function(g){return arguments.length?(l=!!g,p()):l},e.padding=function(g){return arguments.length?(c=Math.min(1,d=+g),p()):c},e.paddingInner=function(g){return arguments.length?(c=Math.min(1,g),p()):c},e.paddingOuter=function(g){return arguments.length?(d=+g,p()):d},e.align=function(g){return arguments.length?(h=Math.max(0,Math.min(1,g)),p()):h},e.copy=function(){return oj(s(),[n,a]).round(l).paddingInner(c).paddingOuter(d).align(h)},Fm.apply(p(),arguments)}function sre(e){var s=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return sre(s())},e}function p0(){return sre(oj.apply(null,arguments).paddingInner(1))}function oD(e,s,r){e.prototype=s.prototype=r,r.constructor=e}function rre(e,s){var r=Object.create(e.prototype);for(var n in s)r[n]=s[n];return r}function fN(){}var lj=.7,MC=1/lj,xy="\\s*([+-]?\\d+)\\s*",cj="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",rp="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",bAe=/^#([0-9a-f]{3,8})$/,wAe=new RegExp(`^rgb\\(${xy},${xy},${xy}\\)$`),jAe=new RegExp(`^rgb\\(${rp},${rp},${rp}\\)$`),NAe=new RegExp(`^rgba\\(${xy},${xy},${xy},${cj}\\)$`),SAe=new RegExp(`^rgba\\(${rp},${rp},${rp},${cj}\\)$`),CAe=new RegExp(`^hsl\\(${cj},${rp},${rp}\\)$`),kAe=new RegExp(`^hsla\\(${cj},${rp},${rp},${cj}\\)$`),Vz={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};oD(fN,dj,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Wz,formatHex:Wz,formatHex8:_Ae,formatHsl:PAe,formatRgb:Kz,toString:Kz});function Wz(){return this.rgb().formatHex()}function _Ae(){return this.rgb().formatHex8()}function PAe(){return nre(this).formatHsl()}function Kz(){return this.rgb().formatRgb()}function dj(e){var s,r;return e=(e+"").trim().toLowerCase(),(s=bAe.exec(e))?(r=s[1].length,s=parseInt(s[1],16),r===6?Gz(s):r===3?new bu(s>>8&15|s>>4&240,s>>4&15|s&240,(s&15)<<4|s&15,1):r===8?k1(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?k1(s>>12&15|s>>8&240,s>>8&15|s>>4&240,s>>4&15|s&240,((s&15)<<4|s&15)/255):null):(s=wAe.exec(e))?new bu(s[1],s[2],s[3],1):(s=jAe.exec(e))?new bu(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=NAe.exec(e))?k1(s[1],s[2],s[3],s[4]):(s=SAe.exec(e))?k1(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=CAe.exec(e))?Xz(s[1],s[2]/100,s[3]/100,1):(s=kAe.exec(e))?Xz(s[1],s[2]/100,s[3]/100,s[4]):Vz.hasOwnProperty(e)?Gz(Vz[e]):e==="transparent"?new bu(NaN,NaN,NaN,0):null}function Gz(e){return new bu(e>>16&255,e>>8&255,e&255,1)}function k1(e,s,r,n){return n<=0&&(e=s=r=NaN),new bu(e,s,r,n)}function EAe(e){return e instanceof fN||(e=dj(e)),e?(e=e.rgb(),new bu(e.r,e.g,e.b,e.opacity)):new bu}function eR(e,s,r,n){return arguments.length===1?EAe(e):new bu(e,s,r,n??1)}function bu(e,s,r,n){this.r=+e,this.g=+s,this.b=+r,this.opacity=+n}oD(bu,eR,rre(fN,{brighter(e){return e=e==null?MC:Math.pow(MC,e),new bu(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?lj:Math.pow(lj,e),new bu(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new bu(Dx(this.r),Dx(this.g),Dx(this.b),RC(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:Yz,formatHex:Yz,formatHex8:TAe,formatRgb:Qz,toString:Qz}));function Yz(){return`#${Px(this.r)}${Px(this.g)}${Px(this.b)}`}function TAe(){return`#${Px(this.r)}${Px(this.g)}${Px(this.b)}${Px((isNaN(this.opacity)?1:this.opacity)*255)}`}function Qz(){const e=RC(this.opacity);return`${e===1?"rgb(":"rgba("}${Dx(this.r)}, ${Dx(this.g)}, ${Dx(this.b)}${e===1?")":`, ${e})`}`}function RC(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Dx(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Px(e){return e=Dx(e),(e<16?"0":"")+e.toString(16)}function Xz(e,s,r,n){return n<=0?e=s=r=NaN:r<=0||r>=1?e=s=NaN:s<=0&&(e=NaN),new gh(e,s,r,n)}function nre(e){if(e instanceof gh)return new gh(e.h,e.s,e.l,e.opacity);if(e instanceof fN||(e=dj(e)),!e)return new gh;if(e instanceof gh)return e;e=e.rgb();var s=e.r/255,r=e.g/255,n=e.b/255,a=Math.min(s,r,n),i=Math.max(s,r,n),o=NaN,l=i-a,c=(i+a)/2;return l?(s===i?o=(r-n)/l+(r<n)*6:r===i?o=(n-s)/l+2:o=(s-r)/l+4,l/=c<.5?i+a:2-i-a,o*=60):l=c>0&&c<1?0:o,new gh(o,l,c,e.opacity)}function AAe(e,s,r,n){return arguments.length===1?nre(e):new gh(e,s,r,n??1)}function gh(e,s,r,n){this.h=+e,this.s=+s,this.l=+r,this.opacity=+n}oD(gh,AAe,rre(fN,{brighter(e){return e=e==null?MC:Math.pow(MC,e),new gh(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?lj:Math.pow(lj,e),new gh(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,s=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*s,a=2*r-n;return new bu(KA(e>=240?e-240:e+120,a,n),KA(e,a,n),KA(e<120?e+240:e-120,a,n),this.opacity)},clamp(){return new gh(Zz(this.h),_1(this.s),_1(this.l),RC(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=RC(this.opacity);return`${e===1?"hsl(":"hsla("}${Zz(this.h)}, ${_1(this.s)*100}%, ${_1(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Zz(e){return e=(e||0)%360,e<0?e+360:e}function _1(e){return Math.max(0,Math.min(1,e||0))}function KA(e,s,r){return(e<60?s+(r-s)*e/60:e<180?r:e<240?s+(r-s)*(240-e)/60:s)*255}const lD=e=>()=>e;function MAe(e,s){return function(r){return e+r*s}}function RAe(e,s,r){return e=Math.pow(e,r),s=Math.pow(s,r)-e,r=1/r,function(n){return Math.pow(e+n*s,r)}}function IAe(e){return(e=+e)==1?are:function(s,r){return r-s?RAe(s,r,e):lD(isNaN(s)?r:s)}}function are(e,s){var r=s-e;return r?MAe(e,r):lD(isNaN(e)?s:e)}const Jz=(function e(s){var r=IAe(s);function n(a,i){var o=r((a=eR(a)).r,(i=eR(i)).r),l=r(a.g,i.g),c=r(a.b,i.b),d=are(a.opacity,i.opacity);return function(h){return a.r=o(h),a.g=l(h),a.b=c(h),a.opacity=d(h),a+""}}return n.gamma=e,n})(1);function OAe(e,s){s||(s=[]);var r=e?Math.min(s.length,e.length):0,n=s.slice(),a;return function(i){for(a=0;a<r;++a)n[a]=e[a]*(1-i)+s[a]*i;return n}}function DAe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function LAe(e,s){var r=s?s.length:0,n=e?Math.min(r,e.length):0,a=new Array(n),i=new Array(r),o;for(o=0;o<n;++o)a[o]=Ub(e[o],s[o]);for(;o<r;++o)i[o]=s[o];return function(l){for(o=0;o<n;++o)i[o]=a[o](l);return i}}function $Ae(e,s){var r=new Date;return e=+e,s=+s,function(n){return r.setTime(e*(1-n)+s*n),r}}function IC(e,s){return e=+e,s=+s,function(r){return e*(1-r)+s*r}}function FAe(e,s){var r={},n={},a;(e===null||typeof e!="object")&&(e={}),(s===null||typeof s!="object")&&(s={});for(a in s)a in e?r[a]=Ub(e[a],s[a]):n[a]=s[a];return function(i){for(a in r)n[a]=r[a](i);return n}}var tR=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,GA=new RegExp(tR.source,"g");function BAe(e){return function(){return e}}function UAe(e){return function(s){return e(s)+""}}function zAe(e,s){var r=tR.lastIndex=GA.lastIndex=0,n,a,i,o=-1,l=[],c=[];for(e=e+"",s=s+"";(n=tR.exec(e))&&(a=GA.exec(s));)(i=a.index)>r&&(i=s.slice(r,i),l[o]?l[o]+=i:l[++o]=i),(n=n[0])===(a=a[0])?l[o]?l[o]+=a:l[++o]=a:(l[++o]=null,c.push({i:o,x:IC(n,a)})),r=GA.lastIndex;return r<s.length&&(i=s.slice(r),l[o]?l[o]+=i:l[++o]=i),l.length<2?c[0]?UAe(c[0].x):BAe(s):(s=c.length,function(d){for(var h=0,p;h<s;++h)l[(p=c[h]).i]=p.x(d);return l.join("")})}function Ub(e,s){var r=typeof s,n;return s==null||r==="boolean"?lD(s):(r==="number"?IC:r==="string"?(n=dj(s))?(s=n,Jz):zAe:s instanceof dj?Jz:s instanceof Date?$Ae:DAe(s)?OAe:Array.isArray(s)?LAe:typeof s.valueOf!="function"&&typeof s.toString!="function"||isNaN(s)?FAe:IC)(e,s)}
vendor: 4,573 bytes, line 504
504function cD(e,s){return e=+e,s=+s,function(r){return Math.round(e*(1-r)+s*r)}}function HAe(e,s){s===void 0&&(s=e,e=Ub);for(var r=0,n=s.length-1,a=s[0],i=new Array(n<0?0:n);r<n;)i[r]=e(a,a=s[++r]);return function(o){var l=Math.max(0,Math.min(n-1,Math.floor(o*=n)));return i[l](o-l)}}function qAe(e){return function(){return e}}function OC(e){return+e}var eH=[0,1];function Kd(e){return e}function sR(e,s){return(s-=e=+e)?function(r){return(r-e)/s}:qAe(isNaN(s)?NaN:.5)}function VAe(e,s){var r;return e>s&&(r=e,e=s,s=r),function(n){return Math.max(e,Math.min(s,n))}}function WAe(e,s,r){var n=e[0],a=e[1],i=s[0],o=s[1];return a<n?(n=sR(a,n),i=r(o,i)):(n=sR(n,a),i=r(i,o)),function(l){return i(n(l))}}function KAe(e,s,r){var n=Math.min(e.length,s.length)-1,a=new Array(n),i=new Array(n),o=-1;for(e[n]<e[0]&&(e=e.slice().reverse(),s=s.slice().reverse());++o<n;)a[o]=sR(e[o],e[o+1]),i[o]=r(s[o],s[o+1]);return function(l){var c=pN(e,l,1,n)-1;return i[c](a[c](l))}}function gN(e,s){return s.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function L_(){var e=eH,s=eH,r=Ub,n,a,i,o=Kd,l,c,d;function h(){var g=Math.min(e.length,s.length);return o!==Kd&&(o=VAe(e[0],e[g-1])),l=g>2?KAe:WAe,c=d=null,p}function p(g){return g==null||isNaN(g=+g)?i:(c||(c=l(e.map(n),s,r)))(n(o(g)))}return p.invert=function(g){return o(a((d||(d=l(s,e.map(n),IC)))(g)))},p.domain=function(g){return arguments.length?(e=Array.from(g,OC),h()):e.slice()},p.range=function(g){return arguments.length?(s=Array.from(g),h()):s.slice()},p.rangeRound=function(g){return s=Array.from(g),r=cD,h()},p.clamp=function(g){return arguments.length?(o=g?!0:Kd,h()):o!==Kd},p.interpolate=function(g){return arguments.length?(r=g,h()):r},p.unknown=function(g){return arguments.length?(i=g,p):i},function(g,v){return n=g,a=v,h()}}function dD(){return L_()(Kd,Kd)}function GAe(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function DC(e,s){if((r=(e=s?e.toExponential(s-1):e.toExponential()).indexOf("e"))<0)return null;var r,n=e.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+e.slice(r+1)]}function Qy(e){return e=DC(Math.abs(e)),e?e[1]:NaN}function YAe(e,s){return function(r,n){for(var a=r.length,i=[],o=0,l=e[0],c=0;a>0&&l>0&&(c+l+1>n&&(l=Math.max(1,n-c)),i.push(r.substring(a-=l,a+l)),!((c+=l+1)>n));)l=e[o=(o+1)%e.length];return i.reverse().join(s)}}function QAe(e){return function(s){return s.replace(/[0-9]/g,function(r){return e[+r]})}}var XAe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function uj(e){if(!(s=XAe.exec(e)))throw new Error("invalid format: "+e);var s;return new uD({fill:s[1],align:s[2],sign:s[3],symbol:s[4],zero:s[5],width:s[6],comma:s[7],precision:s[8]&&s[8].slice(1),trim:s[9],type:s[10]})}uj.prototype=uD.prototype;function uD(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+""}uD.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 ZAe(e){e:for(var s=e.length,r=1,n=-1,a;r<s;++r)switch(e[r]){case".":n=a=r;break;case"0":n===0&&(n=r),a=r;break;default:if(!+e[r])break e;n>0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(a+1):e}var ire;function JAe(e,s){var r=DC(e,s);if(!r)return e+"";var n=r[0],a=r[1],i=a-(ire=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,o=n.length;return i===o?n:i>o?n+new Array(i-o+1).join("0"):i>0?n.slice(0,i)+"."+n.slice(i):"0."+new Array(1-i).join("0")+DC(e,Math.max(0,s+i-1))[0]}function tH(e,s){var r=DC(e,s);if(!r)return e+"";var n=r[0],a=r[1];return a<0?"0."+new Array(-a).join("0")+n:n.length>a+1?n.slice(0,a+1)+"."+n.slice(a+1):n+new Array(a-n.length+2).join("0")}const sH={"%":(e,s)=>(e*100).toFixed(s),b:e=>Math.round(e).toString(2),c:e=>e+"",d:GAe,e:(e,s)=>e.toExponential(s),f:(e,s)=>e.toFixed(s),g:(e,s)=>e.toPrecision(s),o:e=>Math.round(e).toString(8),p:(e,s)=>tH(e*100,s),r:tH,s:JAe,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function rH(e){return e}var nH=Array.prototype.map,aH=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];
504function e4e(e){var s=e.grouping===void 0||e.thousands===void 0?rH:YAe(nH.call(e.grouping,Number),e.thousands+""),r=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",a=e.decimal===void 0?".":e.decimal+"",i=e.numerals===void 0?rH:QAe(nH.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(p){p=uj(p);var g=p.fill,v=p.align,b=p.sign,y=p.symbol,w=p.zero,j=p.width,x=p.comma,C=p.precision,k=p.trim,S=p.type;S==="n"?(x=!0,S="g"):sH[S]||(C===void 0&&(C=12),k=!0,S="g"),(w||g==="0"&&v==="=")&&(w=!0,g="0",v="=");var _=y==="$"?r:y==="#"&&/[boxX]/.test(S)?"0"+S.toLowerCase():"",A=y==="$"?n:/[%p]/.test(S)?o:"",T=sH[S],M=/[defgprs%]/.test(S);C=C===void 0?6:/[gprs]/.test(S)?Math.max(1,Math.min(21,C)):Math.max(0,Math.min(20,C));function R(D){var $=_,O=A,q,V,K;if(S==="c")O=T(D)+O,D="";else{D=+D;var G=D<0||1/D<0;if(D=isNaN(D)?c:T(Math.abs(D),C),k&&(D=ZAe(D)),G&&+D==0&&b!=="+"&&(G=!1),$=(G?b==="("?b:l:b==="-"||b==="("?"":b)+$,O=(S==="s"?aH[8+ire/3]:"")+O+(G&&b==="("?")":""),M){for(q=-1,V=D.length;++q<V;)if(K=D.charCodeAt(q),48>K||K>57){O=(K===46?a+D.slice(q+1):D.slice(q))+O,D=D.slice(0,q);break}}}x&&!w&&(D=s(D,1/0));var z=$.length+D.length+O.length,Z=z<j?new Array(j-z+1).join(g):"";switch(x&&w&&(D=s(Z+D,Z.length?j-O.length:1/0),Z=""),v){case"<":D=$+D+O+Z;break;case"=":D=$+Z+D+O;break;case"^":D=Z.slice(0,z=Z.length>>1)+$+D+O+Z.slice(z);break;default:D=Z+$+D+O;break}return i(D)}return R.toString=function(){return p+""},R}function h(p,g){var v=d((p=uj(p),p.type="f",p)),b=Math.max(-8,Math.min(8,Math.floor(Qy(g)/3)))*3,y=Math.pow(10,-b),w=aH[8+b/3];return function(j){return v(y*j)+w}}return{format:d,formatPrefix:h}}var P1,mD,ore;t4e({thousands:",",grouping:[3],currency:["$",""]});function t4e(e){return P1=e4e(e),mD=P1.format,ore=P1.formatPrefix,P1}function s4e(e){return Math.max(0,-Qy(Math.abs(e)))}function r4e(e,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Qy(s)/3)))*3-Qy(Math.abs(e)))}function n4e(e,s){return e=Math.abs(e),s=Math.abs(s)-e,Math.max(0,Qy(s)-Qy(e))+1}function lre(e,s,r,n){var a=ZM(e,s,r),i;switch(n=uj(n??",f"),n.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(s));return n.precision==null&&!isNaN(i=r4e(a,o))&&(n.precision=i),ore(n,o)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(i=n4e(a,Math.max(Math.abs(e),Math.abs(s))))&&(n.precision=i-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(i=s4e(a))&&(n.precision=i-(n.type==="%")*2);break}}return mD(n)}function Bg(e){var s=e.domain;return e.ticks=function(r){var n=s();return QM(n[0],n[n.length-1],r??10)},e.tickFormat=function(r,n){var a=s();return lre(a[0],a[a.length-1],r??10,n)},e.nice=function(r){r==null&&(r=10);var n=s(),a=0,i=n.length-1,o=n[a],l=n[i],c,d,h=10;for(l<o&&(d=o,o=l,l=d,d=a,a=i,i=d);h-- >0;){if(d=XM(o,l,r),d===c)return n[a]=o,n[i]=l,s(n);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 LC(){var e=dD();return e.copy=function(){return gN(e,LC())},Fm.apply(e,arguments),Bg(e)}function cre(e){var s;function r(n){return n==null||isNaN(n=+n)?s:n}return r.invert=r,r.domain=r.range=function(n){return arguments.length?(e=Array.from(n,OC),r):e.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return cre(e).unknown(s)},e=arguments.length?Array.from(e,OC):[0,1],Bg(r)}function dre(e,s){e=e.slice();var r=0,n=e.length-1,a=e[r],i=e[n],o;return i<a&&(o=r,r=n,n=o,o=a,a=i,i=o),e[r]=s.floor(a),e[n]=s.ceil(i),e}function iH(e){return Math.log(e)}function oH(e){return Math.exp(e)}function a4e(e){return-Math.log(-e)}function i4e(e){return-Math.exp(-e)}function o4e(e){return isFinite(e)?+("1e"+e):e<0?0:e}function l4e(e){return e===10?o4e:e===Math.E?Math.exp:s=>Math.pow(e,s)}function c4e(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),s=>Math.log(s)/e)}function lH(e){return(s,r)=>-e(-s,r)}function hD(e){const s=e(iH,oH),r=s.domain;let n=10,a,i;function o(){return a=c4e(n),i=l4e(n),r()[0]<0?(a=lH(a),i=lH(i),e(a4e,i4e)):e(iH,oH),s}return s.base=function(l){return arguments.length?(n=+l,o()):n},s.domain=function(l){return arguments.length?(r(l),o()):r()},s.ticks=l=>{const c=r();let d=c[0],h=c[c.length-1];const p=h<d;p&&([d,h]=[h,d]);let g=a(d),v=a(h),b,y;const w=l==null?10:+l;let j=[];if(!(n%1)&&v-g<w){if(g=Math.floor(g),v=Math.ceil(v),d>0){for(;g<=v;++g)for(b=1;b<n;++b)if(y=g<0?b/i(-g):b*i(g),!(y<d)){if(y>h)break;j.push(y)}}else for(;g<=v;++g)for(b=n-1;b>=1;--b)if(y=g>0?b/i(-g):b*i(g),!(y<d)){if(y>h)break;j.push(y)}j.length*2<w&&(j=QM(d,h,w))}else j=QM(g,v,Math.min(v-g,w)).map(i);return p?j.reverse():j}
504,s.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=uj(c)).precision==null&&(c.trim=!0),c=mD(c)),l===1/0)return c;const d=Math.max(1,n*l/s.ticks().length);return h=>{let p=h/i(Math.round(a(h)));return p*n<n-.5&&(p*=n),p<=d?c(h):""}},s.nice=()=>r(dre(r(),{floor:l=>i(Math.floor(a(l))),ceil:l=>i(Math.ceil(a(l)))})),s}function ure(){const e=hD(L_()).domain([1,10]);return e.copy=()=>gN(e,ure()).base(e.base()),Fm.apply(e,arguments),e}function cH(e){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/e))}}function dH(e){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*e}}function pD(e){var s=1,r=e(cH(s),dH(s));return r.constant=function(n){return arguments.length?e(cH(s=+n),dH(s)):s},Bg(r)}function mre(){var e=pD(L_());return e.copy=function(){return gN(e,mre()).constant(e.constant())},Fm.apply(e,arguments)}function uH(e){return function(s){return s<0?-Math.pow(-s,e):Math.pow(s,e)}}function d4e(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function u4e(e){return e<0?-e*e:e*e}function fD(e){var s=e(Kd,Kd),r=1;function n(){return r===1?e(Kd,Kd):r===.5?e(d4e,u4e):e(uH(r),uH(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},Bg(s)}function gD(){var e=fD(L_());return e.copy=function(){return gN(e,gD()).exponent(e.exponent())},Fm.apply(e,arguments),e}function m4e(){return gD.apply(null,arguments).exponent(.5)}function mH(e){return Math.sign(e)*e*e}function h4e(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function hre(){var e=dD(),s=[0,1],r=!1,n;function a(i){var o=h4e(e(i));return isNaN(o)?n:r?Math.round(o):o}return a.invert=function(i){return e.invert(mH(i))},a.domain=function(i){return arguments.length?(e.domain(i),a):e.domain()},a.range=function(i){return arguments.length?(e.range((s=Array.from(i,OC)).map(mH)),a):s.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?(n=i,a):n},a.copy=function(){return hre(e.domain(),s).round(r).clamp(e.clamp()).unknown(n)},Fm.apply(a,arguments),Bg(a)}function pre(){var e=[],s=[],r=[],n;function a(){var o=0,l=Math.max(1,s.length);for(r=new Array(l-1);++o<l;)r[o-1]=vAe(e,o/l);return i}function i(o){return o==null||isNaN(o=+o)?n:s[pN(r,o)]}return i.invertExtent=function(o){var l=s.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(Ng),a()},i.range=function(o){return arguments.length?(s=Array.from(o),a()):s.slice()},i.unknown=function(o){return arguments.length?(n=o,i):n},i.quantiles=function(){return r.slice()},i.copy=function(){return pre().domain(e).range(s).unknown(n)},Fm.apply(i,arguments)}function fre(){var e=0,s=1,r=1,n=[.5],a=[0,1],i;function o(c){return c!=null&&c<=c?a[pN(n,c,0,r)]:i}function l(){var c=-1;for(n=new Array(r);++c<r;)n[c]=((c+1)*s-(c-r)*e)/(r+1);return o}return o.domain=function(c){return arguments.length?([e,s]=c,e=+e,s=+s,l()):[e,s]},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,n[0]]:d>=r?[n[r-1],s]:[n[d-1],n[d]]},o.unknown=function(c){return arguments.length&&(i=c),o},o.thresholds=function(){return n.slice()},o.copy=function(){return fre().domain([e,s]).range(a).unknown(i)},Fm.apply(Bg(o),arguments)}function gre(){var e=[.5],s=[0,1],r,n=1;function a(i){return i!=null&&i<=i?s[pN(e,i,0,n)]:r}return a.domain=function(i){return arguments.length?(e=Array.from(i),n=Math.min(e.length,s.length-1),a):e.slice()},a.range=function(i){return arguments.length?(s=Array.from(i),n=Math.min(e.length,s.length-1),a):s.slice()},a.invertExtent=function(i){var o=s.indexOf(i);return[e[o-1],e[o]]},a.unknown=function(i){return arguments.length?(r=i,a):r},a.copy=function(){return gre().domain(e).range(s).unknown(r)},Fm.apply(a,arguments)}const YA=new Date,QA=new Date;function Ql(e,s,r,n){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)),s(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)=>(s(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)),s(i,l),e(i);while(d<i&&i<o);return c},a.filter=i=>Ql(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(;s(o,-1),!i(o););else for(;--l>=0;)for(;s(o,1),!i(o););}),r&&(a.count=(i,o)=>(YA.setTime(+i),QA.setTime(+o),e(YA),e(QA),Math.floor(r(YA,QA))),a.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?a.filter(n?o=>n(o)%i===0:o=>a.count(0,o)%i===0):a)),a}const $C=Ql(()=>{},(e,s)=>{e.setTime(+e+s)},(e,s)=>s-e);$C.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Ql(s=>{s.setTime(Math.floor(s/e)*e)},(s,r)=>{s.setTime(+s+r*e)},(s,r)=>(r-s)/e):$C);$C.range;const Zp=1e3,Am=Zp*60,Jp=Am*60,yf=Jp*24,xD=yf*7,hH=yf*30,XA=yf*365,Ex=Ql(e=>{e.setTime(e-e.getMilliseconds())},(e,s)=>{e.setTime(+e+s*Zp)},(e,s)=>(s-e)/Zp,e=>e.getUTCSeconds());Ex.range;const vD=Ql(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Zp)},(e,s)=>{e.setTime(+e+s*Am)},(e,s)=>(s-e)/Am,e=>e.getMinutes());vD.range;const yD=Ql(e=>{e.setUTCSeconds(0,0)},(e,s)=>{e.setTime(+e+s*Am)},(e,s)=>(s-e)/Am,e=>e.getUTCMinutes());yD.range;const bD=Ql(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Zp-e.getMinutes()*Am)},(e,s)=>{e.setTime(+e+s*Jp)},(e,s)=>(s-e)/Jp,e=>e.getHours());bD.range;const wD=Ql(e=>{e.setUTCMinutes(0,0,0)},(e,s)=>{e.setTime(+e+s*Jp)},(e,s)=>(s-e)/Jp,e=>e.getUTCHours());wD.range;const xN=Ql(e=>e.setHours(0,0,0,0),(e,s)=>e.setDate(e.getDate()+s),(e,s)=>(s-e-(s.getTimezoneOffset()-e.getTimezoneOffset())*Am)/yf,e=>e.getDate()-1);xN.range;const $_=Ql(e=>{e.setUTCHours(0,0,0,0)},(e,s)=>{e.setUTCDate(e.getUTCDate()+s)},(e,s)=>(s-e)/yf,e=>e.getUTCDate()-1);$_.range;const xre=Ql(e=>{e.setUTCHours(0,0,0,0)},(e,s)=>{e.setUTCDate(e.getUTCDate()+s)},(e,s)=>(s-e)/yf,e=>Math.floor(e/yf));xre.range;function pv(e){return Ql(s=>{s.setDate(s.getDate()-(s.getDay()+7-e)%7),s.setHours(0,0,0,0)},(s,r)=>{s.setDate(s.getDate()+r*7)},(s,r)=>(r-s-(r.getTimezoneOffset()-s.getTimezoneOffset())*Am)/xD)}const F_=pv(0),FC=pv(1),p4e=pv(2),f4e=pv(3),Xy=pv(4),g4e=pv(5),x4e=pv(6);F_.range;FC.range;p4e.range;f4e.range;Xy.range;g4e.range;x4e.range;function fv(e){return Ql(s=>{s.setUTCDate(s.getUTCDate()-(s.getUTCDay()+7-e)%7),s.setUTCHours(0,0,0,0)},(s,r)=>{s.setUTCDate(s.getUTCDate()+r*7)},(s,r)=>(r-s)/xD)}const B_=fv(0),BC=fv(1),v4e=fv(2),y4e=fv(3),Zy=fv(4),b4e=fv(5),w4e=fv(6);B_.range;BC.range;v4e.range;y4e.range;Zy.range;b4e.range;w4e.range;const jD=Ql(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,s)=>{e.setMonth(e.getMonth()+s)},(e,s)=>s.getMonth()-e.getMonth()+(s.getFullYear()-e.getFullYear())*12,e=>e.getMonth());jD.range;const ND=Ql(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,s)=>{e.setUTCMonth(e.getUTCMonth()+s)},(e,s)=>s.getUTCMonth()-e.getUTCMonth()+(s.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());ND.range;const bf=Ql(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,s)=>{e.setFullYear(e.getFullYear()+s)},(e,s)=>s.getFullYear()-e.getFullYear(),e=>e.getFullYear());bf.every=e=>
vendor: 4,616 bytes, line 504
504!isFinite(e=Math.floor(e))||!(e>0)?null:Ql(s=>{s.setFullYear(Math.floor(s.getFullYear()/e)*e),s.setMonth(0,1),s.setHours(0,0,0,0)},(s,r)=>{s.setFullYear(s.getFullYear()+r*e)});bf.range;const wf=Ql(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,s)=>{e.setUTCFullYear(e.getUTCFullYear()+s)},(e,s)=>s.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());wf.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ql(s=>{s.setUTCFullYear(Math.floor(s.getUTCFullYear()/e)*e),s.setUTCMonth(0,1),s.setUTCHours(0,0,0,0)},(s,r)=>{s.setUTCFullYear(s.getUTCFullYear()+r*e)});wf.range;function vre(e,s,r,n,a,i){const o=[[Ex,1,Zp],[Ex,5,5*Zp],[Ex,15,15*Zp],[Ex,30,30*Zp],[i,1,Am],[i,5,5*Am],[i,15,15*Am],[i,30,30*Am],[a,1,Jp],[a,3,3*Jp],[a,6,6*Jp],[a,12,12*Jp],[n,1,yf],[n,2,2*yf],[r,1,xD],[s,1,hH],[s,3,3*hH],[e,1,XA]];function l(d,h,p){const g=h<d;g&&([d,h]=[h,d]);const v=p&&typeof p.range=="function"?p:c(d,h,p),b=v?v.range(d,+h+1):[];return g?b.reverse():b}function c(d,h,p){const g=Math.abs(h-d)/p,v=aD(([,,w])=>w).right(o,g);if(v===o.length)return e.every(ZM(d/XA,h/XA,p));if(v===0)return $C.every(Math.max(ZM(d,h,p),1));const[b,y]=o[g/o[v-1][2]<o[v][2]/g?v-1:v];return b.every(y)}return[l,c]}const[j4e,N4e]=vre(wf,ND,B_,xre,wD,yD),[S4e,C4e]=vre(bf,jD,F_,xN,bD,vD);function ZA(e){if(0<=e.y&&e.y<100){var s=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return s.setFullYear(e.y),s}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function JA(e){if(0<=e.y&&e.y<100){var s=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return s.setUTCFullYear(e.y),s}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Nw(e,s,r){return{y:e,m:s,d:r,H:0,M:0,S:0,L:0}}function k4e(e){var s=e.dateTime,r=e.date,n=e.time,a=e.periods,i=e.days,o=e.shortDays,l=e.months,c=e.shortMonths,d=Sw(a),h=Cw(a),p=Sw(i),g=Cw(i),v=Sw(o),b=Cw(o),y=Sw(l),w=Cw(l),j=Sw(c),x=Cw(c),C={a:G,A:z,b:Z,B:ee,c:null,d:yH,e:yH,f:Y4e,g:a5e,G:o5e,H:W4e,I:K4e,j:G4e,L:yre,m:Q4e,M:X4e,p:Q,q:Y,Q:jH,s:NH,S:Z4e,u:J4e,U:e5e,V:t5e,w:s5e,W:r5e,x:null,X:null,y:n5e,Y:i5e,Z:l5e,"%":wH},k={a:oe,A:he,b:je,B:pe,c:null,d:bH,e:bH,f:m5e,g:j5e,G:S5e,H:c5e,I:d5e,j:u5e,L:wre,m:h5e,M:p5e,p:le,q:ue,Q:jH,s:NH,S:f5e,u:g5e,U:x5e,V:v5e,w:y5e,W:b5e,x:null,X:null,y:w5e,Y:N5e,Z:C5e,"%":wH},S={a:R,A:D,b:$,B:O,c:q,d:xH,e:xH,f:z4e,g:gH,G:fH,H:vH,I:vH,j:$4e,L:U4e,m:L4e,M:F4e,p:M,q:D4e,Q:q4e,s:V4e,S:B4e,u:A4e,U:M4e,V:R4e,w:T4e,W:I4e,x:V,X:K,y:gH,Y:fH,Z:O4e,"%":H4e};C.x=_(r,C),C.X=_(n,C),C.c=_(s,C),k.x=_(r,k),k.X=_(n,k),k.c=_(s,k);function _(fe,H){return function(se){var me=[],ge=-1,be=0,ce=fe.length,Pe,et,$e;for(se instanceof Date||(se=new Date(+se));++ge<ce;)fe.charCodeAt(ge)===37&&(me.push(fe.slice(be,ge)),(et=pH[Pe=fe.charAt(++ge)])!=null?Pe=fe.charAt(++ge):et=Pe==="e"?" ":"0",($e=H[Pe])&&(Pe=$e(se,et)),me.push(Pe),be=ge+1);return me.push(fe.slice(be,ge)),me.join("")}}function A(fe,H){return function(se){var me=Nw(1900,void 0,1),ge=T(me,fe,se+="",0),be,ce;if(ge!=se.length)return null;if("Q"in me)return new Date(me.Q);if("s"in me)return new Date(me.s*1e3+("L"in me?me.L:0));if(H&&!("Z"in me)&&(me.Z=0),"p"in me&&(me.H=me.H%12+me.p*12),me.m===void 0&&(me.m="q"in me?me.q:0),"V"in me){if(me.V<1||me.V>53)return null;"w"in me||(me.w=1),"Z"in me?(be=JA(Nw(me.y,0,1)),ce=be.getUTCDay(),be=ce>4||ce===0?BC.ceil(be):BC(be),be=$_.offset(be,(me.V-1)*7),me.y=be.getUTCFullYear(),me.m=be.getUTCMonth(),me.d=be.getUTCDate()+(me.w+6)%7):(be=ZA(Nw(me.y,0,1)),ce=be.getDay(),be=ce>4||ce===0?FC.ceil(be):FC(be),be=xN.offset(be,(me.V-1)*7),me.y=be.getFullYear(),me.m=be.getMonth(),me.d=be.getDate()+(me.w+6)%7)}else("W"in me||"U"in me)&&("w"in me||(me.w="u"in me?me.u%7:"W"in me?1:0),ce="Z"in me?JA(Nw(me.y,0,1)).getUTCDay():ZA(Nw(me.y,0,1)).getDay(),me.m=0,me.d="W"in me?(me.w+6)%7+me.W*7-(ce+5)%7:me.w+me.U*7-(ce+6)%7);return"Z"in me?(me.H+=me.Z/100|0,me.M+=me.Z%100,JA(me)):ZA(me)}}function T(fe,H,se,me){for(var ge=0,be=H.length,ce=se.length,Pe,et;ge<be;){if(me>=ce)return-1;if(Pe=H.charCodeAt(ge++),Pe===37){if(Pe=H.charAt(ge++),et=S[Pe in pH?H.charAt(ge++):Pe],!et||(me=et(fe,se,me))<0)return-1}else if(Pe!=se.charCodeAt(me++))return-1}return me}function M(fe,H,se){var me=d.exec(H.slice(se));return me?(fe.p=h.get(me[0].toLowerCase()),se+me[0].length):-1}function R(fe,H,se){var me=v.exec(H.slice(se));return me?(fe.w=b.get(me[0].toLowerCase()),se+me[0].length):-1}function D(fe,H,se){var me=p.exec(H.slice(se));return me?(fe.w=g.get(me[0].toLowerCase()),se+me[0].length):-1}function $(fe,H,se){var me=j.exec(H.slice(se));return me?(fe.m=x.get(me[0].toLowerCase()),se+me[0].length):-1}function O(fe,H,se){var me=y.exec(H.slice(se));return me?(fe.m=w.get(me[0].toLowerCase()),se+me[0].length):-1}
vendor: 5,672 bytes, line 504
504function q(fe,H,se){return T(fe,s,H,se)}function V(fe,H,se){return T(fe,r,H,se)}function K(fe,H,se){return T(fe,n,H,se)}function G(fe){return o[fe.getDay()]}function z(fe){return i[fe.getDay()]}function Z(fe){return c[fe.getMonth()]}function ee(fe){return l[fe.getMonth()]}function Q(fe){return a[+(fe.getHours()>=12)]}function Y(fe){return 1+~~(fe.getMonth()/3)}function oe(fe){return o[fe.getUTCDay()]}function he(fe){return i[fe.getUTCDay()]}function je(fe){return c[fe.getUTCMonth()]}function pe(fe){return l[fe.getUTCMonth()]}function le(fe){return a[+(fe.getUTCHours()>=12)]}function ue(fe){return 1+~~(fe.getUTCMonth()/3)}return{format:function(fe){var H=_(fe+="",C);return H.toString=function(){return fe},H},parse:function(fe){var H=A(fe+="",!1);return H.toString=function(){return fe},H},utcFormat:function(fe){var H=_(fe+="",k);return H.toString=function(){return fe},H},utcParse:function(fe){var H=A(fe+="",!0);return H.toString=function(){return fe},H}}}var pH={"-":"",_:" ",0:"0"},bc=/^\s*\d+/,_4e=/^%/,P4e=/[\\^$*+?|[\]().{}]/g;function Ra(e,s,r){var n=e<0?"-":"",a=(n?-e:e)+"",i=a.length;return n+(i<r?new Array(r-i+1).join(s)+a:a)}function E4e(e){return e.replace(P4e,"\\$&")}function Sw(e){return new RegExp("^(?:"+e.map(E4e).join("|")+")","i")}function Cw(e){return new Map(e.map((s,r)=>[s.toLowerCase(),r]))}function T4e(e,s,r){var n=bc.exec(s.slice(r,r+1));return n?(e.w=+n[0],r+n[0].length):-1}function A4e(e,s,r){var n=bc.exec(s.slice(r,r+1));return n?(e.u=+n[0],r+n[0].length):-1}function M4e(e,s,r){var n=bc.exec(s.slice(r,r+2));return n?(e.U=+n[0],r+n[0].length):-1}function R4e(e,s,r){var n=bc.exec(s.slice(r,r+2));return n?(e.V=+n[0],r+n[0].length):-1}function I4e(e,s,r){var n=bc.exec(s.slice(r,r+2));return n?(e.W=+n[0],r+n[0].length):-1}function fH(e,s,r){var n=bc.exec(s.slice(r,r+4));return n?(e.y=+n[0],r+n[0].length):-1}function gH(e,s,r){var n=bc.exec(s.slice(r,r+2));return n?(e.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function O4e(e,s,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(s.slice(r,r+6));return n?(e.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function D4e(e,s,r){var n=bc.exec(s.slice(r,r+1));return n?(e.q=n[0]*3-3,r+n[0].length):-1}function L4e(e,s,r){var n=bc.exec(s.slice(r,r+2));return n?(e.m=n[0]-1,r+n[0].length):-1}function xH(e,s,r){var n=bc.exec(s.slice(r,r+2));return n?(e.d=+n[0],r+n[0].length):-1}function $4e(e,s,r){var n=bc.exec(s.slice(r,r+3));return n?(e.m=0,e.d=+n[0],r+n[0].length):-1}function vH(e,s,r){var n=bc.exec(s.slice(r,r+2));return n?(e.H=+n[0],r+n[0].length):-1}function F4e(e,s,r){var n=bc.exec(s.slice(r,r+2));return n?(e.M=+n[0],r+n[0].length):-1}function B4e(e,s,r){var n=bc.exec(s.slice(r,r+2));return n?(e.S=+n[0],r+n[0].length):-1}function U4e(e,s,r){var n=bc.exec(s.slice(r,r+3));return n?(e.L=+n[0],r+n[0].length):-1}function z4e(e,s,r){var n=bc.exec(s.slice(r,r+6));return n?(e.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function H4e(e,s,r){var n=_4e.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function q4e(e,s,r){var n=bc.exec(s.slice(r));return n?(e.Q=+n[0],r+n[0].length):-1}function V4e(e,s,r){var n=bc.exec(s.slice(r));return n?(e.s=+n[0],r+n[0].length):-1}function yH(e,s){return Ra(e.getDate(),s,2)}function W4e(e,s){return Ra(e.getHours(),s,2)}function K4e(e,s){return Ra(e.getHours()%12||12,s,2)}function G4e(e,s){return Ra(1+xN.count(bf(e),e),s,3)}function yre(e,s){return Ra(e.getMilliseconds(),s,3)}function Y4e(e,s){return yre(e,s)+"000"}function Q4e(e,s){return Ra(e.getMonth()+1,s,2)}function X4e(e,s){return Ra(e.getMinutes(),s,2)}function Z4e(e,s){return Ra(e.getSeconds(),s,2)}function J4e(e){var s=e.getDay();return s===0?7:s}function e5e(e,s){return Ra(F_.count(bf(e)-1,e),s,2)}function bre(e){var s=e.getDay();return s>=4||s===0?Xy(e):Xy.ceil(e)}function t5e(e,s){return e=bre(e),Ra(Xy.count(bf(e),e)+(bf(e).getDay()===4),s,2)}function s5e(e){return e.getDay()}function r5e(e,s){return Ra(FC.count(bf(e)-1,e),s,2)}function n5e(e,s){return Ra(e.getFullYear()%100,s,2)}function a5e(e,s){return e=bre(e),Ra(e.getFullYear()%100,s,2)}function i5e(e,s){return Ra(e.getFullYear()%1e4,s,4)}function o5e(e,s){var r=e.getDay();return e=r>=4||r===0?Xy(e):Xy.ceil(e),Ra(e.getFullYear()%1e4,s,4)}function l5e(e){var s=e.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Ra(s/60|0,"0",2)+Ra(s%60,"0",2)}function bH(e,s){return Ra(e.getUTCDate(),s,2)}function c5e(e,s){return Ra(e.getUTCHours(),s,2)}function d5e(e,s){return Ra(e.getUTCHours()%12||12,s,2)}function u5e(e,s){return Ra(1+$_.count(wf(e),e),s,3)}function wre(e,s){return Ra(e.getUTCMilliseconds(),s,3)}function m5e(e,s){return wre(e,s)+"000"}function h5e(e,s){return Ra(e.getUTCMonth()+1,s,2)}function p5e(e,s){return Ra(e.getUTCMinutes(),s,2)}function f5e(e,s){return Ra(e.getUTCSeconds(),s,2)}function g5e(e){var s=e.getUTCDay();return s===0?7:s}function x5e(e,s){return Ra(B_.count(wf(e)-1,e),s,2)}function jre(e){var s=e.getUTCDay();return s>=4||s===0?Zy(e):Zy.ceil(e)}function v5e(e,s){return e=jre(e),Ra(Zy.count(wf(e),e)+(wf(e).getUTCDay()===4),s,2)}function y5e(e){return e.getUTCDay()}function b5e(e,s){return Ra(BC.count(wf(e)-1,e),s,2)}function w5e(e,s){return Ra(e.getUTCFullYear()%100,s,2)}function j5e(e,s){return e=jre(e),Ra(e.getUTCFullYear()%100,s,2)}function N5e(e,s){return Ra(e.getUTCFullYear()%1e4,s,4)}function S5e(e,s){var r=e.getUTCDay();return e=r>=4||r===0?Zy(e):Zy.ceil(e),Ra(e.getUTCFullYear()%1e4,s,4)}function C5e(){return"+0000"}function wH(){return"%"}function jH(e){return+e}function NH(e){return Math.floor(+e/1e3)}var Uv,Nre,Sre;k5e({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Frid
504ay","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 k5e(e){return Uv=k4e(e),Nre=Uv.format,Uv.parse,Sre=Uv.utcFormat,Uv.utcParse,Uv}function _5e(e){return new Date(e)}function P5e(e){return e instanceof Date?+e:+new Date(+e)}function SD(e,s,r,n,a,i,o,l,c,d){var h=dD(),p=h.invert,g=h.domain,v=d(".%L"),b=d(":%S"),y=d("%I:%M"),w=d("%I %p"),j=d("%a %d"),x=d("%b %d"),C=d("%B"),k=d("%Y");function S(_){return(c(_)<_?v:l(_)<_?b:o(_)<_?y:i(_)<_?w:n(_)<_?a(_)<_?j:x:r(_)<_?C:k)(_)}return h.invert=function(_){return new Date(p(_))},h.domain=function(_){return arguments.length?g(Array.from(_,P5e)):g().map(_5e)},h.ticks=function(_){var A=g();return e(A[0],A[A.length-1],_??10)},h.tickFormat=function(_,A){return A==null?S:d(A)},h.nice=function(_){var A=g();return(!_||typeof _.range!="function")&&(_=s(A[0],A[A.length-1],_??10)),_?g(dre(A,_)):h},h.copy=function(){return gN(h,SD(e,s,r,n,a,i,o,l,c,d))},h}function E5e(){return Fm.apply(SD(S4e,C4e,bf,jD,F_,xN,bD,vD,Ex,Nre).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function T5e(){return Fm.apply(SD(j4e,N4e,wf,ND,B_,$_,wD,yD,Ex,Sre).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function U_(){var e=0,s=1,r,n,a,i,o=Kd,l=!1,c;function d(p){return p==null||isNaN(p=+p)?c:o(a===0?.5:(p=(i(p)-r)*a,l?Math.max(0,Math.min(1,p)):p))}d.domain=function(p){return arguments.length?([e,s]=p,r=i(e=+e),n=i(s=+s),a=r===n?0:1/(n-r),d):[e,s]},d.clamp=function(p){return arguments.length?(l=!!p,d):l},d.interpolator=function(p){return arguments.length?(o=p,d):o};function h(p){return function(g){var v,b;return arguments.length?([v,b]=g,o=p(v,b),d):[o(0),o(1)]}}return d.range=h(Ub),d.rangeRound=h(cD),d.unknown=function(p){return arguments.length?(c=p,d):c},function(p){return i=p,r=p(e),n=p(s),a=r===n?0:1/(n-r),d}}function Ug(e,s){return s.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function Cre(){var e=Bg(U_()(Kd));return e.copy=function(){return Ug(e,Cre())},_f.apply(e,arguments)}function kre(){var e=hD(U_()).domain([1,10]);return e.copy=function(){return Ug(e,kre()).base(e.base())},_f.apply(e,arguments)}function _re(){var e=pD(U_());return e.copy=function(){return Ug(e,_re()).constant(e.constant())},_f.apply(e,arguments)}function CD(){var e=fD(U_());return e.copy=function(){return Ug(e,CD()).exponent(e.exponent())},_f.apply(e,arguments)}function A5e(){return CD.apply(null,arguments).exponent(.5)}function Pre(){var e=[],s=Kd;function r(n){if(n!=null&&!isNaN(n=+n))return s((pN(e,n,1)-1)/(e.length-1))}return r.domain=function(n){if(!arguments.length)return e.slice();e=[];for(let a of n)a!=null&&!isNaN(a=+a)&&e.push(a);return e.sort(Ng),r},r.interpolator=function(n){return arguments.length?(s=n,r):s},r.range=function(){return e.map((n,a)=>s(a/(e.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,i)=>xAe(e,i/n))},r.copy=function(){return Pre(s).domain(e)},_f.apply(r,arguments)}function z_(){var e=0,s=.5,r=1,n=1,a,i,o,l,c,d=Kd,h,p=!1,g;function v(y){return isNaN(y=+y)?g:(y=.5+((y=+h(y))-i)*(n*y<n*i?l:c),d(p?Math.max(0,Math.min(1,y)):y))}v.domain=function(y){return arguments.length?([e,s,r]=y,a=h(e=+e),i=h(s=+s),o=h(r=+r),l=a===i?0:.5/(i-a),c=i===o?0:.5/(o-i),n=i<a?-1:1,v):[e,s,r]},v.clamp=function(y){return arguments.length?(p=!!y,v):p},v.interpolator=function(y){return arguments.length?(d=y,v):d};function b(y){return function(w){var j,x,C;return arguments.length?([j,x,C]=w,d=HAe(y,[j,x,C]),v):[d(0),d(.5),d(1)]}}return v.range=b(Ub),v.rangeRound=b(cD),v.unknown=function(y){return arguments.length?(g=y,v):g},function(y){return h=y,a=y(e),i=y(s),o=y(r),l=a===i?0:.5/(i-a),c=i===o?0:.5/(o-i),n=i<a?-1:1,v}}function Ere(){var e=Bg(z_()(Kd));return e.copy=function(){return Ug(e,Ere())},_f.apply(e,arguments)}function Tre(){var e=hD(z_()).domain([.1,1,10]);return e.copy=function(){return Ug(e,Tre()).base(e.base())},_f.apply(e,arguments)}function Are(){var e=pD(z_());
vendor: 68,860 bytes, lines 504-531
504return e.copy=function(){return Ug(e,Are()).constant(e.constant())},_f.apply(e,arguments)}function kD(){var e=fD(z_());return e.copy=function(){return Ug(e,kD()).exponent(e.exponent())},_f.apply(e,arguments)}function M5e(){return kD.apply(null,arguments).exponent(.5)}const SH=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:oj,scaleDiverging:Ere,scaleDivergingLog:Tre,scaleDivergingPow:kD,scaleDivergingSqrt:M5e,scaleDivergingSymlog:Are,scaleIdentity:cre,scaleImplicit:JM,scaleLinear:LC,scaleLog:ure,scaleOrdinal:iD,scalePoint:p0,scalePow:gD,scaleQuantile:pre,scaleQuantize:fre,scaleRadial:hre,scaleSequential:Cre,scaleSequentialLog:kre,scaleSequentialPow:CD,scaleSequentialQuantile:Pre,scaleSequentialSqrt:A5e,scaleSequentialSymlog:_re,scaleSqrt:m4e,scaleSymlog:mre,scaleThreshold:gre,scaleTime:E5e,scaleUtc:T5e,tickFormat:lre},Symbol.toStringTag,{value:"Module"}));var e4,CH;function H_(){if(CH)return e4;CH=1;var e=Db();function s(r,n,a){for(var i=-1,o=r.length;++i<o;){var l=r[i],c=n(l);if(c!=null&&(d===void 0?c===c&&!e(c):a(c,d)))var d=c,h=l}return h}return e4=s,e4}var t4,kH;function Mre(){if(kH)return t4;kH=1;function e(s,r){return s>r}return t4=e,t4}var s4,_H;function R5e(){if(_H)return s4;_H=1;var e=H_(),s=Mre(),r=Bb();function n(a){return a&&a.length?e(a,r,s):void 0}return s4=n,s4}var I5e=R5e();const gg=ei(I5e);var r4,PH;function Rre(){if(PH)return r4;PH=1;function e(s,r){return s<r}return r4=e,r4}var n4,EH;function O5e(){if(EH)return n4;EH=1;var e=H_(),s=Rre(),r=Bb();function n(a){return a&&a.length?e(a,r,s):void 0}return n4=n,n4}var D5e=O5e();const q_=ei(D5e);var a4,TH;function L5e(){if(TH)return a4;TH=1;var e=U3(),s=xp(),r=Use(),n=Cu();function a(i,o){var l=n(i)?e:r;return l(i,s(o,3))}return a4=a,a4}var i4,AH;function $5e(){if(AH)return i4;AH=1;var e=Fse(),s=L5e();function r(n,a){return e(s(n,a),1)}return i4=r,i4}var F5e=$5e();const B5e=ei(F5e);var o4,MH;function U5e(){if(MH)return o4;MH=1;var e=eD();function s(r,n){return e(r,n)}return o4=s,o4}var z5e=U5e();const Jy=ei(z5e);var zb=1e9,H5e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},PD,ao=!0,Lm="[DecimalError] ",Lx=Lm+"Invalid argument: ",_D=Lm+"Exponent out of range: ",Hb=Math.floor,wx=Math.pow,q5e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Xu,mc=1e7,Hi=7,Ire=9007199254740991,UC=Hb(Ire/Hi),dr={};dr.absoluteValue=dr.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e};dr.comparedTo=dr.cmp=function(e){var s,r,n,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(n=i.d.length,a=e.d.length,s=0,r=n<a?n:a;s<r;++s)if(i.d[s]!==e.d[s])return i.d[s]>e.d[s]^i.s<0?1:-1;return n===a?0:n>a^i.s<0?1:-1};dr.decimalPlaces=dr.dp=function(){var e=this,s=e.d.length-1,r=(s-e.e)*Hi;if(s=e.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};dr.dividedBy=dr.div=function(e){return cf(this,new this.constructor(e))};dr.dividedToIntegerBy=dr.idiv=function(e){var s=this,r=s.constructor;return yi(cf(s,new r(e),0,1),r.precision)};dr.equals=dr.eq=function(e){return!this.cmp(e)};dr.exponent=function(){return Sl(this)};dr.greaterThan=dr.gt=function(e){return this.cmp(e)>0};dr.greaterThanOrEqualTo=dr.gte=function(e){return this.cmp(e)>=0};dr.isInteger=dr.isint=function(){return this.e>this.d.length-2};dr.isNegative=dr.isneg=function(){return this.s<0};dr.isPositive=dr.ispos=function(){return this.s>0};dr.isZero=function(){return this.s===0};dr.lessThan=dr.lt=function(e){return this.cmp(e)<0};dr.lessThanOrEqualTo=dr.lte=function(e){return this.cmp(e)<1};dr.logarithm=dr.log=function(e){var s,r=this,n=r.constructor,a=n.precision,i=a+5;if(e===void 0)e=new n(10);else if(e=new n(e),e.s<1||e.eq(Xu))throw Error(Lm+"NaN");if(r.s<1)throw Error(Lm+(r.s?"NaN":"-Infinity"));return r.eq(Xu)?new n(0):(ao=!1,s=cf(mj(r,i),mj(e,i),i),ao=!0,yi(s,a))};dr.minus=dr.sub=function(e){var s=this;return e=new s.constructor(e),s.s==e.s?Lre(s,e):Ore(s,(e.s=-e.s,e))};dr.modulo=dr.mod=function(e){var s,r=this,n=r.constructor,a=n.precision;if(e=new n(e),!e.s)throw Error(Lm+"NaN");return r.s?(ao=!1,s=cf(r,e,0,1).times(e),ao=!0,r.minus(s)):yi(new n(r),a)};dr.naturalExponential=dr.exp=function(){return Dre(this)};dr.naturalLogarithm=dr.ln=function(){return mj(this)};dr.negated=dr.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};dr.plus=dr.add=function(e){var s=this;return e=new s.constructor(e),s.s==e.s?Ore(s,e):Lre(s,(e.s=-e.s,e))};dr.precision=dr.sd=function(e){var s,r,n,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Lx+e);if(s=Sl(a)+1,n=a.d.length-1,r=n*Hi+1,n=a.d[n],n){for(;n%10==0;n/=10)r--;for(n=a.d[0];n>=10;n/=10)r++}return e&&s>r?s:r};dr.squareRoot=dr.sqrt=function(){var e,s,r,n,a,i,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(Lm+"NaN")}for(e=Sl(l),ao=!1,a=Math.sqrt(+l),a==0||a==1/0?(s=Zh(l.d),(s.length+e)%2==0&&(s+="0"),a=Math.sqrt(s),e=Hb((e+1)/2)-(e<0||e%2),a==1/0?s="5e"+e:(s=a.toExponential(),s=s.slice(0,s.indexOf("e")+1)+e),n=new c(s)):n=new c(a.toString()),r=c.precision,a=o=r+3;;)if(i=n,n=i.plus(cf(l,i,o+2)).times(.5),Zh(i.d).slice(0,o)===(s=Zh(n.d)).slice(0,o)){if(s=s.slice(o-3,o+1),a==o&&s=="4999"){if(yi(i,r+1,0),i.times(i).eq(l)){n=i;break}}else if(s!="9999")break;o+=4}return ao=!0,yi(n,r)};dr.times=dr.mul=function(e){var s,r,n,a,i,o,l,c,d,h=this,p=h.constructor,g=h.d,v=(e=new p(e)).d;if(!h.s||!e.s)return new p(0);for(e.s*=h.s,r=h.e+e.e,c=g.length,d=v.length,c<d&&(i=g,g=v,v=i,o=c,c=d,d=o),i=[],o=c+d,n=o;n--;)i.push(0);for(n=d;--n>=0;){for(s=0,a=c+n;a>n;)l=i[a]+v[n]*g[a-n-1]+s,i[a--]=l%mc|0,s=l/mc|0;i[a]=(i[a]+s)%mc|0}for(;!i[--o];)i.pop();return s?++r:i.shift(),e.d=i,e.e=r,ao?yi(e,p.precision):e};dr.toDecimalPlaces=dr.todp=function(e,s){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(mp(e,0,zb),s===void 0?s=n.rounding:mp(s,0,8),yi(r,e+Sl(r)+1,s))};dr.toExponential=function(e,s){var r,n=this,a=n.constructor;return e===void 0?r=sv(n,!0):(mp(e,0,zb),s===void 0?s=a.rounding:mp(s,0,8),n=yi(new a(n),e+1,s),r=sv(n,!0,e+1)),r};dr.toFixed=function(e,s){var r,n,a=this,i=a.constructor;return e===void 0?sv(a):(mp(e,0,zb),s===void 0?s=i.rounding:mp(s,0,8),n=yi(new i(a),e+Sl(a)+1,s),r=sv(n.abs(),!1,e+Sl(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};dr.toInteger=dr.toint=function(){var e=this,s=e.constructor;return yi(new s(e),Sl(e)+1,s.rounding)};dr.toNumber=function(){return+this};dr.toPower=dr.pow=function(e){var s,r,n,a,i,o,l=this,c=l.constructor,d=12,h=+(e=new c(e));if(!e.s)return new c(Xu);if(l=new c(l),!l.s){if(e.s<1)throw Error(Lm+"Infinity");return l}if(l.eq(Xu))return l;if(n=c.precision,e.eq(Xu))return yi(l,n);if(s=e.e,r=e.d.length-1,o=s>=r,i=l.s,o){if((r=h<0?-h:h)<=Ire){for(a=new c(Xu),s=Math.ceil(n/Hi+4),ao=!1;r%2&&(a=a.times(l),IH(a.d,s)),r=Hb(r/2),r!==0;)l=l.times(l),IH(l.d,s);return ao=!0,e.s<0?new c(Xu).div(a):yi(a,n)}}else if(i<0)throw Error(Lm+"NaN");return i=i<0&&e.d[Math.max(s,r)]&1?-1:1,l.s=1,ao=!1,a=e.times(mj(l,n+d)),ao=!0,a=Dre(a),a.s=i,a};dr.toPrecision=function(e,s){var r,n,a=this,i=a.constructor;return e===void 0?(r=Sl(a),n=sv(a,r<=i.toExpNeg||r>=i.toExpPos)):(mp(e,1,zb),s===void 0?s=i.rounding:mp(s,0,8),a=yi(new i(a),e,s),r=Sl(a),n=sv(a,e<=r||r<=i.toExpNeg,e)),n};dr.toSignificantDigits=dr.tosd=function(e,s){var r=this,n=r.constructor;return e===void 0?(e=n.precision,s=n.rounding):(mp(e,1,zb),s===void 0?s=n.rounding:mp(s,0,8)),yi(new n(r),e,s)};dr.toString=dr.valueOf=dr.val=dr.toJSON=dr[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,s=Sl(e),r=e.constructor;return sv(e,s<=r.toExpNeg||s>=r.toExpPos)};function Ore(e,s){var r,n,a,i,o,l,c,d,h=e.constructor,p=h.precision;if(!e.s||!s.s)return s.s||(s=new h(e)),ao?yi(s,p):s;if(c=e.d,d=s.d,o=e.e,a=s.e,c=c.slice(),i=o-a,i){for(i<0?(n=c,i=-i,l=d.length):(n=d,a=o,l=c.length),o=Math.ceil(p/Hi),l=o>l?o+1:l+1,i>l&&(i=l,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(l=c.length,i=d.length,l-i<0&&(i=l,n=d,d=c,c=n),r=0;i;)r=(c[--i]=c[i]+d[i]+r)/mc|0,c[i]%=mc;for(r&&(c.unshift(r),++a),l=c.length;c[--l]==0;)c.pop();return s.d=c,s.e=a,ao?yi(s,p):s}function mp(e,s,r){if(e!==~~e||e<s||e>r)throw Error(Lx+e)}function Zh(e){var s,r,n,a=e.length-1,i="",o=e[0];if(a>0){for(i+=o,s=1;s<a;s++)n=e[s]+"",r=Hi-n.length,r&&(i+=og(r)),i+=n;o=e[s],n=o+"",r=Hi-n.length,r&&(i+=og(r))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}var cf=(function(){function e(n,a){var i,o=0,l=n.length;for(n=n.slice();l--;)i=n[l]*a+o,n[l]=i%mc|0,o=i/mc|0;return o&&n.unshift(o),n}function s(n,a,i,o){var l,c;if(i!=o)c=i>o?1:-1;else for(l=c=0;l<i;l++)if(n[l]!=a[l]){c=n[l]>a[l]?1:-1;break}return c}function r(n,a,i){for(var o=0;i--;)n[i]-=o,o=n[i]<a[i]?1:0,n[i]=o*mc+n[i]-a[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,a,i,o){var l,c,d,h,p,g,v,b,y,w,j,x,C,k,S,_,A,T,M=n.constructor,R=n.s==a.s?1:-1,D=n.d,$=a.d;if(!n.s)return new M(n);if(!a.s)throw Error(Lm+"Division by zero");for(c=n.e-a.e,A=$.length,S=D.length,v=new M(R),b=v.d=[],d=0;$[d]==(D[d]||0);)++d;if($[d]>(D[d]||0)&&--c,i==null?x=i=M.precision:o?x=i+(Sl(n)-Sl(a))+1:x=i,x<0)return new M(0);if(x=x/Hi+2|0,d=0,A==1)for(h=0,$=$[0],x++;(d<S||h)&&x--;d++)C=h*mc+(D[d]||0),b[d]=C/$|0,h=C%$|0;else{for(h=mc/($[0]+1)|0,h>1&&($=e($,h),D=e(D,h),A=$.length,S=D.length),k=A,y=D.slice(0,A),w=y.length;w<A;)y[w++]=0;T=$.slice(),T.unshift(0),_=$[0],$[1]>=mc/2&&++_;do h=0,l=s($,y,A,w),l<0?(j=y[0],A!=w&&(j=j*mc+(y[1]||0)),h=j/_|0,h>1?(h>=mc&&(h=mc-1),p=e($,h),g=p.length,w=y.length,l=s(p,y,g,w),l==1&&(h--,r(p,A<g?T:$,g))):(h==0&&(l=h=1),p=$.slice()),g=p.length,g<w&&p.unshift(0),r(y,p,w),l==-1&&(w=y.length,l=s($,y,A,w),l<1&&(h++,r(y,A<w?T:$,w))),w=y.length):l===0&&(h++,y=[0]),b[d++]=h,l&&y[0]?y[w++]=D[k]||0:(y=[D[k]],w=1);while((k++<S||y[0]!==void 0)&&x--)}return b[0]||b.shift(),v.e=c,yi(v,o?i+Sl(v)+1:i)}})();function Dre(e,s){var r,n,a,i,o,l,c=0,d=0,h=e.constructor,p=h.precision;if(Sl(e)>16)throw Error(_D+Sl(e));if(!e.s)return new h(Xu);for(ao=!1,l=p,o=new h(.03125);e.abs().gte(.1);)e=e.times(o),d+=5;for(n=Math.log(wx(2,d))/Math.LN10*2+5|0,l+=n,r=a=i=new h(Xu),h.precision=l;;){if(a=yi(a.times(e),l),r=r.times(++c),o=i.plus(cf(a,r,l)),Zh(o.d).slice(0,l)===Zh(i.d).slice(0,l)){for(;d--;)i=yi(i.times(i),l);return h.precision=p,s==null?(ao=!0,yi(i,p)):i}i=o}}function Sl(e){for(var s=e.e*Hi,r=e.d[0];r>=10;r/=10)s++;return s}function l4(e,s,r){if(s>e.LN10.sd())throw ao=!0,r&&(e.precision=r),Error(Lm+"LN10 precision limit exceeded");return yi(new e(e.LN10),s)}function og(e){for(var s="";e--;)s+="0";return s}function mj(e,s){var r,n,a,i,o,l,c,d,h,p=1,g=10,v=e,b=v.d,y=v.constructor,w=y.precision;if(v.s<1)throw Error(Lm+(v.s?"NaN":"-Infinity"));if(v.eq(Xu))return new y(0);if(s==null?(ao=!1,d=w):d=s,v.eq(10))return s==null&&(ao=!0),l4(y,d);if(d+=g,y.precision=d,r=Zh(b),n=r.charAt(0),i=Sl(v),Math.abs(i)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)v=v.times(e),r=Zh(v.d),n=r.charAt(0),p++;i=Sl(v),n>1?(v=new y("0."+r),i++):v=new y(n+"."+r.slice(1))}else return c=l4(y,d+2,w).times(i+""),v=mj(new y(n+"."+r.slice(1)),d-g).plus(c),y.precision=w,s==null?(ao=!0,yi(v,w)):v;for(l=o=v=cf(v.minus(Xu),v.plus(Xu),d),h=yi(v.times(v),d),a=3;;){if(o=yi(o.times(h),d),c=l.plus(cf(o,new y(a),d)),Zh(c.d).slice(0,d)===Zh(l.d).slice(0,d))return l=l.times(2),i!==0&&(l=l.plus(l4(y,d+2,w).times(i+""))),l=cf(l,new y(p),d),y.precision=w,s==null?(ao=!0,yi(l,w)):l;l=c,a+=2}}function RH(e,s){var r,n,a;for((r=s.indexOf("."))>-1&&(s=s.replace(".","")),(n=s.search(/e/i))>0?(r<0&&(r=n),r+=+s.slice(n+1),s=s.substring(0,n)):r<0&&(r=s.length),n=0;s.charCodeAt(n)===48;)++n;for(a=s.length;s.charCodeAt(a-1)===48;)--a;if(s=s.slice(n,a),s){if(a-=n,r=r-n-1,e.e=Hb(r/Hi),e.d=[],n=(r+1)%Hi,r<0&&(n+=Hi),n<a){for(n&&e.d.push(+s.slice(0,n)),a-=Hi;n<a;)e.d.push(+s.slice(n,n+=Hi));s=s.slice(n),n=Hi-s.length}else n-=a;for(;n--;)s+="0";if(e.d.push(+s),ao&&(e.e>UC||e.e<-UC))throw Error(_D+r)}else e.s=0,e.e=0,e.d=[0];return e}function yi(e,s,r){var n,a,i,o,l,c,d,h,p=e.d;for(o=1,i=p[0];i>=10;i/=10)o++;if(n=s-o,n<0)n+=Hi,a=s,d=p[h=0];else{if(h=Math.ceil((n+1)/Hi),i=p.length,h>=i)return e;for(d=i=p[h],o=1;i>=10;i/=10)o++;n%=Hi,a=n-Hi+o}if(r!==void 0&&(i=wx(10,o-a-1),l=d/i%10|0,c=s<0||p[h+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&&(n>0?a>0?d/wx(10,o-a):0:p[h-1])%10&1||r==(e.s<0?8:7))),s<1||!p[0])return c?(i=Sl(e),p.length=1,s=s-i-1,p[0]=wx(10,(Hi-s%Hi)%Hi),e.e=Hb(-s/Hi)||0):(p.length=1,p[0]=e.e=e.s=0),e;if(n==0?(p.length=h,i=1,h--):(p.length=h+1,i=wx(10,Hi-n),p[h]=a>0?(d/wx(10,o-a)%wx(10,a)|0)*i:0),c)for(;;)if(h==0){(p[0]+=i)==mc&&(p[0]=1,++e.e);break}else{if(p[h]+=i,p[h]!=mc)break;p[h--]=0,i=1}for(n=p.length;p[--n]===0;)p.pop();if(ao&&(e.e>UC||e.e<-UC))throw Error(_D+Sl(e));return e}function Lre(e,s){var r,n,a,i,o,l,c,d,h,p,g=e.constructor,v=g.precision;if(!e.s||!s.s)return s.s?s.s=-s.s:s=new g(e),ao?yi(s,v):s;if(c=e.d,p=s.d,n=s.e,d=e.e,c=c.slice(),o=d-n,o){for(h=o<0,h?(r=c,o=-o,l=p.length):(r=p,n=d,l=c.length),a=Math.max(Math.ceil(v/Hi),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=p.length,h=a<l,h&&(l=a),a=0;a<l;a++)if(c[a]!=p[a]){h=c[a]<p[a];break}o=0}for(h&&(r=c,c=p,p=r,s.s=-s.s),l=c.length,a=p.length-l;a>0;--a)c[l++]=0;for(a=p.length;a>o;){if(c[--a]<p[a]){for(i=a;i&&c[--i]===0;)c[i]=mc-1;--c[i],c[a]+=mc}c[a]-=p[a]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--n;return c[0]?(s.d=c,s.e=n,ao?yi(s,v):s):new g(0)}function sv(e,s,r){var n,a=Sl(e),i=Zh(e.d),o=i.length;return s?(r&&(n=r-o)>0?i=i.charAt(0)+"."+i.slice(1)+og(n):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(a<0?"e":"e+")+a):a<0?(i="0."+og(-a-1)+i,r&&(n=r-o)>0&&(i+=og(n))):a>=o?(i+=og(a+1-o),r&&(n=r-a-1)>0&&(i=i+"."+og(n))):((n=a+1)<o&&(i=i.slice(0,n)+"."+i.slice(n)),r&&(n=r-o)>0&&(a+1===o&&(i+="."),i+=og(n))),e.s<0?"-"+i:i}function IH(e,s){if(e.length>s)return e.length=s,!0}function $re(e){var s,r,n;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(Lx+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 RH(o,i.toString())}else if(typeof i!="string")throw Error(Lx+i);if(i.charCodeAt(0)===45?(i=i.slice(1),o.s=-1):o.s=1,q5e.test(i))RH(o,i);else throw Error(Lx+i)}if(a.prototype=dr,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=$re,a.config=a.set=V5e,e===void 0&&(e={}),e)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],s=0;s<n.length;)e.hasOwnProperty(r=n[s++])||(e[r]=this[r]);return a.config(e),a}function V5e(e){if(!e||typeof e!="object")throw Error(Lm+"Object expected");var s,r,n,a=["precision",1,zb,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(s=0;s<a.length;s+=3)if((n=e[r=a[s]])!==void 0)if(Hb(n)===n&&n>=a[s+1]&&n<=a[s+2])this[r]=n;else throw Error(Lx+r+": "+n);if((n=e[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(Lx+r+": "+n);return this}var PD=$re(H5e);Xu=new PD(1);const ui=PD;function W5e(e){return Q5e(e)||Y5e(e)||G5e(e)||K5e()}function K5e(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
505In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function G5e(e,s){if(e){if(typeof e=="string")return rR(e,s);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 rR(e,s)}}function Y5e(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function Q5e(e){if(Array.isArray(e))return rR(e)}function rR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}var X5e=function(s){return s},Fre={},Bre=function(s){return s===Fre},OH=function(s){return function r(){return arguments.length===0||arguments.length===1&&Bre(arguments.length<=0?void 0:arguments[0])?r:s.apply(void 0,arguments)}},Z5e=function e(s,r){return s===1?r:OH(function(){for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];var o=a.filter(function(l){return l!==Fre}).length;return o>=s?r.apply(void 0,a):e(s-o,OH(function(){for(var l=arguments.length,c=new Array(l),d=0;d<l;d++)c[d]=arguments[d];var h=a.map(function(p){return Bre(p)?c.shift():p});return r.apply(void 0,W5e(h).concat(c))}))})},V_=function(s){return Z5e(s.length,s)},nR=function(s,r){for(var n=[],a=s;a<r;++a)n[a-s]=a;return n},J5e=V_(function(e,s){return Array.isArray(s)?s.map(e):Object.keys(s).map(function(r){return s[r]}).map(e)}),eMe=function(){for(var s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];if(!r.length)return X5e;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))}},aR=function(s){return Array.isArray(s)?s.reverse():s.split("").reverse.join("")},Ure=function(s){var r=null,n=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,n=s.apply(void 0,i)),n}};function tMe(e){var s;return e===0?s=1:s=Math.floor(new ui(e).abs().log(10).toNumber())+1,s}function sMe(e,s,r){for(var n=new ui(e),a=0,i=[];n.lt(s)&&a<1e5;)i.push(n.toNumber()),n=n.add(r),a++;return i}var rMe=V_(function(e,s,r){var n=+e,a=+s;return n+r*(a-n)}),nMe=V_(function(e,s,r){var n=s-+e;return n=n||1/0,(r-e)/n}),aMe=V_(function(e,s,r){var n=s-+e;return n=n||1/0,Math.max(0,Math.min(1,(r-e)/n))});const W_={rangeStep:sMe,getDigitCount:tMe,interpolateNumber:rMe,uninterpolateNumber:nMe,uninterpolateTruncation:aMe};function iR(e){return lMe(e)||oMe(e)||zre(e)||iMe()}function iMe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
506In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function oMe(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function lMe(e){if(Array.isArray(e))return oR(e)}function hj(e,s){return uMe(e)||dMe(e,s)||zre(e,s)||cMe()}function cMe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
507In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zre(e,s){if(e){if(typeof e=="string")return oR(e,s);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 oR(e,s)}}function oR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function dMe(e,s){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var r=[],n=!0,a=!1,i=void 0;try{for(var o=e[Symbol.iterator](),l;!(n=(l=o.next()).done)&&(r.push(l.value),!(s&&r.length===s));n=!0);}catch(c){a=!0,i=c}finally{try{!n&&o.return!=null&&o.return()}finally{if(a)throw i}}return r}}function uMe(e){if(Array.isArray(e))return e}function Hre(e){var s=hj(e,2),r=s[0],n=s[1],a=r,i=n;return r>n&&(a=n,i=r),[a,i]}function qre(e,s,r){if(e.lte(0))return new ui(0);var n=W_.getDigitCount(e.toNumber()),a=new ui(10).pow(n),i=e.div(a),o=n!==1?.05:.1,l=new ui(Math.ceil(i.div(o).toNumber())).add(r).mul(o),c=l.mul(a);return s?c:new ui(Math.ceil(c))}function mMe(e,s,r){var n=1,a=new ui(e);if(!a.isint()&&r){var i=Math.abs(e);i<1?(n=new ui(10).pow(W_.getDigitCount(e)-1),a=new ui(Math.floor(a.div(n).toNumber())).mul(n)):i>1&&(a=new ui(Math.floor(e)))}else e===0?a=new ui(Math.floor((s-1)/2)):r||(a=new ui(Math.floor(e)));var o=Math.floor((s-1)/2),l=eMe(J5e(function(c){return a.add(new ui(c-o).mul(n)).toNumber()}),nR);return l(0,s)}function Vre(e,s,r,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((s-e)/(r-1)))return{step:new ui(0),tickMin:new ui(0),tickMax:new ui(0)};var i=qre(new ui(s).sub(e).div(r-1),n,a),o;e<=0&&s>=0?o=new ui(0):(o=new ui(e).add(s).div(2),o=o.sub(new ui(o).mod(i)));var l=Math.ceil(o.sub(e).div(i).toNumber()),c=Math.ceil(new ui(s).sub(o).div(i).toNumber()),d=l+c+1;return d>r?Vre(e,s,r,n,a+1):(d<r&&(c=s>0?c+(r-d):c,l=s>0?l:l+(r-d)),{step:i,tickMin:o.sub(new ui(l).mul(i)),tickMax:o.add(new ui(c).mul(i))})}function hMe(e){var s=hj(e,2),r=s[0],n=s[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=Hre([r,n]),c=hj(l,2),d=c[0],h=c[1];if(d===-1/0||h===1/0){var p=h===1/0?[d].concat(iR(nR(0,a-1).map(function(){return 1/0}))):[].concat(iR(nR(0,a-1).map(function(){return-1/0})),[h]);return r>n?aR(p):p}if(d===h)return mMe(d,a,i);var g=Vre(d,h,o,i),v=g.step,b=g.tickMin,y=g.tickMax,w=W_.rangeStep(b,y.add(new ui(.1).mul(v)),v);return r>n?aR(w):w}function pMe(e,s){var r=hj(e,2),n=r[0],a=r[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Hre([n,a]),l=hj(o,2),c=l[0],d=l[1];if(c===-1/0||d===1/0)return[n,a];if(c===d)return[c];var h=Math.max(s,2),p=qre(new ui(d).sub(c).div(h-1),i,0),g=[].concat(iR(W_.rangeStep(new ui(c),new ui(d).sub(new ui(.99).mul(p)),p)),[d]);return n>a?aR(g):g}var fMe=Ure(hMe),gMe=Ure(pMe),xMe="Invariant failed";function rv(e,s){throw new Error(xMe)}var vMe=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function eb(e){"@babel/helpers - typeof";return eb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},eb(e)}function zC(){return zC=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},zC.apply(this,arguments)}function yMe(e,s){return NMe(e)||jMe(e,s)||wMe(e,s)||bMe()}function bMe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
508In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wMe(e,s){if(e){if(typeof e=="string")return DH(e,s);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 DH(e,s)}}function DH(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function jMe(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function NMe(e){if(Array.isArray(e))return e}function SMe(e,s){if(e==null)return{};var r=CMe(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function CMe(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function kMe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function _Me(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Gre(n.key),n)}}function PMe(e,s,r){return s&&_Me(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function EMe(e,s,r){return s=HC(s),TMe(e,Wre()?Reflect.construct(s,r||[],HC(e).constructor):s.apply(e,r))}function TMe(e,s){if(s&&(eb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return AMe(e)}function AMe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Wre(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Wre=function(){return!!e})()}function HC(e){return HC=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},HC(e)}function MMe(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&lR(e,s)}function lR(e,s){return lR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},lR(e,s)}function Kre(e,s,r){return s=Gre(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Gre(e){var s=RMe(e,"string");return eb(s)=="symbol"?s:s+""}function RMe(e,s){if(eb(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(eb(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var K_=(function(e){function s(){return kMe(this,s),EMe(this,s,arguments)}return MMe(s,e),PMe(s,[{key:"render",value:function(){var n=this.props,a=n.offset,i=n.layout,o=n.width,l=n.dataKey,c=n.data,d=n.dataPointFormatter,h=n.xAxis,p=n.yAxis,g=SMe(n,vMe),v=Mr(g,!1);this.props.direction==="x"&&h.type!=="number"&&rv();var b=c.map(function(y){var w=d(y,l),j=w.x,x=w.y,C=w.value,k=w.errorVal;if(!k)return null;var S=[],_,A;if(Array.isArray(k)){var T=yMe(k,2);_=T[0],A=T[1]}else _=A=k;if(i==="vertical"){var M=h.scale,R=x+a,D=R+o,$=R-o,O=M(C-_),q=M(C+A);S.push({x1:q,y1:D,x2:q,y2:$}),S.push({x1:O,y1:R,x2:q,y2:R}),S.push({x1:O,y1:D,x2:O,y2:$})}else if(i==="horizontal"){var V=p.scale,K=j+a,G=K-o,z=K+o,Z=V(C-_),ee=V(C+A);S.push({x1:G,y1:ee,x2:z,y2:ee}),S.push({x1:K,y1:Z,x2:K,y2:ee}),S.push({x1:G,y1:Z,x2:z,y2:Z})}return Ne.createElement(wa,zC({className:"recharts-errorBar",key:"bar-".concat(S.map(function(Q){return"".concat(Q.x1,"-").concat(Q.x2,"-").concat(Q.y1,"-").concat(Q.y2)}))},v),S.map(function(Q){return Ne.createElement("line",zC({},Q,{key:"line-".concat(Q.x1,"-").concat(Q.x2,"-").concat(Q.y1,"-").concat(Q.y2)}))}))});return Ne.createElement(wa,{className:"recharts-errorBars"},b)}}])})(Ne.Component);Kre(K_,"defaultProps",{stroke:"black",strokeWidth:1.5,width:5,offset:0,layout:"horizontal"});Kre(K_,"displayName","ErrorBar");function pj(e){"@babel/helpers - typeof";return pj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},pj(e)}function LH(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function mx(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?LH(Object(r),!0).forEach(function(n){IMe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):LH(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function IMe(e,s,r){return s=OMe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function OMe(e){var s=DMe(e,"string");return pj(s)=="symbol"?s:s+""}function DMe(e,s){if(pj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(pj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var Yre=function(s){var r=s.children,n=s.formattedGraphicalItems,a=s.legendWidth,i=s.legendContent,o=Wu(r,gy);if(!o)return null;var l=gy.defaultProps,c=l!==void 0?mx(mx({},l),o.props):{},d;return o.props&&o.props.payload?d=o.props&&o.props.payload:i==="children"?d=(n||[]).reduce(function(h,p){var g=p.item,v=p.props,b=v.sectors||v.data||[];return h.concat(b.map(function(y){return{type:o.props.iconType||g.props.legendType,value:y.name,color:y.fill,payload:y}}))},[]):d=(n||[]).map(function(h){var p=h.item,g=p.type.defaultProps,v=g!==void 0?mx(mx({},g),p.props):{},b=v.dataKey,y=v.name,w=v.legendType,j=v.hide;return{inactive:j,dataKey:b,type:c.iconType||w||"square",color:ED(p),value:y||b,payload:v}}),mx(mx(mx({},c),gy.getWithHeight(o,a)),{},{payload:d,item:o})};function fj(e){"@babel/helpers - typeof";return fj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},fj(e)}function $H(e){return BMe(e)||FMe(e)||$Me(e)||LMe()}function LMe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
509In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $Me(e,s){if(e){if(typeof e=="string")return cR(e,s);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 cR(e,s)}}function FMe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function BMe(e){if(Array.isArray(e))return cR(e)}function cR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function FH(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Oo(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?FH(Object(r),!0).forEach(function(n){vy(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):FH(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function vy(e,s,r){return s=UMe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function UMe(e){var s=zMe(e,"string");return fj(s)=="symbol"?s:s+""}function zMe(e,s){if(fj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(fj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Wl(e,s,r){return Tn(e)||Tn(s)?r:Gl(s)?em(e,s,r):Qr(s)?s(e):r}function f0(e,s,r,n){var a=B5e(e,function(l){return Wl(l,s)});if(r==="number"){var i=a.filter(function(l){return bs(l)||parseFloat(l)});return i.length?[q_(i),gg(i)]:[1/0,-1/0]}var o=n?a.filter(function(l){return!Tn(l)}):a;return o.map(function(l){return Gl(l)||l instanceof Date?l:""})}var HMe=function(s){var r,n=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=n?.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 h=d>0?a[d-1].coordinate:a[l-1].coordinate,p=a[d].coordinate,g=d>=l-1?a[0].coordinate:a[d+1].coordinate,v=void 0;if(Vd(p-h)!==Vd(g-p)){var b=[];if(Vd(g-p)===Vd(c[1]-c[0])){v=g;var y=p+c[1]-c[0];b[0]=Math.min(y,(y+h)/2),b[1]=Math.max(y,(y+h)/2)}else{v=h;var w=g+c[1]-c[0];b[0]=Math.min(p,(w+p)/2),b[1]=Math.max(p,(w+p)/2)}var j=[Math.min(p,(v+p)/2),Math.max(p,(v+p)/2)];if(s>j[0]&&s<=j[1]||s>=b[0]&&s<=b[1]){o=a[d].index;break}}else{var x=Math.min(h,g),C=Math.max(h,g);if(s>(x+p)/2&&s<=(C+p)/2){o=a[d].index;break}}}else for(var k=0;k<l;k++)if(k===0&&s<=(n[k].coordinate+n[k+1].coordinate)/2||k>0&&k<l-1&&s>(n[k].coordinate+n[k-1].coordinate)/2&&s<=(n[k].coordinate+n[k+1].coordinate)/2||k===l-1&&s>(n[k].coordinate+n[k-1].coordinate)/2){o=n[k].index;break}return o},ED=function(s){var r,n=s,a=n.type.displayName,i=(r=s.type)!==null&&r!==void 0&&r.defaultProps?Oo(Oo({},s.type.defaultProps),s.props):s.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},qMe=function(s){var r=s.barSize,n=s.totalSize,a=s.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 h=i[l[c]].stackGroups,p=Object.keys(h),g=0,v=p.length;g<v;g++){var b=h[p[g]],y=b.items,w=b.cateAxisId,j=y.filter(function(A){return lf(A.type).indexOf("Bar")>=0});if(j&&j.length){var x=j[0].type.defaultProps,C=x!==void 0?Oo(Oo({},x),j[0].props):j[0].props,k=C.barSize,S=C[w];o[S]||(o[S]=[]);var _=Tn(k)?r:k;o[S].push({item:j[0],stackList:j.slice(1),barSize:Tn(_)?void 0:Wd(_,n,0)})}}return o},VMe=function(s){var r=s.barGap,n=s.barCategoryGap,a=s.bandSize,i=s.sizeList,o=i===void 0?[]:i,l=s.maxBarSize,c=o.length;if(c<1)return null;var d=Wd(r,a,0,!0),h,p=[];if(o[0].barSize===+o[0].barSize){var g=!1,v=a/c,b=o.reduce(function(k,S){return k+S.barSize||0},0);b+=(c-1)*d,b>=a&&(b-=(c-1)*d,d=0),b>=a&&v>0&&(g=!0,v*=.9,b=c*v);var y=(a-b)/2>>0,w={offset:y-d,size:0};h=o.reduce(function(k,S){var _={item:S.item,position:{offset:w.offset+w.size+d,size:g?v:S.barSize}},A=[].concat($H(k),[_]);return w=A[A.length-1].position,S.stackList&&S.stackList.length&&S.stackList.forEach(function(T){A.push({item:T,position:w})}),A},p)}else{var j=Wd(n,a,0,!0);a-2*j-(c-1)*d<=0&&(d=0);var x=(a-2*j-(c-1)*d)/c;x>1&&(x>>=0);var C=l===+l?Math.min(x,l):x;h=o.reduce(function(k,S,_){var A=[].concat($H(k),[{item:S.item,position:{offset:j+(x+d)*_+(x-C)/2,size:C}}]);return S.stackList&&S.stackList.length&&S.stackList.forEach(function(T){A.push({item:T,position:A[A.length-1].position})}),A},p)}return h},WMe=function(s,r,n,a){var i=n.children,o=n.width,l=n.margin,c=o-(l.left||0)-(l.right||0),d=Yre({children:i,legendWidth:c});if(d){var h=a||{},p=h.width,g=h.height,v=d.align,b=d.verticalAlign,y=d.layout;if((y==="vertical"||y==="horizontal"&&b==="middle")&&v!=="center"&&bs(s[v]))return Oo(Oo({},s),{},vy({},v,s[v]+(p||0)));if((y==="horizontal"||y==="vertical"&&v==="center")&&b!=="middle"&&bs(s[b]))return Oo(Oo({},s),{},vy({},b,s[b]+(g||0)))}return s},KMe=function(s,r,n){return Tn(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},Qre=function(s,r,n,a,i){var o=r.props.children,l=Rm(o,K_).filter(function(d){return KMe(a,i,d.props.direction)});if(l&&l.length){var c=l.map(function(d){return d.props.dataKey});return s.reduce(function(d,h){var p=Wl(h,n);if(Tn(p))return d;var g=Array.isArray(p)?[q_(p),gg(p)]:[p,p],v=c.reduce(function(b,y){var w=Wl(h,y,0),j=g[0]-Math.abs(Array.isArray(w)?w[0]:w),x=g[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(j,b[0]),Math.max(x,b[1])]},[1/0,-1/0]);return[Math.min(v[0],d[0]),Math.max(v[1],d[1])]},[1/0,-1/0])}return null},GMe=function(s,r,n,a,i){var o=r.map(function(l){return Qre(s,l,n,i,a)}).filter(function(l){return!Tn(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},Xre=function(s,r,n,a,i){var o=r.map(function(c){var d=c.props.dataKey;return n==="number"&&d&&Qre(s,c,d,a)||f0(s,d,n,i)});if(n==="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 h=0,p=d.length;h<p;h++)l[d[h]]||(l[d[h]]=!0,c.push(d[h]));return c},[])},Zre=function(s,r){return s==="horizontal"&&r==="xAxis"||s==="vertical"&&r==="yAxis"||s==="centric"&&r==="angleAxis"||s==="radial"&&r==="radiusAxis"},Jre=function(s,r,n,a){if(a)return s.map(function(c){return c.coordinate});var i,o,l=s.map(function(c){return c.coordinate===r&&(i=!0),c.coordinate===n&&(o=!0),c.coordinate});return i||l.push(r),o||l.push(n),l},ef=function(s,r,n){if(!s)return null;var a=s.scale,i=s.duplicateDomain,o=s.type,l=s.range,c=s.realScaleType==="scaleBand"?a.bandwidth()/2:2,d=(r||n)&&o==="category"&&a.bandwidth?a.bandwidth()/c:0;if(d=s.axisType==="angleAxis"&&l?.length>=2?Vd(l[0]-l[1])*2*d:d,r&&(s.ticks||s.niceTicks)){var h=(s.ticks||s.niceTicks).map(function(p){var g=i?i.indexOf(p):p;return{coordinate:a(g)+d,value:p,offset:d}});return h.filter(function(p){return!$b(p.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(p,g){return{coordinate:a(p)+d,value:p,index:g,offset:d}}):a.ticks&&!n?a.ticks(s.tickCount).map(function(p){return{coordinate:a(p)+d,value:p,offset:d}}):a.domain().map(function(p,g){return{coordinate:a(p)+d,value:i?i[p]:p,index:g,offset:d}})},c4=new WeakMap,E1=function(s,r){if(typeof r!="function")return s;c4.has(s)||c4.set(s,new WeakMap);var n=c4.get(s);if(n.has(r))return n.get(r);var a=function(){s.apply(void 0,arguments),r.apply(void 0,arguments)};return n.set(r,a),a},ene=function(s,r,n){var a=s.scale,i=s.type,o=s.layout,l=s.axisType;if(a==="auto")return o==="radial"&&l==="radiusAxis"?{scale:oj(),realScaleType:"band"}:o==="radial"&&l==="angleAxis"?{scale:LC(),realScaleType:"linear"}:i==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:p0(),realScaleType:"point"}:i==="category"?{scale:oj(),realScaleType:"band"}:{scale:LC(),realScaleType:"linear"};if(mN(a)){var c="scale".concat(T_(a));return{scale:(SH[c]||p0)(),realScaleType:SH[c]?c:"point"}}return Qr(a)?{scale:a}:{scale:p0(),realScaleType:"point"}},BH=1e-4,tne=function(s){var r=s.domain();if(!(!r||r.length<=2)){var n=r.length,a=s.range(),i=Math.min(a[0],a[1])-BH,o=Math.max(a[0],a[1])+BH,l=s(r[0]),c=s(r[n-1]);(l<i||l>o||c<i||c>o)&&s.domain([r[0],r[n-1]])}},YMe=function(s,r){if(!s)return null;for(var n=0,a=s.length;n<a;n++)if(s[n].item===r)return s[n].position;return null},QMe=function(s,r){if(!r||r.length!==2||!bs(r[0])||!bs(r[1]))return s;var n=Math.min(r[0],r[1]),a=Math.max(r[0],r[1]),i=[s[0],s[1]];return(!bs(s[0])||s[0]<n)&&(i[0]=n),(!bs(s[1])||s[1]>a)&&(i[1]=a),i[0]>a&&(i[0]=a),i[1]<n&&(i[1]=n),i},XMe=function(s){var r=s.length;if(!(r<=0))for(var n=0,a=s[0].length;n<a;++n)for(var i=0,o=0,l=0;l<r;++l){var c=$b(s[l][n][1])?s[l][n][0]:s[l][n][1];c>=0?(s[l][n][0]=i,s[l][n][1]=i+c,i=s[l][n][1]):(s[l][n][0]=o,s[l][n][1]=o+c,o=s[l][n][1])}},ZMe=function(s){var r=s.length;if(!(r<=0))for(var n=0,a=s[0].length;n<a;++n)for(var i=0,o=0;o<r;++o){var l=$b(s[o][n][1])?s[o][n][0]:s[o][n][1];l>=0?(s[o][n][0]=i,s[o][n][1]=i+l,i=s[o][n][1]):(s[o][n][0]=0,s[o][n][1]=0)}},JMe={sign:XMe,expand:B2e,none:Vy,silhouette:U2e,wiggle:z2e,positive:ZMe},eRe=function(s,r,n){var a=r.map(function(l){return l.props.dataKey}),i=JMe[n],o=F2e().keys(a).value(function(l,c){return+Wl(l,c,0)}).order(FM).offset(i);return o(s)},tRe=function(s,r,n,a,i,o){if(!s)return null;var l=o?r.reverse():r,c={},d=l.reduce(function(p,g){var v,b=(v=g.type)!==null&&v!==void 0&&v.defaultProps?Oo(Oo({},g.type.defaultProps),g.props):g.props,y=b.stackId,w=b.hide;if(w)return p;var j=b[n],x=p[j]||{hasStack:!1,stackGroups:{}};if(Gl(y)){var C=x.stackGroups[y]||{numericAxisId:n,cateAxisId:a,items:[]};C.items.push(g),x.hasStack=!0,x.stackGroups[y]=C}else x.stackGroups[Fb("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[g]};return Oo(Oo({},p),{},vy({},j,x))},c),h={};return Object.keys(d).reduce(function(p,g){var v=d[g];if(v.hasStack){var b={};v.stackGroups=Object.keys(v.stackGroups).reduce(function(y,w){var j=v.stackGroups[w];return Oo(Oo({},y),{},vy({},w,{numericAxisId:n,cateAxisId:a,items:j.items,stackedData:eRe(s,j.items,i)}))},b)}return Oo(Oo({},p),{},vy({},g,v))},h)},sne=function(s,r){var n=r.realScaleType,a=r.type,i=r.tickCount,o=r.originalDomain,l=r.allowDecimals,c=n||r.scale;if(c!=="auto"&&c!=="linear")return null;if(i&&a==="number"&&o&&(o[0]==="auto"||o[1]==="auto")){var d=s.domain();if(!d.length)return null;var h=fMe(d,i,l);return s.domain([q_(h),gg(h)]),{niceTicks:h}}if(i&&a==="number"){var p=s.domain(),g=gMe(p,i,l);return{niceTicks:g}}return null};function UH(e){var s=e.axis,r=e.ticks,n=e.bandSize,a=e.entry,i=e.index,o=e.dataKey;if(s.type==="category"){if(!s.allowDuplicatedCategory&&s.dataKey&&!Tn(a[s.dataKey])){var l=yC(r,"value",a[s.dataKey]);if(l)return l.coordinate+n/2}return r[i]?r[i].coordinate+n/2:null}var c=Wl(a,Tn(o)?s.dataKey:o);return Tn(c)?null:s.scale(c)}var zH=function(s){var r=s.axis,n=s.ticks,a=s.offset,i=s.bandSize,o=s.entry,l=s.index;if(r.type==="category")return n[l]?n[l].coordinate+a:null;var c=Wl(o,r.dataKey,r.domain[l]);return Tn(c)?null:r.scale(c)-i/2+a},sRe=function(s){var r=s.numericAxis,n=r.scale.domain();if(r.type==="number"){var a=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return a<=0&&i>=0?0:i<0?i:a}return n[0]},rRe=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?Oo(Oo({},s.type.defaultProps),s.props):s.props,i=a.stackId;if(Gl(i)){var o=r[i];if(o){var l=o.items.indexOf(s);return l>=0?o.stackedData[l]:null}}return null},nRe=function(s){return s.reduce(function(r,n){return[q_(n.concat([r[0]]).filter(bs)),gg(n.concat([r[1]]).filter(bs))]},[1/0,-1/0])},rne=function(s,r,n){return Object.keys(s).reduce(function(a,i){var o=s[i],l=o.stackedData,c=l.reduce(function(d,h){var p=nRe(h.slice(r,n+1));return[Math.min(d[0],p[0]),Math.max(d[1],p[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})},HH=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,qH=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,dR=function(s,r,n){if(Qr(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(bs(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(HH.test(s[0])){var i=+HH.exec(s[0])[1];a[0]=r[0]-i}else Qr(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(bs(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(qH.test(s[1])){var o=+qH.exec(s[1])[1];a[1]=r[1]+o}else Qr(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},qC=function(s,r,n){if(s&&s.scale&&s.scale.bandwidth){var a=s.scale.bandwidth();if(!n||a>0)return a}if(s&&r&&r.length>=2){for(var i=sD(r,function(p){return p.coordinate}),o=1/0,l=1,c=i.length;l<c;l++){var d=i[l],h=i[l-1];o=Math.min((d.coordinate||0)-(h.coordinate||0),o)}return o===1/0?0:o}return n?void 0:0},VH=function(s,r,n){return!s||!s.length||Jy(s,em(n,"type.defaultProps.domain"))?r:s},nne=function(s,r){var n=s.type.defaultProps?Oo(Oo({},s.type.defaultProps),s.props):s.props,a=n.dataKey,i=n.name,o=n.unit,l=n.formatter,c=n.tooltipType,d=n.chartType,h=n.hide;return Oo(Oo({},Mr(s,!1)),{},{dataKey:a,unit:o,formatter:l,name:i||a,color:ED(s),value:Wl(r,a),type:c,payload:r,chartType:d,hide:h})};function gj(e){"@babel/helpers - typeof";return gj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},gj(e)}function WH(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Wp(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?WH(Object(r),!0).forEach(function(n){ane(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):WH(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ane(e,s,r){return s=aRe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function aRe(e){var s=iRe(e,"string");return gj(s)=="symbol"?s:s+""}function iRe(e,s){if(gj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(gj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function oRe(e,s){return uRe(e)||dRe(e,s)||cRe(e,s)||lRe()}function lRe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
510In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cRe(e,s){if(e){if(typeof e=="string")return KH(e,s);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 KH(e,s)}}function KH(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function dRe(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function uRe(e){if(Array.isArray(e))return e}var VC=Math.PI/180,mRe=function(s){return s*180/Math.PI},ki=function(s,r,n,a){return{x:s+Math.cos(-VC*a)*n,y:r+Math.sin(-VC*a)*n}},ine=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(s-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},hRe=function(s,r,n,a,i){var o=s.width,l=s.height,c=s.startAngle,d=s.endAngle,h=Wd(s.cx,o,o/2),p=Wd(s.cy,l,l/2),g=ine(o,l,n),v=Wd(s.innerRadius,g,0),b=Wd(s.outerRadius,g,g*.8),y=Object.keys(r);return y.reduce(function(w,j){var x=r[j],C=x.domain,k=x.reversed,S;if(Tn(x.range))a==="angleAxis"?S=[c,d]:a==="radiusAxis"&&(S=[v,b]),k&&(S=[S[1],S[0]]);else{S=x.range;var _=S,A=oRe(_,2);c=A[0],d=A[1]}var T=ene(x,i),M=T.realScaleType,R=T.scale;R.domain(C).range(S),tne(R);var D=sne(R,Wp(Wp({},x),{},{realScaleType:M})),$=Wp(Wp(Wp({},x),D),{},{range:S,radius:b,realScaleType:M,scale:R,cx:h,cy:p,innerRadius:v,outerRadius:b,startAngle:c,endAngle:d});return Wp(Wp({},w),{},ane({},j,$))},{})},pRe=function(s,r){var n=s.x,a=s.y,i=r.x,o=r.y;return Math.sqrt(Math.pow(n-i,2)+Math.pow(a-o,2))},fRe=function(s,r){var n=s.x,a=s.y,i=r.cx,o=r.cy,l=pRe({x:n,y:a},{x:i,y:o});if(l<=0)return{radius:l};var c=(n-i)/l,d=Math.acos(c);return a>o&&(d=2*Math.PI-d),{radius:l,angle:mRe(d),angleInRadian:d}},gRe=function(s){var r=s.startAngle,n=s.endAngle,a=Math.floor(r/360),i=Math.floor(n/360),o=Math.min(a,i);return{startAngle:r-o*360,endAngle:n-o*360}},xRe=function(s,r){var n=r.startAngle,a=r.endAngle,i=Math.floor(n/360),o=Math.floor(a/360),l=Math.min(i,o);return s+l*360},GH=function(s,r){var n=s.x,a=s.y,i=fRe({x:n,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 h=gRe(r),p=h.startAngle,g=h.endAngle,v=l,b;if(p<=g){for(;v>g;)v-=360;for(;v<p;)v+=360;b=v>=p&&v<=g}else{for(;v>p;)v-=360;for(;v<g;)v+=360;b=v>=g&&v<=p}return b?Wp(Wp({},r),{},{radius:o,angle:xRe(v,r)}):null},one=function(s){return!u.isValidElement(s)&&!Qr(s)&&typeof s!="boolean"?s.className:""};function xj(e){"@babel/helpers - typeof";return xj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},xj(e)}var vRe=["offset"];function yRe(e){return NRe(e)||jRe(e)||wRe(e)||bRe()}function bRe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
511In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wRe(e,s){if(e){if(typeof e=="string")return uR(e,s);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 uR(e,s)}}function jRe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function NRe(e){if(Array.isArray(e))return uR(e)}function uR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function SRe(e,s){if(e==null)return{};var r=CRe(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function CRe(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function YH(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ul(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?YH(Object(r),!0).forEach(function(n){kRe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):YH(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function kRe(e,s,r){return s=_Re(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function _Re(e){var s=PRe(e,"string");return xj(s)=="symbol"?s:s+""}function PRe(e,s){if(xj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(xj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function vj(){return vj=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},vj.apply(this,arguments)}var ERe=function(s){var r=s.value,n=s.formatter,a=Tn(s.children)?r:s.children;return Qr(n)?n(a):a},TRe=function(s,r){var n=Vd(r-s),a=Math.min(Math.abs(r-s),360);return n*a},ARe=function(s,r,n){var a=s.position,i=s.viewBox,o=s.offset,l=s.className,c=i,d=c.cx,h=c.cy,p=c.innerRadius,g=c.outerRadius,v=c.startAngle,b=c.endAngle,y=c.clockWise,w=(p+g)/2,j=TRe(v,b),x=j>=0?1:-1,C,k;a==="insideStart"?(C=v+x*o,k=y):a==="insideEnd"?(C=b-x*o,k=!y):a==="end"&&(C=b+x*o,k=y),k=j<=0?k:!k;var S=ki(d,h,w,C),_=ki(d,h,w,C+(k?1:-1)*359),A="M".concat(S.x,",").concat(S.y,`
512    A`).concat(w,",").concat(w,",0,1,").concat(k?0:1,`,
513    `).concat(_.x,",").concat(_.y),T=Tn(s.id)?Fb("recharts-radial-line-"):s.id;return Ne.createElement("text",vj({},n,{dominantBaseline:"central",className:An("recharts-radial-bar-label",l)}),Ne.createElement("defs",null,Ne.createElement("path",{id:T,d:A})),Ne.createElement("textPath",{xlinkHref:"#".concat(T)},r))},MRe=function(s){var r=s.viewBox,n=s.offset,a=s.position,i=r,o=i.cx,l=i.cy,c=i.innerRadius,d=i.outerRadius,h=i.startAngle,p=i.endAngle,g=(h+p)/2;if(a==="outside"){var v=ki(o,l,d+n,g),b=v.x,y=v.y;return{x:b,y,textAnchor:b>=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 w=(c+d)/2,j=ki(o,l,w,g),x=j.x,C=j.y;return{x,y:C,textAnchor:"middle",verticalAnchor:"middle"}},RRe=function(s){var r=s.viewBox,n=s.parentViewBox,a=s.offset,i=s.position,o=r,l=o.x,c=o.y,d=o.width,h=o.height,p=h>=0?1:-1,g=p*a,v=p>0?"end":"start",b=p>0?"start":"end",y=d>=0?1:-1,w=y*a,j=y>0?"end":"start",x=y>0?"start":"end";if(i==="top"){var C={x:l+d/2,y:c-p*a,textAnchor:"middle",verticalAnchor:v};return Ul(Ul({},C),n?{height:Math.max(c-n.y,0),width:d}:{})}if(i==="bottom"){var k={x:l+d/2,y:c+h+g,textAnchor:"middle",verticalAnchor:b};return Ul(Ul({},k),n?{height:Math.max(n.y+n.height-(c+h),0),width:d}:{})}if(i==="left"){var S={x:l-w,y:c+h/2,textAnchor:j,verticalAnchor:"middle"};return Ul(Ul({},S),n?{width:Math.max(S.x-n.x,0),height:h}:{})}if(i==="right"){var _={x:l+d+w,y:c+h/2,textAnchor:x,verticalAnchor:"middle"};return Ul(Ul({},_),n?{width:Math.max(n.x+n.width-_.x,0),height:h}:{})}var A=n?{width:d,height:h}:{};return i==="insideLeft"?Ul({x:l+w,y:c+h/2,textAnchor:x,verticalAnchor:"middle"},A):i==="insideRight"?Ul({x:l+d-w,y:c+h/2,textAnchor:j,verticalAnchor:"middle"},A):i==="insideTop"?Ul({x:l+d/2,y:c+g,textAnchor:"middle",verticalAnchor:b},A):i==="insideBottom"?Ul({x:l+d/2,y:c+h-g,textAnchor:"middle",verticalAnchor:v},A):i==="insideTopLeft"?Ul({x:l+w,y:c+g,textAnchor:x,verticalAnchor:b},A):i==="insideTopRight"?Ul({x:l+d-w,y:c+g,textAnchor:j,verticalAnchor:b},A):i==="insideBottomLeft"?Ul({x:l+w,y:c+h-g,textAnchor:x,verticalAnchor:v},A):i==="insideBottomRight"?Ul({x:l+d-w,y:c+h-g,textAnchor:j,verticalAnchor:v},A):Lb(i)&&(bs(i.x)||_x(i.x))&&(bs(i.y)||_x(i.y))?Ul({x:l+Wd(i.x,d),y:c+Wd(i.y,h),textAnchor:"end",verticalAnchor:"end"},A):Ul({x:l+d/2,y:c+h/2,textAnchor:"middle",verticalAnchor:"middle"},A)},IRe=function(s){return"cx"in s&&bs(s.cx)};function xc(e){var s=e.offset,r=s===void 0?5:s,n=SRe(e,vRe),a=Ul({offset:r},n),i=a.viewBox,o=a.position,l=a.value,c=a.children,d=a.content,h=a.className,p=h===void 0?"":h,g=a.textBreakAll;if(!i||Tn(l)&&Tn(c)&&!u.isValidElement(d)&&!Qr(d))return null;if(u.isValidElement(d))return u.cloneElement(d,a);var v;if(Qr(d)){if(v=u.createElement(d,a),u.isValidElement(v))return v}else v=ERe(a);var b=IRe(i),y=Mr(a,!0);if(b&&(o==="insideStart"||o==="insideEnd"||o==="end"))return ARe(a,v,y);var w=b?MRe(a):RRe(a);return Ne.createElement(tv,vj({className:An("recharts-label",p)},y,w,{breakAll:g}),v)}xc.displayName="Label";var lne=function(s){var r=s.cx,n=s.cy,a=s.angle,i=s.startAngle,o=s.endAngle,l=s.r,c=s.radius,d=s.innerRadius,h=s.outerRadius,p=s.x,g=s.y,v=s.top,b=s.left,y=s.width,w=s.height,j=s.clockWise,x=s.labelViewBox;if(x)return x;if(bs(y)&&bs(w)){if(bs(p)&&bs(g))return{x:p,y:g,width:y,height:w};if(bs(v)&&bs(b))return{x:v,y:b,width:y,height:w}}return bs(p)&&bs(g)?{x:p,y:g,width:0,height:0}:bs(r)&&bs(n)?{cx:r,cy:n,startAngle:i||a||0,endAngle:o||a||0,innerRadius:d||0,outerRadius:h||c||l||0,clockWise:j}:s.viewBox?s.viewBox:{}},ORe=function(s,r){return s?s===!0?Ne.createElement(xc,{key:"label-implicit",viewBox:r}):Gl(s)?Ne.createElement(xc,{key:"label-implicit",viewBox:r,value:s}):u.isValidElement(s)?s.type===xc?u.cloneElement(s,{key:"label-implicit",viewBox:r}):Ne.createElement(xc,{key:"label-implicit",content:s,viewBox:r}):Qr(s)?Ne.createElement(xc,{key:"label-implicit",content:s,viewBox:r}):Lb(s)?Ne.createElement(xc,vj({viewBox:r},s,{key:"label-implicit"})):null:null},DRe=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!s||!s.children&&n&&!s.label)return null;var a=s.children,i=lne(s),o=Rm(a,xc).map(function(c,d){return u.cloneElement(c,{viewBox:r||i,key:"label-".concat(d)})});if(!n)return o;var l=ORe(s.label,r||i);return[l].concat(yRe(o))};xc.parseViewBox=lne;xc.renderCallByParent=DRe;var d4,QH;function LRe(){if(QH)return d4;QH=1;function e(s){var r=s==null?0:s.length;return r?s[r-1]:void 0}return d4=e,d4}var $Re=LRe();const FRe=ei($Re);function yj(e){"@babel/helpers - typeof";return yj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},yj(e)}var BRe=["valueAccessor"],URe=["data","dataKey","clockWise","id","textBreakAll"];function zRe(e){return WRe(e)||VRe(e)||qRe(e)||HRe()}function HRe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
514In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qRe(e,s){if(e){if(typeof e=="string")return mR(e,s);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 mR(e,s)}}function VRe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function WRe(e){if(Array.isArray(e))return mR(e)}function mR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function WC(){return WC=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},WC.apply(this,arguments)}function XH(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ZH(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?XH(Object(r),!0).forEach(function(n){KRe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):XH(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function KRe(e,s,r){return s=GRe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function GRe(e){var s=YRe(e,"string");return yj(s)=="symbol"?s:s+""}function YRe(e,s){if(yj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(yj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function JH(e,s){if(e==null)return{};var r=QRe(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function QRe(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}var XRe=function(s){return Array.isArray(s.value)?FRe(s.value):s.value};function df(e){var s=e.valueAccessor,r=s===void 0?XRe:s,n=JH(e,BRe),a=n.data,i=n.dataKey,o=n.clockWise,l=n.id,c=n.textBreakAll,d=JH(n,URe);return!a||!a.length?null:Ne.createElement(wa,{className:"recharts-label-list"},a.map(function(h,p){var g=Tn(i)?r(h,p):Wl(h&&h.payload,i),v=Tn(l)?{}:{id:"".concat(l,"-").concat(p)};return Ne.createElement(xc,WC({},Mr(h,!0),d,v,{parentViewBox:h.parentViewBox,value:g,textBreakAll:c,viewBox:xc.parseViewBox(Tn(o)?h:ZH(ZH({},h),{},{clockWise:o})),key:"label-".concat(p),index:p}))}))}df.displayName="LabelList";function ZRe(e,s){return e?e===!0?Ne.createElement(df,{key:"labelList-implicit",data:s}):Ne.isValidElement(e)||Qr(e)?Ne.createElement(df,{key:"labelList-implicit",data:s,content:e}):Lb(e)?Ne.createElement(df,WC({data:s},e,{key:"labelList-implicit"})):null:null}function JRe(e,s){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e||!e.children&&r&&!e.label)return null;var n=e.children,a=Rm(n,df).map(function(o,l){return u.cloneElement(o,{data:s,key:"labelList-".concat(l)})});if(!r)return a;var i=ZRe(e.label,s);return[i].concat(zRe(a))}df.renderCallByParent=JRe;function bj(e){"@babel/helpers - typeof";return bj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},bj(e)}function hR(){return hR=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},hR.apply(this,arguments)}function e7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function t7(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?e7(Object(r),!0).forEach(function(n){eIe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):e7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function eIe(e,s,r){return s=tIe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function tIe(e){var s=sIe(e,"string");return bj(s)=="symbol"?s:s+""}function sIe(e,s){if(bj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(bj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var rIe=function(s,r){var n=Vd(r-s),a=Math.min(Math.abs(r-s),359.999);return n*a},T1=function(s){var r=s.cx,n=s.cy,a=s.radius,i=s.angle,o=s.sign,l=s.isExternal,c=s.cornerRadius,d=s.cornerIsExternal,h=c*(l?1:-1)+a,p=Math.asin(c/h)/VC,g=d?i:i+o*p,v=ki(r,n,h,g),b=ki(r,n,a,g),y=d?i-o*p:i,w=ki(r,n,h*Math.cos(p*VC),y);return{center:v,circleTangency:b,lineTangency:w,theta:p}},cne=function(s){var r=s.cx,n=s.cy,a=s.innerRadius,i=s.outerRadius,o=s.startAngle,l=s.endAngle,c=rIe(o,l),d=o+c,h=ki(r,n,i,o),p=ki(r,n,i,d),g="M ".concat(h.x,",").concat(h.y,`
515    A `).concat(i,",").concat(i,`,0,
516    `).concat(+(Math.abs(c)>180),",").concat(+(o>d),`,
517    `).concat(p.x,",").concat(p.y,`
518  `);if(a>0){var v=ki(r,n,a,o),b=ki(r,n,a,d);g+="L ".concat(b.x,",").concat(b.y,`
519            A `).concat(a,",").concat(a,`,0,
520            `).concat(+(Math.abs(c)>180),",").concat(+(o<=d),`,
521            `).concat(v.x,",").concat(v.y," Z")}else g+="L ".concat(r,",").concat(n," Z");return g},nIe=function(s){var r=s.cx,n=s.cy,a=s.innerRadius,i=s.outerRadius,o=s.cornerRadius,l=s.forceCornerRadius,c=s.cornerIsExternal,d=s.startAngle,h=s.endAngle,p=Vd(h-d),g=T1({cx:r,cy:n,radius:i,angle:d,sign:p,cornerRadius:o,cornerIsExternal:c}),v=g.circleTangency,b=g.lineTangency,y=g.theta,w=T1({cx:r,cy:n,radius:i,angle:h,sign:-p,cornerRadius:o,cornerIsExternal:c}),j=w.circleTangency,x=w.lineTangency,C=w.theta,k=c?Math.abs(d-h):Math.abs(d-h)-y-C;if(k<0)return l?"M ".concat(b.x,",").concat(b.y,`
522        a`).concat(o,",").concat(o,",0,0,1,").concat(o*2,`,0
523        a`).concat(o,",").concat(o,",0,0,1,").concat(-o*2,`,0
524      `):cne({cx:r,cy:n,innerRadius:a,outerRadius:i,startAngle:d,endAngle:h});var S="M ".concat(b.x,",").concat(b.y,`
525    A`).concat(o,",").concat(o,",0,0,").concat(+(p<0),",").concat(v.x,",").concat(v.y,`
526    A`).concat(i,",").concat(i,",0,").concat(+(k>180),",").concat(+(p<0),",").concat(j.x,",").concat(j.y,`
527    A`).concat(o,",").concat(o,",0,0,").concat(+(p<0),",").concat(x.x,",").concat(x.y,`
528  `);if(a>0){var _=T1({cx:r,cy:n,radius:a,angle:d,sign:p,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),A=_.circleTangency,T=_.lineTangency,M=_.theta,R=T1({cx:r,cy:n,radius:a,angle:h,sign:-p,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),D=R.circleTangency,$=R.lineTangency,O=R.theta,q=c?Math.abs(d-h):Math.abs(d-h)-M-O;if(q<0&&o===0)return"".concat(S,"L").concat(r,",").concat(n,"Z");S+="L".concat($.x,",").concat($.y,`
529      A`).concat(o,",").concat(o,",0,0,").concat(+(p<0),",").concat(D.x,",").concat(D.y,`
530      A`).concat(a,",").concat(a,",0,").concat(+(q>180),",").concat(+(p>0),",").concat(A.x,",").concat(A.y,`
531      A`).concat(o,",").concat(o,",0,0,").concat(+(p<0),",").concat(T.x,",").concat(T.y,"Z")}else S+="L".concat(r,",").concat(n,"Z");return S},aIe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},dne=function(s){var r=t7(t7({},aIe),s),n=r.cx,a=r.cy,i=r.innerRadius,o=r.outerRadius,l=r.cornerRadius,c=r.forceCornerRadius,d=r.cornerIsExternal,h=r.startAngle,p=r.endAngle,g=r.className;if(o<i||h===p)return null;var v=An("recharts-sector",g),b=o-i,y=Wd(l,b,0,!0),w;return y>0&&Math.abs(h-p)<360?w=nIe({cx:n,cy:a,innerRadius:i,outerRadius:o,cornerRadius:Math.min(y,b/2),forceCornerRadius:c,cornerIsExternal:d,startAngle:h,endAngle:p}):w=cne({cx:n,cy:a,innerRadius:i,outerRadius:o,startAngle:h,endAngle:p}),Ne.createElement("path",hR({},Mr(r,!0),{className:v,d:w,role:"img"}))};function wj(e){"@babel/helpers - typeof";return wj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},wj(e)}function pR(){return pR=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},pR.apply(this,arguments)}function s7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function r7(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?s7(Object(r),!0).forEach(function(n){iIe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function iIe(e,s,r){return s=oIe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function oIe(e){var s=lIe(e,"string");return wj(s)=="symbol"?s:s+""}function lIe(e,s){if(wj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(wj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var n7={curveBasisClosed:P2e,curveBasisOpen:E2e,curveBasis:_2e,curveBumpX:h2e,curveBumpY:p2e,curveLinearClosed:T2e,curveLinear:M_,curveMonotoneX:A2e,curveMonotoneY:M2e,curveNatural:R2e,curveStep:I2e,curveStepAfter:D2e,curveStepBefore:O2e},A1=function(s){return s.x===+s.x&&s.y===+s.y},kw=function(s){return s.x},_w=function(s){return s.y},cIe=function(s,r){if(Qr(s))return s;var n="curve".concat(T_(s));return(n==="curveMonotone"||n==="curveBump")&&r?n7["".concat(n).concat(r==="vertical"?"Y":"X")]:n7[n]||M_},dIe=function(s){var r=s.type,n=r===void 0?"linear":r,a=s.points,i=a===void 0?[]:a,o=s.baseLine,l=s.layout,c=s.connectNulls,d=c===void 0?!1:c,h=cIe(n,l),p=d?i.filter(function(y){return A1(y)}):i,g;if(Array.isArray(o)){var v=d?o.filter(function(y){return A1(y)}):o,b=p.map(function(y,w){return r7(r7({},y),{},{base:v[w]})});return l==="vertical"?g=j1().y(_w).x1(kw).x0(function(y){return y.base.x}):g=j1().x(kw).y1(_w).y0(function(y){return y.base.y}),g.defined(A1).curve(h),g(b)}return l==="vertical"&&bs(o)?g=j1().y(_w).x1(kw).x0(o):bs(o)?g=j1().x(kw).y1(_w).y0(o):g=lse().x(kw).y(_w),g.defined(A1).curve(h),g(p)},yy=function(s){var r=s.className,n=s.points,a=s.path,i=s.pathRef;if((!n||!n.length)&&!a)return null;var o=n&&n.length?dIe(s):a;return Ne.createElement("path",pR({},Mr(s,!1),bC(s),{className:An("recharts-curve",r),d:o,ref:i}))},u4={exports:{}},m4,a7;function uIe(){if(a7)return m4;a7=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return m4=e,m4}var h4,i7;function mIe(){if(i7)return h4;i7=1;var e=uIe();function s(){}function r(){}return r.resetWarningCache=s,h4=function(){function n(o,l,c,d,h,p){if(p!==e){var g=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 g.name="Invariant Violation",g}}n.isRequired=n;function a(){return n}var i={array:n,bigint:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:a,element:n,elementType:n,instanceOf:a,node:n,objectOf:a,oneOf:a,oneOfType:a,shape:a,exact:a,checkPropTypes:r,resetWarningCache:s};return i.PropTypes=i,i},h4}var o7;function hIe(){return o7||(o7=1,u4.exports=mIe()()),u4.exports}var pIe=hIe();const Ya=ei(pIe);var fIe=Object.getOwnPropertyNames,gIe=Object.getOwnPropertySymbols,xIe=Object.prototype.hasOwnProperty;function l7(e,s){return function(n,a,i){return e(n,a,i)&&s(n,a,i)}}function M1(e){return function(r,n,a){if(!r||!n||typeof r!="object"||typeof n!="object")return e(r,n,a);var i=a.cache,o=i.get(r),l=i.get(n);if(o&&l)return o===n&&l===r;i.set(r,n),i.set(n,r);var c=e(r,n,a);return i.delete(r),i.delete(n),c}}function c7(e){return fIe(e).concat(gIe(e))}var vIe=Object.hasOwn||(function(e,s){return xIe.call(e,s)});function gv(e,s){return e===s||!e&&!s&&e!==e&&s!==s}var yIe="__v",bIe="__o",wIe="_owner",d7=Object.getOwnPropertyDescriptor,u7=Object.keys;function jIe(e,s,r){var n=e.length;if(s.length!==n)return!1;for(;n-- >0;)if(!r.equals(e[n],s[n],n,n,e,s,r))return!1;return!0}function NIe(e,s){return gv(e.getTime(),s.getTime())}function SIe(e,s){return e.name===s.name&&e.message===s.message&&e.cause===s.cause&&e.stack===s.stack}function CIe(e,s){return e===s}function m7(e,s,r){var n=e.size;if(n!==s.size)return!1;if(!n)return!0;for(var a=new Array(n),i=e.entries(),o,l,c=0;(o=i.next())&&!o.done;){for(var d=s.entries(),h=!1,p=0;(l=d.next())&&!l.done;
531){if(a[p]){p++;continue}var g=o.value,v=l.value;if(r.equals(g[0],v[0],c,p,e,s,r)&&r.equals(g[1],v[1],g[0],v[0],e,s,r)){h=a[p]=!0;break}p++}if(!h)return!1;c++}return!0}var kIe=gv;function _Ie(e,s,r){var n=u7(e),a=n.length;if(u7(s).length!==a)return!1;for(;a-- >0;)if(!une(e,s,r,n[a]))return!1;return!0}function Pw(e,s,r){var n=c7(e),a=n.length;if(c7(s).length!==a)return!1;for(var i,o,l;a-- >0;)if(i=n[a],!une(e,s,r,i)||(o=d7(e,i),l=d7(s,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function PIe(e,s){return gv(e.valueOf(),s.valueOf())}function EIe(e,s){return e.source===s.source&&e.flags===s.flags}function h7(e,s,r){var n=e.size;if(n!==s.size)return!1;if(!n)return!0;for(var a=new Array(n),i=e.values(),o,l;(o=i.next())&&!o.done;){for(var c=s.values(),d=!1,h=0;(l=c.next())&&!l.done;){if(!a[h]&&r.equals(o.value,l.value,o.value,l.value,e,s,r)){d=a[h]=!0;break}h++}if(!d)return!1}return!0}function TIe(e,s){var r=e.length;if(s.length!==r)return!1;for(;r-- >0;)if(e[r]!==s[r])return!1;return!0}function AIe(e,s){return e.hostname===s.hostname&&e.pathname===s.pathname&&e.protocol===s.protocol&&e.port===s.port&&e.hash===s.hash&&e.username===s.username&&e.password===s.password}function une(e,s,r,n){return(n===wIe||n===bIe||n===yIe)&&(e.$$typeof||s.$$typeof)?!0:vIe(s,n)&&r.equals(e[n],s[n],n,n,e,s,r)}var MIe="[object Arguments]",RIe="[object Boolean]",IIe="[object Date]",OIe="[object Error]",DIe="[object Map]",LIe="[object Number]",$Ie="[object Object]",FIe="[object RegExp]",BIe="[object Set]",UIe="[object String]",zIe="[object URL]",HIe=Array.isArray,p7=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,f7=Object.assign,qIe=Object.prototype.toString.call.bind(Object.prototype.toString);function VIe(e){var s=e.areArraysEqual,r=e.areDatesEqual,n=e.areErrorsEqual,a=e.areFunctionsEqual,i=e.areMapsEqual,o=e.areNumbersEqual,l=e.areObjectsEqual,c=e.arePrimitiveWrappersEqual,d=e.areRegExpsEqual,h=e.areSetsEqual,p=e.areTypedArraysEqual,g=e.areUrlsEqual;return function(b,y,w){if(b===y)return!0;if(b==null||y==null)return!1;var j=typeof b;if(j!==typeof y)return!1;if(j!=="object")return j==="number"?o(b,y,w):j==="function"?a(b,y,w):!1;var x=b.constructor;if(x!==y.constructor)return!1;if(x===Object)return l(b,y,w);if(HIe(b))return s(b,y,w);if(p7!=null&&p7(b))return p(b,y,w);if(x===Date)return r(b,y,w);if(x===RegExp)return d(b,y,w);if(x===Map)return i(b,y,w);if(x===Set)return h(b,y,w);var C=qIe(b);return C===IIe?r(b,y,w):C===FIe?d(b,y,w):C===DIe?i(b,y,w):C===BIe?h(b,y,w):C===$Ie?typeof b.then!="function"&&typeof y.then!="function"&&l(b,y,w):C===zIe?g(b,y,w):C===OIe?n(b,y,w):C===MIe?l(b,y,w):C===RIe||C===LIe||C===UIe?c(b,y,w):!1}}function WIe(e){var s=e.circular,r=e.createCustomConfig,n=e.strict,a={areArraysEqual:n?Pw:jIe,areDatesEqual:NIe,areErrorsEqual:SIe,areFunctionsEqual:CIe,areMapsEqual:n?l7(m7,Pw):m7,areNumbersEqual:kIe,areObjectsEqual:n?Pw:_Ie,arePrimitiveWrappersEqual:PIe,areRegExpsEqual:EIe,areSetsEqual:n?l7(h7,Pw):h7,areTypedArraysEqual:n?Pw:TIe,areUrlsEqual:AIe};if(r&&(a=f7({},a,r(a))),s){var i=M1(a.areArraysEqual),o=M1(a.areMapsEqual),l=M1(a.areObjectsEqual),c=M1(a.areSetsEqual);a=f7({},a,{areArraysEqual:i,areMapsEqual:o,areObjectsEqual:l,areSetsEqual:c})}return a}function KIe(e){return function(s,r,n,a,i,o,l){return e(s,r,l)}}function GIe(e){var s=e.circular,r=e.comparator,n=e.createState,a=e.equals,i=e.strict;if(n)return function(c,d){var h=n(),p=h.cache,g=p===void 0?s?new WeakMap:void 0:p,v=h.meta;return r(c,d,{cache:g,equals:a,meta:v,strict:i})};if(s)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 YIe=zg();zg({strict:!0});zg({circular:!0});zg({circular:!0,strict:!0});zg({createInternalComparator:function(){return gv}});zg({strict:!0,createInternalComparator:function(){return gv}});zg({circular:!0,createInternalComparator:function(){return gv}});zg({circular:!0,createInternalComparator:function(){return gv},strict:!0});function zg(e){e===void 0&&(e={});var s=e.circular,r=s===void 0?!1:s,n=e.createInternalComparator,a=e.createState,i=e.strict,o=i===void 0?!1:i,l=WIe(e),c=VIe(l),d=n?n(c):KIe(c);return GIe({circular:r,comparator:c,createState:a,equals:d,strict:o})}function QIe(e){typeof requestAnimationFrame<"u"&&requestAnimationFrame(e)}function g7(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,n=function a(i){r<0&&(r=i),i-r>s?(e(i),r=-1):QIe(a)};requestAnimationFrame(n)}function fR(e){"@babel/helpers - typeof";return fR=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},fR(e)}function XIe(e){return tOe(e)||eOe(e)||JIe(e)||ZIe()}
vendor: 60,559 bytes, lines 531-550
531function ZIe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
532In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function JIe(e,s){if(e){if(typeof e=="string")return x7(e,s);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 x7(e,s)}}function x7(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function eOe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function tOe(e){if(Array.isArray(e))return e}function sOe(){var e={},s=function(){return null},r=!1,n=function a(i){if(!r){if(Array.isArray(i)){if(!i.length)return;var o=i,l=XIe(o),c=l[0],d=l.slice(1);if(typeof c=="number"){g7(a.bind(null,d),c);return}a(c),g7(a.bind(null,d));return}fR(i)==="object"&&(e=i,s(e)),typeof i=="function"&&i()}};return{stop:function(){r=!0},start:function(i){r=!1,n(i)},subscribe:function(i){return s=i,function(){s=function(){return null}}}}}function jj(e){"@babel/helpers - typeof";return jj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},jj(e)}function v7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function y7(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?v7(Object(r),!0).forEach(function(n){mne(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function mne(e,s,r){return s=rOe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function rOe(e){var s=nOe(e,"string");return jj(s)==="symbol"?s:String(s)}function nOe(e,s){if(jj(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(jj(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var aOe=function(s,r){return[Object.keys(s),Object.keys(r)].reduce(function(n,a){return n.filter(function(i){return a.includes(i)})})},iOe=function(s){return s},oOe=function(s){return s.replace(/([A-Z])/g,function(r){return"-".concat(r.toLowerCase())})},g0=function(s,r){return Object.keys(r).reduce(function(n,a){return y7(y7({},n),{},mne({},a,s(a,r[a])))},{})},b7=function(s,r,n){return s.map(function(a){return"".concat(oOe(a)," ").concat(r,"ms ").concat(n)}).join(",")};function lOe(e,s){return uOe(e)||dOe(e,s)||hne(e,s)||cOe()}function cOe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
533In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dOe(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function uOe(e){if(Array.isArray(e))return e}function mOe(e){return fOe(e)||pOe(e)||hne(e)||hOe()}function hOe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
534In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hne(e,s){if(e){if(typeof e=="string")return gR(e,s);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 gR(e,s)}}function pOe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function fOe(e){if(Array.isArray(e))return gR(e)}function gR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}var KC=1e-4,pne=function(s,r){return[0,3*s,3*r-6*s,3*s-3*r+1]},fne=function(s,r){return s.map(function(n,a){return n*Math.pow(r,a)}).reduce(function(n,a){return n+a})},w7=function(s,r){return function(n){var a=pne(s,r);return fne(a,n)}},gOe=function(s,r){return function(n){var a=pne(s,r),i=[].concat(mOe(a.map(function(o,l){return o*l}).slice(1)),[0]);return fne(i,n)}},j7=function(){for(var s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];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(w){return parseFloat(w)}),h=lOe(d,4);a=h[0],i=h[1],o=h[2],l=h[3]}}}var p=w7(a,o),g=w7(i,l),v=gOe(a,o),b=function(j){return j>1?1:j<0?0:j},y=function(j){for(var x=j>1?1:j,C=x,k=0;k<8;++k){var S=p(C)-x,_=v(C);if(Math.abs(S-x)<KC||_<KC)return g(C);C=b(C-S/_)}return g(C)};return y.isStepper=!1,y},xOe=function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=s.stiff,n=r===void 0?100:r,a=s.damping,i=a===void 0?8:a,o=s.dt,l=o===void 0?17:o,c=function(h,p,g){var v=-(h-p)*n,b=g*i,y=g+(v-b)*l/1e3,w=g*l/1e3+h;return Math.abs(w-p)<KC&&Math.abs(y)<KC?[p,0]:[w,y]};return c.isStepper=!0,c.dt=l,c},vOe=function(){for(var s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];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 j7(a);case"spring":return xOe();default:if(a.split("(")[0]==="cubic-bezier")return j7(a)}return typeof a=="function"?a:null};function Nj(e){"@babel/helpers - typeof";return Nj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Nj(e)}function N7(e){return wOe(e)||bOe(e)||gne(e)||yOe()}function yOe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
535In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function bOe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function wOe(e){if(Array.isArray(e))return vR(e)}function S7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Vc(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?S7(Object(r),!0).forEach(function(n){xR(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function xR(e,s,r){return s=jOe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function jOe(e){var s=NOe(e,"string");return Nj(s)==="symbol"?s:String(s)}function NOe(e,s){if(Nj(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Nj(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function SOe(e,s){return _Oe(e)||kOe(e,s)||gne(e,s)||COe()}function COe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
536In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gne(e,s){if(e){if(typeof e=="string")return vR(e,s);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 vR(e,s)}}function vR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function kOe(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function _Oe(e){if(Array.isArray(e))return e}var GC=function(s,r,n){return s+(r-s)*n},yR=function(s){var r=s.from,n=s.to;return r!==n},POe=function e(s,r,n){var a=g0(function(i,o){if(yR(o)){var l=s(o.from,o.to,o.velocity),c=SOe(l,2),d=c[0],h=c[1];return Vc(Vc({},o),{},{from:d,velocity:h})}return o},r);return n<1?g0(function(i,o){return yR(o)?Vc(Vc({},o),{},{velocity:GC(o.velocity,a[i].velocity,n),from:GC(o.from,a[i].from,n)}):o},r):e(s,a,n-1)};const EOe=(function(e,s,r,n,a){var i=aOe(e,s),o=i.reduce(function(w,j){return Vc(Vc({},w),{},xR({},j,[e[j],s[j]]))},{}),l=i.reduce(function(w,j){return Vc(Vc({},w),{},xR({},j,{from:e[j],velocity:0,to:s[j]}))},{}),c=-1,d,h,p=function(){return null},g=function(){return g0(function(j,x){return x.from},l)},v=function(){return!Object.values(l).filter(yR).length},b=function(j){d||(d=j);var x=j-d,C=x/r.dt;l=POe(r,l,C),a(Vc(Vc(Vc({},e),s),g())),d=j,v()||(c=requestAnimationFrame(p))},y=function(j){h||(h=j);var x=(j-h)/n,C=g0(function(S,_){return GC.apply(void 0,N7(_).concat([r(x)]))},o);if(a(Vc(Vc(Vc({},e),s),C)),x<1)c=requestAnimationFrame(p);else{var k=g0(function(S,_){return GC.apply(void 0,N7(_).concat([r(1)]))},o);a(Vc(Vc(Vc({},e),s),k))}};return p=r.isStepper?b:y,function(){return requestAnimationFrame(p),function(){cancelAnimationFrame(c)}}});function tb(e){"@babel/helpers - typeof";return tb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},tb(e)}var TOe=["children","begin","duration","attributeName","easing","isActive","steps","from","to","canBegin","onAnimationEnd","shouldReAnimate","onAnimationReStart"];function AOe(e,s){if(e==null)return{};var r=MOe(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function MOe(e,s){if(e==null)return{};var r={},n=Object.keys(e),a,i;for(i=0;i<n.length;i++)a=n[i],!(s.indexOf(a)>=0)&&(r[a]=e[a]);return r}function p4(e){return DOe(e)||OOe(e)||IOe(e)||ROe()}function ROe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
537In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function IOe(e,s){if(e){if(typeof e=="string")return bR(e,s);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 bR(e,s)}}function OOe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function DOe(e){if(Array.isArray(e))return bR(e)}function bR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function C7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ah(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?C7(Object(r),!0).forEach(function(n){Ww(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Ww(e,s,r){return s=xne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function LOe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function $Oe(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,xne(n.key),n)}}function FOe(e,s,r){return s&&$Oe(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function xne(e){var s=BOe(e,"string");return tb(s)==="symbol"?s:String(s)}function BOe(e,s){if(tb(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(tb(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function UOe(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&wR(e,s)}function wR(e,s){return wR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},wR(e,s)}function zOe(e){var s=HOe();return function(){var n=YC(e),a;if(s){var i=YC(this).constructor;a=Reflect.construct(n,arguments,i)}else a=n.apply(this,arguments);return jR(this,a)}}function jR(e,s){if(s&&(tb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return NR(e)}function NR(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function HOe(){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 YC(e){return YC=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},YC(e)}var hp=(function(e){UOe(r,e);var s=zOe(r);function r(n,a){var i;LOe(this,r),i=s.call(this,n,a);var o=i.props,l=o.isActive,c=o.attributeName,d=o.from,h=o.to,p=o.steps,g=o.children,v=o.duration;if(i.handleStyleChange=i.handleStyleChange.bind(NR(i)),i.changeStyle=i.changeStyle.bind(NR(i)),!l||v<=0)return i.state={style:{}},typeof g=="function"&&(i.state={style:h}),jR(i);if(p&&p.length)i.state={style:p[0].style};else if(d){if(typeof g=="function")return i.state={style:d},jR(i);i.state={style:c?Ww({},c,d):d}}else i.state={style:{}};return i}return FOe(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,h=i.to,p=i.from,g=this.state.style;if(l){if(!o){var v={style:c?Ww({},c,h):h};this.state&&g&&(c&&g[c]!==h||!c&&g!==h)&&this.setState(v);return}if(!(YIe(a.to,h)&&a.canBegin&&a.isActive)){var b=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var y=b||d?p:a.to;if(this.state&&g){var w={style:c?Ww({},c,y):y};(c&&g[c]!==y||!c&&g!==y)&&this.setState(w)}this.runAnimation(ah(ah({},this.props),{},{from:y,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,h=a.begin,p=a.onAnimationEnd,g=a.onAnimationStart,v=EOe(o,l,vOe(d),c,this.changeStyle),b=function(){i.stopJSAnimation=v()};this.manager.start([g,h,b,c,p])}},{key:"runStepAnimation",value:function(a){var i=this,o=a.steps,l=a.begin,c=a.onAnimationStart,d=o[0],h=d.style,p=d.duration,g=p===void 0?0:p,v=function(y,w,j){if(j===0)return y;var x=w.duration,C=w.easing,k=C===void 0?"ease":C,S=w.style,_=w.properties,A=w.onAnimationEnd,T=j>0?o[j-1]:w,M=_||Object.keys(S);if(typeof k=="function"||k==="spring")return[].concat(p4(y),[i.runJSAnimation.bind(i,{from:T.style,to:S,duration:x,easing:k}),x]);var R=b7(M,x,k),D=ah(ah(ah({},T.style),S),{},{transition:R});return[].concat(p4(y),[D,x,A]).filter(iOe)};return this.manager.start([c].concat(p4(o.reduce(v,[h,Math.max(g,l)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=sOe());var i=a.begin,o=a.duration,l=a.attributeName,c=a.to,d=a.easing,h=a.onAnimationStart,p=a.onAnimationEnd,g=a.steps,v=a.children,b=this.manager;if(this.unSubscribe=b.subscribe(this.handleStyleChange),typeof d=="function"||typeof v=="function"||d==="spring"){this.runJSAnimation(a);return}if(g.length>1){this.runStepAnimation(a);return}var y=l?Ww({},l,c):c,w=b7(Object.keys(y),o,d);b.start([h,i,ah(ah({},y),{},{transition:w}),o,p])}},{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=AOe(a,TOe),d=u.Children.count(i),h=this.state.style;if(typeof i=="function")return i(h);if(!l||d===0||o<=0)return i;var p=function(v){var b=v.props,y=b.style,w=y===void 0?{}:y,j=b.className,x=u.cloneElement(v,ah(ah({},c),{},{style:ah(ah({},w),h),className:j}));return x};return d===1?p(u.Children.only(i)):Ne.createElement("div",null,u.Children.map(i,function(g){return p(g)}))}}]),r})(u.PureComponent);hp.displayName="Animate";hp.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};hp.propTypes={from:Ya.oneOfType([Ya.object,Ya.string]),to:Ya.oneOfType([Ya.object,Ya.string]),attributeName:Ya.string,duration:Ya.number,begin:Ya.number,easing:Ya.oneOfType([Ya.string,Ya.func]),steps:Ya.arrayOf(Ya.shape({duration:Ya.number.isRequired,style:Ya.object.isRequired,easing:Ya.oneOfType([Ya.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Ya.func]),properties:Ya.arrayOf("string"),onAnimationEnd:Ya.func})),children:Ya.oneOfType([Ya.node,Ya.func]),isActive:Ya.bool,canBegin:Ya.bool,onAnimationEnd:Ya.func,shouldReAnimate:Ya.bool,onAnimationStart:Ya.func,onAnimationReStart:Ya.func};function Sj(e){"@babel/helpers - typeof";return Sj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Sj(e)}function QC(){return QC=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},QC.apply(this,arguments)}function qOe(e,s){return GOe(e)||KOe(e,s)||WOe(e,s)||VOe()}function VOe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
538In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function WOe(e,s){if(e){if(typeof e=="string")return k7(e,s);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 k7(e,s)}}function k7(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function KOe(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function GOe(e){if(Array.isArray(e))return e}function _7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function P7(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?_7(Object(r),!0).forEach(function(n){YOe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function YOe(e,s,r){return s=QOe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function QOe(e){var s=XOe(e,"string");return Sj(s)=="symbol"?s:s+""}function XOe(e,s){if(Sj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Sj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var E7=function(s,r,n,a,i){var o=Math.min(Math.abs(n)/2,Math.abs(a)/2),l=a>=0?1:-1,c=n>=0?1:-1,d=a>=0&&n>=0||a<0&&n<0?1:0,h;if(o>0&&i instanceof Array){for(var p=[0,0,0,0],g=0,v=4;g<v;g++)p[g]=i[g]>o?o:i[g];h="M".concat(s,",").concat(r+l*p[0]),p[0]>0&&(h+="A ".concat(p[0],",").concat(p[0],",0,0,").concat(d,",").concat(s+c*p[0],",").concat(r)),h+="L ".concat(s+n-c*p[1],",").concat(r),p[1]>0&&(h+="A ".concat(p[1],",").concat(p[1],",0,0,").concat(d,`,
539        `).concat(s+n,",").concat(r+l*p[1])),h+="L ".concat(s+n,",").concat(r+a-l*p[2]),p[2]>0&&(h+="A ".concat(p[2],",").concat(p[2],",0,0,").concat(d,`,
540        `).concat(s+n-c*p[2],",").concat(r+a)),h+="L ".concat(s+c*p[3],",").concat(r+a),p[3]>0&&(h+="A ".concat(p[3],",").concat(p[3],",0,0,").concat(d,`,
541        `).concat(s,",").concat(r+a-l*p[3])),h+="Z"}else if(o>0&&i===+i&&i>0){var b=Math.min(o,i);h="M ".concat(s,",").concat(r+l*b,`
542            A `).concat(b,",").concat(b,",0,0,").concat(d,",").concat(s+c*b,",").concat(r,`
543            L `).concat(s+n-c*b,",").concat(r,`
544            A `).concat(b,",").concat(b,",0,0,").concat(d,",").concat(s+n,",").concat(r+l*b,`
545            L `).concat(s+n,",").concat(r+a-l*b,`
546            A `).concat(b,",").concat(b,",0,0,").concat(d,",").concat(s+n-c*b,",").concat(r+a,`
547            L `).concat(s+c*b,",").concat(r+a,`
548            A `).concat(b,",").concat(b,",0,0,").concat(d,",").concat(s,",").concat(r+a-l*b," Z")}else h="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return h},ZOe=function(s,r){if(!s||!r)return!1;var n=s.x,a=s.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),h=Math.max(i,i+l),p=Math.min(o,o+c),g=Math.max(o,o+c);return n>=d&&n<=h&&a>=p&&a<=g}return!1},JOe={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},TD=function(s){var r=P7(P7({},JOe),s),n=u.useRef(),a=u.useState(-1),i=qOe(a,2),o=i[0],l=i[1];u.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var k=n.current.getTotalLength();k&&l(k)}catch{}},[]);var c=r.x,d=r.y,h=r.width,p=r.height,g=r.radius,v=r.className,b=r.animationEasing,y=r.animationDuration,w=r.animationBegin,j=r.isAnimationActive,x=r.isUpdateAnimationActive;if(c!==+c||d!==+d||h!==+h||p!==+p||h===0||p===0)return null;var C=An("recharts-rectangle",v);return x?Ne.createElement(hp,{canBegin:o>0,from:{width:h,height:p,x:c,y:d},to:{width:h,height:p,x:c,y:d},duration:y,animationEasing:b,isActive:x},function(k){var S=k.width,_=k.height,A=k.x,T=k.y;return Ne.createElement(hp,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:y,isActive:j,easing:b},Ne.createElement("path",QC({},Mr(r,!0),{className:C,d:E7(A,T,S,_,g),ref:n})))}):Ne.createElement("path",QC({},Mr(r,!0),{className:C,d:E7(c,d,h,p,g)}))},e3e=["points","className","baseLinePoints","connectNulls"];function Zv(){return Zv=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Zv.apply(this,arguments)}function t3e(e,s){if(e==null)return{};var r=s3e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function s3e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function T7(e){return i3e(e)||a3e(e)||n3e(e)||r3e()}function r3e(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
549In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function n3e(e,s){if(e){if(typeof e=="string")return SR(e,s);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 SR(e,s)}}function a3e(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function i3e(e){if(Array.isArray(e))return SR(e)}function SR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}var A7=function(s){return s&&s.x===+s.x&&s.y===+s.y},o3e=function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return s.forEach(function(n){A7(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),A7(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},x0=function(s,r){var n=o3e(s);r&&(n=[n.reduce(function(i,o){return[].concat(T7(i),T7(o))},[])]);var a=n.map(function(i){return i.reduce(function(o,l,c){return"".concat(o).concat(c===0?"M":"L").concat(l.x,",").concat(l.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},l3e=function(s,r,n){var a=x0(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(x0(r.reverse(),n).slice(1))},c3e=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,i=s.connectNulls,o=t3e(s,e3e);if(!r||!r.length)return null;var l=An("recharts-polygon",n);if(a&&a.length){var c=o.stroke&&o.stroke!=="none",d=l3e(r,a,i);return Ne.createElement("g",{className:l},Ne.createElement("path",Zv({},Mr(o,!0),{fill:d.slice(-1)==="Z"?o.fill:"none",stroke:"none",d})),c?Ne.createElement("path",Zv({},Mr(o,!0),{fill:"none",d:x0(r,i)})):null,c?Ne.createElement("path",Zv({},Mr(o,!0),{fill:"none",d:x0(a,i)})):null)}var h=x0(r,i);return Ne.createElement("path",Zv({},Mr(o,!0),{fill:h.slice(-1)==="Z"?o.fill:"none",className:l,d:h}))};function CR(){return CR=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},CR.apply(this,arguments)}var G_=function(s){var r=s.cx,n=s.cy,a=s.r,i=s.className,o=An("recharts-dot",i);return r===+r&&n===+n&&a===+a?Ne.createElement("circle",CR({},Mr(s,!1),bC(s),{className:o,cx:r,cy:n,r:a})):null};function Cj(e){"@babel/helpers - typeof";return Cj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Cj(e)}var d3e=["x","y","top","left","width","height","className"];function kR(){return kR=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},kR.apply(this,arguments)}function M7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function u3e(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?M7(Object(r),!0).forEach(function(n){m3e(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function m3e(e,s,r){return s=h3e(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function h3e(e){var s=p3e(e,"string");return Cj(s)=="symbol"?s:s+""}function p3e(e,s){if(Cj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Cj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function f3e(e,s){if(e==null)return{};var r=g3e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function g3e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}var x3e=function(s,r,n,a,i,o){return"M".concat(s,",").concat(i,"v").concat(a,"M").concat(o,",").concat(r,"h").concat(n)},v3e=function(s){var r=s.x,n=r===void 0?0:r,a=s.y,i=a===void 0?0:a,o=s.top,l=o===void 0?0:o,c=s.left,d=c===void 0?0:c,h=s.width,p=h===void 0?0:h,g=s.height,v=g===void 0?0:g,b=s.className,y=f3e(s,d3e),w=u3e({x:n,y:i,top:l,left:d,width:p,height:v},y);return!bs(n)||!bs(i)||!bs(p)||!bs(v)||!bs(l)||!bs(d)?null:Ne.createElement("path",kR({},Mr(w,!0),{className:An("recharts-cross",b),d:x3e(n,i,p,v,l,d)}))},f4,R7;function y3e(){if(R7)return f4;R7=1;var e=H_(),s=Mre(),r=xp();function n(a,i){return a&&a.length?e(a,r(i,2),s):void 0}return f4=n,f4}var b3e=y3e();const w3e=ei(b3e);var g4,I7;function j3e(){if(I7)return g4;I7=1;var e=H_(),s=xp(),r=Rre();function n(a,i){return a&&a.length?e(a,s(i,2),r):void 0}return g4=n,g4}var N3e=j3e();const S3e=ei(N3e);var C3e=["cx","cy","angle","ticks","axisLine"],k3e=["ticks","tick","angle","tickFormatter","stroke"];function sb(e){"@babel/helpers - typeof";return sb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},sb(e)}function v0(){return v0=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},v0.apply(this,arguments)}function O7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function hx(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?O7(Object(r),!0).forEach(function(n){Y_(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function D7(e,s){if(e==null)return{};var r=_3e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function _3e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function P3e(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function L7(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,yne(n.key),n)}}function E3e(e,s,r){return s&&L7(e.prototype,s),r&&L7(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function T3e(e,s,r){return s=XC(s),A3e(e,vne()?Reflect.construct(s,r||[],XC(e).constructor):s.apply(e,r))}function A3e(e,s){if(s&&(sb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return M3e(e)}function M3e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function vne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(vne=function(){return!!e})()}function XC(e){return XC=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},XC(e)}function R3e(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&_R(e,s)}function _R(e,s){return _R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},_R(e,s)}function Y_(e,s,r){return s=yne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function yne(e){var s=I3e(e,"string");return sb(s)=="symbol"?s:s+""}function I3e(e,s){if(sb(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(sb(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Q_=(function(e){function s(){return P3e(this,s),T3e(this,s,arguments)}return R3e(s,e),E3e(s,[{key:"getTickValueCoord",value:function(n){var a=n.coordinate,i=this.props,o=i.angle,l=i.cx,c=i.cy;return ki(l,c,a,o)}},{key:"getTickTextAnchor",value:function(){var n=this.props.orientation,a;switch(n){case"left":a="end";break;case"right":a="start";break;default:a="middle";break}return a}},{key:"getViewBox",value:function(){var n=this.props,a=n.cx,i=n.cy,o=n.angle,l=n.ticks,c=w3e(l,function(h){return h.coordinate||0}),d=S3e(l,function(h){return h.coordinate||0});return{cx:a,cy:i,startAngle:o,endAngle:o,innerRadius:d.coordinate||0,outerRadius:c.coordinate||0}}},{key:"renderAxisLine",value:function(){var n=this.props,a=n.cx,i=n.cy,o=n.angle,l=n.ticks,c=n.axisLine,d=D7(n,C3e),h=l.reduce(function(b,y){return[Math.min(b[0],y.coordinate),Math.max(b[1],y.coordinate)]},[1/0,-1/0]),p=ki(a,i,h[0],o),g=ki(a,i,h[1],o),v=hx(hx(hx({},Mr(d,!1)),{},{fill:"none"},Mr(c,!1)),{},{x1:p.x,y1:p.y,x2:g.x,y2:g.y});return Ne.createElement("line",v0({className:"recharts-polar-radius-axis-line"},v))}},{key:"renderTicks",value:function(){var n=this,a=this.props,i=a.ticks,o=a.tick,l=a.angle,c=a.tickFormatter,d=a.stroke,h=D7(a,k3e),p=this.getTickTextAnchor(),g=Mr(h,!1),v=Mr(o,!1),b=i.map(function(y,w){var j=n.getTickValueCoord(y),x=hx(hx(hx(hx({textAnchor:p,transform:"rotate(".concat(90-l,", ").concat(j.x,", ").concat(j.y,")")},g),{},{stroke:"none",fill:d},v),{},{index:w},j),{},{payload:y});return Ne.createElement(wa,v0({className:An("recharts-polar-radius-axis-tick",one(o)),key:"tick-".concat(y.coordinate)},ev(n.props,y,w)),s.renderTickItem(o,x,c?c(y.value,w):y.value))});return Ne.createElement(wa,{className:"recharts-polar-radius-axis-ticks"},b)}},{key:"render",value:function(){var n=this.props,a=n.ticks,i=n.axisLine,o=n.tick;return!a||!a.length?null:Ne.createElement(wa,{className:An("recharts-polar-radius-axis",this.props.className)},i&&this.renderAxisLine(),o&&this.renderTicks(),xc.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(n,a,i){var o;return Ne.isValidElement(n)?o=Ne.cloneElement(n,a):Qr(n)?o=n(a):o=Ne.createElement(tv,v0({},a,{className:"recharts-polar-radius-axis-tick-value"}),i),o}}])})(u.PureComponent);Y_(Q_,"displayName","PolarRadiusAxis");Y_(Q_,"axisType","radiusAxis");Y_(Q_,"defaultProps",{type:"number",radiusAxisId:0,cx:0,cy:0,angle:0,orientation:"right",stroke:"#ccc",axisLine:!0,tick:!0,tickCount:5,allowDataOverflow:!1,scale:"auto",allowDuplicatedCategory:!0});function rb(e){"@babel/helpers - typeof";return rb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},rb(e)}function Sx(){return Sx=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Sx.apply(this,arguments)}function $7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function px(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?$7(Object(r),!0).forEach(function(n){X_(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):$7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function O3e(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function F7(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,wne(n.key),n)}}function D3e(e,s,r){return s&&F7(e.prototype,s),r&&F7(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function L3e(e,s,r){return s=ZC(s),$3e(e,bne()?Reflect.construct(s,r||[],ZC(e).constructor):s.apply(e,r))}function $3e(e,s){if(s&&(rb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return F3e(e)}function F3e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function bne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(bne=function(){return!!e})()}function ZC(e){return ZC=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ZC(e)}function B3e(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&PR(e,s)}function PR(e,s){return PR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},PR(e,s)}function X_(e,s,r){return s=wne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function wne(e){var s=U3e(e,"string");return rb(s)=="symbol"?s:s+""}function U3e(e,s){if(rb(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(rb(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var z3e=Math.PI/180,B7=1e-5,Z_=(function(e){function s(){return O3e(this,s),L3e(this,s,arguments)}return B3e(s,e),D3e(s,[{key:"getTickLineCoord",value:function(n){var a=this.props,i=a.cx,o=a.cy,l=a.radius,c=a.orientation,d=a.tickSize,h=d||8,p=ki(i,o,l,n.coordinate),g=ki(i,o,l+(c==="inner"?-1:1)*h,n.coordinate);return{x1:p.x,y1:p.y,x2:g.x,y2:g.y}}},{key:"getTickTextAnchor",value:function(n){var a=this.props.orientation,i=Math.cos(-n.coordinate*z3e),o;return i>B7?o=a==="outer"?"start":"end":i<-B7?o=a==="outer"?"end":"start":o="middle",o}},{key:"renderAxisLine",value:function(){var n=this.props,a=n.cx,i=n.cy,o=n.radius,l=n.axisLine,c=n.axisLineType,d=px(px({},Mr(this.props,!1)),{},{fill:"none"},Mr(l,!1));if(c==="circle")return Ne.createElement(G_,Sx({className:"recharts-polar-angle-axis-line"},d,{cx:a,cy:i,r:o}));var h=this.props.ticks,p=h.map(function(g){return ki(a,i,o,g.coordinate)});return Ne.createElement(c3e,Sx({className:"recharts-polar-angle-axis-line"},d,{points:p}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,i=a.ticks,o=a.tick,l=a.tickLine,c=a.tickFormatter,d=a.stroke,h=Mr(this.props,!1),p=Mr(o,!1),g=px(px({},h),{},{fill:"none"},Mr(l,!1)),v=i.map(function(b,y){var w=n.getTickLineCoord(b),j=n.getTickTextAnchor(b),x=px(px(px({textAnchor:j},h),{},{stroke:"none",fill:d},p),{},{index:y,payload:b,x:w.x2,y:w.y2});return Ne.createElement(wa,Sx({className:An("recharts-polar-angle-axis-tick",one(o)),key:"tick-".concat(b.coordinate)},ev(n.props,b,y)),l&&Ne.createElement("line",Sx({className:"recharts-polar-angle-axis-tick-line"},g,w)),o&&s.renderTickItem(o,x,c?c(b.value,y):b.value))});return Ne.createElement(wa,{className:"recharts-polar-angle-axis-ticks"},v)}},{key:"render",value:function(){var n=this.props,a=n.ticks,i=n.radius,o=n.axisLine;return i<=0||!a||!a.length?null:Ne.createElement(wa,{className:An("recharts-polar-angle-axis",this.props.className)},o&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,i){var o;return Ne.isValidElement(n)?o=Ne.cloneElement(n,a):Qr(n)?o=n(a):o=Ne.createElement(tv,Sx({},a,{className:"recharts-polar-angle-axis-tick-value"}),i),o}}])})(u.PureComponent);X_(Z_,"displayName","PolarAngleAxis");X_(Z_,"axisType","angleAxis");X_(Z_,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var x4,U7;function H3e(){if(U7)return x4;U7=1;var e=Ase(),s=e(Object.getPrototypeOf,Object);return x4=s,x4}var v4,z7;function q3e(){if(z7)return v4;z7=1;var e=Cf(),s=H3e(),r=kf(),n="[object Object]",a=Function.prototype,i=Object.prototype,o=a.toString,l=i.hasOwnProperty,c=o.call(Object);function d(h){if(!r(h)||e(h)!=n)return!1;var p=s(h);if(p===null)return!0;var g=l.call(p,"constructor")&&p.constructor;return typeof g=="function"&&g instanceof g&&o.call(g)==c}return v4=d,v4}var V3e=q3e();const W3e=ei(V3e);var y4,H7;function K3e(){if(H7)return y4;H7=1;var e=Cf(),s=kf(),r="[object Boolean]";function n(a){return a===!0||a===!1||s(a)&&e(a)==r}return y4=n,y4}var G3e=K3e();const Y3e=ei(G3e);function kj(e){"@babel/helpers - typeof";return kj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},kj(e)}function JC(){return JC=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},JC.apply(this,arguments)}function Q3e(e,s){return eDe(e)||J3e(e,s)||Z3e(e,s)||X3e()}function X3e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
550In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Z3e(e,s){if(e){if(typeof e=="string")return q7(e,s);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 q7(e,s)}}function q7(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function J3e(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function eDe(e){if(Array.isArray(e))return e}function V7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function W7(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?V7(Object(r),!0).forEach(function(n){tDe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function tDe(e,s,r){return s=sDe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function sDe(e){var s=rDe(e,"string");return kj(s)=="symbol"?s:s+""}function rDe(e,s){if(kj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(kj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var K7=function(s,r,n,a,i){var o=n-a,l;return l="M ".concat(s,",").concat(r),l+="L ".concat(s+n,",").concat(r),l+="L ".concat(s+n-o/2,",").concat(r+i),l+="L ".concat(s+n-o/2-a,",").concat(r+i),l+="L ".concat(s,",").concat(r," Z"),l},nDe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},aDe=function(s){var r=W7(W7({},nDe),s),n=u.useRef(),a=u.useState(-1),i=Q3e(a,2),o=i[0],l=i[1];u.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var C=n.current.getTotalLength();C&&l(C)}catch{}},[]);var c=r.x,d=r.y,h=r.upperWidth,p=r.lowerWidth,g=r.height,v=r.className,b=r.animationEasing,y=r.animationDuration,w=r.animationBegin,j=r.isUpdateAnimationActive;if(c!==+c||d!==+d||h!==+h||p!==+p||g!==+g||h===0&&p===0||g===0)return null;var x=An("recharts-trapezoid",v);return j?Ne.createElement(hp,{canBegin:o>0,from:{upperWidth:0,lowerWidth:0,height:g,x:c,y:d},to:{upperWidth:h,lowerWidth:p,height:g,x:c,y:d},duration:y,animationEasing:b,isActive:j},function(C){var k=C.upperWidth,S=C.lowerWidth,_=C.height,A=C.x,T=C.y;return Ne.createElement(hp,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:y,easing:b},Ne.createElement("path",JC({},Mr(r,!0),{className:x,d:K7(A,T,k,S,_),ref:n})))}):Ne.createElement("g",null,Ne.createElement("path",JC({},Mr(r,!0),{className:x,d:K7(c,d,h,p,g)})))},iDe=["option","shapeType","propTransformer","activeClassName","isActive"];function _j(e){"@babel/helpers - typeof";return _j=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},_j(e)}function oDe(e,s){if(e==null)return{};var r=lDe(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function lDe(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function G7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ek(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?G7(Object(r),!0).forEach(function(n){cDe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):G7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function cDe(e,s,r){return s=dDe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function dDe(e){var s=uDe(e,"string");return _j(s)=="symbol"?s:s+""}function uDe(e,s){if(_j(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(_j(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function mDe(e,s){return ek(ek({},s),e)}function hDe(e,s){return e==="symbols"}function Y7(e){var s=e.shapeType,r=e.elementProps;switch(s){case"rectangle":return Ne.createElement(TD,r);case"trapezoid":return Ne.createElement(aDe,r);case"sector":return Ne.createElement(dne,r);case"symbols":if(hDe(s))return Ne.createElement(G3,r);break;default:return null}}function pDe(e){return u.isValidElement(e)?e.props:e}function jne(e){var s=e.option,r=e.shapeType,n=e.propTransformer,a=n===void 0?mDe:n,i=e.activeClassName,o=i===void 0?"recharts-active-shape":i,l=e.isActive,c=oDe(e,iDe),d;if(u.isValidElement(s))d=u.cloneElement(s,ek(ek({},c),pDe(s)));else if(Qr(s))d=s(c);else if(W3e(s)&&!Y3e(s)){var h=a(s,c);d=Ne.createElement(Y7,{shapeType:r,elementProps:h})}else{var p=c;d=Ne.createElement(Y7,{shapeType:r,elementProps:p})}return l?Ne.createElement(wa,{className:o},d):d}function J_(e,s){return s!=null&&"trapezoids"in e.props}function e2(e,s){return s!=null&&"sectors"in e.props}function Pj(e,s){return s!=null&&"points"in e.props}function fDe(e,s){var r,n,a=e.x===(s==null||(r=s.labelViewBox)===null||r===void 0?void 0:r.x)||e.x===s.x,i=e.y===(s==null||(n=s.labelViewBox)===null||n===void 0?void 0:n.y)||e.y===s.y;return a&&i}function gDe(e,s){var r=e.endAngle===s.endAngle,n=e.startAngle===s.startAngle;return r&&n}function xDe(e,s){var r=e.x===s.x,n=e.y===s.y,a=e.z===s.z;return r&&n&&a}function vDe(e,s){var r;return J_(e,s)?r=fDe:e2(e,s)?r=gDe:Pj(e,s)&&(r=xDe),r}function yDe(e,s){var r;return J_(e,s)?r="trapezoids":e2(e,s)?r="sectors":Pj(e,s)&&(r="points"),r}function bDe(e,s){if(J_(e,s)){var r;return(r=s.tooltipPayload)===null||r===void 0||(r=r[0])===null||r===void 0||(r=r.payload)===null||r===void 0?void 0:r.payload}if(e2(e,s)){var n;return(n=s.tooltipPayload)===null||n===void 0||(n=n[0])===null||n===void 0||(n=n.payload)===null||n===void 0?void 0:n.payload}return Pj(e,s)?s.payload:{}}function wDe(e){var s=e.activeTooltipItem,r=e.graphicalItem,n=e.itemData,a=yDe(r,s),i=bDe(r,s),o=n.filter(function(c,d){var h=Jy(i,c),p=r.props[a].filter(function(b){var y=vDe(r,s);return y(b,s)}),g=r.props[a].indexOf(p[p.length-1]),v=d===g;return h&&v}),l=n.indexOf(o[o.length-1]);return l}var pS;function nb(e){"@babel/helpers - typeof";return nb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},nb(e)}function Jv(){return Jv=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Jv.apply(this,arguments)}function Q7(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Si(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Q7(Object(r),!0).forEach(function(n){Pm(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Q7(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function jDe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function X7(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Sne(n.key),n)}}function NDe(e,s,r){return s&&X7(e.prototype,s),r&&X7(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function SDe(e,s,r){return s=tk(s),CDe(e,Nne()?Reflect.construct(s,r||[],tk(e).constructor):s.apply(e,r))}function CDe(e,s){if(s&&(nb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return kDe(e)}function kDe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Nne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Nne=function(){return!!e})()}function tk(e){return tk=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},tk(e)}function _De(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&ER(e,s)}function ER(e,s){return ER=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},ER(e,s)}function Pm(e,s,r){return s=Sne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Sne(e){var s=PDe(e,"string");return nb(s)=="symbol"?s:s+""}function PDe(e,s){if(nb(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(nb(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Pf=(function(e){function s(r){var n;return jDe(this,s),n=SDe(this,s,[r]),Pm(n,"pieRef",null),Pm(n,"sectorRefs",[]),Pm(n,"id",Fb("recharts-pie-")),Pm(n,"handleAnimationEnd",function(){var a=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),Qr(a)&&a()}),Pm(n,"handleAnimationStart",function(){var a=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),Qr(a)&&a()}),n.state={isAnimationFinished:!r.isAnimationActive,prevIsAnimationActive:r.isAnimationActive,prevAnimationId:r.animationId,sectorToFocus:0},n}return _De(s,e),NDe(s,[{key:"isActiveIndex",value:function(n){var a=this.props.activeIndex;return Array.isArray(a)?a.indexOf(n)!==-1:n===a}},{key:"hasActiveIndex",value:function(){var n=this.props.activeIndex;return Array.isArray(n)?n.length!==0:n||n===0}},{key:"renderLabels",value:function(n){var a=this.props.isAnimationActive;if(a&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.label,l=i.labelLine,c=i.dataKey,d=i.valueKey,h=Mr(this.props,!1),p=Mr(o,!1),g=Mr(l,!1),v=o&&o.offsetRadius||20,b=n.map(function(y,w){var j=(y.startAngle+y.endAngle)/2,x=ki(y.cx,y.cy,y.outerRadius+v,j),C=Si(Si(Si(Si({},h),y),{},{stroke:"none"},p),{},{index:w,textAnchor:s.getTextAnchor(x.x,y.cx)},x),k=Si(Si(Si(Si({},h),y),{},{fill:"none",stroke:y.fill},g),{},{index:w,points:[ki(y.cx,y.cy,y.outerRadius,j),x]}),S=c;return Tn(c)&&Tn(d)?S="value":Tn(c)&&(S=d),Ne.createElement(wa,{key:"label-".concat(y.startAngle,"-").concat(y.endAngle,"-").concat(y.midAngle,"-").concat(w)},l&&s.renderLabelLineItem(l,k,"line"),s.renderLabelItem(o,C,Wl(y,S)))});return Ne.createElement(wa,{className:"recharts-pie-labels"},b)}},{key:"renderSectorsStatically",value:function(n){var a=this,i=this.props,o=i.activeShape,l=i.blendStroke,c=i.inactiveShape;return n.map(function(d,h){if(d?.startAngle===0&&d?.endAngle===0&&n.length!==1)return null;var p=a.isActiveIndex(h),g=c&&a.hasActiveIndex()?c:null,v=p?o:g,b=Si(Si({},d),{},{stroke:l?d.fill:d.stroke,tabIndex:-1});return Ne.createElement(wa,Jv({ref:function(w){w&&!a.sectorRefs.includes(w)&&a.sectorRefs.push(w)},tabIndex:-1,className:"recharts-pie-sector"},ev(a.props,d,h),{key:"sector-".concat(d?.startAngle,"-").concat(d?.endAngle,"-").concat(d.midAngle,"-").concat(h)}),Ne.createElement(jne,Jv({option:v,isActive:p,shapeType:"sector"},b)))})}},{key:"renderSectorsWithAnimation",value:function(){var n=this,a=this.props,i=a.sectors,o=a.isAnimationActive,l=a.animationBegin,c=a.animationDuration,d=a.animationEasing,h=a.animationId,p=this.state,g=p.prevSectors,v=p.prevIsAnimationActive;return Ne.createElement(hp,{begin:l,duration:c,isActive:o,easing:d,from:{t:0},to:{t:1},key:"pie-".concat(h,"-").concat(v),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(b){var y=b.t,w=[],j=i&&i[0],x=j.startAngle;return i.forEach(function(C,k){var S=g&&g[k],_=k>0?em(C,"paddingAngle",0):0;if(S){var A=gu(S.endAngle-S.startAngle,C.endAngle-C.startAngle),T=Si(Si({},C),{},{startAngle:x+_,endAngle:x+A(y)+_});w.push(T),x=T.endAngle}else{var M=C.endAngle,R=C.startAngle,D=gu(0,M-R),$=D(y),O=Si(Si({},C),{},{startAngle:x+_,endAngle:x+$+_});w.push(O),x=O.endAngle}}),Ne.createElement(wa,null,n.renderSectorsStatically(w))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(i){if(!i.altKey)switch(i.key){case"ArrowLeft":{var o=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[o].focus(),a.setState({sectorToFocus:o});break}case"ArrowRight":{var l=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,i=n.isAnimationActive,o=this.state.prevSectors;return i&&a&&a.length&&(!o||!Jy(o,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var n=this,a=this.props,i=a.hide,o=a.sectors,l=a.className,c=a.label,d=a.cx,h=a.cy,p=a.innerRadius,g=a.outerRadius,v=a.isAnimationActive,b=this.state.isAnimationFinished;if(i||!o||!o.length||!bs(d)||!bs(h)||!bs(p)||!bs(g))return null;var y=An("recharts-pie",l);return Ne.createElement(wa,{tabIndex:this.props.rootTabIndex,className:y,ref:function(j){n.pieRef=j}},this.renderSectors(),c&&this.renderLabels(o),xc.renderCallByParent(this.props,null,!1),(!v||b)&&df.renderCallByParent(this.props,o,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n<a?"end":"middle"}},{key:"renderLabelLineItem",value:function(n,a,i){if(Ne.isValidElement(n))return Ne.cloneElement(n,a);if(Qr(n))return n(a);var o=An("recharts-pie-label-line",typeof n!="boolean"?n.className:"");return Ne.createElement(yy,Jv({},a,{key:i,type:"linear",className:o}))}},{key:"renderLabelItem",value:function(n,a,i){if(Ne.isValidElement(n))return Ne.cloneElement(n,a);var o=i;if(Qr(n)&&(o=n(a),Ne.isValidElement(o)))return o;var l=An("recharts-pie-label-text",typeof n!="boolean"&&!Qr(n)?n.className:"");return Ne.createElement(tv,Jv({},a,{alignmentBaseline:"middle",className:l}),o)}}])})(u.PureComponent);pS=Pf;Pm(Pf,"displayName","Pie");Pm(Pf,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!hv.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});Pm(Pf,"parseDeltaAngle",function(e,s){var r=Vd(s-e),n=Math.min(Math.abs(s-e),360);return r*n});Pm(Pf,"getRealPieData",function(e){var s=e.data,r=e.children,n=Mr(e,!1),a=Rm(r,nj);return s&&s.length?s.map(function(i,o){return Si(Si(Si({payload:i},n),i),a&&a[o]&&a[o].props)}):a&&a.length?a.map(function(i){return Si(Si({},n),i.props)}):[]});Pm(Pf,"parseCoordinateOfPie",function(e,s){var r=s.top,n=s.left,a=s.width,i=s.height,o=ine(a,i),l=n+Wd(e.cx,a,a/2),c=r+Wd(e.cy,i,i/2),d=Wd(e.innerRadius,o,0),h=Wd(e.outerRadius,o,o*.8),p=e.maxRadius||Math.sqrt(a*a+i*i)/2;return{cx:l,cy:c,innerRadius:d,outerRadius:h,maxRadius:p}});Pm(Pf,"getComposedData",function(e){var s=e.item,r=e.offset,n=s.type.defaultProps!==void 0?Si(Si({},s.type.defaultProps),s.props):s.props,a=pS.getRealPieData(n);if(!a||!a.length)return null;var i=n.cornerRadius,o=n.startAngle,l=n.endAngle,c=n.paddingAngle,d=n.dataKey,h=n.nameKey,p=n.valueKey,g=n.tooltipType,v=Math.abs(n.minAngle),b=pS.parseCoordinateOfPie(n,r),y=pS.parseDeltaAngle(o,l),w=Math.abs(y),j=d;Tn(d)&&Tn(p)?(yh(!1,`Use "dataKey" to specify the value of pie,
551      the props "valueKey" will be deprecated in 1.1.0`),j="value"):Tn(d)&&(yh(!1,`Use "dataKey" to specify the value of pie,
552      the props "valueKey" will be deprecated in 1.1.0`),j=p);var x=a.filter(function(T){return Wl(T,j,0)!==0}).length,C=(w>=360?x:x-1)*c,k=w-x*v-C,S=a.reduce(function(T,M){var R=Wl(M,j,0);return T+(bs(R)?R:0)},0),_;if(S>0){var A;_=a.map(function(T,M){var R=Wl(T,j,0),D=Wl(T,h,M),$=(bs(R)?R:0)/S,O;M?O=A.endAngle+Vd(y)*c*(R!==0?1:0):O=o;var q=O+Vd(y)*((R!==0?v:0)+$*k),V=(O+q)/2,K=(b.innerRadius+b.outerRadius)/2,G=[{name:D,value:R,payload:T,dataKey:j,type:g}],z=ki(b.cx,b.cy,K,V);return A=Si(Si(Si({percent:$,cornerRadius:i,name:D,tooltipPayload:G,midAngle:V,middleRadius:K,tooltipPosition:z},T),b),{},{value:Wl(T,j),startAngle:O,endAngle:q,payload:T,paddingAngle:Vd(y)*c}),A})}return Si(Si({},b),{},{sectors:_,data:a})});var b4,Z7;function EDe(){if(Z7)return b4;Z7=1;var e=Math.ceil,s=Math.max;function r(n,a,i,o){for(var l=-1,c=s(e((a-n)/(i||1)),0),d=Array(c);c--;)d[o?c:++l]=n,n+=i;return d}return b4=r,b4}var w4,J7;function Cne(){if(J7)return w4;J7=1;var e=Kse(),s=1/0,r=17976931348623157e292;function n(a){if(!a)return a===0?a:0;if(a=e(a),a===s||a===-s){var i=a<0?-1:1;return i*r}return a===a?a:0}return w4=n,w4}var j4,eq;function TDe(){if(eq)return j4;eq=1;var e=EDe(),s=D_(),r=Cne();function n(a){return function(i,o,l){return l&&typeof l!="number"&&s(i,o,l)&&(o=l=void 0),i=r(i),o===void 0?(o=i,i=0):o=r(o),l=l===void 0?i<o?1:-1:r(l),e(i,o,l,a)}}return j4=n,j4}var N4,tq;function ADe(){if(tq)return N4;tq=1;var e=TDe(),s=e();return N4=s,N4}var MDe=ADe();const sk=ei(MDe);function Ej(e){"@babel/helpers - typeof";return Ej=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Ej(e)}function sq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function rq(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?sq(Object(r),!0).forEach(function(n){kne(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function kne(e,s,r){return s=RDe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function RDe(e){var s=IDe(e,"string");return Ej(s)=="symbol"?s:s+""}function IDe(e,s){if(Ej(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Ej(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var ODe=["Webkit","Moz","O","ms"],DDe=function(s,r){var n=s.replace(/(\w)/,function(i){return i.toUpperCase()}),a=ODe.reduce(function(i,o){return rq(rq({},i),{},kne({},o+n,r))},{});return a[s]=r,a};function ab(e){"@babel/helpers - typeof";return ab=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},ab(e)}function rk(){return rk=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},rk.apply(this,arguments)}function nq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function S4(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?nq(Object(r),!0).forEach(function(n){qu(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):nq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function LDe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function aq(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Pne(n.key),n)}}function $De(e,s,r){return s&&aq(e.prototype,s),r&&aq(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function FDe(e,s,r){return s=nk(s),BDe(e,_ne()?Reflect.construct(s,r||[],nk(e).constructor):s.apply(e,r))}function BDe(e,s){if(s&&(ab(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return UDe(e)}function UDe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _ne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(_ne=function(){return!!e})()}
vendor: 124,493 bytes, lines 552-556
552function nk(e){return nk=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},nk(e)}function zDe(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&TR(e,s)}function TR(e,s){return TR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},TR(e,s)}function qu(e,s,r){return s=Pne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Pne(e){var s=HDe(e,"string");return ab(s)=="symbol"?s:s+""}function HDe(e,s){if(ab(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(ab(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var qDe=function(s){var r=s.data,n=s.startIndex,a=s.endIndex,i=s.x,o=s.width,l=s.travellerWidth;if(!r||!r.length)return{};var c=r.length,d=p0().domain(sk(0,c)).range([i,i+o-l]),h=d.domain().map(function(p){return d(p)});return{isTextActive:!1,isSlideMoving:!1,isTravellerMoving:!1,isTravellerFocused:!1,startX:d(n),endX:d(a),scale:d,scaleValues:h}},iq=function(s){return s.changedTouches&&!!s.changedTouches.length},ib=(function(e){function s(r){var n;return LDe(this,s),n=FDe(this,s,[r]),qu(n,"handleDrag",function(a){n.leaveTimer&&(clearTimeout(n.leaveTimer),n.leaveTimer=null),n.state.isTravellerMoving?n.handleTravellerMove(a):n.state.isSlideMoving&&n.handleSlideDrag(a)}),qu(n,"handleTouchMove",function(a){a.changedTouches!=null&&a.changedTouches.length>0&&n.handleDrag(a.changedTouches[0])}),qu(n,"handleDragEnd",function(){n.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var a=n.props,i=a.endIndex,o=a.onDragEnd,l=a.startIndex;o?.({endIndex:i,startIndex:l})}),n.detachDragEndListener()}),qu(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),qu(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),qu(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),qu(n,"handleSlideDragStart",function(a){var i=iq(a)?a.changedTouches[0]:a;n.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:i.pageX}),n.attachDragEndListener()}),n.travellerDragStartHandlers={startX:n.handleTravellerDragStart.bind(n,"startX"),endX:n.handleTravellerDragStart.bind(n,"endX")},n.state={},n}return zDe(s,e),$De(s,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var a=n.startX,i=n.endX,o=this.state.scaleValues,l=this.props,c=l.gap,d=l.data,h=d.length-1,p=Math.min(a,i),g=Math.max(a,i),v=s.getIndexInRange(o,p),b=s.getIndexInRange(o,g);return{startIndex:v-v%c,endIndex:b===h?h:b-b%c}}},{key:"getTextOfTick",value:function(n){var a=this.props,i=a.data,o=a.tickFormatter,l=a.dataKey,c=Wl(i[n],l,n);return Qr(o)?o(c,n):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(n){var a=this.state,i=a.slideMoveStartX,o=a.startX,l=a.endX,c=this.props,d=c.x,h=c.width,p=c.travellerWidth,g=c.startIndex,v=c.endIndex,b=c.onChange,y=n.pageX-i;y>0?y=Math.min(y,d+h-p-l,d+h-p-o):y<0&&(y=Math.max(y,d-o,d-l));var w=this.getIndex({startX:o+y,endX:l+y});(w.startIndex!==g||w.endIndex!==v)&&b&&b(w),this.setState({startX:o+y,endX:l+y,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var i=iq(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:i.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var a=this.state,i=a.brushMoveStartX,o=a.movingTravellerId,l=a.endX,c=a.startX,d=this.state[o],h=this.props,p=h.x,g=h.width,v=h.travellerWidth,b=h.onChange,y=h.gap,w=h.data,j={startX:this.state.startX,endX:this.state.endX},x=n.pageX-i;x>0?x=Math.min(x,p+g-v-d):x<0&&(x=Math.max(x,p-d)),j[o]=d+x;var C=this.getIndex(j),k=C.startIndex,S=C.endIndex,_=function(){var T=w.length-1;return o==="startX"&&(l>c?k%y===0:S%y===0)||l<c&&S===T||o==="endX"&&(l>c?S%y===0:k%y===0)||l>c&&S===T};this.setState(qu(qu({},o,d+x),"brushMoveStartX",n.pageX),function(){b&&_()&&b(C)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var i=this,o=this.state,l=o.scaleValues,c=o.startX,d=o.endX,h=this.state[a],p=l.indexOf(h);if(p!==-1){var g=p+n;if(!(g===-1||g>=l.length)){var v=l[g];a==="startX"&&v>=d||a==="endX"&&v<=c||this.setState(qu({},a,v),function(){i.props.onChange(i.getIndex({startX:i.state.startX,endX:i.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,a=n.x,i=n.y,o=n.width,l=n.height,c=n.fill,d=n.stroke;return Ne.createElement("rect",{stroke:d,fill:c,x:a,y:i,width:o,height:l})}},{key:"renderPanorama",value:function(){var n=this.props,a=n.x,i=n.y,o=n.width,l=n.height,c=n.data,d=n.children,h=n.padding,p=u.Children.only(d);return p?Ne.cloneElement(p,{x:a,y:i,width:o,height:l,margin:h,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(n,a){var i,o,l=this,c=this.props,d=c.y,h=c.travellerWidth,p=c.height,g=c.traveller,v=c.ariaLabel,b=c.data,y=c.startIndex,w=c.endIndex,j=Math.max(n,this.props.x),x=S4(S4({},Mr(this.props,!1)),{},{x:j,y:d,width:h,height:p}),C=v||"Min value: ".concat((i=b[y])===null||i===void 0?void 0:i.name,", Max value: ").concat((o=b[w])===null||o===void 0?void 0:o.name);return Ne.createElement(wa,{tabIndex:0,role:"slider","aria-label":C,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(S){["ArrowLeft","ArrowRight"].includes(S.key)&&(S.preventDefault(),S.stopPropagation(),l.handleTravellerMoveKeyboard(S.key==="ArrowRight"?1:-1,a))},onFocus:function(){l.setState({isTravellerFocused:!0})},onBlur:function(){l.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},s.renderTraveller(g,x))}},{key:"renderSlide",value:function(n,a){var i=this.props,o=i.y,l=i.height,c=i.stroke,d=i.travellerWidth,h=Math.min(n,a)+d,p=Math.max(Math.abs(a-n)-d,0);return Ne.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:h,y:o,width:p,height:l})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,i=n.endIndex,o=n.y,l=n.height,c=n.travellerWidth,d=n.stroke,h=this.state,p=h.startX,g=h.endX,v=5,b={pointerEvents:"none",fill:d};return Ne.createElement(wa,{className:"recharts-brush-texts"},Ne.createElement(tv,rk({textAnchor:"end",verticalAnchor:"middle",x:Math.min(p,g)-v,y:o+l/2},b),this.getTextOfTick(a)),Ne.createElement(tv,rk({textAnchor:"start",verticalAnchor:"middle",x:Math.max(p,g)+c+v,y:o+l/2},b),this.getTextOfTick(i)))}},{key:"render",value:function(){var n=this.props,a=n.data,i=n.className,o=n.children,l=n.x,c=n.y,d=n.width,h=n.height,p=n.alwaysShowText,g=this.state,v=g.startX,b=g.endX,y=g.isTextActive,w=g.isSlideMoving,j=g.isTravellerMoving,x=g.isTravellerFocused;if(!a||!a.length||!bs(l)||!bs(c)||!bs(d)||!bs(h)||d<=0||h<=0)return null;var C=An("recharts-brush",i),k=Ne.Children.count(o)===1,S=DDe("userSelect","none");return Ne.createElement(wa,{className:C,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:S},this.renderBackground(),k&&this.renderPanorama(),this.renderSlide(v,b),this.renderTravellerLayer(v,"startX"),this.renderTravellerLayer(b,"endX"),(y||w||j||x||p)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,i=n.y,o=n.width,l=n.height,c=n.stroke,d=Math.floor(i+l/2)-1;return Ne.createElement(Ne.Fragment,null,Ne.createElement("rect",{x:a,y:i,width:o,height:l,fill:c,stroke:"none"}),Ne.createElement("line",{x1:a+1,y1:d,x2:a+o-1,y2:d,fill:"none",stroke:"#fff"}),Ne.createElement("line",{x1:a+1,y1:d+2,x2:a+o-1,y2:d+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,a){var i;return Ne.isValidElement(n)?i=Ne.cloneElement(n,a):Qr(n)?i=n(a):i=s.renderDefaultTraveller(a),i}},{key:"getDerivedStateFromProps",value:function(n,a){var i=n.data,o=n.width,l=n.x,c=n.travellerWidth,d=n.updateId,h=n.startIndex,p=n.endIndex;if(i!==a.prevData||d!==a.prevUpdateId)return S4({prevData:i,prevTravellerWidth:c,prevUpdateId:d,prevX:l,prevWidth:o},i&&i.length?qDe({data:i,width:o,x:l,travellerWidth:c,startIndex:h,endIndex:p}):{scale:null,scaleValues:null});if(a.scale&&(o!==a.prevWidth||l!==a.prevX||c!==a.prevTravellerWidth)){a.scale.range([l,l+o-c]);var g=a.scale.domain().map(function(v){return a.scale(v)});return{prevData:i,prevTravellerWidth:c,prevUpdateId:d,prevX:l,prevWidth:o,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:g}}return null}},{key:"getIndexInRange",value:function(n,a){for(var i=n.length,o=0,l=i-1;l-o>1;){var c=Math.floor((o+l)/2);n[c]>a?l=c:o=c}return a>=n[l]?l:o}}])})(u.PureComponent);qu(ib,"displayName","Brush");qu(ib,"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 C4,oq;function VDe(){if(oq)return C4;oq=1;var e=tD();function s(r,n){var a;return e(r,function(i,o,l){return a=n(i,o,l),!a}),!!a}return C4=s,C4}var k4,lq;function WDe(){if(lq)return k4;lq=1;var e=Sse(),s=xp(),r=VDe(),n=Cu(),a=D_();function i(o,l,c){var d=n(o)?e:r;return c&&a(o,l,c)&&(l=void 0),d(o,s(l,3))}return k4=i,k4}var KDe=WDe();const GDe=ei(KDe);var np=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},_4,cq;function YDe(){if(cq)return _4;cq=1;var e=zse();function s(r,n,a){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):r[n]=a}return _4=s,_4}var P4,dq;function QDe(){if(dq)return P4;dq=1;var e=YDe(),s=Bse(),r=xp();function n(a,i){var o={};return i=r(i,3),s(a,function(l,c,d){e(o,c,i(l,c,d))}),o}return P4=n,P4}var XDe=QDe();const ZDe=ei(XDe);var E4,uq;function JDe(){if(uq)return E4;uq=1;function e(s,r){for(var n=-1,a=s==null?0:s.length;++n<a;)if(!r(s[n],n,s))return!1;return!0}return E4=e,E4}var T4,mq;function eLe(){if(mq)return T4;mq=1;var e=tD();function s(r,n){var a=!0;return e(r,function(i,o,l){return a=!!n(i,o,l),a}),a}return T4=s,T4}var A4,hq;function tLe(){if(hq)return A4;hq=1;var e=JDe(),s=eLe(),r=xp(),n=Cu(),a=D_();function i(o,l,c){var d=n(o)?e:s;return c&&a(o,l,c)&&(l=void 0),d(o,r(l,3))}return A4=i,A4}var sLe=tLe();const Ene=ei(sLe);var rLe=["x","y"];function Tj(e){"@babel/helpers - typeof";return Tj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Tj(e)}function AR(){return AR=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},AR.apply(this,arguments)}function pq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ew(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?pq(Object(r),!0).forEach(function(n){nLe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function nLe(e,s,r){return s=aLe(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function aLe(e){var s=iLe(e,"string");return Tj(s)=="symbol"?s:s+""}function iLe(e,s){if(Tj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Tj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function oLe(e,s){if(e==null)return{};var r=lLe(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function lLe(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function cLe(e,s){var r=e.x,n=e.y,a=oLe(e,rLe),i="".concat(r),o=parseInt(i,10),l="".concat(n),c=parseInt(l,10),d="".concat(s.height||a.height),h=parseInt(d,10),p="".concat(s.width||a.width),g=parseInt(p,10);return Ew(Ew(Ew(Ew(Ew({},s),a),o?{x:o}:{}),c?{y:c}:{}),{},{height:h,width:g,name:s.name,radius:s.radius})}function fq(e){return Ne.createElement(jne,AR({shapeType:"rectangle",propTransformer:cLe,activeClassName:"recharts-active-bar"},e))}var dLe=function(s){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,a){if(typeof s=="number")return s;var i=typeof n=="number";return i?s(n,a):(i||rv(),r)}},uLe=["value","background"],Tne;function ob(e){"@babel/helpers - typeof";return ob=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},ob(e)}function mLe(e,s){if(e==null)return{};var r=hLe(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function hLe(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function ak(){return ak=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ak.apply(this,arguments)}function gq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function bl(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?gq(Object(r),!0).forEach(function(n){xg(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):gq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function pLe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function xq(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Mne(n.key),n)}}function fLe(e,s,r){return s&&xq(e.prototype,s),r&&xq(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function gLe(e,s,r){return s=ik(s),xLe(e,Ane()?Reflect.construct(s,r||[],ik(e).constructor):s.apply(e,r))}function xLe(e,s){if(s&&(ob(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return vLe(e)}function vLe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ane(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ane=function(){return!!e})()}function ik(e){return ik=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ik(e)}function yLe(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&MR(e,s)}function MR(e,s){return MR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},MR(e,s)}function xg(e,s,r){return s=Mne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Mne(e){var s=bLe(e,"string");return ob(s)=="symbol"?s:s+""}function bLe(e,s){if(ob(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(ob(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var xv=(function(e){function s(){var r;pLe(this,s);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return r=gLe(this,s,[].concat(a)),xg(r,"state",{isAnimationFinished:!1}),xg(r,"id",Fb("recharts-bar-")),xg(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),o&&o()}),xg(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),o&&o()}),r}return yLe(s,e),fLe(s,[{key:"renderRectanglesStatically",value:function(n){var a=this,i=this.props,o=i.shape,l=i.dataKey,c=i.activeIndex,d=i.activeBar,h=Mr(this.props,!1);return n&&n.map(function(p,g){var v=g===c,b=v?d:o,y=bl(bl(bl({},h),p),{},{isActive:v,option:b,index:g,dataKey:l,onAnimationStart:a.handleAnimationStart,onAnimationEnd:a.handleAnimationEnd});return Ne.createElement(wa,ak({className:"recharts-bar-rectangle"},ev(a.props,p,g),{key:"rectangle-".concat(p?.x,"-").concat(p?.y,"-").concat(p?.value,"-").concat(g)}),Ne.createElement(fq,y))})}},{key:"renderRectanglesWithAnimation",value:function(){var n=this,a=this.props,i=a.data,o=a.layout,l=a.isAnimationActive,c=a.animationBegin,d=a.animationDuration,h=a.animationEasing,p=a.animationId,g=this.state.prevData;return Ne.createElement(hp,{begin:c,duration:d,isActive:l,easing:h,from:{t:0},to:{t:1},key:"bar-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(v){var b=v.t,y=i.map(function(w,j){var x=g&&g[j];if(x){var C=gu(x.x,w.x),k=gu(x.y,w.y),S=gu(x.width,w.width),_=gu(x.height,w.height);return bl(bl({},w),{},{x:C(b),y:k(b),width:S(b),height:_(b)})}if(o==="horizontal"){var A=gu(0,w.height),T=A(b);return bl(bl({},w),{},{y:w.y+w.height-T,height:T})}var M=gu(0,w.width),R=M(b);return bl(bl({},w),{},{width:R})});return Ne.createElement(wa,null,n.renderRectanglesStatically(y))})}},{key:"renderRectangles",value:function(){var n=this.props,a=n.data,i=n.isAnimationActive,o=this.state.prevData;return i&&a&&a.length&&(!o||!Jy(o,a))?this.renderRectanglesWithAnimation():this.renderRectanglesStatically(a)}},{key:"renderBackground",value:function(){var n=this,a=this.props,i=a.data,o=a.dataKey,l=a.activeIndex,c=Mr(this.props.background,!1);return i.map(function(d,h){d.value;var p=d.background,g=mLe(d,uLe);if(!p)return null;var v=bl(bl(bl(bl(bl({},g),{},{fill:"#eee"},p),c),ev(n.props,d,h)),{},{onAnimationStart:n.handleAnimationStart,onAnimationEnd:n.handleAnimationEnd,dataKey:o,index:h,className:"recharts-bar-background-rectangle"});return Ne.createElement(fq,ak({key:"background-bar-".concat(h),option:n.props.background,isActive:h===l},v))})}},{key:"renderErrorBar",value:function(n,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,h=i.children,p=Rm(h,K_);if(!p)return null;var g=d==="vertical"?o[0].height/2:o[0].width/2,v=function(w,j){var x=Array.isArray(w.value)?w.value[1]:w.value;return{x:w.x,y:w.y,value:x,errorVal:Wl(w,j)}},b={clipPath:n?"url(#clipPath-".concat(a,")"):null};return Ne.createElement(wa,b,p.map(function(y){return Ne.cloneElement(y,{key:"error-bar-".concat(a,"-").concat(y.props.dataKey),data:o,xAxis:l,yAxis:c,layout:d,offset:g,dataPointFormatter:v})}))}},{key:"render",value:function(){var n=this.props,a=n.hide,i=n.data,o=n.className,l=n.xAxis,c=n.yAxis,d=n.left,h=n.top,p=n.width,g=n.height,v=n.isAnimationActive,b=n.background,y=n.id;if(a||!i||!i.length)return null;var w=this.state.isAnimationFinished,j=An("recharts-bar",o),x=l&&l.allowDataOverflow,C=c&&c.allowDataOverflow,k=x||C,S=Tn(y)?this.id:y;return Ne.createElement(wa,{className:j},x||C?Ne.createElement("defs",null,Ne.createElement("clipPath",{id:"clipPath-".concat(S)},Ne.createElement("rect",{x:x?d:d-p/2,y:C?h:h-g/2,width:x?p:p*2,height:C?g:g*2}))):null,Ne.createElement(wa,{className:"recharts-bar-rectangles",clipPath:k?"url(#clipPath-".concat(S,")"):null},b?this.renderBackground():null,this.renderRectangles()),this.renderErrorBar(k,S),(!v||w)&&df.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curData:n.data,prevData:a.curData}:n.data!==a.curData?{curData:n.data}:null}}])})(u.PureComponent);Tne=xv;xg(xv,"displayName","Bar");xg(xv,"defaultProps",{xAxisId:0,yAxisId:0,legendType:"rect",minPointSize:0,hide:!1,data:[],layout:"vertical",activeBar:!1,isAnimationActive:!hv.isSsr,animationBegin:0,animationDuration:400,animationEasing:"ease"});xg(xv,"getComposedData",function(e){var s=e.props,r=e.item,n=e.barPosition,a=e.bandSize,i=e.xAxis,o=e.yAxis,l=e.xAxisTicks,c=e.yAxisTicks,d=e.stackedData,h=e.dataStartIndex,p=e.displayedData,g=e.offset,v=YMe(n,r);if(!v)return null;var b=s.layout,y=r.type.defaultProps,w=y!==void 0?bl(bl({},y),r.props):r.props,j=w.dataKey,x=w.children,C=w.minPointSize,k=b==="horizontal"?o:i,S=d?k.scale.domain():null,_=sRe({numericAxis:k}),A=Rm(x,nj),T=p.map(function(M,R){var D,$,O,q,V,K;d?D=QMe(d[h+R],S):(D=Wl(M,j),Array.isArray(D)||(D=[_,D]));var G=dLe(C,Tne.defaultProps.minPointSize)(D[1],R);if(b==="horizontal"){var z,Z=[o.scale(D[0]),o.scale(D[1])],ee=Z[0],Q=Z[1];$=zH({axis:i,ticks:l,bandSize:a,offset:v.offset,entry:M,index:R}),O=(z=Q??ee)!==null&&z!==void 0?z:void 0,q=v.size;var Y=ee-Q;if(V=Number.isNaN(Y)?0:Y,K={x:$,y:o.y,width:q,height:o.height},Math.abs(G)>0&&Math.abs(V)<Math.abs(G)){var oe=Vd(V||G)*(Math.abs(G)-Math.abs(V));O-=oe,V+=oe}}else{var he=[i.scale(D[0]),i.scale(D[1])],je=he[0],pe=he[1];if($=je,O=zH({axis:o,ticks:c,bandSize:a,offset:v.offset,entry:M,index:R}),q=pe-je,V=v.size,K={x:i.x,y:O,width:i.width,height:V},Math.abs(G)>0&&Math.abs(q)<Math.abs(G)){var le=Vd(q||G)*(Math.abs(G)-Math.abs(q));q+=le}}return bl(bl(bl({},M),{},{x:$,y:O,width:q,height:V,value:d?D:D[1],payload:M,background:K},A&&A[R]&&A[R].props),{},{tooltipPayload:[nne(r,M)],tooltipPosition:{x:$+q/2,y:O+V/2}})});return bl({data:T,layout:b},g)});function Aj(e){"@babel/helpers - typeof";return Aj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Aj(e)}function wLe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function vq(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Rne(n.key),n)}}function jLe(e,s,r){return s&&vq(e.prototype,s),r&&vq(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function yq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function mh(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?yq(Object(r),!0).forEach(function(n){t2(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):yq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function t2(e,s,r){return s=Rne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Rne(e){var s=NLe(e,"string");return Aj(s)=="symbol"?s:s+""}function NLe(e,s){if(Aj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Aj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var Ine=function(s,r,n,a,i){var o=s.width,l=s.height,c=s.layout,d=s.children,h=Object.keys(r),p={left:n.left,leftMirror:n.left,right:o-n.right,rightMirror:o-n.right,top:n.top,topMirror:n.top,bottom:l-n.bottom,bottomMirror:l-n.bottom},g=!!Wu(d,xv);return h.reduce(function(v,b){var y=r[b],w=y.orientation,j=y.domain,x=y.padding,C=x===void 0?{}:x,k=y.mirror,S=y.reversed,_="".concat(w).concat(k?"Mirror":""),A,T,M,R,D;if(y.type==="number"&&(y.padding==="gap"||y.padding==="no-gap")){var $=j[1]-j[0],O=1/0,q=y.categoricalDomain.sort();if(q.forEach(function(he,je){je>0&&(O=Math.min((he||0)-(q[je-1]||0),O))}),Number.isFinite(O)){var V=O/$,K=y.layout==="vertical"?n.height:n.width;if(y.padding==="gap"&&(A=V*K/2),y.padding==="no-gap"){var G=Wd(s.barCategoryGap,V*K),z=V*K/2;A=z-G-(z-G)/K*G}}}a==="xAxis"?T=[n.left+(C.left||0)+(A||0),n.left+n.width-(C.right||0)-(A||0)]:a==="yAxis"?T=c==="horizontal"?[n.top+n.height-(C.bottom||0),n.top+(C.top||0)]:[n.top+(C.top||0)+(A||0),n.top+n.height-(C.bottom||0)-(A||0)]:T=y.range,S&&(T=[T[1],T[0]]);var Z=ene(y,i,g),ee=Z.scale,Q=Z.realScaleType;ee.domain(j).range(T),tne(ee);var Y=sne(ee,mh(mh({},y),{},{realScaleType:Q}));a==="xAxis"?(D=w==="top"&&!k||w==="bottom"&&k,M=n.left,R=p[_]-D*y.height):a==="yAxis"&&(D=w==="left"&&!k||w==="right"&&k,M=p[_]-D*y.width,R=n.top);var oe=mh(mh(mh({},y),Y),{},{realScaleType:Q,x:M,y:R,scale:ee,width:a==="xAxis"?n.width:y.width,height:a==="yAxis"?n.height:y.height});return oe.bandSize=qC(oe,Y),!y.hide&&a==="xAxis"?p[_]+=(D?-1:1)*oe.height:y.hide||(p[_]+=(D?-1:1)*oe.width),mh(mh({},v),{},t2({},b,oe))},{})},One=function(s,r){var n=s.x,a=s.y,i=r.x,o=r.y;return{x:Math.min(n,i),y:Math.min(a,o),width:Math.abs(i-n),height:Math.abs(o-a)}},SLe=function(s){var r=s.x1,n=s.y1,a=s.x2,i=s.y2;return One({x:r,y:n},{x:a,y:i})},Dne=(function(){function e(s){wLe(this,e),this.scale=s}return jLe(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 n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,i=n.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 n=this.range(),a=n[0],i=n[n.length-1];return a<=i?r>=a&&r<=i:r>=i&&r<=a}}],[{key:"create",value:function(r){return new e(r)}}])})();t2(Dne,"EPS",1e-4);var AD=function(s){var r=Object.keys(s).reduce(function(n,a){return mh(mh({},n),{},t2({},a,Dne.create(s[a])))},{});return mh(mh({},r),{},{apply:function(a){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.bandAware,l=i.position;return ZDe(a,function(c,d){return r[d].apply(c,{bandAware:o,position:l})})},isInRange:function(a){return Ene(a,function(i,o){return r[o].isInRange(i)})}})};function CLe(e){return(e%180+180)%180}var kLe=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=CLe(a),o=i*Math.PI/180,l=Math.atan(n/r),c=o>l&&o<Math.PI-l?n/Math.sin(o):r/Math.cos(o);return Math.abs(c)},M4,bq;function _Le(){if(bq)return M4;bq=1;var e=xp(),s=hN(),r=I_();function n(a){return function(i,o,l){var c=Object(i);if(!s(i)){var d=e(o,3);i=r(i),o=function(p){return d(c[p],p,c)}}var h=a(i,o,l);return h>-1?c[d?i[h]:h]:void 0}}return M4=n,M4}var R4,wq;function PLe(){if(wq)return R4;wq=1;var e=Cne();function s(r){var n=e(r),a=n%1;return n===n?a?n-a:n:0}return R4=s,R4}var I4,jq;function ELe(){if(jq)return I4;jq=1;var e=Ose(),s=xp(),r=PLe(),n=Math.max;function a(i,o,l){var c=i==null?0:i.length;if(!c)return-1;var d=l==null?0:r(l);return d<0&&(d=n(c+d,0)),e(i,s(o,3),d)}return I4=a,I4}var O4,Nq;function TLe(){if(Nq)return O4;Nq=1;var e=_Le(),s=ELe(),r=e(s);return O4=r,O4}var ALe=TLe();const MLe=ei(ALe);var RLe=Xte();const ILe=ei(RLe);var OLe=ILe(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("")}),MD=u.createContext(void 0),RD=u.createContext(void 0),Lne=u.createContext(void 0),$ne=u.createContext({}),Fne=u.createContext(void 0),Bne=u.createContext(0),Une=u.createContext(0),Sq=function(s){var r=s.state,n=r.xAxisMap,a=r.yAxisMap,i=r.offset,o=s.clipPathId,l=s.children,c=s.width,d=s.height,h=OLe(i);return Ne.createElement(MD.Provider,{value:n},Ne.createElement(RD.Provider,{value:a},Ne.createElement($ne.Provider,{value:i},Ne.createElement(Lne.Provider,{value:h},Ne.createElement(Fne.Provider,{value:o},Ne.createElement(Bne.Provider,{value:d},Ne.createElement(Une.Provider,{value:c},l)))))))},DLe=function(){return u.useContext(Fne)},zne=function(s){var r=u.useContext(MD);r==null&&rv();var n=r[s];return n==null&&rv(),n},LLe=function(){var s=u.useContext(MD);return ug(s)},$Le=function(){var s=u.useContext(RD),r=MLe(s,function(n){return Ene(n.domain,Number.isFinite)});return r||ug(s)},Hne=function(s){var r=u.useContext(RD);r==null&&rv();var n=r[s];return n==null&&rv(),n},FLe=function(){var s=u.useContext(Lne);return s},BLe=function(){return u.useContext($ne)},ID=function(){return u.useContext(Une)},OD=function(){return u.useContext(Bne)};function lb(e){"@babel/helpers - typeof";return lb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},lb(e)}function ULe(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function zLe(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Vne(n.key),n)}}function HLe(e,s,r){return s&&zLe(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function qLe(e,s,r){return s=ok(s),VLe(e,qne()?Reflect.construct(s,r||[],ok(e).constructor):s.apply(e,r))}function VLe(e,s){if(s&&(lb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return WLe(e)}function WLe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function qne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(qne=function(){return!!e})()}function ok(e){return ok=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ok(e)}function KLe(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&RR(e,s)}function RR(e,s){return RR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},RR(e,s)}function Cq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function kq(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Cq(Object(r),!0).forEach(function(n){DD(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Cq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function DD(e,s,r){return s=Vne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Vne(e){var s=GLe(e,"string");return lb(s)=="symbol"?s:s+""}function GLe(e,s){if(lb(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(lb(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function YLe(e,s){return JLe(e)||ZLe(e,s)||XLe(e,s)||QLe()}function QLe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
553In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function XLe(e,s){if(e){if(typeof e=="string")return _q(e,s);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 _q(e,s)}}function _q(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function ZLe(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function JLe(e){if(Array.isArray(e))return e}function IR(){return IR=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},IR.apply(this,arguments)}var e$e=function(s,r){var n;return Ne.isValidElement(s)?n=Ne.cloneElement(s,r):Qr(s)?n=s(r):n=Ne.createElement("line",IR({},r,{className:"recharts-reference-line-line"})),n},t$e=function(s,r,n,a,i,o,l,c,d){var h=i.x,p=i.y,g=i.width,v=i.height;if(n){var b=d.y,y=s.y.apply(b,{position:o});if(np(d,"discard")&&!s.y.isInRange(y))return null;var w=[{x:h+g,y},{x:h,y}];return c==="left"?w.reverse():w}if(r){var j=d.x,x=s.x.apply(j,{position:o});if(np(d,"discard")&&!s.x.isInRange(x))return null;var C=[{x,y:p+v},{x,y:p}];return l==="top"?C.reverse():C}if(a){var k=d.segment,S=k.map(function(_){return s.apply(_,{position:o})});return np(d,"discard")&&GDe(S,function(_){return!s.isInRange(_)})?null:S}return null};function s$e(e){var s=e.x,r=e.y,n=e.segment,a=e.xAxisId,i=e.yAxisId,o=e.shape,l=e.className,c=e.alwaysShow,d=DLe(),h=zne(a),p=Hne(i),g=FLe();if(!d||!g)return null;yh(c===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var v=AD({x:h.scale,y:p.scale}),b=Gl(s),y=Gl(r),w=n&&n.length===2,j=t$e(v,b,y,w,g,e.position,h.orientation,p.orientation,e);if(!j)return null;var x=YLe(j,2),C=x[0],k=C.x,S=C.y,_=x[1],A=_.x,T=_.y,M=np(e,"hidden")?"url(#".concat(d,")"):void 0,R=kq(kq({clipPath:M},Mr(e,!0)),{},{x1:k,y1:S,x2:A,y2:T});return Ne.createElement(wa,{className:An("recharts-reference-line",l)},e$e(o,R),xc.renderCallByParent(e,SLe({x1:k,y1:S,x2:A,y2:T})))}var LD=(function(e){function s(){return ULe(this,s),qLe(this,s,arguments)}return KLe(s,e),HLe(s,[{key:"render",value:function(){return Ne.createElement(s$e,this.props)}}])})(Ne.Component);DD(LD,"displayName","ReferenceLine");DD(LD,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle"});function OR(){return OR=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},OR.apply(this,arguments)}function cb(e){"@babel/helpers - typeof";return cb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},cb(e)}function Pq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Eq(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Pq(Object(r),!0).forEach(function(n){s2(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Pq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function r$e(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function n$e(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Kne(n.key),n)}}function a$e(e,s,r){return s&&n$e(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function i$e(e,s,r){return s=lk(s),o$e(e,Wne()?Reflect.construct(s,r||[],lk(e).constructor):s.apply(e,r))}function o$e(e,s){if(s&&(cb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return l$e(e)}function l$e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Wne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Wne=function(){return!!e})()}function lk(e){return lk=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},lk(e)}function c$e(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&DR(e,s)}function DR(e,s){return DR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},DR(e,s)}function s2(e,s,r){return s=Kne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Kne(e){var s=d$e(e,"string");return cb(s)=="symbol"?s:s+""}function d$e(e,s){if(cb(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(cb(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var u$e=function(s){var r=s.x,n=s.y,a=s.xAxis,i=s.yAxis,o=AD({x:a.scale,y:i.scale}),l=o.apply({x:r,y:n},{bandAware:!0});return np(s,"discard")&&!o.isInRange(l)?null:l},r2=(function(e){function s(){return r$e(this,s),i$e(this,s,arguments)}return c$e(s,e),a$e(s,[{key:"render",value:function(){var n=this.props,a=n.x,i=n.y,o=n.r,l=n.alwaysShow,c=n.clipPathId,d=Gl(a),h=Gl(i);if(yh(l===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.'),!d||!h)return null;var p=u$e(this.props);if(!p)return null;var g=p.x,v=p.y,b=this.props,y=b.shape,w=b.className,j=np(this.props,"hidden")?"url(#".concat(c,")"):void 0,x=Eq(Eq({clipPath:j},Mr(this.props,!0)),{},{cx:g,cy:v});return Ne.createElement(wa,{className:An("recharts-reference-dot",w)},s.renderDot(y,x),xc.renderCallByParent(this.props,{x:g-o,y:v-o,width:2*o,height:2*o}))}}])})(Ne.Component);s2(r2,"displayName","ReferenceDot");s2(r2,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#fff",stroke:"#ccc",fillOpacity:1,strokeWidth:1});s2(r2,"renderDot",function(e,s){var r;return Ne.isValidElement(e)?r=Ne.cloneElement(e,s):Qr(e)?r=e(s):r=Ne.createElement(G_,OR({},s,{cx:s.cx,cy:s.cy,className:"recharts-reference-dot-dot"})),r});function LR(){return LR=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},LR.apply(this,arguments)}function db(e){"@babel/helpers - typeof";return db=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},db(e)}function Tq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Aq(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Tq(Object(r),!0).forEach(function(n){n2(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Tq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function m$e(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function h$e(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Yne(n.key),n)}}function p$e(e,s,r){return s&&h$e(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function f$e(e,s,r){return s=ck(s),g$e(e,Gne()?Reflect.construct(s,r||[],ck(e).constructor):s.apply(e,r))}function g$e(e,s){if(s&&(db(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return x$e(e)}function x$e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Gne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Gne=function(){return!!e})()}function ck(e){return ck=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ck(e)}function v$e(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&$R(e,s)}function $R(e,s){return $R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},$R(e,s)}function n2(e,s,r){return s=Yne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Yne(e){var s=y$e(e,"string");return db(s)=="symbol"?s:s+""}function y$e(e,s){if(db(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(db(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var b$e=function(s,r,n,a,i){var o=i.x1,l=i.x2,c=i.y1,d=i.y2,h=i.xAxis,p=i.yAxis;if(!h||!p)return null;var g=AD({x:h.scale,y:p.scale}),v={x:s?g.x.apply(o,{position:"start"}):g.x.rangeMin,y:n?g.y.apply(c,{position:"start"}):g.y.rangeMin},b={x:r?g.x.apply(l,{position:"end"}):g.x.rangeMax,y:a?g.y.apply(d,{position:"end"}):g.y.rangeMax};return np(i,"discard")&&(!g.isInRange(v)||!g.isInRange(b))?null:One(v,b)},a2=(function(e){function s(){return m$e(this,s),f$e(this,s,arguments)}return v$e(s,e),p$e(s,[{key:"render",value:function(){var n=this.props,a=n.x1,i=n.x2,o=n.y1,l=n.y2,c=n.className,d=n.alwaysShow,h=n.clipPathId;yh(d===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var p=Gl(a),g=Gl(i),v=Gl(o),b=Gl(l),y=this.props.shape;if(!p&&!g&&!v&&!b&&!y)return null;var w=b$e(p,g,v,b,this.props);if(!w&&!y)return null;var j=np(this.props,"hidden")?"url(#".concat(h,")"):void 0;return Ne.createElement(wa,{className:An("recharts-reference-area",c)},s.renderRect(y,Aq(Aq({clipPath:j},Mr(this.props,!0)),w)),xc.renderCallByParent(this.props,w))}}])})(Ne.Component);n2(a2,"displayName","ReferenceArea");n2(a2,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#ccc",fillOpacity:.5,stroke:"none",strokeWidth:1});n2(a2,"renderRect",function(e,s){var r;return Ne.isValidElement(e)?r=Ne.cloneElement(e,s):Qr(e)?r=e(s):r=Ne.createElement(TD,LR({},s,{className:"recharts-reference-area-rect"})),r});function Qne(e,s,r){if(s<1)return[];if(s===1&&r===void 0)return e;for(var n=[],a=0;a<e.length;a+=s)n.push(e[a]);return n}function w$e(e,s,r){var n={width:e.width+s.width,height:e.height+s.height};return kLe(n,r)}function j$e(e,s,r){var n=r==="width",a=e.x,i=e.y,o=e.width,l=e.height;return s===1?{start:n?a:i,end:n?a+o:i+l}:{start:n?a+o:i+l,end:n?a:i}}function dk(e,s,r,n,a){if(e*s<e*n||e*s>e*a)return!1;var i=r();return e*(s-e*i/2-n)>=0&&e*(s+e*i/2-a)<=0}function N$e(e,s){return Qne(e,s+1)}function S$e(e,s,r,n,a){for(var i=(n||[]).slice(),o=s.start,l=s.end,c=0,d=1,h=o,p=function(){var b=n?.[c];if(b===void 0)return{v:Qne(n,d)};var y=c,w,j=function(){return w===void 0&&(w=r(b,y)),w},x=b.coordinate,C=c===0||dk(e,x,j,h,l);C||(c=0,h=o,d+=1),C&&(h=x+e*(j()/2+a),c+=d)},g;d<=i.length;)if(g=p(),g)return g.v;return[]}function Mj(e){"@babel/helpers - typeof";return Mj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Mj(e)}function Mq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function gd(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Mq(Object(r),!0).forEach(function(n){C$e(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Mq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function C$e(e,s,r){return s=k$e(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function k$e(e){var s=_$e(e,"string");return Mj(s)=="symbol"?s:s+""}function _$e(e,s){if(Mj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Mj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function P$e(e,s,r,n,a){for(var i=(n||[]).slice(),o=i.length,l=s.start,c=s.end,d=function(g){var v=i[g],b,y=function(){return b===void 0&&(b=r(v,g)),b};if(g===o-1){var w=e*(v.coordinate+e*y()/2-c);i[g]=v=gd(gd({},v),{},{tickCoord:w>0?v.coordinate-w*e:v.coordinate})}else i[g]=v=gd(gd({},v),{},{tickCoord:v.coordinate});var j=dk(e,v.tickCoord,y,l,c);j&&(c=v.tickCoord-e*(y()/2+a),i[g]=gd(gd({},v),{},{isShow:!0}))},h=o-1;h>=0;h--)d(h);return i}function E$e(e,s,r,n,a,i){var o=(n||[]).slice(),l=o.length,c=s.start,d=s.end;if(i){var h=n[l-1],p=r(h,l-1),g=e*(h.coordinate+e*p/2-d);o[l-1]=h=gd(gd({},h),{},{tickCoord:g>0?h.coordinate-g*e:h.coordinate});var v=dk(e,h.tickCoord,function(){return p},c,d);v&&(d=h.tickCoord-e*(p/2+a),o[l-1]=gd(gd({},h),{},{isShow:!0}))}for(var b=i?l-1:l,y=function(x){var C=o[x],k,S=function(){return k===void 0&&(k=r(C,x)),k};if(x===0){var _=e*(C.coordinate-e*S()/2-c);o[x]=C=gd(gd({},C),{},{tickCoord:_<0?C.coordinate-_*e:C.coordinate})}else o[x]=C=gd(gd({},C),{},{tickCoord:C.coordinate});var A=dk(e,C.tickCoord,S,c,d);A&&(c=C.tickCoord+e*(S()/2+a),o[x]=gd(gd({},C),{},{isShow:!0}))},w=0;w<b;w++)y(w);return o}function $D(e,s,r){var n=e.tick,a=e.ticks,i=e.viewBox,o=e.minTickGap,l=e.orientation,c=e.interval,d=e.tickFormatter,h=e.unit,p=e.angle;if(!a||!a.length||!n)return[];if(bs(c)||hv.isSsr)return N$e(a,typeof c=="number"&&bs(c)?c:0);var g=[],v=l==="top"||l==="bottom"?"width":"height",b=h&&v==="width"?h0(h,{fontSize:s,letterSpacing:r}):{width:0,height:0},y=function(C,k){var S=Qr(d)?d(C.value,k):C.value;return v==="width"?w$e(h0(S,{fontSize:s,letterSpacing:r}),b,p):h0(S,{fontSize:s,letterSpacing:r})[v]},w=a.length>=2?Vd(a[1].coordinate-a[0].coordinate):1,j=j$e(i,w,v);return c==="equidistantPreserveStart"?S$e(w,j,y,a,o):(c==="preserveStart"||c==="preserveStartEnd"?g=E$e(w,j,y,a,o,c==="preserveStartEnd"):g=P$e(w,j,y,a,o),g.filter(function(x){return x.isShow}))}var T$e=["viewBox"],A$e=["viewBox"],M$e=["ticks"];function ub(e){"@babel/helpers - typeof";return ub=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},ub(e)}function ey(){return ey=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ey.apply(this,arguments)}function Rq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ld(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Rq(Object(r),!0).forEach(function(n){FD(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function D4(e,s){if(e==null)return{};var r=R$e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function R$e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function I$e(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function Iq(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Zne(n.key),n)}}function O$e(e,s,r){return s&&Iq(e.prototype,s),r&&Iq(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function D$e(e,s,r){return s=uk(s),L$e(e,Xne()?Reflect.construct(s,r||[],uk(e).constructor):s.apply(e,r))}function L$e(e,s){if(s&&(ub(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return $$e(e)}function $$e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Xne(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Xne=function(){return!!e})()}function uk(e){return uk=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},uk(e)}function F$e(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&FR(e,s)}function FR(e,s){return FR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},FR(e,s)}function FD(e,s,r){return s=Zne(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Zne(e){var s=B$e(e,"string");return ub(s)=="symbol"?s:s+""}function B$e(e,s){if(ub(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(ub(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var qb=(function(e){function s(r){var n;return I$e(this,s),n=D$e(this,s,[r]),n.state={fontSize:"",letterSpacing:""},n}return F$e(s,e),O$e(s,[{key:"shouldComponentUpdate",value:function(n,a){var i=n.viewBox,o=D4(n,T$e),l=this.props,c=l.viewBox,d=D4(l,A$e);return!fy(i,c)||!fy(o,d)||!fy(a,this.state)}},{key:"componentDidMount",value:function(){var n=this.layerReference;if(n){var a=n.getElementsByClassName("recharts-cartesian-axis-tick-value")[0];a&&this.setState({fontSize:window.getComputedStyle(a).fontSize,letterSpacing:window.getComputedStyle(a).letterSpacing})}}},{key:"getTickLineCoord",value:function(n){var a=this.props,i=a.x,o=a.y,l=a.width,c=a.height,d=a.orientation,h=a.tickSize,p=a.mirror,g=a.tickMargin,v,b,y,w,j,x,C=p?-1:1,k=n.tickSize||h,S=bs(n.tickCoord)?n.tickCoord:n.coordinate;switch(d){case"top":v=b=n.coordinate,w=o+ +!p*c,y=w-C*k,x=y-C*g,j=S;break;case"left":y=w=n.coordinate,b=i+ +!p*l,v=b-C*k,j=v-C*g,x=S;break;case"right":y=w=n.coordinate,b=i+ +p*l,v=b+C*k,j=v+C*g,x=S;break;default:v=b=n.coordinate,w=o+ +p*c,y=w+C*k,x=y+C*g,j=S;break}return{line:{x1:v,y1:y,x2:b,y2:w},tick:{x:j,y:x}}}},{key:"getTickTextAnchor",value:function(){var n=this.props,a=n.orientation,i=n.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 n=this.props,a=n.orientation,i=n.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 n=this.props,a=n.x,i=n.y,o=n.width,l=n.height,c=n.orientation,d=n.mirror,h=n.axisLine,p=Ld(Ld(Ld({},Mr(this.props,!1)),Mr(h,!1)),{},{fill:"none"});if(c==="top"||c==="bottom"){var g=+(c==="top"&&!d||c==="bottom"&&d);p=Ld(Ld({},p),{},{x1:a,y1:i+g*l,x2:a+o,y2:i+g*l})}else{var v=+(c==="left"&&!d||c==="right"&&d);p=Ld(Ld({},p),{},{x1:a+v*o,y1:i,x2:a+v*o,y2:i+l})}return Ne.createElement("line",ey({},p,{className:An("recharts-cartesian-axis-line",em(h,"className"))}))}},{key:"renderTicks",value:function(n,a,i){var o=this,l=this.props,c=l.tickLine,d=l.stroke,h=l.tick,p=l.tickFormatter,g=l.unit,v=$D(Ld(Ld({},this.props),{},{ticks:n}),a,i),b=this.getTickTextAnchor(),y=this.getTickVerticalAnchor(),w=Mr(this.props,!1),j=Mr(h,!1),x=Ld(Ld({},w),{},{fill:"none"},Mr(c,!1)),C=v.map(function(k,S){var _=o.getTickLineCoord(k),A=_.line,T=_.tick,M=Ld(Ld(Ld(Ld({textAnchor:b,verticalAnchor:y},w),{},{stroke:"none",fill:d},j),T),{},{index:S,payload:k,visibleTicksCount:v.length,tickFormatter:p});return Ne.createElement(wa,ey({className:"recharts-cartesian-axis-tick",key:"tick-".concat(k.value,"-").concat(k.coordinate,"-").concat(k.tickCoord)},ev(o.props,k,S)),c&&Ne.createElement("line",ey({},x,A,{className:An("recharts-cartesian-axis-tick-line",em(c,"className"))})),h&&s.renderTickItem(h,M,"".concat(Qr(p)?p(k.value,S):k.value).concat(g||"")))});return Ne.createElement("g",{className:"recharts-cartesian-axis-ticks"},C)}},{key:"render",value:function(){var n=this,a=this.props,i=a.axisLine,o=a.width,l=a.height,c=a.ticksGenerator,d=a.className,h=a.hide;if(h)return null;var p=this.props,g=p.ticks,v=D4(p,M$e),b=g;return Qr(c)&&(b=g&&g.length>0?c(this.props):c(v)),o<=0||l<=0||!b||!b.length?null:Ne.createElement(wa,{className:An("recharts-cartesian-axis",d),ref:function(w){n.layerReference=w}},i&&this.renderAxisLine(),this.renderTicks(b,this.state.fontSize,this.state.letterSpacing),xc.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,i){var o;return Ne.isValidElement(n)?o=Ne.cloneElement(n,a):Qr(n)?o=n(a):o=Ne.createElement(tv,ey({},a,{className:"recharts-cartesian-axis-tick-value"}),i),o}}])})(u.Component);FD(qb,"displayName","CartesianAxis");FD(qb,"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 U$e=["x1","y1","x2","y2","key"],z$e=["offset"];function nv(e){"@babel/helpers - typeof";return nv=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},nv(e)}function Oq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function kd(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Oq(Object(r),!0).forEach(function(n){H$e(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Oq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function H$e(e,s,r){return s=q$e(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function q$e(e){var s=V$e(e,"string");return nv(s)=="symbol"?s:s+""}function V$e(e,s){if(nv(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(nv(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Tx(){return Tx=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Tx.apply(this,arguments)}function Dq(e,s){if(e==null)return{};var r=W$e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function W$e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}var K$e=function(s){var r=s.fill;if(!r||r==="none")return null;var n=s.fillOpacity,a=s.x,i=s.y,o=s.width,l=s.height,c=s.ry;return Ne.createElement("rect",{x:a,y:i,ry:c,width:o,height:l,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function Jne(e,s){var r;if(Ne.isValidElement(e))r=Ne.cloneElement(e,s);else if(Qr(e))r=e(s);else{var n=s.x1,a=s.y1,i=s.x2,o=s.y2,l=s.key,c=Dq(s,U$e),d=Mr(c,!1);d.offset;var h=Dq(d,z$e);r=Ne.createElement("line",Tx({},h,{x1:n,y1:a,x2:i,y2:o,fill:"none",key:l}))}return r}function G$e(e){var s=e.x,r=e.width,n=e.horizontal,a=n===void 0?!0:n,i=e.horizontalPoints;if(!a||!i||!i.length)return null;var o=i.map(function(l,c){var d=kd(kd({},e),{},{x1:s,y1:l,x2:s+r,y2:l,key:"line-".concat(c),index:c});return Jne(a,d)});return Ne.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function Y$e(e){var s=e.y,r=e.height,n=e.vertical,a=n===void 0?!0:n,i=e.verticalPoints;if(!a||!i||!i.length)return null;var o=i.map(function(l,c){var d=kd(kd({},e),{},{x1:l,y1:s,x2:l,y2:s+r,key:"line-".concat(c),index:c});return Jne(a,d)});return Ne.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function Q$e(e){var s=e.horizontalFill,r=e.fillOpacity,n=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||!s||!s.length)return null;var h=l.map(function(g){return Math.round(g+a-a)}).sort(function(g,v){return g-v});a!==h[0]&&h.unshift(0);var p=h.map(function(g,v){var b=!h[v+1],y=b?a+o-g:h[v+1]-g;if(y<=0)return null;var w=v%s.length;return Ne.createElement("rect",{key:"react-".concat(v),y:g,x:n,height:y,width:i,stroke:"none",fill:s[w],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return Ne.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},p)}function X$e(e){var s=e.vertical,r=s===void 0?!0:s,n=e.verticalFill,a=e.fillOpacity,i=e.x,o=e.y,l=e.width,c=e.height,d=e.verticalPoints;if(!r||!n||!n.length)return null;var h=d.map(function(g){return Math.round(g+i-i)}).sort(function(g,v){return g-v});i!==h[0]&&h.unshift(0);var p=h.map(function(g,v){var b=!h[v+1],y=b?i+l-g:h[v+1]-g;if(y<=0)return null;var w=v%n.length;return Ne.createElement("rect",{key:"react-".concat(v),x:g,y:o,width:y,height:c,stroke:"none",fill:n[w],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return Ne.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},p)}var Z$e=function(s,r){var n=s.xAxis,a=s.width,i=s.height,o=s.offset;return Jre($D(kd(kd(kd({},qb.defaultProps),n),{},{ticks:ef(n,!0),viewBox:{x:0,y:0,width:a,height:i}})),o.left,o.left+o.width,r)},J$e=function(s,r){var n=s.yAxis,a=s.width,i=s.height,o=s.offset;return Jre($D(kd(kd(kd({},qb.defaultProps),n),{},{ticks:ef(n,!0),viewBox:{x:0,y:0,width:a,height:i}})),o.top,o.top+o.height,r)},zv={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function BD(e){var s,r,n,a,i,o,l=ID(),c=OD(),d=BLe(),h=kd(kd({},e),{},{stroke:(s=e.stroke)!==null&&s!==void 0?s:zv.stroke,fill:(r=e.fill)!==null&&r!==void 0?r:zv.fill,horizontal:(n=e.horizontal)!==null&&n!==void 0?n:zv.horizontal,horizontalFill:(a=e.horizontalFill)!==null&&a!==void 0?a:zv.horizontalFill,vertical:(i=e.vertical)!==null&&i!==void 0?i:zv.vertical,verticalFill:(o=e.verticalFill)!==null&&o!==void 0?o:zv.verticalFill,x:bs(e.x)?e.x:d.left,y:bs(e.y)?e.y:d.top,width:bs(e.width)?e.width:d.width,height:bs(e.height)?e.height:d.height}),p=h.x,g=h.y,v=h.width,b=h.height,y=h.syncWithTicks,w=h.horizontalValues,j=h.verticalValues,x=LLe(),C=$Le();if(!bs(v)||v<=0||!bs(b)||b<=0||!bs(p)||p!==+p||!bs(g)||g!==+g)return null;var k=h.verticalCoordinatesGenerator||Z$e,S=h.horizontalCoordinatesGenerator||J$e,_=h.horizontalPoints,A=h.verticalPoints;if((!_||!_.length)&&Qr(S)){var T=w&&w.length,M=S({yAxis:C?kd(kd({},C),{},{ticks:T?w:C.ticks}):void 0,width:l,height:c,offset:d},T?!0:y);yh(Array.isArray(M),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(nv(M),"]")),Array.isArray(M)&&(_=M)}if((!A||!A.length)&&Qr(k)){var R=j&&j.length,D=k({xAxis:x?kd(kd({},x),{},{ticks:R?j:x.ticks}):void 0,width:l,height:c,offset:d},R?!0:y);yh(Array.isArray(D),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(nv(D),"]")),Array.isArray(D)&&(A=D)}return Ne.createElement("g",{className:"recharts-cartesian-grid"},Ne.createElement(K$e,{fill:h.fill,fillOpacity:h.fillOpacity,x:h.x,y:h.y,width:h.width,height:h.height,ry:h.ry}),Ne.createElement(G$e,Tx({},h,{offset:d,horizontalPoints:_,xAxis:x,yAxis:C})),Ne.createElement(Y$e,Tx({},h,{offset:d,verticalPoints:A,xAxis:x,yAxis:C})),Ne.createElement(Q$e,Tx({},h,{horizontalPoints:_})),Ne.createElement(X$e,Tx({},h,{verticalPoints:A})))}BD.displayName="CartesianGrid";var e6e=["layout","type","stroke","connectNulls","isRange","ref"],t6e=["key"],eae;function mb(e){"@babel/helpers - typeof";return mb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},mb(e)}function tae(e,s){if(e==null)return{};var r=s6e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function s6e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Ax(){return Ax=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Ax.apply(this,arguments)}function Lq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ag(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Lq(Object(r),!0).forEach(function(n){Jh(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Lq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function r6e(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function $q(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,rae(n.key),n)}}function n6e(e,s,r){return s&&$q(e.prototype,s),r&&$q(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function a6e(e,s,r){return s=mk(s),i6e(e,sae()?Reflect.construct(s,r||[],mk(e).constructor):s.apply(e,r))}function i6e(e,s){if(s&&(mb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return o6e(e)}function o6e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function sae(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(sae=function(){return!!e})()}function mk(e){return mk=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},mk(e)}function l6e(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&BR(e,s)}function BR(e,s){return BR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},BR(e,s)}function Jh(e,s,r){return s=rae(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function rae(e){var s=c6e(e,"string");return mb(s)=="symbol"?s:s+""}function c6e(e,s){if(mb(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(mb(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Hg=(function(e){function s(){var r;r6e(this,s);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return r=a6e(this,s,[].concat(a)),Jh(r,"state",{isAnimationFinished:!0}),Jh(r,"id",Fb("recharts-area-")),Jh(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),Qr(o)&&o()}),Jh(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),Qr(o)&&o()}),r}return l6e(s,e),n6e(s,[{key:"renderDots",value:function(n,a,i){var o=this.props.isAnimationActive,l=this.state.isAnimationFinished;if(o&&!l)return null;var c=this.props,d=c.dot,h=c.points,p=c.dataKey,g=Mr(this.props,!1),v=Mr(d,!0),b=h.map(function(w,j){var x=ag(ag(ag({key:"dot-".concat(j),r:3},g),v),{},{index:j,cx:w.x,cy:w.y,dataKey:p,value:w.value,payload:w.payload,points:h});return s.renderDotItem(d,x)}),y={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(i,")"):null};return Ne.createElement(wa,Ax({className:"recharts-area-dots"},y),b)}},{key:"renderHorizontalRect",value:function(n){var a=this.props,i=a.baseLine,o=a.points,l=a.strokeWidth,c=o[0].x,d=o[o.length-1].x,h=n*Math.abs(c-d),p=gg(o.map(function(g){return g.y||0}));return bs(i)&&typeof i=="number"?p=Math.max(i,p):i&&Array.isArray(i)&&i.length&&(p=Math.max(gg(i.map(function(g){return g.y||0})),p)),bs(p)?Ne.createElement("rect",{x:c<d?c:c-h,y:0,width:h,height:Math.floor(p+(l?parseInt("".concat(l),10):1))}):null}},{key:"renderVerticalRect",value:function(n){var a=this.props,i=a.baseLine,o=a.points,l=a.strokeWidth,c=o[0].y,d=o[o.length-1].y,h=n*Math.abs(c-d),p=gg(o.map(function(g){return g.x||0}));return bs(i)&&typeof i=="number"?p=Math.max(i,p):i&&Array.isArray(i)&&i.length&&(p=Math.max(gg(i.map(function(g){return g.x||0})),p)),bs(p)?Ne.createElement("rect",{x:0,y:c<d?c:c-h,width:p+(l?parseInt("".concat(l),10):1),height:Math.floor(h)}):null}},{key:"renderClipRect",value:function(n){var a=this.props.layout;return a==="vertical"?this.renderVerticalRect(n):this.renderHorizontalRect(n)}},{key:"renderAreaStatically",value:function(n,a,i,o){var l=this.props,c=l.layout,d=l.type,h=l.stroke,p=l.connectNulls,g=l.isRange;l.ref;var v=tae(l,e6e);return Ne.createElement(wa,{clipPath:i?"url(#clipPath-".concat(o,")"):null},Ne.createElement(yy,Ax({},Mr(v,!0),{points:n,connectNulls:p,type:d,baseLine:a,layout:c,stroke:"none",className:"recharts-area-area"})),h!=="none"&&Ne.createElement(yy,Ax({},Mr(this.props,!1),{className:"recharts-area-curve",layout:c,type:d,connectNulls:p,fill:"none",points:n})),h!=="none"&&g&&Ne.createElement(yy,Ax({},Mr(this.props,!1),{className:"recharts-area-curve",layout:c,type:d,connectNulls:p,fill:"none",points:a})))}},{key:"renderAreaWithAnimation",value:function(n,a){var i=this,o=this.props,l=o.points,c=o.baseLine,d=o.isAnimationActive,h=o.animationBegin,p=o.animationDuration,g=o.animationEasing,v=o.animationId,b=this.state,y=b.prevPoints,w=b.prevBaseLine;return Ne.createElement(hp,{begin:h,duration:p,isActive:d,easing:g,from:{t:0},to:{t:1},key:"area-".concat(v),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(j){var x=j.t;if(y){var C=y.length/l.length,k=l.map(function(T,M){var R=Math.floor(M*C);if(y[R]){var D=y[R],$=gu(D.x,T.x),O=gu(D.y,T.y);return ag(ag({},T),{},{x:$(x),y:O(x)})}return T}),S;if(bs(c)&&typeof c=="number"){var _=gu(w,c);S=_(x)}else if(Tn(c)||$b(c)){var A=gu(w,0);S=A(x)}else S=c.map(function(T,M){var R=Math.floor(M*C);if(w[R]){var D=w[R],$=gu(D.x,T.x),O=gu(D.y,T.y);return ag(ag({},T),{},{x:$(x),y:O(x)})}return T});return i.renderAreaStatically(k,S,n,a)}return Ne.createElement(wa,null,Ne.createElement("defs",null,Ne.createElement("clipPath",{id:"animationClipPath-".concat(a)},i.renderClipRect(x))),Ne.createElement(wa,{clipPath:"url(#animationClipPath-".concat(a,")")},i.renderAreaStatically(l,c,n,a)))})}},{key:"renderArea",value:function(n,a){var i=this.props,o=i.points,l=i.baseLine,c=i.isAnimationActive,d=this.state,h=d.prevPoints,p=d.prevBaseLine,g=d.totalLength;return c&&o&&o.length&&(!h&&g>0||!Jy(h,o)||!Jy(p,l))?this.renderAreaWithAnimation(n,a):this.renderAreaStatically(o,l,n,a)}},{key:"render",value:function(){var n,a=this.props,i=a.hide,o=a.dot,l=a.points,c=a.className,d=a.top,h=a.left,p=a.xAxis,g=a.yAxis,v=a.width,b=a.height,y=a.isAnimationActive,w=a.id;if(i||!l||!l.length)return null;var j=this.state.isAnimationFinished,x=l.length===1,C=An("recharts-area",c),k=p&&p.allowDataOverflow,S=g&&g.allowDataOverflow,_=k||S,A=Tn(w)?this.id:w,T=(n=Mr(o,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},M=T.r,R=M===void 0?3:M,D=T.strokeWidth,$=D===void 0?2:D,O=W_e(o)?o:{},q=O.clipDot,V=q===void 0?!0:q,K=R*2+$;return Ne.createElement(wa,{className:C},k||S?Ne.createElement("defs",null,Ne.createElement("clipPath",{id:"clipPath-".concat(A)},Ne.createElement("rect",{x:k?h:h-v/2,y:S?d:d-b/2,width:k?v:v*2,height:S?b:b*2})),!V&&Ne.createElement("clipPath",{id:"clipPath-dots-".concat(A)},Ne.createElement("rect",{x:h-K/2,y:d-K/2,width:v+K,height:b+K}))):null,x?null:this.renderArea(_,A),(o||x)&&this.renderDots(_,V,A),(!y||j)&&df.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,curBaseLine:n.baseLine,prevPoints:a.curPoints,prevBaseLine:a.curBaseLine}:n.points!==a.curPoints||n.baseLine!==a.curBaseLine?{curPoints:n.points,curBaseLine:n.baseLine}:null}}])})(u.PureComponent);eae=Hg;Jh(Hg,"displayName","Area");Jh(Hg,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!hv.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});Jh(Hg,"getBaseValue",function(e,s,r,n){var a=e.layout,i=e.baseValue,o=s.props.baseValue,l=o??i;if(bs(l)&&typeof l=="number")return l;var c=a==="horizontal"?n:r,d=c.scale.domain();if(c.type==="number"){var h=Math.max(d[0],d[1]),p=Math.min(d[0],d[1]);return l==="dataMin"?p:l==="dataMax"||h<0?h:Math.max(Math.min(d[0],d[1]),0)}return l==="dataMin"?d[0]:l==="dataMax"?d[1]:d[0]});Jh(Hg,"getComposedData",function(e){var s=e.props,r=e.item,n=e.xAxis,a=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,l=e.bandSize,c=e.dataKey,d=e.stackedData,h=e.dataStartIndex,p=e.displayedData,g=e.offset,v=s.layout,b=d&&d.length,y=eae.getBaseValue(s,r,n,a),w=v==="horizontal",j=!1,x=p.map(function(k,S){var _;b?_=d[h+S]:(_=Wl(k,c),Array.isArray(_)?j=!0:_=[y,_]);var A=_[1]==null||b&&Wl(k,c)==null;return w?{x:UH({axis:n,ticks:i,bandSize:l,entry:k,index:S}),y:A?null:a.scale(_[1]),value:_,payload:k}:{x:A?null:n.scale(_[1]),y:UH({axis:a,ticks:o,bandSize:l,entry:k,index:S}),value:_,payload:k}}),C;return b||j?C=x.map(function(k){var S=Array.isArray(k.value)?k.value[0]:null;return w?{x:k.x,y:S!=null&&k.y!=null?a.scale(S):null}:{x:S!=null?n.scale(S):null,y:k.y}}):C=w?a.scale(y):n.scale(y),ag({points:x,baseLine:C,layout:v,isRange:j},g)});Jh(Hg,"renderDotItem",function(e,s){var r;if(Ne.isValidElement(e))r=Ne.cloneElement(e,s);else if(Qr(e))r=e(s);else{var n=An("recharts-area-dot",typeof e!="boolean"?e.className:""),a=s.key,i=tae(s,t6e);r=Ne.createElement(G_,Ax({},i,{key:a,className:n}))}return r});function hb(e){"@babel/helpers - typeof";return hb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},hb(e)}function d6e(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function u6e(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,iae(n.key),n)}}function m6e(e,s,r){return s&&u6e(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function h6e(e,s,r){return s=hk(s),p6e(e,nae()?Reflect.construct(s,r||[],hk(e).constructor):s.apply(e,r))}function p6e(e,s){if(s&&(hb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return f6e(e)}function f6e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function nae(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(nae=function(){return!!e})()}function hk(e){return hk=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},hk(e)}function g6e(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&UR(e,s)}function UR(e,s){return UR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},UR(e,s)}function aae(e,s,r){return s=iae(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function iae(e){var s=x6e(e,"string");return hb(s)=="symbol"?s:s+""}function x6e(e,s){if(hb(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(hb(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function zR(){return zR=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},zR.apply(this,arguments)}function v6e(e){var s=e.xAxisId,r=ID(),n=OD(),a=zne(s);return a==null?null:Ne.createElement(qb,zR({},a,{className:An("recharts-".concat(a.axisType," ").concat(a.axisType),a.className),viewBox:{x:0,y:0,width:r,height:n},ticksGenerator:function(o){return ef(o,!0)}}))}var Vb=(function(e){function s(){return d6e(this,s),h6e(this,s,arguments)}return g6e(s,e),m6e(s,[{key:"render",value:function(){return Ne.createElement(v6e,this.props)}}])})(Ne.Component);aae(Vb,"displayName","XAxis");aae(Vb,"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 pb(e){"@babel/helpers - typeof";return pb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},pb(e)}function y6e(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function b6e(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,cae(n.key),n)}}function w6e(e,s,r){return s&&b6e(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function j6e(e,s,r){return s=pk(s),N6e(e,oae()?Reflect.construct(s,r||[],pk(e).constructor):s.apply(e,r))}function N6e(e,s){if(s&&(pb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return S6e(e)}function S6e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function oae(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(oae=function(){return!!e})()}function pk(e){return pk=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},pk(e)}function C6e(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&HR(e,s)}function HR(e,s){return HR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},HR(e,s)}function lae(e,s,r){return s=cae(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function cae(e){var s=k6e(e,"string");return pb(s)=="symbol"?s:s+""}function k6e(e,s){if(pb(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(pb(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function qR(){return qR=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},qR.apply(this,arguments)}var _6e=function(s){var r=s.yAxisId,n=ID(),a=OD(),i=Hne(r);return i==null?null:Ne.createElement(qb,qR({},i,{className:An("recharts-".concat(i.axisType," ").concat(i.axisType),i.className),viewBox:{x:0,y:0,width:n,height:a},ticksGenerator:function(l){return ef(l,!0)}}))},Wb=(function(e){function s(){return y6e(this,s),j6e(this,s,arguments)}return C6e(s,e),w6e(s,[{key:"render",value:function(){return Ne.createElement(_6e,this.props)}}])})(Ne.Component);lae(Wb,"displayName","YAxis");lae(Wb,"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 Fq(e){return A6e(e)||T6e(e)||E6e(e)||P6e()}function P6e(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
554In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function E6e(e,s){if(e){if(typeof e=="string")return VR(e,s);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 VR(e,s)}}function T6e(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function A6e(e){if(Array.isArray(e))return VR(e)}function VR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}var WR=function(s,r,n,a,i){var o=Rm(s,LD),l=Rm(s,r2),c=[].concat(Fq(o),Fq(l)),d=Rm(s,a2),h="".concat(a,"Id"),p=a[0],g=r;if(c.length&&(g=c.reduce(function(y,w){if(w.props[h]===n&&np(w.props,"extendDomain")&&bs(w.props[p])){var j=w.props[p];return[Math.min(y[0],j),Math.max(y[1],j)]}return y},g)),d.length){var v="".concat(p,"1"),b="".concat(p,"2");g=d.reduce(function(y,w){if(w.props[h]===n&&np(w.props,"extendDomain")&&bs(w.props[v])&&bs(w.props[b])){var j=w.props[v],x=w.props[b];return[Math.min(y[0],j,x),Math.max(y[1],j,x)]}return y},g)}return i&&i.length&&(g=i.reduce(function(y,w){return bs(w)?[Math.min(y[0],w),Math.max(y[1],w)]:y},g)),g},L4={exports:{}},Bq;function M6e(){return Bq||(Bq=1,(function(e){var s=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function a(c,d,h){this.fn=c,this.context=d,this.once=h||!1}function i(c,d,h,p,g){if(typeof h!="function")throw new TypeError("The listener must be a function");var v=new a(h,p||c,g),b=r?r+d:d;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],v]:c._events[b].push(v):(c._events[b]=v,c._eventsCount++),c}function o(c,d){--c._eventsCount===0?c._events=new n:delete c._events[d]}function l(){this._events=new n,this._eventsCount=0}l.prototype.eventNames=function(){var d=[],h,p;if(this._eventsCount===0)return d;for(p in h=this._events)s.call(h,p)&&d.push(r?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(h)):d},l.prototype.listeners=function(d){var h=r?r+d:d,p=this._events[h];if(!p)return[];if(p.fn)return[p.fn];for(var g=0,v=p.length,b=new Array(v);g<v;g++)b[g]=p[g].fn;return b},l.prototype.listenerCount=function(d){var h=r?r+d:d,p=this._events[h];return p?p.fn?1:p.length:0},l.prototype.emit=function(d,h,p,g,v,b){var y=r?r+d:d;if(!this._events[y])return!1;var w=this._events[y],j=arguments.length,x,C;if(w.fn){switch(w.once&&this.removeListener(d,w.fn,void 0,!0),j){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,h),!0;case 3:return w.fn.call(w.context,h,p),!0;case 4:return w.fn.call(w.context,h,p,g),!0;case 5:return w.fn.call(w.context,h,p,g,v),!0;case 6:return w.fn.call(w.context,h,p,g,v,b),!0}for(C=1,x=new Array(j-1);C<j;C++)x[C-1]=arguments[C];w.fn.apply(w.context,x)}else{var k=w.length,S;for(C=0;C<k;C++)switch(w[C].once&&this.removeListener(d,w[C].fn,void 0,!0),j){case 1:w[C].fn.call(w[C].context);break;case 2:w[C].fn.call(w[C].context,h);break;case 3:w[C].fn.call(w[C].context,h,p);break;case 4:w[C].fn.call(w[C].context,h,p,g);break;default:if(!x)for(S=1,x=new Array(j-1);S<j;S++)x[S-1]=arguments[S];w[C].fn.apply(w[C].context,x)}}return!0},l.prototype.on=function(d,h,p){return i(this,d,h,p,!1)},l.prototype.once=function(d,h,p){return i(this,d,h,p,!0)},l.prototype.removeListener=function(d,h,p,g){var v=r?r+d:d;if(!this._events[v])return this;if(!h)return o(this,v),this;var b=this._events[v];if(b.fn)b.fn===h&&(!g||b.once)&&(!p||b.context===p)&&o(this,v);else{for(var y=0,w=[],j=b.length;y<j;y++)(b[y].fn!==h||g&&!b[y].once||p&&b[y].context!==p)&&w.push(b[y]);w.length?this._events[v]=w.length===1?w[0]:w:o(this,v)}return this},l.prototype.removeAllListeners=function(d){var h;return d?(h=r?r+d:d,this._events[h]&&o(this,h)):(this._events=new n,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})(L4)),L4.exports}var R6e=M6e();const I6e=ei(R6e);var $4=new I6e,F4="recharts.syncMouseEvents";function Rj(e){"@babel/helpers - typeof";return Rj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Rj(e)}function O6e(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function D6e(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,dae(n.key),n)}}function L6e(e,s,r){return s&&D6e(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function B4(e,s,r){return s=dae(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function dae(e){var s=$6e(e,"string");return Rj(s)=="symbol"?s:s+""}function $6e(e,s){if(Rj(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Rj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var F6e=(function(){function e(){O6e(this,e),B4(this,"activeIndex",0),B4(this,"coordinateList",[]),B4(this,"layout","horizontal")}return L6e(e,[{key:"setDetails",value:function(r){var n,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,h=r.offset,p=h===void 0?null:h,g=r.mouseHandlerCallback,v=g===void 0?null:g;this.coordinateList=(n=i??this.coordinateList)!==null&&n!==void 0?n:[],this.container=l??this.container,this.layout=d??this.layout,this.offset=p??this.offset,this.mouseHandlerCallback=v??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,n;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,h=((n=window)===null||n===void 0?void 0:n.scrollY)||0,p=i+c+d,g=o+this.offset.top+l/2+h;this.mouseHandlerCallback({pageX:p,pageY:g})}}}])})();function B6e(e,s,r){if(r==="number"&&s===!0&&Array.isArray(e)){var n=e?.[0],a=e?.[1];if(n&&a&&bs(n)&&bs(a))return!0}return!1}function U6e(e,s,r,n){var a=n/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?s.x-a:r.left+.5,y:e==="horizontal"?r.top+.5:s.y-a,width:e==="horizontal"?n:r.width-1,height:e==="horizontal"?r.height-1:n}}function uae(e){var s=e.cx,r=e.cy,n=e.radius,a=e.startAngle,i=e.endAngle,o=ki(s,r,n,a),l=ki(s,r,n,i);return{points:[o,l],cx:s,cy:r,radius:n,startAngle:a,endAngle:i}}function z6e(e,s,r){var n,a,i,o;if(e==="horizontal")n=s.x,i=n,a=r.top,o=r.top+r.height;else if(e==="vertical")a=s.y,o=a,n=r.left,i=r.left+r.width;else if(s.cx!=null&&s.cy!=null)if(e==="centric"){var l=s.cx,c=s.cy,d=s.innerRadius,h=s.outerRadius,p=s.angle,g=ki(l,c,d,p),v=ki(l,c,h,p);n=g.x,a=g.y,i=v.x,o=v.y}else return uae(s);return[{x:n,y:a},{x:i,y:o}]}function Ij(e){"@babel/helpers - typeof";return Ij=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Ij(e)}function Uq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function R1(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?Uq(Object(r),!0).forEach(function(n){H6e(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Uq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function H6e(e,s,r){return s=q6e(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function q6e(e){var s=V6e(e,"string");return Ij(s)=="symbol"?s:s+""}function V6e(e,s){if(Ij(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(Ij(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function W6e(e){var s,r,n=e.element,a=e.tooltipEventType,i=e.isActive,o=e.activeCoordinate,l=e.activePayload,c=e.offset,d=e.activeTooltipIndex,h=e.tooltipAxisBandSize,p=e.layout,g=e.chartName,v=(s=n.props.cursor)!==null&&s!==void 0?s:(r=n.type.defaultProps)===null||r===void 0?void 0:r.cursor;if(!n||!v||!i||!o||g!=="ScatterChart"&&a!=="axis")return null;var b,y=yy;if(g==="ScatterChart")b=o,y=v3e;else if(g==="BarChart")b=U6e(p,o,c,h),y=TD;else if(p==="radial"){var w=uae(o),j=w.cx,x=w.cy,C=w.radius,k=w.startAngle,S=w.endAngle;b={cx:j,cy:x,startAngle:k,endAngle:S,innerRadius:C,outerRadius:C},y=dne}else b={points:z6e(p,o,c)},y=yy;var _=R1(R1(R1(R1({stroke:"#ccc",pointerEvents:"none"},c),b),Mr(v,!1)),{},{payload:l,payloadIndex:d,className:An("recharts-tooltip-cursor",v.className)});return u.isValidElement(v)?u.cloneElement(v,_):u.createElement(y,_)}var K6e=["item"],G6e=["children","className","width","height","style","compact","title","desc"];function fb(e){"@babel/helpers - typeof";return fb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},fb(e)}function ty(){return ty=Object.assign?Object.assign.bind():function(e){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ty.apply(this,arguments)}function zq(e,s){return X6e(e)||Q6e(e,s)||hae(e,s)||Y6e()}function Y6e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
555In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Q6e(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,s!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==s);c=!0);}catch(h){d=!0,a=h}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function X6e(e){if(Array.isArray(e))return e}function Hq(e,s){if(e==null)return{};var r=Z6e(e,s),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],!(s.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Z6e(e,s){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(s.indexOf(n)>=0)continue;r[n]=e[n]}return r}function J6e(e,s){if(!(e instanceof s))throw new TypeError("Cannot call a class as a function")}function eFe(e,s){for(var r=0;r<s.length;r++){var n=s[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,pae(n.key),n)}}function tFe(e,s,r){return s&&eFe(e.prototype,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function sFe(e,s,r){return s=fk(s),rFe(e,mae()?Reflect.construct(s,r||[],fk(e).constructor):s.apply(e,r))}function rFe(e,s){if(s&&(fb(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return nFe(e)}function nFe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function mae(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(mae=function(){return!!e})()}function fk(e){return fk=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},fk(e)}function aFe(e,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(s&&s.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),s&&KR(e,s)}function KR(e,s){return KR=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},KR(e,s)}function gb(e){return lFe(e)||oFe(e)||hae(e)||iFe()}function iFe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
556In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hae(e,s){if(e){if(typeof e=="string")return GR(e,s);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 GR(e,s)}}function oFe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function lFe(e){if(Array.isArray(e))return GR(e)}function GR(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,n=new Array(s);r<s;r++)n[r]=e[r];return n}function qq(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ot(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?qq(Object(r),!0).forEach(function(n){Gr(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):qq(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Gr(e,s,r){return s=pae(s),s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function pae(e){var s=cFe(e,"string");return fb(s)=="symbol"?s:s+""}function cFe(e,s){if(fb(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,s);if(fb(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}var dFe={xAxis:["bottom","top"],yAxis:["left","right"]},uFe={width:"100%",height:"100%"},fae={x:0,y:0};function I1(e){return e}var mFe=function(s,r){return r==="horizontal"?s.x:r==="vertical"?s.y:r==="centric"?s.angle:s.radius},hFe=function(s,r,n,a){var i=r.find(function(h){return h&&h.index===n});if(i){if(s==="horizontal")return{x:i.coordinate,y:a.y};if(s==="vertical")return{x:a.x,y:i.coordinate};if(s==="centric"){var o=i.coordinate,l=a.radius;return Ot(Ot(Ot({},a),ki(a.cx,a.cy,l,o)),{},{angle:o,radius:l})}var c=i.coordinate,d=a.angle;return Ot(Ot(Ot({},a),ki(a.cx,a.cy,c,d)),{},{angle:d,radius:c})}return fae},i2=function(s,r){var n=r.graphicalItems,a=r.dataStartIndex,i=r.dataEndIndex,o=(n??[]).reduce(function(l,c){var d=c.props.data;return d&&d.length?[].concat(gb(l),gb(d)):l},[]);return o.length>0?o:s&&s.length&&bs(a)&&bs(i)?s.slice(a,i+1):[]};function gae(e){return e==="number"?[0,"auto"]:void 0}var YR=function(s,r,n,a){var i=s.graphicalItems,o=s.tooltipAxis,l=i2(r,s);return n<0||!i||!i.length||n>=l.length?null:i.reduce(function(c,d){var h,p=(h=d.props.data)!==null&&h!==void 0?h:r;p&&s.dataStartIndex+s.dataEndIndex!==0&&s.dataEndIndex-s.dataStartIndex>=n&&(p=p.slice(s.dataStartIndex,s.dataEndIndex+1));var g;if(o.dataKey&&!o.allowDuplicatedCategory){var v=p===void 0?l:p;g=yC(v,o.dataKey,a)}else g=p&&p[n]||l[n];return g?[].concat(gb(c),[nne(d,g)]):c},[])},Vq=function(s,r,n,a){var i=a||{x:s.chartX,y:s.chartY},o=mFe(i,n),l=s.orderedTooltipTicks,c=s.tooltipAxis,d=s.tooltipTicks,h=HMe(o,l,d,c);if(h>=0&&d){var p=d[h]&&d[h].value,g=YR(s,r,h,p),v=hFe(n,l,h,i);return{activeTooltipIndex:h,activeLabel:p,activePayload:g,activeCoordinate:v}}return null},pFe=function(s,r){var n=r.axes,a=r.graphicalItems,i=r.axisType,o=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,d=r.dataEndIndex,h=s.layout,p=s.children,g=s.stackOffset,v=Zre(h,i);return n.reduce(function(b,y){var w,j=y.type.defaultProps!==void 0?Ot(Ot({},y.type.defaultProps),y.props):y.props,x=j.type,C=j.dataKey,k=j.allowDataOverflow,S=j.allowDuplicatedCategory,_=j.scale,A=j.ticks,T=j.includeHidden,M=j[o];if(b[M])return b;var R=i2(s.data,{graphicalItems:a.filter(function(Y){var oe,he=o in Y.props?Y.props[o]:(oe=Y.type.defaultProps)===null||oe===void 0?void 0:oe[o];return he===M}),dataStartIndex:c,dataEndIndex:d}),D=R.length,$,O,q;B6e(j.domain,k,x)&&($=dR(j.domain,null,k),v&&(x==="number"||_!=="auto")&&(q=f0(R,C,"category")));var V=gae(x);if(!$||$.length===0){var K,G=(K=j.domain)!==null&&K!==void 0?K:V;if(C){if($=f0(R,C,x),x==="category"&&v){var z=L_e($);S&&z?(O=$,$=sk(0,D)):S||($=VH(G,$,y).reduce(function(Y,oe){return Y.indexOf(oe)>=0?Y:[].concat(gb(Y),[oe])},[]))}else if(x==="category")S?$=$.filter(function(Y){return Y!==""&&!Tn(Y)}):$=VH(G,$,y).reduce(function(Y,oe){return Y.indexOf(oe)>=0||oe===""||Tn(oe)?Y:[].concat(gb(Y),[oe])},[]);else if(x==="number"){var Z=GMe(R,a.filter(function(Y){var oe,he,je=o in Y.props?Y.props[o]:(oe=Y.type.defaultProps)===null||oe===void 0?void 0:oe[o],pe="hide"in Y.props?Y.props.hide:(he=Y.type.defaultProps)===null||he===void 0?void 0:he.hide;return je===M&&(T||!pe)}),C,i,h);Z&&($=Z)}v&&(x==="number"||_!=="auto")&&(q=f0(R,C,"category"))}else v?$=sk(0,D):l&&l[M]&&l[M].hasStack&&x==="number"?$=g==="expand"?[0,1]:rne(l[M].stackGroups,c,d):$=Xre(R,a.filter(function(Y){var oe=o in Y.props?Y.props[o]:Y.type.defaultProps[o],he="hide"in Y.props?Y.props.hide:Y.type.defaultProps.hide;return oe===M&&(T||!he)}),x,h,!0);if(x==="number")$=WR(p,$,M,i,A),G&&($=dR(G,$,k));else if(x==="category"&&G){var ee=G,Q=$.every(function(Y){return ee.indexOf(Y)>=0});Q&&($=ee)}}return Ot(Ot({},b),{},Gr({},M,Ot(Ot({},j),{},{axisType:i,domain:$,categoricalDomain:q,duplicateDomain:O,originalDomain:(w=j.domain)!==null&&w!==void 0?w:V,isCategorical:v,layout:h})))},{})},fFe=function(s,r){var n=r.graphicalItems,a=r.Axis,i=r.axisType,o=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,d=r.dataEndIndex,h=s.layout,p=s.children,g=i2(s.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:d}),v=g.length,b=Zre(h,i),y=-1;return n.reduce(function(w,j){var x=j.type.defaultProps!==void 0?Ot(Ot({},j.type.defaultProps),j.props):j.props,C=x[o],k=gae("number");if(!w[C]){y++;var S;return b?S=sk(0,v):l&&l[C]&&l[C].hasStack?(S=rne(l[C].stackGroups,c,d),S=WR(p,S,C,i)):(S=dR(k,Xre(g,n.filter(function(_){var A,T,M=o in _.props?_.props[o]:(A=_.type.defaultProps)===null||A===void 0?void 0:A[o],R="hide"in _.props?_.props.hide:(T=_.type.defaultProps)===null||T===void 0?void 0:T.hide;return M===C&&!R}),"number",h),a.defaultProps.allowDataOverflow),S=WR(p,S,C,i)),Ot(Ot({},w),{},Gr({},C,Ot(Ot({axisType:i},a.defaultProps),{},{hide:!0,orientation:em(dFe,"".concat(i,".").concat(y%2),null),domain:S,originalDomain:k,isCategorical:b,layout:h})))}return w},{})},gFe=function(s,r){var n=r.axisType,a=n===void 0?"xAxis":n,i=r.AxisComp,o=r.graphicalItems,l=r.stackGroups,c=r.dataStartIndex,d=r.dataEndIndex,h=s.children,p="".concat(a,"Id"),g=Rm(h,i),v={};return g&&g.length?v=pFe(s,{axes:g,graphicalItems:o,axisType:a,axisIdKey:p,stackGroups:l,dataStartIndex:c,dataEndIndex:d}):o&&o.length&&(v=fFe(s,{Axis:i,graphicalItems:o,axisType:a,axisIdKey:p,stackGroups:l,dataStartIndex:c,dataEndIndex:d})),v},xFe=function(s){var r=ug(s),n=ef(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:sD(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:qC(r,n)}},Wq=function(s){var r=s.children,n=s.defaultShowTooltip,a=Wu(r,ib),i=0,o=0;return s.data&&s.data.length!==0&&(o=s.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:!!n}},vFe=function(s){return!s||!s.length?!1:s.some(function(r){var n=lf(r&&r.type);return n&&n.indexOf("Bar")>=0})},Kq=function(s){return s==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:s==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:s==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},yFe=function(s,r){var n=s.props,a=s.graphicalItems,i=s.xAxisMap,o=i===void 0?{}:i,l=s.yAxisMap,c=l===void 0?{}:l,d=n.width,h=n.height,p=n.children,g=n.margin||{},v=Wu(p,ib),b=Wu(p,gy),y=Object.keys(c).reduce(function(S,_){var A=c[_],T=A.orientation;return!A.mirror&&!A.hide?Ot(Ot({},S),{},Gr({},T,S[T]+A.width)):S},{left:g.left||0,right:g.right||0}),w=Object.keys(o).reduce(function(S,_){var A=o[_],T=A.orientation;return!A.mirror&&!A.hide?Ot(Ot({},S),{},Gr({},T,em(S,"".concat(T))+A.height)):S},{top:g.top||0,bottom:g.bottom||0}),j=Ot(Ot({},w),y),x=j.bottom;v&&(j.bottom+=v.props.height||ib.defaultProps.height),b&&r&&(j=WMe(j,a,n,r));var C=d-j.left-j.right,k=h-j.top-j.bottom;return Ot(Ot({brushBottom:x},j),{},{width:Math.max(C,0),height:Math.max(k,0)})},bFe=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},UD=function(s){var r=s.chartName,n=s.GraphicalChild,a=s.defaultTooltipEventType,i=a===void 0?"axis":a,o=s.validateTooltipEventTypes,l=o===void 0?["axis"]:o,c=s.axisComponents,d=s.legendContent,h=s.formatAxisMap,p=s.defaultProps,g=function(j,x){var C=x.graphicalItems,k=x.stackGroups,S=x.offset,_=x.updateId,A=x.dataStartIndex,T=x.dataEndIndex,M=j.barSize,R=j.layout,D=j.barGap,$=j.barCategoryGap,O=j.maxBarSize,q=Kq(R),V=q.numericAxisName,K=q.cateAxisName,G=vFe(C),z=[];return C.forEach(function(Z,ee){var Q=i2(j.data,{graphicalItems:[Z],dataStartIndex:A,dataEndIndex:T}),Y=Z.type.defaultProps!==void 0?Ot(Ot({},Z.type.defaultProps),Z.props):Z.props,oe=Y.dataKey,he=Y.maxBarSize,je=Y["".concat(V,"Id")],pe=Y["".concat(K,"Id")],le={},ue=c.reduce(function(Be,J){var ae=x["".concat(J.axisType,"Map")],we=Y["".concat(J.axisType,"Id")];ae&&ae[we]||J.axisType==="zAxis"||rv();var Qe=ae[we];return Ot(Ot({},Be),{},Gr(Gr({},J.axisType,Qe),"".concat(J.axisType,"Ticks"),ef(Qe)))},le),fe=ue[K],H=ue["".concat(K,"Ticks")],se=k&&k[je]&&k[je].hasStack&&rRe(Z,k[je].stackGroups),me=lf(Z.type).indexOf("Bar")>=0,ge=qC(fe,H),be=[],ce=G&&qMe({barSize:M,stackGroups:k,totalSize:bFe(ue,K)});if(me){var Pe,et,$e=Tn(he)?O:he,bt=(Pe=(et=qC(fe,H,!0))!==null&&et!==void 0?et:$e)!==null&&Pe!==void 0?Pe:0;be=VMe({barGap:D,barCategoryGap:$,bandSize:bt!==ge?bt:ge,sizeList:ce[pe],maxBarSize:$e}),bt!==ge&&(be=be.map(function(Be){return Ot(Ot({},Be),{},{position:Ot(Ot({},Be.position),{},{offset:Be.position.offset-bt/2})})}))}var Ae=Z&&Z.type&&Z.type.getComposedData;Ae&&z.push({props:Ot(Ot({},Ae(Ot(Ot({},ue),{},{displayedData:Q,props:j,dataKey:oe,item:Z,bandSize:ge,barPosition:be,offset:S,stackedData:se,layout:R,dataStartIndex:A,dataEndIndex:T}))),{},Gr(Gr(Gr({key:Z.key||"item-".concat(ee)},V,ue[V]),K,ue[K]),"animationId",_)),childIndex:Y_e(Z,j.children),item:Z})}),z},v=function(j,x){var C=j.props,k=j.dataStartIndex,S=j.dataEndIndex,_=j.updateId;if(!a8({props:C}))return null;var A=C.children,T=C.layout,M=C.stackOffset,R=C.data,D=C.reverseStackOrder,$=Kq(T),O=$.numericAxisName,q=$.cateAxisName,V=Rm(A,n),K=tRe(R,V,"".concat(O,"Id"),"".concat(q,"Id"),M,D),G=c.reduce(function(Y,oe){var he="".concat(oe.axisType,"Map");return Ot(Ot({},Y),{},Gr({},he,gFe(C,Ot(Ot({},oe),{},{graphicalItems:V,stackGroups:oe.axisType===O&&K,dataStartIndex:k,dataEndIndex:S}))))},{}),z=yFe(Ot(Ot({},G),{},{props:C,graphicalItems:V}),x?.legendBBox);Object.keys(G).forEach(function(Y){G[Y]=h(C,G[Y],z,Y.replace("Map",""),r)});var Z=G["".concat(q,"Map")],ee=xFe(Z),Q=g(C,Ot(Ot({},G),{},{dataStartIndex:k,dataEndIndex:S,updateId:_,graphicalItems:V,stackGroups:K,offset:z}));return Ot(Ot({formattedGraphicalItems:Q,graphicalItems:V,offset:z,stackGroups:K},ee),G)},b=(function(w){function j(x){var C,k,S;return J6e(this,j),S=sFe(this,j,[x]),Gr(S,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),Gr(S,"accessibilityManager",new F6e),Gr(S,"handleLegendBBoxUpdate",function(_){if(_){var A=S.state,T=A.dataStartIndex,M=A.dataEndIndex,R=A.updateId;S.setState(Ot({legendBBox:_},v({props:S.props,dataStartIndex:T,dataEndIndex:M,updateId:R},Ot(Ot({},S.state),{},{legendBBox:_}))))}}),Gr(S,"handleReceiveSyncEvent",function(_,A,T){if(S.props.syncId===_){if(T===S.eventEmitterSymbol&&typeof S.props.syncMethod!="function")return;S.applySyncEvent(A)}}),Gr(S,"handleBrushChange",function(_){var A=_.startIndex,T=_.endIndex;if(A!==S.state.dataStartIndex||T!==S.state.dataEndIndex){var M=S.state.updateId;S.setState(function(){return Ot({dataStartIndex:A,dataEndIndex:T},v({props:S.props,dataStartIndex:A,dataEndIndex:T,updateId:M},S.state))}),S.triggerSyncEvent({dataStartIndex:A,dataEndIndex:T})}}),Gr(S,"handleMouseEnter",function(_){var A=S.getMouseInfo(_);if(A){var T=Ot(Ot({},A),{},{isTooltipActive:!0});S.setState(T),S.triggerSyncEvent(T);var M=S.props.onMouseEnter;Qr(M)&&M(T,_)}}),Gr(S,"triggeredAfterMouseMove",function(_){var A=S.getMouseInfo(_),T=A?Ot(Ot({},A),{},{isTooltipActive:!0}):{isTooltipActive:!1};S.setState(T),S.triggerSyncEvent(T);var M=S.props.onMouseMove;Qr(M)&&M(T,_)}),Gr(S,"handleItemMouseEnter",function(_){S.setState(function(){return{isTooltipActive:!0,activeItem:_,activePayload:_.tooltipPayload,activeCoordinate:_.tooltipPosition||{x:_.cx,y:_.cy}}})}),Gr(S,"handleItemMouseLeave",function(){S.setState(function(){return{isTooltipActive:!1}})}),Gr(S,"handleMouseMove",function(_){_.persist(),S.throttleTriggeredAfterMouseMove(_)}),Gr(S,"handleMouseLeave",function(_){S.throttleTriggeredAfterMouseMove.cancel();var A={isTooltipActive:!1};S.setState(A),S.triggerSyncEvent(A);var T=S.props.onMouseLeave;Qr(T)&&T(A,_)}),Gr(S,"handleOuterEvent",function(_){var A=G_e(_),T=em(S.props,"".concat(A));if(A&&Qr(T)){var M,R;/.*touch.*/i.test(A)?R=S.getMouseInfo(_.changedTouches[0]):R=S.getMouseInfo(_),T((M=R)!==null&&M!==void 0?M:{},_)}}),Gr(S,"handleClick",function(_){var A=S.getMouseInfo(_);if(A){var T=Ot(Ot({},A),{},{isTooltipActive:!0});S.setState(T),S.triggerSyncEvent(T);var M=S.props.onClick;Qr(M)&&M(T,_)}}),Gr(S,"handleMouseDown",function(_){var A=S.props.onMouseDown;if(Qr(A)){var T=S.getMouseInfo(_);A(T,_)}}),Gr(S,"handleMouseUp",function(_){var A=S.props.onMouseUp;if(Qr(A)){var T=S.getMouseInfo(_);A(T,_)}}),Gr(S,"handleTouchMove",function(_){_.changedTouches!=null&&_.changedTouches.length>0&&S.throttleTriggeredAfterMouseMove(_.changedTouches[0])}),Gr(S,"handleTouchStart",function(_){_.changedTouches!=null&&_.changedTouches.length>0&&S.handleMouseDown(_.changedTouches[0])}),Gr(S,"handleTouchEnd",function(_){_.changedTouches!=null&&_.changedTouches.length>0&&S.handleMouseUp(_.changedTouches[0])}),Gr(S,"handleDoubleClick",function(_){var A=S.props.onDoubleClick;if(Qr(A)){var T=S.getMouseInfo(_);A(T,_)}}),Gr(S,"handleContextMenu",function(_){var A=S.props.onContextMenu;if(Qr(A)){var T=S.getMouseInfo(_);A(T,_)}}),Gr(S,"triggerSyncEvent",function(_){S.props.syncId!==void 0&&$4.emit(F4,S.props.syncId,_,S.eventEmitterSymbol)}),Gr(S,"applySyncEvent",function(_){var A=S.props,T=A.layout,M=A.syncMethod,R=S.state.updateId,D=_.dataStartIndex,$=_.dataEndIndex;if(_.dataStartIndex!==void 0||_.dataEndIndex!==void 0)S.setState(Ot({dataStartIndex:D,dataEndIndex:$},v({props:S.props,dataStartIndex:D,dataEndIndex:$,updateId:R},S.state)));else if(_.activeTooltipIndex!==void 0){var O=_.chartX,q=_.chartY,V=_.activeTooltipIndex,K=S.state,G=K.offset,z=K.tooltipTicks;if(!G)return;if(typeof M=="function")V=M(z,_);else if(M==="value"){V=-1;for(var Z=0;Z<z.length;Z++)if(z[Z].value===_.activeLabel){V=Z;break}}var ee=Ot(Ot({},G),{},{x:G.left,y:G.top}),Q=Math.min(O,ee.x+ee.width),Y=Math.min(q,ee.y+ee.height),oe=z[V]&&z[V].value,he=YR(S.state,S.props.data,V),je=z[V]?{x:T==="horizontal"?z[V].coordinate:Q,y:T==="horizontal"?Y:z[V].coordinate}:fae;S.setState(Ot(Ot({},_),{},{activeLabel:oe,activeCoordinate:je,activePayload:he,activeTooltipIndex:V}))}else S.setState(_)}),Gr(S,"renderCursor",function(_){var A,T=S.state,M=T.isTooltipActive,R=T.activeCoordinate,D=T.activePayload,$=T.offset,O=T.activeTooltipIndex,q=T.tooltipAxisBandSize,V=S.getTooltipEventType(),K=(A=_.props.active)!==null&&A!==void 0?A:M,G=S.props.layout,z=_.key||"_recharts-cursor";return Ne.createElement(W6e,{key:z,activeCoordinate:R,activePayload:D,activeTooltipIndex:O,chartName:r,element:_,isActive:K,layout:G,offset:$,tooltipAxisBandSize:q,tooltipEventType:V})}),Gr(S,"renderPolarAxis",function(_,A,T){var M=em(_,"type.axisType"),R=em(S.state,"".concat(M,"Map")),D=_.type.defaultProps,$=D!==void 0?Ot(Ot({},D),_.props):_.props,O=R&&R[$["".concat(M,"Id")]];return u.cloneElement(_,Ot(Ot({},O),{},{className:An(M,O.className),key:_.key||"".concat(A,"-").concat(T),ticks:ef(O,!0)}))}),Gr(S,"renderPolarGrid",function(_){var A=_.props,T=A.radialLines,M=A.polarAngles,R=A.polarRadius,D=S.state,$=D.radiusAxisMap,O=D.angleAxisMap,q=ug($),V=ug(O),K=V.cx,G=V.cy,z=V.innerRadius,Z=V.outerRadius;return u.cloneElement(_,{polarAngles:Array.isArray(M)?M:ef(V,!0).map(function(ee){return ee.coordinate}),polarRadius:Array.isArray(R)?R:ef(q,!0).map(function(ee){return ee.coordinate}),cx:K,cy:G,innerRadius:z,outerRadius:Z,key:_.key||"polar-grid",radialLines:T})}),Gr(S,"renderLegend",function(){var _=S.state.formattedGraphicalItems,A=S.props,T=A.children,M=A.width,R=A.height,D=S.props.margin||{},$=M-(D.left||0)-(D.right||0),O=Yre({children:T,formattedGraphicalItems:_,legendWidth:$,legendContent:d});if(!O)return null;var q=O.item,V=Hq(O,K6e);return u.cloneElement(q,Ot(Ot({},V),{},{chartWidth:M,chartHeight:R,margin:D,onBBoxUpdate:S.handleLegendBBoxUpdate}))}),Gr(S,"renderTooltip",function(){var _,A=S.props,T=A.children,M=A.accessibilityLayer,R=Wu(T,uh);if(!R)return null;var D=S.state,$=D.isTooltipActive,O=D.activeCoordinate,q=D.activePayload,V=D.activeLabel,K=D.offset,G=(_=R.props.active)!==null&&_!==void 0?_:$;return u.cloneElement(R,{viewBox:Ot(Ot({},K),{},{x:K.left,y:K.top}),active:G,label:V,payload:G?q:[],coordinate:O,accessibilityLayer:M})}),Gr(S,"renderBrush",function(_){var A=S.props,T=A.margin,M=A.data,R=S.state,D=R.offset,$=R.dataStartIndex,O=R.dataEndIndex,q=R.updateId;return u.cloneElement(_,{key:_.key||"_recharts-brush",onChange:E1(S.handleBrushChange,_.props.onChange),data:M,x:bs(_.props.x)?_.props.x:D.left,y:bs(_.props.y)?_.props.y:D.top+D.height+D.brushBottom-(T.bottom||0),width:bs(_.props.width)?_.props.width:D.width,startIndex:$,endIndex:O,updateId:"brush-".concat(q)})}),Gr(S,"renderReferenceElement",function(_,A,T){if(!_)return null;var M=S,R=M.clipPathId,D=S.state,$=D.xAxisMap,O=D.yAxisMap,q=D.offset,V=_.type.defaultProps||{},K=_.props,G=K.xAxisId,z=G===void 0?V.xAxisId:G,Z=K.yAxisId,ee=Z===void 0?V.yAxisId:Z;return u.cloneElement(_,{key:_.key||"".concat(A,"-").concat(T),xAxis:$[z],yAxis:O[ee],viewBox:{x:q.left,y:q.top,width:q.width,height:q.height},clipPathId:R})}),Gr(S,"renderActivePoints",function(_){var A=_.item,T=_.activePoint,M=_.basePoint,R=_.childIndex,D=_.isRange,$=[],O=A.props.key,q=A.item.type.defaultProps!==void 0?Ot(Ot({},A.item.type.defaultProps),A.item.props):A.item.props,V=q.activeDot,K=q.dataKey,G=Ot(Ot({index:R,dataKey:K,cx:T.x,cy:T.y,r:4,fill:ED(A.item),strokeWidth:2,stroke:"#fff",payload:T.payload,value:T.value},Mr(V,!1)),bC(V));return $.push(j.renderActiveDot(V,G,"".concat(O,"-activePoint-").concat(R))),M?$.push(j.renderActiveDot(V,Ot(Ot({},G),{},{cx:M.x,cy:M.y}),"".concat(O,"-basePoint-").concat(R))):D&&$.push(null),$}),Gr(S,"renderGraphicChild",function(_,A,T){var M=S.filterFormatItem(_,A,T);if(!M)return null;var R=S.getTooltipEventType(),D=S.state,$=D.isTooltipActive,O=D.tooltipAxis,q=D.activeTooltipIndex,V=D.activeLabel,K=S.props.children,G=Wu(K,uh),z=M.props,Z=z.points,ee=z.isRange,Q=z.baseLine,Y=M.item.type.defaultProps!==void 0?Ot(Ot({},M.item.type.defaultProps),M.item.props):M.item.props,oe=Y.activeDot,he=Y.hide,je=Y.activeBar,pe=Y.activeShape,le=!!(!he&&$&&G&&(oe||je||pe)),ue={};R!=="axis"&&G&&G.props.trigger==="click"?ue={onClick:E1(S.handleItemMouseEnter,_.props.onClick)}:R!=="axis"&&(ue={onMouseLeave:E1(S.handleItemMouseLeave,_.props.onMouseLeave),onMouseEnter:E1(S.handleItemMouseEnter,_.props.onMouseEnter)});var fe=u.cloneElement(_,Ot(Ot({},M.props),ue));function H(J){return typeof O.dataKey=="function"?O.dataKey(J.payload):null}if(le)if(q>=0){var se,me;if(O.dataKey&&!O.allowDuplicatedCategory){var ge=typeof O.dataKey=="function"?H:"payload.".concat(O.dataKey.toString());se=yC(Z,ge,V),me=ee&&Q&&yC(Q,ge,V)}else se=Z?.[q],me=ee&&Q&&Q[q];if(pe||je){var be=_.props.activeIndex!==void 0?_.props.activeIndex:q;return[u.cloneElement(_,Ot(Ot(Ot({},M.props),ue),{},{activeIndex:be})),null,null]}if(!Tn(se))return[fe].concat(gb(S.renderActivePoints({item:M,activePoint:se,basePoint:me,childIndex:q,isRange:ee})))}else{var ce,Pe=(ce=S.getItemByXY(S.state.activeCoordinate))!==null&&ce!==void 0?ce:{graphicalItem:fe},et=Pe.graphicalItem,$e=et.item,bt=$e===void 0?_:$e,Ae=et.childIndex,Be=Ot(Ot(Ot({},M.props),ue),{},{activeIndex:Ae});return[u.cloneElement(bt,Be),null,null]}return ee?[fe,null,null]:[fe,null]}),Gr(S,"renderCustomized",function(_,A,T){return u.cloneElement(_,Ot(Ot({key:"recharts-customized-".concat(T)},S.props),S.state))}),Gr(S,"renderMap",{CartesianGrid:{handler:I1,once:!0},ReferenceArea:{handler:S.renderReferenceElement},ReferenceLine:{handler:I1},ReferenceDot:{handler:S.renderReferenceElement},XAxis:{handler:I1},YAxis:{handler:I1},Brush:{handler:S.renderBrush,once:!0},Bar:{handler:S.renderGraphicChild},Line:{handler:S.renderGraphicChild},Area:{handler:S.renderGraphicChild},Radar:{handler:S.renderGraphicChild},RadialBar:{handler:S.renderGraphicChild},Scatter:{handler:S.renderGraphicChild},Pie:{handler:S.renderGraphicChild},Funnel:{handler:S.renderGraphicChild},Tooltip:{handler:S.renderCursor,once:!0},PolarGrid:{handler:S.renderPolarGrid,once:!0},PolarAngleAxis:{handler:S.renderPolarAxis},PolarRadiusAxis:{handler:S.renderPolarAxis},Customized:{handler:S.renderCustomized}}),S.clipPathId="".concat((C=x.id)!==null&&C!==void 0?C:Fb("recharts"),"-clip"),S.throttleTriggeredAfterMouseMove=Gse(S.triggeredAfterMouseMove,(k=x.throttleDelay)!==null&&k!==void 0?k:1e3/60),S.state={},S}return aFe(j,w),tFe(j,[{key:"componentDidMount",value:function(){var C,k;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(C=this.props.margin.left)!==null&&C!==void 0?C:0,top:(k=this.props.margin.top)!==null&&k!==void 0?k:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var C=this.props,k=C.children,S=C.data,_=C.height,A=C.layout,T=Wu(k,uh);if(T){var M=T.props.defaultIndex;if(!(typeof M!="number"||M<0||M>this.state.tooltipTicks.length-1)){var R=this.state.tooltipTicks[M]&&this.state.tooltipTicks[M].value,D=YR(this.state,S,M,R),$=this.state.tooltipTicks[M].coordinate,O=(this.state.offset.top+_)/2,q=A==="horizontal",V=q?{x:$,y:O}:{y:$,x:O},K=this.state.formattedGraphicalItems.find(function(z){var Z=z.item;return Z.type.name==="Scatter"});K&&(V=Ot(Ot({},V),K.props.points[M].tooltipPosition),D=K.props.points[M].tooltipPayload);var G={activeTooltipIndex:M,isTooltipActive:!0,activeLabel:R,activePayload:D,activeCoordinate:V};this.setState(G),this.renderCursor(T),this.accessibilityManager.setIndex(M)}}}},{key:"getSnapshotBeforeUpdate",value:function(C,k){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==k.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==C.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==C.margin){var S,_;this.accessibilityManager.setDetails({offset:{left:(S=this.props.margin.left)!==null&&S!==void 0?S:0,top:(_=this.props.margin.top)!==null&&_!==void 0?_:0}})}return null}},{key:"componentDidUpdate",value:function(C){MM([Wu(C.children,uh)],[Wu(this.props.children,uh)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var C=Wu(this.props.children,uh);if(C&&typeof C.props.shared=="boolean"){var k=C.props.shared?"axis":"item";return l.indexOf(k)>=0?k:i}return i}},{key:"getMouseInfo",value:function(C){if(!this.container)return null;var k=this.container,S=k.getBoundingClientRect(),_=OTe(S),A={chartX:Math.round(C.pageX-_.left),chartY:Math.round(C.pageY-_.top)},T=S.width/k.offsetWidth||1,M=this.inRange(A.chartX,A.chartY,T);if(!M)return null;var R=this.state,D=R.xAxisMap,$=R.yAxisMap,O=this.getTooltipEventType(),q=Vq(this.state,this.props.data,this.props.layout,M);if(O!=="axis"&&D&&$){var V=ug(D).scale,K=ug($).scale,G=V&&V.invert?V.invert(A.chartX):null,z=K&&K.invert?K.invert(A.chartY):null;return Ot(Ot({},A),{},{xValue:G,yValue:z},q)}return q?Ot(Ot({},A),q):null}},{key:"inRange",value:function(C,k){var S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,_=this.props.layout,A=C/S,T=k/S;if(_==="horizontal"||_==="vertical"){var M=this.state.offset,R=A>=M.left&&A<=M.left+M.width&&T>=M.top&&T<=M.top+M.height;return R?{x:A,y:T}:null}var D=this.state,$=D.angleAxisMap,O=D.radiusAxisMap;if($&&O){var q=ug($);return GH({x:A,y:T},q)}return null}},{key:"parseEventsOfWrapper",value:function(){var C=this.props.children,k=this.getTooltipEventType(),S=Wu(C,uh),_={};S&&k==="axis"&&(S.props.trigger==="click"?_={onClick:this.handleClick}:_={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 A=bC(this.props,this.handleOuterEvent);return Ot(Ot({},A),_)}},{key:"addListener",value:function(){$4.on(F4,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){$4.removeListener(F4,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(C,k,S){for(var _=this.state.formattedGraphicalItems,A=0,T=_.length;A<T;A++){var M=_[A];if(M.item===C||M.props.key===C.key||k===lf(M.item.type)&&S===M.childIndex)return M}return null}},{key:"renderClipPath",value:function(){var C=this.clipPathId,k=this.state.offset,S=k.left,_=k.top,A=k.height,T=k.width;return Ne.createElement("defs",null,Ne.createElement("clipPath",{id:C},Ne.createElement("rect",{x:S,y:_,height:A,width:T})))}},{key:"getXScales",value:function(){var C=this.state.xAxisMap;return C?Object.entries(C).reduce(function(k,S){var _=zq(S,2),A=_[0],T=_[1];return Ot(Ot({},k),{},Gr({},A,T.scale))},{}):null}},{key:"getYScales",value:function(){var C=this.state.yAxisMap;return C?Object.entries(C).reduce(function(k,S){var _=zq(S,2),A=_[0],T=_[1];return Ot(Ot({},k),{},Gr({},A,T.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(C){var k;return(k=this.state.xAxisMap)===null||k===void 0||(k=k[C])===null||k===void 0?void 0:k.scale}},{key:"getYScaleByAxisId",value:function(C){var k;return(k=this.state.yAxisMap)===null||k===void 0||(k=k[C])===null||k===void 0?void 0:k.scale}},{key:"getItemByXY",value:function(C){var k=this.state,S=k.formattedGraphicalItems,_=k.activeItem;if(S&&S.length)for(var A=0,T=S.length;A<T;A++){var M=S[A],R=M.props,D=M.item,$=D.type.defaultProps!==void 0?Ot(Ot({},D.type.defaultProps),D.props):D.props,O=lf(D.type);if(O==="Bar"){var q=(R.data||[]).find(function(z){return ZOe(C,z)});if(q)return{graphicalItem:M,payload:q}}else if(O==="RadialBar"){var V=(R.data||[]).find(function(z){return GH(C,z)});if(V)return{graphicalItem:M,payload:V}}else if(J_(M,_)||e2(M,_)||Pj(M,_)){var K=wDe({graphicalItem:M,activeTooltipItem:_,itemData:$.data}),G=$.activeIndex===void 0?K:$.activeIndex;return{graphicalItem:Ot(Ot({},M),{},{childIndex:G}),payload:Pj(M,_)?$.data[K]:M.props.data[K]}}}return null}},{key:"render",value:function(){var C=this;if(!a8(this))return null;var k=this.props,S=k.children,_=k.className,A=k.width,T=k.height,M=k.style,R=k.compact,D=k.title,$=k.desc,O=Hq(k,G6e),q=Mr(O,!1);if(R)return Ne.createElement(Sq,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},Ne.createElement(IM,ty({},q,{width:A,height:T,title:D,desc:$}),this.renderClipPath(),o8(S,this.renderMap)));if(this.props.accessibilityLayer){var V,K;q.tabIndex=(V=this.props.tabIndex)!==null&&V!==void 0?V:0,q.role=(K=this.props.role)!==null&&K!==void 0?K:"application",q.onKeyDown=function(z){C.accessibilityManager.keyboardEvent(z)},q.onFocus=function(){C.accessibilityManager.focus()}}var G=this.parseEventsOfWrapper();return Ne.createElement(Sq,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},Ne.createElement("div",ty({className:An("recharts-wrapper",_),style:Ot({position:"relative",cursor:"default",width:A,height:T},M)},G,{ref:function(Z){C.container=Z}}),Ne.createElement(IM,ty({},q,{width:A,height:T,title:D,desc:$,style:uFe}),this.renderClipPath(),o8(S,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(u.Component);Gr(b,"displayName",r),Gr(b,"defaultProps",Ot({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},p)),Gr(b,"getDerivedStateFromProps",function(w,j){var x=w.dataKey,C=w.data,k=w.children,S=w.width,_=w.height,A=w.layout,T=w.stackOffset,M=w.margin,R=j.dataStartIndex,D=j.dataEndIndex;if(j.updateId===void 0){var $=Wq(w);return Ot(Ot(Ot({},$),{},{updateId:0},v(Ot(Ot({props:w},$),{},{updateId:0}),j)),{},{prevDataKey:x,prevData:C,prevWidth:S,prevHeight:_,prevLayout:A,prevStackOffset:T,prevMargin:M,prevChildren:k})}if(x!==j.prevDataKey||C!==j.prevData||S!==j.prevWidth||_!==j.prevHeight||A!==j.prevLayout||T!==j.prevStackOffset||!fy(M,j.prevMargin)){var O=Wq(w),q={chartX:j.chartX,chartY:j.chartY,isTooltipActive:j.isTooltipActive},V=Ot(Ot({},Vq(j,C,A)),{},{updateId:j.updateId+1}),K=Ot(Ot(Ot({},O),q),V);return Ot(Ot(Ot({},K),v(Ot({props:w},K),j)),{},{prevDataKey:x,prevData:C,prevWidth:S,prevHeight:_,prevLayout:A,prevStackOffset:T,prevMargin:M,prevChildren:k})}if(!MM(k,j.prevChildren)){var G,z,Z,ee,Q=Wu(k,ib),Y=Q&&(G=(z=Q.props)===null||z===void 0?void 0:z.startIndex)!==null&&G!==void 0?G:R,oe=Q&&(Z=(ee=Q.props)===null||ee===void 0?void 0:ee.endIndex)!==null&&Z!==void 0?Z:D,he=Y!==R||oe!==D,je=!Tn(C),pe=je&&!he?j.updateId:j.updateId+1;return Ot(Ot({updateId:pe},v(Ot(Ot({props:w},j),{},{updateId:pe,dataStartIndex:Y,dataEndIndex:oe}),j)),{},{prevChildren:k,dataStartIndex:Y,dataEndIndex:oe})}return null}),Gr(b,"renderActiveDot",function(w,j,x){var C;return u.isValidElement(w)?C=u.cloneElement(w,j):Qr(w)?C=w(j):C=Ne.createElement(G_,j),Ne.createElement(wa,{className:"recharts-active-dot",key:x},C)});var y=u.forwardRef(function(j,x){return Ne.createElement(b,ty({},j,{ref:x}))});return y.displayName=b.displayName,y},wFe=UD({chartName:"BarChart",GraphicalChild:xv,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Vb},{axisType:"yAxis",AxisComp:Wb}],formatAxisMap:Ine}),jFe=UD({chartName:"PieChart",GraphicalChild:Pf,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:Z_},{axisType:"radiusAxis",AxisComp:Q_}],formatAxisMap:hRe,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}}),NFe=UD({chartName:"AreaChart",GraphicalChild:Hg,axisComponents:[{axisType:"xAxis",AxisComp:Vb},{axisType:"yAxis",AxisComp:Wb}],formatAxisMap:Ine});function Gq(e){if(!e)return null;for(const s of e)if(s&&s.toLowerCase()!=="motion")return s.toLowerCase();return null}const SFe={person:yde,car:Rk,truck:cO,bus:qce,motorcycle:k$,bicycle:k$,dog:ede,cat:Vce,bird:Hce,horse:T$,animal:T$,backpack:zce,handbag:VK,suitcase:oh,"cell phone":Yc,umbrella:Lde,boat:Cde};function Yq(e){return e&&SFe[e]||Do}function Qq(e){return e.replace(/\b\w/g,s=>s.toUpperCase())}const O1=["#f59e0b","#ef4444","#22c55e","#a855f7","#06b6d4","#f97316","#e
556c4899","#84cc16","#14b8a6","#eab308","#6366f1"];function gk({segments:e,onEventClick:s,selectedDate:r,onSelectDate:n,cameraDisplayNames:a,groupBySite:i=!1,siteNames:o,singleSiteName:l,playingId:c,detectionColor:d,motionColor:h,isLoading:p=!1,privacyBlocked:g=!1,recordingDays:v,onSwitchView:b,testIdPrefix:y="classic"}){const[w,j]=u.useState(null),x=100,[C,k]=u.useState(x),S=u.useRef(null),_=u.useCallback(Q=>{S.current&&(S.current.disconnect(),S.current=null),!(!Q||typeof IntersectionObserver>"u")&&(S.current=new IntersectionObserver(Y=>{Y.some(oe=>oe.isIntersecting)&&k(oe=>oe+x)},{rootMargin:"200px"}),S.current.observe(Q))},[]);u.useEffect(()=>()=>{S.current?.disconnect()},[]);const[A,T]=u.useState(new Set),M=u.useRef(null),R=()=>{requestAnimationFrame(()=>{let Q=M.current?.parentElement||null,Y=null;for(;Q;){const oe=getComputedStyle(Q);if(/(auto|scroll)/.test(oe.overflowY)&&Q.scrollHeight>Q.clientHeight+1){Y=Q;break}Q=Q.parentElement}if(Y)Y.scrollTo({top:Y.scrollHeight,behavior:"smooth"});else{const oe=document.scrollingElement||document.documentElement;oe.scrollTo?.({top:oe.scrollHeight,behavior:"smooth"})}})},D=u.useRef(p),$=u.useRef(0);u.useEffect(()=>{const Q=D.current,Y=$.current;D.current=p,$.current=e.length;const oe=Q&&!p,he=Y===0&&e.length>0;!p&&e.length>0&&(oe||he)&&R()},[p,e.length]);const O=u.useMemo(()=>{const Q=new Map;for(const Y of e){const oe=i?Y.siteId||"":"__single__";let he=Q.get(oe);he||(he=new Map,Q.set(oe,he));const je=he.get(Y.camera)||[];je.push(Y),he.set(Y.camera,je)}return Q.forEach(Y=>{Y.forEach((oe,he)=>{const je=new Set,pe=[];for(const le of[...oe].sort((ue,fe)=>ue.startMs-fe.startMs)){const ue=le.id.split("::")[0];je.has(ue)||(je.add(ue),pe.push(le))}Y.set(he,pe)})}),Q},[e,i]),q=u.useMemo(()=>Array.from(O.keys()).sort((Q,Y)=>(o?.get(Q)||Q).localeCompare(o?.get(Y)||Y)),[O,o]),V=Q=>{const Y=w!==Q;j(Y?Q:null),k(x),Y&&requestAnimationFrame(()=>{M.current?.querySelector(`[data-node-key="${CSS.escape(Q)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"})})},K=Q=>{T(Y=>{const oe=new Set(Y);return oe.has(Q)?oe.delete(Q):oe.add(Q),oe})},G=b?t.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>b("events"),"data-testid":`${y}-switch-events`,children:[t.jsx(Cy,{className:"w-4 h-4 mr-1.5"}),"Event Grid View"]}),t.jsxs(L,{variant:"outline",size:"sm",className:"hidden sm:inline-flex",onClick:()=>b("timeline"),"data-testid":`${y}-switch-timeline`,children:[t.jsx(Hx,{className:"w-4 h-4 mr-1.5"}),"Time Line View"]}),t.jsx(L,{variant:"outline",size:"sm",asChild:!0,"data-testid":`${y}-open-video-export`,children:t.jsxs(Rx,{href:"/video-export",children:[t.jsx(ya,{className:"w-4 h-4 mr-1.5"}),"Video Exporter"]})})]}):null,z=c?e.find(Q=>Q.id.split("::")[0]===c):null,Z=u.useMemo(()=>{const Q=new Set;let Y=0,oe=0;const he=new Map;for(const pe of e){const le=pe.id.split("::")[0];if(Q.has(le))continue;Q.add(le);const ue=Gq(pe.labels);ue?(oe++,he.set(ue,(he.get(ue)||0)+1)):Y++}const je=Array.from(he.entries()).sort((pe,le)=>le[1]-pe[1]).map(([pe,le])=>({label:pe,count:le}));return{total:Q.size,motion:Y,ai:oe,labels:je}},[e]),ee=(Q,Y,oe)=>{const he=`${Q}|${Y}`,je=w===he,pe=a?.get(Y)||Y;return t.jsxs("div",{"data-node-key":he,children:[t.jsxs("button",{type:"button",className:"w-full flex items-center gap-1.5 px-2 py-1.5 rounded-sm hover-elevate text-left",onClick:()=>V(he),"data-testid":`${y}-camera-${Y}`,children:[je?t.jsx(Xa,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}):t.jsx(hi,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),t.jsx(no,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"text-sm truncate flex-1",children:pe}),t.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:oe.length})]}),je&&t.jsxs("div",{className:"ml-5 border-l pl-2 space-y-0.5 py-0.5",children:[oe.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground px-2 py-1",children:"No events"}),oe.slice(0,C).map(le=>{const ue=le.id.split("::")[0],fe=c!=null&&ue===c,H=le.source==="unavailable",se=Gq(le.labels),me=se!=null,ge=me?(le.labels||[]).filter(ce=>ce&&ce.toLowerCase()!=="motion").join(", "):"",be=Yq(se);return t.jsxs("button",{type:"button",disabled:H||g,title:me?`AI detection: ${ge}`:"Motion event",className:`w-full flex items-center gap-1.5 text-left px-2 py-1 rounded-sm text-xs font-mono tabular-nums ${fe?"bg-primary text-primary-foreground":H||g?"text-muted-foreground
556/60 cursor-not-allowed":"hover-elevate"}`,onClick:()=>{!H&&!g&&s(le)},"data-testid":`${y}-event-${ue}`,children:[me?t.jsx(be,{className:`w-3 h-3 shrink-0 ${fe||d?"":"text-amber-500"}`,style:!fe&&d?{color:d}:void 0,"data-testid":`${y}-icon-ai-${ue}`}):t.jsx(Wh,{className:`w-3 h-3 shrink-0 ${fe||h?"":"text-blue-500"}`,style:!fe&&h?{color:h}:void 0,"data-testid":`${y}-icon-motion-${ue}`}),t.jsxs("span",{className:"truncate",children:[Bn(new Date(le.startMs),"MM/dd/yyyy - hh:mm:ss a"),H?" (unavailable)":""]})]},le.id)}),oe.length>C&&t.jsxs("button",{type:"button",ref:_,className:"w-full text-left px-2 py-1.5 rounded-sm text-xs text-primary hover-elevate",onClick:()=>k(le=>le+x),"data-testid":`${y}-show-more-${Y}`,children:["Show ",Math.min(x,oe.length-C)," more of ",(oe.length-C).toLocaleString()," remaining…"]})]})]},he)};return t.jsxs("div",{ref:M,className:"flex flex-col lg:flex-row gap-4 items-start",children:[t.jsx(ut,{className:"w-full lg:w-80 shrink-0 order-2 lg:order-1",children:t.jsxs(mt,{className:"p-2 space-y-2",children:[t.jsx(_m,{mode:"single",selected:r,onSelect:Q=>{if(Q){const Y=new Date(Q);Y.setHours(0,0,0,0),n(Y)}},disabled:Q=>Q>new Date,modifiers:{hasRecordings:Q=>!!v&&v.has(Bn(Q,"yyyy-MM-dd"))},modifiersClassNames:{hasRecordings:"classic-cal-dot"},className:"rounded-md border w-full","data-testid":`${y}-calendar`}),t.jsx("div",{className:"border-t pt-2 max-h-[50vh] overflow-y-auto","data-testid":`${y}-tree`,children:p?t.jsx("div",{className:"space-y-2 p-2",children:Array.from({length:5}).map((Q,Y)=>t.jsx(Bt,{className:"h-6 w-full"},Y))}):q.length===0?t.jsxs("p",{className:"text-xs text-muted-foreground p-2",children:["No events found for ",Bn(r,"MMM d, yyyy"),"."]}):q.map(Q=>{const Y=O.get(Q),oe=Array.from(Y.keys()).sort((pe,le)=>(a?.get(pe)||pe).localeCompare(a?.get(le)||le)),he=i?o?.get(Q)||"Unknown Site":l||"Site",je=A.has(Q);return t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{type:"button",className:"w-full flex items-center gap-1.5 px-2 py-1.5 rounded-sm hover-elevate text-left",onClick:()=>K(Q),"data-testid":`${y}-site-${Q}`,children:[je?t.jsx(hi,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}):t.jsx(Xa,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),t.jsx(ql,{className:"w-3.5 h-3.5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"text-sm font-medium truncate",children:he})]}),!je&&t.jsx("div",{className:"ml-4",children:oe.map(pe=>ee(Q,pe,Y.get(pe)))})]},Q)})})]})}),t.jsx(ut,{className:"flex-1 w-full self-stretch order-1 lg:order-2",children:t.jsx(mt,{className:"h-full flex items-center justify-center py-16",children:z?t.jsxs("div",{className:"text-center","data-testid":`${y}-now-playing`,children:[t.jsx(vu,{className:"w-10 h-10 mx-auto text-primary mb-3"}),t.jsx("h3",{className:"text-base font-medium mb-1",children:a?.get(z.camera)||z.camera}),t.jsx("p",{className:"text-sm text-muted-foreground",children:Bn(new Date(z.startMs),"MM/dd/yyyy - hh:mm:ss a")})]}):Z.total>0?t.jsxs("div",{className:"text-center w-full","data-testid":`${y}-day-stats`,children:[t.jsx("h3",{className:"text-base font-medium mb-1",children:Bn(r,"MMMM d, yyyy")}),t.jsxs("p",{className:"text-sm text-muted-foreground mb-2","data-testid":`${y}-stats-total`,children:[Z.total.toLocaleString()," recording",Z.total===1?"":"s"]}),t.jsx("div",{className:"h-56 w-full max-w-sm mx-auto",children:t.jsx(nD,{width:"100%",height:"100%",children:t.jsx(jFe,{children:t.jsxs(Pf,{data:[{name:"Motion",value:Z.motion},...Z.labels.map(Q=>({name:Qq(Q.label),value:Q.count}))],dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:55,outerRadius:85,strokeWidth:2,stroke:"hsl(var(--card))",children:[t.jsx(nj,{fill:h||"#3b82f6"}),Z.labels.map((Q,Y)=>t.jsx(nj,{fill:Y===0&&d?d:O1[Y%O1.length]},Q.label))]})})})}),t.jsxs("div",{className:"flex items-center justify-center gap-x-5 gap-y-1.5 mt-2 text-sm flex-wrap max-w-md mx-auto",children:[t.jsxs("span",{className:"flex items-center gap-1.5","data-testid":`${y}-stats-motion`,children:[t.jsx(Wh,{className:"w-3.5 h-3.5",style:{color:h||"#3b82f6"}}),t.jsx("span",{className:"text-muted-foreground",children:"Motion"}),t.jsx("span",{className:"font-medium tabular-nums",children:Z.motion.toLocaleStr
556ing()})]}),Z.labels.map((Q,Y)=>{const oe=Yq(Q.label),he=Y===0&&d?d:O1[Y%O1.length];return t.jsxs("span",{className:"flex items-center gap-1.5","data-testid":`${y}-stats-label-${Q.label.replace(/\s+/g,"-")}`,children:[t.jsx(oe,{className:"w-3.5 h-3.5",style:{color:he}}),t.jsx("span",{className:"text-muted-foreground",children:Qq(Q.label)}),t.jsx("span",{className:"font-medium tabular-nums",children:Q.count.toLocaleString()})]},Q.label)})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-4 max-w-sm mx-auto",children:"Expand a camera in the tree and click an event to play it."}),G]}):t.jsxs("div",{className:"text-center",children:[t.jsx(Vi,{className:"w-10 h-10 mx-auto text-muted-foreground mb-3"}),t.jsx("h3",{className:"text-base font-medium mb-1",children:"Classic View"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-sm mx-auto",children:"Pick a day on the calendar, expand a camera in the tree, and click an event to play it in the video player."}),G]})})})]})}const Fp=2e3,CFe=1e4;function kFe(e,s,r){let n=[{startMs:e.startMs,endMs:e.endMs}];for(const a of s){const i=a.startMs-r,o=a.endMs+r,l=[];for(const c of n){if(o<=c.startMs||i>=c.endMs){l.push(c);continue}i>c.startMs&&l.push({startMs:c.startMs,endMs:Math.min(i,c.endMs)}),o<c.endMs&&l.push({startMs:Math.max(o,c.startMs),endMs:c.endMs})}n=l}return n.filter(a=>a.endMs-a.startMs>r)}function D1(e,s,r,n){const a=n?.minGapFillMs??CFe,i=new Map;for(const d of e){const h=i.get(d.camera)||{cloud:[],local:[]};h.cloud.push(d),i.set(d.camera,h)}for(const d of s){const h=i.get(d.camera)||{cloud:[],local:[]};h.local.push(d),i.set(d.camera,h)}const o=[];let l=0,c=0;return i.forEach(d=>{for(const p of d.cloud)o.push(p);const h=d.cloud.map(p=>({startMs:p.startMs,endMs:p.endMs}));for(const p of d.local){const g=kFe(p,h,r);if(g.length===0){l++;continue}const v=g.length===1&&g[0].startMs===p.startMs&&g[0].endMs===p.endMs;if(n?.localUnavailable){g.filter(b=>v||b.endMs-b.startMs>=a).forEach((b,y)=>{o.push({...p,id:`${p.id}::u${y}`,startMs:b.startMs,endMs:b.endMs,source:"unavailable"}),c++});continue}v?(o.push(p),c++):g.filter(b=>b.endMs-b.startMs>=a).forEach((b,y)=>{o.push({...p,id:`${p.id}::h${y}`,startMs:b.startMs,endMs:b.endMs}),c++})}}),(e.length||s.length)&&console.log(`[HybridRetrieval] merged timeline cloud=${e.length} local=${s.length} localOverlapsRemoved=${l} localGapFills=${c}`),o}function _Fe(e,s,r,n,a){const i=e.filter(o=>o.camera===s&&o.source!=="unavailable").sort((o,l)=>o.startMs-l.startMs);if(i.length===0)return null;if(n===1){for(const o of i)if(o.startMs>r-a&&o.endMs>r+a)return o;return null}for(let o=i.length-1;o>=0;o--)if(i[o].startMs<r-a)return i[o];return null}function PFe(e,s,r){return s??(!e.id.includes("::h")||r!=null&&e.startMs<=r+1e3?null:e.startMs)}function EFe(e){const{targetMs:s,clipStartSec:r,clipDurationSec:n,minSeekSec:a=1}=e;if(s==null)return null;let i=s/1e3-r;return i>a?(n!=null&&isFinite(n)&&n>.5&&(i=Math.min(i,n-.5)),i>0?i:null):null}function xae(e,s,r,n){return e.find(i=>i.camera===s&&r>=i.startMs-n&&r<=i.endMs+n)||null}function U4(e){const{attempted:s,failedSource:r,clipId:n,camera:a,timestampMs:i,altPool:o,tol:l}=e,c=`${r}:${n}`;if(s.has(c))return null;const d=xae(o,a,i,l);return d?(s.add(c),d):null}const fx=52,Hv=52,fS="#0ea5e9",gS="#a855f7",Kw="#64748b";function Xq(e){const s={person:"#3b82f6",car:"#0ea5e9",vehicle:"#0ea5e9",truck:"#f43f5e",motorcycle:"#8b5cf6",bicycle:"#14b8a6",bus:"#dc2626",dog:"#22c55e",cat:"#a855f7",animal:"#22c55e",bird:"#34d399",face:"#ec4899",license_plate:"#ef4444",package:"#6366f1",motion:"#eab308"};for(const r of e){const n=r.toLowerCase();if(s[n])return s[n]}return"#6366f1"}function Zq(e){return{ctx:e,startedAt:Date.now(),ttffMs:null,hlsErrorCount:0,hlsFatalErrorCount:0,stallCount:0,totalStallMs:0,seekCount:0,fallbackUsed:!1,finalSource:null,playbackFailed:!1,reported:!1,waitingAt:null,hasPlayed:!1}}function z4(e){if(!e.reported&&(e.reported=!0,!(e.ttffMs==null&&e.hlsErrorCount===0&&!e.fallbackUsed&&!e.playbackFailed)))try{const s={siteId:e.ctx.siteId,eventId:e.ctx.eventId,camera:e.ctx.camera,ttffMs:e.ttffMs,hlsErrorCount:e.hlsErrorCount,hlsFatalErrorCount:e.hlsFatalErrorCount,stallCount:e.stallCount,totalStallMs:e.totalStallMs,seekCount:e.seekCount,fallbackUsed:e.fallbackUsed,finalSource:e.finalSource,playbackFailed:e.playbackFailed,sessionDurationMs:Date.now()-e.startedAt},r=JSON.stringify(s);if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function"){const n=new Blob([r],{type:"application/json"});navigator.sendBeacon("/api/playback-telemetry",n);return}fetch("/api/playback-telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:r,credentials:"include",keepalive:!0}
556).catch(()=>{})}catch{}}function Jq({hlsSrc:e,fallbackSrc:s,eventId:r,siteId:n,camera:a,autoPlay:i,onError:o,onEnded:l,onSourceDetected:c,externalVideoRef:d,muted:h,...p}){const g=u.useRef(null),v=d||g,b=u.useRef(null),y=u.useRef(null),w=u.useRef(!1),j=u.useRef(Zq({eventId:r,siteId:n,camera:a}));u.useEffect(()=>{const k=()=>z4(j.current);return window.addEventListener("pagehide",k),()=>window.removeEventListener("pagehide",k)},[]);const x=u.useRef({hlsSrc:e,fallbackSrc:s});x.current={hlsSrc:e,fallbackSrc:s};const C=/[?&]vt=/.test(e||"")||/[?&]vt=/.test(s||"");return u.useEffect(()=>{const k=v.current;if(!k)return;const{hlsSrc:S,fallbackSrc:_}=x.current;z4(j.current),j.current=Zq({eventId:r,siteId:n,camera:a});const A=j.current;if(b.current&&(b.current.destroy(),b.current=null),y.current=null,w.current=!1,k.pause(),!S&&!_)return;const T=()=>{if(!w.current){if(w.current=!0,b.current&&(b.current.destroy(),b.current=null),!_){A.playbackFailed=A.ttffMs==null,o?.();return}y.current="fallback",A.fallbackUsed=!0,A.finalSource="clip",k.src=_,c?.("clip"),i&&k.play().catch(()=>{})}};S?(console.log("[HlsVideo] Loading HLS src:",S),fg(async()=>{const{default:O}=await import("./hls-DuDM7LWb.js");return{default:O}},[]).then(({default:O})=>{if(v.current)if(O.isSupported()){console.log("[HlsVideo] hls.js supported, attaching media"),y.current="hls",A.finalSource="hls";const q=new O({maxBufferLength:60,maxMaxBufferLength:180,enableWorker:!0,lowLatencyMode:!1});b.current=q,q.loadSource(S),q.attachMedia(k),q.on(O.Events.MANIFEST_PARSED,()=>{console.log("[HlsVideo] Manifest parsed, playing"),c?.("hls"),i&&k.play().catch(()=>{})}),q.on(O.Events.ERROR,(V,K)=>{console.log("[HlsVideo] HLS error:",K.type,K.details,"fatal:",K.fatal),$o("clip",`local HLS error: ${K.type}/${K.details} fatal=${!!K.fatal}`,{eventId:r,hlsSrc:S}),A.hlsErrorCount+=1,K.fatal&&(A.hlsFatalErrorCount+=1,console.log("[HlsVideo] Fatal HLS error, switching to direct clip URL"),$o("clip","local clip falling back HLS→MP4",{eventId:r,fallbackSrc:_}),T())})}else k.canPlayType("application/vnd.apple.mpegurl")?(console.log("[HlsVideo] Safari native HLS"),y.current="hls",A.finalSource="hls",k.src=S,k.addEventListener("loadedmetadata",()=>{c?.("hls"),i&&k.play().catch(()=>{})},{once:!0})):(console.log("[HlsVideo] HLS not supported, using fallback"),T())}).catch(O=>{console.log("[HlsVideo] hls.js import failed:",O),T()})):(console.log("[HlsVideo] No hlsSrc, going straight to fallback"),T());const M=()=>{A.hasPlayed||(A.hasPlayed=!0,A.ttffMs=Math.max(0,Date.now()-A.startedAt)),A.waitingAt!=null&&(A.totalStallMs+=Math.max(0,Date.now()-A.waitingAt),A.waitingAt=null)},R=()=>{A.hasPlayed&&A.waitingAt==null&&(A.waitingAt=Date.now(),A.stallCount+=1)},D=()=>{A.hasPlayed&&(A.seekCount+=1)};k.addEventListener("playing",M),k.addEventListener("waiting",R),k.addEventListener("seeked",D);const $=N_(k,"[local]");return()=>{k.removeEventListener("playing",M),k.removeEventListener("waiting",R),k.removeEventListener("seeked",D),b.current&&(b.current.destroy(),b.current=null),A.waitingAt!=null&&(A.totalStallMs+=Math.max(0,Date.now()-A.waitingAt),A.waitingAt=null),z4(A),$()}},[r,C]),u.useEffect(()=>{h&&v.current&&(v.current.muted=!0,v.current.volume=0)},[h]),t.jsx("div",{className:`relative w-full h-full ${h?"audio-restricted":""}`,children:t.jsx("video",{ref:v,controls:!0,playsInline:!0,muted:h||void 0,className:"w-full h-full rounded-md bg-black object-contain",onVolumeChange:k=>{if(h){const S=k.currentTarget;(!S.muted||S.volume>0)&&(S.muted=!0,S.volume=0)}},onPlay:k=>{h&&(k.currentTarget.muted=!0,k.currentTarget.volume=0)},onError:k=>{const S=k.currentTarget,_=S.error,A=_?`code=${_.code} (${["","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED"][_.code]||"UNKNOWN"}) msg="${_.message||""}" netState=${S.networkState} readyState=${S.readyState}`:`no MediaError netState=${S.networkState} readyState=${S.readyState}`;if($o("clip",`local clip <video> error (mode=${y.current}): ${A}`,{eventId:r,src:S.currentSrc}),y.current==="hls"){const T=v.current;T&&s&&!w.current?(w.current=!0,b.current&&(b.current.destroy(),b.current=null),y.current="fallback",j.current.fallbackUsed=!0,j.current.finalSource="clip",T.src=s,c?.("clip"),$o("clip","local clip falling back HLS→MP4",{eventId:r,fallbackSrc:s}),i&&T.play().catch(()=>{})):s||(j.current.playbackFailed=j.current.ttffMs==null,o?.())}else y.current==="fallback"&&(j.current.playbackFailed=j.current.ttffMs==null,o?.())},onEnded:l,...p})})}const Uh=[1,2,4,8,24,48,96],TFe=["24h","12h","6h","3h","1h","30m","15m"];function AFe(e,s){const r=s-e;let n,a;r>=18*36e5?(n=36e5,a="h a"):r>=6*36e5?(n=18e5,a="h:mm"):r>=2*36e5?(n=9e5,a="h:mm"):r>=45*6e4?(n=3e5,a="h:mm"):(n=6e4,a="h:mm");const i=[],o=Math.ceil(e/n)*n;for(let l=o;l<=s;l+=n)i.push({time:l,label:Bn(new Date(l),a)});return i}
556function e9({segments:e,onSegmentClick:s,siteId:r,timelineDate:n,detectionColor:a,motionColor:i,cameraDisplayNames:o,privacyBlocked:l,distinguishSources:c}){const d=u.useRef(null),h=u.useRef(null),[p,g]=u.useState(null),[v,b]=u.useState(0),[y,w]=u.useState(0),j=u.useRef(null),x=u.useRef(!1),C=u.useRef(new Map),k=u.useRef(null),S=u.useRef(0),_=u.useRef(0);S.current=v,_.current=y;const{cameraGroups:A,fullDayStart:T,fullDayEnd:M}=u.useMemo(()=>{const se=new Date(n);se.setHours(0,0,0,0);const me=new Date(n);me.setHours(23,59,59,999);const ge=new Date,be=se.toDateString()===ge.toDateString(),ce=new Date(be?Math.min(me.getTime(),ge.getTime()):me.getTime());ce.setMinutes(0,0,0),ce.setHours(ce.getHours()+1);const Pe=new Map;for(const et of e){const $e=Pe.get(et.camera)||[];$e.push(et),Pe.set(et.camera,$e)}return Pe.forEach((et,$e)=>{Pe.set($e,et.sort((bt,Ae)=>bt.startMs-Ae.startMs))}),{cameraGroups:Pe,fullDayStart:se.getTime(),fullDayEnd:ce.getTime()}},[e,n]),R=M-T,D=1/Uh[v],$=Math.max(0,Math.min(y,1-D)),O=T+$*R,q=T+($+D)*R,V=q-O,K=v>0,G=u.useMemo(()=>AFe(O,q),[O,q]);u.useEffect(()=>{b(0),w(0)},[n]);const[z,Z]=u.useState(800);u.useEffect(()=>{const se=d.current;if(!se)return;const me=new ResizeObserver(ge=>{for(const be of ge)Z(be.contentRect.width-128)});return me.observe(se),()=>me.disconnect()},[]);const ee=u.useCallback((se,me)=>{const ge=S.current,be=Math.max(0,Math.min(Uh.length-1,ge+se));if(be===ge)return;const ce=me??.5,Pe=1/Uh[ge],et=_.current,bt=Math.max(0,Math.min(et,1-Pe))+ce*Pe,Ae=1/Uh[be];b(be),w(Math.max(0,Math.min(bt-ce*Ae,1-Ae)))},[]);u.useEffect(()=>{const se=h.current;if(!se)return;const me=ge=>{if(ge.deltaY===0)return;ge.preventDefault();const be=se.getBoundingClientRect(),ce=Math.max(0,Math.min(1,(ge.clientX-be.left)/be.width));ee(ge.deltaY<0?1:-1,ce)};return se.addEventListener("wheel",me,{passive:!1}),()=>se.removeEventListener("wheel",me)},[ee]);const Q=u.useRef(0);u.useEffect(()=>{const se=()=>{C.current.clear(),j.current&&j.current.totalDist>5&&(x.current=!0,setTimeout(()=>{x.current=!1},0)),j.current=null,k.current=null};return document.addEventListener("pointerup",se),document.addEventListener("pointercancel",se),()=>{document.removeEventListener("pointerup",se),document.removeEventListener("pointercancel",se)}},[]);const Y=u.useCallback(se=>{if(C.current.set(se.pointerId,{x:se.clientX,y:se.clientY}),C.current.size===2){j.current=null;try{se.currentTarget.setPointerCapture(se.pointerId)}catch{}const me=Array.from(C.current.values());k.current={startDist:Math.hypot(me[1].x-me[0].x,me[1].y-me[0].y),startZoomIdx:S.current}}else if(C.current.size===1&&S.current>0){const me=1/Uh[S.current],ge=Math.max(0,Math.min(_.current,1-me));j.current={startX:se.clientX,startView:ge,totalDist:0},Q.current=se.clientX,x.current=!1}},[]),oe=u.useCallback(se=>{if(C.current.has(se.pointerId)&&C.current.set(se.pointerId,{x:se.clientX,y:se.clientY}),C.current.size===2&&k.current){const Pe=Array.from(C.current.values()),$e=Math.hypot(Pe[1].x-Pe[0].x,Pe[1].y-Pe[0].y)/k.current.startDist,bt=Math.round(Math.log2($e)*2),Ae=Math.max(0,Math.min(Uh.length-1,k.current.startZoomIdx+bt));if(Ae!==S.current){const Be=h.current?.getBoundingClientRect();if(Be){const J=(Pe[0].x+Pe[1].x)/2,ae=Math.max(0,Math.min(1,(J-Be.left)/Be.width)),we=1/Uh[S.current],ye=Math.max(0,Math.min(_.current,1-we))+ae*we,te=1/Uh[Ae];b(Ae),w(Math.max(0,Math.min(ye-ae*te,1-te)))}}return}if(!j.current||C.current.size!==1)return;j.current.totalDist+=Math.abs(se.clientX-Q.current),Q.current=se.clientX;const me=h.current?.getBoundingClientRect();if(!me)return;const ge=1/Uh[S.current],ce=(j.current.startX-se.clientX)/me.width*ge;w(Math.max(0,Math.min(j.current.startView+ce,1-ge)))},[]),he=u.useCallback(se=>{try{se.currentTarget?.releasePointerCapture?.(se.pointerId)}catch{}j.current&&j.current.totalDist>5&&(x.current=!0,setTimeout(()=>{x.current=!1},0)),C.current.delete(se.pointerId),C.current.size<2&&(k.current=null),C.current.size===0&&(j.current=null)},[]),je=u.useCallback(()=>{C.current.clear(),j.current=null,k.current=null},[]),le=z>0?8/z*100:.5;if(e.length===0)return t.jsxs("div",{className:"text-center py-16",children:[t.jsx(Hx,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Events to Display"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"No events found for the selected filters. Try adjusting the date range or camera selection."})]});const ue=se=>V===0?0:(se-O)/V*100,fe=(se,me)=>V===0?0:Math.max((me-se)/V*100,le),H=Array.from(A.keys()).sort();return t.jsx(ut,{children:t.jsxs(mt,{className:"pt-4 pb-2",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3 flex-wrap gap-2",children:[t.jsxs("div",{className:"flex items-center gap-1","data-testid":"timeline-zoom-control
556s",children:[t.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ee(-1),disabled:v===0,"data-testid":"button-zoom-out",children:t.jsx(uO,{className:"w-3.5 h-3.5"})}),t.jsx("span",{className:"text-[11px] text-muted-foreground font-medium min-w-[2rem] text-center select-none","data-testid":"text-zoom-level",children:TFe[v]}),t.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ee(1),disabled:v===Uh.length-1,"data-testid":"button-zoom-in",children:t.jsx(Vj,{className:"w-3.5 h-3.5"})}),K&&t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[11px] ml-1",onClick:()=>{b(0),w(0)},"data-testid":"button-zoom-reset",children:"Reset"})]}),t.jsx("div",{className:"flex items-center gap-3",children:c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1.5","data-testid":"timeline-legend-cloud",children:[t.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:fS}}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Cloud"})]}),t.jsxs("div",{className:"flex items-center gap-1.5","data-testid":"timeline-legend-local",children:[t.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:gS}}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Local"})]}),t.jsxs("div",{className:"flex items-center gap-1.5","data-testid":"timeline-legend-unavailable",children:[t.jsx("div",{className:"w-3 h-3 rounded-sm border border-border bg-transparent"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Unavailable"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:a||"#3b82f6"}}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"AI Events"})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:i||"#eab308"}}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Motion"})]})]})})]}),t.jsxs("div",{className:"relative",children:[p&&(()=>{const se=p.seg,me=se.originalEvent?.detections?.[0]?`/api/local-recordings/${r}/thumbnail?detection=${encodeURIComponent(se.originalEvent.detections[0])}`:se.originalEvent?.camera&&se.originalEvent?.start_time?`/api/local-recordings/${r}/thumbnail?camera=${encodeURIComponent(se.originalEvent.camera)}&time=${se.originalEvent.start_time}`:se.thumbnailUrl||null;return t.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 bottom-full z-50 pointer-events-none mb-1","data-testid":"timeline-hover-preview",children:t.jsxs("div",{className:"rounded-md border bg-card shadow-lg overflow-hidden",style:{width:"200px"},children:[l?t.jsx("div",{className:"w-full flex items-center justify-center bg-black",style:{height:"120px"},"data-testid":"privacy-blocked-timeline-preview",children:t.jsx(ka,{className:"w-8 h-8 text-white/40"})}):me&&t.jsx("img",{src:me,alt:"",className:"w-full h-auto object-cover",style:{maxHeight:"120px"},onError:ge=>{ge.target.style.display="none"}}),t.jsxs("div",{className:"px-2 py-1.5 flex items-center gap-2 text-xs",children:[t.jsx("span",{className:"font-medium truncate",children:o?.get(p.cameraName)||p.cameraName}),t.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:Bn(new Date(se.startMs),"h:mm:ss a")}),(c||se.source==="unavailable")&&t.jsx("span",{className:"ml-auto whitespace-nowrap rounded px-1.5 py-0.5 text-[10px] font-medium text-white",style:{backgroundColor:se.source==="cloud"?fS:se.source==="unavailable"?Kw:gS},"data-testid":`timeline-hover-source-${se.source}`,children:se.source==="cloud"?"Cloud":se.source==="unavailable"?"Unavailable":"Local"})]})]})})})(),t.jsx("div",{className:"overflow-hidden",children:t.jsxs("div",{ref:d,children:[t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"w-32 flex-shrink-0"}),t.jsx("div",{className:"flex-1 relative h-6",children:G.map(se=>{const me=ue(se.time);return me<-1||me>101?null:t.jsx("div",{className:"absolute top-0 flex flex-col items-center",style:{left:`${me}%`,transform:"translateX(-50%)"},children:t.jsx("span",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:se.label})},se.time)})})]}),t.jsx("div",{ref:h,className:`space-y-1 select-none ${K?"cursor-grab active:cursor-grabbing":""}`,style:{touchAction:"none"},onPointerDown:Y,onPointerMove:oe,onPointerUp:he,onPointerCancel:he,onLostPointerCapture:je,onMouseLeave:()=>g(null),children:H.map(se=>{const me=A.get(se)||[];return t.jsxs("div",{className:"flex items-center gap-0",children:[t.jsxs("div",{className:"w-32 flex-shrink-0 pr-2 flex items-center gap-1.5",children:[t.jsx(wo,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-xs truncate",title:o?.get(se)||se,children:o?.get(se)||se})]}),t.jsxs("div",{className:"flex-1 relative h-7 bg-muted/50 rounded-sm overflow-hidden",children:[G.map(ge=>{const be=ue(ge.time);return be<=0||be>=100?null:t.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-border/50",style:{left:`${be}%`}},ge.time)}),me.map(ge=>{const be=ue(ge.startMs),ce=fe(ge.startMs,ge.endMs);if(be+ce<0||be>100)return null;const Pe=ge.labels.length>0?ge.labels.join(", "):"event",et=Bn(new Date(ge.startMs),"h:mm:ss a");return ge.source==="unavailable"?t.jsx("div",{className:"absolute top-1 bottom-1 rounded-sm opacity-50",style:{left:`${be}%`,width:`${ce}%`,minWidth:"8px",backgroundColor:"transparent",border:`1px solid ${Kw}`,backgroundImage:`repeating-linear-gradient(45deg, ${Kw} 0, ${Kw} 1px, transparent 1px, transparent 4px)`,zIndex:3},onMouseEnter:()=>g({seg:ge,cameraName:se}),"aria-label":`${o?.get(se)||se} temporarily unavailable at ${et}`,"data-testid":`timeline-segment-unavailable-${ge.id}`},ge.id):t.jsx("div",{className:"absolute top-1 bottom-1 rounded-sm cursor-pointer opacity-80 hover:opacity-100 transition-opacity",style:{left:`${be}%`,width:`${ce}
556%`,minWidth:"8px",backgroundColor:c?ge.source==="cloud"?fS:gS:ge.labels.includes("motion")?i||"#eab308":Xq(ge.labels),zIndex:3,boxShadow:"inset -1px 0 0 0 rgba(0,0,0,0.55)"},onClick:()=>{x.current||s(ge)},onMouseEnter:()=>g({seg:ge,cameraName:se}),role:"button",tabIndex:0,"aria-label":`${o?.get(se)||se} ${Pe} at ${et}`,"data-testid":`timeline-segment-${ge.id}`},ge.id)})]})]},se)})}),K&&t.jsx("div",{className:"mt-2 mx-0",children:t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"w-32 flex-shrink-0"}),t.jsx("div",{className:"flex-1 h-1.5 bg-muted rounded-full relative",children:t.jsx("div",{className:"absolute top-0 bottom-0 bg-primary/40 rounded-full min-w-[4px]",style:{left:`${$*100}%`,width:`${D*100}%`}})})]})}),t.jsx("div",{className:"flex items-center gap-3 mt-3 pt-2 border-t flex-wrap",children:c?null:Array.from(new Set(e.flatMap(se=>se.labels))).sort().map(se=>t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm",style:{backgroundColor:Xq([se])}}),t.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:se})]},se))})]})})]})]})})}function H4(){const{user:e}=Gi(),[,s]=Ia(),{toast:r}=Hs();u.useEffect(()=>{fg(()=>import("./hls-DuDM7LWb.js"),[]).catch(()=>{})},[]);const n=hle(),a=new URLSearchParams(n),i=a.get("siteId")||void 0,[o,l]=u.useState(i),{data:c}=lCe(o),d=!!c?.privacyBlocked,p=new URLSearchParams(n).get("siteId")||"none",[g,v]=u.useState("local"),[b,y]=u.useState(p),[w,j]=u.useState("all"),[x,C]=u.useState("all"),[k,S]=u.useState(1),[_,A]=u.useState(()=>{const I=new Date;return I.setTime(I.getTime()-3600*1e3),I}),[T,M]=u.useState(()=>new Date),[R,D]=u.useState(!1),[$,O]=u.useState(!1),[q,V]=u.useState(()=>{const I=new Date;return I.setHours(0,0,0,0),I}),[K,G]=u.useState(!1),[z,Z]=u.useState(null),ee=u.useRef(!1);u.useEffect(()=>{if(ee.current)return;const I=a.get("detection"),ie=a.get("camera"),Le=a.get("start");if(!I||!ie||!Le)return;const Ye=parseFloat(Le),Mt=parseFloat(a.get("end")||"")||Ye+30,_s=a.get("label")||"object",ks={id:`dl-${I}`,camera:ie,label:_s,objects:[_s],start_time:Ye,end_time:Mt,has_clip:!0,severity:"alert",detections:[I],zones:[]};Z(ks),ee.current=!0},[a]);const[Q,Y]=u.useState(null),oe=u.useRef({}),[he,je]=u.useState(0),[pe,le]=u.useState(!1),[ue,fe]=u.useState(null),H=u.useRef(null),se=u.useRef(null),[me,ge]=u.useState(-1),[be,ce]=u.useState(0),[Pe,et]=u.useState([void 0]),[$e,bt]=u.useState(null),[Ae,Be]=u.useState(null),J=u.useRef(null);u.useEffect(()=>()=>{J.current&&(clearTimeout(J.current),J.current=null)},[Ae?.id]);const ae=Er(),[we,Qe]=u.useState([]),[ye,te]=u.useState(!1),[Ue,We]=u.useState(0),[St,It]=u.useState([]),[ns,dt]=u.useState(!1);u.useEffect(()=>{dt(!1)},[z?.id,Ae?.id,he]),u.useEffect(()=>{if(!$e?.id){Qe([]),We(0),It([]);return}We(0),It([]),te(!1),Qe([]);let I=!1,ie=null,Le=0;const Ye=Date.now(),Mt=$e.startTime?new Date($e.startTime).getTime():0,_s=Mt>0&&Date.now()-Mt<600*1e3,ks=1e4,Ts=2*6e4,ls=()=>{_s&&Date.now()-Ye<Ts&&(ie=setTimeout(ps,ks))},ps=async()=>{Le++;try{const Kr=await fetch(`/api/cloud-recordings/${$e.id}`,{credentials:"include",cache:"no-store",priority:"high"});if(!Kr.ok){if(I)return;Le===1&&Qe([]),ls();return}const Is=await Kr.json();if(I)return;const kn=Is;bt(ri=>ri&&ri.id===kn.id?{...ri,...kn}:ri);const an=Array.isArray(kn.chunks)&&kn.chunks.length>0?kn.chunks.map(ri=>({id:ri.id,proxyUrl:ri.proxyUrl,clipPath:ri.clipPath})):[];if(an.length>0){Qe(an),It([]);return}Le===1&&Qe([]),ls()}catch{if(I)return;Le===1&&Qe([]),ls()}};return ps(),()=>{I=!0,ie&&clearTimeout(ie)}},[$e?.id]);const[Qt,Re]=u.useState(!1),[pt,Ft]=u.useState(null),[Es,Ge]=u.useState(!1),ft=u.useRef(null);u.useEffect(()=>{Re(!1),Ft(null),Ge(!1),ft.current=null},[$e?.id]);const[He,zt]=u.useState(null),fs=u.useRef(null),Ce=u.useRef(null);u.useEffect(()=>{const I=Ae??z,ie=I?null:$e,Le=b,Ye=I?.camera??ie?.cameraName,Mt=I?.id??ie?.id;if(!Mt||!Ye||Le==="none"){Ce.current?.clear(),Ce.current=null;return}const _s=I?"local":"cloud",ks=0;Ce.current?.clear();const Ts=lC({category:"playback",siteId:Le,camera:Ye,eventId:String(Mt),source:_s,playbackTime:ks});Ce.current=Ts;const ls=I?H.current:fs.current,ps=()=>Ts.update({category:"playback",siteId:Le,camera:Ye,eventId:String(Mt),source:_s,playbackTime:ls?.currentTime??ks});return ls?.addEventListener("timeupdate",ps),ls?.addEventListener("play",ps),()=>{ls?.removeEventListener("timeupdate",ps),ls?.removeEventListener("play",ps),Ts.clear(),
556Ce.current===Ts&&(Ce.current=null)}},[Ae?.id,z?.id,$e?.id,b]);const Dt=u.useRef(null),ne=u.useRef(null),[Oe,De]=u.useState(-1),[jt,Ct]=u.useState(null);oCe(null);const[Lt,xr]=u.useState(!1),[qe,Xt]=u.useState(null),[Ut,gt]=u.useState(null),[es,br]=u.useState(!1),[fr,xn]=u.useState(null),[Br,Pi]=u.useState(null),[Qn,ii]=u.useState(null),[ua,Ua]=u.useState(7200),[Ln,Ir]=u.useState("all"),Hr=u.useRef(null),[lt,Rt]=u.useState(""),[At,Ht]=u.useState(null),vr=I=>I>=100?"bg-green-500 text-white border-transparent hover:bg-green-500":I>=90?"bg-lime-500 text-white border-transparent hover:bg-lime-500":I>=75?"bg-yellow-500 text-black border-transparent hover:bg-yellow-500":"bg-red-500 text-white border-transparent hover:bg-red-500",[mn,hr]=u.useState(!1),[Sn,Sr]=u.useState(null),Os=u.useRef(null),ur=u.useRef(null);u.useEffect(()=>()=>{ur.current?.clear(),ur.current=null},[]);const[nr,qr]=u.useState(null),So=u.useRef(null),Xn=ze({queryKey:["/api/visual-search/status"],staleTime:300*1e3}),Jr=ze({queryKey:["/api/sites",b,"ai-plus","status"],queryFn:()=>fetch(`/api/sites/${b}/ai-plus/status`).then(I=>I.json()),enabled:b!=="none",staleTime:30*1e3,refetchOnWindowFocus:!0}),vn=(Jr.data?.aiPlusEnabled??!1)&&(Jr.data?.hasSubscription??!1),Mn=(Xn.data?.available??!1)&&vn,Dr=Jr.data?.dailyUsed??0,en=Jr.data?.dailyLimit??0,Co=Jr.data?.dailyRemaining??0,Oa=vn&&en>0&&Co<=0,ku=u.useMemo(()=>{if(!z)return"";const I=z.detections?.[0],ie=new URLSearchParams({reviewId:z.id,camera:z.camera,start:String(z.start_time),end:String(z.end_time||z.start_time+30)});return I&&ie.set("detection",I),`/api/local-recordings/${b}/clip.mp4?${ie.toString()}`},[z?.id,b]),ma=u.useMemo(()=>{if(!Ae)return"";const I=Ae.detections?.[0],ie=new URLSearchParams({reviewId:Ae.id,camera:Ae.camera,start:String(Ae.start_time),end:String(Ae.end_time||Ae.start_time+30)});return I&&ie.set("detection",I),`/api/local-recordings/${b}/clip.mp4?${ie.toString()}`},[Ae?.id,b]),Cn=ze({queryKey:["/api/video-token"],staleTime:1800*1e3,gcTime:0,refetchOnWindowFocus:!0}).data?.token??"",Lr=u.useRef(Cn);Lr.current=Cn;const Vr=we.length?we[Math.min(Ue,we.length-1)]:null,Nc=!!Vr?.proxyUrl?.includes(".m3u8"),Ds=u.useMemo(()=>typeof document>"u"?!1:!!document.createElement("video").canPlayType("application/vnd.apple.mpegurl"),[]),nl=Nc&&!Ds,co=u.useMemo(()=>{if(nl||!$e)return;const I=Vr?.proxyUrl||`/api/cloud-recordings/${$e.id}/clip.mp4`,ie=[];return Lr.current&&ie.push(`vt=${Lr.current}`),Es&&I.includes("/api/cloud-recordings/")&&ie.push("transcode=1"),ie.length?`${I}?${ie.join("&")}`:I},[$e?.id,Vr?.proxyUrl,nl,!!Cn,Es]);u.useEffect(()=>{const I=fs.current;if(!I)return;if(Dt.current){try{Dt.current.destroy()}catch{}Dt.current=null}if(!$e||!Vr)return;const ie=Vr.proxyUrl||`/api/cloud-recordings/${$e.id}/clip.mp4`;if(!ie.includes(".m3u8")||Ds)return;let Le=!1;return fg(async()=>{const{default:Ye}=await import("./hls-DuDM7LWb.js");return{default:Ye}},[]).then(({default:Ye})=>{if(Le||!Ye.isSupported())return;const Mt=new Ye({enableWorker:!1});Dt.current=Mt,Mt.loadSource(`${ie}${Lr.current?`?vt=${Lr.current}`:""}`),Mt.attachMedia(I),Mt.on(Ye.Events.ERROR,(_s,ks)=>{if(ks?.fatal)if(St.length>0){try{Mt.destroy()}catch{}Dt.current=null,Qe(St),It([]),We(0)}else Re(!0)})}).catch(()=>{}),()=>{if(Le=!0,Dt.current){try{Dt.current.destroy()}catch{}Dt.current=null}}},[$e?.id,Vr?.proxyUrl,Ds,St,!!Cn]),u.useEffect(()=>{const I=fs.current;if(!(!I||!$e))return N_(I,"[cloud]")},[$e?.id,Ue,Vr?.proxyUrl]);const fn=ze({queryKey:["/api/user/settings"]}),[bi,Sc]=u.useState(!1),ra=u.useRef(null);u.useEffect(()=>{fn.data&&ra.current===null&&Sc(fn.data.autoPlayEnabled??!0)},[fn.data]),u.useEffect(()=>{if(fn.data&&ra.current!==null){const I=fn.data.autoPlayEnabled??!0;I!==ra.current&&(Sc(I),ra.current=null)}},[fn.data]);const za=Et({mutationFn:I=>Ze("PATCH","/api/user/settings",{autoPlayEnabled:I}),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/user/settings"]})},onError:()=>{ra.current=null,Sc(fn.data?.autoPlayEnabled??!0)}}),Xl=u.useCallback(()=>{const I=!bi;ra.current=I,Sc(I),za.mutate(I)},[bi,za]),[Ei,na]=u.useState(0),[Ur,Da]=u.useState([]),Xc=!1,[oi,Zl]=u.useState(!1),[al,Zc]=u.useState(""),[il,Jl]=u.useState(!1),[Uo,Cc]=u.useState(new Map),[Ti,oa]=u.useState(!1),[ja,Tr]=u.useState([]),[zo,ha]=u.useState(""),[Jc,ol]=u.useState(!1),[zn,ll]=u.useState(new Map),[yn,cl]=u.useState(!1),[ko,dl]=u.useState([]),[Cl,Ho]=u.useState({done:0,total:0}),Ha=u.useRef(null),Ai=u.useRef([]),[Bs,ti]=u.useState(()=>{if(a.get("view")==="events"||typeof window<"u"&&window.innerWidth<640)return"events";if(!localStorage.getItem("truvios-recordings-classic-default-v1"))return localStorage.setItem("truvios-recordings-classic-default-v1","1"),localStorage.setItem("truvios-recordings-view-mode","classic"),"classic";const I=localStorage.getItem("truvios-recordings-view-mode");return I==="timeline"?"timeline":I==="events"?"events":"classic"}),ec=u.useRef(a.get("view")==="events"),uo=Bs==="classic"?256:16,[Na,La]=u.useState("desc"),kc=u.useMemo(()=>
556{if(!At)return null;const I=[...At];return I.sort((ie,Le)=>Na==="asc"?ie.startTime-Le.startTime:Le.startTime-ie.startTime),I},[At,Na]),_c=u.useMemo(()=>{if(!Ut)return null;const I=[...Ut];return I.sort((ie,Le)=>Na==="asc"?ie.startTime-Le.startTime:Le.startTime-ie.startTime),I},[Ut,Na]),[tn,qo]=u.useState(!1),[Hn,mo]=u.useState([]),[qn,_o]=u.useState([]),[tm,Pd]=u.useState(!1),[wi,tc]=u.useState(typeof window<"u"&&window.innerWidth<640),[ul,Pc]=u.useState([]),[_u,Ec]=u.useState(!1),Tc=u.useRef(null);u.useEffect(()=>{const I=()=>{const ie=window.innerWidth<640;tc(ie),ie&&Bs==="timeline"&&ti("events")};return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[Bs]),u.useEffect(()=>{ec.current&&Bs==="events"||(ec.current=!1,localStorage.setItem("truvios-recordings-view-mode",Bs))},[Bs]);const[Ea,Ac]=u.useState(()=>{const I=new Date;return I.setHours(0,0,0,0),I}),[Ed,ed]=u.useState(!1),td=ze({queryKey:["/api/companies"]}).data?.flatMap(I=>I.sites)||[],Vo=b!=="none"?td.find(I=>I.id===b):null,nn=Vo?.edgeDevice?.id,Pu=ze({queryKey:["/api/edge-devices",nn,"person-labels"],queryFn:async()=>{if(!nn)return{labels:[]};const I=await fetch(`/api/edge-devices/${nn}/person-labels`,{credentials:"include"});return I.ok?I.json():{labels:[]}},enabled:!!nn&&vn,staleTime:60*1e3}).data?.labels||[],sd=I=>{Rt(ie=>{const Le=(ie||"").trim();return new RegExp(`(^|[^a-z0-9_])${I.replace(/[.*+?^${}()|[\\]\\\\]/g,"\\$&")}([^a-z0-9_]|$)`,"i").test(Le)?ie:Le.length===0?I:`${Le} ${I}`})},sc=ze({queryKey:["/api/cloud-sync-status",nn],queryFn:async()=>{if(!nn)return{syncEnabled:!1};const I=await fetch(`/api/cloud-sync-status/${nn}`,{credentials:"include"});return I.ok?I.json():{syncEnabled:!1}},enabled:!!nn}),Wo=sc.data?.syncEnabled??!1,Mh=sc.data?.syncMode||"continuous",Td=ze({queryKey:["/api/device-notifications/status"],refetchInterval:3e4}),qa=(()=>{if(!nn||!Td.data)return!1;const I=Td.data.find(ie=>ie.edgeDeviceId===nn&&!ie.cameraName);return!I||I.monitoringDisabled?!1:I.isOnline===!1})();u.useEffect(()=>{Vo?.edgeDevice?Zl(Vo.edgeDevice.colorMatchingEnabled??!1):Zl(!1),Zc(""),oa(!1),Jl(!1),Cc(new Map),Tr([]),$t.current&&$t.current.abort()},[nn,Vo?.edgeDevice?.colorMatchingEnabled]),u.useEffect(()=>{!Ur.some(I=>I!=="motion")&&Ti&&Ii()},[Ur]);const Qs=["red","orange","brown","yellow","green","blue","purple","pink","black","white"],rc={red:"#ef4444",orange:"#f97316",brown:"#92400e",yellow:"#eab308",green:"#22c55e",blue:"#3b82f6",purple:"#a855f7",pink:"#ec4899",black:"#1a1a1a",white:"#f5f5f5"},Eu={black:["black","dark gray"],white:["white","light gray"],blue:["blue","cyan"]},Po=u.useRef({vs:()=>{},ts:()=>{}}),la=u.useCallback(I=>{Po.current.vs(),Po.current.ts();const ie=new Date,Le=new Date(ie.getTime()-I*60*60*1e3);A(Le),M(ie),S(I),gi()},[]),ml=(()=>{if(b==="none")return"";const I=new URLSearchParams;if(qn.length>0&&I.set("cameras",qn.join(",")),x!=="all"&&I.set("severity",x),Ur.length>0&&I.set("labels",Ur.join(",")),_&&I.set("after",String(Math.floor(_.getTime()/1e3))),T&&I.set("before",String(Math.floor(T.getTime()/1e3))),I.set("limit",String(fx)),I.set("sort",Na),Na==="asc")I.set("offset",String(be*fx));else{const ie=Pe[be];if(ie){const Le=parseFloat(ie),Ye=T?Math.floor(T.getTime()/1e3):1/0;I.set("before",String(Math.min(Le,Ye)))}}return`/api/local-recordings/${b}/events?${I.toString()}`})(),{data:rd}=ze({queryKey:["/api/sites",b,"record-options"],queryFn:async()=>{const I=await fetch(`/api/sites/${b}/record-options`,{credentials:"include"});return I.ok?I.json():{preCaptureSec:5,postCaptureSec:5}},enabled:b!=="none",staleTime:6e4}),{data:Mc}=ze({queryKey:["/api/sites",b,"cloud-preferences"],queryFn:async()=>{if(b==="none")return{hideLocalRecordings:!1};const I=await fetch(`/api/sites/${b}/cloud-preferences`,{credentials:"include"});return I.ok?I.json():{hideLocalRecordings:!1}},enabled:b!=="none",staleTime:3e4}),{data:Mi}=ze({queryKey:["/api/sites",b,"recording-days"],queryFn:async()=>{const I=await fetch(`/api/sites/${b}/recording-days`,{credentials:"include"});return I.ok?I.json():{localDays:[],cloudDays:[]}},enabled:b!=="none"&&Bs==="classic",staleTime:5*6e4}),nc=u.useMemo(()=>new Set(Mi?.localDays??[]),[Mi]),kl=u.useMemo(()=>new Set(Mi?.cloudDays??[]),[Mi]),Ri=u.useMemo(()=>new Set([...Mi?.localDays??[],...Mi?.cloudDays??[]]),[Mi]),ho=Mc?.hybridPlaybackActive??Mc?.hybridRetrievalEnabled??!1,ac=Mc?.hybridDistinguishActive??Mc?.distinguishHybridSources??!1,tr=ho&&g==="cloud",_l=u.useRef(tr);u.useEffect(()=>{_l.current=tr},[tr]);const{data:nd}=ze({queryKey:["/api/user/role"],enabled:!!e,staleTime:6e4}),hl=nd?.role==="superadmin",Rc=Mc?.hideLocalRecordings??!1,sm=hl&&typeof window<"u"&&localStorage.getItem(`superadmin_showlocal_${b}`)==="true",Eo=Rc&&!sm;u.useEffect(()=>{Eo&&g==="local"&&v("cloud")},[Eo,b]);const pl=ze({queryKey:["/api/local-recordings",b,qn.join(","),x,Ur,_,T,be,Na],queryFn:async()=>{const I=await pC("local","events list",ml,{credentials:"include"});if(!I.ok)throw $o("local",`events list failed: HTTP ${I.status}`,{url:ml}),new Error("Failed to fetch events");const ie=await I.json();return $o("local",`events list ok: ${ie?.events?.length??0} events (total=${ie?.total??"?"})`),ie},enabled:b!=="none"&&g==="local"&&Bs==="events"&&qn.length>0}),U=ze({queryKey:["/api/recordings-cameras",b],queryFn:async()=>{try{const Ye=await fetch(`/api/local-recordings/${b}/cameras`,{credentials:"include"});if(Ye.ok)return Ye.json();if(Ye.status!==403)throw new Error(`Failed to fetch cameras: ${Ye.status}`)}catch{}const I=await fetch(`/api/sites/${b}/cameras`,{credentials:"include"});if(!I.ok)throw new Error(`Failed to fetch cameras: ${I.status}`);const ie=await I.json();return{cameras:(Array.isArray(ie?.cameras)?ie.cameras:[]).filter(Ye=>Ye?.enabled!==!1).map(Ye=>({name:Ye.name,displayName:Ye.displayName||Ye.name}))}},enabled:b!=="none"}
556),qt=ze({queryKey:["/api/cloud-recording-labels",nn],queryFn:async()=>{const I=new URLSearchParams;nn&&I.set("edgeDeviceId",nn);const ie=await fetch(`/api/cloud-recording-labels?${I.toString()}`,{credentials:"include"});return ie.ok?ie.json():{labels:[]}},enabled:!!nn}).data?.labels||[],Zt=["/api/cloud-recordings",nn,b,qn.join(","),Ur.join(","),Xc,x,_?.toISOString()??null,T?.toISOString()??null,Ei,Na],Rs=ze({queryKey:Zt,queryFn:async({queryKey:I})=>{const[,ie,Le,Ye,Mt,_s,ks,Ts,ls,ps,Kr]=I,Is=new URLSearchParams;ie&&Is.set("edgeDeviceId",String(ie)),Le&&Le!=="none"&&Is.set("siteId",String(Le)),Ye&&Is.set("cameraNames",String(Ye)),Mt&&(Is.set("labels",String(Mt)),_s&&Is.set("matchAll","true")),ks==="alert"?Is.set("excludeMotion","true"):ks==="detection"&&Is.set("onlyMotion","true"),Ts&&Is.set("startDate",String(Ts)),ls&&Is.set("endDate",String(ls)),Is.set("limit",String(Hv)),Is.set("offset",String(Number(ps)*Hv)),Is.set("sort",String(Kr));const kn=`/api/cloud-recordings?${Is.toString()}`,an=await pC("cloud","cloud list",kn,{credentials:"include"});if(!an.ok)throw $o("cloud",`cloud list failed: HTTP ${an.status}`,{url:kn}),new Error("Failed to fetch cloud recordings");const ri=await an.json();return $o("cloud",`cloud list ok: ${ri?.recordings?.length??0} recordings (total=${ri?.total??"?"})`),ri},enabled:g==="cloud"&&b!=="none"&&Wo&&Bs==="events"&&qn.length>0,staleTime:3e4}),ir=pl.data?.events||[],Vn=(U.data?.cameras||[]).filter(I=>!c?.restrictedCameras?.length||!c.restrictedCameras.includes(I.name)),Ns=Vn.map(I=>I.name);u.useEffect(()=>{Ns.length>0&&qn.length===0&&_o([...Ns])},[Ns.length]);const or=new Map(Vn.map(I=>[I.name,I.displayName]));ir.forEach(I=>{I.displayName&&!or.has(I.camera)&&or.set(I.camera,I.displayName)});const os=pl.data?.total,nt=Na==="asc"&&os!==void 0?(be+1)*fx<os:ir.length===fx,tt=be>0,$t=u.useRef(null),[kr,Wn]=u.useState({done:0,total:0}),zr=fn.data?.aiColorThreshold??15,$n=fn.data?.aiConfidenceThreshold??.48,Va=u.useCallback(async I=>{if(!nn||!I||b==="none")return;$t.current&&$t.current.abort();const ie=new AbortController;$t.current=ie,Zc(I),Jl(!0),oa(!0),Cc(new Map),Tr([]),Wn({done:0,total:0});const Le=new Map,Ye=[],Mt=10;let _s=0,ks=T?Math.floor(T.getTime()/1e3):null;const Ts=_?Math.floor(_.getTime()/1e3):null;for(;!ie.signal.aborted;){const ls=new URLSearchParams;qn.length>0&&ls.set("cameras",qn.join(",")),x!=="all"&&ls.set("severity",x),Ur.length>0&&ls.set("labels",Ur.join(",")),Ts&&ls.set("after",String(Ts)),ks&&ls.set("before",String(ks)),ls.set("limit",String(fx));let ps=[];try{const Is=await fetch(`/api/local-recordings/${b}/events?${ls.toString()}`,{credentials:"include",signal:ie.signal});if(!Is.ok)break;ps=(await Is.json()).events||[]}catch{break}if(ie.signal.aborted||ps.length===0)break;for(let Is=0;Is<ps.length;Is+=Mt){if(ie.signal.aborted)return;const kn=ps.slice(Is,Is+Mt);if(await Promise.all(kn.map(async an=>{if(ie.signal.aborted)return;const ri=an.id,Id=an.detections?.[0],Zg=new URLSearchParams;Id&&Zg.set("detectionId",Id);try{const Ep=await fetch(`/api/edge-devices/${nn}/event-colors/${ri}?${Zg}`,{credentials:"include",signal:ie.signal});if(!Ep.ok)return;const $f=await Ep.json();$f.colors&&$f.colors.some(Ff=>Ff.color===I&&Ff.percentage>=zr)&&(Le.set(an.id,$f.colors),Ye.push(an))}catch{}})),ie.signal.aborted)return;_s+=kn.length,Cc(new Map(Le)),Tr([...Ye]),Wn({done:_s,total:_s})}if(ps.length<fx)break;ks=ps[ps.length-1].start_time}ie.signal.aborted||Jl(!1)},[nn,b,qn,x,Ur,_,T,zr]),Yi=()=>{$t.current&&$t.current.abort(),Jl(!1)},Ii=()=>{$t.current&&$t.current.abort(),Zc(""),oa(!1),Jl(!1),Cc(new Map),Tr([]),Wn({done:0,total:0})},To=u.useCallback(async I=>{if(!I||!nn||b==="none")return;Ha.current&&Ha.current.abort();const ie=new AbortController;Ha.current=ie,ha(I),ol(!0),cl(!0),ll(new Map),dl([]),Ho({done:0,total:0});const Le=new Map,Ye=[],Mt=10,_s=Eu[I]??[I];if(Bs==="timeline"||Bs==="classic"){const ks=Ai.current;if(ks.length===0){ol(!1);return}Ho({done:0,total:ks.length});for(let Ts=0;Ts<ks.length;Ts+=Mt){if(ie.signal.aborted)return;const ls=ks.slice(Ts,Ts+Mt);if(await Promise.all(ls.map(async ps=>
556{if(!ie.signal.aborted)try{const Kr=await fetch(`/api/cloud-recordings/${ps.id}/colors`,{credentials:"include",signal:ie.signal});if(!Kr.ok)return;const Is=await Kr.json();Is.colors&&Is.colors.some(kn=>_s.includes(kn.color)&&kn.percentage>=zr)&&(Le.set(String(ps.id),Is.colors),Ye.push(ps))}catch{}})),ie.signal.aborted)return;ll(new Map(Le)),dl([...Ye]),Ho({done:Math.min(Ts+Mt,ks.length),total:ks.length})}}else{let ks=0,Ts=0;for(;!ie.signal.aborted;){const ls=new URLSearchParams;nn&&ls.set("edgeDeviceId",nn),b!=="none"&&ls.set("siteId",b),qn.length>0&&ls.set("cameraNames",qn.join(",")),Ur.length>0&&ls.set("labels",Ur.join(",")),x==="alert"?ls.set("excludeMotion","true"):x==="detection"&&ls.set("onlyMotion","true"),_&&ls.set("startDate",_.toISOString()),T&&ls.set("endDate",T.toISOString()),ls.set("limit",String(Hv)),ls.set("offset",String(Ts));let ps=[];try{const Kr=await fetch(`/api/cloud-recordings?${ls.toString()}`,{credentials:"include",signal:ie.signal});if(!Kr.ok)break;ps=(await Kr.json()).recordings||[]}catch{break}if(ie.signal.aborted||ps.length===0)break;for(let Kr=0;Kr<ps.length;Kr+=Mt){if(ie.signal.aborted)return;const Is=ps.slice(Kr,Kr+Mt);if(await Promise.all(Is.map(async kn=>{if(!ie.signal.aborted)try{const an=await fetch(`/api/cloud-recordings/${kn.id}/colors`,{credentials:"include",signal:ie.signal});if(!an.ok)return;const ri=await an.json();ri.colors&&ri.colors.some(Id=>_s.includes(Id.color)&&Id.percentage>=zr)&&(Le.set(String(kn.id),ri.colors),Ye.push(kn))}catch{}})),ie.signal.aborted)return;ks+=Is.length,ll(new Map(Le)),dl([...Ye]),Ho({done:ks,total:ks})}if(ps.length<Hv)break;Ts+=Hv}}ie.signal.aborted||ol(!1)},[Bs,nn,b,qn,x,Ur,Xc,_,T,zr]),Qi=()=>{Ha.current&&Ha.current.abort(),ol(!1)},Ls=()=>{Ha.current&&Ha.current.abort(),ha(""),cl(!1),ol(!1),ll(new Map),dl([]),Ho({done:0,total:0})},Or=u.useRef("");u.useEffect(()=>{const I=Ns.join(",");Ns.length>0&&I!==Or.current&&(Or.current&&(Po.current.vs(),Po.current.ts()),Or.current=I)},[Ns]);const Pl=u.useRef("");u.useEffect(()=>{const I=qn.join(",");I!==Pl.current&&(Pl.current&&(Po.current.vs(),Po.current.ts()),Pl.current=I)},[qn]),u.useEffect(()=>{wi&&(be===0?Pc(ir):ir.length>0&&(Pc(I=>{const ie=new Set(I.map(Ye=>Ye.id)),Le=ir.filter(Ye=>!ie.has(Ye.id));return[...I,...Le]}),Ec(!1)))},[ir,be,wi]),u.useEffect(()=>{if(!wi||!Tc.current)return;const I=Tc.current,ie=new IntersectionObserver(Le=>{Le[0].isIntersecting&&nt&&!pl.isLoading&&!_u&&(Ec(!0),Np())},{threshold:.1});return ie.observe(I),()=>ie.disconnect()},[wi,nt,pl.isLoading,_u,ir]);const Oi=Rs.data?.recordings||[],ad=Rs.data?.total||0,ji=Math.ceil(ad/Hv),Wa=u.useMemo(()=>!$n||$n<=0?Oi:Oi.filter(I=>I.recordingType!=="event"||!I.label||I.score==null||I.score<=0?!0:I.score>=$n),[Oi,$n]),Tu=ze({queryKey:["/api/local-recordings",b,"labels"],queryFn:async()=>{const I=await fetch(`/api/local-recordings/${b}/labels`,{credentials:"include"});return I.ok?I.json():{labels:["motion"]}},enabled:b!=="none",staleTime:6e4}).data?.labels||[],id=I=>Ur.length===0?I:I.filter(ie=>{const Le=ie.objects&&ie.objects.length>0?ie.objects:ie.label==="motion"?["motion"]:[];return Le.length===0?!1:Ur.some(Ye=>Le.includes(Ye))}),El=id(ir),Di=u.useMemo(()=>!$n||$n<=0?El:El.filter(I=>I.label==="motion"||I.severity!=="alert"||I.score==null||I.score<=0?!0:I.score>=$n),[El,$n]),Xi=u.useMemo(()=>{if(!Ti||!al)return Di;const I=ja.length>0?ja:Di,ie=Ur.filter(Le=>Le!=="motion");return I.filter(Le=>{if(ie.length>0){const _s=Le.objects||[],ks=Le.label||"";if(!ie.some(ls=>_s.includes(ls)||ks.split(", ").includes(ls)))return!1}const Ye=Uo.get(Le.id);if(!Ye)return!1;const Mt=Eu[al]??[al];return Ye.some(_s=>Mt.includes(_s.color)&&_s.percentage>=zr)})},[Di,Ti,al,Uo,ja,Ur,zr]),tu=u.useMemo(()=>!yn||!zo?Wa:(ko.length>0?ko:Wa).filter(ie=>{const Le=zn.get(String(ie.id));if(!Le)return!1;const Ye=Eu[zo]??[zo];return Le.some(Mt=>Ye.includes(Mt.color)&&Mt.percentage>=zr)}),[Wa,ko,yn,zo,zn,zr]),bn=u.useMemo(()=>Xi,[Xi]),Tl=u.useMemo(()=>yn?tu:Wa,[Wa,tu,yn]),od=u.useMemo(()=>Ti&&al?bn:id(ul),[Ti,al,bn,ul,Ur,Xc]),ld=()=>{if(b==="none")return"";const I=new URLSearchParams;x!=="all"&&I.set("severity",x),Ur.length>0&&I.set("labels",Ur.join(",")),Hn.length>0&&I.set("cameras",Hn.join(","));const ie=new Date(Ea);ie.setHours(0,0,0,0);const Le=new Date(Ea);Le.setHours(23,59,59,999);const Ye=new Date;return I.set("after",String(Math.floor(ie.getTime()/1e3))),I.set("before",String(Math.floor(Math.min(Le.getTime(),Ye.getTime())/1e3))),I.set("limit","5000"),`/api/local-recordings/${b}/events?${I.toString()}`},Al=ze({queryKey:["/api/local-recordings-timeline",b,x,Ur,Ea.toISOString(),Hn.join(",")],queryFn:async()=>{const I=ld(),ie=await fetch(I,{credentials:"include"});if(!ie.ok)throw new Error("Failed to fetch timeline events");return ie.json()},enabled:b!=="none"&&(Bs==="timeline"||Bs==="classic")&&Hn.length>0&&(g==="local"||tr),staleTime:300*1e3,gcTime:600*1e3}),Ni=Al.data?.events||[],rm=Hn.length>0&&Hn.length<Ns.length?Ni.filter(I=>Hn.includes(I.camera)):Ni,Ko=Ur.length===0?rm:rm.filter(I=>{const ie=I.objects&&I.objects.length>0?I.objects:I.label==="motion"?["motion"]:[];return ie.length===0?!1:Ur.some(Le=>ie.includes(Le))}),Ad=Ti&&al?Ko.filter(I=>Xi.some(ie=>ie.id===I.id)):Ko,Ml=u.useMemo(()=>Ad.map(I=>{const ie=I.start_time*1e3,Le=(I.end_time||I.start_time+10)*1e3,Ye=I.objects&&I.objects.length>0?I.objects:I.label==="motion"?["motion"]:[];return{id:I.id,camera:I.camera,startMs:ie,endMs:Le,labels:Ye,source:"local",originalEvent:I}}),[Ad]),qg=()=>{const I=new URLSearchParams;nn&&I.set("edgeDeviceId",nn),b!=="none"&&I.set("siteId",b),Hn.length>0&&I.set("cameraNames",Hn.join(",")),x==="alert"?I.set("excludeMotion","true"):x==="detection"&&I.set("onlyM
556otion","true");const ie=new Date(Ea);ie.setHours(0,0,0,0);const Le=new Date(Ea);return Le.setHours(23,59,59,999),I.set("startDate",ie.toISOString()),I.set("endDate",Le.toISOString()),I.set("noLimit","true"),I.set("lite","true"),`/api/cloud-recordings?${I.toString()}`},zm=ze({queryKey:["/api/cloud-recordings-timeline",nn,b,x,Ea.toISOString(),Hn.join(",")],queryFn:async()=>{const I=await fetch(qg(),{credentials:"include"});if(!I.ok)throw new Error("Failed to fetch cloud timeline recordings");return I.json()},enabled:g==="cloud"&&b!=="none"&&Wo&&(Bs==="timeline"||Bs==="classic")&&Hn.length>0}),Au=zm.data?.recordings||[],Ih=u.useMemo(()=>c0(Au),[Au]),cd=Au.filter(I=>!Ih.has(I.id)),Oh=Hn.length>0&&Hn.length<Ns.length?cd.filter(I=>Hn.includes(I.cameraName)):cd,Zi=Ur.length===0?Oh:Oh.filter(I=>{if(!I.label)return!1;const ie=I.label.split(",").map(Le=>Le.trim().toLowerCase());return Ur.some(Le=>ie.includes(Le.toLowerCase()))});Ai.current=Zi;const Hm=u.useMemo(()=>!yn||!zo?null:new Set(ko.map(I=>String(I.id))),[yn,zo,ko]),Mu=Hm?Zi.filter(I=>Hm.has(String(I.id))):Zi,Oc=u.useMemo(()=>Mu.map(I=>({id:String(I.id),camera:I.cameraName,startMs:new Date(I.startTime).getTime(),endMs:I.endTime?new Date(I.endTime).getTime():new Date(I.startTime).getTime()+3e4,labels:I.label?I.label.split(",").map(ie=>ie.trim()):[],source:"cloud",thumbnailUrl:I.thumbnailPath||null,originalRecording:I})),[Mu]),nm=Al.isError,yp=zm.isError,Ru=u.useMemo(()=>{if(!tr)return[];const I=yp?[]:Oc;return Eo?D1(I,[],Fp):(yp&&console.warn("[HybridRetrieval] cloud availability request failed — showing local only"),nm?(console.warn("[HybridRetrieval] local availability request failed — cloud stays playable, local-only periods marked unavailable"),D1(I,Ml,Fp,{localUnavailable:!0})):D1(I,Ml,Fp))},[tr,Oc,Ml,yp,nm,Eo]),su=u.useRef(new Set),po=u.useRef(null),Dh=u.useRef(null);u.useEffect(()=>{Dh.current=z||Ae?"local":$e?"cloud":null},[z,Ae,$e]),u.useEffect(()=>{Ae&&($e||z)&&Be(null)},[$e,z,Ae]);const Rl=u.useCallback((I,ie)=>{if(I.source==="unavailable")return;const Le=ie?.fresh!==!0,Ye=I.source==="local"&&I.originalEvent?I.originalEvent.start_time*1e3:null;po.current=Le?PFe(I,ie?.seekToMs??null,Ye):null,I.source==="local"&&I.originalEvent?(Re(!1),bt(null),Y(null),fe(null),_l.current?(Z(null),Be(I.originalEvent)):(Be(null),Z(I.originalEvent))):I.source==="cloud"&&I.originalRecording&&(Y(null),Z(null),Be(null),Re(!1),bt(I.originalRecording)),Dh.current=I.source},[]),Il=u.useCallback(I=>{const ie=po.current,Le=Ae??z;if(ie==null||!Le)return;po.current=null;const Ye=I.currentTarget,Mt=Math.floor(Le.start_time)-5;if(isFinite(Ye.duration)&&Ye.duration>.5&&ie/1e3-Mt>Ye.duration+2){console.log(`[HybridRetrieval] stale pending seek ignored (target beyond clip) camera=${Le.camera}`);return}const _s=EFe({targetMs:ie,clipStartSec:Mt,clipDurationSec:Ye.duration});_s!=null&&(Ye.currentTime=_s,console.log(`[HybridRetrieval] seek to preserve position offset=${_s.toFixed(1)}s camera=${Le.camera}`))},[z,Ae]),Go=u.useCallback(I=>{su.current.clear(),Rl(I,{fresh:!0})},[Rl]),fl=u.useCallback(I=>{su.current.clear(),Rl(I)},[Rl]),Ol=u.useCallback((I,ie,Le)=>_Fe(Ru,I,ie,Le,Fp),[Ru]);u.useCallback((I,ie,Le)=>xae(I==="cloud"?Oc:Ml,ie,Le,Fp),[Oc,Ml]);const Af=u.useRef([]),gl=u.useRef([]),Dc=u.useCallback((I,ie)=>{if(Bs==="timeline"||Bs==="classic"){const ks=(g==="local"?Ml:[]).filter(ps=>ps.camera===I.camera&&ps.originalEvent).sort((ps,Kr)=>ps.startMs-Kr.startMs),Ts=ks.findIndex(ps=>ps.originalEvent?.id===I.id);return Ts<0?null:ks[Ts+ie]?.originalEvent||null}const Le=new Set,Ye=[];for(const _s of[...Af.current,...Di])_s.camera===I.camera&&!Le.has(_s.id)&&(Le.add(_s.id),Ye.push(_s));Ye.sort((_s,ks)=>_s.start_time-ks.start_time);const Mt=Ye.findIndex(_s=>_s.id===I.id);return Mt<0?null:Ye[Mt+ie]||null},[g,Bs,Ml,Di]),Lc=u.useCallback((I,ie)=>{if(Bs==="timeline"||Bs==="classic"){const ks=(g==="cloud"?Oc:[]).filter(ps=>ps.camera===I.cameraName&&ps.originalRecording).sort((ps,Kr)=>ps.startMs-Kr.startMs),Ts=ks.findIndex(ps=>ps.originalRecording?.id===I.id);return Ts<0?null:ks[Ts+ie]?.originalRecording||null}const Le=new Set,Ye=[];for(const _s of[...gl.current,...Wa])_s.cameraName===I.cameraName&&!Le.has(String(_s.id))&&(Le.add(String(_s.id)),Ye.push(_s));Ye.sort((_s,ks)=>new Date(_s.startTime).getTime()-new Date(ks.startTime).getTime());const Mt=Ye.findIndex(_s=>_s.id===I.id);return Mt<0?null:Ye[Mt+ie]||null},[g,Bs,Oc,Wa]),Iu=u.useCallback(I=>{const ie=Dc(I,1);ie&&(Z(ie),Y(null),fe(null),ge(-1),oc(null))},[Dc]),Ou=u.useCallback(I=>{const ie=Lc(I,1);ie&&(Re(!1),Be(null),Y(null),bt(ie))},[Lc]),Ta=7200,$c=7200,fo=720*60,Zn=Ae?.camera??z?.camera??$e?.cameraName??null,hn=Ae?Ae.start_time:z?z.start_time:$e?Math.floor(new Date($e.startTime).getTime()/1e3):null,[Ao,Sa]=u.useState(0),[Aa,dd]=u.useState(0);u.useEffect(()=>{Sa(0),dd(0)},[z?.id,tr?hn:null]);const Dl=tr?Zn:z?.camera??null,li=tr?hn:z?.start_time??null,Fc=900,F=li!=null?Math.floor(li/Fc)*Fc:null,ve=b!=="none"&&li!=null&&!!Dl&&(tr?!Eo:!!z),Te=async(I,ie)=>{const Le=new URLSearchParams;Le.set("cameras",Dl),Le.set("after",String(I)),Le.set("before",String(ie)),Le.set("limit","500");const Ye=await fetch(`/api/local-recordings/${b}/events?${Le.toString()}`,{credentials:"include"});if(!Ye.ok)throw new Error("Failed to fetch mini-timeline events");return Ye.json()},ht=2700,kt=ze({queryKey:["/api/local-recordings",b,"mini-timeline-fast",Dl,F],queryFn:async()=>F==null||!Dl?{events:[]}:Te(F-ht,F+Fc+ht),enabled:ve,staleTime:300*1e3,placeholderData:SS}),us=3600,ts=u.useMemo(()=>
556{if(F==null)return[];const I=F-(Ta+Ao),ie=F+Fc+(Ta+Aa),Le=Math.floor(I/us)*us,Ye=[];for(let Mt=Le;Mt<ie;Mt+=us)Ye.push(Mt);return Ye},[F,Ao,Aa]),is=Ix({queries:ts.map(I=>({queryKey:["/api/local-recordings",b,"mini-timeline-chunk",Dl,I],queryFn:async()=>Dl?Te(I,I+us):{events:[]},enabled:ve,staleTime:300*1e3,gcTime:1800*1e3}))}),js=is.some(I=>I.isFetching),ms=is.length>0&&is.every(I=>I.isError),gs=u.useMemo(()=>{const I=[];for(const ie of is){const Le=ie.data?.events;Le?.length&&I.push(...Le)}return I},[is.map(I=>I.dataUpdatedAt).join(","),b,Dl]),Ar=u.useMemo(()=>{const I=kt.data?.events||[];if(I.length===0)return gs;if(gs.length===0)return I;const ie=new Set(gs.map(Le=>Le.id));return[...gs,...I.filter(Le=>!ie.has(Le.id))]},[gs,kt.data]),si=z?(li-(Ta+Ao))*1e3:void 0,Ka=z?(li+(Ta+Aa))*1e3:void 0,[Wr,dn]=u.useState(null),Yo=u.useCallback(I=>{if(I.direction==="before"){if(Ao>=fo)return;dn("before"),Sa(ie=>Math.min(ie+$c,fo))}else{if(Aa>=fo)return;dn("after"),dd(ie=>Math.min(ie+$c,fo))}},[Ao,Aa,fo,$c]);u.useEffect(()=>{js||dn(null)},[js]);const Ji=Ao>=fo,pi=Aa>=fo,Pr=Wr==="before"&&js,am=Wr==="after"&&js,Md=u.useMemo(()=>{if(!z)return Af.current=[],[];const I=Ar,ie=new Set,Le=[];ie.add(z.id),Le.push(z);for(const ks of I)ks.camera===z.camera&&!ie.has(ks.id)&&(ie.add(ks.id),Le.push(ks));const Ye=1800;for(const ks of[Di,Ni])for(const Ts of ks)Ts.camera===z.camera&&!ie.has(Ts.id)&&Ts.start_time>=z.start_time-Ye&&Ts.start_time<=z.start_time+Ye&&(ie.add(Ts.id),Le.push(Ts));Af.current=Le;const Mt=fn.data?.timelineMotionColor||"#eab308",_s=fn.data?.timelineDetectionColor||"#3b82f6";return Le.map(ks=>{const Ts=ks.detections?.[0]?`/api/local-recordings/${b}/thumbnail?detection=${encodeURIComponent(ks.detections[0])}`:`/api/local-recordings/${b}/thumbnail?camera=${encodeURIComponent(ks.camera)}&time=${ks.start_time}`,ls=ks.label==="motion"||ks.objects.length===0&&ks.severity==="detection";return{id:ks.id,startMs:ks.start_time*1e3,endMs:(ks.end_time||ks.start_time+60)*1e3,color:ls?Mt:_s,label:ks.objects?.join(", ")||ks.label||void 0,thumbnailUrl:Ts}})},[Ar,Di,Ni,z,b,fn.data?.timelineMotionColor,fn.data?.timelineDetectionColor]),wn=7200*1e3,Li=7200*1e3,fi=720*60*1e3,[aa,eo]=u.useState(0),[Bc,Vg]=u.useState(0);u.useEffect(()=>{eo(0),Vg(0)},[$e?.id,tr?hn:null]);const Lh=tr?Zn:$e?.cameraName??null,ru=tr?hn!=null?hn*1e3:null:$e?new Date($e.startTime).getTime():null,Wg=tr?ru:$e?.startTime??null,Uc=ze({queryKey:["/api/cloud-recordings","mini-timeline",b,nn,Lh,Wg,aa,Bc],queryFn:async()=>{if(ru==null||!Lh)return{recordings:[],total:0};const I=ru,ie=new URLSearchParams;nn&&ie.set("edgeDeviceId",nn),b!=="none"&&ie.set("siteId",b),ie.set("cameraNames",Lh),ie.set("startDate",new Date(I-(wn+aa)).toISOString()),ie.set("endDate",new Date(I+(wn+Bc)).toISOString()),ie.set("noLimit","true");const Le=await fetch(`/api/cloud-recordings?${ie.toString()}`,{credentials:"include"});if(!Le.ok)throw new Error("Failed to fetch cloud mini-timeline");return Le.json()},enabled:b!=="none"&&ru!=null&&!!Lh&&(tr?!0:!!$e),staleTime:300*1e3,placeholderData:SS}),yv=ru!=null?ru-(wn+aa):void 0,qm=ru!=null?ru+(wn+Bc):void 0,[Mf,Kg]=u.useState(null),im=u.useCallback(I=>{if(I.direction==="before"){if(aa>=fi)return;Kg("before"),eo(ie=>Math.min(ie+Li,fi))}else{if(Bc>=fi)return;Kg("after"),Vg(ie=>Math.min(ie+Li,fi))}},[aa,Bc,fi,Li]);u.useEffect(()=>{Uc.isFetching||Kg(null)},[Uc.isFetching]);const bp=aa>=fi,Gg=Bc>=fi,Rf=Mf==="before"&&Uc.isFetching,Vm=Mf==="after"&&Uc.isFetching,bv=u.useMemo(()=>{if(!$e)return gl.current=[],[];const I=c0([...Uc.data?.recordings||[],...Wa,...Au]),ie=ps=>I.has(ps.id),Le=(Uc.data?.recordings||[]).filter(ps=>!ie(ps)),Ye=new Set,Mt=[];Ye.add($e.id),Mt.push($e);for(const ps of Le)ps.cameraName===$e.cameraName&&!Ye.has(ps.id)&&(Ye.add(ps.id),Mt.push(ps));const _s=new Date($e.startTime).getTime(),ks=1800*1e3;for(const ps of[Wa,cd])for(const Kr of ps)if(!ie(Kr)&&Kr.cameraName===$e.cameraName&&!Ye.has(Kr.id)){const Is=new Date(Kr.startTime).getTime();Is>=_s-ks&&Is<=_s+ks&&(Ye.add(Kr.id),Mt.push(Kr))}gl.current=Mt;const Ts=fn.data?.timelineMotionColor||"#eab308",ls=fn.data?.timelineDetectionColor||"#3b82f6";return Mt.map(ps=>{const Kr=ps.label?.includes("motion")&&!ps.label?.includes(",");return{id:ps.id,startMs:new Date(ps.startTime).getTime(),endMs:ps.endTime?new Date(ps.endTime).getTime():new Date(ps.startTime).getTime()+6e4,color:Kr?Ts:ls,label:ps.label||void 0,thumbnailUrl:ps.thumbnailPath||null}})},[Uc.data,Wa,cd,$e,fn.data?.timelineMotionColor,fn.data?.timelineDetectionColor]),Wm=u.useRef(new Map),Du=u.useMemo(()=>
556{if(!tr||!Zn)return Wm.current=new Map,[];const I=[...$e?[$e]:[],...Uc.data?.recordings||[]],ie=c0(I),Le=[],Ye=new Set;for(const Is of I)ie.has(Is.id)||Is.cameraName!==Zn||Ye.has(String(Is.id))||(Ye.add(String(Is.id)),Le.push({id:`c:${Is.id}`,camera:Is.cameraName,startMs:new Date(Is.startTime).getTime(),endMs:Is.endTime?new Date(Is.endTime).getTime():new Date(Is.startTime).getTime()+6e4,labels:Is.label?Is.label.split(",").map(kn=>kn.trim()):[],source:"cloud",thumbnailUrl:Is.thumbnailPath||null,originalRecording:Is}));const Mt=[];if(!Eo){const Is=[...Ae?[Ae]:[],...z?[z]:[],...Ar],kn=new Set;for(const an of Is){if(an.camera!==Zn||kn.has(an.id))continue;kn.add(an.id);const ri=an.detections?.[0]?`/api/local-recordings/${b}/thumbnail?detection=${encodeURIComponent(an.detections[0])}`:`/api/local-recordings/${b}/thumbnail?camera=${encodeURIComponent(an.camera)}&time=${an.start_time}`;Mt.push({id:`l:${an.id}`,camera:an.camera,startMs:an.start_time*1e3,endMs:(an.end_time||an.start_time+60)*1e3,labels:an.objects?.length?an.objects:an.label?[an.label]:[],source:"local",thumbnailUrl:ri,originalEvent:an})}}const ks=D1(Le,Mt,Fp,{localUnavailable:!Eo&&ms}),Ts=new Map,ls=fn.data?.timelineMotionColor||"#eab308",ps=fn.data?.timelineDetectionColor||"#3b82f6",Kr=ks.map(Is=>{Ts.set(Is.id,Is);let kn;return Is.source==="unavailable"?kn=Kw:ac?kn=Is.source==="cloud"?fS:gS:kn=Is.labels.length===0||Is.labels.length===1&&Is.labels[0]==="motion"?ls:ps,{id:Is.id,startMs:Is.startMs,endMs:Is.endMs,color:kn,label:Is.source==="unavailable"?"Temporarily unavailable":Is.labels.join(", ")||void 0,thumbnailUrl:Is.source==="unavailable"?null:
556Is.thumbnailUrl||null,unavailable:Is.source==="unavailable"}});return Wm.current=Ts,Kr},[tr,Zn,ac,Eo,Uc.data,Ar,ms,z,Ae,$e,b,fn.data?.timelineMotionColor,fn.data?.timelineDetectionColor]),Km=u.useMemo(()=>{if(!tr||hn==null)return null;if($e){const Ye=Du.find(Mt=>Mt.id===`c:${$e.id}`);if(Ye)return Ye.id}const I=Ae??z;if(I){const Ye=Du.find(Mt=>Mt.id===`l:${I.id}`||Mt.id.startsWith(`l:${I.id}::h`));if(Ye)return Ye.id}const ie=hn*1e3;return Du.find(Ye=>ie>=Ye.startMs&&ie<=Ye.endMs)?.id||null},[tr,hn,Du,z,Ae,$e]),If=Math.max(Ao,Math.floor(aa/1e3)),Yg=Math.max(Aa,Math.floor(Bc/1e3)),Of=hn!=null?(hn-(Ta+If))*1e3:void 0,wp=hn!=null?(hn+(Ta+Yg))*1e3:void 0,Gm=u.useCallback(I=>{Yo(I),im(I)},[Yo,im]),ic=Ji&&bp,om=pi&&Gg,jp=Pr||Rf,Qg=am||Vm,nu=u.useCallback(I=>{const ie=Wm.current.get(I);ie&&Go(ie)},[Go]);u.useEffect(()=>{if(!He||Tl.length===0)return;const{camera:I,startTime:ie}=He,Le=Tl.find(Ye=>{if(Ye.camera!==I)return!1;const Mt=new Date(Ye.startTime).getTime()/1e3,_s=Ye.endTime?new Date(Ye.endTime).getTime()/1e3:Mt+60;return Mt<=ie+60&&_s>=ie-60});Le&&(Re(!1),Be(null),Y(null),bt(Le),zt(null))},[Tl,He]);const gi=()=>{ce(0),et([void 0]),na(0),Da([]),Pc([]),Ec(!1)},Np=()=>{if(Na==="asc")ce(be+1);else if(ir.length>0){const I=ir[ir.length-1],ie=String(I.start_time-.001),Le=[...Pe];Le[be+1]=ie,et(Le),ce(be+1)}window.scrollTo({top:0,behavior:"smooth"})},Xg=()=>{be>0&&(ce(be-1),window.scrollTo({top:0,behavior:"smooth"}))};function Lu(I){return I?new Date(I*1e3).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):""}function $u(I){return I?new Date(I*1e3).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function Sp(I){return I?new Date(I).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):""}function lm(I){return I?new Date(I).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}const Ym=I=>{const ie=I.detections?.[0];return ie?`/api/local-recordings/${b}/thumbnail?detection=${encodeURIComponent(ie)}`:I.camera&&I.start_time?`/api/local-recordings/${b}/thumbnail?camera=${encodeURIComponent(I.camera)}&time=${I.start_time}`:""},Cp=I=>{const ie=new URLSearchParams,Le=I.detections?.[0];return Le&&ie.set("detection",Le),ie.set("reviewId",I.id),ie.set("camera",I.camera),ie.set("start",String(I.start_time)),ie.set("end",String(I.end_time||I.start_time+30)),Cn&&ie.set("vt",Cn),`/api/local-recordings/${b}/clip.mp4?${ie.toString()}`},au=I=>{const ie=Math.max(0,Math.min(60,rd?.preCaptureSec??15)),Le=Math.max(0,Math.min(60,rd?.postCaptureSec??15)),Ye=Math.floor(I.start_time)-ie,Mt=Math.ceil(I.end_time||I.start_time+30)+Le,_s=new URLSearchParams;return Cn&&_s.set("vt",Cn),`/api/local-recordings/${b}/vod/${encodeURIComponent(I.camera)}/start/${Ye}/end/${Mt}/index.m3u8${Cn?`?${_s.toString()}`:""}`},Rd=u.useRef(null);u.useEffect(()=>{if(!bi||!$e?.id||we.length===0)return;const I=Lc($e,1);!I?.id||I.id===Rd.current||(Rd.current=I.id,(async()=>{try{const ie=await fetch(`/api/cloud-recordings/${I.id}`,{credentials:"include",cache:"no-store",priority:"low"});if(!ie.ok)return;const Ye=(await ie.json()).chunks?.[0]?.proxyUrl||`/api/cloud-recordings/${I.id}/clip.mp4`,Mt=`${Ye}${Cn?`${Ye.includes("?")?"&":"?"}vt=${Cn}`:""}`;await fetch(Mt,{credentials:"include",priority:"low",headers:{Range:"bytes=0-1048575"}})}catch{}})())},[bi,$e,we.length,Lc,Cn]);const Qm=u.useRef(null);u.useEffect(()=>{if(!bi||!z||Q)return;const I=Dc(z,1);!I?.id||I.id===Qm.current||(Qm.current=I.id,(async()=>{try{await fetch(au(I),{credentials:"include",priority:"low"})}catch{}})())},[bi,z,Q,Dc]);const cm=z?.detections?.join(",")||"",[iu,oc]=u.useState(null),ud=ze({queryKey:["/api/local-recordings",b,"event-detections",z?.id,cm],queryFn:async()=>{if(!cm)return{detections:[]};const I=await fetch(`/api/local-recordings/${b}/event-detections?ids=${encodeURIComponent(cm)}`,{credentials:"include"});if(!I.ok)throw new Error("Failed to fetch detections");return I.json()},enabled:!!z&&cm.length>0&&!Q,staleTime:6e4}).data?.detections||[],Df=I=>{const ie=I.toLowerCase();return ie==="person"?{border:"#22c55e",glow:"rgba(34,197,94,0.5)",bg:"#22c55e"}:ie==="car"||ie==="vehicle"||ie==="truck"||ie==="motorcycle"||ie==="bicycle"||ie==="bus"?{border:"#3b82f6",glow:"rgba(59,130,246,0.5)",bg:"#3b82f6"}:{border:"#ef4444",glow:"rgba(239,68,68,0.5)",bg:"#ef4444"}},ci=u.useCallback(()=>{const I=H.current;if(!I||ud.length===0||!z)return;const ie=Math.floor(z.start_time)-5,Le=me+1>=ud.length?0:me+1,Ye=ud[Le],_s=Ye.start_time-ie,ks=I.duration||1/0;I.currentTime=Math.max(0,Math.min(_s,ks-.5)),I.pause(),ge(Le),oc(Ye.sub_label||Ye.label)},[ud,me,z]),_p=u.useCallback(I=>{Xt(I),xr(!1)},[]),Pp=u.useCallback(async(I=!1)=>
556{if(!qe||!b)return;const ie=!!$e&&!z,Le=z?.start_time||($e?typeof $e.startTime=="number"?$e.startTime:new Date($e.startTime).getTime()/1e3:null),Ye=z?.camera||$e?.cameraName||null;if(!Le)return;const Mt=Bs!=="events"?Hn.filter(ls=>Ns.includes(ls)):qn,_s=Bs!=="events"&&Mt.length>0&&Mt.length<Ns.length,ks=en>0?(en-Co)/en:0;if(!I&&vn&&en>0&&ks>=.75){const ls=Math.max(1,Ns.length);let ps,Kr;Bs!=="events"?_s?(ps=`${Mt.length} of ${ls} cameras`,Kr=Mt.length/ls):(ps=`all ${ls} cameras`,Kr=1):Ln==="current"?(ps="current camera",Kr=1/ls):(ps=`all ${ls} cameras`,Kr=1);const Is=ua*2,kn=Kte(ie?"cloud":"local",1,Kr,Is),an=vC(kn);qr({kind:"visual",estImages:kn,estRequests:an,remaining:Co,dailyLimit:en,exceeds:en>0&&(en-Co)/en>=.75,cameraScope:ps,severityScope:`±${Math.round(ua/60)} min window · all severities`}),So.current=()=>Pp(!0);return}Hr.current?.abort();const Ts=new AbortController;Hr.current=Ts,br(!0),gt(null),xn(null),Pi({scored:0,total:0});try{const ls={image:(qe||"").replace(/^data:[^,]*,/,""),siteIds:[b],after:Le-ua,before:Le+ua};(ie||Eo)&&(ls.source="cloud"),Bs!=="events"?_s&&(ls.cameras=Mt):Ln==="current"&&Ye&&(ls.camera=Ye);const ps=await fetch("/api/visual-search",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(ls),signal:Ts.signal});if(!ps.ok){const Is=await ps.text().catch(()=>"");let kn="";try{kn=JSON.parse(Is)?.error||JSON.parse(Is)?.message||""}catch{}const an=Is.slice(0,200).replace(/\s+/g," ").trim(),ri=kn||an||"Search failed";throw console.error(`[VisualSearch] HTTP ${ps.status} ${ps.statusText} ct=${ps.headers.get("content-type")} body=${an}`),new Error(`(${ps.status}) ${ri}`)}const Kr=await ps.json();Ts.signal.aborted||(gt(Kr.matches||[]),xn(Kr.description||null))}catch(ls){if(ls.name==="AbortError")return;r({title:"Visual Search Failed",description:ls.message,variant:"destructive"}),gt(null)}finally{Ts.signal.aborted||(br(!1),Pi(null)),Je.invalidateQueries({queryKey:["/api/sites",b,"ai-plus","status"]})}},[qe,z,$e,b,ua,Ln,r,vn,en,Co,Ns,Bs,Hn,qn]),Mo=u.useCallback(()=>{Hr.current?.abort(),Hr.current=null,xr(!1),Xt(null),gt(null),xn(null),br(!1),Pi(null)},[]),ou=u.useCallback(async(I=!1)=>{if(!lt.trim()||b==="none")return;let ie,Le;if(Bs!=="events"){const Ts=new Date(Ea);Ts.setHours(0,0,0,0);const ls=new Date(Ea);ls.setHours(23,59,59,999),ie=Math.floor(Ts.getTime()/1e3),Le=Math.floor(ls.getTime()/1e3)}else ie=_?Math.floor(_.getTime()/1e3):Math.floor(Date.now()/1e3)-7200,Le=Math.floor(T?T.getTime()/1e3:Date.now()/1e3);const Ye=(Le-ie)/3600;if(Ye>72){r({title:"Time range too large",description:"AI Search is limited to 72 hours or less. Please reduce your date range.",variant:"destructive"});return}const Mt=Bs!=="events"?Hn.filter(Ts=>Ns.includes(Ts)):qn,_s=en>0?(en-Co)/en:0;if(!I&&vn&&en>0&&_s>=.75){const Ts=g==="cloud"?"cloud":"local",ls=Math.max(1,Ns.length),ps=Mt.length>0&&Mt.length<ls?Mt.length:Bs!=="timeline"&&w!=="all"?1:ls,Kr=Gte({selectedCameras:ps,totalCameras:ls,selectedSeverity:x,selectedLabels:Ur}),Is=Wte(Ye,Ts,1,Kr),kn=vC(Is),an=ps===ls?`all ${ls} cameras`:`${ps} of ${ls} cameras`,ri=x!=="all"||Ur.length>0?[x!=="all"?`severity: ${x}`:null,Ur.length>0?`labels: ${Ur.join(", ")}`:null].filter(Boolean).join("; "):"any severity/label";qr({kind:"text",estImages:Is,estRequests:kn,remaining:Co,dailyLimit:en,exceeds:en>0&&(en-Co)/en>=.75,cameraScope:an,severityScope:ri}),So.current=()=>ou(!0);return}Os.current?.abort();const ks=new AbortController;Os.current=ks,hr(!0),Ht(null),Sr(lt.trim()),ii({scored:0,total:0}),ur.current?.clear(),ur.current=lC({category:"ai_search",searchTerm:lt.trim(),searchSiteIds:[b],siteId:b,source:g==="cloud"?"cloud":"local"});try{const Ts={query:lt.trim(),siteIds:[b],after:ie,before:Le};g==="cloud"&&(Ts.source="cloud"),Mt.length>0&&Mt.length<Ns.length?Ts.cameras=Mt:Bs!=="timeline"&&w!=="all"&&(Ts.camera=w);const ls=await fetch("/api/ai-text-search",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(Ts),signal:ks.signal});if(!ls.ok){const Kr=await ls.json().catch(()=>({error:"Search failed"}));throw new Error(Kr.error||"Search failed")}const ps=await ls.json();ks.signal.aborted||Ht(ps.matches||[])}catch(Ts){if(Ts.name==="AbortError")return;const ls=Ts?.message||"Text search failed";r({title:"Search failed",description:ls,variant:"destructive"}),Ht(null),Sr(null)}
556finally{ks.signal.aborted||(hr(!1),ii(null)),Je.invalidateQueries({queryKey:["/api/sites",b,"ai-plus","status"]})}},[lt,b,_,T,Bs,Ea,w,qn,Hn,Ns,g,r,vn,en,Co,x,Ur]),Ll=u.useCallback(()=>{Os.current?.abort(),Os.current=null,ur.current?.clear(),ur.current=null,mn&&Ze("POST","/api/ai-text-search/cancel",{}).catch(()=>{}),Rt(""),Ht(null),Sr(null),hr(!1),ii(null)},[mn]);u.useEffect(()=>{if(!es)return;let I=!1;const ie=async()=>{try{const Ye=await fetch("/api/ai-search/progress?type=visual",{credentials:"include"});if(!Ye.ok||I)return;const Mt=await Ye.json();if(I)return;(Mt.status==="running"||Mt.status==="done")&&(Pi({scored:Mt.scored||0,total:Mt.total||0}),Array.isArray(Mt.matches)&&Mt.matches.length>0&&gt(Mt.matches),Mt.description&&xn(Mt.description))}catch{}};ie();const Le=window.setInterval(ie,800);return()=>{I=!0,window.clearInterval(Le)}},[es]),u.useEffect(()=>{if(!mn)return;let I=!1;const ie=async()=>{try{const Ye=await fetch("/api/ai-search/progress?type=text",{credentials:"include"});if(!Ye.ok||I)return;const Mt=await Ye.json();if(I)return;(Mt.status==="running"||Mt.status==="done")&&(ii({scored:Mt.scored||0,total:Mt.total||0}),Array.isArray(Mt.matches)&&Mt.matches.length>0&&Ht(Mt.matches))}catch{}};ie();const Le=window.setInterval(ie,800);return()=>{I=!0,window.clearInterval(Le)}},[mn]),Po.current={vs:Mo,ts:Ll};const ca=ze({queryKey:["/api/cloud-recordings",$e?.id,"detections"],queryFn:async()=>{if(!$e?.id)return{detections:[]};const I=await fetch(`/api/cloud-recordings/${$e.id}/detections`,{credentials:"include"});return I.ok?I.json():{detections:[]}},enabled:!!$e?.id,staleTime:6e4}).data?.detections||[],to=u.useCallback(()=>{const I=fs.current;if(!I||ca.length===0||!$e)return;const ie=new Date($e.startTime).getTime()/1e3,Le=Oe+1>=ca.length?0:Oe+1,Ye=ca[Le],Mt=Ye.start_time-ie,_s=I.duration||1/0;I.currentTime=Math.max(0,Math.min(Mt,_s-.5)),I.pause(),De(Le),Ct(Ye.sub_label||Ye.label)},[ca,Oe,$e]),$i=async I=>{const ie=nG({camera:I.camera,severity:I.severity,label:I.label,displayName:or.get(I.camera)||I.displayName,startTime:I.start_time});if(/iphone|ipad|ipod|android/i.test(navigator.userAgent)){const Ye=Cp(I).includes("?")?"&":"?",Mt=`${Cp(I)}${Ye}download=true&filename=${encodeURIComponent(ie)}`,_s=document.createElement("a");_s.href=Mt,_s.rel="noopener",document.body.appendChild(_s),_s.click(),document.body.removeChild(_s);return}le(!0);try{const Ye=await fetch(Cp(I),{credentials:"include",headers:{"x-download-intent":"true"}}),Mt=(Ye.headers.get("content-type")||"").toLowerCase();if(!Ye.ok||!Mt.startsWith("video/")&&!Mt.includes("application/octet-stream")){const ls=await Ye.json().catch(()=>null);r({title:"Download failed",description:ls?.detail||ls?.error||"The clip is not available on the Edge device.",variant:"destructive"});return}const _s=await Ye.blob(),ks=window.URL.createObjectURL(_s),Ts=document.createElement("a");Ts.href=ks,Ts.download=ie,document.body.appendChild(Ts),Ts.click(),document.body.removeChild(Ts),window.URL.revokeObjectURL(ks)}catch{r({title:"Download failed",description:"Could not download the clip.",variant:"destructive"})}finally{le(!1)}},Lf=I=>{Mo(),Ll(),y(I),l(I==="none"?void 0:I),j("all"),qo(!1),mo([]),_o([]),gi()};return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>s("/"),"data-testid":"button-back-dashboard",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(cn,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold",children:"Event Retrieval"})]}),t.jsx(qd,{showDashboardLink:!0})]})})}),t.jsxs("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6",children:[d&&t.jsxs("div",{className:"mb-6 flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 p-4","data-testid":"privacy-banner",children:[t.jsx(ka,{className:"w-5 h-5 text-amber-600 dar
556k:text-amber-400 shrink-0 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-amber-700 dark:text-amber-300",children:"Video is hidden by the site owner"}),t.jsx("p",{className:"text-xs text-amber-700/80 dark:text-amber-300/80 mt-0.5",children:"Recordings, thumbnails, and playback are unavailable for this site. Ask the owner to grant Temporary Support access if you need to view footage for troubleshooting."})]})]}),t.jsx(ut,{className:"mb-6",children:t.jsx(mt,{className:"pt-6",children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-end gap-3",children:[t.jsxs("div",{className:"space-y-1.5 flex-1 min-w-0",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Site"}),t.jsxs(Us,{value:b,onValueChange:Lf,children:[t.jsx($s,{"data-testid":"select-site",children:t.jsx(zs,{placeholder:"Select a Site"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"none",children:"Select a Site"}),td.map(I=>t.jsx(rt,{value:I.id,children:I.name},I.id))]})]})]}),t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Camera"}),Bs!=="events"?t.jsxs(vd,{open:tm,onOpenChange:Pd,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",role:"combobox",disabled:b==="none",className:"w-full justify-between font-normal","data-testid":"select-camera-timeline",children:[t.jsx("span",{className:"truncate",children:Hn.length===0?"Select cameras...":Hn.length===Ns.length?"All Cameras":`${Hn.length} camera${Hn.length>1?"s":""}`}),t.jsx(Xa,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsx(Kc,{className:"w-56 p-2",align:"start",children:t.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-sm hover-elevate cursor-pointer",onClick:()=>{Hn.length===Math.min(Ns.length,uo)?mo([]):mo(Ns.slice(0,uo)),gi()},"data-testid":"checkbox-camera-all",children:[t.jsx(On,{checked:Hn.length===Math.min(Ns.length,uo)&&Ns.length>0,className:"pointer-events-none"}),t.jsxs("span",{className:"text-sm font-medium",children:["All Cameras ",Ns.length>uo?`(first ${uo})`:""]})]}),Ns.length>uo&&t.jsxs("p",{className:"text-xs text-muted-foreground px-2",children:["Max ",uo," cameras for ",Bs==="classic"?"classic view":"timeline"]}),t.jsx("div",{className:"border-t my-1"}),Ns.map(I=>{const ie=Hn.includes(I),Le=Hn.length>=uo&&!ie;return t.jsxs("div",{className:`flex items-center gap-2 px-2 py-1.5 rounded-sm cursor-pointer ${Le?"opacity-40 cursor-not-allowed":"hover-elevate"}`,onClick:()=>{Le||(mo(Ye=>Ye.includes(I)?Ye.filter(Mt=>Mt!==I):[...Ye,I]),gi())},"data-testid":`checkbox-camera-${I}`,children:[t.jsx(On,{checked:ie,disabled:Le,className:"pointer-events-none"}),t.jsx("span",{className:"text-sm",children:or.get(I)||I})]},I)})]})})]}):t.jsxs(vd,{children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",role:"combobox",disabled:b==="none",className:"w-full justify-between font-normal","data-testid":"select-camera-events",children:[t.jsx("span",{className:"truncate",children:qn.length===0?"Select cameras...":qn.length===Ns.length?"All Cameras":`${qn.length} camera${qn.length>1?"s":""}`}),t.jsx(Xa,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),t.jsx(Kc,{className:"w-56 p-2",align:"start",children:t.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-sm hover-elevate cursor-pointer",onClick:()=>{qn.length===Ns.length?_o([]):_o([...Ns]),gi()},"data-testid":"checkbox-events-camera-all",children:[t.jsx(On,{checked:qn.length===Ns.length&&Ns.length>0,className:"pointer-events-none"}),t.jsx("span",{className:"text-sm font-medium",children:"All Cameras"})]}),t.jsx("div",{className:"border-t my-1"}),Ns.map(I=>t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-sm hover-elevate cursor-pointer",onClick:()=>{_o(ie=>ie.includes(I)?ie.filter(Le=>Le!==I):[...ie,I]),gi()},"data-testid":`checkbox-events-camera-${I}`,children:[t.jsx(On,{checked:qn.includes(I),className:"pointer-events-none"}),t.jsx("span",{className:"text-sm",children:or.get(I)||I})]},I))]})})]})]})]}),t.jsx("div",{className:"flex items-end gap-3 flex-wrap",children:Bs!=="events"?t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Date"}),t.jsxs(vd,{open:Ed,onOpenChange:ed,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",disabled:b==="none",className:"w-full justify-start text-left font-normal","data-testid":"input-timeline-date",children:[t.jsx(ro,{className:"mr-2 h-4 w-4 flex-shrink-0"}),wi?Bn(Ea,"MM/dd/yy"):Bn(Ea,"MMM d, yyyy")]})}),t.jsx(Kc,{className:"w-auto p-0",align:"start",children:t.jsx(_m,{mode:"single",selected:Ea,onSelect:I=>{if(I){const ie=new Date(I);ie.setHours(0,0,0,0),Ac(ie)}ed(!1)},disabled:I=>I>new Date,initialFocus:!0})})]})]}):wi?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-end gap-2 w-full",children:[t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"From"}),t.jsxs(vd,{open:R,onOpenChange:D,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",disabled:b==="none",className:"w-full justify-start text-left font-normal","data-testid":"input-mobile-start-date",children:[t.jsx(ro,{className:"mr-1 h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:_?Bn(_,"M/d h:mm a"):"Start"})]})}),t.jsxs(Kc,{className:"w-auto p-0",align:"start",children:[t.jsx(_m,{mode:"single",selected:_,onSelect:I=>{if(I){const ie=new Date(I);_&&ie.setHours(_.getHours(),_.getMinutes()),A(ie)}else A(void 0);S(0),gi()},disabled:I=>I>new Date,initialFocus:!0}),t.jsxs("div",{className:"border-t px-3 py-2 flex items-center gap-2",children:[t.jsx(cn,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx(ke,{type:"time",value:_?Bn(_,"HH:mm"):"00:00",onChange:I=>{if(!I.target.value||!_)return;const ie=I.target.value.split(":"),Le=parseInt(ie[0],10),Ye=parseInt(ie[1],10);if(isNaN(Le)||isNaN(Ye))return;const Mt=new Date(_);
556Mt.setHours(Le,Ye,0,0),A(Mt),S(0),gi()},disabled:!_,className:"flex-1","data-testid":"input-mobile-start-time"})]})]})]})]}),t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"To"}),t.jsxs(vd,{open:$,onOpenChange:O,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",disabled:b==="none",className:"w-full justify-start text-left font-normal","data-testid":"input-mobile-end-date",children:[t.jsx(ro,{className:"mr-1 h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:T?Bn(T,"M/d h:mm a"):"End"})]})}),t.jsxs(Kc,{className:"w-auto p-0",align:"start",children:[t.jsx(_m,{mode:"single",selected:T,onSelect:I=>{if(I){const ie=new Date(I);T?ie.setHours(T.getHours(),T.getMinutes()):ie.setHours(23,59),M(ie)}else M(void 0);S(0),gi()},disabled:I=>I>new Date,initialFocus:!0}),t.jsxs("div",{className:"border-t px-3 py-2 flex items-center gap-2",children:[t.jsx(cn,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx(ke,{type:"time",value:T?Bn(T,"HH:mm"):"23:59",onChange:I=>{if(!I.target.value||!T)return;const ie=I.target.value.split(":"),Le=parseInt(ie[0],10),Ye=parseInt(ie[1],10);if(isNaN(Le)||isNaN(Ye))return;const Mt=new Date(T);
556Mt.setHours(Le,Ye,0,0),M(Mt),S(0),gi()},disabled:!T,className:"flex-1","data-testid":"input-mobile-end-time"})]})]})]})]})]}),t.jsx("div",{className:"flex items-center gap-1 w-full",children:[{hours:1,label:"1H"},{hours:2,label:"2H"},{hours:4,label:"4H"},{hours:8,label:"8H"},{hours:12,label:"12H"},{hours:24,label:"24H"}].map(({hours:I,label:ie})=>t.jsxs(L,{variant:k===I?"default":"outline",size:"sm",disabled:b==="none",onClick:()=>la(I),className:"flex-1 min-w-0 px-1 text-[11px]","data-testid":`button-mobile-time-range-${I}h`,children:[k===I?t.jsx(cn,{className:"w-3 h-3 mr-1 flex-shrink-0"}):null,ie]},I))})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"From"}),t.jsxs(vd,{open:R,onOpenChange:D,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",disabled:b==="none",className:"w-full justify-start text-left font-normal","data-testid":"input-start-date",children:[t.jsx(ro,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:_?Bn(_,"MMM d, yyyy h:mm a"):t.jsx("span",{className:"text-muted-foreground",children:"Pick a date"})}),_&&t.jsx(va,{className:"ml-auto h-3 w-3 flex-shrink-0 opacity-50 hover:opacity-100",onClick:I=>{I.stopPropagation(),A(void 0),gi()}})]})}),t.jsxs(Kc,{className:"w-auto p-0",align:"start",children:[t.jsx(_m,{mode:"single",selected:_,onSelect:I=>{if(I){const ie=new Date(I);_&&ie.setHours(_.getHours(),_.getMinutes()),A(ie)}else A(void 0);S(0),gi()},disabled:I=>I>new Date,initialFocus:!0}),t.jsxs("div",{className:"border-t px-3 py-2 flex items-center gap-2",children:[t.jsx(cn,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx(ke,{type:"time",value:_?Bn(_,"HH:mm"):"00:00",onChange:I=>{if(!I.target.value||!_)return;const ie=I.target.value.split(":"),Le=parseInt(ie[0],10),Ye=parseInt(ie[1],10);if(isNaN(Le)||isNaN(Ye))return;const Mt=new Date(_);
556Mt.setHours(Le,Ye,0,0),A(Mt),gi()},disabled:!_,className:"flex-1","data-testid":"input-start-time"})]})]})]})]}),t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"To"}),t.jsxs(vd,{open:$,onOpenChange:O,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",disabled:b==="none",className:"w-full justify-start text-left font-normal","data-testid":"input-end-date",children:[t.jsx(ro,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:T?Bn(T,"MMM d, yyyy h:mm a"):t.jsx("span",{className:"text-muted-foreground",children:"Pick a date"})}),T&&t.jsx(va,{className:"ml-auto h-3 w-3 flex-shrink-0 opacity-50 hover:opacity-100",onClick:I=>{I.stopPropagation(),M(void 0),gi()}})]})}),t.jsxs(Kc,{className:"w-auto p-0",align:"start",children:[t.jsx(_m,{mode:"single",selected:T,onSelect:I=>{if(I){const ie=new Date(I);T?ie.setHours(T.getHours(),T.getMinutes()):ie.setHours(23,59),M(ie)}else M(void 0);S(0),gi()},disabled:I=>I>new Date,initialFocus:!0}),t.jsxs("div",{className:"border-t px-3 py-2 flex items-center gap-2",children:[t.jsx(cn,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx(ke,{type:"time",value:T?Bn(T,"HH:mm"):"23:59",onChange:I=>{if(!I.target.value||!T)return;const ie=I.target.value.split(":"),Le=parseInt(ie[0],10),Ye=parseInt(ie[1],10);if(isNaN(Le)||isNaN(Ye))return;const Mt=new Date(T);
556Mt.setHours(Le,Ye,0,0),M(Mt),gi()},disabled:!T,className:"flex-1","data-testid":"input-end-time"})]})]})]})]}),t.jsxs("div",{className:"space-y-1.5 flex-shrink-0",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Quick Range"}),t.jsx("div",{className:"flex items-center gap-1",children:[{hours:1,label:"1H"},{hours:2,label:"2H"},{hours:4,label:"4H"},{hours:8,label:"8H"},{hours:12,label:"12H"},{hours:24,label:"24H"}].map(({hours:I,label:ie})=>t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:k===I?"default":"outline",size:"icon",className:"h-9 w-9 text-xs",disabled:b==="none",onClick:()=>la(I),"data-testid":`button-time-range-${I}h`,children:k===I?t.jsx(cn,{className:"w-3.5 h-3.5"}):ie})}),t.jsxs(Yt,{children:["Last ",I," hour",I>1?"s":""]})]},I))})]})]})})]})})}),Mn&&b!=="none"&&t.jsx(ut,{className:"mb-4",children:t.jsxs(mt,{className:"py-3 px-4",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(ai,{className:"w-4 h-4 text-primary flex-shrink-0"}),t.jsx(re,{className:"text-xs text-muted-foreground flex-shrink-0",children:"AI Search"}),t.jsx(ke,{placeholder:"Describe what you're looking for (e.g. person in red shirt, white SUV)...",value:lt,onChange:I=>Rt(I.target.value),onKeyDown:I=>{I.key==="Enter"&&!mn&&!Oa&&ou(!1)},disabled:mn||Oa,className:"text-sm h-8 flex-1 min-w-0 sm:min-w-[200px]","data-testid":"input-text-search"}),t.jsx(L,{size:"sm",onClick:()=>ou(),disabled:mn||!lt.trim()||Oa,"data-testid":"button-text-search",children:mn?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):t.jsx(ai,{className:"w-3.5 h-3.5"})}),(At||mn)&&t.jsx(L,{size:"sm",variant:"ghost",onClick:Ll,"data-testid":"button-text-search-cancel",children:t.jsx(va,{className:"w-3.5 h-3.5"})}),en>0&&Dr/en>=.75&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(Ke,{variant:Oa?"destructive":Co<=10?"secondary":"outline",className:"text-xs font-normal gap-1 cursor-help ml-auto","data-testid":"badge-ai-usage",children:[t.jsx(Sy,{className:"w-3 h-3"}),Oa?`Daily limit reached (${Dr} / ${en})`:`${Dr} / ${en} AI requests today`]})}),t.jsxs(Yt,{className:"max-w-xs",children:[t.jsxs("p",{className:"text-xs",children:["Each AI search counts as multiple requests — roughly ",t.jsx("b",{children:"1 request per 25 images scored"}),". A single search across a long time window can use several requests."]}),Oa&&t.jsx("p",{className:"text-xs mt-1 text-destructive-foreground",children:"You've hit today's limit for this site. AI search will be available again tomorrow."})]})]})]}),Oa&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 p-2 rounded-md bg-destructive/10 text-destructive","data-testid":"text-ai-limit-reached",children:[t.jsx(Sy,{className:"w-3.5 h-3.5 flex-shrink-0"}),t.jsx("span",{className:"text-xs",children:"Daily AI search limit reached for this site. Searches are disabled until tomorrow."})]}),Pu.length>0&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-2 flex-wrap","data-testid":"row-person-label-chips",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground mr-0.5",children:"Known people:"}),Pu.filter(I=>(I.imageCount??0)>0).map(I=>t.jsx("button",{type:"button",onClick:()=>sd(I.name),disabled:mn||Oa,className:"text-[11px] px-2 py-0.5 rounded-full border border-border bg-background hover-elevate active-elevate-2 disabled:opacity-50","data-testid":`chip-person-${I.id}`,title:`Insert "${I.name}" into search`,children:I.name},I.id))]}),mn&&t.jsxs("div",{className:"flex items-center gap-3 mt-2 p-2 rounded-md bg-muted","data-testid":"text-search-loading",children:[t.jsx(Fe,{className:"w-4 h-4 animate-spin text-primary flex-shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-muted-foreground","data-testid":"text-text-search-progress",children:Qn&&Qn.total>0?`Scoring ${Math.min(Qn.scored,Qn.total)} / ${Qn.total} images for "${Sn}"${At&&At.length>0?` — ${At.length} match${At.length!==1?"es":""} so far`:""}`:`Searching recordings for "${Sn}"...`}),Qn&&Qn.total>0&&t.jsx("div",{className:"mt-1 h-1 w-full bg-background rounded overflow-hidden",children:t.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.min(100,Math.round(Qn.scored/Math.max(1,Qn.total)*100))}%`}})})]})]})]})}),b==="none"?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(Vi,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"Select a Site"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Choose a site from the filter above to view recordings."})]}):t.jsxs(_h,{value:g,onValueChange:I=>{v(I),Da([]),Ii(),Ls(),Ll(),I==="cloud"&&x==="detection"&&Mh!=="continuous"&&C("all")},className:"space-y-4",children:[t.jsxs(Dm,{"data-testid":"tabs-recording-source",children:[!Eo&&t.jsxs(_n,{value:"local",className:"gap-1.5","data-testid":"tab-local",children:[t.jsx(Fa,{className:"w-3.5 h-3.5"}),"Local"]}),t.jsxs(_n,{value:"cloud",className:"gap-1.5","data-testid":"tab-cloud",children:[t.jsx(pn,{className:"w-3.5 h-3.5"}),"Cloud"]})]}),t.jsx(ea,{value:"local",className:"space-y-4",children:qa?t.jsxs("div",{className:"text-center py-16","data-testid":"local-recordings-device-offline",children:[t.jsx(Fa,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"Local Recordings Unavailable"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"This site's edge device is offline, so local recordings can't be reached right now. Cloud recordings remain available in the Cloud tab."}),Wo&&t.jsxs(L,{variant:"outline",size:"sm",className:"mt-4",onClick:()=>v("cloud"),"data-testid":"button-switch-to-cloud-offline",children:[t.jsx(pn,{className:"w-3.5 h-3.5 mr-1.5"}),"View Cloud Recordings"]})]}):t.jsxs(t.Fragment,{children:[Tu.length>0&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap","data-testid":"filter-local-labels",children:[t.jsx(Py,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx(Ke,{variant:Ur.length===0?"default":"outline",className:"cursor-pointer text-xs toggle-elevate",onClick:()=>Da([]),"data-testid":"filter-label-all",children:"All"}),Tu.map(I=>t.jsx(Ke,{variant:Ur.includes(I)?"default":"outline",className:"cursor-pointer text-xs toggle-elevate",onClick:()=>{Da(ie=>ie.includes(I)?ie.filter(Le=>Le!==I):[...ie,I]),ce(0),et([void 0])},"data-testid":`filter-label-${I}`,children:I.charAt(0).toUpperCase()+I.slice(1)},I))]}),oi&&g==="local"&&Ur.some(I=>I!=="motion")&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap","data-testid":"filter-color",children:[t.jsx(Xr,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:"Color:"}),t.jsx(Ke,{variant:Ti?"outline":"default",className:"cursor-pointer text-xs toggle-elevate",onClick:Ii,"data-testid":"filter-color-none",children:"None"}),Qs.map(I=>t.jsx(Ke,{variant:al===I&&Ti?"default":"outline",className:`curs
556or-pointer text-xs toggle-elevate ${il&&al===I?"opacity-60":""}`,onClick:()=>{Va(I)},"data-testid":`filter-color-${I.replace(/\s+/g,"-")}`,children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[il&&al===I?t.jsx(Fe,{className:"w-2.5 h-2.5 animate-spin"}):t.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-border",style:{backgroundColor:rc[I]}}),t.jsx("span",{className:"capitalize",children:I})]})},I)),Ti&&!il&&t.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:[Xi.length," match",Xi.length!==1?"es":""," (",kr.done," scanned)"]}),il&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["Scanning ",kr.done," events...",Xi.length>0&&` (${Xi.length} found)`]}),t.jsx(Ke,{variant:"destructive",className:"cursor-pointer text-xs ml-1",onClick:Yi,"data-testid":"button-stop-color-search",children:"Stop"})]})]}),At&&t.jsxs("div",{className:"space-y-3","data-testid":"text-search-results-area",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ai,{className:"w-4 h-4 text-primary"}),t.jsxs("span",{className:"text-sm font-medium",children:["AI Search: ",At.length," match",At.length!==1?"es":""]}),Sn&&t.jsxs("span",{className:"text-xs text-muted-foreground italic",children:['— "',Sn,'"']})]}),t.jsxs(L,{size:"sm",variant:"outline",onClick:Ll,"data-testid":"button-text-search-clear-results",children:[t.jsx(va,{className:"w-3.5 h-3.5 mr-1"})," Clear Results"]})]}),At.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(ai,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Matches Found"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"No events matched your search. Try different terms or a wider time range."})]}):t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:(kc||At).map(I=>t.jsxs(ut,{className:`overflow-visible ${d?"cursor-not-allowed":"hover-elevate cursor-pointer"}`,onClick:async()=>{if(d)return;if(I.source==="cloud"&&I.cloudRecordingId){Z(null);const Le=Oi.find(Ye=>Ye.id===I.cloudRecordingId);Le?(bt(Le),Re(!1),De(-1),Ct(null)):(bt({id:I.cloudRecordingId,cameraName:I.camera,startTime:new Date(I.startTime*1e3).toISOString(),label:I.label,thumbnailPath:null}),Re(!1),De(-1),Ct(null));return}const ie={id:I.eventId,camera:I.camera,label:I.label,zones:[],start_time:I.startTime,end_time:I.startTime+30,objects:[I.label],detections:[I.eventId],score:I.score/100,severity:"detection",has_clip:!0,has_snapshot:!0};Z(ie),Y(null),fe(null),ge(-1),oc(null)},"data-testid":`card-text-search-result-${I.eventId}`,children:[t.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center rounded-t-md overflow-hidden",children:[d?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black","data-testid":`privacy-blocked-search-${I.eventId}`,children:t.jsx(ka,{className:"w-8 h-8 text-white/40"})}):t.jsx("img",{src:I.source==="cloud"&&I.cloudRecordingId?`/api/cloud-recordings/${encodeURIComponent(I.cloudRecordingId)}/thumbnail`:`/api/local-recordings/${I.siteId}/thumbnail?detection=${encodeURIComponent(I.eventId)}&camera=${encodeURIComponent(I.camera)}`,alt:I.camera,loading:"lazy",decoding:"async",className:"w-full h-full object-cover",onError:ie=>{const Le=ie.target;Le.style.display="none";const Ye=Le.nextElementSibling;Ye&&(Ye.style.display="flex")}}),t.jsx("div",{className:"hidden items-center justify-center absolute inset-0 bg-black",children:t.jsx(wo,{className:"w-8 h-8 text-muted-foreground"})}),!d&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity",children:t.jsx(vu,{className:"w-10 h-10 text-white"})}),t.jsxs("div",{className:"absolute top-2 left-2 flex items-center gap-1",children:[t.jsxs(Ke,{variant:"secondary",className:"text-[10px]",children:[t.jsx(ai,{className:"w-2.5 h-2.5 mr-1"}),"AI Match"]}),t.jsx(Ke,{variant:"outline",className:"text-[10px] bg-background/80",children:I.label.charAt(0).toUpperCase()+I.label.slice(1)}),I.source==="cloud"&&t.jsx(Ke,{variant:"outline",className:"text-[10px] bg-background/80",children:"Cloud"})]}),t.jsx("div",{className:"absolute top-2 right-2",children:t.jsxs(Ke,{className:`text-[10px] ${vr(I.score)}`,children:[I.score,"%"]})})]}),t.jsxs(mt,{className:"p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(wo,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-sm font-medium truncate",children:or.get(I.camera)||I.camera})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(ro,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:new Date(I.startTime*1e3).toLocaleDateString()})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[t.jsx(cn,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:new Date(I.startTime*1e3).toLocaleTimeString()})]})]})]},`${I.siteId}-${I.eventId}`))})]}),!At&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsx("div",{className:"flex items-center gap-3",children:t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-events-count",children:pl.isLoading||Al.isLoading?"Loading...":""})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex items-center border rounded-md",children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`rounded-r-none toggle-elevate ${Bs==="classic"?"toggle-elevated":""}`,onClick:()=>{ti("classic")},"data-testid":"button-view-classic",children:t.jsx(cn,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Classic View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`rounded-l-none sm:rounded-r-none toggle-elevate ${Bs==="events"?"toggle-elevated":""}`,onClick:()=>{_o([...Ns]),ti("events")},"data-testid":"button-view-events",children:t.jsx(Cy,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Event Grid View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`hidden sm:inline-flex rounded-l-none toggle-elevate ${Bs==="timeline"?"toggle-elevated":""}`,onClick:()=>{mo([]),ti("timeline")},"data-testid":"button-view-timeline",children:t.jsx(Hx,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Timeline Bar View"})]})]}),Bs==="events"&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>{La(I=>I==="desc"?"asc":"desc"),ce(0),et([void 0])},"data-testid":"button-sort-order",children:[t.jsx(PS,{className:"w-3 h-3"}),Na==="desc"?"Recent":"Oldest"]})}),t.jsx(Yt,{children:Na==="desc"?"Showing newest first — click for oldest first":"Showing oldest first — click for newest first"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:`toggle-elevate ${bi?"toggle-elevated":""}`,onClick:Xl,"data-testid":"button-autoplay-toggle-local",children:t.jsx(ky,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:bi?"Auto-Play: ON":"Auto-Play: OFF"})]}),Bs==="events"&&!pl.isLoading&&(tt||nt)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(L,{variant:"outline",size:"sm",onClick:Xg,disabled:!tt,"data-testid":"button-prev-page",children:[t.jsx(Kl,{className:"w-4 h-4 mr-1"})," Prev"]}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",be+1]}),t.jsxs(L,{variant:"outline",size:"sm",onClick:Np,disabled:!nt,"data-testid":"button-next-page",children:["Next ",t.jsx(hi,{className:"w-4 h-4 ml-1"})]})]})]})]}),Bs!=="events"?Hn.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(no,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"Select Cameras"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Use the Camera dropdown above to select which cameras to show on the timeline."})]}):Al.isLoading?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[t.jsx(Fe,{className:"w-4 h-4 animate-spin text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading — this may take 30 seconds or more for sites with many cameras or high activity."})]}),Array.from({length:4}).map((I,ie)=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Bt,{className:"h-4 w-28"}),t.jsx(Bt,{className:"h-8 flex-1"})]},ie))]}):Bs==="classic"?t.jsx(gk,{segments:tr?Ru:Ml,onEventClick:Go,selectedDate:Ea,onSelectDate:Ac,cameraDisplayNames:or,singleSiteName:Vo?.name,playingId:Ae?.id??z?.id??($e?String($e.id):null),privacyBlocked:d,recordingDays:tr?Ri:nc,detectionColor:fn.data?.timelineDetectionColor||void 0,motionColor:fn.data?.timelineMotionColor||void 0,onSwitchView:I=>{I==="events"?_o([...Ns]):mo([]),ti(I)},testIdPrefix:"classic-local"}):t.jsx(e9,{segments:tr?Ru:Ml,onSegmentClick:Go,siteId:b,timelineDate:Ea,detectionColor:fn.data?.timelineDetectionColor||void 0,motionColor:fn.data?.timelineMotionColor||void 0,cameraDisplayNames:or,privacyBlocked:d,distinguishSources:tr&&ac}):qn.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(no,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"Select Cameras"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Use the Camera dropdown above to select which cameras to show events for."})]}):pl.isLoading?t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Array.from({length:8}).map((I,ie)=>t.jsxs(ut,{children:[t.jsx(Bt,{className:"aspect-video w-full"}),t.jsxs(mt,{className:"p-3 space-y-2",children:[t.jsx(Bt,{className:"h-4 w-3/4"}),t.jsx(Bt,{className:"h-3 w-1/2"})]})]},ie))}):(wi?od:bn).length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(Vi,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Events Found"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:Ur.length>0?`No events found matching ${Ur.join(" or ")}. Try selecting different labels or clear the filter.`:"No AI events were found on this Edge device for the selected filters. Try adjusting the date range or camera selection."})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:(wi?od:bn).map(I=>t.jsxs(ut,{className:`overflow-visible ${d?"cursor-not-allowed":"hover-elevate cursor-pointer"}`,onClick:()=>{d||(Z(I),Y(null),fe(null),ge(-1),oc(null))},"data-testid":`card-event-${I.id}`,children:[t.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center rounded-t-md overflow-hidden",children:[d?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black","data-testid":`privacy-blocked-event-${I.id}`,children:t.jsx(ka,{className:"w-8 h-8 text-white/40"})}):t.jsx("img",{src:Ym(I),alt:`${I.camera}
556 - ${I.objects?.join(", ")||"review"}`,className:"w-full h-full object-cover",onError:ie=>{const Le=ie.target;Le.style.display="none";const Ye=Le.nextElementSibling;Ye&&(Ye.style.display="flex")}}),t.jsx("div",{className:"hidden items-center justify-center absolute inset-0 bg-black",children:t.jsx(wo,{className:"w-8 h-8 text-muted-foreground"})}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity",children:I.has_clip?t.jsx(vu,{className:"w-10 h-10 text-white"}):t.jsx(Ok,{className:"w-8 h-8 text-white"})}),t.jsxs("div",{className:"absolute top-2 left-2 flex items-center gap-1",children:[t.jsxs(Ke,{variant:"secondary",className:"text-[10px]",children:[t.jsx(Fa,{className:"w-2.5 h-2.5 mr-1"}),"Local"]}),I.objects&&I.objects.length>0?I.objects.map(ie=>{const Le=I.objectCounts?.[ie]||1;return t.jsxs(Ke,{variant:"outline",className:"text-[10px] bg-background/80",children:[ie.charAt(0).toUpperCase()+ie.slice(1),Le>1?` (${Le})`:""]},ie)}):I.label==="motion"?t.jsx(Ke,{variant:"outline",className:"text-[10px] bg-background/80",children:"Motion"}):null]})]}),t.jsxs(mt,{className:"p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(wo,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-sm font-medium truncate",children:I.displayName||or.get(I.camera)||I.camera})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(ro,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:Lu(I.start_time)})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[t.jsx(cn,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:$u(I.start_time)})]})]})]},I.id))}),wi?t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:Tc,className:"h-4"}),_u&&t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx(Fe,{className:"w-5 h-5 animate-spin text-muted-foreground mr-2"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading more..."})]}),!nt&&od.length>0&&t.jsx("p",{className:"text-center text-xs text-muted-foreground py-4",children:"No more events"})]}):Bs==="events"&&(tt||nt)?t.jsxs("div",{className:"flex items-center justify-center gap-4 mt-6",children:[t.jsxs(L,{variant:"outline",size:"sm",onClick:Xg,disabled:!tt,"data-testid":"button-prev-page-bottom",children:[t.jsx(Kl,{className:"w-4 h-4 mr-1"})," Prev"]}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",be+1]}),t.jsxs(L,{variant:"outline",size:"sm",onClick:Np,disabled:!nt,"data-testid":"button-next-page-bottom",children:["Next ",t.jsx(hi,{className:"w-4 h-4 ml-1"})]})]}):null]})]})]})}),t.jsx(ea,{value:"cloud",className:"space-y-4",children:sc.isLoading?t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Array.from({length:4}).map((I,ie)=>t.jsxs(ut,{children:[t.jsx(Bt,{className:"aspect-video w-full"}),t.jsxs(mt,{className:"p-3 space-y-2",children:[t.jsx(Bt,{className:"h-4 w-3/4"}),t.jsx(Bt,{className:"h-3 w-1/2"})]})]},ie))}):Wo?t.jsxs(t.Fragment,{children:[At&&t.jsxs("div",{className:"space-y-3","data-testid":"cloud-text-search-results-area",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ai,{className:"w-4 h-4 text-primary"}),t.jsxs("span",{className:"text-sm font-medium",children:["AI Search: ",At.length," match",At.length!==1?"es":""]}),Sn&&t.jsxs("span",{className:"text-xs text-muted-foreground italic",children:['— "',Sn,'"']})]}),t.jsxs(L,{size:"sm",variant:"outline",onClick:Ll,"data-testid":"button-cloud-text-search-clear-results",children:[t.jsx(va,{className:"w-3.5 h-3.5 mr-1"})," Clear Results"]})]}),At.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(ai,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Matches Found"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"No cloud events matched your search. Try different terms or a wider time range."})]}):t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:(kc||At).map(I=>t.jsxs(ut,{className:`overflow-visible ${d?"cursor-not-allowed":"hover-elevate cursor-pointer"}`,onClick:async()=>
556{if(!d&&I.cloudRecordingId){Z(null);const ie=Oi.find(Le=>Le.id===I.cloudRecordingId);ie?(bt(ie),Re(!1),De(-1),Ct(null)):(bt({id:I.cloudRecordingId,cameraName:I.camera,startTime:new Date(I.startTime*1e3).toISOString(),label:I.label,thumbnailPath:null}),Re(!1),De(-1),Ct(null))}},"data-testid":`card-cloud-text-search-result-${I.eventId}`,children:[t.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center rounded-t-md overflow-hidden",children:[d?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black","data-testid":`privacy-blocked-cloud-search-${I.eventId}`,children:t.jsx(ka,{className:"w-8 h-8 text-white/40"})}):t.jsx("img",{src:I.cloudRecordingId?`/api/cloud-recordings/${encodeURIComponent(I.cloudRecordingId)}/thumbnail`:`/api/local-recordings/${I.siteId}/thumbnail?detection=${encodeURIComponent(I.eventId)}&camera=${encodeURIComponent(I.camera)}`,alt:I.camera,loading:"lazy",decoding:"async",className:"w-full h-full object-cover",onError:ie=>{const Le=ie.target;Le.style.display="none";const Ye=Le.nextElementSibling;Ye&&(Ye.style.display="flex")}}),t.jsx("div",{className:"hidden items-center justify-center absolute inset-0 bg-black",children:t.jsx(wo,{className:"w-8 h-8 text-muted-foreground"})}),!d&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity",children:t.jsx(vu,{className:"w-10 h-10 text-white"})}),t.jsxs("div",{className:"absolute top-2 left-2 flex items-center gap-1",children:[t.jsxs(Ke,{variant:"secondary",className:"text-[10px]",children:[t.jsx(ai,{className:"w-2.5 h-2.5 mr-1"}),"AI Match"]}),t.jsx(Ke,{variant:"outline",className:"text-[10px] bg-background/80",children:I.label.charAt(0).toUpperCase()+I.label.slice(1)}),t.jsx(Ke,{variant:"outline",className:"text-[10px] bg-background/80",children:"Cloud"})]}),t.jsx("div",{className:"absolute top-2 right-2",children:t.jsxs(Ke,{className:`text-[10px] ${vr(I.score)}`,children:[I.score,"%"]})})]}),t.jsxs(mt,{className:"p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(wo,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-sm font-medium truncate",children:or.get(I.camera)||I.camera})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(ro,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:new Date(I.startTime*1e3).toLocaleDateString()})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[t.jsx(cn,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:new Date(I.startTime*1e3).toLocaleTimeString()})]})]})]},`cloud-${I.siteId}-${I.eventId}`))})]}),!At&&qt.length>0&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap","data-testid":"filter-cloud-labels",children:[t.jsx(Py,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx(Ke,{variant:Ur.length===0?"default":"outline",className:"cursor-pointer text-xs toggle-elevate",onClick:()=>{Da([]),na(0)},"data-testid":"filter-cloud-label-all",children:"All"}),qt.map(I=>t.jsx(Ke,{variant:Ur.includes(I)?"default":"outline",className:"cursor-pointer text-xs toggle-elevate",onClick:()=>{Da(ie=>ie.includes(I)?ie.filter(Le=>Le!==I):[...ie,I]),na(0)},"data-testid":`filter-cloud-label-${I}`,children:I.charAt(0).toUpperCase()+I.slice(1)},I))]}),!At&&oi&&Ur.some(I=>I!=="motion")&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap","data-testid":"filter-cloud-color",children:[t.jsx(Xr,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:"Color:"}),t.jsx(Ke,{variant:yn?"outline":"default",className:"cursor-pointer text-xs toggle-elevate",onClick:Ls,"data-testid":"filter-cloud-color-none",children:"None"}),Qs.map(I=>t.jsx(Ke,{variant:zo===I&&yn?"default":"outline",className:`cursor-pointer text-xs toggle-elevate ${Jc&&zo===I?"opacity-60":""}`,onClick:()=>{To(I)},"data-testid":`filter-cloud-color-${I.replace(/\s+/g,"-")}`,children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[Jc&&zo===I?t.jsx(Fe,{className:"w-2.5 h-2.5 animate-spin"}):t.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-border",style:{backgroundColor:rc[I]}}),t.jsx("span",{className:"capitalize",children:I})]})},I)),yn&&!Jc&&t.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:[Bs!=="events"?ko.length:tu.length," match",(Bs!=="events"?ko.length:tu.length)!==1?"es":""," (",Cl.done," scanned)"]}),Jc&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["Scanning ",Cl.done,Bs!=="events"?`/${Cl.total}`:""," events...",ko.length>0&&` (${ko.length} found)`]}),t.jsx(Ke,{variant:"destructive",className:"cursor-pointer text-xs ml-1",onClick:Qi,"data-testid":"button-stop-cloud-color-search",children:"Stop"})]})]}),!At&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:Rs.isLoading||zm.isLoading?"Loading...":""}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex items-center border rounded-md",children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`rounded-r-none toggle-elevate ${Bs==="classic"?"toggle-elevated":""}`,onClick:()=>{ti("classic")},"data-testid":"button-cloud-view-classic",children:t.jsx(cn,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Classic View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`rounded-l-none sm:rounded-r-none toggle-elevate ${Bs==="events"?"toggle-elevated":""}`,onClick:()=>{_o([...Ns]),ti("events")},"data-testid":"button-cloud-view-events",children:t.jsx(Cy,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Event Grid View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`hidden sm:inline-flex rounded-l-none toggle-elevate ${Bs==="timeline"?"toggle-elevated":""}`,onClick:()=>{mo([]),ti("timeline")},"data-testid":"button-cloud-view-timeline",children:t.jsx(Hx,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Timeline Bar View"})]})]}),Bs==="events"&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>{La(I=>I==="desc"?"asc":"desc"),na(0)},"data-testid":"button-sort-order-cloud",children:[t.jsx(PS,{className:"w-3 h-3"}),Na==="desc"?"Recent":"Oldest"]})}),t.jsx(Yt,{children:Na==="desc"?"Showing newest first — click for oldest first":"Showing oldest first — click for newest first"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:`toggle-elevate ${bi?"toggle-elevated":""}`,onClick:Xl,"data-testid":"button-autoplay-toggle-cloud",children:t.jsx(ky,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:bi?"Auto-Play: ON":"Auto-Play: OFF"})]}),Bs==="events"&&ji>1&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(L,{variant:"outline",size:"icon",disabled:Ei===0,onClick:()=>{na(I=>I-1),window.scrollTo({top:0,behavior:"smooth"})},"data-testid":"button-cloud-prev-page",children:t.jsx(Kl,{className:"w-4 h-4"})}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.jsx("span",{className:"hidden sm:inline",children:"Page "}),Ei+1," of ",ji]}),t.jsx(L,{variant:"outline",size:"icon",disabled:Ei>=ji-1,onClick:()=>{na(I=>I+1),window.scrollTo({top:0,behavior:"smooth"})},"data-testid":"button-cloud-next-page",children:t.jsx(hi,{className:"w-4 h-4"})})]})]})]}),Bs!=="events"?Hn.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(no,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"Select Cameras"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Use the Camera dropdown above to select which cameras to show on the timeline."})]}):zm.isLoading?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[t.jsx(Fe,{className:"w-4 h-4 animate-spin text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading — this may take 30 seconds or more for sites with many cameras or high activity."})]}),Array.from({length:4}).map((I,ie)=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Bt,{className:"h-4 w-28"}),t.jsx(Bt,{className:"h-8 flex-1"})]},ie))]}):Bs==="classic"?t.jsx(gk,{segments:tr?Ru:Oc,onEventClick:Go,selectedDate:Ea,onSelectDate:Ac,cameraDisplayNames:or,singleSiteName:Vo?.name,playingId:Ae?.id??z?.id??($e?String($e.id):null),privacyBlocked:d,recordingDays:tr?Ri:kl,detectionColor:fn.data?.timelineDetectionColor||void 0,motionColor:fn.data?.timelineMotionColor||void 0,onSwitchView:I=>{I==="events"?_o([...Ns]):mo([]),ti(I)},testIdPrefix:"classic-cloud"}):t.jsx(e9,{segments:tr?Ru:Oc,onSegmentClick:Go,siteId:b,timelineDate:Ea,detectionColor:fn.data?.timelineDetectionColor||void 0,motionColor:fn.data?.timelineMotionColor||void 0,cameraDisplayNames:or,privacyBlocked:d,distinguishSources:tr&&ac}):qn.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(no,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"Select Cameras"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Use the Camera dropdown above to select which cameras to show events for."})]}):Rs.isLoading?t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Array.from({length:8}).map((I,ie)=>t.jsxs(ut,{children:[t.jsx(Bt,{className:"aspect-video w-full"}),t.jsxs(mt,{className:"p-3 space-y-2",children:[t.jsx(Bt,{className:"h-4 w-3/4"}),t.jsx(Bt,{className:"h-3 w-1/2"})]})]},ie))}):Tl.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(pn,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:yn?"No Color Matches":"No Cloud Recordings"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:yn?"No cloud recordings matched the selected color filter.":"No cloud recordings found for the selected filters. Recordings will appear here once they sync from the Edge device."})]}):t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Tl.map(I=>t.jsxs(ut,{className:`overflow-visible ${d?"cursor-not-allowed":"hover-elevate cursor-pointer"}`,onClick:()=>{d||(Re(!1),bt(I))},"data-testid":`card-recording-${I.id}`,children:[t.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center rounded-t-md overflow-hidden",children:[d?t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black","data-testid":`privacy-blocked-rec
556ording-${I.id}`,children:t.jsx(ka,{className:"w-8 h-8 text-white/40"})}):I.thumbnailPath?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:I.thumbnailPath,alt:`${I.cameraName} - ${I.label||"recording"}`,className:"w-full h-full object-cover",onError:ie=>{const Le=ie.target;Le.style.display="none";const Ye=Le.nextElementSibling;Ye&&(Ye.style.display="flex")}}),t.jsx("div",{className:"hidden items-center justify-center absolute inset-0 bg-black",children:t.jsx(wo,{className:"w-8 h-8 text-muted-foreground"})})]}):t.jsx("div",{className:"flex items-center justify-center w-full h-full bg-black",children:t.jsx(wo,{className:"w-8 h-8 text-muted-foreground"})}),!d&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity",children:t.jsx(vu,{className:"w-10 h-10 text-white"})}),t.jsxs("div",{className:"absolute top-2 left-2 flex items-center gap-1",children:[t.jsxs(Ke,{variant:"secondary",className:"text-[10px]",children:[t.jsx(pn,{className:"w-2.5 h-2.5 mr-1"}),"Cloud"]}),I.label&&I.label.split(",").map((ie,Le)=>{const Ye=ie.trim();return Ye?t.jsx(Ke,{variant:"outline",className:"text-[10px] bg-background/80",children:Ye.charAt(0).toUpperCase()+Ye.slice(1)},Le):null})]}),I.score!=null&&t.jsxs(Ke,{variant:"secondary",className:"absolute top-2 right-2 text-[10px]",children:[Math.round(I.score*100),"%"]})]}),t.jsxs(mt,{className:"p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(wo,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-sm font-medium truncate",children:I.displayName||or.get(I.cameraName)||I.cameraName})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(ro,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:Sp(I.startTime)})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[t.jsx(cn,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:lm(I.startTime)})]}),!I.clipPath&&!I.thumbnailPath&&t.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400 mt-1",children:[t.jsx(ta,{className:"w-2.5 h-2.5 flex-shrink-0"}),t.jsx("span",{children:"Recording processing"})]})]})]},I.id))}),Bs==="events"&&ji>1&&t.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4","data-testid":"cloud-pagination-bottom",children:[t.jsx(L,{variant:"outline",size:"icon",disabled:Ei===0,onClick:()=>{na(I=>I-1),window.scrollTo({top:0,behavior:"smooth"})},"data-testid":"button-cloud-prev-page-bottom",children:t.jsx(Kl,{className:"w-4 h-4"})}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.jsx("span",{className:"hidden sm:inline",children:"Page "}),Ei+1," of ",ji]}),t.jsx(L,{variant:"outline",size:"icon",disabled:Ei>=ji-1,onClick:()=>{na(I=>I+1),window.scrollTo({top:0,behavior:"smooth"})},"data-testid":"button-cloud-next-page-bottom",children:t.jsx(hi,{className:"w-4 h-4"})})]})]})]}):t.jsxs("div",{className:"text-center py-16",children:[t.jsx(Zce,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"Cloud Storage Not Enabled"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Cloud recording sync is not enabled for this site's edge device. An administrator can enable cloud sync in the Admin Control panel."})]})})]})]}),t.jsx(Ys,{open:!!z&&!d,onOpenChange:I=>{I||(Z(null),Y(null),fe(null),ge(-1),oc(null),Mo())},children:t.jsxs(Ws,{className:"max-w-4xl player-dialog p-4 sm:p-5 gap-3",hideClose:!0,"aria-describedby":"local-recording-detail-desc",onEscapeKeyDown:I=>{Lt&&(I.preventDefault(),Mo())},onPointerDownOutside:I=>{!Lt||I.detail?.originalEvent?.target?.closest?.('[data-radix-popper-content-wrapper],[data-radix-select-content],[data-radix-select-viewport],[role="listbox"],[role="dialog"],[role="menu"]')||I.preventDefault()},onInteractOutside:I=>{!Lt||I.detail?.originalEvent?.target?.closest?.('[data-radix-popper-content-wrapper],[data-radix-select-content],[data-radix-select-viewport],[role="listbox"],[role="dialog"],[role="menu"]')||I.preventDefault()},children:[t.jsx(Ks,{className:"sr-only",children:"Local Recording Playback"}),t.jsx("p",{id:"local-recording-detail-desc",className:"sr-only",children:"Local recording detail view from Edge device"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 landscape-header",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[t.jsx(wo,{className:"w-4 h-4 flex-shrink-0"}),t.jsx("span",{className:"font-medium text-sm truncate",children:z?.camera?z.displayName||or.get(z.camera)||z.camera:""}),t.jsxs(Ke,{variant:"secondary",className:"text-[10px] px-1.5 py-0 landscape-hide",children:[t.jsx(Fa,{className:"w-3 h-3 mr-1"}),"Local"]}),z?.objects&&z.objects.length>0&&z.objects.map(I=>{const ie=z.objectCounts?.[I]||1;return t.jsxs(Ke,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[I.charAt(0).toUpperCase()+I.slice(1),ie>1?` (${ie})`:""]},I)})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 landscape-hide",children:[!Q&&ud.length>0&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{size:"icon",variant:"ghost",className:"h-8 w-8 inline-flex relative",onClick:ci,"data-testid":"button-header-snap-local",children:[t.jsx(mg,{className:"w-4 h-4"}),ud.length>1&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 text-[9px] bg-primary text-primary-foreground rounded-full w-3.5 h-3.5 flex items-center justify-center",children:ud.length})]})}),t.jsx(Yt,{children:"Snap to Object"})]}),!Q&&!c?.downloadRestricted&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:"h-8 w-8 sm:h-8 sm:w-8",onClick:()=>z&&$i(z),disabled:pe,"data-testid":"button-download-clip",children:pe?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):t.jsx(ya,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Download Clip"})]}),Mn&&!Q&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:Lt?"default":"ghost",className:"h-8 w-8 inline-flex",onClick:()=>
556{if(Lt)Mo();else{const I=H.current;I&&I.pause(),xr(!0),Xt(null),gt(null),xn(null)}},"data-testid":"button-header-visual-search",children:t.jsx(ai,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Visual Search"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:"h-8 w-8 hidden sm:inline-flex",onClick:()=>{const I=se.current;I&&X0(I)},"data-testid":"button-fullscreen-local",children:t.jsx(pf,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Fullscreen"})]}),t.jsx(HS,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:"h-10 w-10 sm:h-8 sm:w-8","data-testid":"button-close-local-player",children:t.jsx(va,{className:"h-5 w-5 sm:h-4 sm:w-4"})})})]})]}),t.jsx("div",{className:"space-y-3",children:t.jsxs("div",{ref:se,className:"fs-player-container",children:[t.jsxs("div",{className:"fs-overlay-btn",children:[!Q&&ud.length>0&&t.jsxs("button",{className:"flex items-center justify-center h-10 px-3 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer text-xs font-medium gap-1.5",onClick:ci,"data-testid":"button-fs-snap-local",children:[t.jsx(mg,{className:"w-4 h-4"}),ud.length>1&&t.jsxs("span",{children:[me>=0?me+1:1,"/",ud.length]})]}),!Q&&!c?.downloadRestricted&&t.jsx("button",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer",onClick:()=>z&&$i(z),"data-testid":"button-fs-download-local",children:pe?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):t.jsx(ya,{className:"w-4 h-4"})}),!Q&&Mn&&t.jsx("button",{className:`flex items-center justify-center w-10 h-10 rounded-full ${Lt?"bg-blue-600 hover:bg-blue-700":"bg-black/60 hover:bg-black/80"} text-white cursor-pointer`,onClick:()=>{if(Lt)Mo();else{const I=H.current;I&&I.pause(),xr(!0),Xt(null),gt(null),xn(null)}},"data-testid":"button-fs-visual-search",children:t.jsx(ai,{className:"w-4 h-4"})})]}),t.jsx("button",{className:"fs-exit-btn items-center justify-center w-10 h-10 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer",onClick:()=>{document.fullscreenElement&&document.exitFullscreen()},"data-testid":"button-exit-fullscreen-local",children:t.jsx(C0,{className:"w-5 h-5"})}),Q?t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"relative rounded-md overflow-hidden bg-black flex items-center justify-center landscape-video-wrap aspect-video fs-video-area",children:t.jsx("img",{src:z?Ym(z):"",alt:`${z?.camera} - ${z?.objects?.join(", ")||"review"}`,className:"max-w-full max-h-full object-contain","data-testid":"img-event-thumbnail",onError:I=>{const ie=I.target;ie.style.display="none"}})}),t.jsxs("div",{className:"flex flex-col gap-3 mt-3 p-3 rounded-md bg-muted text-sm text-muted-foreground","data-testid":"container-local-clip-error",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(ta,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),t.jsx("span",{"data-testid":"text-clip-error-message",children:Q||(z&&Date.now()/1e3-z.start_time<172800?"The recording clip could not be retrieved from the Edge device. The device may still be processing this event — please try again in a moment.":"This event appears to be overwritten on the Edge local storage drive.")})]}),Wo&&z&&!/Retrying/i.test(Q||"")&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-sm",children:"Would you like to access this event from cloud storage?"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(L,{variant:"default",size:"sm","data-testid":"button-cloud-fallback-yes",onClick:()=>{if(!z)return;const I=z.camera,ie=z.start_time;_o([I]),v("cloud"),zt({camera:I,startTime:ie}),Z(null),Y(null),fe(null),ge(-1),oc(null)},children:"Yes"}),t.jsx(L,{variant:"outline",size:"sm","data-testid":"button-cloud-fallback-no",onClick:()=>{Z(null),Y(null),fe(null),ge(-1),oc(null)},children:"No"})]})]})]})]}):t.jsxs("div",{className:"relative rounded-md landscape-video-wrap aspect-video max-h-[70vh] overflow-hidden bg-black fs-video-area clip-reveal","data-testid":"video-container",children:[t.jsx(d0,{videoRef:H,resetKey:z?.
556id}),!ns&&t.jsxs("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-black pointer-events-none","data-testid":"overlay-local-loading",children:[t.jsx("img",{src:ae.appEmblemUrl||Tm,alt:ae.brandName||"Loading",className:"w-20 h-20 object-contain opacity-90 animate-pulse"}),t.jsx("span",{className:"text-xs text-white/60",children:"Loading recording…"})]}),z&&t.jsx(jg,{testIdPrefix:"zoom-local",disabled:Lt,children:t.jsx(Jq,{hlsSrc:au(z),fallbackSrc:Cn?`${ku}&vt=${Cn}`:ku,eventId:z.id,controls:!1,siteId:b!=="none"?b:void 0,camera:z.camera,autoPlay:!0,muted:!!c?.audioRestricted,externalVideoRef:H,onError:()=>{if(tr&&z){const ie=H.current,Le=Math.floor(z.start_time)-5,Ye=(ie&&ie.currentTime>0?Le+ie.currentTime:z.start_time)*1e3,Mt=U4({attempted:su.current,failedSource:"local",clipId:z.id,camera:z.camera,timestampMs:Ye,altPool:Oc,tol:Fp});if(Mt){console.warn(`[HybridRetrieval] local playback failed — falling back to cloud camera=${z.camera}`),Rl(Mt);return}}const I=z?Date.now()/1e3-z.start_time:1/0;I<7200&&z&&oe.current[z.id]!==!0?(oe.current[z.id]=!0,Y("The Edge device is still finalizing this recording. Retrying in a moment…"),setTimeout(()=>{z&&(Y(null),je(ie=>ie+1))},3e4)):I<7200?Y("The Edge device is still finalizing this recording. It usually becomes available within a few minutes — please try again shortly."):Y("This clip is no longer available. The Edge device may not have recording segments stored for this event.")},onEnded:()=>{if(!(!bi||!z)){if(tr&&Bs!=="events"){const I=(z.end_time||z.start_time+10)*1e3,ie=Ol(z.camera,I,1);if(ie){ie.source!=="local"&&console.log(`[HybridRetrieval] auto-transition local→cloud camera=${z.camera}`),fl(ie);return}}Iu(z)}},onSourceDetected:I=>fe(I),onPlay:()=>oc(null),onLoadedMetadata:tr?Il:void 0,onCanPlay:()=>dt(!0),onTimeUpdate:I=>{!ns&&I.currentTarget.currentTime>0&&dt(!0)},"data-testid":"video-playback"},`${z.id}__retry-${he}`)}),z&&t.jsx(u0,{videoRef:H,resetKey:`${z.id}__retry-${he}`,audioRestricted:!!c?.audioRestricted,hidden:Lt,fullscreenTargetRef:se,testIdPrefix:"vc-local"}),iu&&(()=>{const I=Df(iu);return t.jsx("div",{className:"absolute top-2 left-2 pointer-events-none",style:{zIndex:10},"data-testid":"snap-label-tag",children:t.jsx("span",{className:"text-xs font-bold text-white px-2 py-1 rounded-md whitespace-nowrap shadow-md",style:{backgroundColor:I.bg},children:iu})})})(),t.jsx(fC,{videoRef:H,onCrop:_p,onCancel:()=>xr(!1),active:Lt}),ue==="preview"&&z&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 p-2 rounded-md bg-muted text-xs text-muted-foreground",children:[t.jsx(ta,{className:"w-3.5 h-3.5 flex-shrink-0"}),t.jsx("span",{children:Date.now()/1e3-z.start_time<7200?"Showing AI preview. Full recording will be available once the Edge device finishes processing (usually within 2 hours).":"Showing AI preview. Full recording clips are unavailable - the Edge device recording segments may have expired."})]})]}),t.jsx("div",{className:"landscape-hide text-center text-[10px] text-muted-foreground",children:z&&$u(z.start_time)}),t.jsx("div",{className:"landscape-mini-timeline fs-mini-timeline-area",children:t.jsx(gC,{events:tr?Du:Md,currentEventId:tr?Km:z?.id||null,loadedStartMs:tr?Of:si,loadedEndMs:tr?wp:Ka,onPanRequestMore:tr?Gm:Yo,isLoadingBefore:tr?jp:Pr,isLoadingAfter:tr?Qg:am,atStartCap:tr?ic:Ji,atEndCap:tr?om:pi,onEventSelect:tr?nu:I=>{const ie=Di.find(Le=>Le.id===I)||Ni.find(Le=>Le.id===I)||Ar.find(Le=>Le.id===I);ie&&(Z(ie),Y(null),fe(null),ge(-1),oc(null))}})}),qe&&!es&&!Ut&&t.jsx("div",{className:"flex flex-col gap-2 p-2 rounded-md bg-muted landscape-hide","data-testid":"visual-search-confirm",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:qe,alt:"Cropped selection",className:"h-14 w-auto rounded border border-border object-contain","data-testid":"img-visual-search-crop"}),t.jsxs("div",{className:"flex-1 flex flex-wrap items-center gap-2",children:[t.jsxs(Us,{value:String(ua),onValueChange:I=>Ua(Number(I)),children:[t.jsx($s,{className:"h-7 w-[110px] text-xs","data-testid":"select-vs-time-window",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"1800",children:"± 30 min"}),t.jsx(rt,{value:"3600",children:"± 1 hour"}),t.jsx(rt,{value:"7200",children:"± 2 hours"}),t.jsx(rt,{value:"14400",children:"± 4 hours"}),t.jsx(rt,{value:"43200",children:"± 12 hours"}),t.jsx(rt,{value:"86400",children:"± 24 hours"})]})]}),t.jsxs(Us,{value:Ln,onValueChange:I=>Ir(I),children:[t.jsx($s,{className:"h-7 w-[120px] text-xs","data-testid":"select-vs-camera-scope",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All cameras"}),t.jsx(rt,{value:"current",children:"This camera"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(L,{size:"sm",onClick:()=>Pp(),"data-testid":"button-visual-search-go",children:[t.jsx(ai,{className:"w-3.5 h-3.5 mr-1"}),"Search"]}),t.jsx(L,{size:"sm",variant:"outline",onClick:Mo,"data-testid":"button-visual-search-cancel",children:"Cancel"})]})]})}),es&&t.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-md bg-muted landscape-hide","data-testid":"visual-search-loading",children:[t.jsx(Fe,{className:"w-5 h-5 animate-spin text-primary"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-muted-foreground","data-testid":"text-visual-search-progress",children:Br&&Br.total>0?`Scoring ${Math.min(Br.scored,Br.total)} / ${Br.total} images${Ut&&Ut.length>0?` — ${Ut.length} match${Ut.length!==1?"es":""} so far`:""}`:"Analyzing image and searching recordings..."}),Br&&Br.total>0&&t.jsx("div",{className:"mt-1.5 h-1 w-full bg-background rounded overflow-hidden",children:t.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.min(100,Math.round(Br.scored/Math.max(1,Br.total)*100))}%`}})})]}),t.jsx(L,{size:"sm",variant:"outline",onClick:Mo,"data-testid":"button-visual-search-loading-cancel",children:"Cancel"})]}),Ut&&t.jsxs("div",{className:"rounded-md border bg-card landscape-hide","data-testid":"visual-search-results",children:[t.jsxs("div",{className:"flex items-center justify-between p-2 border-b",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ai,{className:"w-4 h-4 text-primary"}),t.jsxs("span",{className:"text-sm font-medium",children:[Ut.length," match",Ut.length!==1?"es":""," found"]}
556)]}),t.jsx(L,{size:"sm",variant:"ghost",onClick:Mo,"data-testid":"button-visual-search-close",children:t.jsx(va,{className:"w-3.5 h-3.5"})})]}),fr&&t.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground border-b bg-muted/50 italic","data-testid":"text-visual-search-description",children:["Looking for: ",fr]}),Ut.length===0?t.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground","data-testid":"text-visual-search-empty",children:"No similar events found in the selected time window. Try a wider time range or more distinctive area."}):t.jsx("div",{className:"max-h-48 overflow-y-auto divide-y","data-testid":"visual-search-results-list",children:(_c||Ut).map(I=>t.jsxs("button",{className:`flex items-center gap-3 w-full p-2 hover:bg-muted/50 text-left cursor-pointer ${z?.id===I.eventId?"bg-primary/10 border-l-2 border-l-primary":""}`,onClick:async()=>{if(I.source==="cloud"&&I.cloudRecordingId){const Le=Oi.find(Ye=>Ye.id===I.cloudRecordingId);Le?(Z(null),bt(Le),Re(!1),De(-1),Ct(null)):(Z(null),bt({id:I.cloudRecordingId,cameraName:I.camera,startTime:new Date(I.startTime*1e3).toISOString(),label:I.label,thumbnailPath:null}),Re(!1),De(-1),Ct(null));return}const ie={id:I.eventId,camera:I.camera,label:I.label,zones:[],start_time:I.startTime,end_time:I.startTime+30,objects:[I.label],detections:[I.eventId],score:I.score/100,severity:"detection",has_clip:!0,has_snapshot:!0};Z(ie),Y(null),fe(null),ge(-1),oc(null)},"data-testid":`button-visual-search-result-${I.eventId}`,children:[d?t.jsx("div",{className:"h-10 w-16 rounded bg-black flex items-center justify-center shrink-0","data-testid":`privacy-blocked-visual-search-${I.eventId}`,children:t.jsx(ka,{className:"w-4 h-4 text-white/40"})}):t.jsx("img",{src:I.source==="cloud"&&I.cloudRecordingId?`/api/cloud-recordings/${encodeURIComponent(I.cloudRecordingId)}/thumbnail`:`/api/local-recordings/${I.siteId}/thumbnail?detection=${encodeURIComponent(I.eventId)}&camera=${encodeURIComponent(I.camera)}`,alt:I.camera,loading:"lazy",decoding:"async",className:"h-10 w-16 rounded object-cover bg-black",onError:ie=>{ie.target.style.display="none"}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs font-medium truncate",children:or.get(I.camera)||I.camera}),t.jsx("div",{className:"text-[10px] text-muted-foreground",children:new Date(I.startTime*1e3).toLocaleString()})]}),t.jsxs(Ke,{className:`text-[10px] px-1.5 shrink-0 ${vr(I.score)}`,children:[I.score,"%"]}),I.source==="cloud"&&t.jsx(Ke,{variant:"secondary",className:"text-[10px] px-1 shrink-0",children:"Cloud"})]},`${I.siteId}-${I.eventId}`))})]})]})})]})}),t.jsx(Ys,{open:!!$e||!!Ae&&!d,onOpenChange:I=>{I||(bt(null),Be(null),Y(null),Re(!1),De(-1),Ct(null),Mo())},children:t.jsxs(Ws,{className:"max-w-4xl player-dialog p-4 sm:p-5 gap-3",hideClose:!0,"aria-describedby":"cloud-recording-detail-desc",onEscapeKeyDown:I=>{Lt&&(I.preventDefault(),Mo())},onPointerDownOutside:I=>{!Lt||I.detail?.originalEvent?.target?.closest?.('[data-radix-popper-content-wrapper],[data-radix-select-content],[data-radix-select-viewport],[role="listbox"],[role="dialog"],[role="menu"]')||I.preventDefault()},onInteractOutside:I=>{!Lt||I.detail?.originalEvent?.target?.closest?.('[data-radix-popper-content-wrapper],[data-radix-select-content],[data-radix-select-viewport],[role="listbox"],[role="dialog"],[role="menu"]')||I.preventDefault()},children:[t.jsx(Ks,{className:"sr-only",children:"Cloud Recording Playback"}
556),t.jsx("p",{id:"cloud-recording-detail-desc",className:"sr-only",children:"Cloud recording detail view with playback and download"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 landscape-header",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[t.jsx(wo,{className:"w-4 h-4 flex-shrink-0"}),t.jsx("span",{className:"font-medium text-sm truncate",children:Ae?Ae.displayName||or.get(Ae.camera)||Ae.camera:$e?.cameraName?$e.displayName||or.get($e.cameraName)||$e.cameraName:""}),Ae&&ac?t.jsxs(Ke,{variant:"secondary",className:"text-[10px] px-1.5 py-0 landscape-hide",children:[t.jsx(Fa,{className:"w-3 h-3 mr-1"}),"Local"]}):t.jsxs(Ke,{variant:"secondary",className:"text-[10px] px-1.5 py-0 landscape-hide",children:[t.jsx(pn,{className:"w-3 h-3 mr-1"}),"Cloud"]}),$e?.label&&$e.label.split(",").map((I,ie)=>{const Le=I.trim();return Le?t.jsx(Ke,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:Le.charAt(0).toUpperCase()+Le.slice(1)},ie):null})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 landscape-hide",children:[Ae&&!c?.downloadRestricted&&t.jsx(L,{size:"icon",variant:"ghost",className:"h-8 w-8 sm:h-8 sm:w-8",title:"Download","data-testid":"button-download-hybrid-local-clip",onClick:()=>Ae&&$i(Ae),children:t.jsx(ya,{className:"w-4 h-4"})}),$e&&!c?.downloadRestricted&&t.jsx(L,{size:"icon",variant:"ghost",className:"h-8 w-8 sm:h-8 sm:w-8",title:"Download from Cloud","data-testid":"button-download-cloud-clip",onClick:()=>{const I=document.createElement("a");I.href=`/api/cloud-recordings/${$e.id}/download?type=clip`,document.body.appendChild(I),I.click(),document.body.removeChild(I)},children:t.jsx(ya,{className:"w-4 h-4"})}),ca.length>0&&!Qt&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{size:"icon",variant:"ghost",className:"h-8 w-8 inline-flex relative",onClick:to,"data-testid":"button-header-snap-cloud",children:[t.jsx(mg,{className:"w-4 h-4"}),ca.length>1&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 text-[9px] bg-primary text-primary-foreground rounded-full w-3.5 h-3.5 flex items-center justify-center",children:ca.length})]})}),t.jsx(Yt,{children:"Snap to Object"})]}),Mn&&!Qt&&!Ae&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:Lt?"default":"ghost",className:"h-8 w-8 inline-flex",onClick:()=>{if(Lt)Mo();else{const I=fs.current;I&&I.pause(),xr(!0),Xt(null),gt(null),xn(null)}},"data-testid":"button-header-visual-search-cloud",children:t.jsx(ai,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Visual Search"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:"h-8 w-8 hidden sm:inline-flex",onClick:()=>{const I=ne.current;I&&X0(I)},"data-testid":"button-fullscreen-cloud",children:t.jsx(pf,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Fullscreen"})]}),t.jsx(HS,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:"h-10 w-10 sm:h-8 sm:w-8","data-testid":"button-close-cloud-player",children:t.jsx(va,{className:"h-5 w-5 sm:h-4 sm:w-4"})})})]})]}),t.jsx("div",{className:"space-y-3",children:t.jsxs("div",{ref:ne,className:"fs-player-container",children:[t.jsxs("div",{className:"fs-overlay-btn",children:[ca.length>0&&!Qt&&t.jsxs("button",{className:"flex items-center justify-center h-10 px-3 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer text-xs font-medium gap-1.5",onClick:to,"data-testid":"button-fs-snap-cloud",children:[t.jsx(mg,{className:"w-4 h-4"}),ca.length>1&&t.jsxs("span",{children:[Oe>=0?Oe+1:1,"/",ca.length]})]}),$e&&!c?.downloadRestricted&&t.jsx("button",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer",onClick:()=>{if(!$e)return;const I=document.createElement("a");I.href=`/api/cloud-recordings/${$e.id}/download?type=clip`,document.body.appendChild(I),I.click(),document.body.removeChild(I)},"data-testid":"button-fs-download-cloud",children:t.jsx(ya,{className:"w-4 h-4"})}),Ae&&!c?.downloadRestricted&&t.jsx("button",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer",onClick:()=>Ae&&$i(Ae),"data-testid":"button-fs-download-hybrid-local",children:t.jsx(ya,{className:"w-4 h-4"})}),!Qt&&Mn&&!Ae&&t.jsx("button",{className:`flex items-center justify-center w-10 h-10 rounded-full ${Lt?"bg-blue-600 hover:bg-blue-700":"bg-black/60 hover:bg-black/80"} text-white cursor-pointer`,onClick:()=>
556{if(Lt)Mo();else{const I=fs.current;I&&I.pause(),xr(!0),Xt(null),gt(null),xn(null)}},"data-testid":"button-fs-visual-search-cloud",children:t.jsx(ai,{className:"w-4 h-4"})})]}),t.jsx("button",{className:"fs-exit-btn items-center justify-center w-10 h-10 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer",onClick:()=>{document.fullscreenElement&&document.exitFullscreen()},"data-testid":"button-exit-fullscreen-cloud",children:t.jsx(C0,{className:"w-5 h-5"})}),Ae&&Q?t.jsxs("div",{"data-testid":"hybrid-local-clip-fallback",children:[t.jsx("div",{className:"relative rounded-md overflow-hidden bg-black flex items-center justify-center landscape-video-wrap aspect-video fs-video-area",children:t.jsx("img",{src:Ym(Ae),alt:"Recording thumbnail",className:"max-w-full max-h-full object-contain",onError:I=>{I.target.style.display="none"}})}),t.jsxs("div",{className:"flex items-start gap-2 mt-2 p-2 rounded-md bg-muted text-xs text-muted-foreground",children:[t.jsx(ta,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),t.jsx("span",{"data-testid":"text-hybrid-clip-error",children:Q})]})]}):Ae?t.jsxs("div",{className:"relative rounded-md landscape-video-wrap aspect-video max-h-[70vh] overflow-hidden bg-black fs-video-area clip-reveal","data-testid":"video-container-hybrid-local",children:[t.jsx(d0,{videoRef:H,resetKey:Ae.id}),!ns&&t.jsxs("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-black pointer-events-none","data-testid":"overlay-hybrid-local-loading",children:[t.jsx("img",{src:ae.appEmblemUrl||Tm,alt:ae.brandName||"Loading",className:"w-20 h-20 object-contain opacity-90 animate-pulse"}),t.jsx("span",{className:"text-xs text-white/60",children:"Loading recording…"})]}),t.jsx(jg,{testIdPrefix:"zoom-hybrid-local",disabled:Lt,children:t.jsx(Jq,{hlsSrc:au(Ae),fallbackSrc:Cn?`${ma}&vt=${Cn}`:ma,eventId:Ae.id,controls:!1,siteId:b!=="none"?b:void 0,camera:Ae.camera,autoPlay:!0,muted:!!c?.audioRestricted,externalVideoRef:H,onError:()=>{const I=H.current,ie=Math.floor(Ae.start_time)-5,Le=(I&&I.currentTime>0?ie+I.currentTime:Ae.start_time)*1e3,Ye=U4({attempted:su.current,failedSource:"local",clipId:Ae.id,camera:Ae.camera,timestampMs:Le,altPool:Oc,tol:Fp});if(Ye){console.warn(`[HybridRetrieval] local playback failed — falling back to cloud camera=${Ae.camera}`),Rl(Ye);return}const Mt=Date.now()/1e3-Ae.start_time;Mt<7200&&oe.current[Ae.id]!==!0?(oe.current[Ae.id]=!0,Y("The Edge device is still finalizing this recording. Retrying in a moment…"),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>{J.current=null,Y(null),je(_s=>_s+1)},3e4)):Mt<7200?Y("The Edge device is still finalizing this recording. It usually becomes available within a few minutes — please try again shortly."):Y("This clip is no longer available. The Edge device may not have recording segments stored for this event.")},onEnded:()=>{if(!bi)return;const I=(Ae.end_time||Ae.start_time+10)*1e3,ie=Ol(Ae.camera,I,1);ie&&(ie.source!=="local"&&console.log(`[HybridRetrieval] auto-transition local→cloud camera=${Ae.camera}`),fl(ie))},onLoadedMetadata:Il,onCanPlay:()=>dt(!0),onTimeUpdate:I=>{!ns&&I.currentTarget.currentTime>0&&dt(!0)},"data-testid":"video-hybrid-local-playback"},`${Ae.id}__hybrid-retry-${he}`)}),t.jsx(u0,{videoRef:H,resetKey:`${Ae.id}__hybrid-retry-${he}`,audioRestricted:!!c?.audioRestricted,hidden:Lt,fullscreenTargetRef:ne,testIdPrefix:"vc-hybrid-local"})]}):$e&&!Qt?t.jsxs("div",{className:"relative rounded-md landscape-video-wrap aspect-video max-h-[70vh] overflow-hidden bg-black fs-video-area clip-reveal",children:[t.jsx(d0,{videoRef:fs,resetKey:$e.id}),we.length===0&&!ye&&t.jsxs("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-black pointer-events-none","data-testid":"overlay-cloud-loading",children:[t.jsx("img",{src:ae.appEmblemUrl||Tm,alt:ae.brandName||"Loading",className:"w-20 h-20 object-contain opacity-90 animate-pulse"}),t.jsx("span",{className:"text-xs text-white/60",children:"Loading recording…"})]}),t.jsx(jg,{testIdPrefix:"zoom-cloud",disabled:Lt,children:t.jsx("div",{className:`relative w-full h-full ${c?.audioRestricted?"audio-restricted":""}`,children:t.jsx("video",{ref:fs,crossOrigin:"anonymous",src:co,playsInl
556ine:!0,autoPlay:!0,muted:!!c?.audioRestricted||void 0,className:"w-full h-full rounded-md bg-black object-contain","data-testid":"video-cloud-playback",onEnded:()=>{if(we.length>1&&Ue<we.length-1){We(I=>I+1);return}if(!(!bi||!$e)){if(tr&&Bs!=="events"){const I=new Date($e.startTime).getTime(),ie=$e.endTime?new Date($e.endTime).getTime():I+3e4,Le=Ol($e.cameraName,ie,1);if(Le){Le.source!=="cloud"&&console.log(`[HybridRetrieval] auto-transition cloud→local camera=${$e.cameraName}`),fl(Le);return}}Ou($e)}},onError:I=>{const ie=I.currentTarget,Le=$e?.id||"";if(Le&&ie.currentSrc&&!ie.currentSrc.includes(`/api/cloud-recordings/${Le}/`)){console.log("[CloudClip] stale onError ignored",{expectedId:Le,src:ie.currentSrc});return}if(Le&&!ie.currentSrc){console.log("[CloudClip] empty-src onError ignored",{expectedId:Le});return}const Ye=ie.error,Mt=Ye?`code=${Ye.code} (${["","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED"][Ye.code]||"UNKNOWN"}) message="${Ye.message||""}" netState=${ie.networkState} readyState=${ie.readyState}`:`no MediaError netState=${ie.networkState} readyState=${ie.readyState}`;if(console.log("[CloudClip] onError",{id:Le,detail:Mt,src:ie.currentSrc}),$o("clip",`cloud clip error: ${Mt}`,{id:Le,src:ie.currentSrc}),(Ye?.code===3||Ye?.code===4)&&!Es&&!Nc){console.log("[CloudClip] decode error — retrying with server transcode",{id:Le,at:ie.currentTime}),ft.current=ie.currentTime>1?ie.currentTime:null,Ge(!0);return}if(Nc&&St.length>0){Qe(St),It([]),We(0);return}if(tr&&$e){const _s=new Date($e.startTime).getTime(),Ts=we.length<=1&&ie.currentTime>0?_s+ie.currentTime*1e3:_s,ls=U4({attempted:su.current,failedSource:"cloud",clipId:$e.id,camera:$e.cameraName,timestampMs:Ts,altPool:Ml,tol:Fp});if(ls){console.warn(`[HybridRetrieval] cloud playback failed — falling back to local camera=${$e.cameraName}`),Rl(ls,{seekToMs:Ts});return}console.warn(`[HybridRetrieval] cloud playback failed and no local fallback available camera=${$e.cameraName}`)}Ft(Mt),Re(!0)},onCanPlay:I=>{te(!0);const ie=ft.current;if(ie!=null&&Es){ft.current=null;try{const Le=I.currentTarget;Number.isFinite(Le.duration)&&ie<Le.duration-1&&(Le.currentTime=Math.max(0,ie-.5))}catch{}}},onPlay:I=>{Ct(null),te(!0),c?.audioRestricted&&(I.currentTarget.muted=!0,I.currentTarget.volume=0)},onVolumeChange:I=>{if(c?.audioRestricted){const ie=I.currentTarget;(!ie.muted||ie.volume>0)&&(ie.muted=!0,ie.volume=0)}},onTimeUpdate:I=>{const ie=I.currentTarget;if(Es||Nc||ie.currentTime<2)return;const Le=ie.getVideoPlaybackQuality?.();(ie.videoWidth===0||Le&&Le.totalVideoFrames===0)&&(console.log("[CloudClip] black playback detected (0 decoded frames) — retrying with server transcode",{id:$e?.id,at:ie.currentTime}),$o("clip",`cloud clip black-playback watchdog fired (videoWidth=${ie.videoWidth}, frames=${Le?.totalVideoFrames??"n/a"})`,{id:$e?.id}),ft.current=ie.currentTime>1?ie.currentTime:null,Ge(!0))}},`${$e.id}__chunk${Ue}`)})}),t.jsx(u0,{videoRef:fs,resetKey:`${$e.id}__chunk${Ue}`,audioRestricted:!!c?.audioRestricted,hidden:Lt,fullscreenTargetRef:ne,testIdPrefix:"vc-cloud"}),jt&&(()=>{const I=Df(jt);return t.jsx("div",{className:"absolute top-2 left-2 pointer-events-none",style:{zIndex:10},"data-testid":"cloud-snap-label-tag",children:t.jsx("span",{className:"text-xs font-bold text-white px-2 py-1 rounded-md whitespace-nowrap shadow-md",style:{backgroundColor:I.bg},children:jt})})})(),t.jsx(fC,{videoRef:fs,onCrop:_p,onCancel:()=>xr(!1),active:Lt})]}):$e&&Qt?t.jsxs("div",{"data-testid":"cloud-clip-fallback",children:[t.jsx("div",{className:"relative rounded-md overflow-hidden bg-black flex items-center justify-center landscape-video-wrap aspect-video fs-video-area",children:$e.thumbnailPath?t.jsx("img",{src:$e.thumbnailPath,alt:"Recording thumbnail",className:"max-w-full max-h-full object-contain"}):t.jsx("p",{className:"text-muted-foreground",children:"No media available"})}),t.jsxs("div",{className:"flex items-start gap-2 mt-2 p-2 rounded-md bg-muted text-xs text-muted-foreground",children:[t.jsx(ta,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[$e.retentionExpired?t.jsxs("div",{"data-testid":"cloud-clip-expired-message",children:["This event is outside your cloud storage plan",$e.retentionDays?` (${$e.retentionDays} days)`:""," and its video has expired. Expired footage is automatically removed from cloud storage and can no longer be played or downloaded."]}):t.jsx("div",{children:"Video for this event hasn't reached the cloud yet. When a device falls behind, footage uploads oldest-first — this event's video will become playable automatically once the device catches up to it (this can take a while on slower connections)."}),pt&&!$e.retentionExpired&&t.jsxs("div",{className:"mt-1 font-mono text-[10px] break-all opacity-70","data-testid":"cloud-clip-error-detail",children:["debug: ",pt]})]})]})]}):null,t.jsx("div",{className:"landscape-hide text-center text-[10px] text-muted-foreground",children:Ae?lm(new Date(Ae.start_time*1e3)):$e&&lm($e.startTime)}),t.jsx("div",{className:"landscape-mini-timeline fs-mini-timeline-area",children:t.jsx(gC,{events:tr?Du:bv,currentEventId:tr?Km:$e?.id||null,loadedStartMs:tr?Of:yv,loadedEndMs:tr?wp:qm,onPanRequestMore:tr?Gm:im,isLoadingBefore:tr?jp:Rf,isLoadingAfter:tr?Qg:Vm,atStartCap:tr?ic:bp,atEndCap:tr?om
556:Gg,onEventSelect:tr?nu:I=>{const ie=Wa.find(Le=>Le.id===I)||cd.find(Le=>Le.id===I)||(Uc.data?.recordings||[]).find(Le=>Le.id===I);ie&&(Re(!1),bt(ie),De(-1),Ct(null))}})}),qe&&!es&&!Ut&&t.jsxs("div",{className:"flex flex-wrap items-center gap-3 p-2 rounded-md bg-muted landscape-hide","data-testid":"cloud-visual-search-crop-panel",children:[t.jsx("img",{src:qe,alt:"Cropped",className:"h-16 rounded border"}),t.jsxs("div",{className:"flex flex-col gap-1.5 flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Us,{value:String(ua),onValueChange:I=>Ua(Number(I)),children:[t.jsx($s,{className:"h-7 w-[120px] text-xs","data-testid":"select-vs-time-range-cloud",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"1800",children:"± 30 min"}),t.jsx(rt,{value:"3600",children:"± 1 hour"}),t.jsx(rt,{value:"7200",children:"± 2 hours"}),t.jsx(rt,{value:"14400",children:"± 4 hours"}),t.jsx(rt,{value:"43200",children:"± 12 hours"}),t.jsx(rt,{value:"86400",children:"± 24 hours"})]})]}),t.jsxs(Us,{value:Ln,onValueChange:I=>Ir(I),children:[t.jsx($s,{className:"h-7 w-[120px] text-xs","data-testid":"select-vs-camera-scope-cloud",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All cameras"}),t.jsx(rt,{value:"current",children:"This camera"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(L,{size:"sm",onClick:()=>Pp(),"data-testid":"button-visual-search-go-cloud",children:[t.jsx(ai,{className:"w-3.5 h-3.5 mr-1"}),"Search"]}),t.jsx(L,{size:"sm",variant:"outline",onClick:Mo,"data-testid":"button-visual-search-cancel-cloud",children:"Cancel"})]})]})]}),es&&t.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-md bg-muted landscape-hide","data-testid":"cloud-visual-search-loading",children:[t.jsx(Fe,{className:"w-5 h-5 animate-spin text-primary"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-muted-foreground","data-testid":"text-cloud-visual-search-progress",children:Br&&Br.total>0?`Scoring ${Math.min(Br.scored,Br.total)} / ${Br.total} images${Ut&&Ut.length>0?` — ${Ut.length} match${Ut.length!==1?"es":""} so far`:""}`:"Analyzing image and searching recordings..."}),Br&&Br.total>0&&t.jsx("div",{className:"mt-1.5 h-1 w-full bg-background rounded overflow-hidden",children:t.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.min(100,Math.round(Br.scored/Math.max(1,Br.total)*100))}%`}})})]}),t.jsx(L,{size:"sm",variant:"outline",onClick:Mo,"data-testid":"button-cloud-visual-search-loading-cancel",children:"Cancel"})]}),Ut&&t.jsxs("div",{className:"rounded-md border bg-card landscape-hide","data-testid":"cloud-visual-search-results",children:[t.jsxs("div",{className:"flex items-center justify-between p-2 border-b",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ai,{className:"w-4 h-4 text-primary"}),t.jsxs("span",{className:"text-sm font-medium",children:[Ut.length," match",Ut.length!==1?"es":""," found"]})]}),t.jsx(L,{size:"sm",variant:"ghost",onClick:Mo,"data-testid":"button-cloud-visual-search-close",children:t.jsx(va,{className:"w-3.5 h-3.5"})})]}),fr&&t.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground border-b bg-muted/50 italic","data-testid":"text-cloud-visual-search-description",children:["Looking for: ",fr]}),Ut.length===0?t.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground","data-testid":"text-cloud-visual-search-empty",children:"No similar events found in the selected time window."}):t.jsx("div",{className:"max-h-48 overflow-y-auto divide-y","data-testid":"cloud-visual-search-results-list",children:(_c||Ut).map(I=>t.jsxs("button",{className:"flex items-center gap-3 w-full p-2 hover:bg-muted/50 text-left cursor-pointer",onClick:async()=>{if(I.source==="cloud"&&I.cloudRecordingId){const Le=Oi.find(Ye=>Ye.id===I.cloudRecordingId);Be(null),Y(null),Le?(bt(Le),Re(!1),De(-1),Ct(null)):(bt({id:I.cloudRecordingId,cameraName:I.camera,startTime:new Date(I.startTime*1e3).toISOString(),label:I.label,thumbnailPath:null}),Re(!1),De(-1),Ct(null));return}const ie={id:I.eventId,camera:I.camera,label:I.label,zones:[],start_time:I.startTime,end_time:I.startTime+30,objects:[I.label],detections:[I.eventId],score:I.score/100,severity:"detection",has_clip:!0,has_snapshot:!0};bt(null),Be(null),Z(ie),Y(null),fe(null),ge(-1),oc(null)},"data-testid":`button-cloud-visual-search-result-${I.eventId}`,children:[d?t.jsx("div",{className:"h-10 w-16 rounded bg-black flex items-center justify-center shrink-0","data-testid":`privacy-blocked-cloud-visual-search-${I.eventId}`,children:t.jsx(ka,{className:"w-4 h-4 text-white/40"})}):t.jsx("img",{src:I.source==="cloud"&&I.cloudRecordingId?`/api/cloud-rec
556ordings/${encodeURIComponent(I.cloudRecordingId)}/thumbnail`:`/api/local-recordings/${I.siteId}/thumbnail?detection=${encodeURIComponent(I.eventId)}&camera=${encodeURIComponent(I.camera)}`,alt:I.camera,loading:"lazy",decoding:"async",className:"h-10 w-16 rounded object-cover bg-black",onError:ie=>{ie.target.style.display="none"}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs font-medium truncate",children:or.get(I.camera)||I.camera}),t.jsx("div",{className:"text-[10px] text-muted-foreground",children:new Date(I.startTime*1e3).toLocaleString()})]}),t.jsxs(Ke,{className:`text-[10px] px-1.5 shrink-0 ${vr(I.score)}`,children:[I.score,"%"]}),I.source==="cloud"&&t.jsx(Ke,{variant:"secondary",className:"text-[10px] px-1 shrink-0",children:"Cloud"})]},`${I.siteId}-${I.eventId}`))})]})]})})]})}),t.jsx(zd,{open:nr!==null,onOpenChange:I=>{I||(qr(null),So.current=null)},children:t.jsxs(bd,{"data-testid":"dialog-ai-quota-confirm",children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:nr?.exceeds?"This search may exhaust today's AI quota":"Confirm AI search"}),t.jsx(Sd,{asChild:!0,children:nr?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:["This ",nr.kind==="text"?"text search":"visual search"," is estimated to scan up to"," ",t.jsx("span",{className:"font-medium","data-testid":"text-quota-est-images",children:nr.estImages})," images, which uses about"," ",t.jsx("span",{className:"font-medium","data-testid":"text-quota-est-requests",children:nr.estRequests})," ","AI request",nr.estRequests===1?"":"s"," (roughly 1 request per 25 images)."]}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:["Scope: ",nr.cameraScope," · ",nr.severityScope]}),t.jsxs("div",{children:["You have"," ",t.jsx("span",{className:"font-medium","data-testid":"text-quota-remaining",children:nr.remaining})," of"," ",nr.dailyLimit," daily requests left on this site."]}),nr.exceeds&&t.jsx("div",{className:"text-destructive",children:"Running this search will likely hit the daily cap. Narrow the time window, cameras, or severity to reduce the cost."})]}):t.jsx("div",{})})]}),t.jsxs(jd,{children:[t.jsx(Gc,{"data-testid":"button-quota-cancel",children:nr?.exceeds?"Narrow search":"Cancel"}),t.jsx(Cd,{"data-testid":"button-quota-confirm",autoFocus:!nr?.exceeds,onClick:()=>{const I=So.current;So.current=null,qr(null),I?.()},children:nr?.exceeds?"Run anyway":"Run search"})]})]})}),t.jsx(Ote,{})]})}const q4=50;function vae({hlsSrc:e,fallbackSrc:s,eventId:r,autoPlay:n,onError:a,onEnded:i,onSourceDetected:o,externalVideoRef:l,muted:c,className:d,controls:h=!0,lanOrigin:p,...g}){const v=u.useRef(null),b=l||v,y=u.useRef(null),w=u.useRef(null),j=u.useRef([]),x=u.useRef(0),C=u.useRef(null),k=u.useRef({hlsSrc:e,fallbackSrc:s,lanOrigin:p});k.current={hlsSrc:e,fallbackSrc:s,lanOrigin:p};const S=/[?&]vt=/.test(e||"")||/[?&]vt=/.test(s||"");return u.useEffect(()=>{const _=b.current;if(!_)return;const{hlsSrc:A,fallbackSrc:T,lanOrigin:M}=k.current;if(y.current&&(y.current.destroy(),y.current=null),w.current=null,_.pause(),!A&&!T)return;const R=[];A&&(M&&R.push({kind:"hls",src:`${M}${A}`}),R.push({kind:"hls",src:A})),T&&(M&&R.push({kind:"fallback",src:`${M}${T}`}),R.push({kind:"fallback",src:T})),j.current=R,x.current=0;const D=K=>{w.current="hls",fg(async()=>{const{default:G}=await import("./hls-DuDM7LWb.js");return{default:G}},[]).then(({default:G})=>{if(!(!b.current||j.current!==R))if(G.isSupported()){const z=new G({maxBufferLength:60,maxMaxBufferLength:180,enableWorker:!0,lowLatencyMode:!1});y.current=z,z.loadSource(K),z.attachMedia(_),z.on(G.Events.MANIFEST_PARSED,()=>{o?.("hls"),n&&_.play().catch(()=>{})}),z.on(G.Events.ERROR,(Z,ee)=>{$o("clip",`local HLS error: ${ee.type}/${ee.details} fatal=${!!ee.fatal}`,{eventId:r,src:K}),ee.fatal&&q()})}else _.canPlayType("application/vnd.apple.mpegurl")?(_.src=K,_.addEventListener("loadedmetadata",()=>{o?.("hls"),n&&_.play().catch(()=>{})},{once:!0})):q()}).catch(()=>{q()})},$=K=>{y.current&&(y.current.destroy(),y.current=null),w.current="fallback",_.src=K,o?.("clip"),n&&_.play().catch(()=>{})},O=K=>{const G=j.current[K];if(!G){a?.();return}G.kind==="hls"?D(G.src):$(G.src)},q=()=>{const K=x.current+1;if(x.current=K,K>=j.current.length){a?.();return}const G=j.current[K];$o("clip",`local clip advancing to candidate #${K} (${G.kind})`,{eventId:r,src:G.src}),O(K)};C.current=q,O(0);const V=N_(_,"[local]");return()=>{V(),y.current&&(y.current.destroy(),y.current=null),_.pause(),_.removeAttribute("src"),_.load(),C.current=null}},[r,S]),u.useEffect(()=>{c&&b.current&&(b.current.muted=!0,b.current.volume=0)},[c]),t.jsx("div",{className:`relative w-full h-full ${c?"audio-restricted":""}
556`,children:t.jsx("video",{ref:b,controls:h,playsInline:!0,muted:c||void 0,className:d||"w-full h-full rounded-md bg-black object-contain",onVolumeChange:_=>{if(c){const A=_.currentTarget;(!A.muted||A.volume>0)&&(A.muted=!0,A.volume=0)}},onPlay:_=>{c&&(_.currentTarget.muted=!0,_.currentTarget.volume=0)},onError:_=>{const A=_.currentTarget,T=A.error,M=T?`code=${T.code} (${["","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED"][T.code]||"UNKNOWN"}) msg="${T.message||""}" netState=${A.networkState} readyState=${A.readyState}`:`no MediaError netState=${A.networkState} readyState=${A.readyState}`;$o("clip",`local clip <video> error (mode=${w.current}): ${M}`,{eventId:r,src:A.currentSrc}),C.current&&C.current()},onEnded:i,...g})})}function t9(e,s){if(!e||!s)return e;const r=e.includes("?")?"&":"?";return`${e}${r}vt=${encodeURIComponent(s)}`}function MFe(e,s,r){return{hlsSrc:t9(e||"",r),fallbackSrc:t9(s,r)}}function RFe({eventId:e,hlsSrc:s,fallbackSrc:r,videoToken:n}){const[a,i]=u.useState(!1),o=MFe(s,r,n);return t.jsxs("div",{className:"relative w-full bg-black",children:[t.jsx(vae,{eventId:e,hlsSrc:o.hlsSrc,fallbackSrc:o.fallbackSrc,autoPlay:!0,controls:!0,className:"w-full max-h-[70vh] object-contain",onError:()=>i(!0),"data-testid":"video-clip-player"},e),a&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 px-6 text-center text-sm text-white","data-testid":"text-clip-playback-error",role:"status",children:"This clip is not available for playback."})]})}function IFe({className:e}){return t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[t.jsx("path",{d:"M12 20H4a1 1 0 0 1-1-1v0a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v0a1 1 0 0 1-1 1h-8z"}),t.jsx("path",{d:"M12 18c4.418 0 8-3.134 8-7a8 8 0 1 0-16 0c0 3.866 3.582 7 8 7z"}),t.jsx("circle",{cx:"12",cy:"11",r:"3"}),t.jsx("path",{d:"M15 11l2-1.5"})]})}function s9({online:e,size:s="sm"}){const r=s==="md"?"w-2.5 h-2.5":"w-2 h-2";return t.jsx("span",{className:`${r} rounded-full shrink-0 ${e?"bg-green-500":"bg-destructive"}`,"data-testid":`status-dot-${e?"online":"offline"}`})}function r9(e){const s=e.eventSource,r=e.triggerType;if(s==="face-rec"||r==="face")return{typeLabel:"Known Persons",typeColor:"bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300",detail:e.label?`${e.label}${e.score!=null?` (${(e.score*100).toFixed(0)}%)`:""}`:null};if(s==="openai"||r==="action"){const a=[];return e.aiPrompt&&a.push(`"${e.aiPrompt}"`),e.label&&a.push(e.label+(e.score!=null?` (${(e.score*100).toFixed(0)}%)`:"")),{typeLabel:"AI Action & Search",typeColor:"bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",detail:a.join(" · ")||null}}if(s==="combined"||r==="combined"){const a=[];return e.label&&a.push(e.label+(e.score!=null?` (${(e.score*100).toFixed(0)}%)`:"")),e.aiPrompt&&a.push(`"${e.aiPrompt}"`),{typeLabel:"Combined Rule",typeColor:"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-300",detail:a.join(" · ")||null}}return{typeLabel:"Object Detection",typeColor:"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300",detail:e.label?`Detected: ${e.label}${e.score!=null?` (${(e.score*100).toFixed(0)}%)`:""}`:null}}function OFe(e){const s=Date.now()-new Date(e).getTime(),r=Math.floor(s/6e4),n=Math.floor(s/36e5);return r<1?"Just now":r<60?`${r}m ago`:n<24?`${n}h ago`:new Date(e).toLocaleString()}function DFe(){Gi();const[,e]=Ia(),[s,r]=u.useState(!0),[n,a]=u.useState(null),i=Su(),{toast:o}=Hs(),l=ze({queryKey:["/api/video-token"],staleTime:1800*1e3,gcTime:0,refetchOnWindowFocus:!0}),c=(()=>{try{const Re=parseInt(localStorage.getItem("bellLastSeenSmartAlerts")||"0",10);return Date.now()-Re<2e3?"smart-alerts":"device-alerts"}catch{return"device-alerts"}})(),[d,h]=u.useState(c),[p,g]=u.useState("not_reviewed"),[v,b]=u.useState("__all__"),[y,w]=u.useState("__all__"),[j,x]=u.useState(""),[C,k]=u.useState(""),[S,_]=u.useState(new Set),{data:A}=ze({queryKey:["/api/user/role"]}),T=A?.role==="superadmin",M=A?.role==="admin"||T,{data:R}=ze({queryKey:["/api/user/settings"]}),D=R?.demetriMode?"text-purple-500":"text-blue-500",{data:$,isLoading:O}=ze({queryKey:["/api/device-notifications/status"],refetchInterval:3e4}),{data:q,isLoading:V}=ze({queryKey:["/api/device-notifications/alert-history"]}),{data:K,isLoading:G,isError:z}=ze({queryKey:["/api/device-notifications/system-alerts"],queryFn:async()=>{const Re=await fetch("/api/device-notifications/system-alerts",{credentials:"include"});if(!Re.ok)throw new Error("Failed to fetch system alerts");return Re.json()},enabled:M,refetchInterval:3e4,staleTime:0,refetchOnMount:"always"}),Z=u.useMemo(()=>{const Re=new URLSearchParams;return Re.set("status",p),v&&v!=="__all__"&&Re.set("siteId",v),y&&y!=="__all__"&&Re.set("label",y),j&&Re.set("search",j),Re.toString()},[p,v,y,j]),[ee,Q]=u.useState({filters:"",cursors:[null]}),Y=u.useMemo(()=>ee.filters===Z?ee.cursors:[null],[ee,Z]),oe=Y.length,he=Y.at(-1),je=u.useMemo(()=>{const Re=new URLSearchParams(Z);return Re.set("pageSize",String(q4)),he&&Re.set("cursor",he),Re.toString()},[Z,he]);u.useEffect(()=>{_(new Set)},[Z,he]),u.useEffect(()=>{Q({filters:Z,cursors:[null]})},[Z]);const pe=u.useMemo(()=>["/api/device-notifications/smart-alert-events",je],[je]),{data:le,isLoading:ue,isPlaceholderData:fe,isError:H,error:se,refetch:me,isFetching:ge}=ze({queryKey:pe,placeholderData:()=>
556{if(he)return;const Re=i.getQueriesData({queryKey:["/api/device-notifications/smart-alert-events"]}).filter(([Ge,ft])=>typeof Ge[1]=="string"&&Ge[1].includes("pageSize=50")&&!Ge[1].includes("cursor=")&&Array.isArray(ft?.events)).flatMap(([,Ge])=>Ge.events);if(!Re.length)return;const pt=j.toLowerCase(),Ft=new Set;return{events:Re.filter(Ge=>!Ft.has(Ge.id)&&!!Ft.add(Ge.id)&&(!v||v==="__all__"||Ge.siteId===v)&&(!y||y==="__all__"||Ge.label?.toLowerCase()===y.toLowerCase())&&(!pt||[Ge.cameraName,Ge.ruleName,Ge.label].some(ft=>ft?.toLowerCase().includes(pt)))&&(Ge.status||"not_reviewed")===p).sort((Ge,ft)=>new Date(ft.matchedAt).getTime()-new Date(Ge.matchedAt).getTime()).slice(0,q4),nextCursor:null}},queryFn:async({signal:Re})=>{try{const pt=await fetch(`/api/device-notifications/smart-alert-events?${je}`,{credentials:"include",signal:AbortSignal.any([Re,AbortSignal.timeout(15e3)])});if(!pt.ok)throw new Error(`Unable to load Smart Alerts (${pt.status}).`);return await pt.json()}catch(pt){throw Re.aborted?pt:pt instanceof DOMException&&pt.name==="TimeoutError"?new Error("Loading Smart Alerts timed out. Please try again."):pt}},retry:!1,refetchInterval:6e4,staleTime:0,refetchOnMount:"always"}),be=le?.events;u.useEffect(()=>{if(!be||fe)return;const Re=new Set(be.map(pt=>pt.id));_(pt=>{const Ft=new Set([...pt].filter(Es=>Re.has(Es)));return Ft.size===pt.size?pt:Ft}),!ge&&!H&&!be.length&&oe>1&&Q({filters:Z,cursors:Y.slice(0,-1)})},[be,fe,ge,H,oe,Z,Y]);const{data:ce,isError:Pe,error:et,refetch:$e}=ze({queryKey:["/api/device-notifications/smart-alert-events","summary"],queryFn:async({signal:Re})=>{try{const pt=await fetch("/api/device-notifications/smart-alert-events?summary=1",{credentials:"include",signal:AbortSignal.any([Re,AbortSignal.timeout(15e3)])});if(!pt.ok)throw new Error(`Unable to load locations and alert counts (${pt.status}).`);return await pt.json()}catch(pt){throw Re.aborted?pt:pt instanceof DOMException&&pt.name==="TimeoutError"?new Error("Loading locations and alert counts timed out. Please try again."):pt}},retry:!1,refetchInterval:6e4,staleTime:0,refetchOnMount:"always"}
556),bt=ce?.counts||{not_reviewed:0,critical:0,reviewed:0},Ae=ce?.siteOptions||[],Be=ce?.labelOptions||[],J=Et({mutationFn:async({id:Re,status:pt})=>Ze("PATCH",`/api/device-notifications/smart-alert-events/${Re}/status`,{status:pt}),onSuccess:(Re,{status:pt})=>{i.invalidateQueries({queryKey:["/api/device-notifications/smart-alert-events"]}),pt==="critical"&&o({title:"Marked Critical",description:"Escalation notifications sent to alert group members."})},onError:()=>{o({title:"Error",description:"Failed to update status.",variant:"destructive"})}}),ae=Et({mutationFn:async({ids:Re,status:pt})=>{let Es=0,Ge=0;for(let ft=0;ft<Re.length;ft+=6){const He=Re.slice(ft,ft+6),zt=await Promise.allSettled(He.map(fs=>Ze("PATCH",`/api/device-notifications/smart-alert-events/${fs}/status`,{status:pt})));for(const fs of zt)fs.status==="fulfilled"?Es++:Ge++}return{succeeded:Es,failed:Ge}},onSuccess:({succeeded:Re,failed:pt},{status:Ft})=>{i.invalidateQueries({queryKey:["/api/device-notifications/smart-alert-events"]}),_(new Set);const Es=Ft==="reviewed"?"reviewed":Ft==="critical"?"critical":"unreviewed";o(pt===0?{title:`${Re} alert${Re===1?"":"s"} marked ${Es}`}:Re===0?{title:"Error",description:`Failed to update ${pt} alert${pt===1?"":"s"}.`,variant:"destructive"}:{title:`${Re} marked ${Es}`,description:`${pt} alert${pt===1?"":"s"} failed to update.`,variant:"destructive"})},onError:()=>{o({title:"Error",description:"Failed to update alerts.",variant:"destructive"})}}),we=new Map;if($)for(const Re of $){we.has(Re.edgeDeviceId)||we.set(Re.edgeDeviceId,{device:null,cameras:[]});const pt=we.get(Re.edgeDeviceId);Re.cameraName?pt.cameras.push(Re):pt.device=Re}const Qe=[...we.entries()].sort(([,Re],[,pt])=>{const Ft=Re.device?.monitoringDisabled,Es=pt.device?.monitoringDisabled;if(Ft&&!Es)return 1;if(!Ft&&Es)return-1;if(s){const He=Re.device&&!Re.device.isOnline&&!Re.device.monitoringDisabled||Re.cameras.some(fs=>!fs.isOnline),zt=pt.device&&!pt.device.isOnline&&!pt.device.monitoringDisabled||pt.cameras.some(fs=>!fs.isOnline);if(He&&!zt)return-1;if(!He&&zt)return 1}const Ge=(Re.device?.siteName||"").toLowerCase(),ft=(pt.device?.siteName||"").toLowerCase();return Ge.localeCompare(ft)}),ye=[...we.values()].filter(Re=>!Re.device?.monitoringDisabled);[...we.values()].filter(Re=>Re.device?.monitoringDisabled).length;const te=we.size,Ue=ye.filter(Re=>Re.device&&!Re.device.isOnline).length,We=$?.filter(Re=>Re.cameraName&&!we.get(Re.edgeDeviceId)?.device?.monitoringDisabled).length||0,St=$?.filter(Re=>Re.cameraName&&!Re.isOnline&&!we.get(Re.edgeDeviceId)?.device?.monitoringDisabled).length||0,It=Ue===0&&St===0,ns=bt.not_reviewed,dt=K?.length??0,Qt=Re=>Re.healthy?Re.width&&Re.height?`${Re.width}×${Re.height}`:"Measured resolution unavailable":"Unavailable";return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>e("/"),"data-testid":"button-back-dashboard",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(mi,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold","data-testid":"text-page-title",children:"Notifications"})]}),t.jsx(qd,{showDashboardLink:!0})]})})}),t.jsx("main",{className:"max-w-7xl mx-auto px-4 py-6",children:t.jsxs(_h,{value:d,onValueChange:h,children:[t.jsxs(Dm,{className:"mb-6",children:[t.jsxs(_n,{value:"device-alerts","data-testid":"tab-device-alerts",children:[t.jsx("span",{className:"sm:hidden",children:"Device"}),t.jsx("span",{className:"hidden sm:inline",children:"Device Alerts"}),Ue>0||St>0?t.jsx("span",{className:"ml-2 px-1.5 py-0.5 rounded-full bg-destructive text-destructive-foreground text-[10px] font-bold leading-none",children:Ue+St}):null]}),t.jsxs(_n,{value:"smart-alerts","data-testid":"tab-smart-alerts",children:[t.jsx("span",{className:"sm:hidden",children:"Smart"}),t.jsx("span",{className:"hidden sm:inline",children:"Smart Alerts"}),ns>0&&t.jsx("span",{className:"ml-2 px-1.5 py-0.5 rounded-full bg-amber-500 text-white text-[10px] font-bold leading-none",children:ns})]}),M&&t.jsxs(_n,{value:"system-alerts","data-testid":"tab-system-alerts",children:[t.jsx("span",{className:"sm:hidden",children:"System"}),t.jsx("span",{className:"hidden sm:inline",children:"System Alerts"}),dt>0&&t.jsx("span",{className:"ml-2 px-1.5 py-0.5 rounded-full bg-destructive text-destructive-foreground text-[10px] font-bold leading-none","data-testid":"badge-system-alerts-count",children:dt})]})]}),t.jsxs(ea,{value:"device-alerts",className:"space-y-6",children:[t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[t.jsx(ut,{children:t.jsxs(mt,{className:"py-4 text-center",children:[t.jsx("div",{className:"text-2xl font-bold","data-testid":"text-total-devices",children:te}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Edge Devices"})]})}),t.jsx(ut,{children:t.jsxs(mt,{className:"py-4 text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${Ue>0?"text-destructive":"text-primary"}`,"data-testid":"text-offline-devices",children:Ue}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Edge Devices Offline"})]})}),t.jsx(ut,{children:t.jsxs(mt,{className:"py-4 text-center",children:[t.jsx("div",{className:"text-2xl font-bold","data-testid":"text-total-cameras",children:We}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Cameras"})]})}),t.jsx(ut,{children:t.jsxs(mt,{className:"py-4 text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${St>0?"text-destructive":"text-primary"}`,"data-testid":"text-offline-cameras",children:St}),t.jsx("div",{className:"text-xs text-muted-foreground",children:"Cameras Offline"})]})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{id:"sort
556-offline",checked:s,onCheckedChange:r,"data-testid":"switch-sort-offline"}),t.jsx(re,{htmlFor:"sort-offline",className:"text-sm text-muted-foreground cursor-pointer",children:"Sort offline first"})]}),It&&te>0&&t.jsx(ut,{children:t.jsxs(mt,{className:"py-8 text-center",children:[t.jsx(ar,{className:"w-12 h-12 mx-auto mb-3 text-green-500"}),t.jsx("h3",{className:"text-lg font-medium mb-1","data-testid":"text-all-healthy",children:"All Systems Healthy"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"All your devices and cameras are online and operating normally."})]})}),O?t.jsx("div",{className:"space-y-4",children:[1,2,3].map(Re=>t.jsx(ut,{children:t.jsxs(mt,{className:"py-4 space-y-3",children:[t.jsx(Bt,{className:"h-5 w-48"}),t.jsx(Bt,{className:"h-4 w-32"}),t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[t.jsx(Bt,{className:"h-8"}),t.jsx(Bt,{className:"h-8"}),t.jsx(Bt,{className:"h-8"})]})]})},Re))}):te===0?t.jsx(ut,{children:t.jsxs(mt,{className:"py-8 text-center",children:[t.jsx(Wx,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground"}),t.jsx("h3",{className:"text-lg font-medium mb-1",children:"No Devices Found"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Device health data will appear here after the next monitoring cycle (every 3 minutes)."})]})}):t.jsx("div",{className:"space-y-4",children:Qe.map(([Re,{device:pt,cameras:Ft}])=>{if(pt?.monitoringDisabled)return t.jsxs(ut,{className:"opacity-60","data-testid":`card-device-${Re}`,children:[t.jsxs(xs,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(ES,{className:"w-4 h-4 text-muted-foreground"}),t.jsx(ys,{className:"text-base","data-testid":`text-device-name-${Re}`,children:pt?.siteName||"Unknown Site"}),t.jsx(Ke,{variant:"secondary","data-testid":`badge-device-status-${Re}`,children:"Disabled"})]}),t.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-wrap",children:pt?.companyName&&t.jsx("span",{children:pt.companyName})})]}),t.jsx(mt,{children:t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(Pn,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{children:"Monitoring disabled. A subscription is required to activate device monitoring and notifications for this site."})]})})]},Re);const Ge=pt?pt.isOnline:!0,ft=Ft.filter(fs=>!fs.isOnline),He=!Ge||ft.length>0,zt=[...Ft].sort((fs,Ce)=>!fs.isOnline&&Ce.isOnline?-1:fs.isOnline&&!Ce.isOnline?1:(fs.cameraName||"").localeCompare(Ce.cameraName||""));return t.jsxs(ut,{"data-testid":`card-device-${Re}`,children:[t.jsxs(xs,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(s9,{online:Ge,size:"md"}),t.jsx(ys,{className:"text-base","data-testid":`text-device-name-${Re}`,children:pt?.siteName||"Unknown Site"}),t.jsx(Ke,{variant:Ge?"outline":"destructive","data-testid":`badge-device-status-${Re}`,children:Ge?"Online":"Offline"})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-wrap",children:[pt?.companyName&&t.jsx("span",{children:pt.companyName}),pt?.lastChecked&&t.jsxs("span",{"data-testid":`text-last-checked-${Re}`,children:["Last checked: ",new Date(pt.lastChecked).toLocaleTimeString()]})]})]}),t.jsx(mt,{children:Ge?Ft.length>0?t.jsxs("div",{className:"space-y-2",children:[He&&ft.length>0&&t.jsxs("div",{className:"flex items-center gap-2 text-sm text-amber-500 mb-3",children:[t.jsx(Pn,{className:"w-4 h-4"}),t.jsxs("span",{children:[ft.length," camera",ft.length>1?"s":""," offline"]})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:zt.map(fs=>t.jsxs("div",{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border ${fs.isOnline?"border-border":"border-destructive/50 bg-destructive/5"}`,"data-testid":`camera-status-${fs.cameraName}`,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(IFe,{className:`w-4 h-4 shrink-0 ${D}`}),t.jsx("span",{className:"text-sm truncate",children:fs.cameraDisplayName||fs.cameraName})]}),t.jsx(s9,{online:fs.isOnline})]},fs.id))})]}):t.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[t.jsx(ar,{className:"w-4 h-4 text-green-500"}),"Device online. Waiting for camera data..."]}):t.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm",children:[t.jsx(Pn,{className:"w-4 h-4"}),t.jsx("span",{children:pt?.statusMessage||"Device unreachable"})]})})]},Re)})}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(qi,{className:"w-5 h-5"}),"Alert History"]}),t.jsx(Xs,{children:"Outbound email alerts from the last 14 days"})]}),t.jsx(mt,{children:V?t.jsx("div",{className:"space-y-3",children:[1,2,3].map(Re=>t.jsx(Bt,{className:"h-14"},Re))}):!q||q.length===0?t.jsxs("div",{className:"py-6 text-center","data-testid":"alert-history-empty",children:[t.jsx(cn,{className:"w-10 h-10 mx-auto mb-2 text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No alerts sent in the last 14 days"})]}):t.jsx("div",{className:"space-y-2",children:q.map(Re=>t.jsxs("div",{className:"flex items-start gap-3 px-3 py-3 rounded-md border","data-testid":`alert-history-${Re.id}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:Re.alertType==="offline"?t.jsx(Pn,{className:"w-4 h-4 text-destructive"}):Re.alertType==="stream_degraded"?t.jsx(Pn,{className:"w-4 h-4 text-amber-500"}):Re.alertType==="recovery"||Re.alertType==="stream_recovered"?t.jsx(ar,{className:"w-4 h-4 text-green-500"}):t.jsx(qi,{className:"w-4 h-4 text-primary"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:"text-sm font-medium",children:Re.subject}),t.jsx(Ke,{variant:Re.alertType==="offline"?"destructive":Re.alertType==="stream_degraded"?"secondary":Re.alertType==="recovery"||Re.alertType==="stream_recovered"?"outline":"secondary",children:Re.alertType==="offline"?"Offline":Re.alertType==="stream_degraded"?"Backup Stream":Re.alertType==="recovery"?"Resolved":Re.alertType==="stream_recovered"?"Recovered":"Summary"})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1 truncate",children:Re.devicesSummary}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5 flex-wrap",children:[t.jsx("span",{children:new Date(Re.sentAt).toLocaleStr
556ing()}),t.jsxs("span",{children:["Sent to: ",Re.recipientEmail]})]})]})]},Re.id))})})]})]}),M&&t.jsxs(ea,{value:"system-alerts",className:"space-y-4","data-testid":"panel-system-alerts",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"Live license-compliance findings"}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"These findings are based on the latest camera measurements and disappear automatically once a camera is compliant."})]}),G?t.jsx("div",{className:"space-y-3","data-testid":"system-alerts-loading",children:[1,2].map(Re=>t.jsx(ut,{children:t.jsxs(mt,{className:"py-5 space-y-3",children:[t.jsx(Bt,{className:"h-5 w-48"}),t.jsx(Bt,{className:"h-4 w-72"}),t.jsx(Bt,{className:"h-8 w-44"})]})},Re))}):z?t.jsx(ut,{children:t.jsxs(mt,{className:"py-10 text-center",children:[t.jsx(Pn,{className:"w-10 h-10 mx-auto mb-3 text-destructive"}),t.jsx("h3",{className:"text-lg font-medium mb-1",children:"System Alerts unavailable"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Try refreshing this page to load the latest compliance findings."})]})}):!K||K.length===0?t.jsx(ut,{"data-testid":"system-alerts-empty",children:t.jsxs(mt,{className:"py-12 text-center",children:[t.jsx(ar,{className:"w-12 h-12 mx-auto mb-3 text-green-500"}),t.jsx("h3",{className:"text-lg font-medium mb-1",children:"No unresolved system alerts"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"All freshly measured recording streams are within their licensed resolution limits."})]})}):t.jsx("div",{className:"space-y-4",children:(()=>{const Re=[...K].sort((Ft,Es)=>{const Ge=(Ft.siteName||"").toLowerCase(),ft=(Es.siteName||"").toLowerCase();return Ge!==ft?Ge<ft?-1:1:(Ft.cameraName||"").toLowerCase()<(Es.cameraName||"").toLowerCase()?-1:1}),pt=new Map;for(const Ft of Re){const Es=Ft.siteId;pt.has(Es)||pt.set(Es,[]),pt.get(Es).push(Ft)}return[...pt.entries()].map(([Ft,Es])=>{const Ge=Es[0];return t.jsxs(ut,{children:[t.jsxs("div",{className:"px-4 pt-4 pb-3 border-b border-border flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Pn,{className:"w-4 h-4 text-amber-500 shrink-0"}),t.jsx("span",{className:"font-semibold truncate",children:Ge.siteName}),t.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[Ge.serialNumber||Ge.edgeDeviceId," · Licensed max: ",Ge.licensedMaximum]})]}),t.jsxs(L,{size:"sm",variant:"outline",className:"shrink-0 self-start sm:self-auto",onClick:()=>e(`/device-settings/${Ft}?tab=camera-configuration`),"data-testid":`button-review-site-${Ft}`,children:[t.jsx(Vi,{className:"w-3.5 h-3.5 mr-1.5"}),"Camera Configuration"]})]}),t.jsx("div",{className:"divide-y divide-border",children:Es.map(ft=>{const He=ft.recommendedSource==="sub";return t.jsx("div",{className:"px-4 py-3 flex flex-col sm:flex-row sm:items-start gap-2","data-testid":`system-alert-${ft.id}`,children:t.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-medium text-sm",children:ft.cameraName}),t.jsx(Ke,{variant:"destructive",className:"text-[10px] px-1.5 py-0",children:"License out of compliance"}),He&&t.jsx("span",{className:"inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-400",children:"Fix: switch to sub-stream"})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:ft.reason}),t.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[t.jsxs(Ke,{variant:ft.currentSource==="main"?"secondary":"outline",children:["Main: ",Qt(ft.measuredStreams.main)]}),t.jsxs(Ke,{variant:ft.currentSource==="sub"?"secondary":"outline",children:["Sub: ",Qt(ft.measuredStreams.sub)]})]})]})},ft.id)})})]},Ft)})})()})]}),t.jsx(ea,{value:"smart-alerts",className:"space-y-4",children:t.jsxs(_h,{value:p,onValueChange:Re=>g(Re),children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[t.jsxs(Dm,{className:"shrink-0",children:[t.jsxs(_n,{value:"not_reviewed","data-testid":"tab-triage-not-reviewed",children:["Not Reviewed",bt.not_reviewed>0&&t.jsx("span",{className:"ml-1.5 px-1.5 py-0.5 rounded-full bg-amber-500 text-white text-[10px] font-bold leading-none",children:bt.not_reviewed})]}),t.jsxs(_n,{value:"critical","data-testid":"tab-triage-critical",children:["Critical",bt.critical>0&&t.jsx("span",{className:"ml-1.5 px-1.5 py-0.5 rounded-full bg-red-600 text-white text-[10px] font-bold leading-none",children:bt.critical})]}),t.jsxs(_n,{value:"reviewed","data-testid":"tab-triage-reviewed",children:["Reviewed",bt.reviewed>0&&t.jsx("span",{className:"ml-1.5 px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground text-[10px] font-bold leading-none",children:bt.reviewed})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-1 flex-wrap",children:[Ae.length>1&&t.jsxs(Us,{value:v,onValueChange:b,children:[t.jsx($s,{className:"h-8 w-40 text-xs","data-testid":"select-filter-site",children:t.jsx(zs,{placeholder:"All locations"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"__all__",children:"All locations"}),Ae.map(Re=>
556t.jsx(rt,{value:Re.id,children:Re.name},Re.id))]})]}),Be.length>0&&t.jsxs(Us,{value:y,onValueChange:w,children:[t.jsx($s,{className:"h-8 w-36 text-xs","data-testid":"select-filter-label",children:t.jsx(zs,{placeholder:"All labels"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"__all__",children:"All labels"}),Be.map(Re=>t.jsx(rt,{value:Re,children:Re},Re))]})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-32 max-w-64",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(yc,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none"}),t.jsx(ke,{className:"h-8 pl-7 text-xs",placeholder:"Camera, rule, label…",value:C,onChange:Re=>k(Re.target.value),onKeyDown:Re=>{Re.key==="Enter"&&x(C)},"data-testid":"input-search-alerts"})]}),C!==j&&t.jsx(L,{size:"sm",className:"h-8 px-2 text-xs",onClick:()=>x(C),"data-testid":"button-apply-search",children:t.jsx(qj,{className:"w-3.5 h-3.5"})}),j&&t.jsx(L,{size:"sm",variant:"ghost",className:"h-8 px-2 text-xs",onClick:()=>{x(""),k("")},"data-testid":"button-clear-search",children:"×"})]})]})]}),Pe&&t.jsxs("div",{role:"alert",className:"flex items-center gap-2 text-sm text-destructive","data-testid":"smart-alert-locations-error",children:[t.jsx("span",{children:et instanceof Error?et.message:"Unable to load locations and alert counts."}),t.jsx(L,{type:"button",size:"sm",variant:"outline",onClick:()=>{$e()},children:"Retry locations"})]}),t.jsxs("nav",{"aria-label":"Smart Alerts pages",className:"flex flex-wrap items-center justify-between gap-3 mt-4",children:[t.jsxs("span",{className:"text-sm text-muted-foreground","data-testid":"smart-alert-page-number",children:["Page ",oe," · Up to ",q4," alerts per page"]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(L,{type:"button",size:"sm",variant:"outline","data-testid":"button-smart-alert-previous",disabled:oe===1||ge,onClick:()=>Q({filters:Z,cursors:Y.slice(0,-1)}),children:"Previous"}),t.jsx(L,{type:"button",size:"sm",variant:"outline","data-testid":"button-smart-alert-next",disabled:!le?.nextCursor||ge||fe||H,onClick:()=>{le?.nextCursor&&Q({filters:Z,cursors:[...Y,le.nextCursor]})},children:"Next"})]})]}),["not_reviewed","critical","reviewed"].map(Re=>t.jsxs(ea,{value:Re,className:"mt-4",children:[fe&&t.jsx("p",{className:"mb-3 text-xs text-muted-foreground",role:"status",children:"Showing recent matching alerts while loading the complete results…"}),ue?t.jsx("div",{className:"space-y-3",children:[1,2,3].map(pt=>t.jsx(ut,{children:t.jsx(mt,{className:"py-4",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Bt,{className:"w-20 h-14 rounded shrink-0"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx(Bt,{className:"h-4 w-48"}),t.jsx(Bt,{className:"h-3 w-32"}),t.jsx(Bt,{className:"h-6 w-36"})]})]})})},pt))}):H?t.jsx(ut,{children:t.jsxs(mt,{className:"py-8 text-center",children:[t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:se instanceof Error?se.message:"Unable to load Smart Alerts."}),t.jsx(L,{type:"button",variant:"outline",className:"mt-4",onClick:()=>{me()},children:"Try again"})]})}):fe&&be?.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",role:"status",children:"Loading alerts for this selection…"}):!be||be.length===0?t.jsx(ut,{children:t.jsxs(mt,{className:"py-12 text-center",children:[Re==="not_reviewed"&&t.jsx(Nb,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground"}),Re==="critical"&&t.jsx(Pn,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground"}),Re==="reviewed"&&t.jsx(ar,{className:"w-12 h-12 mx-auto mb-3 text-muted-foreground"}),t.jsxs("h3",{className:"text-lg font-medium mb-1",children:[Re==="not_reviewed"&&"No unreviewed alerts",Re==="critical"&&"No critical alerts",Re==="reviewed"&&"No reviewed alerts"]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:Re==="not_reviewed"?"All caught up! Triggered alert rules will appear here.":Re==="critical"?"No events have been escalated to critical.":"Mark events as reviewed to track what has been actioned."})]})}):t.jsx(KG,{delayDuration:150,children:(()=>{const pt=be.map(He=>He.id),Ft=pt.filter(He=>S.has(He)),Es=pt.length>0&&Ft.length===pt.length,Ge=Ft.length>0&&!Es,ft=ae.isPending;return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3 flex-wrap p-2 rounded-md bg-muted/40 border border-border/60",children:[t.jsxs("div",{className:"flex items-center gap-2 pl-1",children:[t.jsx(On,{checked:Es?!0:Ge?"indeterminate":!1,onCheckedChange:He=>{if(He)_(new Set([...S,...pt]));
556else{const zt=new Set(S);pt.forEach(fs=>zt.delete(fs)),_(zt)}},"data-testid":"checkbox-select-all","aria-label":"Select all visible alerts"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:Ft.length>0?`${Ft.length} selected`:`Select all (${pt.length})`})]}),Ft.length>0&&t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{variant:"outline",size:"sm",className:"h-8 px-2 text-green-700 border-green-300 hover:bg-green-50 dark:text-green-400 dark:border-green-700 dark:hover:bg-green-950",disabled:ft,onClick:()=>ae.mutate({ids:Ft,status:"reviewed"}),"data-testid":"button-bulk-mark-reviewed",children:[t.jsx(ar,{className:"w-4 h-4 mr-1.5"}),"Mark Reviewed"]})}),t.jsxs(Yt,{children:["Mark ",Ft.length," as reviewed"]})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{variant:"outline",size:"sm",className:"h-8 px-2 text-red-700 border-red-300 hover:bg-red-50 dark:text-red-400 dark:border-red-700 dark:hover:bg-red-950",disabled:ft,onClick:()=>ae.mutate({ids:Ft,status:"critical"}),"data-testid":"button-bulk-mark-critical",children:[t.jsx(Pn,{className:"w-4 h-4 mr-1.5"}),"Mark Critical"]})}),t.jsxs(Yt,{children:["Mark ",Ft.length," as critical"]})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"sm",className:"h-8 px-2 text-muted-foreground",disabled:ft,onClick:()=>_(new Set),"data-testid":"button-bulk-clear",children:"Clear"})}),t.jsx(Yt,{children:"Clear selection"})]})]})]}),be.map(He=>{const zt=He.status||"not_reviewed",fs=J.isPending&&J.variables?.id===He.id,Ce=S.has(He.id);return t.jsx(ut,{"data-testid":`smart-alert-event-${He.id}`,className:zt==="critical"?"border-red-500/60 dark:border-red-600/60":"",children:t.jsx(mt,{className:"py-4",children:t.jsxs("div",{className:"flex gap-3 items-start",children:[t.jsx("div",{className:"pt-1 shrink-0",children:t.jsx(On,{checked:Ce,onCheckedChange:Dt=>{const ne=new Set(S);Dt?ne.add(He.id):ne.delete(He.id),_(ne)},"data-testid":`checkbox-select-${He.id}`,"aria-label":"Select alert"})}),He.thumbnailUrl?t.jsx("img",{src:He.thumbnailUrl,alt:"snapshot",className:"w-20 h-14 object-cover rounded border border-border shrink-0","data-testid":`img-thumbnail-${He.id}`}):t.jsxs("div",{className:"w-20 h-14 rounded border border-border shrink-0 bg-muted flex flex-col items-center justify-center gap-1",children:[t.jsx(lde,{className:"w-4 h-4 text-muted-foreground/50"}),t.jsx("span",{className:"text-[9px] text-muted-foreground/50 leading-none",children:"No snapshot"})]}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:"text-sm font-semibold","data-testid":`text-rule-name-${He.id}`,children:He.ruleName}),(()=>{const{typeLabel:Dt,typeColor:ne}=r9(He);return t.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium ${ne}`,"data-testid":`badge-type-${He.id}`,children:Dt})})(),zt==="critical"&&t.jsx("span",{className:"inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-bold bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-400","data-testid":`badge-status-${He.id}`,children:"🚨 Critical"}),zt==="reviewed"&&t.jsx("span",{className:"inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-400","data-testid":`badge-status-${He.id}`,children:"✓ Reviewed"}),He.notifyError&&t.jsx(Ke,{variant:"secondary",className:"text-[10px]",children:He.notifyError==="rate_limited"?"Rate limited":"Error"})]}),t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:[He.siteName,He.cameraName].filter(Boolean).join(" · ")}),(()=>{const{detail:Dt}=r9(He);return Dt?t.jsx("div",{className:"text-xs text-foreground/80 mt-1 font-medium truncate max-w-sm","data-testid":`text-detail-${He.id}`,children:Dt}):null})(),zt==="reviewed"&&He.reviewedByName&&t.jsxs("div",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-1","data-testid":`text-reviewer-${He.id}`,children:[t.jsx(Xr,{className:"w-3 h-3"}),"Reviewed by ",He.reviewedByName,He.reviewedAt&&` — ${new Date(He.reviewedAt).toLocaleStr
556ing()}`]}),zt==="critical"&&He.markedCriticalByName&&t.jsxs("div",{className:"text-xs text-red-600 dark:text-red-400 mt-1 flex items-center gap-1","data-testid":`text-critical-by-${He.id}`,children:[t.jsx(Pn,{className:"w-3 h-3"}),"Flagged by ",He.markedCriticalByName,He.markedCriticalAt&&` — ${new Date(He.markedCriticalAt).toLocaleString()}`]})]}),t.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap shrink-0","data-testid":`text-time-${He.id}`,children:OFe(He.matchedAt)})]}),t.jsxs("div",{className:"mt-2 flex items-center gap-1.5 flex-wrap",children:[t.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:new Date(He.matchedAt).toLocaleString()}),He.clipUrl&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"default",size:"icon",className:"h-7 w-7",onClick:()=>a(He),"data-testid":`button-play-clip-${He.id}`,"aria-label":"Review clip",children:t.jsx(vu,{className:"w-3.5 h-3.5"})})}),t.jsx(Yt,{children:"Review clip"})]}),He.deepLink&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>e(He.deepLink),"data-testid":`button-view-recording-${He.id}`,"aria-label":"Open in Recordings",children:t.jsx(op,{className:"w-3.5 h-3.5"})})}),t.jsx(Yt,{children:"Open in Recordings"})]}),zt!=="reviewed"&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"outline",size:"icon",className:"h-7 w-7 text-green-700 border-green-300 hover:bg-green-50 dark:text-green-400 dark:border-green-700 dark:hover:bg-green-950",disabled:fs,onClick:()=>J.mutate({id:He.id,status:"reviewed"}),"data-testid":`button-mark-reviewed-${He.id}`,"aria-label":"Mark Reviewed",children:t.jsx(ar,{className:"w-3.5 h-3.5"})})}),t.jsx(Yt,{children:"Mark Reviewed"})]}),zt!=="critical"&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"outline",size:"icon",className:"h-7 w-7 text-red-700 border-red-300 hover:bg-red-50 dark:text-red-400 dark:border-red-700 dark:hover:bg-red-950",disabled:fs,onClick:()=>J.mutate({id:He.id,status:"critical"}),"data-testid":`button-mark-critical-${He.id}`,"aria-label":"Mark Critical",children:t.jsx(Pn,{className:"w-3.5 h-3.5"})})}),t.jsx(Yt,{children:"Mark Critical"})]}),zt!=="not_reviewed"&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground",disabled:fs,onClick:()=>J.mutate({id:He.id,status:"not_reviewed"}),"data-testid":`button-reset-status-${He.id}`,"aria-label":"Reset status",children:t.jsx(bh,{className:"w-3.5 h-3.5"})})}),t.jsx(Yt,{children:"Reset status"})]})]})]})]})})},He.id)})]})})()})]},Re))]})})]})}),t.jsx(Ys,{open:!!n,onOpenChange:Re=>{Re||a(null)},children:t.jsxs(Ws,{className:"max-w-3xl w-full p-0 overflow-hidden",children:[t.jsxs(Zs,{className:"px-4 pt-4 pb-2",children:[t.jsxs(Ks,{className:"text-base",children:[n?.ruleName,n&&t.jsxs("span",{className:"ml-2 text-sm font-normal text-muted-foreground",children:[[n.siteName,n.cameraName].filter(Boolean).join(" · "),n.label&&` · ${n.label}${n.score!=null?` (${(n.score*100).toFixed(0)}%)`:""}`]})]}),t.jsx(cr,{className:"sr-only",children:"Recording clip for smart alert event"})]}),n?.clipUrl&&t.jsx(RFe,{eventId:n.id,hlsSrc:n.hlsUrl,fallbackSrc:n.clipUrl,videoToken:l.data?.token},n.id),t.jsxs("div",{className:"px-4 py-3 flex items-center justify-between gap-2 flex-wrap",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n&&new Date(n.matchedAt).toLocaleString()}),n?.deepLink&&t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>{a(null),e(n.deepLink)},"data-testid":"button-open-in-recordings",children:[t.jsx(op,{className:"w-3.5 h-3.5 mr-1.5"}),"Open in Recordings"]})]})]})})]})}const L1=[{value:1,label:"1",cols:1,rows:1},{value:4,label:"4",cols:2,rows:2},{value:9,label:"9",cols:3,rows:3},{value:16,label:"16",cols:4,rows:4},{value:32,label:"32",cols:8,rows:4},{value:64,label:"64",cols:8,rows:8}];function LFe({cols:e,rows:s,active:r}){const n=Math.min(e,4),a=Math.min(s,4),i=r?"fill-primary-foreground":"fill-white/50",o=.8,l=16,c=(l-o*(n-1))/n,d=(l-o*(a-1))/a;return t.jsx("svg",{width:l,height:l,viewBox:`0 0 ${l} ${l}`,className:"shrink-0",children:Array.from({length:a}).map((h,p)=>Array.from({length:n}).map((g,v)=>t.jsx("rect",{x:v*(c+o),y:p*(d+o),width:c,height:d,rx:e===1?2:.5,className:i},`${p}-${v}`)))})}function $Fe(e){return e<=4?500:e<=16?1e3:2e3}function FFe(){const[,e]=NW("/live/:siteId/:cameraName"),s=e?.siteId||"",r=e?.cameraName?decodeURIComponent(e.cameraName):"",{data:n}=ze({queryKey:["/api/user/role"],staleTime:5*6e4}),a=n?.role==="admin"||n?.role==="superadmin",[i,o]=u.useState([]),[l,c]=u.useState(""),[d,h]=u.useState(r),[p,g]=u.useState(0),[v,b]=u.useState(!1),[y,w]=u.useState(!1),[j,x]=u.useState(1),[C,k]=u.useState(0),[S,_]=u.useState(null),[A,T]=UO(s),[M,R]=u.useState(!0),[D,$]=u.useState(!0),[O,q]=u.useState(()=>Math.min(window.innerWidth,window.innerHeight)<640),[V,K]=u.useState(()=>window.innerHeight>window.innerWidth),[G,z]=u.useState(1),Z=u.useRef(0),ee=u.useRef(0),{data:Q}=ze({queryKey:["/api/sites",s,"stream-options"],enabled:!!s,staleTime:300*1e3}),Y=Q?.useRtc??!0,{data:oe}=ze({queryKey:["/api/user/settings"]}),he=(oe?.previewCycleRate||5)*1e3;u.useEffect(()=>{const te=()=>{q(Math.min(window.innerWidth,window.innerHeight)<640),K(window.innerHeight>window.innerWidth)};return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]),u.useEffect(()=>{O&&V&&ae()},[O,V]);const je=O?L1.filter(te=>te.value===1||te.value===4||te.value===9||te.value===16):L1;u.useEffect(()=>{O&&j!==1&&j!==4&&j!==9&&j!==16&&x(16)},[O,j]);const pe=te=>{Z.current=te.touches[0].clientX,ee.current=te.touches[0].clientY},le=te=>{if(G>1)return;const Ue=te.changedTouches[0].clientX-Z.current,We=Math.abs(te.changedTouches[0].clientY-ee.current);Math.abs(Ue)>50&&Math.abs(Ue)>We&&ue.length>1&&(Ue<0?Be():Ae())};u.useEffect(()=>{if(!s)return;const te=async()=>{try{$(!0);const We=await fetch(`/api/sites/${s}/cameras`,{credentials:"include"});if(We.ok){const St=await We.json();o(St.cameras||[]),St.siteName&&c(St.siteName)}}catch{}finally{$(!1)}};te();const Ue=setInterval(te,3e4);return()=>clearInterval(Ue)},[s]);const ue=i.filter(te=>te.enabled),fe=ue.findIndex(te=>te.name===d);u.useEffect(()=>{if(ue.length>0&&fe===-1){const te=ue.find(Ue=>Ue.name===r);h(te?te.name:ue[0].name)}},[ue,r,fe]),u.useEffect(()=>{if(!y||j!==1||ue.length<=1)return;const te=setInterval(()=>{h(Ue=>{const St=(ue.findIndex(It=>It.name===Ue)+1)%ue.length;return ue[St].name})},he);return()=>clearInterval(te)},[y,j,ue,he]),u.useEffect(()=>{if(v)return;const te=$Fe(j),Ue=setInterval(()=>g(We=>We+1),te);return()=>clearInterval(Ue)},[v,j]);const H=u.useRef(null),se=u.useCallback(()=>{H.current&&clearTimeout(H.current),H.current=setTimeout(()=>R(!1),3e3)},[]);u.useEffect(()=>{const te=()=>{R(!0),se()};return R(!0),se(),window.addEventListener("mousemove",te),()=>{H.current&&clearTimeout(H.current),window.removeEventListener("mousemove",te)}},[se]);const me=u.useCallback(()=>{R(te=>(te||se(),!te))},[se]),ge=L1.find(te=>te.value===j)||L1[0],be=ge.value,ce=Math.max(1,Math.ceil(ue.length/be)),Pe=Math.min(C,ce-1),et=u.useCallback(te=>{const Ue=te.changedTouches[0].clientX-Z.current,We=Math.abs(te.changedTouches[0].clientY-ee.current);Math.abs(Ue)>50&&Math.abs(Ue)>We&&(Ue<0?k(St=>Math.min(St+1,ce-1)):k(St=>Math.max(St-1,0)))},[ce]),$e=ue.slice(Pe*be,Pe*be+be),bt=j<=4?720:j<=16?480:240,Ae=u.useCallback(()=>
556{if(ue.length===0)return;const te=(fe-1+ue.length)%ue.length;h(ue[te].name)},[fe,ue]),Be=u.useCallback(()=>{if(ue.length===0)return;const te=(fe+1)%ue.length;h(ue[te].name)},[fe,ue]),J=te=>{S===te?(x(1),h(te),_(null)):_(te)},ae=()=>{window.history.length>1?window.history.back():window.close()};u.useEffect(()=>{const te=Ue=>{Ue.key==="ArrowLeft"&&Ae(),Ue.key==="ArrowRight"&&Be(),Ue.key===" "&&(Ue.preventDefault(),b(We=>!We)),Ue.key==="Escape"&&ae()};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[Ae,Be]);const we=j===1?d:S||`${$e.length} Cameras`;if(D&&i.length===0)return t.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center","data-testid":"live-fullscreen",children:t.jsx("span",{className:"text-white/60 text-sm",children:"Loading cameras..."})});const Qe=O&&V,ye=Qe?{aspectRatio:"4/3"}:{};return t.jsxs("div",{className:"fixed inset-0 bg-black flex flex-col","data-testid":"live-fullscreen",children:[t.jsx("div",{className:`shrink-0 z-50 transition-opacity duration-300 ${M?"opacity-100":"opacity-0 h-0 overflow-hidden"}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 py-2 bg-black/80 backdrop-blur-sm border-b border-white/10",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Vi,{className:"w-4 h-4 text-primary shrink-0"}),l&&t.jsx("span",{className:"text-sm text-white/60 font-medium truncate","data-testid":"fullscreen-site-name",children:l}),l&&t.jsx("span",{className:"text-white/30",children:"|"}),t.jsx("span",{className:"text-sm text-white font-medium truncate","data-testid":"fullscreen-camera-name",children:we}),!v&&t.jsx(Ke,{variant:"destructive",className:"text-[10px] px-1.5 py-0 no-default-hover-elevate no-default-active-elevate shrink-0",children:"LIVE"}),t.jsx(cC,{siteId:s})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx("div",{className:"flex items-center gap-0.5 bg-white/10 rounded-md p-0.5","data-testid":"fullscreen-layout-selector",children:je.map(te=>t.jsx("button",{onClick:()=>{x(te.value),k(0),_(null)},className:`flex items-center justify-center w-8 h-7 rounded transition-colors ${j===te.value?"bg-primary text-primary-foreground shadow-sm":"text-white/60 hover:text-white hover:bg-white/10"}`,title:`${te.label} camera${te.value>1?"s":""}`,"data-testid":`fullscreen-layout-${te.value}`,children:t.jsx(LFe,{cols:te.cols,rows:te.rows,active:j===te.value})},te.value))}),O&&V?t.jsxs("button",{onClick:()=>T(te=>te==="auto"?"main":te==="main"?"sub":te==="sub"?"jpeg":"auto"),className:"flex items-center gap-1 px-2 h-7 rounded-md bg-white/10 text-xs font-medium text-white",title:"Stream source — tap to cycle Auto / Main / Sub / JPEG","data-testid":"fullscreen-stream-source-toggle",children:[t.jsx(hf,{className:"w-3.5 h-3.5 text-white/60"}),A==="auto"?"Auto":A==="main"?"Main":A==="sub"?"Sub":"JPEG"]}):t.jsxs("div",{className:"flex items-center gap-0.5 bg-white/10 rounded-md p-0.5","data-testid":"fullscreen-stream-source-selector",children:[t.jsx(hf,{className:"w-3.5 h-3.5 text-white/60 mx-1 hidden sm:block"}),[{value:"auto",label:"Auto",title:"Auto — main stream for single view, sub stream for grids"},{value:"main",label:"Main",title:"Main stream — higher quality, more bandwidth"},{value:"sub",label:"Sub",title:"Sub stream — lower bandwidth"},{value:"jpeg",label:"JPEG",title:"JPEG — Image stills for lowest bandwidth"}].map(te=>t.jsx("button",{onClick:()=>T(te.value),className:`flex items-center justify-center px-2 h-7 rounded text-xs font-medium transition-colors ${A===te.value?"bg-primary text-primary-foreground shadow-sm":"text-white/60 hover:text-white hover:bg-white/10"}`,title:te.title,"data-testid":`fullscreen-stream-source-${te.value}`,children:te.label},te.value))]}),j===1&&ue.length>1&&t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>w(te=>!te),className:`text-white ${y?"text-primary":""}`,title:y?`Looping (${oe?.previewCycleRate||5}s)`:"Auto-cycle cameras","data-testid":"fullscreen-loop-toggle",children:t.jsx(tl,{className:`w-4 h-4 ${y?"animate-spin":""}`,style:y?{animationDuration:"3s"}:void 0})}),t.jsx(L,{variant:"ghost",size:"icon",onClick:ae,className:"text-white","data-testid":"fullscreen-close",children:t.jsx(va,{className:"w-4 h-4"})})]})]})}),j===1?t.jsxs("div",{className:"flex-1 overflow-hidden relative",onTouchStart:pe,onTouchEnd:le,onClick:me,children:[d&&t.jsxs(t.Fragment,{children:[t.jsx(jg,{testIdPrefix:"zoom-live-fs",className:"absolute inset-0",doubleClickZoom:!1,onZoomChange:z,children:ue.find(te=>te.name===d)?.usesGo2rtc&&Y?t.jsx(Ly,{siteId:s,cameraName:d,className:"absolute inset-0 w-full h-full",objectFit:"cover",streamSource:A,singleView:!0},d):t.jsx(af,{src:`/api/sites/${s}/cameras/${encodeURIComponent(d)}/thumbnail?t=${p}
556&stream=record&live=1`,alt:d,className:"absolute inset-0 w-full h-full object-cover","data-testid":"fullscreen-image"})},`${s}|${d}`),t.jsx(Q0,{siteId:s,cameraName:d,isAdmin:a})]}),ue.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(L,{variant:"ghost",size:"icon",className:"absolute left-4 top-1/2 -translate-y-1/2 bg-black/50 text-white hidden lg:flex",onClick:Ae,"data-testid":"fullscreen-prev",children:t.jsx(Pde,{className:"w-5 h-5"})}),t.jsx(L,{variant:"ghost",size:"icon",className:"absolute right-4 top-1/2 -translate-y-1/2 bg-black/50 text-white hidden lg:flex",onClick:Be,"data-testid":"fullscreen-next",children:t.jsx(Ede,{className:"w-5 h-5"})})]})]}):t.jsxs("div",{className:`w-full overflow-hidden ${Qe?"shrink-0":"flex-1 relative"}`,onTouchStart:pe,onTouchEnd:et,onClick:me,children:[t.jsx("div",{className:"grid w-full",style:{gridTemplateColumns:`repeat(${ge.cols}, 1fr)`,...Qe?{}:{gridTemplateRows:`repeat(${ge.rows}, minmax(0, 1fr))`,height:"100%"}},"data-testid":"fullscreen-grid",children:Array.from({length:be}).map((te,Ue)=>{const We=$e[Ue];return We?t.jsxs("div",{className:`relative bg-black border cursor-pointer overflow-hidden ${S===We.name?"border-primary border-2":"border-white/10"}`,style:ye,onClick:()=>J(We.name),"data-testid":`fullscreen-grid-cell-${We.name}`,children:[We.usesGo2rtc&&Y?t.jsx(Ly,{siteId:s,cameraName:We.name,className:"absolute inset-0 w-full h-full",objectFit:"cover",streamSource:A,singleView:!1},We.name):t.jsx(af,{src:`/api/sites/${s}/cameras/${encodeURIComponent(We.name)}/thumbnail?t=${p}&h=${bt}&live=1`,alt:We.name,className:"absolute inset-0 w-full h-full object-cover"}),t.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 px-2 py-0.5 z-10",children:t.jsx("span",{className:"text-[10px] text-white truncate block",children:We.name})}),S===We.name&&t.jsx(Q0,{siteId:s,cameraName:We.name,isAdmin:a,compact:!0})]},We.name):t.jsx("div",{className:"bg-black border border-white/5 overflow-hidden",style:ye},`empty-${Ue}`)})}),ce>1&&t.jsxs("div",{className:`flex items-center gap-2 bg-black/70 rounded-md px-3 py-1 ${O?"justify-center mt-1":"absolute bottom-4 left-1/2 -translate-x-1/2"}`,children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>k(te=>Math.max(0,te-1)),disabled:Pe===0,className:"text-white",children:t.jsx(Kl,{className:"w-4 h-4"})}),t.jsxs("span",{className:"text-xs text-white",children:[Pe+1," / ",ce]}),t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>k(te=>Math.min(ce-1,te+1)),disabled:Pe>=ce-1,className:"text-white",children:t.jsx(hi,{className:"w-4 h-4"})})]})]}),j===1&&ue.length>1&&t.jsx("div",{className:`absolute bottom-0 left-0 right-0 z-50 transition-opacity duration-300 ${M?"opacity-100":"opacity-0 pointer-events-none"}`,children:t.jsx("div",{className:"flex items-center gap-1 px-4 py-2 bg-black/80 backdrop-blur-sm border-t border-white/10 overflow-x-auto",children:ue.map(te=>t.jsx("button",{onClick:()=>h(te.name),className:`relative shrink-0 rounded overflow-hidden border-2 transition-colors ${te.name===d?"border-primary":"border-transparent"}`,"data-testid":`fullscreen-cam-select-${te.name}`,children:t.jsx(af,{src:`/api/sites/${s}/cameras/${encodeURIComponent(te.name)}/thumbnail?h=80`,alt:te.name,className:"h-12 w-auto object-cover",compact:!0})},te.name))})})]})}function BFe(e){const s=UFe(e),r=u.forwardRef((n,a)=>{const{children:i,...o}=n,l=u.Children.toArray(i),c=l.find(HFe);if(c){const d=c.props.children,h=l.map(p=>p===c?u.Children.count(d)>1?u.Children.only(null):u.isValidElement(d)?d.props.children:null:p);return t.jsx(s,{...o,ref:a,children:u.isValidElement(d)?u.cloneElement(d,void 0,h):null})}return t.jsx(s,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function UFe(e){const s=u.forwardRef((r,n)=>{const{children:a,...i}=r;if(u.isValidElement(a)){const o=VFe(a),l=qFe(i,a.props);return a.type!==u.Fragment&&(l.ref=n?jf(n,o):o),u.cloneElement(a,l)}return u.Children.count(a)>1?u.Children.only(null):null});return s.displayName=`${e}.SlotClone`,s}var zFe=Symbol("radix.slottable");function HFe(e){return u.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===zFe}function qFe(e,s){const r={...s};for(const n in s){const a=e[n],i=s[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}
vendor: 5,241 bytes, line 556
556:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function VFe(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var WFe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vN=WFe.reduce((e,s)=>{const r=BFe(`Primitive.${s}`),n=u.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(c,{...l,ref:i})});return n.displayName=`Primitive.${s}`,{...e,[s]:n}},{});function KFe(e,s){return u.useReducer((r,n)=>s[r][n]??r,e)}var yN=e=>{const{present:s,children:r}=e,n=GFe(s),a=typeof r=="function"?r({present:n.isPresent}):u.Children.only(r),i=mr(n.ref,YFe(a));return typeof r=="function"||n.isPresent?u.cloneElement(a,{ref:i}):null};yN.displayName="Presence";function GFe(e){const[s,r]=u.useState(),n=u.useRef(null),a=u.useRef(e),i=u.useRef("none"),o=e?"mounted":"unmounted",[l,c]=KFe(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return u.useEffect(()=>{const d=$1(n.current);i.current=l==="mounted"?d:"none"},[l]),da(()=>{const d=n.current,h=a.current;if(h!==e){const g=i.current,v=$1(d);e?c("MOUNT"):v==="none"||d?.display==="none"?c("UNMOUNT"):c(h&&g!==v?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),da(()=>{if(s){let d;const h=s.ownerDocument.defaultView??window,p=v=>{const y=$1(n.current).includes(CSS.escape(v.animationName));if(v.target===s&&y&&(c("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",d=h.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},g=v=>{v.target===s&&(i.current=$1(n.current))};return s.addEventListener("animationstart",g),s.addEventListener("animationcancel",p),s.addEventListener("animationend",p),()=>{h.clearTimeout(d),s.removeEventListener("animationstart",g),s.removeEventListener("animationcancel",p),s.removeEventListener("animationend",p)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:u.useCallback(d=>{n.current=d?getComputedStyle(d):null,r(d)},[])}}function $1(e){return e?.animationName||"none"}function YFe(e){let s=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning;return r?e.ref:(s=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function $x(e,s,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e?.(a),r===!1||!a.defaultPrevented)return s?.(a)}}function QFe(e,s){return u.useReducer((r,n)=>s[r][n]??r,e)}var zD="ScrollArea",[yae]=oo(zD),[XFe,Bm]=yae(zD),bae=u.forwardRef((e,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:i=600,...o}=e,[l,c]=u.useState(null),[d,h]=u.useState(null),[p,g]=u.useState(null),[v,b]=u.useState(null),[y,w]=u.useState(null),[j,x]=u.useState(0),[C,k]=u.useState(0),[S,_]=u.useState(!1),[A,T]=u.useState(!1),M=mr(s,D=>c(D)),R=Og(a);return t.jsx(XFe,{scope:r,type:n,dir:R,scrollHideDelay:i,scrollArea:l,viewport:d,onViewportChange:h,content:p,onContentChange:g,scrollbarX:v,onScrollbarXChange:b,scrollbarXEnabled:S,onScrollbarXEnabledChange:_,scrollbarY:y,onScrollbarYChange:w,scrollbarYEnabled:A,onScrollbarYEnabledChange:T,onCornerWidthChange:x,onCornerHeightChange:k,children:t.jsx(vN.div,{dir:R,...o,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});bae.displayName=zD;var wae="ScrollAreaViewport",jae=u.forwardRef((e,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...i}=e,o=Bm(wae,r),l=u.useRef(null),c=mr(s,l,o.onViewportChange);return t.jsxs(t.Fragment,{children:[t.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}),t.jsx(vN.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:t.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});jae.displayName=wae;var vp="ScrollAreaScrollbar",HD=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=Bm(vp,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=a,l=e.orientation==="horizontal";return u.useEffect(()=>(l?i(!0):o(!0),()=>{l?i(!1):o(!1)}),[l,i,o]),a.type==="hover"?t.jsx(ZFe,{...n,ref:s,forceMount:r}):a.type==="scroll"?t.jsx(JFe,{...n,ref:s,forceMount:r}):a.type==="auto"?t.jsx(Nae,{...n,ref:s,forceMount:r}):a.type==="always"?t.jsx(qD,{...n,ref:s}):null});HD.displayName=vp;var ZFe=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=Bm(vp,e.__scopeScrollArea),[i,o]=u.useState(!1);return u.useEffect(()=>{const l=a.scrollArea;let c=0;if(l){const d=()=>{window.clearTimeout(c),o(!0)},h=()=>{c=window.setTimeout(()=>
vendor: 7,107 bytes, line 556
556o(!1),a.scrollHideDelay)};return l.addEventListener("pointerenter",d),l.addEventListener("pointerleave",h),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",d),l.removeEventListener("pointerleave",h)}}},[a.scrollArea,a.scrollHideDelay]),t.jsx(yN,{present:r||i,children:t.jsx(Nae,{"data-state":i?"visible":"hidden",...n,ref:s})})}),JFe=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=Bm(vp,e.__scopeScrollArea),i=e.orientation==="horizontal",o=l2(()=>c("SCROLL_END"),100),[l,c]=QFe("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 u.useEffect(()=>{if(l==="idle"){const d=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(d)}},[l,a.scrollHideDelay,c]),u.useEffect(()=>{const d=a.viewport,h=i?"scrollLeft":"scrollTop";if(d){let p=d[h];const g=()=>{const v=d[h];p!==v&&(c("SCROLL"),o()),p=v};return d.addEventListener("scroll",g),()=>d.removeEventListener("scroll",g)}},[a.viewport,i,c,o]),t.jsx(yN,{present:r||l!=="hidden",children:t.jsx(qD,{"data-state":l==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:$x(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:$x(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Nae=u.forwardRef((e,s)=>{const r=Bm(vp,e.__scopeScrollArea),{forceMount:n,...a}=e,[i,o]=u.useState(!1),l=e.orientation==="horizontal",c=l2(()=>{if(r.viewport){const d=r.viewport.offsetWidth<r.viewport.scrollWidth,h=r.viewport.offsetHeight<r.viewport.scrollHeight;o(l?d:h)}},10);return xb(r.viewport,c),xb(r.content,c),t.jsx(yN,{present:n||i,children:t.jsx(qD,{"data-state":i?"visible":"hidden",...a,ref:s})})}),qD=u.forwardRef((e,s)=>{const{orientation:r="vertical",...n}=e,a=Bm(vp,e.__scopeScrollArea),i=u.useRef(null),o=u.useRef(0),[l,c]=u.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=Pae(l.viewport,l.content),h={...n,sizes:l,onSizesChange:c,hasThumb:d>0&&d<1,onThumbChange:g=>i.current=g,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:g=>o.current=g};function p(g,v){return aBe(g,o.current,l,v)}return r==="horizontal"?t.jsx(eBe,{...h,ref:s,onThumbPositionChange:()=>{if(a.viewport&&i.current){const g=a.viewport.scrollLeft,v=n9(g,l,a.dir);i.current.style.transform=`translate3d(${v}px, 0, 0)`}},onWheelScroll:g=>{a.viewport&&(a.viewport.scrollLeft=g)},onDragScroll:g=>{a.viewport&&(a.viewport.scrollLeft=p(g,a.dir))}}):r==="vertical"?t.jsx(tBe,{...h,ref:s,onThumbPositionChange:()=>{if(a.viewport&&i.current){const g=a.viewport.scrollTop,v=n9(g,l);i.current.style.transform=`translate3d(0, ${v}px, 0)`}},onWheelScroll:g=>{a.viewport&&(a.viewport.scrollTop=g)},onDragScroll:g=>{a.viewport&&(a.viewport.scrollTop=p(g))}}):null}),eBe=u.forwardRef((e,s)=>{const{sizes:r,onSizesChange:n,...a}=e,i=Bm(vp,e.__scopeScrollArea),[o,l]=u.useState(),c=u.useRef(null),d=mr(s,c,i.onScrollbarXChange);return u.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),t.jsx(Cae,{"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":o2(r)+"px",...e.style},onThumbPointerDown:h=>e.onThumbPointerDown(h.x),onDragScroll:h=>e.onDragScroll(h.x),onWheelScroll:(h,p)=>{if(i.viewport){const g=i.viewport.scrollLeft+h.deltaX;e.onWheelScroll(g),Tae(g,p)&&h.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&n({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:vk(o.paddingLeft),paddingEnd:vk(o.paddingRight)}})}})}),tBe=u.forwardRef((e,s)=>{const{sizes:r,onSizesChange:n,...a}=e,i=Bm(vp,e.__scopeScrollArea),[o,l]=u.useState(),c=u.useRef(null),d=mr(s,c,i.onScrollbarYChange);return u.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),t.jsx(Cae,{"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":o2(r)+"px",...e.style},onThumbPointerDown:h=>e.onThumbPointerDown(h.y),onDragScroll:h=>e.onDragScroll(h.y),onWheelScroll:(h,p)=>{if(i.viewport){const g=i.viewport.scrollTop+h.deltaY;e.onWheelScroll(g),Tae(g,p)&&h.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&n({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:vk(o.paddingTop),paddingEnd:vk(o.paddingBottom)}})}})}),[sBe,Sae]=yae(vp),Cae=u.forwardRef((e,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:h,onResize:p,...g}=e,v=Bm(vp,r),[b,y]=u.useState(null),w=mr(s,M=>y(M)),j=u.useRef(null),x=u.useRef(""),C=v.viewport,k=n.content-n.viewport,S=Za(h),_=Za(c),A=l2(p,10);function T(M){if(j.current){const R=M.clientX-j.current.left,D=M.clientY-j.current.top;d({x:R,y:D})}}return u.useEffect(()=>{const M=R=>{const D=R.target;b?.contains(D)&&S(R,k)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[C,b,k,S]),u.useEffect(_,[n,_]),xb(b,A),xb(v.content,A),t.jsx(sBe,{scope:r,scrollbar:b,hasThumb:a,onThumbChange:Za(i),onThumbPointerUp:Za(o),onThumbPositionChange:_,onThumbPointerDown:Za(l),children:t.jsx(vN.div,{...g,ref:w,style:{position:"absolute",...g.style},onPointerDown:$x(e.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),j.current=b.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",v.viewport&&(v.viewport.style.scrollBehavior="auto"),T(M))}),onPointerMove:$x(e.onPointerMove,T),onPointerUp:$x(e.onPointerUp,M=>{const R=M.target;R.hasPointerCapture(M.pointerId)&&R.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=x.current,v.viewport&&(v.viewport.style.scrollBehavior=""),j.current=null})})})}),xk="ScrollAreaThumb",kae=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=Sae(xk,e.__scopeScrollArea);return t.jsx(yN,{present:r||a.hasThumb,children:t.jsx(rBe,{ref:s,...n})})}),rBe=u.forwardRef((e,s)=>{const{__scopeScrollArea:r,style:n,...a}=e,i=Bm(xk,r),o=Sae(xk,r),{onThumbPositionChange:l}=o,c=mr(s,p=>o.onThumbChange(p)),d=u.useRef(void 0),h=l2(()=>{d.current&&(d.current(),d.current=void 0)},100);return u.useEffect(()=>{const p=i.viewport;if(p){const g=()=>{if(h(),!d.current){const v=iBe(p,l);d.current=v,l()}};return l(),p.addEventListener("scroll",g),()=>p.removeEventListener("scroll",g)}},[i.viewport,h,l]),t.jsx(vN.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)",...n},onPointerDownCapture:$x(e.onPointerDownCapture,p=>{const v=p.target.getBoundingClientRect(),b=p.clientX-v.left,y=p.clientY-v.top;o.onThumbPointerDown({x:b,y})}),onPointerUp:$x(e.onPointerUp,o.onThumbPointerUp)})});
556kae.displayName=xk;var VD="ScrollAreaCorner",_ae=u.forwardRef((e,s)=>{const r=Bm(VD,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?t.jsx(nBe,{...e,ref:s}):null});_ae.displayName=VD;var nBe=u.forwardRef((e,s)=>{const{__scopeScrollArea:r,...n}=e,a=Bm(VD,r),[i,o]=u.useState(0),[l,c]=u.useState(0),d=!!(i&&l);return xb(a.scrollbarX,()=>{const h=a.scrollbarX?.offsetHeight||0;a.onCornerHeightChange(h),c(h)}),xb(a.scrollbarY,()=>{const h=a.scrollbarY?.offsetWidth||0;a.onCornerWidthChange(h),o(h)}),d?t.jsx(vN.div,{...n,ref:s,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 vk(e){return e?parseInt(e,10):0}function Pae(e,s){const r=e/s;return isNaN(r)?0:r}function o2(e){const s=Pae(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*s;return Math.max(n,18)}function aBe(e,s,r,n="ltr"){const a=o2(r),i=a/2,o=s||i,l=a-o,c=r.scrollbar.paddingStart+o,d=r.scrollbar.size-r.scrollbar.paddingEnd-l,h=r.content-r.viewport,p=n==="ltr"?[0,h]:[h*-1,0];return Eae([c,d],p)(e)}function n9(e,s,r="ltr"){const n=o2(s),a=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,i=s.scrollbar.size-a,o=s.content-s.viewport,l=i-n,c=r==="ltr"?[0,o]:[o*-1,0],d=Y0(e,c);return Eae([0,o],[0,l])(d)}function Eae(e,s){return r=>{if(e[0]===e[1]||s[0]===s[1])return s[0];const n=(s[1]-s[0])/(e[1]-e[0]);return s[0]+n*(r-e[0])}}function Tae(e,s){return e>0&&e<s}var iBe=(e,s=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function a(){const i={left:e.scrollLeft,top:e.scrollTop},o=r.left!==i.left,l=r.top!==i.top;(o||l)&&s(),r=i,n=window.requestAnimationFrame(a)})(),()=>window.cancelAnimationFrame(n)};function l2(e,s){const r=Za(e),n=u.useRef(0);return u.useEffect(()=>()=>window.clearTimeout(n.current),[]),u.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function xb(e,s){const r=Za(s);da(()=>{let n=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(e),()=>{window.cancelAnimationFrame(n),a.unobserve(e)}}},[e,r])}var Aae=bae,oBe=jae,lBe=_ae;const yk=u.forwardRef(({className:e,children:s,...r},n)=>t.jsxs(Aae,{ref:n,className:Cs("relative overflow-hidden",e),...r,children:[t.jsx(oBe,{className:"h-full w-full rounded-[inherit]",children:s}),t.jsx(Mae,{}),t.jsx(lBe,{})]}));yk.displayName=Aae.displayName;const Mae=u.forwardRef(({className:e,orientation:s="vertical",...r},n)=>t.jsx(HD,{ref:n,orientation:s,className:Cs("flex touch-none select-none transition-colors",s==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",s==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:t.jsx(kae,{className:"relative flex-1 rounded-full bg-border"})}));Mae.displayName=HD.displayName;const F1=[{value:1,label:"1",cols:1,rows:1},{value:4,label:"4",cols:2,rows:2},{value:8,label:"8",cols:4,rows:2},{value:16,label:"16",cols:4,rows:4},{value:32,label:"32",cols:8,rows:4},{value:64,label:"64",cols:8,rows:8}];function cBe({cols:e,rows:s,active:r}){const n=Math.min(e,4),a=Math.min(s,4),i=r?"fill-primary-foreground":"fill-muted-foreground/60",o=.8,l=16,c=(l-o*(n-1))/n,d=(l-o*(a-1))/a;return t.jsx("svg",{width:l,height:l,viewBox:`0 0 ${l} ${l}`,className:"shrink-0",children:Array.from({length:a}).map((h,p)=>Array.from({length:n}).map((g,v)=>t.jsx("rect",{x:v*(c+o),y:p*(d+o),width:c,height:d,rx:e===1?2:.5,className:i},`${p}-${v}`)))})}function dBe(){const[,e]=Ia(),{toast:s}=Hs(),[r,n]=u.useState(()=>{try{const Xt=new URLSearchParams(window.location.search).get("cameras");if(Xt)return JSON.parse(Xt)}catch{}return[]}),[a,i]=u.useState(()=>{const Xt=new URLSearchParams(window.location.search).get("layout");if(Xt){const Ut=Number(Xt);if([1,4,9,16,25,36,49,64].includes(Ut))return Ut}return 4}),[o,l]=u.useState(0),[c,d]=u.useState(null),{data:h}=ze({queryKey:["/api/user/role"],staleTime:5*6e4}),p=h?.role==="admin"||h?.role==="superadmin",g=u.useRef(null),[v,b]=u.useState(0),[y,w]=u.useState(()=>new URLSearchParams(window.location.search).get("loop")==="1"),[j,x]=u.useState(0),[C,k]=u.useState(!1),[S,_]=u.useState(()=>Math.min(window.innerWidth,window.innerHeight)<640),[A,T]=u.useState(()=>window.innerHeight>window.innerWidth),[M,R]=u.useState(!0),[D,$]=u.useState(!0),O=u.useRef(0),q=u.useRef(0),V=u.useRef(!1),[K,G]=u.useState(1),[z,Z]=u.useState(!1),[ee,Q]=u.useState(!1),[Y,oe]=u.useState(!1),[he,je]=u.useState(""),[pe,le]=u.useState(()=>new URLSearchParams(window.location.search).get("viewId")||null),[ue,fe]=u.useState(()=>new URLSearchParams(window.location.search).get("viewName")||null);u.useEffect(()=>{const qe=()=>{k(window.innerWidth<640),_(Math.min(window.innerWidth,window.innerHeight)<640),T(window.innerHeight>window.innerWidth)};return qe(),window.addEventListener("resize",qe),()=>window.removeEventListener("resize",qe)},[]);const H=S?F1.filter(qe=>qe.value<=16):F1;u.useEffect(()=>{S&&a>16&&i(16)},[S,a]),u.useEffect(()=>{A&&(R(!0),$(!0))},[A]),u.useEffect(()=>{a!==1&&$(!0)},[a]);const{data:se}=ze({queryKey:["/api/user/settings"]}),me=(se?.previewCycleRate||5)*1e3,ge=u.useRef(1e3);u.useEffect(()=>{if(r.length===0)return;const qe=setInterval(()=>b(Xt=>Xt+1),ge.current);return()=>clearInterval(qe)},[r.length]),u.useEffect(()=>{if(!(!y||r.length<=1))if(a===1){const qe=setInterval(()=>{x(Xt=>(Xt+1)%r.length)},me);return()=>clearInterval(qe)}else{const qe=Math.max(1,Math.ceil(r.length/a));if(qe<=1)return;const Xt=setInterval(()=>{l(Ut=>(Ut+1)%qe)},me);return()=>clearInterval(Xt)}},[y,r.length,a,me]);const{data:be=[],isLoading:ce}=ze({queryKey:["/api/multi-live-view/sites-cameras"],staleTime:60*1e3}),{data:Pe=[]}=ze({queryKey:["/api/multi-live-views"]}),et=Et({mutationFn:async qe=>(await Ze("POST","/api/multi-live-views",qe)).json(),onSuccess:qe=>
556{Je.invalidateQueries({queryKey:["/api/multi-live-views"]}),le(qe.id),fe(qe.name),s({title:"View saved",description:`"${qe.name}" has been saved.`})}}),$e=Et({mutationFn:async({id:qe,data:Xt})=>(await Ze("PATCH",`/api/multi-live-views/${qe}`,Xt)).json(),onSuccess:qe=>{Je.invalidateQueries({queryKey:["/api/multi-live-views"]}),fe(qe.name),s({title:"View updated",description:`"${qe.name}" has been updated.`})}}),bt=Et({mutationFn:async qe=>{await Ze("DELETE",`/api/multi-live-views/${qe}`)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/multi-live-views"]}),s({title:"View deleted"})}}),Ae=u.useCallback((qe,Xt,Ut,gt)=>{n(es=>es.some(fr=>fr.siteId===qe&&fr.cameraName===Ut)?es.filter(fr=>!(fr.siteId===qe&&fr.cameraName===Ut)):[...es,{siteId:qe,siteName:Xt,cameraName:Ut,displayName:gt}])},[]),Be=u.useCallback((qe,Xt)=>r.some(Ut=>Ut.siteId===qe&&Ut.cameraName===Xt),[r]),J=F1.find(qe=>qe.value===a)||F1[0],ae=J.value,we=Math.max(1,Math.ceil(r.length/ae)),Qe=Math.min(o,we-1),ye=r.slice(Qe*ae,Qe*ae+ae),te=a===1?r[j]:null,Ue=ye.find(qe=>`${qe.siteId}|${qe.cameraName}`===c),We=te??Ue??ye[0],[St,It]=UO(We?.siteId??""),ns=qe=>{O.current=qe.touches[0].clientX,q.current=qe.touches[0].clientY},dt=u.useCallback(qe=>{const Xt=qe.changedTouches[0].clientX-O.current,Ut=Math.abs(qe.changedTouches[0].clientY-q.current);Math.abs(Xt)>50&&Math.abs(Xt)>Ut&&(Xt<0?l(gt=>Math.min(gt+1,we-1)):l(gt=>Math.max(gt-1,0)))},[we]),Qt=a<=4?720:a<=16?480:240,Re=qe=>{const Xt=ye[qe];if(!Xt)return;const Ut=`${Xt.siteId}|${Xt.cameraName}`;d(gt=>gt===Ut?null:Ut),S&&!A&&R(gt=>!gt)},pt=qe=>{const Xt=ye[qe];if(!Xt)return;g.current={layout:a,page:o};const Ut=r.findIndex(gt=>gt.siteId===Xt.siteId&&gt.cameraName===Xt.cameraName);x(Ut>=0?Ut:0),i(1),d(null)},Ft=()=>{g.current&&(i(g.current.layout),l(g.current.page),g.current=null,d(null))},Es=()=>{r.length!==0&&x(qe=>(qe-1+r.length)%r.length)},Ge=()=>{r.length!==0&&x(qe=>(qe+1)%r.length)},ft=u.useCallback((qe,Xt)=>{const Ut=be.find(gt=>gt.siteId===qe);if(Ut){const gt=Ut.cameras.find(es=>es.name===Xt);if(gt)return gt.displayName}return Xt},[be]),He=u.useMemo(()=>{const qe={};for(const Xt of be)for(const Ut of Xt.cameras)Ut.usesGo2rtc&&(qe[`${Xt.siteId}|${Ut.name}`]=!0);return qe},[be]),zt=u.useMemo(()=>[...new Set(be.map(qe=>qe.siteId))],[be]),fs=Ix({queries:zt.map(qe=>({queryKey:["/api/sites",qe,"stream-options"],staleTime:300*1e3}))});u.useEffect(()=>{const qe=zt.map((Ut,gt)=>{const es=fs[gt]?.data;return Math.max(1,Math.min(2,es?.jpegFps??1))}),Xt=qe.length>0?Math.max(...qe):1;ge.current=Math.round(1e3/Xt)},[zt,fs]);const Ce=a===1?te?`${ft(te.siteId,te.cameraName)} - ${te.siteName}`:"No Camera Selected":c?(()=>{const[qe,Xt]=c.split("|"),Ut=r.find(gt=>gt.siteId===qe&&gt.cameraName===Xt);return Ut?`${ft(qe,Xt)} - ${Ut.siteName}`:`${r.length} Cameras`})():`${ye.length} Cameras`,[Dt,ne]=u.useState("new"),Oe=()=>{pe?(ne("choose"),je(""),Q(!0)):(ne("new"),je(""),Q(!0))},De=()=>{he.trim()&&(et.mutate({name:he.trim(),layout:a,cameras:r}),Q(!1))},jt=()=>{pe&&($e.mutate({id:pe,data:{layout:a,cameras:r}}),Q(!1))},Ct=qe=>{try{const Ut=JSON.parse(qe.cameras).map(gt=>({...gt,displayName:ft(gt.siteId,gt.cameraName)}));n(Ut),i(qe.layout||4),le(qe.id),fe(qe.name),l(0),d(null),x(0),oe(!1)}catch{s({title:"Error loading view",variant:"destructive"})}},Lt=(qe,Xt)=>{Xt.stopPropagation(),bt.mutate(qe),pe===qe&&(le(null),fe(null))},xr=u.useCallback(qe=>{n(Xt=>{const Ut=Xt.filter(es=>es.siteId!==qe.siteId);return qe.cameras.every(es=>Xt.some(br=>br.siteId===qe.siteId&&br.cameraName===es.name))?Ut:[...Ut,...qe.cameras.map(es=>({siteId:qe.siteId,siteName:qe.siteName,cameraName:es.name,displayName:es.displayName}))]})},[]);return t.jsxs("div",{className:"flex flex-col h-screen bg-black",style:{paddingTop:"env(safe-area-inset-top)"},"data-testid":"multi-live-view-page",children:[t.jsxs("div",{className:`px-2 sm:px-3 py-1.5 sm:py-2 border-b border-border bg-background flex items-center justify-between gap-1 sm:gap-2 shrink-0 transition-all duration-200 ${S&&!A&&!M?"hidden":""}`,children:[t.jsxs("div",{className:"flex items-center gap-1 sm:gap-2 min-w-0 shrink-0",children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>e("/"),"data-testid":"button-back-dashboard",children:t.jsx(Wi,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Back to Dashboard"})]}),t.jsx(Vi,{className:"w-4 h-4 text-primary shrink-0 hidden sm:block"}),t.jsx("span",{className:"text-sm font-medium truncate hidden sm:inline","data-testid":"text-view-title",children:ue||"Edge+ Live View"})]}),t.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1 flex-wrap justify-end",children:[t.jsxs(vd,{open:z,onOpenChange:Z,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",size:"sm","data-testid":"button-select-cameras",children:[t.jsx(no,{className:"w-4 h-4 mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Cameras"}),r.length>0&&t.jsx(Ke,{variant:"secondary",className:"ml-1 text-[10px] px-1 hidden sm:inline-flex",children:r.length}),t.jsx(CK,{className:"w-3 h-3 ml-1"})]})}),t.jsxs(Kc,{className:"w-80 p-0",align:"end",children:[t.jsxs("div",{className:"p-3 border-b",children:[t.jsx("p",{className:"text-sm font-medium",children:"Select Cameras"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Choose cameras from your sites"})]}),t.jsx(yk,{className:"h-[320px]",children:t.jsx("div",{className:"p-2 space-y-1",children:ce?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(Fe,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):be.length===0?t.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No accessible sites found"}):be.map(qe=>{const Xt=qe.cameras.every(gt=>Be(qe.siteId,gt.name)),Ut=qe.cameras.some(gt=>Be(qe.siteId,gt.name));return t.jsxs("div",{className:"space-y-0.5",children:[t.jsx(Wt,{children:t.jsx(Kt,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-left hover-elevate",onClick:()=>xr(qe),"data-testid":`site-toggle-${qe.siteId}`,children:[t.jsx(On,{checked:Xt?!0:Ut?"indeterminate":!1,className:"pointer-events-none"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:qe.siteName}),t.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:qe.companyName})]})]})})}),t.jsx("div",{className:"ml-6 space-y-0.5",children:qe.cameras.map(gt=>t.jsxs("button",{type:"button",className:"flex items-center gap-2 w-full px-2 py-1 rounded text-left hover-elevate",onClick:()=>Ae(qe.siteId,qe.siteName,gt.name,gt.displayName),"data-testid":`camera-toggle-${qe.siteId}-${gt.name}`,children:[t.jsx(On,{checked:Be(qe.siteId,gt.name),className:"pointer-events-none"}
556),t.jsx("span",{className:"text-sm truncate",children:gt.displayName})]},`${qe.siteId}-${gt.name}`))}),t.jsx(Qh,{className:"my-1"})]},qe.siteId)})})}),r.length>0&&t.jsxs("div",{className:"p-2 border-t flex items-center justify-between gap-2",children:[t.jsxs("span",{className:"text-xs text-muted-foreground",children:[r.length," selected"]}),t.jsx(L,{variant:"ghost",size:"sm",onClick:()=>n([]),"data-testid":"button-clear-cameras",children:"Clear All"})]})]})]}),t.jsx(Qh,{orientation:"vertical",className:"h-6 mx-1 hidden sm:block"}),t.jsx("div",{className:"flex items-center gap-0.5 bg-muted/50 rounded-md p-0.5","data-testid":"multi-live-layout-selector",children:H.map(qe=>t.jsx("button",{onClick:()=>{i(qe.value),l(0),d(null),g.current=null},className:`flex items-center justify-center w-8 h-7 rounded transition-colors ${a===qe.value?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:`${qe.label} camera${qe.value>1?"s":""}`,"data-testid":`multi-live-layout-${qe.value}`,children:t.jsx(cBe,{cols:qe.cols,rows:qe.rows,active:a===qe.value})},qe.value))}),t.jsx(Qh,{orientation:"vertical",className:"h-6 mx-1 hidden sm:block"}),S&&A?t.jsxs("button",{onClick:()=>It(qe=>qe==="auto"?"main":qe==="main"?"sub":qe==="sub"?"jpeg":"auto"),className:"flex items-center gap-1 px-2 h-7 rounded-md bg-muted/50 text-xs font-medium text-foreground",title:`Stream source for ${We?.siteName??"selected site"} — tap to cycle Auto / Main / Sub / JPEG`,"aria-label":`Stream source for ${We?.siteName??"selected site"}: ${St}`,disabled:!We,"data-testid":"multi-live-stream-source-toggle",children:[t.jsx(hf,{className:"w-3.5 h-3.5 text-muted-foreground"}),St==="auto"?"Auto":St==="main"?"Main":St==="sub"?"Sub":"JPEG"]}):t.jsxs("div",{className:"flex items-center gap-0.5 bg-muted/50 rounded-md p-0.5","aria-label":`Stream source for ${We?.siteName??"selected site"}`,"data-testid":"multi-live-stream-source-selector",children:[t.jsx(hf,{className:"w-3.5 h-3.5 text-muted-foreground mx-1 hidden sm:block"}),[{value:"auto",label:"Auto",title:"Auto — main stream for single view, sub stream for grids"},{value:"main",label:"Main",title:"Main stream — higher quality, more bandwidth"},{value:"sub",label:"Sub",title:"Sub stream — lower bandwidth"},{value:"jpeg",label:"JPEG",title:"JPEG — Image stills for lowest bandwidth"}].map(qe=>t.jsx("button",{onClick:()=>It(qe.value),className:`flex items-center justify-center px-2 h-7 rounded text-xs font-medium transition-colors ${St===qe.value?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-muted"}`,title:`${We?.siteName??"Selected site"}: ${qe.title}`,"aria-label":`${qe.label} for ${We?.siteName??"selected site"}`,disabled:!We,"data-testid":`multi-live-stream-source-${qe.value}`,children:qe.label},qe.value))]}),t.jsx(Qh,{orientation:"vertical",className:"h-6 mx-1 hidden sm:block"}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>w(qe=>!qe),className:`toggle-elevate ${y?"toggle-elevated":""}`,"data-testid":"button-loop-toggle",children:t.jsx(tl,{className:`w-4 h-4 ${y?"animate-spin":""}`,style:y?{animationDuration:"3s"}:void 0})})}),t.jsx(Yt,{children:y?`Looping (${se?.previewCycleRate||5}s)`:"Auto-cycle cameras"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:"hidden lg:inline-flex",onClick:()=>{const qe=new URLSearchParams;r.length>0&&qe.set("cameras",JSON.stringify(r)),qe.set("layout",String(a)),y&&qe.set("loop","1"),pe&&qe.set("viewId",pe),ue&&qe.set("viewName",ue);const Xt=`${window.location.pathname}?${qe.toString()}`;if(!window.open(Xt,"_blank")){window.location.assign(Xt);return}e("/")},"data-testid":"button-fullscreen-tab",children:t.jsx(pf,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Open in new tab"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>oe(!0),"data-testid":"button-load-view",children:t.jsx(P$,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Load Saved View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",onClick:Oe,disabled:r.length===0||et.isPending||$e.isPending,"data-testid":"button-save-view",children:t.jsx(Vl,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Save View"})]}),t.jsx("div",{className:"hidden lg:block ml-1",children:t.jsx(qd,{showDashboardLink:!0})})]})]}),t.jsx("div",{className:`${A&&S&&a===1?"":"flex-1"} min-h-0 bg-black ${S?"overflow-y-auto":"overflow-hidden"}`,children:r.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-white/60",children:[t.jsx(no,{className:"w-16 h-16 mb-4 text-white/20"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Cameras Selected"}),t.jsx("p",{className:"text-sm text-white/40 max-w-sm text-center mb-6",children:"Select cameras from multiple sites to create a custom live view."}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(L,{variant:"outline",onClick:()=>Z(!0),"data-testid":"button-select-cameras-empty",children:[t.jsx(no,{className:"w-4 h-4 mr-2"}),"Select Cameras"]}),Pe.length>0&&t.jsxs(L,{variant:"outline",onClick:()=>oe(!0),"data-testid":"button-load-view-empty",children:[t.jsx(P$,{className:"w-4 h-4 mr-2"}),"Load View"]}
556)]})]}):a===1?t.jsxs("div",{className:`relative w-full overflow-hidden select-none ${A&&S?"aspect-video":"h-full"}`,children:[te&&t.jsx(jg,{testIdPrefix:"zoom-live-single",className:"absolute inset-0",doubleClickZoom:!1,onZoomChange:G,children:He[`${te.siteId}|${te.cameraName}`]?t.jsx(Ly,{siteId:te.siteId,cameraName:te.cameraName,className:"absolute inset-0 w-full h-full",refreshKey:v,objectFit:A&&S?"contain":"cover",streamSource:eM(te.siteId),singleView:!0},`${te.siteId}|${te.cameraName}`):t.jsx(af,{src:`/api/sites/${te.siteId}/cameras/${encodeURIComponent(te.cameraName)}/thumbnail?t=${v}&stream=record&live=1`,alt:ft(te.siteId,te.cameraName),className:`absolute inset-0 w-full h-full ${A&&S?"object-contain":"object-cover"}`,"data-testid":"multi-live-single-image"})},`${te.siteId}|${te.cameraName}`),t.jsx("div",{className:"absolute inset-0 z-10",onClick:()=>{if(V.current){V.current=!1;return}S&&!A&&(R(qe=>!qe),$(qe=>!qe))},onDoubleClick:Ft,onTouchStart:qe=>{V.current=!1,O.current=qe.touches[0].clientX,q.current=qe.touches[0].clientY},onTouchEnd:qe=>{if(K>1)return;const Xt=qe.changedTouches[0].clientX-O.current,Ut=Math.abs(qe.changedTouches[0].clientY-q.current);Math.abs(Xt)>50&&Math.abs(Xt)>Ut&&(V.current=!0,Xt<0?Ge():Es())}}),r.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"absolute left-2 top-1/2 -translate-y-1/2 w-9 h-9 rounded-full bg-black/60 backdrop-blur-sm text-white/90 hover:bg-black/80 hover:text-white items-center justify-center transition-all hidden lg:flex z-20",onClick:Es,"data-testid":"multi-live-prev",children:t.jsx(Kl,{className:"w-5 h-5"})}),t.jsx("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 w-9 h-9 rounded-full bg-black/60 backdrop-blur-sm text-white/90 hover:bg-black/80 hover:text-white items-center justify-center transition-all hidden lg:flex z-20",onClick:Ge,"data-testid":"multi-live-next",children:t.jsx(hi,{className:"w-5 h-5"})})]})]}):t.jsx("div",{className:`w-full select-none ${S?"shrink-0":"overflow-hidden h-full"}`,onTouchStart:ns,onTouchEnd:dt,children:t.jsx("div",{className:"grid w-full",style:{gridTemplateColumns:`repeat(${J.cols}, 1fr)`,...S?{}:{gridTemplateRows:`repeat(${J.rows}, minmax(0, 1fr))`,height:"100%"}},"data-testid":"multi-live-grid",children:Array.from({length:ae}).map((qe,Xt)=>{const Ut=ye[Xt],gt=S?{aspectRatio:"4/3"}:{};if(!Ut)return t.jsx("div",{className:"relative bg-black/80 border border-white/5 flex items-center justify-center overflow-hidden",style:gt,children:t.jsx(no,{className:"w-6 h-6 text-white/10"})},`empty-${Xt}`);const es=`${Ut.siteId}|${Ut.cameraName}`,br=c===es;return t.jsxs("button",{type:"button",onClick:()=>Re(Xt),onDoubleClick:()=>pt(Xt),className:`relative bg-black border transition-colors overflow-hidden select-none ${br?"border-primary border-2":"border-white/10"}`,style:gt,"data-testid":`multi-live-cell-${Xt}`,children:[He[es]?t.jsx(Ly,{siteId:Ut.siteId,cameraName:Ut.cameraName,className:"absolute inset-0 w-full h-full",refreshKey:v,streamSource:eM(Ut.siteId),singleView:!1},es):t.jsx(af,{src:`/api/sites/${Ut.siteId}/cameras/${encodeURIComponent(Ut.cameraName)}/thumbnail?t=${v}&h=${Qt}&live=1`,alt:ft(Ut.siteId,Ut.cameraName),className:"absolute inset-0 w-full h-full object-cover"}),t.jsxs("span",{className:"absolute bottom-0 left-0 right-0 text-[10px] text-white bg-black/70 px-1 py-0.5 truncate z-10",children:[ft(Ut.siteId,Ut.cameraName),t.jsxs("span",{className:"text-white/50 ml-1",children:["(",Ut.siteName,")"]})]}),br&&t.jsx(Q0,{siteId:Ut.siteId,cameraName:Ut.cameraName,isAdmin:p,compact:!0})]},es)})})})}),t.jsxs("div",{className:`px-3 py-2 border-t border-border bg-background flex items-center justify-between gap-2 shrink-0 transition-all duration-200 ${S&&!A&&!M?"hidden":""}`,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground shrink-0 hidden lg:inline","data-testid":"text-camera-info",children:Ce}),t.jsx(cC,{siteId:a===1?te?.siteId:c?c.split("|")[0]:void 0})]}),a===1&&r.length>1?t.jsx("div",{className:`flex items-center gap-1 overflow-x-auto transition-all duration-200 ${S&&!A&&!D?"opacity-0 pointer-events-none h-0 py-0 overflow-hidden":""}`,children:r.map((qe,Xt)=>t.jsxs("button",{type:"button",onClick:()=>x(Xt),className:`relative aspect-video w-20 shrink-0 rounded overflow-hidden border-2 transition-colors ${Xt===j?"border-primary":"border-transparent"}`,"data-testid":`multi-live-thumb-${Xt}`,children:[t.jsx(af,{src:`/api/sites/${qe.siteId}/cameras/${encodeURIComponent(qe.cameraName)}/thumbnail?t=static`,alt:ft(qe.siteId,qe.cameraName),className:"w-full h-full object-cover",compact:!0}),t.jsx("span",{className:"absolute bottom-0 left-0 right-0 text-[8px] text-white bg-black/60 px-0.5 truncate text-center",children:ft(qe.siteId,qe.cameraName)})]},`${qe.siteId}-${qe.cameraName}`))}):a>1&&we>1?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(L,{variant:"ghost",size:"sm",disabled:Qe===0,onClick:()=>l(qe=>Math.max(0,qe-1)),"data-testid":"multi-live-grid-prev",children:t.jsx(Kl,{className:"w-4 h-4"})}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["Page ",Qe+1," of ",we]}),t.jsx(L,{variant:"ghost",size:"sm",disabled:Qe>=we-1,onClick:()=>l(qe=>Math.min(we-1,qe+1)),"data-testid":"multi-live-grid-next",children:t.jsx(hi,{className:"w-4 h-4"})})]}):null]}),t.jsx(Ys,{open:ee,onOpenChange:Q,children:t.jsxs(Ws,{children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Save View"}),t.jsx(cr,{children:Dt==="choose"?`Update "${ue}" or save as a new view.`:"Give your custom camera view a name so you can load it later."})]}),Dt==="choose"?t.jsxs("div",{className:"space-y-3 py-2",children:[t.jsx(L,{className:"w-full",onClick:jt,disabled:$e.isPending,"data-testid":"button-update-existing",children:$e.isPending?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Updating..."]}):`Update "${ue}"`}),t.jsx("div",{className:"relative flex items-center justify-center",children:t.jsx("span",{className:"bg-background px-2 text-xs text-muted-foreground",children:"or save as new"})}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ke,{value:he,onCh
556ange:qe=>je(qe.target.value),placeholder:"New view name","data-testid":"input-view-name",onKeyDown:qe=>{qe.key==="Enter"&&De()}}),t.jsx(L,{onClick:De,disabled:!he.trim()||et.isPending,"data-testid":"button-confirm-save",children:et.isPending?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):"Save"})]})]}):t.jsxs("div",{className:"space-y-2 py-2",children:[t.jsx(re,{htmlFor:"view-name",children:"View Name"}),t.jsx(ke,{id:"view-name",value:he,onChange:qe=>je(qe.target.value),placeholder:"e.g. Front Entrances","data-testid":"input-view-name",onKeyDown:qe=>{qe.key==="Enter"&&De()}})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>Q(!1),"data-testid":"button-cancel-save",children:"Cancel"}),Dt!=="choose"&&t.jsx(L,{onClick:De,disabled:!he.trim()||et.isPending,"data-testid":"button-confirm-save",children:et.isPending?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):"Save"})]})]})}),t.jsx(Ys,{open:Y,onOpenChange:oe,children:t.jsxs(Ws,{children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Load Saved View"}),t.jsx(cr,{children:"Select a saved view to load its camera configuration."})]}),t.jsx(yk,{className:"max-h-80",children:t.jsx("div",{className:"space-y-2 py-2",children:Pe.length===0?t.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No saved views yet. Select cameras and save a view to get started."}):Pe.map(qe=>{const Xt=(()=>{try{return JSON.parse(qe.cameras).length}catch{return 0}})();return t.jsx(ut,{className:`overflow-visible hover-elevate cursor-pointer ${pe===qe.id?"border-primary":""}`,onClick:()=>Ct(qe),"data-testid":`saved-view-${qe.id}`,children:t.jsxs(mt,{className:"p-3 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:qe.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[Xt," camera",Xt!==1?"s":""," · ",qe.layout,"-grid layout"]})]}),t.jsx(L,{variant:"ghost",size:"icon",onClick:Ut=>Lt(qe.id,Ut),"data-testid":`delete-view-${qe.id}`,children:t.jsx(sa,{className:"w-4 h-4 text-destructive"})})]})},qe.id)})})})]})})]})}const uBe=120,mBe=900;function a9(e,s,r){const n=uBe,a=mBe,i=Math.floor(e.start_time),o=Math.ceil(e.end_time??e.start_time+30),l=(s||[]).filter(d=>d.camera===e.camera&&Number.isFinite(d.start_time)).map(d=>({start:Math.floor(d.start_time),end:Math.ceil(d.end_time??d.start_time+30)})).filter(d=>d.end>=i).sort((d,h)=>d.start-h.start);let c=o;for(const d of l)if(d.start<=c+n)d.end>c&&(c=d.end);else break;return c=Math.min(c,i+a),{start:i,end:c}}const hBe=500,V4=52,qv=52;function i9(e){const s={person:"#3b82f6",car:"#f59e0b",vehicle:"#f59e0b",truck:"#ea580c",motorcycle:"#fb923c",bicycle:"#14b8a6",bus:"#ca8a04",dog:"#22c55e",cat:"#a855f7",animal:"#22c55e",bird:"#34d399",face:"#ec4899",license_plate:"#ef4444",package:"#6366f1",motion:"#eab308"};for(const r of e){const n=r.toLowerCase();if(s[n])return s[n]}return"#6366f1"}const zh=[1,2,4,8,24,48,96],pBe=["24h","12h","6h","3h","1h","30m","15m"];function fBe(e,s){const r=s-e;let n,a;r>=18*36e5?(n=36e5,a="h a"):r>=6*36e5?(n=18e5,a="h:mm"):r>=2*36e5?(n=9e5,a="h:mm"):r>=45*6e4?(n=3e5,a="h:mm"):(n=6e4,a="h:mm");const i=[],o=Math.ceil(e/n)*n;for(let l=o;l<=s;l+=n)i.push({time:l,label:Bn(new Date(l),a)});return i}function o9({segments:e,onSegmentClick:s,timelineDate:r,detectionColor:n,motionColor:a,cameraDisplayNames:i}){const o=u.useRef(null),l=u.useRef(null),[c,d]=u.useState(null),[h,p]=u.useState(0),[g,v]=u.useState(0),b=u.useRef(null),y=u.useRef(!1),w=u.useRef(new Map),j=u.useRef(null),x=u.useRef(0),C=u.useRef(0);x.current=h,C.current=g;const{cameraGroups:k,fullDayStart:S,fullDayEnd:_}=u.useMemo(()=>{const ue=new Date(r);ue.setHours(0,0,0,0);const fe=new Date(r);fe.setHours(23,59,59,999);const H=new Date,se=ue.toDateString()===H.toDateString(),me=new Date(se?Math.min(fe.getTime(),H.getTime()):fe.getTime());me.setMinutes(0,0,0),me.setHours(me.getHours()+1);const ge=new Map;for(const be of e){const ce=ge.get(be.camera)||[];ce.push(be),ge.set(be.camera,ce)}return ge.forEach((be,ce)=>{ge.set(ce,be.sort((Pe,et)=>Pe.startMs-et.startMs))}),{cameraGroups:ge,fullDayStart:ue.getTime(),fullDayEnd:me.getTime()}},[e,r]),A=_-S,T=1/zh[h],M=Math.max(0,Math.min(g,1-T)),R=S+M*A,D=S+(M+T)*A,$=D-R,O=h>0,q=u.useMemo(()=>fBe(R,D),[R,D]);u.useEffect(()=>{p(0),v(0)},[r]);const[V,K]=u.useState(800);u.useEffect(()=>{const ue=o.current;if(!ue)return;const fe=new ResizeObserver(H=>{for(const se of H)K(se.contentRect.width-128)});return fe.observe(ue),()=>fe.disconnect()},[]);const G=u.useCallback((ue,fe)=>{const H=x.current,se=Math.max(0,Math.min(zh.length-1,H+ue));if(se===H)return;const me=fe??.5,ge=1/zh[H],be=C.current,Pe=Math.max(0,Math.min(be,1-ge))+me*ge,et=1/zh[se];p(se),v(Math.max(0,Math.min(Pe-me*et,1-et)))},[]);u.useEffect(()=>{const ue=l.current;if(!ue)return;const fe=H=>{if(H.deltaY===0)return;H.preventDefault();const se=ue.getBoundingClientRect(),me=Math.max(0,Math.min(1,(H.clientX-se.left)/se.width));G(H.deltaY<0?1:-1,me)};return ue.addEventListener("wheel",fe,{passive:!1}),()=>ue.removeEventListener("wheel",fe)},[G]);const z=u.useRef(0);u.useEffect(()=>{const ue=()=>{w.current.clear(),b.current&&b.current.totalDist>5&&(y.current=!0,setTimeout(()=>{y.current=!1},0)),b.current=null,j.current=null};return document.addEventListener("pointerup",ue),document.addEventListener("pointercancel",ue),()=>{document.removeEventListener("pointerup",ue),document.removeEventListener("pointercancel",ue)}},[]);const Z=u.useCallback(ue=>{if(w.current.set(ue.pointerId,{x:ue.clientX,y:ue.clientY}),w.current.size===2){b.current=null;try{ue.currentTarget.setPointerCapture(ue.pointerId)}catch{}const fe=Array.from(w.current.values());j.current={startDist:Math.hypot(fe[1].x-fe[0].x,fe[1].y-fe[0].y),startZoomIdx:x.current}}else if(w.current.size===1&&x.current>0){const fe=1/zh[x.current],H=Math.max(0,Math.min(C.current,1-fe));b.current={startX:ue.clientX,startView:H,totalDist:0},z.current=ue.clientX,y.current=!1}},[]),ee=u.useCallback(ue=>{if(w.current.has(ue.pointerId)&&w.current.set(ue.pointerId,{x:ue.clientX,y:ue.clientY}),w.current.size===2&&j.current){const ge=Array.from(w.current.values()),ce=Math.hypot(ge[1].x-ge[0].x,ge[1].y-ge[0].y)/j.current.startDist,Pe=Math.round(Math.log2(ce)*2),et=Math.max(0,Math.min(zh.length-1,j.current.startZoomIdx+Pe));if(et!==x.current){const $e=l.current?.getBoundingClientRect();if($e){const bt=(ge[0].x+ge[1].x)/2,Ae=Math.max(0,Math.min(1,(bt-$e.left)/$e.width)),Be=1/zh[x.current],ae=Math.max(0,Math.min(C.current,1-Be))+Ae*Be,we=1/zh[et];p(et),v(Math.max(0,Math.min(ae-Ae*we,1-we)))}}return}if(!b.current||w.current.size!==1)return;b.current.totalDist+=Math.abs(ue.clientX-z.current),z.current=ue.clientX;const fe=l.current?.getBoundingClientRect();if(!fe)return;const H=1/zh[x.current],me=(b.current.startX-ue.clientX)/fe.width*H;v(Math.max(0,Math.min(b.current.startView+me,1-H)))},[]),Q=u.useCallback(ue=>{try{ue.currentTarget?.releasePointerCapture?.(ue.pointerId)}catch{}b.current&&b.current.totalDist>5&&(y.current=!0,setTimeout(()=>{y.current=!1},0)),w.current.delete(ue.pointerId),w.current.size<2&&(j.current=null),w.current.size===0&&(b.current=null)},[]),Y=u.useCallback(()=>{w.current.clear(),b.current=null,j.current=null},[]),he=V>0?8/V*100:.5;if(e.length===0)return t.jsxs("div",{className:"text-center py-16",children:[t.jsx(Hx,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Events to Display"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"No events found for the selected filters. Try adjusting the date range or camera selection."})]});const je=ue=>$===0?0:(ue-R)/$*100,pe=(ue,fe)=>$===0?0:Math.max((fe-ue)/$*100,he),le=Array.from(k.keys()).sort();return t.jsx(ut,{children:t.jsxs(mt,{className:"pt-4 pb-2",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3 flex-wrap gap-2",children:[t.jsxs("div",{className:"flex items-center gap-1","data-testid":"multi-timeline-zoom-control
556s",children:[t.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>G(-1),disabled:h===0,"data-testid":"button-multi-zoom-out",children:t.jsx(uO,{className:"w-3.5 h-3.5"})}),t.jsx("span",{className:"text-[11px] text-muted-foreground font-medium min-w-[2rem] text-center select-none","data-testid":"text-multi-zoom-level",children:pBe[h]}),t.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>G(1),disabled:h===zh.length-1,"data-testid":"button-multi-zoom-in",children:t.jsx(Vj,{className:"w-3.5 h-3.5"})}),O&&t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 px-2 text-[11px] ml-1",onClick:()=>{p(0),v(0)},"data-testid":"button-multi-zoom-reset",children:"Reset"})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:n||"#3b82f6"}}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"AI Events"})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:a||"#eab308"}}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Motion"})]})]})]}),t.jsxs("div",{className:"relative",children:[c&&(()=>{const ue=c.seg,fe=ue.siteId||ue.originalEvent?.siteId||"",H=ue.originalEvent?.detections?.[0]&&fe?`/api/local-recordings/${fe}/thumbnail?detection=${encodeURIComponent(ue.originalEvent.detections[0])}`:ue.originalEvent?.camera&&ue.originalEvent?.start_time&&fe?`/api/local-recordings/${fe}/thumbnail?camera=${encodeURIComponent(ue.originalEvent.camera)}&time=${ue.originalEvent.start_time}`:ue.thumbnailUrl||null;return t.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 bottom-full z-50 pointer-events-none mb-1","data-testid":"multi-timeline-hover-preview",children:t.jsxs("div",{className:"rounded-md border bg-card shadow-lg overflow-hidden",style:{width:"200px"},children:[H&&t.jsx("img",{src:H,alt:"",className:"w-full h-auto object-cover",style:{maxHeight:"120px"},onError:se=>{se.target.style.display="none"}}),t.jsxs("div",{className:"px-2 py-1.5 flex items-center gap-2 text-xs",children:[t.jsx("span",{className:"font-medium truncate",children:i?.get(c.cameraKey)||c.cameraKey}),t.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:Bn(new Date(ue.startMs),"h:mm:ss a")})]})]})})})(),t.jsx("div",{className:"overflow-hidden",children:t.jsxs("div",{ref:o,children:[t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"w-32 flex-shrink-0"}),t.jsx("div",{className:"flex-1 relative h-6",children:q.map(ue=>{const fe=je(ue.time);return fe<-1||fe>101?null:t.jsx("div",{className:"absolute top-0 flex flex-col items-center",style:{left:`${fe}%`,transform:"translateX(-50%)"},children:t.jsx("span",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:ue.label})},ue.time)})})]}),t.jsx("div",{ref:l,className:`space-y-1 select-none ${O?"cursor-grab active:cursor-grabbing":""}`,style:{touchAction:"none"},onPointerDown:Z,onPointerMove:ee,onPointerUp:Q,onPointerCancel:Q,onLostPointerCapture:Y,onMouseLeave:()=>d(null),children:le.map(ue=>{const fe=k.get(ue)||[],H=i?.get(ue)||ue;return t.jsxs("div",{className:"flex items-center gap-0",children:[t.jsxs("div",{className:"w-32 flex-shrink-0 pr-2 flex items-center gap-1.5",children:[t.jsx(wo,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-xs truncate",title:H,children:H})]}),t.jsxs("div",{className:"flex-1 relative h-7 bg-muted/50 rounded-sm overflow-hidden",children:[q.map(se=>{const me=je(se.time);return me<=0||me>=100?null:t.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-border/50",style:{left:`${me}%`}},se.time)}),fe.map(se=>{const me=je(se.startMs),ge=pe(se.startMs,se.endMs);if(me+ge<0||me>100)return null;const be=se.labels.length>0?se.labels.join(", "):"event",ce=Bn(new Date(se.startMs),"h:mm:ss a");return t.jsx("div",{className:"absolute top-1 bottom-1 rounded-sm cursor-pointer opacity-80 hover:opacity-100 transition-opacity",style:{left:`${me}%`,width:`${ge}%`,minWidth:"8px",backgroundColor:se.labels.includes("motion")?a||"#eab308":n||i9(se.labels),zIndex:3,boxShadow:"inset -1px 0 0 0 rgba(0,0,0,0.55)"},onClick:()=>{y.current||s(se)},onMouseEnter:()=>d({seg:se,cameraKey:ue}),role:"button",tabIndex:0,"aria-label":`${H} ${be} at ${ce}`,"data-testid":`multi-timeline-segment-${se.id}`},se.id)})]})]},ue)})}),O&&t.jsx("div",{className:"mt-2 mx-0",children:t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"w-32 flex-shrink-0"}),t.jsx("div",{className:"flex-1 h-1.5 bg-muted rounded-full relative",children:t.jsx("div",{className:"absolute top-0 bottom-0 bg-primary/40 rounded-full min-w-[4px]",style:{left:`${M*100}%`,width:`${T*100}%`}})})]})}),t.jsx("div",{className:"flex items-center gap-3 mt-3 pt-2 border-t flex-wrap",children:Array.from(new Set(e.flatMap(ue=>ue.labels))).sort().map(ue=>
556t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:"w-2.5 h-2.5 rounded-sm",style:{backgroundColor:i9([ue])}}),t.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:ue})]},ue))})]})})]})]})})}function gBe(){const{user:e}=Gi(),[,s]=Ia(),{toast:r}=Hs(),[n,a]=u.useState("local"),[i,o]=u.useState([]),[l,c]=u.useState("all"),[d,h]=u.useState(1),[p,g]=u.useState(()=>{const F=new Date;return F.setTime(F.getTime()-3600*1e3),F}),[v,b]=u.useState(()=>new Date),[y,w]=u.useState(!1),[j,x]=u.useState(!1),[C,k]=u.useState(!1),[S,_]=u.useState(null),A=wJ(S?.siteId),[T,M]=u.useState(null),[R,D]=u.useState(!1),[$,O]=u.useState(null),q=u.useRef(null),V=u.useRef(null),[K,G]=u.useState(-1),[z,Z]=u.useState(0),[ee,Q]=u.useState(null),Y=Er(),[oe,he]=u.useState(!1),[je,pe]=u.useState(!1),[le,ue]=u.useState(!1),[fe,H]=u.useState(null),[se,me]=u.useState(null);u.useEffect(()=>{ue(!1),H(null),pe(!1),me(null)},[ee?.id]),u.useEffect(()=>{if(!le||!ee?.id||se)return;let F=!1;return(async()=>{try{const ve=await fetch(`/api/cloud-recordings/${ee.id}`,{credentials:"include"});if(!ve.ok||F)return;const Te=await ve.json();if(F)return;me({expired:!!Te.retentionExpired,retentionDays:typeof Te.retentionDays=="number"?Te.retentionDays:null})}catch{}})(),()=>{F=!0}},[le,ee?.id]),u.useEffect(()=>{he(!1)},[S?.id]);const ge=u.useRef(null);u.useEffect(()=>{const F=ge.current;if(!(!F||!ee))return N_(F,"[cloud]")},[ee?.id]);const be=u.useRef(null),[ce,Pe]=u.useState(-1),[et,$e]=u.useState(null),[bt,Ae]=u.useState(!1),[Be,J]=u.useState(null),[ae,we]=u.useState(null),[Qe,ye]=u.useState(!1),[te,Ue]=u.useState(null),[We,St]=u.useState(null),[It,ns]=u.useState(null),[dt,Qt]=u.useState(7200),[Re,pt]=u.useState("all"),Ft=u.useRef(null),[Es,Ge]=u.useState(""),[ft,He]=u.useState(null),zt=F=>F>=100?"bg-green-500 text-white border-transparent hover:bg-green-500":F>=90?"bg-lime-500 text-white border-transparent hover:bg-lime-500":F>=75?"bg-yellow-500 text-black border-transparent hover:bg-yellow-500":"bg-red-500 text-white border-transparent hover:bg-red-500",fs=F=>F>=100?"text-green-600 dark:text-green-400 font-medium":F>=90?"text-lime-600 dark:text-lime-400 font-medium":F>=75?"text-yellow-600 dark:text-yellow-400 font-medium":"text-red-600 dark:text-red-400 font-medium",[Ce,Dt]=u.useState(!1),[ne,Oe]=u.useState(null),De=u.useRef(null),jt=u.useRef(null);u.useEffect(()=>()=>{jt.current?.clear(),jt.current=null},[]);const[Ct,Lt]=u.useState(null),xr=u.useRef(null),Xt=ze({queryKey:["/api/visual-search/status"],staleTime:300*1e3}).data?.available??!1,[Ut,gt]=u.useState(""),[es,br]=u.useState(!1),[fr,xn]=u.useState(!1),[Br,Pi]=u.useState(new Map),[Qn,ii]=u.useState([]),[ua,Ua]=u.useState({done:0,total:0}),Ln=u.useRef(null),[Ir,Hr]=u.useState(""),[lt,Rt]=u.useState(!1),[At,Ht]=u.useState(!1),[vr,mn]=u.useState(new Map),[hr,Sn]=u.useState([]),[Sr,Os]=u.useState({done:0,total:0}),ur=u.useRef(null),qr=ze({queryKey:["/api/video-token"],staleTime:1800*1e3,gcTime:0,refetchOnWindowFocus:!0}).data?.token??"",So=u.useRef(qr);So.current=qr;const[Xn,Jr]=u.useState(!1),vn=u.useRef(null);u.useEffect(()=>{Jr(!1),vn.current=null},[ee?.id]);const Mn=u.useMemo(()=>{if(!ee)return;const F=[];return So.current&&F.push(`vt=${So.current}`),Xn&&F.push("transcode=1"),`/api/cloud-recordings/${ee.id}/clip.mp4${F.length?`?${F.join("&")}`:""}`},[ee?.id,!!qr,Xn]),Dr=ze({queryKey:["/api/user/settings"]}),[en,Co]=u.useState(!1),Oa=u.useRef(null);u.useEffect(()=>{Dr.data&&Oa.current===null&&Co(Dr.data.autoPlayEnabled??!0)},[Dr.data]),u.useEffect(()=>{if(Dr.data&&Oa.current!==null){const F=Dr.data.autoPlayEnabled??!0;F!==Oa.current&&(Co(F),Oa.current=null)}},[Dr.data]);const ku=Et({mutationFn:F=>Ze("PATCH","/api/user/settings",{autoPlayEnabled:F}),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/user/settings"]})},onError:()=>{Oa.current=null,Co(Dr.data?.autoPlayEnabled??!0)}}),ma=u.useCallback(()=>{const F=!en;Oa.current=F,Co(F),ku.mutate(F)},[en,ku]),[lo,Cn]=u.useState(0),[Lr,Vr]=u.useState([]),Nc=!1,[Ds,nl]=u.useState(()=>{if(typeof window<"u"&&window.innerWidth<640)return"events";if(!localStorage.getItem("truvios-recordings-classic-default-v1"))return localStorage.setItem("truvios-recordings-classic-default-v1","1"),localStorage.setItem("truvios-recordings-view-mode","classic"),"classic";const F=localStorage.getItem("truvios-recordings-view-mode");return F==="timeline"?"timeline":F==="events"?"events":"classic"}),[co,fn]=u.useState("desc"),bi=u.useMemo(()=>
556{if(!ft)return null;const F=[...ft];return F.sort((ve,Te)=>co==="asc"?ve.startTime-Te.startTime:Te.startTime-ve.startTime),F},[ft,co]),Sc=u.useMemo(()=>{if(!ae)return null;const F=[...ae];return F.sort((ve,Te)=>co==="asc"?ve.startTime-Te.startTime:Te.startTime-ve.startTime),F},[ae,co]),ra=u.useMemo(()=>i.map(F=>`${F.siteId}:${F.cameraName}`),[i]),[za,Xl]=u.useState(typeof window<"u"&&window.innerWidth<640),[Ei,na]=u.useState([]),[Ur,Da]=u.useState(!1),Xc=u.useRef(null);u.useEffect(()=>{const F=()=>{const ve=window.innerWidth<640;Xl(ve),ve&&Ds==="timeline"&&nl("events")};return F(),window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[Ds]),u.useEffect(()=>{localStorage.setItem("truvios-recordings-view-mode",Ds)},[Ds]);const[oi,Zl]=u.useState(()=>{const F=new Date;return F.setHours(0,0,0,0),F}),[al,Zc]=u.useState(!1),[il,Jl]=u.useState(!1),{data:Uo=[],isLoading:Cc}=ze({queryKey:["/api/multi-live-view/sites-cameras"],staleTime:0}),Ti=u.useMemo(()=>Uo.map(F=>F.siteId),[Uo]),{data:oa={}}=ze({queryKey:["multi-perms",Ti.join(",")],queryFn:async()=>{const F={};return await Promise.all(Ti.map(async ve=>{try{const Te=await fetch(`/api/sites/${ve}/my-permissions`,{credentials:"include"});Te.ok&&(F[ve]=await Te.json())}catch{}})),F},enabled:Ti.length>0,staleTime:6e4}),ja=u.useMemo(()=>Uo.map(F=>{const ve=oa[F.siteId];return!ve||ve.isExempt||!ve.restrictedCameras?.length?F:{...F,cameras:F.cameras.filter(Te=>!ve.restrictedCameras.includes(Te.name))}}),[Uo,oa]),Tr=u.useMemo(()=>[...new Set(i.map(F=>F.siteId))],[i]),zo=Tr[0]||"",ha=u.useRef(null);u.useEffect(()=>{const F=S,ve=F?null:ee,Te=F?.siteId??ve?.siteId??zo,ht=F?.camera??ve?.cameraName,kt=F?.id??ve?.id;if(!kt||!ht||!Te){ha.current?.clear(),ha.current=null;return}const us=F?"local":"cloud",ts=0;ha.current?.clear();const is=lC({category:"playback",siteId:Te,camera:ht,eventId:String(kt),source:us,playbackTime:ts});ha.current=is;const js=F?q.current:ge.current,ms=()=>is.update({category:"playback",siteId:Te,camera:ht,eventId:String(kt),source:us,playbackTime:js?.currentTime??ts});return js?.addEventListener("timeupdate",ms),js?.addEventListener("play",ms),()=>{js?.removeEventListener("timeupdate",ms),js?.removeEventListener("play",ms),is.clear(),ha.current===is&&(ha.current=null)}},[S?.id,ee?.id,zo]);const Jc=Ix({queries:Tr.map(F=>({queryKey:["/api/sites",F,"record-options"],queryFn:async()=>{const ve=await fetch(`/api/sites/${F}/record-options`,{credentials:"include"});return ve.ok?ve.json():{preCaptureSec:5,postCaptureSec:5}},enabled:!!F,staleTime:6e4}))}),ol={};Tr.forEach((F,ve)=>{const Te=Jc[ve]?.data;Te&&(ol[F]=Te)});const zn=Ix({queries:Tr.map(F=>({queryKey:["/api/sites",F,"recording-days"],queryFn:async()=>{const ve=await fetch(`/api/sites/${F}/recording-days`,{credentials:"include"});return ve.ok?ve.json():{localDays:[],cloudDays:[]}},enabled:!!F&&Ds==="classic",staleTime:5*6e4}))}),ll=zn.map(F=>F.data?`${F.data.localDays.length}:${F.data.cloudDays.length}`:"-").join("|"),{localRecordingDaysSet:yn,cloudRecordingDaysSet:cl}=u.useMemo(()=>{const F=new Set,ve=new Set;for(const Te of zn){for(const ht of Te.data?.localDays??[])F.add(ht);for(const ht of Te.data?.cloudDays??[])ve.add(ht)}return{localRecordingDaysSet:F,cloudRecordingDaysSet:ve}},[ll,Tr]),ko=Ix({queries:Tr.map(F=>({queryKey:["/api/sites",F,"ai-plus","status"],queryFn:()=>fetch(`/api/sites/${F}/ai-plus/status`).then(ve=>ve.json()),enabled:!!F,staleTime:30*1e3,refetchOnWindowFocus:!0}))}),dl=ko.map(F=>{const ve=F.data;return ve?`${ve.aiPlusEnabled?1:0}:${ve.hasSubscription?1:0}:${ve.dailyUsed??0}:${ve.dailyLimit??0}:${ve.dailyRemaining??0}`:"none"}).join("|"),Cl=u.useMemo(()=>{const F={};return Tr.forEach((ve,Te)=>{const ht=ko[Te]?.data;ht&&(F[ve]=ht)}),F},[Tr,dl]),Ho=Cl[zo],Ha=(Ho?.aiPlusEnabled??!1)&&(Ho?.hasSubscription??!1),Ai=Xt&&Ha,Bs=u.useMemo(()=>Tr.map(F=>{const ve=Cl[F],Te=Uo.find(is=>is.siteId===F)?.siteName||i.find(is=>is.siteId===F)?.siteName||F,ht=ve?.dailyLimit??0,kt=ve?.dailyUsed??0,us=ve?.dailyRemaining??0,ts=(ve?.aiPlusEnabled??!1)&&(ve?.hasSubscription??!1)&&ht>0&&us<=0;return{siteId:F,siteName:Te,status:ve,limit:ht,used:kt,remaining:us,limitReached:ts}}),[Tr,Cl,Uo,i]),ti=Bs.some(F=>F.limitReached),ec=Bs.length>0&&Bs.every(F=>F.limitReached),uo=Bs.filter(F=>F.status&&F.limit>0&&F.used/F.limit>=.75),Na=u.useMemo(()=>i.map(F=>F.cameraName),[i]),La=u.useMemo(()=>{const F=new Map;for(const ve of i)F.set(ve.cameraName,ve.displayName),F.set(`${ve.siteId}:${ve.cameraName}`,`${ve.siteName} - ${ve.displayName}`);return F},[i]),kc=["red","orange","brown","yellow","green","blue","purple","pink","black","white"],_c={red:"#ef4444",orange:"#f97316",brown:"#92400e",yellow:"#eab308",green:"#22c55e",blue:"#3b82f6",purple:"#a85
5565f7",pink:"#ec4899",black:"#1a1a1a",white:"#f5f5f5"},tn={black:["black","dark gray"],white:["white","light gray"],blue:["blue","cyan"]},qo=Dr.data?.aiColorThreshold??15,Hn=u.useMemo(()=>new Map(ja.map(F=>[F.siteId,F.edgeDeviceId||""])),[ja]),mo=u.useMemo(()=>i.some(F=>ja.find(ve=>ve.siteId===F.siteId)?.colorMatchingEnabled),[i,ja]),{data:qn}=ze({queryKey:["multi-cloud-prefs",Tr],queryFn:async()=>{const F=await Promise.all(Tr.map(async Te=>{const ht=await fetch(`/api/sites/${Te}/cloud-preferences`,{credentials:"include"});if(!ht.ok)return{siteId:Te,hideLocal:!1};const kt=await ht.json();return{siteId:Te,hideLocal:kt.hideLocalRecordings??!1}})),ve={};return F.forEach(Te=>{ve[Te.siteId]=Te.hideLocal}),ve},enabled:Tr.length>0,staleTime:3e4}),{data:_o}=ze({queryKey:["/api/user/role"],enabled:!!e,staleTime:6e4}),tm=_o?.role==="superadmin",Pd=Tr.length>0&&Tr.every(F=>{const ve=qn?.[F]??!1,Te=tm&&typeof window<"u"&&localStorage.getItem(`superadmin_showlocal_${F}`)==="true";return ve&&!Te});u.useEffect(()=>{Pd&&n==="local"&&a("cloud")},[Pd,Tr.join(",")]);const wi=u.useRef({vs:()=>{},ts:()=>{}}),tc=u.useCallback(F=>{wi.current.vs(),wi.current.ts();const ve=new Date,Te=new Date(ve.getTime()-F*60*60*1e3);g(Te),b(ve),h(F),Zi()},[]),ul=ze({queryKey:["multi-local-recordings",Tr,Na.join(","),l,Lr,p,v,n,Ds],queryFn:async()=>({events:(await Promise.all(Tr.map(async Te=>{const ht=i.filter(ms=>ms.siteId===Te).map(ms=>ms.cameraName),kt=new URLSearchParams;kt.set("cameras",ht.join(",")),l!=="all"&&kt.set("severity",l),Lr.length>0&&kt.set("labels",Lr.join(",")),p&&kt.set("after",String(Math.floor(p.getTime()/1e3))),v&&kt.set("before",String(Math.floor(v.getTime()/1e3))),kt.set("limit",String(hBe));const us=`/api/local-recordings/${Te}/events?${kt.toString()}`,ts=await pC("local",`events list site=${Te}`,us,{credentials:"include"});if(!ts.ok)return $o("local",`events list site=${Te} failed: HTTP ${ts.status}`),[];const is=await ts.json();$o("local",`events list site=${Te} ok: ${is?.events?.length??0} events`);const js=i.find(ms=>ms.siteId===Te)?.siteName||"";return(is.events||[]).map(ms=>({...ms,siteId:Te,siteName:js}))}))).flat().sort((Te,ht)=>ht.start_time-Te.start_time)}),enabled:i.length>0&&n==="local"&&Ds==="events"}),Pc=ze({queryKey:["multi-local-recordings-timeline",Tr,l,Lr,oi.toISOString(),ra.join(",")],queryFn:async()=>{const F=new Date(oi);F.setHours(0,0,0,0);const ve=new Date(oi);ve.setHours(23,59,59,999);const Te=new Date;return{events:(await Promise.all(Tr.map(async kt=>{const us=ra.filter(gs=>gs.startsWith(`${kt}:`)).map(gs=>gs.split(":")[1]),ts=new URLSearchParams;l!=="all"&&ts.set("severity",l),Lr.length>0&&ts.set("labels",Lr.join(",")),us.length>0&&ts.set("cameras",us.join(",")),ts.set("after",String(Math.floor(F.getTime()/1e3))),ts.set("before",String(Math.floor(Math.min(ve.getTime(),Te.getTime())/1e3))),ts.set("limit","5000");const is=await fetch(`/api/local-recordings/${kt}/events?${ts.toString()}`,{credentials:"include"});if(!is.ok)return[];const js=await is.json(),ms=i.find(gs=>gs.siteId===kt)?.siteName||"";return(js.events||[]).map(gs=>({...gs,siteId:kt,siteName:ms}))}))).flat()}},enabled:i.length>0&&n==="local"&&(Ds==="timeline"||Ds==="classic")&&ra.length>0,staleTime:300*1e3,gcTime:600*1e3}),_u=["multi-cloud-recordings",Tr.join(","),Na.join(","),Lr.join(","),Nc,l,p?.toISOString()??null,v?.toISOString()??null,lo,co],Ec=ze({queryKey:_u,queryFn:async({queryKey:F})=>{const[,ve,Te,ht,kt,us,ts,is,js,ms]=F,gs=new URLSearchParams;ve&&gs.set("siteIds",String(ve)),Te&&gs.set("cameraNames",String(Te)),ht&&(gs.set("labels",String(ht)),kt&&gs.set("matchAll","true")),us==="alert"?gs.set("excludeMotion","true"):us==="detection"&&gs.set("onlyMotion","true"),ts&&gs.set("startDate",String(ts)),is&&gs.set("endDate",String(is)),gs.set("limit",String(qv)),gs.set("offset",String(Number(js)*qv)),gs.set("sort",String(ms));const Ar=`/api/cloud-recordings?${gs.toString()}`,si=await pC("cloud","cloud list (multi)",Ar,{credentials:"include"});if(!si.ok)throw $o("cloud",`cloud list (multi) failed: HTTP ${si.status}`,{url:Ar}),new Error("Failed to fetch cloud recordings");const Ka=await si.json();$o("cloud",`cloud list (multi) ok: ${Ka?.recordings?.length??0} recordings (total=${Ka?.total??"?"})`);const Wr=(Ka.recordings||[]).map(dn=>{const Yo=i.find(Ji=>Ji.siteId===dn.siteId);return{...dn,siteName:Yo?.siteName||dn.siteName||""}});return{recordings:Wr,total:Ka.total||Wr.length}},enabled:n==="cloud"&&i.length>0&&Ds==="events",staleTime:3e4}),Tc=u.useMemo(()=>ra.map(F=>
556F.split(":")[1]).filter(Boolean),[ra]),Ea=ze({queryKey:["multi-cloud-recordings-timeline",Tr.join(","),ra.join(","),l,oi.toISOString()],queryFn:async()=>{const F=new URLSearchParams;Tr.length>0&&F.set("siteIds",Tr.join(",")),Tc.length>0&&F.set("cameraNames",Tc.join(",")),l==="alert"?F.set("excludeMotion","true"):l==="detection"&&F.set("onlyMotion","true");const ve=new Date(oi);ve.setHours(0,0,0,0);const Te=new Date(oi);Te.setHours(23,59,59,999),F.set("startDate",ve.toISOString()),F.set("endDate",Te.toISOString()),F.set("noLimit","true"),F.set("lite","true");const ht=await fetch(`/api/cloud-recordings?${F.toString()}`,{credentials:"include"});if(!ht.ok)throw new Error("Failed to fetch cloud timeline recordings");const us=((await ht.json()).recordings||[]).map(ts=>{const is=i.find(js=>js.siteId===ts.siteId);return{...ts,siteName:is?.siteName||""}});return{recordings:us,total:us.length}},enabled:n==="cloud"&&i.length>0&&(Ds==="timeline"||Ds==="classic")&&ra.length>0}),Ed=ze({queryKey:["multi-local-labels",Tr],queryFn:async()=>{const F=await Promise.all(Tr.map(async Te=>{const ht=await fetch(`/api/local-recordings/${Te}/labels`,{credentials:"include"});return ht.ok?(await ht.json()).labels||[]:["motion"]}));return{labels:[...new Set(F.flat())].sort()}},enabled:i.length>0,staleTime:6e4}).data?.labels||[],Ah=ze({queryKey:["multi-cloud-labels"],queryFn:async()=>{const F=await fetch("/api/cloud-recording-labels",{credentials:"include"});return F.ok?F.json():{labels:[]}},enabled:i.length>0}).data?.labels||[],td=ul.data?.events||[],nn=(F=>Lr.length===0?F:F.filter(ve=>{const Te=ve.objects&&ve.objects.length>0?ve.objects:ve.label==="motion"?["motion"]:[];return Te.length===0?!1:Lr.some(ht=>Te.includes(ht))}))(td),Um=Pc.data?.events||[],Pu=ra.length>0?Um.filter(F=>ra.includes(`${F.siteId}:${F.camera}`)):Um,sd=Lr.length===0?Pu:Pu.filter(F=>{const ve=F.objects&&F.objects.length>0?F.objects:F.label==="motion"?["motion"]:[];return ve.length===0?!1:Lr.some(Te=>ve.includes(Te))}),sc=Ea.data?.recordings||[],Wo=u.useMemo(()=>c0(sc),[sc]),Mh=sc.filter(F=>!Wo.has(F.id)),Td=ra.length>0?Mh.filter(F=>ra.includes(`${F.siteId}:${F.cameraName}`)):Mh,qa=Lr.length===0?Td:Td.filter(F=>{if(!F.label)return!1;const ve=F.label.split(",").map(Te=>Te.trim().toLowerCase());return Lr.some(Te=>ve.includes(Te.toLowerCase()))}),Qs=u.useCallback(async F=>{const ve=Ds!=="events"?sd:nn;if(!F||ve.length===0)return;Ln.current&&Ln.current.abort();const Te=new AbortController;Ln.current=Te,gt(F),br(!0),xn(!0),Pi(new Map),ii([]),Ua({done:0,total:ve.length});const ht=new Map,kt=[],us=10,ts=tn[F]??[F];for(let is=0;is<ve.length;is+=us){if(Te.signal.aborted)return;const js=ve.slice(is,is+us);if(await Promise.all(js.map(async ms=>
556{if(Te.signal.aborted)return;const gs=Hn.get(ms.siteId||"");if(!gs)return;const Ar=ms.detections?.[0],si=new URLSearchParams;Ar&&si.set("detectionId",Ar);try{const Ka=await fetch(`/api/edge-devices/${gs}/event-colors/${ms.id}?${si}`,{credentials:"include",signal:Te.signal});if(!Ka.ok)return;const Wr=await Ka.json();Wr.colors&&Wr.colors.some(dn=>ts.includes(dn.color)&&dn.percentage>=qo)&&(ht.set(ms.id,Wr.colors),kt.push(ms))}catch{}})),Te.signal.aborted)return;Pi(new Map(ht)),ii([...kt]),Ua({done:Math.min(is+us,ve.length),total:ve.length})}Te.signal.aborted||br(!1)},[nn,sd,Ds,Hn,qo]),rc=()=>{Ln.current&&Ln.current.abort(),br(!1)},Eu=()=>{Ln.current&&Ln.current.abort(),gt(""),xn(!1),br(!1),Pi(new Map),ii([]),Ua({done:0,total:0})},Po=u.useCallback(async F=>{if(!F)return;ur.current&&ur.current.abort();const ve=new AbortController;ur.current=ve,Hr(F),Rt(!0),Ht(!0),mn(new Map),Sn([]),Os({done:0,total:0});const Te=new Map,ht=[],kt=10,us=tn[F]??[F];if(Ds!=="events"){const ts=qa;if(ts.length===0){Rt(!1);return}Os({done:0,total:ts.length});for(let is=0;is<ts.length;is+=kt){if(ve.signal.aborted)return;const js=ts.slice(is,is+kt);if(await Promise.all(js.map(async ms=>
556{if(!ve.signal.aborted)try{const gs=await fetch(`/api/cloud-recordings/${ms.id}/colors`,{credentials:"include",signal:ve.signal});if(!gs.ok)return;const Ar=await gs.json();Ar.colors&&Ar.colors.some(si=>us.includes(si.color)&&si.percentage>=qo)&&(Te.set(String(ms.id),Ar.colors),ht.push(ms))}catch{}})),ve.signal.aborted)return;mn(new Map(Te)),Sn([...ht]),Os({done:Math.min(is+kt,ts.length),total:ts.length})}}else{let ts=0,is=0;for(;!ve.signal.aborted;){const js=new URLSearchParams;Tr.length>0&&js.set("siteIds",Tr.join(",")),Na.length>0&&js.set("cameraNames",Na.join(",")),Lr.length>0&&js.set("labels",Lr.join(",")),l==="alert"&&js.set("excludeMotion","true"),p&&js.set("startDate",p.toISOString()),v&&js.set("endDate",v.toISOString()),js.set("limit",String(qv)),js.set("offset",String(is));let ms=[];try{const gs=await fetch(`/api/cloud-recordings?${js.toString()}`,{credentials:"include",signal:ve.signal});if(!gs.ok)break;ms=(await gs.json()).recordings||[]}catch{break}if(ve.signal.aborted||ms.length===0)break;for(let gs=0;gs<ms.length;gs+=kt){if(ve.signal.aborted)return;const Ar=ms.slice(gs,gs+kt);if(await Promise.all(Ar.map(async si=>{if(!ve.signal.aborted)try{const Ka=await fetch(`/api/cloud-recordings/${si.id}/colors`,{credentials:"include",signal:ve.signal});if(!Ka.ok)return;const Wr=await Ka.json();Wr.colors&&Wr.colors.some(dn=>us.includes(dn.color)&&dn.percentage>=qo)&&(Te.set(String(si.id),Wr.colors),ht.push(si))}catch{}})),ve.signal.aborted)return;ts+=Ar.length,mn(new Map(Te)),Sn([...ht]),Os({done:ts,total:ts})}if(ms.length<qv)break;is+=qv}}ve.signal.aborted||Rt(!1)},[Ds,qa,Tr,Na,Lr,Nc,l,p,v,qo]),la=()=>{ur.current&&ur.current.abort(),Rt(!1)},Rh=()=>{ur.current&&ur.current.abort(),Hr(""),Ht(!1),Rt(!1),mn(new Map),Sn([]),Os({done:0,total:0})},ml=u.useMemo(()=>!fr||!Ut?nn:Qn,[nn,fr,Ut,Qn]),rd=u.useMemo(()=>co==="asc"?[...ml].sort((F,ve)=>F.start_time-ve.start_time):ml,[ml,co]),Mc=rd.slice(z*V4,(z+1)*V4),Mi=rd.length>(z+1)*V4,nc=z>0;u.useEffect(()=>{za&&na(rd)},[rd,za]);const kl=za?Ei:Mc,Ri=Ec.data?.recordings||[],ho=u.useMemo(()=>!At||!Ir?Ri:hr,[Ri,At,Ir,hr]),ac=ho,tr=Ec.data?.total||0,_l=Math.ceil(tr/qv),nd=Pc.data?.events||[],hl=ra.length>0?nd.filter(F=>ra.includes(`${F.siteId}:${F.camera}`)):nd,Rc=Lr.length===0?hl:hl.filter(F=>{const ve=F.objects&&F.objects.length>0?F.objects:F.label==="motion"?["motion"]:[];return ve.length===0?!1:Lr.some(Te=>ve.includes(Te))}),sm=u.useMemo(()=>!fr||!Ut?null:new Set(Qn.map(F=>F.id)),[fr,Ut,Qn]),Eo=sm?Rc.filter(F=>sm.has(F.id)):Rc,pl=u.useMemo(()=>Eo.map(F=>{const ve=F.start_time*1e3,Te=(F.end_time||F.start_time+10)*1e3,ht=F.objects&&F.objects.length>0?F.objects:F.label==="motion"?["motion"]:[];return{id:F.id,camera:`${F.siteId}:${F.camera}`,startMs:ve,endMs:Te,labels:ht,source:"local",originalEvent:F,siteId:F.siteId}}),[Eo]),U=sc.filter(F=>!Wo.has(F.id)),_e=ra.length>0?U.filter(F=>ra.includes(`${F.siteId}:${F.cameraName}`)):U,qt=Lr.length===0?_e:_e.filter(F=>{if(!F.label)return!1;const ve=F.label.split(",").map(Te=>Te.trim().toLowerCase());return Lr.some(Te=>ve.includes(Te.toLowerCase()))}),Zt=u.useMemo(()=>!At||!Ir?null:new Set(hr.map(F=>String(F.id))),[At,Ir,hr]),Rs=Zt?qt.filter(F=>Zt.has(String(F.id))):qt,ir=u.useMemo(()=>Rs.map(F=>({id:String(F.id),camera:`${F.siteId}:${F.cameraName}`,startMs:new Date(F.startTime).getTime(),endMs:F.endTime?new Date(F.endTime).getTime():new Date(F.startTime).getTime()+3e4,labels:F.label?F.label.split(",").map(ve=>ve.trim()):[],source:"cloud",thumbnailUrl:F.thumbnailPath||null,originalRecording:F,siteId:F.siteId})),[Rs]),Vn=u.useMemo(()=>{const F=new Map;for(const ve of i)F.set(`${ve.siteId}:${ve.cameraName}`,`${ve.siteName} - ${ve.displayName}`);return F},[i]),Ns=u.useMemo(()=>{const F=new Map;for(const ve of i)F.set(`${ve.siteId}:${ve.cameraName}`,ve.displayName);return F},[i]),or=u.useMemo(()=>{const F=new Map;for(const ve of i)F.set(ve.siteId,ve.siteName);return F},[i]),os=u.useCallback(F=>{F.source==="local"&&F.originalEvent?(_(F.originalEvent),M(null),O(null)):F.source==="cloud"&&F.originalRecording&&(ue(!1),Q(F.originalRecording))},[]),nt=u.useCallback((F,ve)=>{if(Ds==="timeline"||Ds==="classic"){const us=n==="local"?pl:[],ts=`${F.siteId}:${F.camera}`,is=us.filter(gs=>gs.camera===ts&&gs.originalEvent).sort((gs,Ar)=>gs.startMs-Ar.startMs),js=is.findIndex(gs=>gs.originalEvent?.id===F.id);return js<0?null:is[js+ve]?.originalEvent||null}const Te=nn.filter(us=>us.camera===F.camera&&(us.siteId||"")===(F.siteId||"")).sort((us,ts)=>ts.start_time-us.start_time),ht=Te.findIndex(us=>us.id===F.id);if(ht<0)return null;
556const kt=ht-ve;return Te[kt]||null},[n,Ds,pl,nn]),tt=u.useCallback((F,ve)=>{if(Ds==="timeline"||Ds==="classic"){const us=n==="cloud"?ir:[],ts=`${F.siteId}:${F.cameraName}`,is=us.filter(gs=>gs.camera===ts&&gs.originalRecording).sort((gs,Ar)=>gs.startMs-Ar.startMs),js=is.findIndex(gs=>gs.originalRecording?.id===F.id);return js<0?null:is[js+ve]?.originalRecording||null}const Te=ho.filter(us=>us.cameraName===F.cameraName&&(us.siteId||"")===(F.siteId||"")).sort((us,ts)=>new Date(ts.startTime).getTime()-new Date(us.startTime).getTime()),ht=Te.findIndex(us=>us.id===F.id);if(ht<0)return null;const kt=ht-ve;return Te[kt]||null},[n,Ds,ir,ho]),$t=u.useMemo(()=>{const F=new Map;for(const ve of td)F.set(ve.id,ve);for(const ve of nd)F.has(ve.id)||F.set(ve.id,ve);return Array.from(F.values())},[td,nd]),kr=u.useCallback(F=>{const ve=F.siteId||"",Te=$t.filter(ts=>(ts.siteId||"")===ve),ht=a9(F,Te);let kt=nt(F,1),us=0;for(;kt&&kt.start_time>ht.start&&kt.start_time<=ht.end&&us<500;)kt=nt(kt,1),us++;return kt},[nt,$t]),Wn=u.useCallback(F=>{const ve=kr(F);ve&&(_(ve),M(null),O(null),G(-1),Ol(null))},[kr]),zr=u.useCallback(F=>{const ve=tt(F,1);ve&&(ue(!1),Q(ve))},[tt]),$n=7200,Va=7200,Yi=720*60,[Ii,To]=u.useState(0),[Qi,Ls]=u.useState(0);u.useEffect(()=>{To(0),Ls(0)},[S?.id]);const Or=ze({queryKey:["multi-mini-timeline-local",S?.siteId,S?.camera,S?.start_time,Ii,Qi],queryFn:async()=>{if(!S||!S.siteId)return{events:[]};const F=S.start_time-($n+Ii),ve=S.start_time+($n+Qi),Te=new URLSearchParams;Te.set("cameras",S.camera),Te.set("after",String(F)),Te.set("before",String(ve)),Te.set("limit","500");const ht=await fetch(`/api/local-recordings/${S.siteId}/events?${Te.toString()}`,{credentials:"include"});if(!ht.ok)return{events:[]};const kt=await ht.json(),us=i.find(ts=>ts.siteId===S.siteId)?.siteName||"";return{events:(kt.events||[]).map(ts=>({...ts,siteId:S.siteId,siteName:us}))}},enabled:!!S&&!!S.siteId,staleTime:300*1e3,placeholderData:SS}),Pl=S?(S.start_time-($n+Ii))*1e3:void 0,Oi=S?(S.start_time+($n+Qi))*1e3:void 0,[ad,ji]=u.useState(null),Wa=u.useCallback(F=>{if(F.direction==="before"){if(Ii>=Yi)return;ji("before"),To(ve=>Math.min(ve+Va,Yi))}else{if(Qi>=Yi)return;ji("after"),Ls(ve=>Math.min(ve+Va,Yi))}},[Ii,Qi,Yi,Va]);u.useEffect(()=>{Or.isFetching||ji(null)},[Or.isFetching]);const Ic=Ii>=Yi,Tu=Qi>=Yi,id=ad==="before"&&Or.isFetching,El=ad==="after"&&Or.isFetching,Di=u.useMemo(()=>{if(!S)return[];const F=Or.data?.events||[],ve=new Set,Te=[];ve.add(S.id),Te.push(S);for(const ts of F)ts.camera===S.camera&&ts.siteId===S.siteId&&!ve.has(ts.id)&&(ve.add(ts.id),Te.push(ts));const ht=1800;for(const ts of[nn,nd])for(const is of ts)is.camera===S.camera&&is.siteId===S.siteId&&!ve.has(is.id)&&is.start_time>=S.start_time-ht&&is.start_time<=S.start_time+ht&&(ve.add(is.id),Te.push(is));const kt=Dr.data?.timelineMotionColor||"#eab308",us=Dr.data?.timelineDetectionColor||"#3b82f6";return Te.map(ts=>{const is=ts.detections?.[0]?`/api/local-recordings/${ts.siteId}/thumbnail?detection=${encodeURIComponent(ts.detections[0])}`:`/api/local-recordings/${ts.siteId}/thumbnail?camera=${encodeURIComponent(ts.camera)}&time=${ts.start_time}`,js=ts.label==="motion"||(ts.objects?.length??0)===0&&ts.severity==="detection";return{id:ts.id,startMs:ts.start_time*1e3,endMs:(ts.end_time||ts.start_time+60)*1e3,color:js?kt:us,label:ts.objects?.join(", ")||ts.label||void 0,thumbnailUrl:is}})},[Or.data,nn,nd,S,Dr.data?.timelineMotionColor,Dr.data?.timelineDetectionColor]),Xi=7200*1e3,tu=7200*1e3,bn=720*60*1e3,[Tl,od]=u.useState(0),[ld,Al]=u.useState(0);u.useEffect(()=>{od(0),Al(0)},[ee?.id]);const Ni=ze({queryKey:["multi-mini-timeline-cloud",ee?.siteId,ee?.cameraName,ee?.startTime,Tl,ld],queryFn:async()=>{if(!ee)return{recordings:[],total:0};const F=new Date(ee.startTime).getTime(),ve=new URLSearchParams;ee.siteId&&ve.set("siteId",ee.siteId),ve.set("cameraNames",ee.cameraName),ve.set("startDate",new Date(F-(Xi+Tl)).toISOString()),ve.set("endDate",new Date(F+(Xi+ld)).toISOString()),ve.set("noLimit","true");const Te=await fetch(`/api/cloud-recordings?${ve.toString()}`,{credentials:"include"});return Te.ok?Te.json():{recordings:[],total:0}},enabled:!!ee,staleTime:300*1e3,placeholderData:SS}),rm=ee?new Date(ee.startTime).getTime()-(Xi+Tl):void 0,Ko=ee?new Date(ee.startTime).getTime()+(Xi+ld):void 0,[Ad,Ml]=u.useState(null),qg=u.useCallback(F=>{if(F.direction==="before"){if(Tl>=bn)return;Ml("before"),od(ve=>
556Math.min(ve+tu,bn))}else{if(ld>=bn)return;Ml("after"),Al(ve=>Math.min(ve+tu,bn))}},[Tl,ld,bn,tu]);u.useEffect(()=>{Ni.isFetching||Ml(null)},[Ni.isFetching]);const zm=Tl>=bn,Au=ld>=bn,Ih=Ad==="before"&&Ni.isFetching,cd=Ad==="after"&&Ni.isFetching,Oh=u.useMemo(()=>{if(!ee)return[];const F=c0([...Ni.data?.recordings||[],...ho,...sc]),ve=ms=>F.has(ms.id),Te=(Ni.data?.recordings||[]).filter(ms=>!ve(ms)),ht=new Set,kt=[];ht.add(ee.id),kt.push(ee);for(const ms of Te)ms.cameraName===ee.cameraName&&(!ee.siteId||ms.siteId===ee.siteId)&&!ht.has(ms.id)&&(ht.add(ms.id),kt.push(ms));const us=new Date(ee.startTime).getTime(),ts=1800*1e3;for(const ms of[ho,U])for(const gs of ms)if(!ve(gs)&&gs.cameraName===ee.cameraName&&(!ee.siteId||gs.siteId===ee.siteId)&&!ht.has(gs.id)){const Ar=new Date(gs.startTime).getTime();Ar>=us-ts&&Ar<=us+ts&&(ht.add(gs.id),kt.push(gs))}const is=Dr.data?.timelineMotionColor||"#eab308",js=Dr.data?.timelineDetectionColor||"#3b82f6";return kt.map(ms=>{const gs=ms.label?.includes("motion")&&!ms.label?.includes(",");return{id:ms.id,startMs:new Date(ms.startTime).getTime(),endMs:ms.endTime?new Date(ms.endTime).getTime():new Date(ms.startTime).getTime()+6e4,color:gs?is:js,label:ms.label||void 0,thumbnailUrl:ms.thumbnailPath||null}})},[Ni.data,ho,U,ee,Dr.data?.timelineMotionColor,Dr.data?.timelineDetectionColor]),Zi=()=>{Z(0),Cn(0),Vr([]),na([]),Da(!1)},Hm=()=>{Mi&&(Z(F=>F+1),window.scrollTo({top:0,behavior:"smooth"}))},Mu=()=>{z>0&&(Z(F=>F-1),window.scrollTo({top:0,behavior:"smooth"}))};function Oc(F){return F?new Date(F*1e3).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):""}function nm(F){return F?new Date(F*1e3).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function yp(F){return F?new Date(F).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):""}function Ru(F){return F?new Date(F).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}const su=F=>{const ve=F.siteId||"",Te=F.detections?.[0];return Te?`/api/local-recordings/${ve}/thumbnail?detection=${encodeURIComponent(Te)}`:F.camera&&F.start_time?`/api/local-recordings/${ve}/thumbnail?camera=${encodeURIComponent(F.camera)}&time=${F.start_time}`:""},po=F=>{const ve=F.siteId||"",Te=new URLSearchParams,ht=F.detections?.[0];return ht&&Te.set("detection",ht),Te.set("reviewId",F.id),Te.set("camera",F.camera),Te.set("start",String(F.start_time)),Te.set("end",String(F.end_time||F.start_time+30)),qr&&Te.set("vt",qr),`/api/local-recordings/${ve}/clip.mp4?${Te.toString()}`},Dh=F=>{const ve=F.siteId||"",Te=ol[ve],ht=Math.max(0,Math.min(60,Te?.preCaptureSec??15)),kt=Math.max(0,Math.min(60,Te?.postCaptureSec??15)),us=$t.filter(gs=>(gs.siteId||"")===ve),ts=a9(F,us),is=ts.start-ht,js=ts.end+kt,ms=new URLSearchParams;return qr&&ms.set("vt",qr),`/api/local-recordings/${ve}/vod/${encodeURIComponent(F.camera)}/start/${is}/end/${js}/index.m3u8${qr?`?${ms.toString()}`:""}`},Rl=u.useRef(null);u.useEffect(()=>{if(!en||!ee?.id||le)return;const F=tt(ee,1);!F?.id||F.id===Rl.current||(Rl.current=F.id,(async()=>{try{await fetch(`/api/cloud-recordings/${F.id}/clip.mp4${qr?`?vt=${qr}`:""}`,{credentials:"include",priority:"low",headers:{Range:"bytes=0-1048575"}})}catch{}})())},[en,ee,le,tt,qr]);const Il=u.useRef(null);u.useEffect(()=>{if(!en||!S||T)return;const F=kr(S);!F?.id||F.id===Il.current||(Il.current=F.id,(async()=>{try{await fetch(Dh(F),{credentials:"include",priority:"low"})}catch{}})())},[en,S,T,kr]);const Go=S?.detections?.join(",")||"",[fl,Ol]=u.useState(null),gl=ze({queryKey:["/api/local-recordings",S?.siteId,"event-detections",S?.id,Go],queryFn:async()=>{if(!Go||!S?.siteId)return{detections:[]};const F=await fetch(`/api/local-recordings/${S.siteId}/event-detections?ids=${encodeURIComponent(Go)}`,{credentials:"include"});if(!F.ok)throw new Error("Failed to fetch detections");return F.json()},enabled:!!S&&!!S.siteId&&Go.length>0&&!T,staleTime:6e4}).data?.detections||[],Dc=F=>{const ve=F.toLowerCase();return ve==="person"?{border:"#22c55e",glow:"rgba(34,197,94,0.5)",bg:"#22c55e"}:ve==="car"||ve==="vehicle"||ve==="truck"||ve==="motorcycle"||ve==="bicycle"||ve==="bus"?{border:"#3b82f6",glow:"rgba(59,130,246,0.5)",bg:"#3b82f6"}:{border:"#ef4444",glow:"rgba(239,68,68,0.5)",bg:"#ef4444"}},Lc=u.useCallback(()=>{const F=q.current;if(!F||gl.length===0||!S)return;const ve=Math.floor(S.start_time)-5,Te=K+1>=gl.length?0:K+1,ht=gl[Te],us=ht.start_time-ve,ts=F.duration||1/0;F.currentTime=Math.max(0,Math.min(us,ts-.5)),F.pause(),G(Te),Ol(ht.sub_label||ht.label)},[gl,K,S]),Iu=u.useCallback(F=>{J(F),Ae(!1)},[]),Ou=u.useCallback(async(F=!1)=>
556{if(!Be)return;const ve=!!ee&&!S;if(!S&&!ee)return;const Te=i.map(js=>js.siteId).filter((js,ms,gs)=>gs.indexOf(js)===ms);if(Te.length===0)return;const ht=S?.start_time||(ee?typeof ee.startTime=="number"?ee.startTime:new Date(ee.startTime).getTime()/1e3:null),kt=S?.camera||ee?.cameraName||null;if(!ht)return;const ts=Bs.filter(js=>(js.status?.aiPlusEnabled??!1)&&(js.status?.hasSubscription??!1)&&js.limit>0).some(js=>js.limit>0&&(js.limit-js.remaining)/js.limit>=.75);if(!F&&ts){const ms=Te.map(wn=>{const Li=ja.find(fi=>fi.siteId===wn);return{siteId:wn,total:Li?.cameras.length??0}}).reduce((wn,Li)=>wn+Li.total,0),gs=Re==="current"&&ms>0?1/ms:1,Ar=Re==="current"?"current camera":`all cameras across ${Te.length} site${Te.length===1?"":"s"}`,si=dt*2,Ka=Kte(ve?"cloud":"local",1,gs,si),Wr=vC(Ka),dn=Bs.filter(wn=>(wn.status?.aiPlusEnabled??!1)&&(wn.status?.hasSubscription??!1)&&wn.limit>0),Yo=dn.filter(wn=>wn.limit>0&&(wn.limit-wn.remaining)/wn.limit>=.75),Ji=Math.max(1,Math.min(5,Te.length)),pi=Ka*Ji,Pr=Wr*Ji,am=dn.length>0?Math.min(...dn.map(wn=>wn.remaining)):0,Md=dn[0]?.limit??0;Lt({kind:"visual",estImages:pi,estRequests:Pr,remaining:am,dailyLimit:Md,exceeds:Yo.length>0,siteCount:Ji,tightSiteNames:Yo.map(wn=>wn.siteName),cameraScope:Ar,severityScope:`±${Math.round(dt/60)} min window · all severities`}),xr.current=()=>Ou(!0);return}Ft.current?.abort();const is=new AbortController;Ft.current=is,ye(!0),we(null),Ue(null),St({scored:0,total:0});try{const js={image:(Be||"").replace(/^data:[^,]*,/,""),siteIds:Te,after:ht-dt,before:ht+dt};(ve||Pd)&&(js.source="cloud"),Re==="current"&&kt&&(js.camera=kt);const ms=await fetch("/api/visual-search",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(js),signal:is.signal});if(!ms.ok){const Ar=await ms.text().catch(()=>"");let si="";try{si=JSON.parse(Ar)?.error||JSON.parse(Ar)?.message||""}catch{}const Ka=Ar.slice(0,200).replace(/\s+/g," ").trim(),Wr=si||Ka||"Search failed";throw console.error(`[VisualSearch] HTTP ${ms.status} ${ms.statusText} ct=${ms.headers.get("content-type")} body=${Ka}`),new Error(`(${ms.status}) ${Wr}`)}const gs=await ms.json();is.signal.aborted||(we(gs.matches||[]),Ue(gs.description||null))}catch(js){if(js.name==="AbortError")return;r({title:"Visual Search Failed",description:js.message,variant:"destructive"}),we(null)}finally{is.signal.aborted||(ye(!1),St(null)),Tr.forEach(js=>{Je.invalidateQueries({queryKey:["/api/sites",js,"ai-plus","status"]})})}},[Be,S,ee,i,Tr,dt,Re,r,Bs,ja]),Ta=u.useCallback(()=>{Ft.current?.abort(),Ft.current=null,Ae(!1),J(null),we(null),Ue(null),ye(!1),St(null)},[]),$c=u.useCallback(async(F=!1)=>{if(!Es.trim()||Tr.length===0)return;let ve,Te;if(Ds!=="events"){const is=new Date(oi);is.setHours(0,0,0,0);const js=new Date(oi);js.setHours(23,59,59,999),ve=Math.floor(is.getTime()/1e3),Te=Math.floor(js.getTime()/1e3)}else ve=p?Math.floor(p.getTime()/1e3):Math.floor(Date.now()/1e3)-7200,Te=Math.floor(v?v.getTime()/1e3:Date.now()/1e3);const ht=(Te-ve)/3600;if(ht>72){r({title:"Time range too large",description:"AI Search is limited to 72 hours or less. Please reduce your date range.",variant:"destructive"});return}const us=Bs.filter(is=>(is.status?.aiPlusEnabled??!1)&&(is.status?.hasSubscription??!1)&&is.limit>0).some(is=>is.limit>0&&(is.limit-is.remaining)/is.limit>=.75);if(!F&&us){const is=n==="cloud"?"cloud":"local",js=Tr.reduce((wn,Li)=>{const fi=ja.find(aa=>aa.siteId===Li);return wn+(fi?.cameras.length??0)},0),ms=i.length,gs=Gte({selectedCameras:ms,totalCameras:js,selectedSeverity:l,selectedLabels:Lr}),Ar=Wte(ht,is,1,gs),si=vC(Ar),Ka=Bs.filter(wn=>(wn.status?.aiPlusEnabled??!1)&&(wn.status?.hasSubscription??!1)&&wn.limit>0),Wr=Ka.filter(wn=>wn.limit>0&&(wn.limit-wn.remaining)/wn.limit>=.75),dn=Math.max(1,Math.min(5,Tr.length)),Yo=Ar*dn,Ji=si*dn,pi=Ka.length>0?Math.min(...Ka.map(wn=>wn.remaining)):0,Pr=Ka[0]?.limit??0,am=js>0&&ms<js?`${ms} of ${js} cameras`:`all ${js||ms} cameras`,Md=l!=="all"||Lr.length>0?[l!=="all"?`severity: ${l}`:null,Lr.length>0?`labels: ${Lr.join(", ")}`:null].filter(Boolean).join("; "):"any severity/label";Lt({kind:"text",estImages:Yo,estRequests:Ji,remaining:pi,dailyLimit:Pr,exceeds:Wr.length>0,siteCount:dn,tightSiteNames:Wr.map(wn=>wn.siteName),cameraScope:am,severityScope:Md}),xr.current=()=>$c(!0);return}De.current?.abort();const ts=new AbortController;De.current=ts,Dt(!0),He(null),Oe(Es.trim()),ns({scored:0,total:0}),jt.current?.clear(),jt.current=lC({category:"ai_search",searchTerm:Es.trim(),searchSiteIds:Tr,source:n==="cloud"?"cloud":"local"});try{const is={};for(const Ar of i)is[Ar.siteId]||(is[Ar.siteId]=[]),is[Ar.siteId].push(Ar.cameraName);const js={query:Es.trim(),siteIds:Tr,after:ve,before:Te,cameraBySite:is};n==="cloud"&&(js.source="cloud");const ms=await fetch("/api/ai-text-search",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(js),signal:ts.signal});if(!ms.ok){const Ar=await ms.json().catch(()=>({error:"Search failed"}));throw new Error(Ar.error||"Search failed")}const gs=await ms.json();ts.signal.aborted||He(gs.matches||[])}catch(is){if(is.name==="AbortError")return;const js=is?.message||"Text search failed";r({title:"Search failed",description:js,variant:"destructive"}),He(null),Oe(null)}finally{ts.signal.aborted||(Dt(!1),ns(null)),Tr.forEach(is=>
556{Je.invalidateQueries({queryKey:["/api/sites",is,"ai-plus","status"]})})}},[Es,Tr,i,p,v,Ds,oi,n,r,Bs,ja,l,Lr]),fo=u.useCallback(()=>{De.current?.abort(),De.current=null,jt.current?.clear(),jt.current=null,Ce&&Ze("POST","/api/ai-text-search/cancel",{}).catch(()=>{}),Ge(""),He(null),Oe(null),Dt(!1),ns(null)},[Ce]);u.useEffect(()=>{if(!Qe)return;let F=!1;const ve=async()=>{try{const ht=await fetch("/api/ai-search/progress?type=visual",{credentials:"include"});if(!ht.ok||F)return;const kt=await ht.json();if(F)return;(kt.status==="running"||kt.status==="done")&&(St({scored:kt.scored||0,total:kt.total||0}),Array.isArray(kt.matches)&&kt.matches.length>0&&we(kt.matches),kt.description&&Ue(kt.description))}catch{}};ve();const Te=window.setInterval(ve,800);return()=>{F=!0,window.clearInterval(Te)}},[Qe]),u.useEffect(()=>{if(!Ce)return;let F=!1;const ve=async()=>{try{const ht=await fetch("/api/ai-search/progress?type=text",{credentials:"include"});if(!ht.ok||F)return;const kt=await ht.json();if(F)return;(kt.status==="running"||kt.status==="done")&&(ns({scored:kt.scored||0,total:kt.total||0}),Array.isArray(kt.matches)&&kt.matches.length>0&&He(kt.matches))}catch{}};ve();const Te=window.setInterval(ve,800);return()=>{F=!0,window.clearInterval(Te)}},[Ce]),wi.current={vs:Ta,ts:fo};const Zn=u.useRef("");u.useEffect(()=>{const F=Tr.join(",");F!==Zn.current&&(Zn.current&&(wi.current.vs(),wi.current.ts()),Zn.current=F)},[Tr]);const hn=u.useRef("");u.useEffect(()=>{const F=i.map(ve=>`${ve.siteId}:${ve.cameraName}`).join(",");F!==hn.current&&(hn.current&&(wi.current.vs(),wi.current.ts()),hn.current=F)},[i]);const Sa=ze({queryKey:["/api/cloud-recordings",ee?.id,"detections"],queryFn:async()=>{if(!ee?.id)return{detections:[]};const F=await fetch(`/api/cloud-recordings/${ee.id}/detections`,{credentials:"include"});return F.ok?F.json():{detections:[]}},enabled:!!ee?.id&&!le,staleTime:6e4}).data?.detections||[],Aa=u.useCallback(()=>{const F=ge.current;if(!F||Sa.length===0||!ee)return;const ve=new Date(ee.startTime).getTime()/1e3,Te=ce+1>=Sa.length?0:ce+1,ht=Sa[Te],kt=ht.start_time-ve,us=F.duration||1/0;F.currentTime=Math.max(0,Math.min(kt,us-.5)),F.pause(),Pe(Te),$e(ht.sub_label||ht.label)},[Sa,ce,ee]),dd=async F=>{const ve=nG({camera:F.camera,severity:F.severity,label:F.label,displayName:F.displayName,startTime:F.start_time});if(/iphone|ipad|ipod|android/i.test(navigator.userAgent)){const ht=po(F).includes("?")?"&":"?",kt=`${po(F)}${ht}download=true&filename=${encodeURIComponent(ve)}`,us=document.createElement("a");us.href=kt,us.rel="noopener",document.body.appendChild(us),us.click(),document.body.removeChild(us);return}D(!0);try{const ht=await fetch(po(F),{credentials:"include",headers:{"x-download-intent":"true"}}),kt=(ht.headers.get("content-type")||"").toLowerCase();if(!ht.ok||!kt.startsWith("video/")&&!kt.includes("application/octet-stream")){const js=await ht.json().catch(()=>null);r({title:"Download failed",description:js?.detail||js?.error||"The clip is not available on the Edge device.",variant:"destructive"});return}const us=await ht.blob(),ts=window.URL.createObjectURL(us),is=document.createElement("a");is.href=ts,is.download=ve,document.body.appendChild(is),is.click(),document.body.removeChild(is),window.URL.revokeObjectURL(ts)}catch{r({title:"Download failed",description:"Could not download the clip.",variant:"destructive"})}finally{D(!1)}},Dl=u.useCallback((F,ve,Te,ht)=>{o(kt=>kt.some(ts=>ts.siteId===F&&ts.cameraName===Te)?kt.filter(ts=>!(ts.siteId===F&&ts.cameraName===Te)):[...kt,{siteId:F,siteName:ve,cameraName:Te,displayName:ht}])},[]),li=u.useCallback((F,ve)=>i.some(Te=>Te.siteId===F&&Te.cameraName===ve),[i]),Fc=u.useCallback(F=>{o(ve=>{const Te=ve.filter(kt=>kt.siteId!==F.siteId);return F.cameras.every(kt=>ve.some(us=>us.siteId===F.siteId&&us.cameraName===kt.name))?Te:[...Te,...F.cameras.map(kt=>({siteId:F.siteId,siteName:F.siteName,cameraName:kt.name,displayName:kt.displayName}))]})},[]);return t.jsxs("div",{className:"min-h-screen bg-background","data-testid":"multi-recordings-page",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>s("/"),"data-testid":"button-back-dashboard",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(cn,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold","data-testid":"text-page-title",children:"Edge+ Retrieval"})]}),t.jsx(qd,{showDashboardLink:!0})]})})}),t.jsxs("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6",children:[t.jsx(ut,{className:"mb-6",children:t.jsx(mt,{className:"pt-6",children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-end gap-3 flex-wrap",children:[t.jsxs("div",{className:"space-y-1.5 min-w-0",style:{minWidth:"200px"},children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Cameras"}),t.jsxs(vd,{open:C,onOpenChange:k,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",className:"w-full justify-between font-normal","data-testid":"button-select-cameras",children:[t.jsxs("span",{className:"flex items-center gap-2 truncate",children:[t.jsx(no,{className:"w-4 h-4 flex-shrink-0"}),i.length===0?"Select cameras...":`${i.length} camera${i.length>
5561?"s":""} selected`]}),t.jsx(CK,{className:"w-3 h-3 ml-1 flex-shrink-0"})]})}),t.jsxs(Kc,{className:"w-80 p-0",align:"start",children:[t.jsxs("div",{className:"p-3 border-b",children:[t.jsx("p",{className:"text-sm font-medium",children:"Select Cameras"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Choose cameras from your sites"})]}),t.jsx(yk,{className:"h-[320px]",children:t.jsx("div",{className:"p-2 space-y-1",children:Cc?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(Fe,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):ja.length===0?t.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No accessible sites found"}):ja.map(F=>{const ve=F.cameras.every(ht=>li(F.siteId,ht.name)),Te=F.cameras.some(ht=>li(F.siteId,ht.name));return t.jsxs("div",{className:"space-y-0.5",children:[t.jsx(Wt,{children:t.jsx(Kt,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-left hover-elevate",onClick:()=>Fc(F),"data-testid":`multi-rec-site-toggle-${F.siteId}`,children:[t.jsx(On,{checked:ve?!0:Te?"indeterminate":!1,className:"pointer-events-none"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:F.siteName}),t.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:F.companyName})]})]})})}),t.jsx("div",{className:"ml-6 space-y-0.5",children:F.cameras.map(ht=>t.jsxs("button",{type:"button",className:"flex items-center gap-2 w-full px-2 py-1 rounded text-left hover-elevate",onClick:()=>Dl(F.siteId,F.siteName,ht.name,ht.displayName),"data-testid":`multi-rec-camera-toggle-${F.siteId}-${ht.name}`,children:[t.jsx(On,{checked:li(F.siteId,ht.name),className:"pointer-events-none"}),t.jsx("span",{className:"text-sm truncate",children:ht.displayName})]},`${F.siteId}-${ht.name}`))}),t.jsx(Qh,{className:"my-1"})]},F.siteId)})})}),i.length>0&&t.jsxs("div",{className:"p-2 border-t flex items-center justify-between gap-2",children:[t.jsxs("span",{className:"text-xs text-muted-foreground",children:[i.length," selected"]}),t.jsx(L,{variant:"ghost",size:"sm",onClick:()=>{o([]),Zi()},"data-testid":"button-clear-cameras",children:"Clear All"})]})]})]})]}),t.jsxs("div",{className:"space-y-1.5 flex-shrink-0",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Severity"}),t.jsxs(Us,{value:l,onValueChange:F=>{c(F),Zi()},children:[t.jsx($s,{"data-testid":"select-severity",className:"w-[130px]",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All Events"}),t.jsx(rt,{value:"alert",children:"AI Alerts"}),t.jsx(rt,{value:"detection",children:"Motion Only"})]})]})]})]}),t.jsx("div",{className:"flex items-end gap-3 flex-wrap",children:Ds!=="events"?t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Date"}),t.jsxs(vd,{open:al,onOpenChange:Zc,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",disabled:i.length===0,className:"w-full justify-start text-left font-normal","data-testid":"input-multi-timeline-date",children:[t.jsx(ro,{className:"mr-2 h-4 w-4 flex-shrink-0"}),za?Bn(oi,"MM/dd/yy"):Bn(oi,"MMM d, yyyy")]})}),t.jsx(Kc,{className:"w-auto p-0",align:"start",children:t.jsx(_m,{mode:"single",selected:oi,onSelect:F=>{if(F){const ve=new Date(F);ve.setHours(0,0,0,0),Zl(ve)}Zc(!1)},disabled:F=>F>new Date,initialFocus:!0})})]})]}):za?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-end gap-2 w-full",children:[t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"From"}),t.jsxs(vd,{open:y,onOpenChange:w,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",disabled:i.length===0,className:"w-full justify-start text-left font-normal","data-testid":"input-multi-mobile-start-date",children:[t.jsx(ro,{className:"mr-1 h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:p?Bn(p,"M/d h:mm a"):"Start"})]})}),t.jsxs(Kc,{className:"w-auto p-0",align:"start",children:[t.jsx(_m,{mode:"single",selected:p,onSelect:F=>
556{if(F){const ve=new Date(F);p&&ve.setHours(p.getHours(),p.getMinutes()),g(ve)}else g(void 0);h(0),Zi()},disabled:F=>F>new Date,initialFocus:!0}),t.jsxs("div",{className:"border-t px-3 py-2 flex items-center gap-2",children:[t.jsx(cn,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx(ke,{type:"time",value:p?Bn(p,"HH:mm"):"00:00",onChange:F=>{if(!F.target.value||!p)return;const ve=F.target.value.split(":"),Te=parseInt(ve[0],10),ht=parseInt(ve[1],10);if(isNaN(Te)||isNaN(ht))return;const kt=new Date(p);kt.setHours(Te,ht,0,0),g(kt),h(0),Zi()},disabled:!p,className:"flex-1","data-testid":"input-multi-mobile-start-time"})]})]})]})]}),t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"To"}),t.jsxs(vd,{open:j,onOpenChange:x,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",disabled:i.length===0,className:"w-full justify-start text-left font-normal","data-testid":"input-multi-mobile-end-date",children:[t.jsx(ro,{className:"mr-1 h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate text-xs",children:v?Bn(v,"M/d h:mm a"):"End"})]})}),t.jsxs(Kc,{className:"w-auto p-0",align:"start",children:[t.jsx(_m,{mode:"single",selected:v,onSelect:F=>{if(F){const ve=new Date(F);v?ve.setHours(v.getHours(),v.getMinutes()):ve.setHours(23,59),b(ve)}else b(void 0);h(0),Zi()},disabled:F=>F>new Date,initialFocus:!0}),t.jsxs("div",{className:"border-t px-3 py-2 flex items-center gap-2",children:[t.jsx(cn,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx(ke,{type:"time",value:v?Bn(v,"HH:mm"):"23:59",onChange:F=>{if(!F.target.value||!v)return;const ve=F.target.value.split(":"),Te=parseInt(ve[0],10),ht=parseInt(ve[1],10);if(isNaN(Te)||isNaN(ht))return;const kt=new Date(v);kt.setHours(Te,ht,0,0),b(kt),h(0),Zi()},disabled:!v,className:"flex-1","data-testid":"input-multi-mobile-end-time"})]})]})]})]})]}),t.jsx("div",{className:"flex items-center gap-1 w-full",children:[{hours:1,label:"1H"},{hours:2,label:"2H"},{hours:4,label:"4H"},{hours:8,label:"8H"},{hours:12,label:"12H"},{hours:24,label:"24H"}].map(({hours:F,label:ve})=>t.jsxs(L,{variant:d===F?"default":"outline",size:"sm",disabled:i.length===0,onClick:()=>tc(F),className:"flex-1 min-w-0 px-1 text-[11px]","data-testid":`button-multi-mobile-time-range-${F}h`,children:[d===F?t.jsx(cn,{className:"w-3 h-3 mr-1 flex-shrink-0"}):null,ve]},F))})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"From"}),t.jsxs(vd,{open:y,onOpenChange:w,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",disabled:i.length===0,className:"w-full justify-start text-left font-normal","data-testid":"input-multi-start-date",children:[t.jsx(ro,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:p?Bn(p,"MMM d, yyyy h:mm a"):t.jsx("span",{className:"text-muted-foreground",children:"Pick a date"})}),p&&t.jsx(va,{className:"ml-auto h-3 w-3 flex-shrink-0 opacity-50 hover:opacity-100",onClick:F=>{F.stopPropagation(),g(void 0),Zi()}})]})}),t.jsxs(Kc,{className:"w-auto p-0",align:"start",children:[t.jsx(_m,{mode:"single",selected:p,onSelect:F=>{if(F){const ve=new Date(F);p&&ve.setHours(p.getHours(),p.getMinutes()),g(ve)}else g(void 0);h(0),Zi()},disabled:F=>F>new Date,initialFocus:!0}),t.jsxs("div",{className:"border-t px-3 py-2 flex items-center gap-2",children:[t.jsx(cn,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx(ke,{type:"time",value:p?Bn(p,"HH:mm"):"00:00",onChange:F=>{if(!F.target.value||!p)return;const ve=F.target.value.split(":"),Te=parseInt(ve[0],10),ht=parseInt(ve[1],10);if(isNaN(Te)||isNaN(ht))return;const kt=new Date(p);kt.setHours(Te,ht,0,0),g(kt),Zi()},disabled:!p,className:"flex-1","data-testid":"input-multi-start-time"})]})]})]})]}),t.jsxs("div",{className:"space-y-1.5 min-w-0 flex-1",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"To"}),t.jsxs(vd,{open:j,onOpenChange:x,children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",disabled:i.length===0,className:"w-full justify-start text-left font-normal","data-testid":"input-multi-end-date",children:[t.jsx(ro,{className:"mr-2 h-4 w-4 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:v?Bn(v,"MMM d, yyyy h:mm a"):t.jsx("span",{className:"text-muted-foreground",children:"Pick a date"})}),v&&t.jsx(va,{className:"ml-auto h-3 w-3 flex-shrink-0 opacity-50 hover:opacity-100",onClick:F=>{F.stopPropagation(),b(void 0),Zi()}})]})}),t.jsxs(Kc,{className:"w-auto p-0",align:"start",children:[t.jsx(_m,{mode:"single",selected:v,onSelect:F=>
556{if(F){const ve=new Date(F);v?ve.setHours(v.getHours(),v.getMinutes()):ve.setHours(23,59),b(ve)}else b(void 0);h(0),Zi()},disabled:F=>F>new Date,initialFocus:!0}),t.jsxs("div",{className:"border-t px-3 py-2 flex items-center gap-2",children:[t.jsx(cn,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),t.jsx(ke,{type:"time",value:v?Bn(v,"HH:mm"):"23:59",onChange:F=>{if(!F.target.value||!v)return;const ve=F.target.value.split(":"),Te=parseInt(ve[0],10),ht=parseInt(ve[1],10);if(isNaN(Te)||isNaN(ht))return;const kt=new Date(v);kt.setHours(Te,ht,0,0),b(kt),Zi()},disabled:!v,className:"flex-1","data-testid":"input-multi-end-time"})]})]})]})]}),t.jsxs("div",{className:"space-y-1.5 flex-shrink-0",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Quick Range"}),t.jsx("div",{className:"flex items-center gap-1",children:[{hours:1,label:"1H"},{hours:2,label:"2H"},{hours:4,label:"4H"},{hours:8,label:"8H"},{hours:12,label:"12H"},{hours:24,label:"24H"}].map(({hours:F,label:ve})=>t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:d===F?"default":"outline",size:"icon",className:"h-9 w-9 text-xs",disabled:i.length===0,onClick:()=>tc(F),"data-testid":`button-multi-time-range-${F}h`,children:d===F?t.jsx(cn,{className:"w-3.5 h-3.5"}):ve})}),t.jsxs(Yt,{children:["Last ",F," hour",F>1?"s":""]})]},F))})]})]})})]})})}),Ai&&i.length>0&&t.jsx(ut,{className:"mb-4",children:t.jsxs(mt,{className:"py-3 px-4",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(ai,{className:"w-4 h-4 text-primary flex-shrink-0"}),t.jsx(re,{className:"text-xs text-muted-foreground flex-shrink-0",children:"AI Search"}),t.jsx(ke,{placeholder:"Describe what you're looking for (e.g. person in red shirt, white SUV)...",value:Es,onChange:F=>Ge(F.target.value),onKeyDown:F=>{F.key==="Enter"&&!Ce&&!ec&&$c(!1)},disabled:Ce||ec,className:"text-sm h-8 flex-1 min-w-0 sm:min-w-[200px]","data-testid":"input-multi-text-search"}),t.jsx(L,{size:"sm",onClick:()=>$c(),disabled:Ce||!Es.trim()||ec,"data-testid":"button-multi-text-search",children:Ce?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):t.jsx(ai,{className:"w-3.5 h-3.5"})}),(ft||Ce)&&t.jsx(L,{size:"sm",variant:"ghost",onClick:fo,"data-testid":"button-multi-text-search-cancel",children:t.jsx(va,{className:"w-3.5 h-3.5"})})]}),uo.length>0&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap","data-testid":"multi-ai-usage-row",children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground cursor-help",children:[t.jsx(Sy,{className:"w-3 h-3"}),"AI requests today:"]})}),t.jsx(Yt,{className:"max-w-xs",children:t.jsxs("p",{className:"text-xs",children:["Each AI search counts as multiple requests — roughly ",t.jsx("b",{children:"1 request per 25 images scored"}),". A single search across many cameras or a long time window can use several requests."]})})]}),uo.map(F=>t.jsxs(Ke,{variant:F.limitReached?"destructive":F.remaining<=10?"secondary":"outline",className:"text-xs font-normal","data-testid":`badge-multi-ai-usage-${F.siteId}`,children:[F.siteName,": ",F.used," / ",F.limit,F.limitReached&&" — limit reached"]},F.siteId))]}),ti&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 p-2 rounded-md bg-destructive/10 text-destructive","data-testid":"text-multi-ai-limit-reached",children:[t.jsx(Sy,{className:"w-3.5 h-3.5 flex-shrink-0"}),t.jsx("span",{className:"text-xs",children:ec?"All selected sites have reached today's AI search limit. Searches are disabled until tomorrow.":"Some selected sites have reached today's AI search limit and will be skipped. Results will only come from the remaining sites."})]}),Ce&&t.jsxs("div",{className:"flex items-center gap-3 mt-2 p-2 rounded-md bg-muted","data-testid":"multi-text-search-loading",children:[t.jsx(Fe,{className:"w-4 h-4 animate-spin text-primary flex-shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-muted-foreground","data-testid":"text-multi-text-search-progress",children:It&&It.total>0?`Scoring ${Math.min(It.scored,It.total)} / ${It.total} images for "${ne}"${ft&&ft.length>0?` — ${ft.length} match${ft.length!==1?"es":""} so far`:""}`:`Searching recordings for "${ne}"...`}),It&&It.total>0&&t.jsx("div",{className:"mt-1 h-1 w-full bg-background rounded overflow-hidden",children:t.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.min(100,Math.round(It.scored/Math.max(1,It.total)*100))}%`}})})]})]})]})}),ft&&t.jsxs("div",{"data-testid":"multi-text-search-results",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ai,{className:"w-4 h-4 text-primary"}),t.jsxs("span",{className:"text-sm font-medium",children:["AI Search: ",ft.length," match",ft.length!==1?"es":""]}),ne&&t.jsxs("span",{className:"text-xs text-muted-foreground italic ml-2",children:['for "',ne,'"']})]}),t.jsxs(L,{size:"sm",variant:"ghost",onClick:fo,"data-testid":"button-multi-text-search-results-close",children:[t.jsx(va,{className:"w-3.5 h-3.5 mr-1"})," Clear"]})]}),ft.length===0?t.jsxs("div",{className:"text-center py-12 border rounded-lg bg-card","data-testid":"text-multi-text-search-empty",children:[t.jsx(ai,{className:"w-8 h-8 mx-auto text-muted-foreground mb-3"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No matching events found. Try different terms or a wider time range."})]}):t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4","data-testid":"multi-text-search-results-grid",children:(bi||ft).map(F=>{const ve=i.find(Te=>Te.siteId===F.siteId)?.siteName||"";
556return t.jsxs(ut,{className:`cursor-pointer hover:ring-2 hover:ring-primary/50 transition-all ${S?.id===F.eventId?"ring-2 ring-primary":""}`,onClick:async()=>{if(F.source==="cloud"&&F.cloudRecordingId){_(null);const ht=Ri.find(kt=>kt.id===F.cloudRecordingId);if(ht)Q(ht),ue(!1),Pe(-1),$e(null);else try{const kt=await fetch(`/api/cloud-recordings/${encodeURIComponent(F.cloudRecordingId)}`,{credentials:"include"});if(kt.ok){const us=await kt.json();Q(us),ue(!1),Pe(-1),$e(null)}}catch{}return}const Te={id:F.eventId,camera:F.camera,start_time:F.startTime,end_time:F.startTime+30,objects:[F.label],detections:[F.eventId],score:F.score/100,severity:"detection",has_clip:!0,has_snapshot:!0,siteId:F.siteId,siteName:ve};_(Te),M(null),O(null),G(-1),Ol(null)},"data-testid":`card-multi-text-search-result-${F.eventId}`,children:[t.jsxs("div",{className:"relative",children:[t.jsx("img",{src:F.source==="cloud"&&F.cloudRecordingId?`/api/cloud-recordings/${encodeURIComponent(F.cloudRecordingId)}/thumbnail`:`/api/local-recordings/${F.siteId}/thumbnail?detection=${encodeURIComponent(F.eventId)}&camera=${encodeURIComponent(F.camera)}`,alt:F.camera,className:"w-full h-32 object-cover rounded-t-lg bg-black",onError:Te=>{Te.target.src="",Te.target.className="w-full h-32 bg-muted rounded-t-lg flex items-center justify-center"}}),t.jsxs(Ke,{className:`absolute top-2 right-2 text-[10px] ${zt(F.score)}`,children:[F.score,"%"]}),F.source==="cloud"&&t.jsx(Ke,{variant:"outline",className:"absolute top-2 left-2 text-[10px] bg-background/80",children:"Cloud"})]}),t.jsxs(mt,{className:"p-3",children:[t.jsx("div",{className:"text-sm font-medium truncate",children:La.get(`${F.siteId}:${F.camera}`)||F.camera}),t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:ve}),t.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(F.startTime*1e3).toLocaleString()}),t.jsx(Ke,{variant:"outline",className:"text-[10px]",children:F.label})]})]})]},`${F.siteId}-${F.eventId}`)})})]}),!ft&&t.jsx(t.Fragment,{children:i.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(no,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2","data-testid":"text-no-cameras",children:"Select Cameras"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Choose cameras from the selector above to view recordings from multiple sites."})]}):t.jsxs(_h,{value:n,onValueChange:F=>{a(F),Vr([]),fo()},className:"space-y-4",children:[t.jsxs(Dm,{"data-testid":"tabs-multi-recording-source",children:[!Pd&&t.jsxs(_n,{value:"local",className:"gap-1.5","data-testid":"tab-multi-local",children:[t.jsx(Fa,{className:"w-3.5 h-3.5"}),"Local"]}),t.jsxs(_n,{value:"cloud",className:"gap-1.5","data-testid":"tab-multi-cloud",children:[t.jsx(pn,{className:"w-3.5 h-3.5"}),"Cloud"]})]}),t.jsxs(ea,{value:"local",className:"space-y-4",children:[Ed.length>0&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap","data-testid":"filter-multi-local-labels",children:[t.jsx(Py,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx(Ke,{variant:Lr.length===0?"default":"outline",className:"cursor-pointer text-xs toggle-elevate",onClick:()=>Vr([]),"data-testid":"filter-multi-label-all",children:"All"}),Ed.map(F=>t.jsx(Ke,{variant:Lr.includes(F)?"default":"outline",className:"cursor-pointer text-xs toggle-elevate",onClick:()=>{Vr(ve=>ve.includes(F)?ve.filter(Te=>Te!==F):[...ve,F]),Z(0)},"data-testid":`filter-multi-label-${F}`,children:F.charAt(0).toUpperCase()+F.slice(1)},F))]}),mo&&Lr.some(F=>F!=="motion")&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap","data-testid":"filter-multi-local-color",children:[t.jsx(Xr,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:"Color:"}),t.jsx(Ke,{variant:fr?"outline":"default",className:"cursor-pointer text-xs toggle-elevate",onClick:Eu,"data-testid":"filter-multi-local-color-none",children:"None"}),kc.map(F=>t.jsx(Ke,{variant:Ut===F&&fr?"default":"outline",className:`curs
556or-pointer text-xs toggle-elevate ${es&&Ut===F?"opacity-60":""}`,onClick:()=>Qs(F),"data-testid":`filter-multi-local-color-${F}`,children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[es&&Ut===F?t.jsx(Fe,{className:"w-2.5 h-2.5 animate-spin"}):t.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-border",style:{backgroundColor:_c[F]}}),t.jsx("span",{className:"capitalize",children:F})]})},F)),fr&&!es&&t.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:[ml.length," match",ml.length!==1?"es":""," (",ua.done," scanned)"]}),es&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["Scanning ",ua.done,"/",ua.total,"...",ml.length>0&&` (${ml.length} found)`]}),t.jsx(Ke,{variant:"destructive",className:"cursor-pointer text-xs ml-1",onClick:rc,"data-testid":"button-stop-multi-local-color-search",children:"Stop"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsx("div",{className:"flex items-center gap-3",children:t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-multi-events-count",children:ul.isLoading||Pc.isLoading?"Loading...":""})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex items-center border rounded-md",children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`rounded-r-none toggle-elevate ${Ds==="classic"?"toggle-elevated":""}`,onClick:()=>{nl("classic")},"data-testid":"button-multi-view-classic",children:t.jsx(cn,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Classic View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`rounded-l-none sm:rounded-r-none toggle-elevate ${Ds==="events"?"toggle-elevated":""}`,onClick:()=>{nl("events")},"data-testid":"button-multi-view-events",children:t.jsx(Cy,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Event Grid View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`hidden sm:inline-flex rounded-l-none toggle-elevate ${Ds==="timeline"?"toggle-elevated":""}`,onClick:()=>{nl("timeline")},"data-testid":"button-multi-view-timeline",children:t.jsx(Hx,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Timeline Bar View"})]})]}),Ds==="events"&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>{fn(F=>F==="desc"?"asc":"desc"),Z(0)},"data-testid":"button-multi-sort-order",children:[t.jsx(PS,{className:"w-3 h-3"}),co==="desc"?"Recent":"Oldest"]})}),t.jsx(Yt,{children:co==="desc"?"Showing newest first — click for oldest first":"Showing oldest first — click for newest first"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:`toggle-elevate ${en?"toggle-elevated":""}`,onClick:ma,"data-testid":"button-multi-autoplay-toggle-local",children:t.jsx(ky,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:en?"Auto-Play: ON":"Auto-Play: OFF"})]}),Ds==="events"&&!ul.isLoading&&(nc||Mi)&&!za&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(L,{variant:"outline",size:"sm",onClick:Mu,disabled:!nc,"data-testid":"button-multi-prev-page",children:[t.jsx(Kl,{className:"w-4 h-4 mr-1"})," Prev"]}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",z+1]}),t.jsxs(L,{variant:"outline",size:"sm",onClick:Hm,disabled:!Mi,"data-testid":"button-multi-next-page",children:["Next ",t.jsx(hi,{className:"w-4 h-4 ml-1"})]})]})]})]}),Ds!=="events"?ra.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(no,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"Select Cameras"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Use the Cameras dropdown above to select which cameras to show on the timeline."})]}):Pc.isLoading?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[t.jsx(Fe,{className:"w-4 h-4 animate-spin text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Timeline may take time to populate based on number of cameras and frequency of motion activity."})]}),Array.from({length:4}).map((F,ve)=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Bt,{className:"h-4 w-28"}),t.jsx(Bt,{className:"h-8 flex-1"})]},ve))]}):Ds==="classic"?t.jsx(gk,{segments:pl,onEventClick:os,selectedDate:oi,onSelectDate:Zl,cameraDisplayNames:Ns,groupBySite:!0,siteNames:or,playingId:S?.id??(ee?String(ee.id):null),recordingDays:yn,detectionColor:Dr.data?.timelineDetectionColor||void 0,motionColor:Dr.data?.timelineMotionColor||void 0,onSwitchView:F=>nl(F),testIdPrefix:"classic-multi-local"}):t.jsx(o9,{segments:pl,onSegmentClick:os,timelineDate:oi,detectionColor:Dr.data?.timelineDetectionColor||void 0,motionColor:Dr.data?.timelineMotionColor||void 0,cameraDisplayNames:Vn}):ul.isLoading?t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Array.from({length:8}).map((F,ve)=>t.jsxs(ut,{children:[t.jsx(Bt,{className:"aspect-video w-full"}),t.jsxs(mt,{className:"p-3 space-y-2",children:[t.jsx(Bt,{className:"h-4 w-3/4"}),t.jsx(Bt,{className:"h-3 w-1/2"})]})]},ve))}):kl.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(Vi,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Events Found"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:Lr.length>0?`No events found matching ${Lr.join(" or ")}. Try selecting different labels or clear the filter.`:"No AI events were found for the selected cameras and filters. Try adjusting the date range or camera selection."})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:kl.map(F=>t.jsxs(ut,{className:"overflow-visible hover-elevate cursor-pointer",onClick:()=>{_(F),M(null),O(null)},"data-testid":`card-multi-event-${F.id}`,children:[t.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center rounded-t-md overflow-hidden",children:[t.jsx("img",{src:su(F),alt:`${F.camera}
556 - ${F.objects?.join(", ")||"review"}`,className:"w-full h-full object-cover",onError:ve=>{const Te=ve.target;Te.style.display="none";const ht=Te.nextElementSibling;ht&&(ht.style.display="flex")}}),t.jsx("div",{className:"hidden items-center justify-center absolute inset-0",children:t.jsx(Vi,{className:"w-8 h-8 text-muted-foreground"})}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity",children:F.has_clip?t.jsx(vu,{className:"w-10 h-10 text-white"}):t.jsx(Ok,{className:"w-8 h-8 text-white"})}),t.jsxs("div",{className:"absolute top-2 left-2 flex items-center gap-1",children:[t.jsxs(Ke,{variant:"secondary",className:"text-[10px]",children:[t.jsx(Fa,{className:"w-2.5 h-2.5 mr-1"}),"Local"]}),F.objects&&F.objects.length>0?F.objects.map((ve,Te)=>t.jsx(Ke,{variant:"outline",className:"text-[10px] bg-background/80",children:ve.charAt(0).toUpperCase()+ve.slice(1)},Te)):F.label==="motion"?t.jsx(Ke,{variant:"outline",className:"text-[10px] bg-background/80",children:"Motion"}):null]})]}),t.jsxs(mt,{className:"p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(wo,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsxs("span",{className:"text-sm font-medium truncate","data-testid":`text-multi-event-camera-${F.id}`,children:[F.displayName||La.get(F.camera)||F.camera,F.siteName?` - ${F.siteName}`:""]})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(ro,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:Oc(F.start_time)})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[t.jsx(cn,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:nm(F.start_time)})]})]})]},`${F.siteId}-${F.id}`))}),za?t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:Xc,className:"h-4"}),Ur&&t.jsxs("div",{className:"flex items-center justify-center py-4",children:[t.jsx(Fe,{className:"w-5 h-5 animate-spin text-muted-foreground mr-2"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading more..."})]})]}):Ds==="events"&&(nc||Mi)?t.jsxs("div",{className:"flex items-center justify-center gap-4 mt-6",children:[t.jsxs(L,{variant:"outline",size:"sm",onClick:Mu,disabled:!nc,"data-testid":"button-multi-prev-page-bottom",children:[t.jsx(Kl,{className:"w-4 h-4 mr-1"})," Prev"]}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",z+1]}),t.jsxs(L,{variant:"outline",size:"sm",onClick:Hm,disabled:!Mi,"data-testid":"button-multi-next-page-bottom",children:["Next ",t.jsx(hi,{className:"w-4 h-4 ml-1"})]})]}):null]})]}),t.jsx(ea,{value:"cloud",className:"space-y-4",children:t.jsxs(t.Fragment,{children:[Ah.length>0&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap","data-testid":"filter-multi-cloud-labels",children:[t.jsx(Py,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx(Ke,{variant:Lr.length===0?"default":"outline",className:"cursor-pointer text-xs toggle-elevate",onClick:()=>{Vr([]),Cn(0)},"data-testid":"filter-multi-cloud-label-all",children:"All"}),Ah.map(F=>t.jsx(Ke,{variant:Lr.includes(F)?"default":"outline",className:"cursor-pointer text-xs toggle-elevate",onClick:()=>{Vr(ve=>ve.includes(F)?ve.filter(Te=>Te!==F):[...ve,F]),Cn(0)},"data-testid":`filter-multi-cloud-label-${F}`,children:F.charAt(0).toUpperCase()+F.slice(1)},F))]}),mo&&Lr.some(F=>F!=="motion")&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap","data-testid":"filter-multi-cloud-color",children:[t.jsx(Xr,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:"Color:"}),t.jsx(Ke,{variant:At?"outline":"default",className:"cursor-pointer text-xs toggle-elevate",onClick:Rh,"data-testid":"filter-multi-cloud-color-none",children:"None"}),kc.map(F=>t.jsx(Ke,{variant:Ir===F&&At?"default":"outline",className:`cursor-pointer text-xs toggle-elevate ${lt&&Ir===F?"opacity-60":""}`,onClick:()=>Po(F),"data-testid":`filter-multi-cloud-color-${F}`,children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[lt&&Ir===F?t.jsx(Fe,{className:"w-2.5 h-2.5 animate-spin"}):t.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-border",style:{backgroundColor:_c[F]}}),t.jsx("span",{className:"capitalize",children:F})]})},F)),At&&!lt&&t.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:[Ds!=="events"?hr.length:ho.length," match",(Ds!=="events"?hr.length:ho.length)!==1?"es":""," (",Sr.done," scanned)"]}),lt&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["Scanning ",Sr.done,Ds!=="events"?`/${Sr.total}`:"","...",hr.length>0&&` (${hr.length} found)`]}),t.jsx(Ke,{variant:"destructive",className:"cursor-pointer text-xs ml-1",onClick:la,"data-testid":"button-stop-multi-cloud-color-search",children:"Stop"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:Ec.isLoading||Ea.isLoading?"Loading...":""}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex items-center border rounded-md",children:[t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`rounded-r-none toggle-elevate ${Ds==="classic"?"toggle-elevated":""}`,onClick:()=>{nl("classic")},"data-testid":"button-multi-cloud-view-classic",children:t.jsx(cn,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Classic View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`rounded-l-none sm:rounded-r-none toggle-elevate ${Ds==="events"?"toggle-elevated":""}`,onClick:()=>{nl("events")},"data-testid":"button-multi-cloud-view-events",children:t.jsx(Cy,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Event Grid View"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:`hidden sm:inline-flex rounded-l-none toggle-elevate ${Ds==="timeline"?"toggle-elevated":""}`,onClick:()=>{nl("timeline")},"data-testid":"button-multi-cloud-view-timeline",children:t.jsx(Hx,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Timeline Bar View"})]})]}),Ds==="events"&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>{fn(F=>F==="desc"?"asc":"desc"),Cn(0)},"data-testid":"button-multi-cloud-sort-order",children:[t.jsx(PS,{className:"w-3 h-3"}),co==="desc"?"Recent":"Oldest"]})}),t.jsx(Yt,{children:co==="desc"?"Showing newest first — click for oldest first":"Showing oldest first — click for newest first"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:`toggle-elevate ${en?"toggle-elevated":""}`,onClick:ma,"data-testid":"button-multi-autoplay-toggle-cloud",children:t.jsx(ky,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:en?"Auto-Play: ON":"Auto-Play: OFF"})]}),Ds==="events"&&_l>1&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>{Cn(F=>F-1),window.scrollTo({top:0,behavior:"smooth"})},disabled:lo===0,"data-testid":"button-multi-cloud-prev-page",children:[t.jsx(Kl,{className:"w-4 h-4 mr-1"})," Prev"]}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.jsx("span",{className:"hidden sm:inline",children:"Page "}),lo+1," of ",_l]}),t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>{Cn(F=>F+1),window.scrollTo({top:0,behavior:"smooth"})},disabled:lo>=_l-1,"data-testid":"button-multi-cloud-next-page",children:["Next ",t.jsx(hi,{className:"w-4 h-4 ml-1"})]})]})]})]}),Ds!=="events"?ra.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(no,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"Select Cameras"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Use the Cameras dropdown above to select which cameras to show on the timeline."})]}):Ea.isLoading?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3",children:[t.jsx(Fe,{className:"w-4 h-4 animate-spin text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading cloud timeline..."})]}),Array.from({length:4}).map((F,ve)=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Bt,{className:"h-4 w-28"}),t.jsx(Bt,{className:"h-8 flex-1"})]},ve))]}):Ds==="classic"?t.jsx(gk,{segments:ir,onEventClick:os,selectedDate:oi,onSelectDate:Zl,cameraDisplayNames:Ns,groupBySite:!0,siteNames:or,playingId:S?.id??(ee?String(ee.id):null),recordingDays:cl,detectionColor:Dr.data?.timelineDetectionColor||void 0,motionColor:Dr.data?.timelineMotionColor||void 0,onSwitchView:F=>nl(F),testIdPrefix:"classic-multi-cloud"}):t.jsx(o9,{segments:ir,onSegmentClick:os,timelineDate:oi,detectionColor:Dr.data?.timelineDetectionColor||void 0,motionColor:Dr.data?.timelineMotionColor||void 0,cameraDisplayNames:Vn}):Ec.isLoading?t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Array.from({length:8}).map((F,ve)=>t.jsxs(ut,{children:[t.jsx(Bt,{className:"aspect-video w-full"}),t.jsxs(mt,{className:"p-3 space-y-2",children:[t.jsx(Bt,{className:"h-4 w-3/4"}),t.jsx(Bt,{className:"h-3 w-1/2"})]})]},ve))}):ac.length===0?t.jsxs("div",{className:"text-center py-16",children:[t.jsx(pn,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Cloud Recordings"}),t.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:At?"No cloud recordings matched the selected color filter.":"No cloud recordings found for the selected filters. Recordings will appear here once they sync from the Edge device."})]}):t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:ac.map(F=>t.jsxs(ut,{className:"overflow-visible hover-elevate cursor-pointer",onClick:()=>{ue(!1),Q(F)}
556,"data-testid":`card-multi-cloud-recording-${F.id}`,children:[t.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center rounded-t-md overflow-hidden",children:[F.thumbnailPath?t.jsx("img",{src:F.thumbnailPath,alt:`${F.cameraName} - ${F.label||"recording"}`,className:"w-full h-full object-cover"}):t.jsx(Vi,{className:"w-8 h-8 text-muted-foreground"}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity",children:t.jsx(vu,{className:"w-10 h-10 text-white"})}),t.jsxs("div",{className:"absolute top-2 left-2 flex items-center gap-1",children:[t.jsxs(Ke,{variant:"secondary",className:"text-[10px]",children:[t.jsx(pn,{className:"w-2.5 h-2.5 mr-1"}),"Cloud"]}),F.label&&F.label.split(",").map((ve,Te)=>{const ht=ve.trim();return ht?t.jsx(Ke,{variant:"outline",className:"text-[10px] bg-background/80",children:ht.charAt(0).toUpperCase()+ht.slice(1)},Te):null})]}),F.score!=null&&t.jsxs(Ke,{variant:"secondary",className:"absolute top-2 right-2 text-[10px]",children:[Math.round(F.score*100),"%"]})]}),t.jsxs(mt,{className:"p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(wo,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),t.jsxs("span",{className:"text-sm font-medium truncate","data-testid":`text-multi-cloud-camera-${F.id}`,children:[F.displayName||La.get(F.cameraName)||F.cameraName,F.siteName?` - ${F.siteName}`:""]})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(ro,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:yp(F.startTime)})]}),t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[t.jsx(cn,{className:"w-3 h-3 flex-shrink-0"}),t.jsx("span",{children:Ru(F.startTime)})]})]})]},F.id))}),Ds==="events"&&_l>1&&t.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4","data-testid":"multi-cloud-pagination-bottom",children:[t.jsx(L,{variant:"outline",size:"icon",disabled:lo===0,onClick:()=>{Cn(F=>F-1),window.scrollTo({top:0,behavior:"smooth"})},"data-testid":"button-multi-cloud-prev-page-bottom",children:t.jsx(Kl,{className:"w-4 h-4"})}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.jsx("span",{className:"hidden sm:inline",children:"Page "}),lo+1," of ",_l]}),t.jsx(L,{variant:"outline",size:"icon",disabled:lo>=_l-1,onClick:()=>{Cn(F=>F+1),window.scrollTo({top:0,behavior:"smooth"})},"data-testid":"button-multi-cloud-next-page-bottom",children:t.jsx(hi,{className:"w-4 h-4"})})]})]})})]})})]}),t.jsx(Ys,{open:!!S,onOpenChange:F=>{F||(_(null),M(null),O(null),G(-1),Ol(null),Ta())},children:t.jsxs(Ws,{className:"max-w-4xl player-dialog p-4 sm:p-5 gap-3",hideClose:!0,"aria-describedby":"multi-local-recording-detail-desc",onEscapeKeyDown:F=>{bt&&(F.preventDefault(),Ta())},onPointerDownOutside:F=>{!bt||F.detail?.originalEvent?.target?.closest?.('[data-radix-popper-content-wrapper],[data-radix-select-content],[data-radix-select-viewport],[role="listbox"],[role="dialog"],[role="menu"]')||F.preventDefault()},onInteractOutside:F=>{!bt||F.detail?.originalEvent?.target?.closest?.('[data-radix-popper-content-wrapper],[data-radix-select-content],[data-radix-select-viewport],[role="listbox"],[role="dialog"],[role="menu"]')||F.preventDefault()},children:[t.jsx(Ks,{className:"sr-only",children:"Local Recording Playback"}),t.jsx("p",{id:"multi-local-recording-detail-desc",className:"sr-only",children:"Local recording detail view from Edge device"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 landscape-header",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[t.jsx(wo,{className:"w-4 h-4 flex-shrink-0"}),t.jsx("span",{className:"font-medium text-sm truncate",children:S?.camera?S.displayName||La.get(S.camera)||S.camera:""}),S?.siteName&&t.jsx(Ke,{variant:"outline",className:"text-[10px] px-1.5 py-0 landscape-hide",children:S.siteName}),t.jsxs(Ke,{variant:"secondary",className:"text-[10px] px-1.5 py-0 landscape-hide",children:[t.jsx(Fa,{className:"w-3 h-3 mr-1"}),"Local"]}),S?.objects&&S.objects.length>0&&S.objects.map((F,ve)=>t.jsx(Ke,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:F.charAt(0).toUpperCase()+F.slice(1)},ve))]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 landscape-hide",children:[!T&&gl.length>0&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{size:"icon",variant:"ghost",className:"h-8 w-8 inline-flex relative",onClick:Lc,"data-testid":"button-header-snap-local",children:[t.jsx(mg,{className:"w-4 h-4"}),gl.length>1&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 text-[9px] bg-primary text-primary-foreground rounded-full w-3.5 h-3.5 flex items-center justify-center",children:gl.length})]})}),t.jsx(Yt,{children:"Snap to Object"})]}),!T&&!(S?.siteId&&oa[S.siteId]?.downloadRestricted)&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:"h-8 w-8 sm:h-8 sm:w-8",onClick:()=>S&&dd(S),disabled:R,"data-testid":"button-multi-download-clip",children:R?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):t.jsx(ya,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Download Clip"})]}),Ai&&!T&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:bt?"default":"ghost",className:"h-8 w-8 inline-flex",onClick:()=>
556{if(bt)Ta();else{const F=q.current;F&&F.pause(),Ae(!0),J(null),we(null),Ue(null)}},"data-testid":"button-header-multi-visual-search",children:t.jsx(ai,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Visual Search"})]}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:"h-8 w-8 hidden sm:inline-flex",onClick:()=>{const F=V.current;F&&X0(F)},"data-testid":"button-fullscreen-multi-local",children:t.jsx(pf,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Fullscreen"})]}),t.jsx(HS,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:"h-10 w-10 sm:h-8 sm:w-8","data-testid":"button-close-multi-local-player",children:t.jsx(va,{className:"h-5 w-5 sm:h-4 sm:w-4"})})})]})]}),t.jsx("div",{className:"space-y-3",children:t.jsxs("div",{ref:V,className:"fs-player-container",children:[t.jsxs("div",{className:"fs-overlay-btn",children:[!T&&gl.length>0&&t.jsxs("button",{className:"flex items-center justify-center h-10 px-3 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer text-xs font-medium gap-1.5",onClick:Lc,"data-testid":"button-fs-snap-local",children:[t.jsx(mg,{className:"w-4 h-4"}),gl.length>1&&t.jsxs("span",{children:[K>=0?K+1:1,"/",gl.length]})]}),!T&&!(S?.siteId&&oa[S.siteId]?.downloadRestricted)&&t.jsx("button",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer",onClick:()=>S&&dd(S),"data-testid":"button-fs-download-local",children:R?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):t.jsx(ya,{className:"w-4 h-4"})}),!T&&Ai&&t.jsx("button",{className:`flex items-center justify-center w-10 h-10 rounded-full ${bt?"bg-blue-600 hover:bg-blue-700":"bg-black/60 hover:bg-black/80"} text-white cursor-pointer`,onClick:()=>{if(bt)Ta();else{const F=q.current;F&&F.pause(),Ae(!0),J(null),we(null),Ue(null)}},"data-testid":"button-fs-multi-visual-search",children:t.jsx(ai,{className:"w-4 h-4"})})]}),t.jsx("button",{className:"fs-exit-btn items-center justify-center w-10 h-10 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer",onClick:()=>{document.fullscreenElement&&document.exitFullscreen()},"data-testid":"button-exit-fullscreen-local",children:t.jsx(C0,{className:"w-5 h-5"})}),T?t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"relative rounded-md overflow-hidden bg-black flex items-center justify-center landscape-video-wrap aspect-video fs-video-area",children:t.jsx("img",{src:S?su(S):"",alt:`${S?.camera} - ${S?.objects?.join(", ")||"review"}`,className:"max-w-full max-h-full object-contain","data-testid":"img-multi-event-thumbnail",onError:F=>{const ve=F.target;ve.style.display="none"}})}),t.jsxs("div",{className:"flex items-center gap-2 mt-3 p-3 rounded-md bg-muted text-sm text-muted-foreground",children:[t.jsx(ta,{className:"w-4 h-4 flex-shrink-0"}),t.jsx("span",{children:T})]})]}):t.jsxs("div",{className:"relative rounded-md landscape-video-wrap aspect-video max-h-[70vh] overflow-hidden bg-black fs-video-area clip-reveal","data-testid":"multi-video-container",children:[t.jsx(d0,{videoRef:q,resetKey:S?.id}),!oe&&t.jsxs("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-black pointer-events-none","data-testid":"overlay-multi-local-loading",children:[t.jsx("img",{src:Y.appEmblemUrl||Tm,alt:Y.brandName||"Loading",className:"w-20 h-20 object-contain opacity-90 animate-pulse"}),t.jsx("span",{className:"text-xs text-white/60",children:"Loading recording…"})]}),S&&t.jsx(jg,{testIdPrefix:"zoom-multi-local",disabled:bt,children:t.jsx(vae,{hlsSrc:Dh(S),fallbackSrc:po(S),lanOrigin:A,eventId:S.id,autoPlay:!0,controls:!1,muted:!!(S?.siteId&&oa[S.siteId]?.audioRestricted),externalVideoRef:q,onError:()=>M("This clip has been overwritten on the Edge device due to storage rotation."),onEnded:()=>{en&&S&&Wn(S)},onSourceDetected:F=>O(F),onPlay:()=>Ol(null),onCanPlay:()=>he(!0),onTimeUpdate:F=>{!oe&&F.currentTarget.currentTime>0&&he(!0)},"data-testid":"multi-video-playback"})}),S&&t.jsx(u0,{videoRef:q,resetKey:S.id,audioRestricted:!!(S?.siteId&&oa[S.siteId]?.audioRestricted),hidden:bt,fullscreenTargetRef
556:V,testIdPrefix:"vc-multi-local"}),fl&&(()=>{const F=Dc(fl);return t.jsx("div",{className:"absolute top-2 left-2 pointer-events-none",style:{zIndex:10},"data-testid":"multi-snap-label-tag",children:t.jsx("span",{className:"text-xs font-bold text-white px-2 py-1 rounded-md whitespace-nowrap shadow-md",style:{backgroundColor:F.bg},children:fl})})})(),t.jsx(fC,{videoRef:q,onCrop:Iu,onCancel:()=>Ae(!1),active:bt}),$==="preview"&&S&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 p-2 rounded-md bg-muted text-xs text-muted-foreground",children:[t.jsx(ta,{className:"w-3.5 h-3.5 flex-shrink-0"}),t.jsx("span",{children:Date.now()/1e3-S.start_time<7200?"Showing AI preview. Full recording will be available once the Edge device finishes processing (usually within 2 hours).":"Showing AI preview. Full recording clips are unavailable - the Edge device recording segments may have expired."})]})]}),t.jsx("div",{className:"landscape-hide text-center text-[10px] text-muted-foreground",children:S&&nm(S.start_time)}),t.jsx("div",{className:"landscape-mini-timeline fs-mini-timeline-area",children:t.jsx(gC,{events:Di,currentEventId:S?.id||null,loadedStartMs:Pl,loadedEndMs:Oi,onPanRequestMore:Wa,isLoadingBefore:id,isLoadingAfter:El,atStartCap:Ic,atEndCap:Tu,onEventSelect:F=>{const ve=nn.find(Te=>Te.id===F)||nd.find(Te=>Te.id===F)||(Or.data?.events||[]).find(Te=>Te.id===F);ve&&(_(ve),M(null),O(null),G(-1),Ol(null))}})}),Be&&!Qe&&!ae&&t.jsx("div",{className:"flex flex-col gap-2 p-2 rounded-md bg-muted landscape-hide","data-testid":"multi-visual-search-confirm",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:Be,alt:"Cropped selection",className:"h-14 w-auto rounded border border-border object-contain","data-testid":"img-multi-visual-search-crop"}),t.jsxs("div",{className:"flex-1 flex flex-wrap items-center gap-2",children:[t.jsxs(Us,{value:String(dt),onValueChange:F=>Qt(Number(F)),children:[t.jsx($s,{className:"h-7 w-[110px] text-xs","data-testid":"select-multi-vs-time-window",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"1800",children:"± 30 min"}),t.jsx(rt,{value:"3600",children:"± 1 hour"}),t.jsx(rt,{value:"7200",children:"± 2 hours"}),t.jsx(rt,{value:"14400",children:"± 4 hours"}),t.jsx(rt,{value:"43200",children:"± 12 hours"}),t.jsx(rt,{value:"86400",children:"± 24 hours"})]})]}),t.jsxs(Us,{value:Re,onValueChange:F=>pt(F),children:[t.jsx($s,{className:"h-7 w-[120px] text-xs","data-testid":"select-multi-vs-camera-scope",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All cameras"}),t.jsx(rt,{value:"current",children:"This camera"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(L,{size:"sm",onClick:()=>Ou(),"data-testid":"button-multi-visual-search-go",children:[t.jsx(ai,{className:"w-3.5 h-3.5 mr-1"}),"Search"]}),t.jsx(L,{size:"sm",variant:"outline",onClick:Ta,"data-testid":"button-multi-visual-search-cancel",children:"Cancel"})]})]})}),Qe&&t.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-md bg-muted landscape-hide","data-testid":"multi-visual-search-loading",children:[t.jsx(Fe,{className:"w-5 h-5 animate-spin text-primary"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-muted-foreground","data-testid":"text-multi-visual-search-progress",children:We&&We.total>0?`Scoring ${Math.min(We.scored,We.total)} / ${We.total} images${ae&&ae.length>0?` — ${ae.length} match${ae.length!==1?"es":""} so far`:""}`:"Analyzing image and searching recordings across sites..."}),We&&We.total>0&&t.jsx("div",{className:"mt-1.5 h-1 w-full bg-background rounded overflow-hidden",children:t.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.min(100,Math.round(We.scored/Math.max(1,We.total)*100))}%`}})})]}),t.jsx(L,{size:"sm",variant:"outline",onClick:Ta,"data-testid":"button-multi-visual-search-loading-cancel",children:"Cancel"})]}),ae&&t.jsxs("div",{className:"rounded-md border bg-card landscape-hide","data-testid":"multi-visual-search-results",children:[t.jsxs("div",{className:"flex items-center justify-between p-2 border-b",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ai,{className:"w-4 h-4 text-primary"}),t.jsxs("span",{className:"text-sm font-medium",children:[ae.length," match",ae.length!==1?"es":""," found"]}
556)]}),t.jsx(L,{size:"sm",variant:"ghost",onClick:Ta,"data-testid":"button-multi-visual-search-close",children:t.jsx(va,{className:"w-3.5 h-3.5"})})]}),te&&t.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground border-b bg-muted/50 italic","data-testid":"text-multi-visual-search-description",children:["Looking for: ",te]}),ae.length===0?t.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground","data-testid":"text-multi-visual-search-empty",children:"No similar events found in the selected time window. Try a wider time range or more distinctive area."}):t.jsx("div",{className:"max-h-48 overflow-y-auto divide-y","data-testid":"multi-visual-search-results-list",children:(Sc||ae).map(F=>{const ve=i.find(Te=>Te.siteId===F.siteId)?.siteName||"";return t.jsxs("button",{className:`flex items-center gap-3 w-full p-2 hover:bg-muted/50 text-left cursor-pointer ${S?.id===F.eventId?"bg-primary/10 border-l-2 border-l-primary":""}`,onClick:async()=>{if(F.source==="cloud"&&F.cloudRecordingId){_(null);const ht=Ri.find(kt=>kt.id===F.cloudRecordingId);if(ht)Q(ht),ue(!1),Pe(-1),$e(null);else try{const kt=await fetch(`/api/cloud-recordings/${encodeURIComponent(F.cloudRecordingId)}`,{credentials:"include"});if(kt.ok){const us=await kt.json();Q(us),ue(!1),Pe(-1),$e(null)}}catch{}return}const Te={id:F.eventId,camera:F.camera,start_time:F.startTime,end_time:F.startTime+30,objects:[F.label],detections:[F.eventId],score:F.score/100,severity:"detection",has_clip:!0,has_snapshot:!0,siteId:F.siteId,siteName:ve};_(Te),M(null),O(null),G(-1),Ol(null)},"data-testid":`button-multi-visual-search-result-${F.eventId}`,children:[t.jsx("img",{src:F.source==="cloud"&&F.cloudRecordingId?`/api/cloud-recordings/${encodeURIComponent(F.cloudRecordingId)}/thumbnail`:`/api/local-recordings/${F.siteId}/thumbnail?detection=${encodeURIComponent(F.eventId)}&camera=${encodeURIComponent(F.camera)}`,alt:F.camera,className:"h-10 w-16 rounded object-cover bg-black",onError:Te=>{Te.target.style.display="none"}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs font-medium truncate",children:La.get(`${F.siteId}:${F.camera}`)||F.camera}),t.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ve," · ",new Date(F.startTime*1e3).toLocaleString()]})]}),t.jsxs(Ke,{className:`text-[10px] px-1.5 shrink-0 ${zt(F.score)}`,children:[F.score,"%"]}),F.source==="cloud"&&t.jsx(Ke,{variant:"secondary",className:"text-[10px] px-1 shrink-0",children:"Cloud"})]},`${F.siteId}-${F.eventId}`)})})]})]})})]})}),t.jsx(Ys,{open:!!ee,onOpenChange:F=>{F||(Q(null),ue(!1),Pe(-1),$e(null),Ta())},children:t.jsxs(Ws,{className:"max-w-4xl player-dialog p-4 sm:p-5 gap-3",hideClose:!0,"aria-describedby":"multi-cloud-recording-detail-desc",onEscapeKeyDown:F=>{bt&&(F.preventDefault(),Ta())},onPointerDownOutside:F=>{!bt||F.detail?.originalEvent?.target?.closest?.('[data-radix-popper-content-wrapper],[data-radix-select-content],[data-radix-select-viewport],[role="listbox"],[role="dialog"],[role="menu"]')||F.preventDefault()},onInteractOutside:F=>{!bt||F.detail?.originalEvent?.target?.closest?.('[data-radix-popper-content-wrapper],[data-radix-select-content],[data-radix-select-viewport],[role="listbox"],[role="dialog"],[role="menu"]')||F.preventDefault()},children:[t.jsx(Ks,{className:"sr-only",children:"Cloud Recording Playback"}),t.jsx("p",{id:"multi-cloud-recording-detail-desc",className:"sr-only",children:"Cloud recording detail view with playback and download"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 landscape-header",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[t.jsx(wo,{className:"w-4 h-4 flex-shrink-0"}),t.jsx("span",{className:"font-medium text-sm truncate",children:ee?.cameraName?ee.displayName||La.get(ee.cameraName)||ee.cameraName:""}),ee?.siteName&&t.jsx(Ke,{variant:"outline",className:"text-[10px] px-1.5 py-0 landscape-hide",children:ee.siteName}),t.jsxs(Ke,{variant:"secondary",className:"text-[10px] px-1.5 py-0 landscape-hide",children:[t.jsx(pn,{className:"w-3 h-3 mr-1"}),"Cloud"]}),ee?.label&&ee.label.split(",").map((F,ve)=>{const Te=F.trim();return Te?t.jsx(Ke,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:Te.charAt(0).toUpperCase()+Te.
556slice(1)},ve):null})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 landscape-hide",children:[Ai&&!le&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:bt?"default":"ghost",className:"h-8 w-8 inline-flex",onClick:()=>{if(bt)Ta();else{const F=ge.current;F&&F.pause(),Ae(!0),J(null),we(null),Ue(null)}},"data-testid":"button-header-multi-cloud-visual-search",children:t.jsx(ai,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Visual Search"})]}),Sa.length>0&&!le&&t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsxs(L,{size:"icon",variant:"ghost",className:"h-8 w-8 inline-flex relative",onClick:Aa,"data-testid":"button-header-snap-cloud",children:[t.jsx(mg,{className:"w-4 h-4"}),Sa.length>1&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 text-[9px] bg-primary text-primary-foreground rounded-full w-3.5 h-3.5 flex items-center justify-center",children:Sa.length})]})}),t.jsx(Yt,{children:"Snap to Object"})]}),ee?.clipPath&&!(ee.siteId&&oa[ee.siteId]?.downloadRestricted)&&t.jsx(L,{size:"icon",variant:"ghost",className:"h-8 w-8 sm:h-8 sm:w-8",title:"Download from Cloud","data-testid":"button-multi-download-cloud-clip",onClick:()=>{const F=document.createElement("a");F.href=`/api/cloud-recordings/${ee.id}/download?type=clip`,document.body.appendChild(F),F.click(),document.body.removeChild(F)},children:t.jsx(ya,{className:"w-4 h-4"})}),ee?.thumbnailPath&&!ee?.clipPath&&!(ee.siteId&&oa[ee.siteId]?.downloadRestricted)&&t.jsx(L,{size:"icon",variant:"ghost",className:"h-8 w-8 sm:h-8 sm:w-8",title:"Download Snapshot","data-testid":"button-multi-download-thumbnail",onClick:()=>{const F=document.createElement("a");F.href=`/api/cloud-recordings/${ee.id}/download?type=thumbnail`,document.body.appendChild(F),F.click(),document.body.removeChild(F)},children:t.jsx(ya,{className:"w-4 h-4"})}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:"h-8 w-8 hidden sm:inline-flex",onClick:()=>{const F=be.current;F&&X0(F)},"data-testid":"button-fullscreen-multi-cloud",children:t.jsx(pf,{className:"w-4 h-4"})})}),t.jsx(Yt,{children:"Fullscreen"})]}),t.jsx(HS,{asChild:!0,children:t.jsx(L,{size:"icon",variant:"ghost",className:"h-10 w-10 sm:h-8 sm:w-8","data-testid":"button-close-multi-cloud-player",children:t.jsx(va,{className:"h-5 w-5 sm:h-4 sm:w-4"})})})]})]}),t.jsx("div",{className:"space-y-3",children:t.jsxs("div",{ref:be,className:"fs-player-container",children:[t.jsxs("div",{className:"fs-overlay-btn",children:[Sa.length>0&&!le&&t.jsxs("button",{className:"flex items-center justify-center h-10 px-3 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer text-xs font-medium gap-1.5",onClick:Aa,"data-testid":"button-fs-snap-cloud",children:[t.jsx(mg,{className:"w-4 h-4"}),Sa.length>1&&t.jsxs("span",{children:[ce>=0?ce+1:1,"/",Sa.length]})]}),ee?.clipPath&&!(ee.siteId&&oa[ee.siteId]?.downloadRestricted)&&t.jsx("button",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer",onClick:()=>{if(!ee)return;const F=document.createElement("a");F.href=`/api/cloud-recordings/${ee.id}/download?type=clip`,document.body.appendChild(F),F.click(),document.body.removeChild(F)},"data-testid":"button-fs-download-cloud",children:t.jsx(ya,{className:"w-4 h-4"})}),!le&&Ai&&t.jsx("button",{className:`flex items-center justify-center w-10 h-10 rounded-full ${bt?"bg-blue-600 hover:bg-blue-700":"bg-black/60 hover:bg-black/80"} text-white cursor-pointer`,onClick:()=>{if(bt)Ta();else{const F=ge.current;F&&F.pause(),Ae(!0),J(null),we(null),Ue(null)}},"data-testid":"button-fs-visual-search-cloud",children:t.jsx(ai,{className:"w-4 h-4"})})]}),t.jsx("button",{className:"fs-exit-btn items-center justify-center w-10 h-10 rounded-full bg-black/60 hover:bg-black/80 text-white cursor-pointer",onClick:()=>{document.fullscreenElement&&document.exitFullscreen()},"data-testid":"button-exit-fullscreen-cloud",children:t.jsx(C0,{className:"w-5 h-5"})}),ee&&!le?t.jsxs("div",{className:"relative rounded-md landscape-video-wrap aspect-video max-h-[70vh] overflow-hidden bg-black fs-video-area clip-reveal",children:[t.jsx(d0,{videoRef:ge,resetKey:ee.id}),!je&&t.jsxs("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-black pointer-events-none","data-testid":"overlay-multi-cloud-loading",children:[t.jsx("img",{src:Y.appEmblemUrl||Tm,alt:Y.brandName||"Loading",className:"w-20 h-20 object-contain opacity-90 animate-pulse"}),t.jsx("span",{className:"text-xs text-white/60",children:"Loading recording…"})]}),(()=>{const F=!!(ee.siteId&&oa[ee.siteId]?.audioRestricted);return t.jsx(jg,{testIdPrefix:"zoom-multi-cloud",disabled:bt,children:t.jsx("div",{className:`relative w-full h-full ${F?"audio-restricted":""}`,children:t.jsx("video",{ref:ge,crossOrigin:"anonymous",src:Mn,playsInl
556ine:!0,autoPlay:!0,muted:F||void 0,className:"w-full h-full rounded-md bg-black object-contain","data-testid":"multi-video-cloud-playback",onEnded:()=>{en&&ee&&zr(ee)},onError:ve=>{const Te=ve.currentTarget,ht=ee?.id||"";if(ht&&Te.currentSrc&&!Te.currentSrc.includes(`/api/cloud-recordings/${ht}/`)){console.log("[CloudClip] stale onError ignored",{expectedId:ht,src:Te.currentSrc});return}if(ht&&!Te.currentSrc){console.log("[CloudClip] empty-src onError ignored",{expectedId:ht});return}const kt=Te.error,us=kt?`code=${kt.code} (${["","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED"][kt.code]||"UNKNOWN"}) message="${kt.message||""}" netState=${Te.networkState} readyState=${Te.readyState}`:`no MediaError netState=${Te.networkState} readyState=${Te.readyState}`;if(console.log("[CloudClip] onError",{id:ht,detail:us,src:Te.currentSrc}),$o("clip",`cloud clip error: ${us}`,{id:ht,src:Te.currentSrc}),(kt?.code===3||kt?.code===4)&&!Xn){console.log("[CloudClip] decode error — retrying with server transcode",{id:ht,at:Te.currentTime}),vn.current=Te.currentTime>1?Te.currentTime:null,Jr(!0);return}H(us),ue(!0)},onCanPlay:ve=>{pe(!0);const Te=vn.current;if(Te!=null&&Xn){vn.current=null;try{const ht=ve.currentTarget;Number.isFinite(ht.duration)&&Te<ht.duration-1&&(ht.currentTime=Math.max(0,Te-.5))}catch{}}},onTimeUpdate:ve=>{const Te=ve.currentTarget;if(!je&&Te.currentTime>0&&pe(!0),Xn||Te.currentTime<2)return;const ht=Te.getVideoPlaybackQuality?.();(Te.videoWidth===0||ht&&ht.totalVideoFrames===0)&&(console.log("[CloudClip] black playback detected (0 decoded frames) — retrying with server transcode",{id:ee?.id,at:Te.currentTime}),$o("clip",`cloud clip black-playback watchdog fired (videoWidth=${Te.videoWidth}, frames=${ht?.totalVideoFrames??"n/a"})`,{id:ee?.id}),vn.current=Te.currentTime>1?Te.currentTime:null,Jr(!0))},onPlay:ve=>{$e(null),F&&(ve.currentTarget.muted=!0,ve.currentTarget.volume=0)},onVolumeChange:ve=>{if(F){const Te=ve.currentTarget;(!Te.muted||Te.volume>0)&&(Te.muted=!0,Te.volume=0)}}},ee.id)})})})(),t.jsx(u0,{videoRef:ge,resetKey:ee.id,audioRestricted:!!(ee.siteId&&oa[ee.siteId]?.audioRestricted),hidden:bt,fullscreenTargetRef:be,testIdPrefix:"vc-multi-cloud"}),et&&(()=>{const F=Dc(et);return t.jsx("div",{className:"absolute top-2 left-2 pointer-events-none",style:{zIndex:10},"data-testid":"multi-cloud-snap-label-tag",children:t.jsx("span",{className:"text-xs font-bold text-white px-2 py-1 rounded-md whitespace-nowrap shadow-md",style:{backgroundColor:F.bg},children:et})})})(),t.jsx(fC,{videoRef:ge,onCrop:Iu,onCancel:()=>Ae(!1),active:bt})]}):ee&&le?t.jsxs("div",{"data-testid":"multi-cloud-clip-fallback",children:[t.jsx("div",{className:"relative rounded-md overflow-hidden bg-black flex items-center justify-center landscape-video-wrap aspect-video fs-video-area",children:ee.thumbnailPath?t.jsx("img",{src:ee.thumbnailPath,alt:"Recording thumbnail",className:"max-w-full max-h-full object-contain"}):t.jsx("p",{className:"text-muted-foreground",children:"No media available"})}),t.jsxs("div",{className:"flex items-start gap-2 mt-2 p-2 rounded-md bg-muted text-xs text-muted-foreground",children:[t.jsx(ta,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[se?.expired?t.jsxs("div",{"data-testid":"multi-cloud-clip-expired-message",children:["This event is outside your cloud storage plan",se.retentionDays?` (${se.retentionDays} days)`:""," and its video has expired. Expired footage is automatically removed from cloud storage and can no longer be played or downloaded."]}):t.jsx("div",{children:"Video for this event hasn't reached the cloud yet. When a device falls behind, footage uploads oldest-first — this event's video will become playable automatically once the device catches up to it (this can take a while on slower connections)."}),fe&&!se?.expired&&t.jsxs("div",{className:"mt-1 font-mono text-[10px] break-all opacity-70","data-testid":"multi-cloud-clip-error-detail",children:["debug: ",fe]})]})]})]}):null,t.jsx("div",{className:"landscape-hide text-center text-[10px] text-muted-foreground",children:ee&&Ru(ee.startTime)}),t.jsx("div",{className:"landscape-mini-timeline fs-mini-timeline-area",children:t.jsx(gC,{events:Oh,currentEventId:ee?.id||null,loadedStartMs:rm,loadedEndMs:Ko,onPanRequestMore:qg,isLoadingBefore:Ih,isLoadingAfter:cd,atStartCap:zm,atEndCap:Au,onEventSelect:F=>{const ve=ho.find(Te=>Te.id===F)||U.find(Te=>Te.id===F)||(Ni.data?.recordings||[]).find(Te=>Te.id===F);ve&&(ue(!1),Q(ve),Pe(-1),$e(null))}})}),Be&&!Qe&&!ae&&t.jsx("div",{className:"flex flex-col gap-2 p-2 rounded-md bg-muted landscape-hide","data-testid":"multi-cloud-visual-search-confirm",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:Be,alt:"Cropped selection",className:"h-14 w-auto rounded border border-border object-contain","data-testid":"img-multi-cloud-visual-search-crop"}),t.jsxs("div",{className:"flex-1 flex flex-wrap items-center gap-2",children:[t.jsxs(Us,{value:String(dt),onValueChange:F=>Qt(Number(F)),children:[t.jsx($s,{className:"h-7 w-[110px] text-xs","data-testid":"select-multi-cloud-vs-time-window",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"1800",children:"± 30 min"}),t.jsx(rt,{value:"3600",children:"± 1 hour"}),t.jsx(rt,{value:"7200",children:"± 2 hours"}),t.jsx(rt,{value:"14400",children:"± 4 hours"}),t.jsx(rt,{value:"43200",children:"± 12 hours"}),t.jsx(rt,{value:"86400",children:"± 24 hours"})]})]}),t.jsxs(Us,{value:Re,onValueChange:F=>pt(F),children:[t.jsx($s,{className:"h-7 w-[120px] text-xs","data-testid":"select-multi-cloud-vs-camera-scope",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All cameras"}),t.jsx(rt,{value:"current",children:"This camera"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(L,{size:"sm",onClick:()=>Ou(),"data-testid":"button-multi-cloud-visual-search-go",children:[t.jsx(ai,{className:"w-3.5 h-3.5 mr-1"}),"Search"]}),t.jsx(L,{size:"sm",variant:"outline",onClick:Ta,"data-testid":"button-multi-cloud-visual-search-cancel",children:"Cancel"})]})]})}),Qe&&t.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-md bg-muted landscape-hide","data-testid":"multi-cloud-visual-search-loading",children:[t.jsx(Fe,{className:"w-5 h-5 animate-spin text-primary"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-muted-foreground","data-testid":"text-multi-cloud-visual-search-progress",children:We&&We.total>0?`Scoring ${Math.min(We.scored,We.total)} / ${We.total} images${ae&&ae.length>0?` — ${ae.length} match${ae.length!==1?"es":""} so far`:""}`:"Analyzing image and searching recordings across sites..."}),We&&We.total>0&&t.jsx("div",{className:"mt-1.5 h-1 w-full bg-background rounded overflow-hidden",children:t.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.min(100,Math.round(We.scored/Math.max(1,We.total)*100))}%`}})})]}),t.jsx(L,{size:"sm",variant:"outline",onClick:Ta,"data-testid":"button-multi-cloud-visual-search-loading-cancel",children:"Cancel"})]}),ae&&t.jsxs("div",{className:"rounded-md border bg-card landscape-hide","data-testid":"multi-cloud-visual-search-results",children:[t.jsxs("div",{className:"flex items-center justify-between p-2 border-b",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ai,{className:"w-4 h-4 text-primary"}),t.jsxs("span",{className:"text-sm font-medium",children:[ae.length," match",ae.length!==1?"es":""," found"]}
556)]}),t.jsx(L,{size:"sm",variant:"ghost",onClick:Ta,"data-testid":"button-multi-cloud-visual-search-close",children:t.jsx(va,{className:"w-3.5 h-3.5"})})]}),te&&t.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground border-b bg-muted/50 italic","data-testid":"text-multi-cloud-visual-search-description",children:["Looking for: ",te]}),ae.length===0?t.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground","data-testid":"text-multi-cloud-visual-search-empty",children:"No similar events found in the selected time window. Try a wider time range or more distinctive area."}):t.jsx("div",{className:"max-h-48 overflow-y-auto divide-y",children:(Sc||ae).map(F=>{const ve=ja.find(ht=>ht.siteId===F.siteId)?.siteName||F.siteId,Te=La.get(F.camera)||F.camera;return t.jsxs("button",{className:"w-full flex items-center gap-3 p-2 hover:bg-muted/50 text-left","data-testid":`button-multi-cloud-vs-result-${F.eventId}`,onClick:async()=>{if(F.cloudRecordingId){const ht=ho.find(kt=>kt.id===F.cloudRecordingId)||U.find(kt=>kt.id===F.cloudRecordingId);if(ht)ue(!1),Q(ht),Pe(-1),$e(null);else try{const kt=await fetch(`/api/cloud-recordings/${encodeURIComponent(F.cloudRecordingId)}`,{credentials:"include"});if(kt.ok){const us=await kt.json();ue(!1),Q(us),Pe(-1),$e(null)}}catch{}}},children:[t.jsx("img",{src:F.cloudRecordingId?`/api/cloud-recordings/${F.cloudRecordingId}/thumbnail`:`/api/sites/${F.siteId}/events/${F.eventId}/thumbnail`,alt:F.label,className:"w-16 h-10 object-cover rounded border",onError:ht=>{ht.target.style.display="none"}}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs font-medium truncate",children:Te}),t.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[ve," · ",F.label," · ",t.jsxs("span",{className:fs(F.score),children:[F.score,"%"]})]}),t.jsx("div",{className:"text-[10px] text-muted-foreground",children:new Date(F.startTime*1e3).toLocaleString()})]})]},`${F.siteId}-${F.eventId}`)})})]})]})})]})}),t.jsx(zd,{open:Ct!==null,onOpenChange:F=>{F||(Lt(null),xr.current=null)},children:t.jsxs(bd,{"data-testid":"dialog-multi-ai-quota-confirm",children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:Ct?.exceeds?"This search may exhaust today's AI quota":"Confirm AI search"}),t.jsx(Sd,{asChild:!0,children:Ct?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:["This ",Ct.kind==="text"?"text search":"visual search"," will run across"," ",t.jsx("span",{className:"font-medium",children:Ct.siteCount})," site",Ct.siteCount===1?"":"s",", scanning up to"," ",t.jsx("span",{className:"font-medium","data-testid":"text-multi-quota-est-images",children:Ct.estImages})," images total, which uses about"," ",t.jsx("span",{className:"font-medium","data-testid":"text-multi-quota-est-requests",children:Ct.estRequests})," ","AI request",Ct.estRequests===1?"":"s"," (roughly 1 request per 25 images)."]}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:["Scope: ",Ct.cameraScope," · ",Ct.severityScope]}),Ct.dailyLimit>0&&t.jsxs("div",{children:["Lowest remaining quota across selected sites:"," ",t.jsx("span",{className:"font-medium","data-testid":"text-multi-quota-remaining",children:Ct.remaining})," ","of ",Ct.dailyLimit," daily requests."]}),Ct.tightSiteNames.length>0&&t.jsxs("div",{className:"text-destructive",children:[Ct.tightSiteNames.length===1?`Site "${Ct.tightSiteNames[0]}" has already used 75% or more of today's AI quota.`:`These sites have already used 75% or more of today's AI quota: ${Ct.tightSiteNames.join(", ")}.`," ","Narrow the time window, cameras, or severity to lower the cost."]})]}):t.jsx("div",{})})]}),t.jsxs(jd,{children:[t.jsx(Gc,{"data-testid":"button-multi-quota-cancel",children:Ct?.exceeds?"Narrow search":"Cancel"}),t.jsx(Cd,{"data-testid":"button-multi-quota-confirm",autoFocus:!Ct?.exceeds,onClick:()=>{const F=xr.current;xr.current=null,Lt(null),F?.()},children:Ct?.exceeds?"Run anyway":"Run search"})]})]})}),t.jsx(Ote,{})]})}function xBe(e){const s=(e||"").trim().toLowerCase();return s&&s!=="motion"?"ai":"motion"}const l9=1024*1024*1024;function Xf(e){return!e||e<=0?"—":e>=l9?`${(e/l9).toFixed(2)} GB`:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(0)} KB`:`${e} B`}function vBe(e){if(!e||e<=0)return"—";const s=Math.floor(e/60),r=Math.round(e%60);return s===0?`${r}s`:`${s}m ${r.toString().padStart(2,"0")}s`}function yBe(e){if(!e||e<=0)return"—";const s=Math.round(e),r=Math.floor(s/3600),n=Math.floor(s%3600/60),a=s%60,i=[];return r&&i.push(`${r} ${r===1?"hour":"hours"}`),n&&i.push(`${n} ${n===1?"minute":"minutes"}`),(a||i.length===0)&&i.push(`${a} ${a===1?"second":"seconds"}`),i.join(", ")}
556function bBe(e){return new Date(e*1e3).toLocaleString()}function y0(e){const s=e.getTimezoneOffset();return new Date(e.getTime()-s*60*1e3).toISOString().slice(0,16)}function wBe(){const e=h_(),[,s]=Ia(),{toast:r}=Hs(),n=u.useMemo(()=>new Date,[]),a=u.useMemo(()=>{const Ce=new Date(n.getTime()-36e5);return y0(Ce)},[n]),i=u.useMemo(()=>y0(n),[n]),[o,l]=u.useState(a),[c,d]=u.useState(i),[h,p]=u.useState(""),[g,v]=u.useState("all"),[b,y]=u.useState("all"),[w,j]=u.useState("local"),x=w==="cloud",C=w==="local",[k,S]=u.useState({});u.useEffect(()=>{S({})},[w]);const A=ze({queryKey:["/api/multi-live-view/sites-cameras"]}).data??[],T=ze({queryKey:["/api/companies"]}),M=u.useMemo(()=>{const Ce=[];return(T.data??[]).forEach(Dt=>{(Dt.sites??[]).forEach(ne=>{ne.edgeDevice&&Ce.push({siteId:ne.id,siteName:ne.name})})}),Ce.sort((Dt,ne)=>Dt.siteName.localeCompare(ne.siteName))},[T.data]),R=Ix({queries:A.map(Ce=>({queryKey:["/api/sites",Ce.siteId,"my-permissions"],queryFn:async()=>{const Dt=await fetch(`/api/sites/${Ce.siteId}/my-permissions`,{credentials:"include"});if(!Dt.ok)throw new Error("perm");return await Dt.json()}}))}),D=u.useMemo(()=>{const Ce={};return A.forEach((Dt,ne)=>{const Oe=R[ne]?.data;Oe&&(Ce[Dt.siteId]=Oe)}),Ce},[A,R]),$=Ce=>{const Dt=D[Ce];return Dt?Dt.isExempt||!Dt.downloadRestricted:!0},O=u.useMemo(()=>A.filter(Ce=>Ce.siteId===h),[A,h]),q=u.useMemo(()=>Math.floor(new Date(o).getTime()/1e3),[o]),V=u.useMemo(()=>Math.floor(new Date(c).getTime()/1e3),[c]),K=V>q?V-q>24*3600?"Time range cannot exceed 24 hours.":null:"End must be after start.",G=q>0&&!K,z=ze({queryKey:["/api/cloud-recordings",{startSec:q,endSec:V,siteFilter:h,cameraFilter:g,includeCloud:x}],enabled:x&&G,queryFn:async()=>{const Ce=new URLSearchParams,Dt=O.map(Oe=>Oe.siteId).join(",");Dt&&Ce.set("siteIds",Dt),g!=="all"&&Ce.set("cameraNames",g),Ce.set("startDate",new Date(q*1e3).toISOString()),Ce.set("endDate",new Date(V*1e3).toISOString()),Ce.set("noLimit","true"),Ce.set("sort","desc");const ne=await fetch(`/api/cloud-recordings?${Ce.toString()}`,{credentials:"include"});if(!ne.ok)throw new Error("cloud");return ne.json()}}),Z=Ix({queries:(C?O:[]).map(Ce=>({queryKey:["/api/local-recordings",Ce.siteId,"events",{startSec:q,endSec:V,cameraFilter:g}],enabled:C&&G,queryFn:async()=>{const Dt=new URLSearchParams;g!=="all"&&Dt.set("cameras",g),Dt.set("after",String(q)),Dt.set("before",String(V)),Dt.set("limit","100000");const ne=await fetch(`/api/local-recordings/${Ce.siteId}/events?${Dt.toString()}`,{credentials:"include"});if(!ne.ok)throw new Error("local");const Oe=await ne.json();return{siteId:Ce.siteId,events:Oe.events??[]}}}))}),ee=u.useMemo(()=>{const Ce=[],Dt=new Map(A.map(De=>[De.siteId,De])),ne=(De,jt)=>{const Ct=D[De];
556return!Ct||Ct.isExempt?!0:!(Ct.restrictedCameras&&Ct.restrictedCameras.includes(jt))};if(x)for(const De of z.data?.recordings??[]){if(!ne(De.siteId,De.cameraName))continue;const jt=Dt.get(De.siteId),Ct=Math.floor(new Date(De.startTime).getTime()/1e3),Lt=Math.floor(new Date(De.endTime).getTime()/1e3);Ce.push({key:`cloud:${De.id}`,source:"cloud",siteId:De.siteId,siteName:jt?.siteName??"—",edgeDeviceId:De.edgeDeviceId,cameraName:De.cameraName,startSec:Ct,endSec:Lt,durationSec:De.clipDurationSec||Math.max(0,Lt-Ct),bytes:De.fileSize||0,label:De.label||De.recordingType||"",rawLabel:De.label||"",item:{source:"cloud",recordingId:De.id,edgeDeviceId:De.edgeDeviceId,siteId:De.siteId,cameraName:De.cameraName,startSec:Ct,endSec:Lt,label:De.label||null}})}if(C)for(const De of Z){const jt=De.data;if(!jt)continue;const Ct=Dt.get(jt.siteId);if(Ct?.edgeDeviceId)for(const Lt of jt.events){if(Lt.has_clip===!1||!ne(jt.siteId,Lt.camera))continue;const xr=Math.floor(Lt.start_time),qe=Math.floor(Lt.end_time??Lt.start_time+10);Ce.push({key:`local:${jt.siteId}:${Lt.id}`,source:"local",siteId:jt.siteId,siteName:Ct.siteName,edgeDeviceId:Ct.edgeDeviceId,cameraName:Lt.camera,startSec:xr,endSec:qe,durationSec:Math.max(0,qe-xr),bytes:0,label:Lt.label||"",rawLabel:Lt.label||"",item:{source:"local",edgeDeviceId:Ct.edgeDeviceId,siteId:jt.siteId,cameraName:Lt.camera,startSec:xr,endSec:qe,label:Lt.label||null}})}}const Oe=b==="all"?Ce:Ce.filter(De=>xBe(De.rawLabel)===b);return Oe.sort((De,jt)=>jt.startSec-De.startSec),Oe},[z.data,Z,x,C,A,D,b]),Q=ze({queryKey:["/api/video-exports/quota"],refetchInterval:3e4}),Y=ze({queryKey:["/api/video-exports"],refetchInterval:Ce=>Ce.state.data?.some(Oe=>Oe.status==="queued"||Oe.status==="processing")?4e3:!1}),oe=ze({queryKey:["/api/video-export-schedules"]}),he=u.useMemo(()=>new Set(ee.map(Ce=>
556Ce.key)),[ee]),je=Object.values(k).filter(Ce=>he.has(Ce.key)),le=je.filter(Ce=>Ce.source==="cloud").reduce((Ce,Dt)=>Ce+Dt.bytes,0),ue=je.reduce((Ce,Dt)=>Ce+Dt.durationSec,0),fe=u.useMemo(()=>{const Ce=Q.data?.remainingBytes??1/0;return le>Ce?`Selected cloud clips (${Xf(le)}) exceed remaining quota (${Xf(Ce)}).`:null},[le,Q.data]),H=je.some(Ce=>!$(Ce.siteId)),se=(Ce,Dt)=>{S(ne=>{const Oe={...ne};return Dt?Oe[Ce.key]=Ce:delete Oe[Ce.key],Oe})},me=Et({mutationFn:async()=>{const Ce=je.map(ne=>ne.item);return(await Ze("POST","/api/video-exports",{items:Ce})).json()},onSuccess:()=>{r({title:"Export queued",description:"Your export is being prepared."}),S({}),be("jobs"),Je.invalidateQueries({queryKey:["/api/video-exports"]}),Je.invalidateQueries({queryKey:["/api/video-exports/quota"]})},onError:async Ce=>{r({title:"Export failed",description:Ce?.message||"Could not start export.",variant:"destructive"})}}),[ge,be]=u.useState("export"),[ce,Pe]=u.useState(null),[et,$e]=u.useState(""),[bt,Ae]=u.useState(""),[Be,J]=u.useState(null),[ae,we]=u.useState(""),Qe=Et({mutationFn:async Ce=>(await Ze("POST",`/api/video-exports/${Ce}/share`,{})).json(),onSuccess:(Ce,Dt)=>{Pe(Dt),$e(Ce.shareUrl),Ae(Ce.code),J(null),we(""),Je.invalidateQueries({queryKey:["/api/video-exports"]})},onError:Ce=>r({title:"Could not create link",description:Ce?.message||"Try again.",variant:"destructive"})}),ye=Et({mutationFn:async({jobId:Ce,email:Dt})=>(await Ze("POST",`/api/video-exports/${Ce}/share/email`,{email:Dt,code:bt})).json(),onSuccess:(Ce,Dt)=>{r({title:"Email sent",description:`The link and code were sent to ${Dt.email}.`}),we("")},onError:Ce=>r({title:"Could not send email",description:Ce?.message||"Try again.",variant:"destructive"})}),te=Et({mutationFn:async Ce=>Ze("DELETE",`/api/video-exports/${Ce}/share`),onSuccess:()=>{Pe(null),$e(""),Ae(""),r({title:"Sharing stopped",description:"The link no longer works."}),Je.invalidateQueries({queryKey:["/api/video-exports"]})},onError:Ce=>r({title:"Could not stop sharing",description:Ce?.message||"Try again.",variant:"destructive"})}),Ue=async(Ce,Dt)=>{try{await navigator.clipboard.writeText(Ce),J(Dt),setTimeout(()=>J(null),1500)}catch{r({title:"Copy failed",description:"Copy it manually.",variant:"destructive"})}},[We,St]=u.useState(null),It=Et({mutationFn:async Ce=>Ze("DELETE",`/api/video-exports/${Ce}`),onSuccess:()=>{St(null),r({title:"Export deleted",description:"The export and any share link were removed."}),Je.invalidateQueries({queryKey:["/api/video-exports"]})},onError:Ce=>r({title:"Could not delete",description:Ce?.message||"Try again.",variant:"destructive"})}),ns=Et({mutationFn:async Ce=>Ze("DELETE",`/api/video-export-schedules/${Ce}`),onSuccess:()=>Je.invalidateQueries({queryKey:["/api/video-export-schedules"]})}),dt=Et({mutationFn:async({id:Ce,paused:Dt})=>Ze("PATCH",`/api/video-export-schedules/${Ce}`,{paused:Dt}),onSuccess:()=>Je.invalidateQueries({queryKey:["/api/video-export-schedules"]})}),Qt=ee.map(Ce=>
556Ce.key),Re=Qt.length>0&&Qt.every(Ce=>k[Ce]),pt=ee.filter(Ce=>$(Ce.siteId)),Ft=Ce=>{S(Dt=>{const ne={...Dt};for(const Oe of pt)Ce?ne[Oe.key]=Oe:delete ne[Oe.key];return ne})},Es=x&&z.isLoading||C&&Z.some(Ce=>Ce.isLoading),Ge=je.length>0&&!fe&&!H&&!me.isPending,ft=u.useMemo(()=>{const Ce=new Set;return O.forEach(Dt=>{const ne=D[Dt.siteId],Oe=ne&&!ne.isExempt?ne.restrictedCameras||[]:[];Dt.cameras.forEach(De=>{Oe.includes(De.name)||Ce.add(De.name)})}),Array.from(Ce).sort()},[O,D]),He=u.useMemo(()=>{const Ce=new Map;return A.forEach(Dt=>{Dt.cameras.forEach(ne=>{Ce.set(`${Dt.siteId}::${ne.name}`,ne.displayName||ne.name)})}),Ce},[A]),zt=(Ce,Dt)=>He.get(`${Ce}::${Dt}`)||Dt,fs=Q.data?Math.min(100,Q.data.usedBytes/Q.data.capBytes*100):0;return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"border-b sticky top-0 bg-background z-10",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-3 flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>s("/"),"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(ya,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold","data-testid":"text-page-title",children:"Video Export"})]})}),t.jsx("div",{className:"max-w-7xl mx-auto px-4 py-6",children:t.jsxs(_h,{value:ge,onValueChange:be,children:[t.jsxs(Dm,{className:"mb-4",children:[t.jsx(_n,{value:"export","data-testid":"tab-export",children:"Export"}),t.jsx(_n,{value:"jobs","data-testid":"tab-jobs",children:"Jobs"}),t.jsx(_n,{value:"schedules","data-testid":"tab-schedules",children:"Schedules"})]}),t.jsx(ea,{value:"export",children:t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[t.jsxs(ut,{children:[t.jsx(xs,{children:t.jsx(ys,{className:"text-base",children:"Filters"})}),t.jsxs(mt,{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Start"}),t.jsx(ke,{type:"datetime-local",value:o,onChange:Ce=>l(Ce.target.value),"data-testid":"input-start-date"})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"End"}),t.jsx(ke,{type:"datetime-local",value:c,onChange:Ce=>d(Ce.target.value),"data-testid":"input-end-date"})]}),K?t.jsx("p",{className:"text-xs text-destructive sm:col-span-2 -mt-1","data-testid":"text-range-error",children:K}):t.jsx("p",{className:"text-xs text-muted-foreground sm:col-span-2 -mt-1","data-testid":"text-range-hint",children:"Exports are limited to a 24-hour window."}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Site"}),t.jsxs(Us,{value:h,onValueChange:Ce=>{p(Ce),v("all")},children:[t.jsx($s,{"data-testid":"select-site",children:t.jsx(zs,{placeholder:"Select a site"})}),t.jsx(Fs,{children:M.map(Ce=>t.jsx(rt,{value:Ce.siteId,children:Ce.siteName},Ce.siteId))})]})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Camera"}),t.jsxs(Us,{value:g,onValueChange:v,children:[t.jsx($s,{"data-testid":"select-camera",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All cameras"}),ft.map(Ce=>t.jsx(rt,{value:Ce,children:zt(h,Ce)},Ce))]})]})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Event type"}),t.jsxs(Us,{value:b,onValueChange:Ce=>y(Ce),children:[t.jsx($s,{"data-testid":"select-event-type",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All events"}),t.jsx(rt,{value:"motion",children:"Motion"}),t.jsx(rt,{value:"ai",children:"AI only"})]})]})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs invisible","aria-hidden":"true",children:"Source"}),t.jsxs("div",{className:"flex items-center gap-2 h-10",children:[t.jsx(re,{className:"text-sm",children:"Source"}),t.jsxs("div",{className:"flex rounded-md border overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>j("local"),className:`flex items-center gap-1 px-3 py-1.5 text-sm ${w==="local"?"bg-primary text-primary-foreground":"bg-background hover:bg-muted"}`,"data-testid":"button-source-local",children:[t.jsx(Fa,{className:"w-4 h-4"})," Local"]}),t.jsxs("button",{type:"button",onClick:()=>j("cloud"),className:`flex items-center gap-1 px-3 py-1.5 text-sm border-l ${w==="cloud"?"bg-primary text-primary-foreground":"bg-background hover:bg-muted"}`,"data-testid":"button-source-cloud",children:[t.jsx(pn,{className:"w-4 h-4"})," Cloud"]})]})]})]})]})]}),t.jsxs(ut,{children:[t.jsxs(xs,{className:"flex flex-row items-center justify-between",children:[t.jsxs(ys,{className:"text-base",children:["Recordings"," ",t.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",ee.length,")"]})]}),Es&&t.jsx(Fe,{className:"w-4 h-4 animate-spin"})]}),t.jsx(mt,{children:t.jsx("div",{className:"border rounded-md max-h-[460px] overflow-auto",children:t.jsxs(Fy,{children:[t.jsx(By,{className:"sticky top-0 bg-background",children:t.jsxs(hu,{children:[t.jsx(fa,{className:"w-8",children:t.jsx(On,{checked:Re,onCheckedChange:Ce=>Ft(!!Ce),"data-testid":"checkbox-select-all"})}),t.jsx(fa,{children:"Site"}),t.jsx(fa,{children:"Camera"}),t.jsx(fa,{children:"Type"}),t.jsx(fa,{children:"Start"}),t.jsx(fa,{children:"Duration"}),w==="cloud"&&t.jsx(fa,{children:"Size"}),t.jsx(fa,{children:"Source"})]})}),t.jsxs(Uy,{children:[ee.length===0&&!Es&&t.jsx(hu,{children:t.jsx(ia,{colSpan:w==="cloud"?8:7,className:"text-center text-muted-foreground py-8",children:"No recordings match the current filters."})}),ee.map(Ce=>{const Dt=!$(Ce.siteId);return t.jsxs(hu,{"data-testid":`row-recording-${Ce.key}`,children:[t.jsx(ia,{children:t.jsx(On,{checked:!!k[Ce.key],disabled:Dt,onCheckedChange:ne=>se(Ce,!!ne),"data-testid":`checkbox-${Ce.key}`})}),t.jsxs(ia,{className:"whitespace-nowrap",children:[Ce.siteName,Dt&&t.jsx("span",{className:"ml-1 text-xs text-destructive",children:"(download off)"})]}),t.jsx(ia,{"data-testid":`text-camera-${Ce.key}`,children:zt(Ce.siteId,Ce.cameraName)}),t.jsx(ia,{className:"capitalize","data-testid":`text-type-${Ce.key}`,children:Ce.label||"—"}),t.jsx(ia,{className:"whitespace-nowrap text-xs",children:bBe(Ce.startSec)}),t.jsx(ia,{children:vBe(Ce.durationSec)}),w==="cloud"&&t.jsx(ia,{children:Ce.source==="cloud"?Xf(Ce.bytes):"—"}),t.jsx(ia,{children:t.jsxs(Ke,{variant:Ce.source==="cloud"?"default":"secondary",children:[Ce.source==="cloud"?t.jsx(pn,{className:"w-3 h-3 mr-1"}):t.jsx(Fa,{className:"w-3 h-3 mr-1"}),Ce.source]})})]},Ce.key)})]})]})})})]})]}),t.jsxs("div",{className:"space-y-4",children:[w==="cloud"&&t.jsxs(ut,{children:[t.jsx(xs,{children:t.jsx(ys,{className:"text-base",children:"Daily Cloud Quota"})}),t.jsx(mt,{children:Q.data?t.jsxs(t.Fragment,{children:[t.jsx(j3,{value:fs,className:"mb-2"}),t.jsxs("div",{className:"text-sm text-muted-foreground","data-testid":"text-quota",children:[Xf(Q.data.usedBytes)," used ·"," ",Xf(Q.data.remainingBytes)," remaining of"," ",Xf(Q.data.capBytes)]})]}):t.jsx(Fe,{className:"w-4 h-4 animate-spin"})})]}),t.jsxs(ut,{children:[t.jsx(xs,{children:t.jsx(ys,{className:"text-base",children:"Export Options"})}),t.jsxs(mt,{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm","data-testid":"text-format-zip",children:[t.jsx(AK,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{children:"Exports download as a ZIP of the selected MP4 clips."})]}),t.jsx(Qh,{}),t.jsxs("div",{className:"text-sm space-y-1",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-muted-foreground",children:"Selected"}),t.jsxs("span",{"data-testid":"text-selected-count",children:[je.length," clips"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-muted-foreground",children:"Total length"}),t.jsx("span",{"data-testid":"text-total-length",children:yBe(ue)})]}),w==="cloud"&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-muted-foreground",children:"Cloud size"}),t.jsx("span",{children:Xf(le)})]})]}),(fe||H)&&t.jsxs("div",{className:"text-xs text-destructive flex items-start gap-1","data-testid":"text-export-error",children:[t.jsx(ta,{className:"w-4 h-4 shrink-0 mt-0.5"}),t.jsx("span",{children:fe||"Some selected clips are on devices where your download permission is off."})]}),t.jsxs(L,{className:"w-full",disabled:e||!Ge,onClick:()=>me.mutate(),"data-testid":"button-export",children:[me.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(ya,{className:"w-4 h-4 mr-2"}),"Export"]})]})]})]})]})}),t.jsx(ea,{value:"jobs",children:t.jsxs(ut,{children:[t.jsx(xs,{children:t.jsx(ys,{className:"text-base",children:"Recent Exports"})}),t.jsx(mt,{children:t.jsx("div",{className:"border rounded-md overflow-auto",children:t.jsxs(Fy,{children:[t.jsx(By,{children:t.jsxs(hu,{children:[t.jsx(fa,{children:"Created"}),t.jsx(fa,{children:"Format"}),t.jsx(fa,{children:"Clips"}),t.jsx(fa,{children:"Size"}),t.jsx(fa,{children:"Status"}),t.jsx(fa,{children:"Download"})]})}),t.jsxs(Uy,{children:[(Y.data??[]).length===0&&t.jsx(hu,{children:t.jsx(ia,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No exp
556orts yet."})}),(Y.data??[]).map(Ce=>t.jsxs(hu,{"data-testid":`row-job-${Ce.id}`,children:[t.jsx(ia,{className:"text-xs whitespace-nowrap",children:new Date(Ce.createdAt).toLocaleString()}),t.jsx(ia,{className:"uppercase",children:"ZIP"}),t.jsx(ia,{children:Ce.itemCount}),t.jsx(ia,{children:Xf(Ce.totalBytes)}),t.jsxs(ia,{children:[t.jsxs(Ke,{variant:Ce.status==="ready"?"default":Ce.status==="failed"?"destructive":"secondary",children:[(Ce.status==="queued"||Ce.status==="processing")&&t.jsx(Fe,{className:"w-3 h-3 mr-1 animate-spin"}),Ce.status]}),Ce.status==="failed"&&Ce.error&&t.jsx("div",{className:"text-xs text-destructive mt-1",children:Ce.error}),Ce.status==="processing"&&Ce.error&&t.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:Ce.error})]}),t.jsx(ia,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"flex-1",children:Ce.status==="ready"?t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("a",{href:`/api/video-exports/${Ce.id}/download`,"data-testid":`link-download-${Ce.id}`,children:t.jsxs(L,{size:"sm",variant:"outline",children:[t.jsx(ya,{className:"w-3 h-3 mr-1"})," Download"]})}),t.jsxs(L,{size:"sm",variant:Ce.shared?"secondary":"outline",onClick:()=>Qe.mutate(Ce.id),disabled:Qe.isPending,"data-testid":`button-share-${Ce.id}`,title:Ce.shared?"Sharing on — manage link":"Create a shareable link",children:[Qe.isPending&&Qe.variables===Ce.id?t.jsx(Fe,{className:"w-3 h-3 mr-1 animate-spin"}):t.jsx(Nde,{className:"w-3 h-3 mr-1"}),Ce.shared?"Shared":"Share"]})]}),Ce.expiresAt&&t.jsxs("div",{className:"text-[11px] text-muted-foreground","data-testid":`text-expiry-${Ce.id}`,children:["Expires ",new Date(Ce.expiresAt).toLocaleDateString()]})]}):Ce.status==="expired"?t.jsx("span",{className:"text-muted-foreground text-xs","data-testid":`text-expired-${Ce.id}`,children:"Expired"}):t.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),Ce.status!=="queued"&&Ce.status!=="processing"&&t.jsx(L,{size:"icon",variant:"ghost",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:()=>St(Ce),"data-testid":`button-delete-job-${Ce.id}`,title:"Delete export",children:t.jsx(sa,{className:"w-4 h-4"})})]})})]},Ce.id))]})]})})})]})}),t.jsx(ea,{value:"schedules",children:t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[t.jsx(jBe,{sites:A,permsBySite:D}),t.jsxs(ut,{children:[t.jsx(xs,{children:t.jsx(ys,{className:"text-base",children:"Scheduled Exports"})}),t.jsxs(mt,{className:"space-y-3",children:[(oe.data??[]).length===0&&t.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"No schedules yet."}),(oe.data??[]).map(Ce=>t.jsxs("div",{className:"border rounded-md p-3 flex items-start justify-between gap-2","data-testid":`row-schedule-${Ce.id}`,children:[t.jsxs("div",{className:"text-sm",children:[t.jsxs("div",{className:"font-medium flex items-center gap-2",children:[t.jsx(R5,{className:"w-4 h-4"}),Ce.name,Ce.paused&&t.jsx(Ke,{variant:"secondary",children:"Paused"})]}),t.jsxs("div",{className:"text-muted-foreground text-xs mt-1",children:[`Once${Ce.runAt?" · "+new Date(Ce.runAt).toLocaleString():""}`," ","· ZIP · ",Ce.includeCloud?"Cloud":"Local",Ce.eventType&&Ce.eventType!=="all"?` · ${Ce.eventType==="ai"?"AI only":"Motion"}`:"",Ce.rangeStart&&Ce.rangeEnd?` · ${new Date(Ce.rangeStart).toLocaleString()} → ${new Date(Ce.rangeEnd).toLocaleString()}`:` · ${Ce.lookbackHours}h lookback`]}),t.jsxs("div",{className:"text-muted-foreground text-xs",children:["Next run:"," ",Ce.nextRunAt?new Date(Ce.nextRunAt).toLocaleString():"—"]}),Ce.lastRunAt&&t.jsxs("div",{className:"text-muted-foreground text-xs","data-testid":`text-last-run-${Ce.id}`,children:["Last run: ",new Date(Ce.lastRunAt).toLocaleString(),Ce.lastStatus?` · ${Ce.lastStatus}`:""]})]}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(L,{size:"icon",variant:"ghost",onClick:()=>dt.mutate({id:Ce.id,paused:!Ce.paused}),"data-testid":`button-toggle-${Ce.id}`,children:Ce.paused?t.jsx(vu,{className:"w-4 h-4"}):t.jsx(nO,{className:"w-4 h-4"})}),t.jsx(L,{size:"icon",variant:"ghost",onClick:()=>ns.mutate(Ce.id),"data-testid":`button-delete-${Ce.id}`,children:t.jsx(sa,{className:"w-4 h-4 text-destructive"})})]})]},Ce.id))]})]})]})})]})}),t.jsx(Ys,{open:!!We,onOpenChange:Ce=>!Ce&&St(null),children:t.jsxs(Ws,{"data-testid":"dialog-delete-job",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Delete this export?"}),t.jsx(cr,{children:We?.shared?"This export is currently shared. Deleting it permanently removes the file and immediately disables its share link — anyone with the link will no longer be able to download it.":"This permanently removes the export file. This cannot be undone."})]}),t.jsxs(In,{className:"gap-2",children:[t.jsx(L,{variant:"outline",onClick:()=>St(null),"data-testid":"button-cancel-delete",children:"Cancel"}),t.jsxs(L,{variant:"destructive",onClick:()=>We&&It.mutate(We.id),disabled:It.isPending,"data-testid":"button-confirm-delete",children:[It.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Delete"]})]})]})}),t.jsx(Ys,{open:!!ce,onOpenChange:Ce=>!Ce&&Pe(null),children:t.jsxs(Ws,{"data-testid":"dialog-share",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Share this export"}),t.jsx(cr,{children:"Anyone with the link can download this export, but only after entering the access code. Send the link and the code separately for safety."})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"Download link"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ke,{readOnly:!0,value:et,className:"text-xs","data-testid":"input-share-url"}),t.jsx(L,{size:"icon",variant:"outline",onClick:()=>Ue(et,"link"),"data-testid":"button-copy-link",title:"Copy link",children:Be==="link"?t.jsx(Hd,{className:"w-4 h-4 text-green-600"}):t.jsx(I5,{className:"w-4 h-4"})})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs",children:"Access code"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ke,{readOnly:!0,value:bt,className:"font-mono tracking-widest text-base","data-testid":"input-share-code"}),t.jsx(L,{size:"icon",variant:"outline",onClick:()=>Ue(bt,"code"),"data-testid":"button-copy-code",title:"Copy code",children:Be==="code"?t.jsx(Hd,{className:"w-4 h-4 text-green-600"}):t.jsx(I5,{className:"w-4 h-4"})})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:'For security this code is only shown now. Click "Share" again on the export to generate a new one.'})]}),t.jsxs(L,{variant:"secondary",className:"w-full",onClick:()=>Ue(`Download: ${et}
557Access code: ${bt}`,"both"),"data-testid":"button-copy-both",children:[Be==="both"?t.jsx(Hd,{className:"w-4 h-4 mr-2 text-green-600"}):t.jsx($K,{className:"w-4 h-4 mr-2"}),"Copy link & code"]}),t.jsxs("div",{className:"space-y-1.5 border-t pt-4",children:[t.jsx(re,{className:"text-xs",children:"Email it to someone"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ke,{type:"email",placeholder:"[email protected]",value:ae,onChange:Ce=>we(Ce.target.value),className:"text-sm","data-testid":"input-share-email",onKeyDown:Ce=>{Ce.key==="Enter"&&ae.trim()&&ce&&ye.mutate({jobId:ce,email:ae.trim()})}}),t.jsxs(L,{onClick:()=>ce&&ye.mutate({jobId:ce,email:ae.trim()}),disabled:!ae.trim()||ye.isPending,"data-testid":"button-email-sh
557are",title:"Email link & code",children:[ye.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(qi,{className:"w-4 h-4 mr-2"}),"Send"]})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"We'll email the download link and the access code together to this address."})]})]}),t.jsxs(In,{className:"sm:justify-between gap-2",children:[t.jsxs(L,{variant:"destructive",onClick:()=>ce&&te.mutate(ce),disabled:te.isPending,"data-testid":"button-stop-sharing",children:[te.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Stop sharing"]}),t.jsx(L,{variant:"outline",onClick:()=>Pe(null),"data-testid":"button-share-done",children:"Done"})]})]})})]})}function jBe({sites:e,permsBySite:s}){const{toast:r}=Hs(),n=h_(),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState([]);u.useEffect(()=>{e.length!==0&&(!o||!e.some(q=>q.siteId===o))&&l(e[0].siteId)},[e,o]);const h=u.useMemo(()=>{const q=e.find(G=>G.siteId===o);if(!q)return[];const V=s[o],K=V&&!V.isExempt?V.restrictedCameras||[]:[];return q.cameras.map(G=>G.name).filter(G=>!K.includes(G)).sort()},[e,o,s]),p=u.useMemo(()=>{const q=e.find(K=>K.siteId===o),V=new Map;return q?.cameras.forEach(K=>V.set(K.name,K.displayName||K.name)),K=>V.get(K)||K},[e,o]);u.useEffect(()=>{d(q=>q.filter(V=>h.includes(V)))},[h]);const[g,v]=u.useState("local"),b=g==="cloud",y=g==="local",[w,j]=u.useState(()=>y0(new Date(Date.now()-3600*1e3))),[x,C]=u.useState(()=>y0(new Date)),[k,S]=u.useState("all"),_=u.useMemo(()=>Math.floor(new Date(w).getTime()/1e3),[w]),A=u.useMemo(()=>Math.floor(new Date(x).getTime()/1e3),[x]),T=A-_,M=A>_?T>24*3600?"Footage window cannot exceed 24 hours.":null:"End must be after start.",[R,D]=u.useState(y0(new Date(Date.now()+3600*1e3))),$=u.useMemo(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"America/New_York",[]),O=Et({mutationFn:async()=>{const q={name:a,format:"zip",siteIds:o?[o]:[],cameraNames:c,includeCloud:b,includeLocal:y,rangeStart:new Date(w).toISOString(),rangeEnd:new Date(x).toISOString(),eventType:k,recurrence:"once",timezone:$,runAt:new Date(R).toISOString()};return(await Ze("POST","/api/video-export-schedules",q)).json()},onSuccess:()=>{r({title:"Schedule created"}),i(""),d([]),Je.invalidateQueries({queryKey:["/api/video-export-schedules"]})},onError:q=>r({title:"Could not create schedule",description:q?.message,variant:"destructive"})});return t.jsxs(ut,{children:[t.jsx(xs,{children:t.jsx(ys,{className:"text-base",children:"New Schedule"})}),t.jsxs(mt,{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Name"}),t.jsx(ke,{value:a,onChange:q=>i(q.target.value),placeholder:"Nightly cloud export","data-testid":"input-schedule-name"})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Site"}),t.jsxs(Us,{value:o,onValueChange:l,children:[t.jsx($s,{"data-testid":"select-schedule-site",children:t.jsx(zs,{})}),t.jsx(Fs,{children:e.map(q=>t.jsx(rt,{value:q.siteId,children:q.siteName},q.siteId))})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Footage start"}),t.jsx(ke,{type:"datetime-local",value:w,onChange:q=>j(q.target.value),"data-testid":"input-schedule-range-start"})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Footage end"}),t.jsx(ke,{type:"datetime-local",value:x,onChange:q=>C(q.target.value),"data-testid":"input-schedule-range-end"})]})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Event type"}),t.jsxs(Us,{value:k,onValueChange:q=>S(q),children:[t.jsx($s,{"data-testid":"select-schedule-event-type",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All events"}),t.jsx(rt,{value:"motion",children:"Motion"}),t.jsx(rt,{value:"ai",children:"AI only"})]})]}),M?t.jsx("p",{className:"text-xs text-destructive mt-1","data-testid":"text-schedule-range-error",children:M}):t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Pick a footage window (max 24 hours). Exports run once and download as a ZIP of MP4 clips."})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Cameras"}),t.jsx("div",{className:"max-h-32 overflow-y-auto rounded-md border p-2 space-y-1","data-testid":"list-schedule-cameras",children:h.length===0?t.jsx("p",{className:"text-xs text-muted-foreground",children:"No cameras available"}):h.map(q=>t.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[t.jsx(On,{checked:c.includes(q),onCheckedChange:V=>d(K=>V?[...K,q]:K.filter(G=>G!==q)),"data-testid":`checkbox-schedule-camera-${q}`}),p(q)]},q))}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Leave all unchecked to include every accessible camera."})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Source"}),t.jsxs("div",{className:"flex rounded-md border overflow-hidden mt-1 w-fit",children:[t.jsxs("button",{type:"button",onClick:()=>v("local"),className:`flex items-center gap-1 px-3 py-1.5 text-sm ${g==="local"?"bg-primary text-primary-foreground":"bg-background hover:bg-muted"}`,"data-testid":"button-schedule-source-local",children:[t.jsx(Fa,{className:"w-4 h-4"})," Local"]}),t.jsxs("button",{type:"button",onClick:()=>v("cloud"),className:`flex items-center gap-1 px-3 py-1.5 text-sm border-l ${g==="cloud"?"bg-primary text-primary-foreground":"bg-background hover:bg-muted"}`,"data-testid":"button-schedule-source-cloud",children:[t.jsx(pn,{className:"w-4 h-4"})," Cloud"]})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Local clips are fetched from the edge at run time; an offline edge is skipped until it returns."})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Run at"}),t.jsx(ke,{type:"datetime-local",value:R,onChange:q=>D(q.target.value),"data-testid":"input-run-at"})]}),t.jsxs(L,{className:"w-full",disabled:n||!a.trim()||!!M||O.isPending,onClick:()=>O.mutate(),"data-testid":"button-create-schedule",children:[O.isPending&&t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),"Create Schedule"]})]})]})}const Rae="aiConfigAssistDontAskAgain";function NBe(e){if(e.getItem(Rae)==="1")return!0;for(let s=0;s<e.length;s++){const r=e.key(s);if(r&&(r.startsWith("aiConfigAssistDontAskAgain:")||r.startsWith("aiConfigAssistDeclined:"))&&e.getItem(r)==="1")return Iae(e),!0}return!1}function Iae(e){e.setItem(Rae,"1")}const SBe=[{key:"discovery",label:"Camera Discovery",menuKey:"camera-discovery"},{key:"camera-names",label:"Camera Names",menuKey:"camera-names"},{key:"streams",label:"Camera Configuration",menuKey:"camera-configuration"},{key:"stream-options",label:"Live Streaming",menuKey:"live-streaming"},{key:"record-options",label:"Record Options",menuKey:"record-options"},{key:"system-time",label:"System Time",menuKey:"system-time",divi
557derBefore:!0},{key:"network",label:"Network Settings",menuKey:"network-settings"},{key:"netstats",label:"Network Stats",menuKey:"network-stats"},{key:"cloud-storage",label:"Cloud Storage",menuKey:"cloud-storage"},{key:"aidetection",label:"AI Object Detection",menuKey:"ai-detection",dividerBefore:!0},{key:"ai-plus",label:"AI+ Features",menuKey:"ai-plus",requireAiPlusGate:!0},{key:"faces",label:"Faces & People",menuKey:"faces-people",requireFacesGate:!0},{key:"device-alerts",label:"Device Alerts",menuKey:"device-alerts",dividerBefore:!0},{key:"smart-alerts",label:"Smart Alerts",menuKey:"smart-alerts"},{key:"camera-import-export",label:"Import / Export",menuKey:"import-export",dividerBefore:!0}];function CBe(e,s){const r=new Set(e),n=SBe.filter(a=>r.has(a.menuKey)).filter(a=>!a.requireAiPlusGate||s.showAiPlusTab).filter(a=>!a.requireFacesGate||s.showFacesTab).map(a=>({key:a.key,label:a.label,menuKey:a.menuKey,dividerBefore:a.dividerBefore}));return s.showUserPermissions!==!1&&n.push({key:"user-permissions",label:"User Permissions",dividerBefore:!0}),r.has("privacy")&&n.push({key:"privacy",label:"Owner Privacy"}),n}const B1={ip:"",port:"",user:"",pass:""},Tw=e=>{try{return decodeURIComponent(e)}catch{return e}},c9=e=>{const s=e.trim();if(!s)return{...B1};try{const r=new URL(s);return r.protocol.toLowerCase()!=="rtsp:"||!r.hostname?{...B1}:{ip:r.hostname,port:r.port,user:Tw(r.username),pass:Tw(r.password)}}catch{const r=/^rtsp:\/\/([^/?#]*)(?:[/?#]|$)/i.exec(s);if(!r)return{...B1};const n=r[1],a=n.lastIndexOf("@"),i=a>=0?n.slice(0,a):"",o=a>=0?n.slice(a+1):n,l=i.indexOf(":"),c=o.startsWith("[")?o.match(/^(\[[^\]]+\])(?::(\d+))?$/):o.match(/^([^:]+)(?::(\d+))?$/);return c?{ip:c[1],port:c[2]||"",user:l>=0?Tw(i.slice(0,l)):Tw(i),pass:l>=0?Tw(i.slice(l+1)):""}:{...B1}}};function d9(e){const s=Number(e?.width),r=Number(e?.height);return e?.ok!==!0||!Number.isFinite(s)||s<=0||!Number.isFinite(r)||r<=0?null:{width:s,height:r}}function kBe(e,s,r){const n=d9(e),a=d9(s),i=Number.isFinite(r)&&Number(r)>0;if(!n||!i)return{status:null,record:n,detect:a,recommendedSource:null};if(n.width*n.height<=Number(r))return{status:"compliant",record:n,detect:a,recommendedSource:null};const o=!!a&&a.width*a.height<=Number(r);return{status:"mismatch",record:n,detect:a,recommendedSource:o?"sub":null}}const bk=["top-left","top-right","bottom-left","bottom-right"],WD=["MM/DD/YYYY -hh:mm:ss A","MM/DD/YYYY HH:mm:ss","YYYY-MM-DD HH:mm:ss"],_Be=Gd({timestampEnabled:nf(),timestampFontSize:_r().int().min(12).max(72),timestampPosition:Wc(bk),timestampFormat:Wc(WD),logoEnabled:nf(),logoPosition:Wc(bk),logoTransparency:_r().int().min(50).max(90)}).strict();_Be.partial().strict();const W4={timestampEnabled:!1,timestampFontSize:24,timestampPosition:"top-right",timestampFormat:"MM/DD/YYYY -hh:mm:ss A",logoEnabled:!0,logoPosition:"bottom-right",logoTransparency:50};function PBe(e,s,r){const n={},a=r===WD[0];for(const o of new Intl.DateTimeFormat("en-US",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:a?"h12":"h23"}).formatToParts(new Date(e*1e3)))n[o.type]=o.value;return`${r==="YYYY-MM-DD HH:mm:ss"?`${n.year}-${n.month}-${n.day}`:`${n.month}/${n.day}/${n.year}`}${a?" -":" "}${n.hour}:${n.minute}:${n.second}${a?` ${n.dayPeriod}`:""}`}const u9={"top-left":"Top left","top-right":"Top right","bottom-left":"Bottom left","bottom-right":"Bottom right"},EBe={"MM/DD/YYYY -hh:mm:ss A":"Month/Day/Year – 12-hour time","MM/DD/YYYY HH:mm:ss":"Month/Day/Year – 24-hour time","YYYY-MM-DD HH:mm:ss":"Year-Month-Day – 24-hour time"};function TBe({options:e,timezone:s,saving:r,saved:n,onChange:a,onSave:i}){const o=p=>a({...e,...p}),l=Number.isInteger(e.timestampFontSize)&&e.timestampFontSize>=12&&e.timestampFontSize<=72,c=Number.isInteger(e.logoTransparency)&&e.logoTransparency>=50&&e.logoTransparency<=90;let d="";try{d=PBe(Date.UTC(2026,9,1,13,15,30)/1e3,s||"UTC",e.timestampFormat)}catch{d="Unavailable — configure a valid device timezone."}const h=(!e.timestampEnabled||l)&&(!e.logoEnabled||c);return t.jsxs("section",{className:"p-4 rounded-lg border border-border bg-card space-y-5","aria-labelledby":"export-overlay-heading",children:[t.jsxs("div",{children:[t.jsx("h3",{id:"export-overlay-heading",className:"text-sm font-medium",children:"Video export overlays"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"These settings affect manually downloaded clips and video exports only. Stored recordings and live playback are unchanged."})]}),t.jsxs("div",{className:"space-y-4 rounded-md border border-border p-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx(re,{htmlFor:"export-timestamp-enabled",className:"text-sm font-medium",children:"Include a timestamp during video exporting"}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Uses the original recording time in the device timezone",s?` (${s})`:"",". Off by default."]})]}),t.jsx(sr,{id:"export-timestamp-enabled",checked:e.timestampEnabled,disabled:r,onCheckedChange:p=>o({timestampEnabled:p}),"data-testid":"switch-export-timestamp"})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(re,{htmlFor:"export-timestamp-font",className:"text-xs",children:"Font size (12–72 px at 1080p)"}),t.jsx(ke,{id:"export-timestamp-font",type:"number",min:12,max:72,step:1,value:e.timestampFontSize,disabled:!e.timestampEnabled||r,onChange:p=>o({timestampFontSize:Number(p.target.value)}),className:"mt-1","data-testid":"input-export-timestamp-font"}),e.timestampEnabled&&!l&&t.jsx("p",{className:"text-xs text-destructive mt-1",role:"alert",children:"Enter a whole number from 12 to 72."})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Timestamp position"}),t.jsxs(Us,{value:e.timestampPosition,onValueChange:p=>o({timestampPosition:p}),disabled:!e.timestampEnabled||r,children:[t.jsx($s,{className:"mt-1","data-testid":"select-export-timestamp-position",children:t.jsx(zs,{})}),t.jsx(Fs,{children:bk.map(p=>t.jsx(rt,{value:p,children:u9[p]},p))})]})]})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Timestamp format"}),t.jsxs(Us,{value:e.timestampFormat,onValueChange:p=>o({timestampFormat:p}),disabled:!e.timestampEnabled||r,children:[t.jsx($s,{className:"mt-1","data-testid":"select-export-timestamp-format",children:t.jsx(zs,{})}),t.jsx(Fs,{children:WD.map(p=>t.jsx(rt,{value:p,children:EBe[p]},p))})]}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1","data-testid":"text-export-timestamp-preview",children:["Example: ",t.jsx("span",{className:"font-mono",children:d})]})]})]}),t.jsxs("div",{className:"space-y-4 rounded-md border border-border p-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx(re,{htmlFor:"export-logo-enabled",className:"text-sm font-medium",children:"Include branded logo watermark during video exporting"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Uses the configured brand logo, with the bundled logo as a fallback."})]}),t.jsx(sr,{id:"export-logo-enabled",checked:e.logoEnabled,disabled:r,onCheckedChange:p=>o({logoEnabled:p}),"data-testid":"switch-export-logo"})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Logo position"}),t.jsxs(Us,{value:e.logoPosition,onValueChange:p=>o({logoPosition:p}),disabled:!e.logoEnabled||r,children:[t.jsx($s,{className:"mt-1","data-testid":"select-export-logo-position",children:t.jsx(zs,{})}),t.jsx(Fs,{children:bk.map(p=>t.jsx(rt,{value:p,children:u9[p]},p))})]})]}),t.jsxs("div",{children:[t.jsx(re,{htmlFor:"export-logo-transparency",className:"text-xs",children:"Logo transparency (50–90%)"}),t.jsx(ke,{id:"export-logo-transparency",type:"number",min:50,max:90,step:1,value:e.logoTransparency,disabled:!e.logoEnabled||r,onChange:p=>o({logoTransparency:Number(p.target.value)}),className:"mt-1","data-testid":"input-export-logo-transparency"}),e.logoEnabled&&!c&&t.jsx("p",{className:"text-xs text-destructive mt-1",role:"alert",children:"Enter a whole number from 50 to 90."})]})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(L,{onClick:i,disabled:r||!h,"data-testid":"button-save-export-overlays",children:[r?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):null,r?"Saving...":"Save export options"]}),n&&!r&&t.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"text-export-overlays-saved",children:"Export options saved."})]})]})}var KD="Collapsible",[ABe]=oo(KD),[MBe,GD]=ABe(KD),Oae=u.forwardRef((e,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[c=!1,d]=ip({prop:n,defaultProp:a,onChange:o});return t.jsx(MBe,{scope:r,disabled:i,contentId:wu(),open:c,onOpenToggle:u.useCallback(()=>d(h=>!h),[d]),children:t.jsx(Cr.div,{"data-state":QD(c),"data-disabled":i?"":void 0,...l,ref:s})})});Oae.displayName=KD;
557var Dae="CollapsibleTrigger",Lae=u.forwardRef((e,s)=>{const{__scopeCollapsible:r,...n}=e,a=GD(Dae,r);return t.jsx(Cr.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":QD(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Ms(e.onClick,a.onOpenToggle)})});Lae.displayName=Dae;var YD="CollapsibleContent",$ae=u.forwardRef((e,s)=>{const{forceMount:r,...n}=e,a=GD(YD,e.__scopeCollapsible);return t.jsx($m,{present:r||a.open,children:({present:i})=>t.jsx(RBe,{...n,ref:s,present:i})})});$ae.displayName=YD;var RBe=u.forwardRef((e,s)=>{const{__scopeCollapsible:r,present:n,children:a,...i}=e,o=GD(YD,r),[l,c]=u.useState(n),d=u.useRef(null),h=mr(s,d),p=u.useRef(0),g=p.current,v=u.useRef(0),b=v.current,y=o.open||l,w=u.useRef(y),j=u.useRef(void 0);return u.useEffect(()=>{const x=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(x)},[]),da(()=>{const x=d.current;if(x){j.current=j.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const C=x.getBoundingClientRect();p.current=C.height,v.current=C.width,w.current||(x.style.transitionDuration=j.current.transitionDuration,x.style.animationName=j.current.animationName),c(n)}},[o.open,n]),t.jsx(Cr.div,{"data-state":QD(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!y,...i,ref:h,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:y&&a})});function QD(e){return e?"open":"closed"}var IBe=Oae;const m9=IBe,h9=Lae,p9=$ae,Jt=Symbol.for("drizzle:entityKind");function wl(e,s){if(!e||typeof e!="object")return!1;if(e instanceof s)return!0;if(!Object.prototype.hasOwnProperty.call(s,Jt))throw new Error(`Class "${s.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let r=Object.getPrototypeOf(e).constructor;if(r)for(;r;){if(Jt in r&&r[Jt]===s[Jt])return!0;r=Object.getPrototypeOf(r)}return!1}class Oj{constructor(s,r){this.table=s,this.config=r,this.name=r.name,this.keyAsName=r.keyAsName,this.notNull=r.notNull,this.default=r.default,this.defaultFn=r.defaultFn,this.onUpdateFn=r.onUpdateFn,this.hasDefault=r.hasDefault,this.primary=r.primaryKey,this.isUnique=r.isUnique,this.uniqueName=r.uniqueName,this.uniqueType=r.uniqueType,this.dataType=r.dataType,this.columnType=r.columnType,this.generated=r.generated,this.generatedIdentity=r.generatedIdentity}static[Jt]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(s){return s}mapToDriverValue(s){return s}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class OBe{static[Jt]="ColumnBuilder";config;constructor(s,r,n){this.config={name:s,keyAsName:s==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:r,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(s){return this.config.default=s,this.config.hasDefault=!0,this}$defaultFn(s){return this.config.defaultFn=s,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(s){return this.config.onUpdateFn=s,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(s){this.config.name===""&&(this.config.name=s)}}const by=Symbol.for("drizzle:Name");class DBe{static[Jt]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(s,r){this.reference=()=>{const{name:n,columns:a,foreignColumns:i}=s();return{name:n,columns:a,foreignTable:i[0].table,foreignColumns:i}},r&&(this._onUpdate=r.onUpdate,this._onDelete=r.onDelete)}onUpdate(s){return this._onUpdate=s===void 0?"no action":s,this}onDelete(s){return this._onDelete=s===void 0?"no action":s,this}build(s){return new LBe(s,this)}}class LBe{constructor(s,r){this.table=s,this.reference=r.reference,this.onUpdate=r._onUpdate,this.onDelete=r._onDelete}static[Jt]="PgForeignKey";reference;onUpdate;onDelete;getName(){const{name:s,columns:r,foreignColumns:n}=this.reference(),a=r.map(l=>
557l.name),i=n.map(l=>l.name),o=[this.table[by],...a,n[0].table[by],...i];return s??`${o.join("_")}_fk`}}function $Be(e,...s){return e(...s)}function FBe(e,s){return`${e[by]}_${s.join("_")}_unique`}function f9(e,s,r){for(let n=s;n<e.length;n++){const a=e[n];if(a==="\\"){n++;continue}if(a==='"')return[e.slice(s,n).replace(/\\/g,""),n+1];if(!r&&(a===","||a==="}"))return[e.slice(s,n).replace(/\\/g,""),n]}return[e.slice(s).replace(/\\/g,""),e.length]}function Fae(e,s=0){const r=[];let n=s,a=!1;for(;n<e.length;){const i=e[n];if(i===","){(a||n===s)&&r.push(""),a=!0,n++;continue}if(a=!1,i==="\\"){n+=2;continue}if(i==='"'){const[c,d]=f9(e,n+1,!0);r.push(c),n=d;continue}if(i==="}")return[r,n+1];if(i==="{"){const[c,d]=Fae(e,n+1);r.push(c),n=d;continue}const[o,l]=f9(e,n,!1);r.push(o),n=l}return[r,n]}function BBe(e){const[s]=Fae(e,1);return s}function Bae(e){return`{${e.map(s=>Array.isArray(s)?Bae(s):typeof s=="string"?`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:`${s}`).join(",")}}`}class Pa extends OBe{foreignKeyConfigs=[];static[Jt]="PgColumnBuilder";array(s){return new zBe(this.config.name,this,s)}references(s,r={}){return this.foreignKeyConfigs.push({ref:s,actions:r}),this}unique(s,r){return this.config.isUnique=!0,this.config.uniqueName=s,this.config.uniqueType=r?.nulls,this}generatedAlwaysAs(s){return this.config.generated={as:s,type:"always",mode:"stored"},this}buildForeignKeys(s,r){return this.foreignKeyConfigs.map(({ref:n,actions:a})=>$Be((i,o)=>{const l=new DBe(()=>{const c=i();return{columns:[s],foreignColumns:[c]}});return o.onUpdate&&l.onUpdate(o.onUpdate),o.onDelete&&l.onDelete(o.onDelete),l.build(r)},n,a))}buildExtraConfigColumn(s){return new UBe(s,this.config)}}class Dn extends Oj{constructor(s,r){r.uniqueName||(r.uniqueName=FBe(s,[r.name])),super(s,r),this.table=s}static[Jt]="PgColumn"}class UBe extends Dn{static[Jt]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(s){return this.indexConfig.opClass=s,this}}class K4{static[Jt]="IndexedColumn";constructor(s,r,n,a){this.name=s,this.keyAsName=r,this.type=n,this.indexConfig=a}name;keyAsName;type;indexConfig}class zBe extends Pa{static[Jt]="PgArrayBuilder";constructor(s,r,n){super(s,"array","PgArray"),this.config.baseBuilder=r,this.config.size=n}build(s){const r=this.config.baseBuilder.build(s);return new XD(s,this.config,r)}}class XD extends Dn{constructor(s,r,n,a){super(s,r),this.baseColumn=n,this.range=a,this.size=r.size}size;static[Jt]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size=="number"?this.size:""}]`}mapFromDriverValue(s){return typeof s=="string"&&(s=BBe(s)),s.map(r=>this.baseColumn.mapFromDriverValue(r))}mapToDriverValue(s,r=!1){const n=s.map(a=>a===null?null:wl(this.baseColumn,XD)?this.baseColumn.mapToDriverValue(a,!0):this.baseColumn.mapToDriverValue(a));return r?n:Bae(n)}}const g9=Symbol.for("drizzle:isPgEnum");function HBe(e){return!!e&&typeof e=="function"&&g9 in e&&e[g9]===!0}class Uae{static[Jt]="Subquery";constructor(s,r,n,a=!1){this._={brand:"Subquery",sql:s,selectedFields:r,alias:n,isWith:a}}}const qBe={startActiveSpan(e,s){return s()}},wy=Symbol.for("drizzle:ViewBaseConfig"),G4=Symbol.for("drizzle:Schema"),x9=Symbol.for("drizzle:Columns"),v9=Symbol.for("drizzle:ExtraConfigColumns"),Y4=Symbol.for("drizzle:OriginalName"),Q4=Symbol.for("drizzle:BaseName"),wk=Symbol.for("drizzle:IsAlias"),y9=Symbol.for("drizzle:ExtraConfigBuilder"),zae=Symbol.for("drizzle:IsDrizzleTable");class Qu{static[Jt]="Table";static Symbol={Name:by,Schema:G4,OriginalName:Y4,Columns:x9,ExtraConfigColumns:v9,BaseName:Q4,IsAlias:wk,ExtraConfigBuilder:y9};[by];[Y4];[G4];[x9];[v9];[Q4];[wk]=!1;[zae]=!0;[y9]=void 0;constructor(s,r,n){this[by]=this[Y4]=s,this[G4]=r,this[Q4]=n}}function Hae(e){return typeof e=="object"&&e!==null&&zae in e}function VBe(e){return e!=null&&typeof e.getSQL=="function"}function WBe(e){const s={sql:"",params:[]};for(const r of e)s.sql+=r.sql,s.params.push(...r.params),r.typings?.length&&(s.typings||(s.typings=[]),s.typings.push(...r.typings));return s}class ch{static[Jt]="StringChunk";value;constructor(s){this.value=Array.isArray(s)?s:[s]}getSQL(){return new Ki([this])}}class Ki{constructor(s){this.queryChunks=s}static[Jt]="SQL";decoder=qae;shouldInlineParams=!1;
557append(s){return this.queryChunks.push(...s.queryChunks),this}toQuery(s){return qBe.startActiveSpan("drizzle.buildSQL",r=>{const n=this.buildQueryFromSourceParams(this.queryChunks,s);return r?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(s,r){const n=Object.assign({},r,{inlineParams:r.inlineParams||this.shouldInlineParams,paramStartIndex:r.paramStartIndex||{value:0}}),{casing:a,escapeName:i,escapeParam:o,prepareTyping:l,inlineParams:c,paramStartIndex:d}=n;return WBe(s.map(h=>{if(wl(h,ch))return{sql:h.value.join(""),params:[]};if(wl(h,QR))return{sql:i(h.value),params:[]};if(h===void 0)return{sql:"",params:[]};if(Array.isArray(h)){const p=[new ch("(")];for(const[g,v]of h.entries())p.push(v),g<h.length-1&&p.push(new ch(", "));return p.push(new ch(")")),this.buildQueryFromSourceParams(p,n)}if(wl(h,Ki))return this.buildQueryFromSourceParams(h.queryChunks,{...n,inlineParams:c||h.shouldInlineParams});if(wl(h,Qu)){const p=h[Qu.Symbol.Schema],g=h[Qu.Symbol.Name];return{sql:p===void 0||h[wk]?i(g):i(p)+"."+i(g),params:[]}}if(wl(h,Oj)){const p=a.getColumnCasing(h);if(r.invokeSource==="indexes")return{sql:i(p),params:[]};const g=h.table[Qu.Symbol.Schema];return{sql:h.table[wk]||g===void 0?i(h.table[Qu.Symbol.Name])+"."+i(p):i(g)+"."+i(h.table[Qu.Symbol.Name])+"."+i(p),params:[]}}if(wl(h,KBe)){const p=h[wy].schema,g=h[wy].name;return{sql:p===void 0||h[wy].isAlias?i(g):i(p)+"."+i(g),params:[]}}if(wl(h,Wae)){if(wl(h.value,XR))return{sql:o(d.value++,h),params:[h],typings:["none"]};const p=h.value===null?null:h.encoder.mapToDriverValue(h.value);if(wl(p,Ki))return this.buildQueryFromSourceParams([p],n);if(c)return{sql:this.mapInlineParam(p,n),params:[]};let g=["none"];return l&&(g=[l(h.encoder)]),{sql:o(d.value++,p),params:[p],typings:g}}return wl(h,XR)?{sql:o(d.value++,h),params:[h],typings:["none"]}:wl(h,Ki.Aliased)&&h.fieldAlias!==void 0?{sql:i(h.fieldAlias),params:[]}:wl(h,Uae)?h._.isWith?{sql:i(h._.alias),params:[]}:this.buildQueryFromSourceParams([new ch("("),h._.sql,new ch(") "),new QR(h._.alias)],n):HBe(h)?h.schema?{sql:i(h.schema)+"."+i(h.enumName),params:[]}:{sql:i(h.enumName),params:[]}:VBe(h)?h.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([h.getSQL()],n):this.buildQueryFromSourceParams([new ch("("),h.getSQL(),new ch(")")],n):c?{sql:this.mapInlineParam(h,n),params:[]}:{sql:o(d.value++,h),params:[h],typings:["none"]}}))}mapInlineParam(s,{escapeString:r}){if(s===null)return"null";if(typeof s=="number"||typeof s=="boolean")return s.toString();if(typeof s=="string")return r(s);if(typeof s=="object"){const n=s.toString();return r(n==="[object Object]"?JSON.stringify(s):n)}throw new Error("Unexpected param value: "+s)}getSQL(){return this}as(s){return s===void 0?this:new Ki.Aliased(this,s)}mapWith(s){return this.decoder=typeof s=="function"?{mapFromDriverValue:s}:s,this}inlineParams(){return this.shouldInlineParams=!0,this}if(s){return s?this:void 0}}class QR{constructor(s){this.value=s}static[Jt]="Name";brand;getSQL(){return new Ki([this])}}const qae={mapFromDriverValue:e=>e},Vae={mapToDriverValue:e=>e};({...qae,...Vae});class Wae{constructor(s,r=Vae){this.value=s,this.encoder=r}static[Jt]="Param";brand;getSQL(){return new Ki([this])}}function gr(e,...s){const r=[];(s.length>0||e.length>0&&e[0]!=="")&&r.push(new ch(e[0]));for(const[n,a]of s.entries())r.push(a,new ch(e[n+1]));return new Ki(r)}(e=>{function s(){return new Ki([])}e.empty=s;function r(c){return new Ki(c)}e.fromList=r;function n(c){return new Ki([new ch(c)])}e.raw=n;function a(c,d){const h=[];for(const[p,g]of c.entries())p>0&&d!==void 0&&h.push(d),h.push(g);return new Ki(h)}e.join=a;function i(c){return new QR(c)}e.identifier=i;function o(c){return new XR(c)}e.placeholder=o;function l(c,d){return new Wae(c,d)}e.param=l})(gr||(gr={}));(e=>{class s{constructor(n,a){this.sql=n,this.fieldAlias=a}static[Jt]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new s(this.sql,this.fieldAlias)}}e.Aliased=s})(Ki||(Ki={}));class XR{constructor(s){this.name=s}static[Jt]="Placeholder";getSQL(){return new Ki([this])}}const Kae=Symbol.for("drizzle:IsDrizzleView");class KBe{static[Jt]="View";[wy];[Kae]=!0;constructor({name:s,schema:r,selectedFields:n,query:a}){this[wy]={name:s,originalName:s,schema:r,selectedFields:n,query:a,isExisting:!a,isAlias:!1}}getSQL(){return new Ki([this])}}function GBe(e){return typeof e=="object"&&e!==null&&Kae in e}Oj.prototype.getSQL=function(){return new Ki([this])};Qu.prototype.getSQL=function(){return new Ki([this])};Uae.prototype.getSQL=function(){return new Ki([this])};function YBe(e){return e[Qu.Symbol.Columns]}function QBe(e){return e[wy].selectedFields}function wc(e,s){return{name:typeof e=="string"&&e.length>0?e:"",config:typeof e=="object"?e:s}}class c2 extends Pa{static[Jt]="PgIntColumnBaseBuilder";generatedAlwaysAsIdentity(s){if(s){const{name:r,...n}=s;this.config.generatedIdentity={type:"always",sequenceName:r,sequenceOptions:n}}else this.config.generatedIdentity={type:"always"};return this.config.hasDefault=!0,this.config.notNull=!0,this}generatedByDefaultAsIdentity(s){if(s){const{name:r,...n}=s;this.config.generatedIdentity={type:"byDefault",sequenceName:r,sequenceOptions:n}}else this.config.generatedIdentity={type:"byDefault"};return this.config.hasDefault=!0,this.config.notNull=!0,this}}class XBe extends c2{static[Jt]="PgBigInt53Builder";constructor(s){super(s,"number","PgBigInt53")}build(s){return new ZBe(s,this.config)}}class ZBe extends Dn{static[Jt]="PgBigInt53";getSQLType(){return"bigint"}mapFromDriverValue(s){return typeof s=="number"?s:Number(s)}}class JBe extends c2{static[Jt]="PgBigInt64Builder";constructor(s){super(s,"bigint","PgBigInt64")}build(s){return new e8e(s,this.config)}}class e8e extends Dn{static[Jt]="PgBigInt64";getSQLType(){return"bigint"}mapFromDriverValue(s){return BigInt(s)}}function av(e,s){const{name:r,config:n}=wc(e,s);return n.mode==="number"?new XBe(r):new JBe(r)}
557class t8e extends Pa{static[Jt]="PgBigSerial53Builder";constructor(s){super(s,"number","PgBigSerial53"),this.config.hasDefault=!0,this.config.notNull=!0}build(s){return new s8e(s,this.config)}}class s8e extends Dn{static[Jt]="PgBigSerial53";getSQLType(){return"bigserial"}mapFromDriverValue(s){return typeof s=="number"?s:Number(s)}}class r8e extends Pa{static[Jt]="PgBigSerial64Builder";constructor(s){super(s,"bigint","PgBigSerial64"),this.config.hasDefault=!0}build(s){return new n8e(s,this.config)}}class n8e extends Dn{static[Jt]="PgBigSerial64";getSQLType(){return"bigserial"}mapFromDriverValue(s){return BigInt(s)}}function a8e(e,s){const{name:r,config:n}=wc(e,s);return n.mode==="number"?new t8e(r):new r8e(r)}class i8e extends Pa{static[Jt]="PgBooleanBuilder";constructor(s){super(s,"boolean","PgBoolean")}build(s){return new o8e(s,this.config)}}class o8e extends Dn{static[Jt]="PgBoolean";getSQLType(){return"boolean"}}function Ss(e){return new i8e(e??"")}class l8e extends Pa{static[Jt]="PgCharBuilder";constructor(s,r){super(s,"string","PgChar"),this.config.length=r.length,this.config.enumValues=r.enum}build(s){return new c8e(s,this.config)}}class c8e extends Dn{static[Jt]="PgChar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"char":`char(${this.length})`}}function d8e(e,s={}){const{name:r,config:n}=wc(e,s);return new l8e(r,n)}class u8e extends Pa{static[Jt]="PgCidrBuilder";constructor(s){super(s,"string","PgCidr")}build(s){return new m8e(s,this.config)}}class m8e extends Dn{static[Jt]="PgCidr";getSQLType(){return"cidr"}}
557function h8e(e){return new u8e(e??"")}class p8e extends Pa{static[Jt]="PgCustomColumnBuilder";constructor(s,r,n){super(s,"custom","PgCustomColumn"),this.config.fieldConfig=r,this.config.customTypeParams=n}build(s){return new f8e(s,this.config)}}class f8e extends Dn{static[Jt]="PgCustomColumn";sqlName;mapTo;mapFrom;constructor(s,r){super(s,r),this.sqlName=r.customTypeParams.dataType(r.fieldConfig),this.mapTo=r.customTypeParams.toDriver,this.mapFrom=r.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(s){return typeof this.mapFrom=="function"?this.mapFrom(s):s}mapToDriverValue(s){return typeof this.mapTo=="function"?this.mapTo(s):s}}function Gae(e){return(s,r)=>{const{name:n,config:a}=wc(s,r);return new p8e(n,a,e)}}class bN extends Pa{static[Jt]="PgDateColumnBaseBuilder";defaultNow(){return this.default(gr`now()`)}}class g8e extends bN{static[Jt]="PgDateBuilder";constructor(s){super(s,"date","PgDate")}build(s){return new x8e(s,this.config)}}class x8e extends Dn{static[Jt]="PgDate";getSQLType(){return"date"}mapFromDriverValue(s){return new Date(s)}mapToDriverValue(s){return s.toISOString()}}class v8e extends bN{static[Jt]="PgDateStringBuilder";constructor(s){super(s,"string","PgDateString")}build(s){return new y8e(s,this.config)}}class y8e extends Dn{static[Jt]="PgDateString";
557getSQLType(){return"date"}}function vb(e,s){const{name:r,config:n}=wc(e,s);return n?.mode==="date"?new g8e(r):new v8e(r)}class b8e extends Pa{static[Jt]="PgDoublePrecisionBuilder";constructor(s){super(s,"number","PgDoublePrecision")}build(s){return new w8e(s,this.config)}}class w8e extends Dn{static[Jt]="PgDoublePrecision";getSQLType(){return"double precision"}mapFromDriverValue(s){return typeof s=="string"?Number.parseFloat(s):s}}function xa(e){return new b8e(e??"")}class j8e extends Pa{static[Jt]="PgInetBuilder";constructor(s){super(s,"string","PgInet")}build(s){return new N8e(s,this.config)}}class N8e extends Dn{static[Jt]="PgInet";getSQLType(){return"inet"}}function S8e(e){return new j8e(e??"")}class C8e extends c2{static[Jt]="PgIntegerBuilder";constructor(s){super(s,"number","PgInteger")}build(s){return new k8e(s,this.config)}}class k8e extends Dn{static[Jt]="PgInteger";getSQLType(){return"integer"}mapFromDriverValue(s){return typeof s=="string"?Number.parseInt(s):s}}function As(e){return new C8e(e??"")}class _8e extends Pa{static[Jt]="PgIntervalBuilder";constructor(s,r){super(s,"string","PgInterval"),this.config.intervalConfig=r}build(s){return new P8e(s,this.config)}}class P8e extends Dn{static[Jt]="PgInterval";fields=this.config.intervalConfig.fields;precision=this.config.intervalConfig.precision;getSQLType(){const s=this.fields?` ${this.fields}`:"",r=this.precision?`(${this.precision})`:"";return`interval${s}${r}`}}function E8e(e,s={}){const{name:r,config:n}=wc(e,s);return new _8e(r,n)}class T8e extends Pa{static[Jt]="PgJsonBuilder";constructor(s){super(s,"json","PgJson")}build(s){return new A8e(s,this.config)}}class A8e extends Dn{static[Jt]="PgJson";constructor(s,r){super(s,r)}getSQLType(){return"json"}mapToDriverValue(s){return JSON.stringify(s)}mapFromDriverValue(s){if(typeof s=="string")try{return JSON.parse(s)}catch{return s}return s}}function M8e(e){return new T8e(e??"")}class R8e extends Pa{static[Jt]="PgJsonbBuilder";constructor(s){super(s,"json","PgJsonb")}build(s){return new I8e(s,this.config)}}class I8e extends Dn{static[Jt]="PgJsonb";constructor(s,r){super(s,r)}getSQLType(){return"jsonb"}mapToDriverValue(s){return JSON.stringify(s)}mapFromDriverValue(s){if(typeof s=="string")try{return JSON.parse(s)}catch{return s}return s}}function No(e){return new R8e(e??"")}class O8e extends Pa{static[Jt]="PgLineBuilder";constructor(s){super(s,"array","PgLine")}build(s){return new D8e(s,this.config)}}class D8e extends Dn{static[Jt]="PgLine";getSQLType(){return"line"}mapFromDriverValue(s){const[r,n,a]=s.slice(1,-1).split(",");return[Number.parseFloat(r),Number.parseFloat(n),Number.parseFloat(a)]}mapToDriverValue(s){return`{${s[0]},${s[1]},${s[2]}}`}}class L8e extends Pa{static[Jt]="PgLineABCBuilder";constructor(s){super(s,"json","PgLineABC")}build(s){return new $8e(s,this.config)}}class $8e extends Dn{static[Jt]="PgLineABC";getSQLType(){return"line"}mapFromDriverValue(s){const[r,n,a]=s.slice(1,-1).split(",");return{a:Number.parseFloat(r),b:Number.parseFloat(n),c:Number.parseFloat(a)}}mapToDriverValue(s){return`{${s.a},${s.b},${s.c}}`}}function F8e(e,s){const{name:r,config:n}=wc(e,s);return!n?.mode||n.mode==="tuple"?new O8e(r):new L8e(r)}class B8e extends Pa{static[Jt]="PgMacaddrBuilder";constructor(s){super(s,"string","PgMacaddr")}build(s){return new U8e(s,this.config)}}class U8e extends Dn{static[Jt]="PgMacaddr";getSQLType(){return"macaddr"}}function z8e(e){return new B8e(e??"")}class H8e extends Pa{static[Jt]="PgMacaddr8Builder";constructor(s){super(s,"string","PgMacaddr8")}build(s){return new q8e(s,this.config)}}class q8e extends Dn{static[Jt]="PgMacaddr8";getSQLType(){return"macaddr8"}}function V8e(e){return new H8e(e??"")}class W8e extends Pa{static[Jt]="PgNumericBuilder";constructor(s,r,n){super(s,"string","PgNumeric"),this.config.precision=r,this.config.scale=n}build(s){return new K8e(s,this.config)}}class K8e extends Dn{static[Jt]="PgNumeric";precision;scale;constructor(s,r){super(s,r),this.precision=r.precision,this.scale=r.scale}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}}function G8e(e,s){const{name:r,config:n}=wc(e,s);return new W8e(r,n?.precision,n?.scale)}class Y8e extends Pa{static[Jt]="PgPointTupleBuilder";constructor(s){super(s,"array","PgPointTuple")}build(s){return new Q8e(s,this.config)}}class Q8e extends Dn{static[Jt]="PgPointTuple";getSQLType(){return"point"}mapFromDriverValue(s){if(typeof s=="string"){const[r,n]=s.slice(1,-1).split(",");return[Number.parseFloat(r),Number.parseFloat(n)]}return[s.x,s.y]}mapToDriverValue(s){return`(${s[0]},${s[1]})`}}class X8e extends Pa{static[Jt]="PgPointObjectBuilder";constructor(s){super(s,"json","PgPointObject")}build(s){return new Z8e(s,this.config)}}class Z8e extends Dn{static[Jt]="PgPointObject";getSQLType(){return"point"}mapFromDriverValue(s){if(typeof s=="string"){const[r,n]=s.slice(1,-1).split(",");return{x:Number.parseFloat(r),y:Number.parseFloat(n)}}return s}mapToDriverValue(s){return`(${s.x},${s.y})`}}function J8e(e,s){const{name:r,config:n}=wc(e,s);return!n?.mode||n.mode==="tuple"?new Y8e(r):new X8e(r)}function eUe(e){const s=[];for(let r=0;r<e.length;r+=2)s.push(Number.parseInt(e.slice(r,r+2),16));return new Uint8Array(s)}function b9(e,s){const r=new ArrayBuffer(8),n=new DataView(r);for(let a=0;a<8;a++)n.setUint8(a,e[s+a]);return n.getFloat64(0,!0)}function Yae(e){const s=eUe(e);let r=0;const n=s[r];r+=1;const a=new DataView(s.buffer),i=a.getUint32(r,n===1);if(r+=4,i&536870912&&(a.getUint32(r,n===1),r+=4),(i&65535)===1){const o=b9(s,r);r+=8;const l=b9(s,r);return r+=8,[o,l]}throw new Error("Unsupported geometry type")}class tUe extends Pa{static[Jt]="PgGeometryBuilder";constructor(s){super(s,"array","PgGeometry")}build(s){return new sUe(s,this.config)}}class sUe extends Dn{static[Jt]="PgGeometry";getSQLType(){return"geometry(point)"}mapFromDriverValue(s){return Yae(s)}mapToDriverValue(s){return`point(${s[0]} ${s[1]})`}}class rUe extends Pa{static[Jt]="PgGeometryObjectBuilder";constructor(s){super(s,"json","PgGeometryObject")}build(s){return new nUe(s,this.config)}}class nUe extends Dn{static[Jt]="PgGeometryObject";getSQLType(){return"geometry(point)"}mapFromDriverValue(s){const r=Yae(s);return{x:r[0],y:r[1]}}mapToDriverValue(s){return`point(${s.x} ${s.y})`}}function aUe(e,s){const{name:r,config:n}=wc(e,s);return!n?.mode||n.mode==="tuple"?new tUe(r):new rUe(r)}class iUe extends Pa{static[Jt]="PgRealBuilder";constructor(s,r){super(s,"number","PgReal"),this.config.length=r}build(s){return new oUe(s,this.config)}}class oUe extends Dn{static[Jt]="PgReal";constructor(s,r){super(s,r)}getSQLType(){return"real"}mapFromDriverValue=s=>typeof s=="string"?Number.parseFloat(s):s}function Qae(e){return new iUe(e??"")}class lUe extends Pa{static[Jt]="PgSerialBuilder";constructor(s){super(s,"number","PgSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(s){return new cUe(s,this.config)}}class cUe extends Dn{static[Jt]="PgSerial";
557getSQLType(){return"serial"}}function dUe(e){return new lUe(e??"")}class uUe extends c2{static[Jt]="PgSmallIntBuilder";constructor(s){super(s,"number","PgSmallInt")}build(s){return new mUe(s,this.config)}}class mUe extends Dn{static[Jt]="PgSmallInt";getSQLType(){return"smallint"}mapFromDriverValue=s=>typeof s=="string"?Number(s):s}function hUe(e){return new uUe(e??"")}class pUe extends Pa{static[Jt]="PgSmallSerialBuilder";constructor(s){super(s,"number","PgSmallSerial"),this.config.hasDefault=!0,this.config.notNull=!0}build(s){return new fUe(s,this.config)}}class fUe extends Dn{static[Jt]="PgSmallSerial";getSQLType(){return"smallserial"}}function gUe(e){return new pUe(e??"")}class xUe extends Pa{static[Jt]="PgTextBuilder";constructor(s,r){super(s,"string","PgText"),this.config.enumValues=r.enum}build(s){return new vUe(s,this.config)}}class vUe extends Dn{static[Jt]="PgText";enumValues=this.config.enumValues;getSQLType(){return"text"}}function Se(e,s={}){const{name:r,config:n}=wc(e,s);return new xUe(r,n)}class yUe extends bN{constructor(s,r,n){super(s,"string","PgTime"),this.withTimezone=r,this.precision=n,this.config.withTimezone=r,this.config.precision=n}static[Jt]="PgTimeBuilder";build(s){return new bUe(s,this.config)}}class bUe extends Dn{static[Jt]="PgTime";withTimezone;precision;constructor(s,r){super(s,r),this.withTimezone=r.withTimezone,this.precision=r.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function wUe(e,s={}){const{name:r,config:n}=wc(e,s);return new yUe(r,n.withTimezone??!1,n.precision)}class jUe extends bN{static[Jt]="PgTimestampBuilder";constructor(s,r,n){super(s,"date","PgTimestamp"),this.config.withTimezone=r,this.config.precision=n}build(s){return new NUe(s,this.config)}}class NUe extends Dn{static[Jt]="PgTimestamp";withTimezone;precision;constructor(s,r){super(s,r),this.withTimezone=r.withTimezone,this.precision=r.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}mapFromDriverValue=s=>new Date(this.withTimezone?s:s+"+0000");mapToDriverValue=s=>s.toISOString()}class SUe extends bN{static[Jt]="PgTimestampStringBuilder";constructor(s,r,n){super(s,"string","PgTimestampString"),this.config.withTimezone=r,this.config.precision=n}build(s){return new CUe(s,this.config)}}class CUe extends Dn{static[Jt]="PgTimestampString";withTimezone;precision;constructor(s,r){super(s,r),this.withTimezone=r.withTimezone,this.precision=r.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}function Tt(e,s={}){const{name:r,config:n}=wc(e,s);return n?.mode==="string"?new SUe(r,n.withTimezone??!1,n.precision):new jUe(r,n?.withTimezone??!1,n?.precision)}class kUe extends Pa{static[Jt]="PgUUIDBuilder";constructor(s){super(s,"string","PgUUID")}defaultRandom(){return this.default(gr`gen_random_uuid()`)}build(s){return new _Ue(s,this.config)}}class _Ue extends Dn{static[Jt]="PgUUID";getSQLType(){return"uuid"}}function PUe(e){return new kUe(e??"")}class EUe extends Pa{static[Jt]="PgVarcharBuilder";constructor(s,r){super(s,"string","PgVarchar"),this.config.length=r.length,this.config.enumValues=r.enum}build(s){return new TUe(s,this.config)}}class TUe extends Dn{static[Jt]="PgVarchar";length=this.config.length;enumValues=this.config.enumValues;getSQLType(){return this.length===void 0?"varchar":`varchar(${this.length})`}}function ct(e,s={}){const{name:r,config:n}=wc(e,s);return new EUe(r,n)}class AUe extends Pa{static[Jt]="PgBinaryVectorBuilder";constructor(s,r){super(s,"string","PgBinaryVector"),this.config.dimensions=r.dimensions}build(s){return new MUe(s,this.config)}}class MUe extends Dn{static[Jt]="PgBinaryVector";dimensions=this.config.dimensions;getSQLType(){return`bit(${this.dimensions})`}}function RUe(e,s){const{name:r,config:n}=wc(e,s);return new AUe(r,n)}class IUe extends Pa{static[Jt]="PgHalfVectorBuilder";constructor(s,r){super(s,"array","PgHalfVector"),this.config.dimensions=r.dimensions}build(s){return new OUe(s,this.config)}}class OUe extends Dn{static[Jt]="PgHalfVector";dimensions=this.config.dimensions;getSQLType(){return`halfvec(${this.dimensions})`}mapToDriverValue(s){return JSON.stringify(s)}mapFromDriverValue(s){return s.slice(1,-1).split(",").map(r=>Number.parseFloat(r))}}function DUe(e,s){const{name:r,config:n}=wc(e,s);return new IUe(r,n)}class LUe extends Pa{static[Jt]="PgSparseVectorBuilder";constructor(s,r){super(s,"string","PgSparseVector"),this.config.dimensions=r.dimensions}build(s){return new $Ue(s,this.config)}}class $Ue extends Dn{static[Jt]="PgSparseVector";dimensions=this.config.dimensions;getSQLType(){return`sparsevec(${this.dimensions})`}}
557function FUe(e,s){const{name:r,config:n}=wc(e,s);return new LUe(r,n)}class BUe extends Pa{static[Jt]="PgVectorBuilder";constructor(s,r){super(s,"array","PgVector"),this.config.dimensions=r.dimensions}build(s){return new UUe(s,this.config)}}class UUe extends Dn{static[Jt]="PgVector";dimensions=this.config.dimensions;getSQLType(){return`vector(${this.dimensions})`}mapToDriverValue(s){return JSON.stringify(s)}mapFromDriverValue(s){return s.slice(1,-1).split(",").map(r=>Number.parseFloat(r))}}function zUe(e,s){const{name:r,config:n}=wc(e,s);return new BUe(r,n)}function HUe(){return{bigint:av,bigserial:a8e,boolean:Ss,char:d8e,cidr:h8e,customType:Gae,date:vb,doublePrecision:xa,inet:S8e,integer:As,interval:E8e,json:M8e,jsonb:No,line:F8e,macaddr:z8e,macaddr8:V8e,numeric:G8e,point:J8e,geometry:aUe,real:Qae,serial:dUe,smallint:hUe,smallserial:gUe,text:Se,time:wUe,timestamp:Tt,uuid:PUe,varchar:ct,bit:RUe,halfvec:DUe,sparsevec:FUe,vector:zUe}}const ZR=Symbol.for("drizzle:PgInlineForeignKeys"),w9=Symbol.for("drizzle:EnableRLS");class X4 extends Qu{static[Jt]="PgTable";static Symbol=Object.assign({},Qu.Symbol,{InlineForeignKeys:ZR,EnableRLS:w9});[ZR]=[];[w9]=!1;[Qu.Symbol.ExtraConfigBuilder]=void 0}function qUe(e,s,r,n,a=e){const i=new X4(e,n,a),o=typeof s=="function"?s(HUe()):s,l=Object.fromEntries(Object.entries(o).map(([h,p])=>{const g=p;g.setName(h);const v=g.build(i);return i[ZR].push(...g.buildForeignKeys(v,i)),[h,v]})),c=Object.fromEntries(Object.entries(o).map(([h,p])=>{const g=p;g.setName(h);const v=g.buildExtraConfigColumn(i);return[h,v]})),d=Object.assign(i,l);return d[Qu.Symbol.Columns]=l,d[Qu.Symbol.ExtraConfigColumns]=c,r&&(d[X4.Symbol.ExtraConfigBuilder]=r),Object.assign(d,{enableRLS:()=>(d[X4.Symbol.EnableRLS]=!0,d)})}const wr=(e,s,r)=>qUe(e,s,r,void 0);class Xae{constructor(s,r){this.unique=s,this.name=r}static[Jt]="PgIndexBuilderOn";on(...s){return new Z4(s.map(r=>{if(wl(r,Ki))return r;r=r;const n=new K4(r.name,!!r.keyAsName,r.columnType,r.indexConfig);return r.indexConfig=JSON.parse(JSON.stringify(r.defaultConfig)),n}),this.unique,!1,this.name)}onOnly(...s){return new Z4(s.map(r=>{if(wl(r,Ki))return r;r=r;const n=new K4(r.name,!!r.keyAsName,r.columnType,r.indexConfig);return r.indexConfig=r.defaultConfig,n}),this.unique,!0,this.name)}using(s,...r){return new Z4(r.map(n=>{if(wl(n,Ki))return n;n=n;const a=new K4(n.name,!!n.keyAsName,n.columnType,n.indexConfig);return n.indexConfig=JSON.parse(JSON.stringify(n.defaultConfig)),a}),this.unique,!0,this.name,s)}}class Z4{static[Jt]="PgIndexBuilder";config;constructor(s,r,n,a,i="btree"){this.config={name:a,columns:s,unique:r,only:n,method:i}}concurrently(){return this.config.concurrently=!0,this}with(s){return this.config.with=s,this}where(s){return this.config.where=s,this}build(s){return new VUe(this.config,s)}}class VUe{static[Jt]="PgIndex";config;constructor(s,r){this.config={...s,table:r}}}function Rr(e){return new Xae(!1,e)}function Zd(e){return new Xae(!0,e)}const bo={INT8_MIN:-128,INT8_MAX:127,INT8_UNSIGNED_MAX:255,INT16_MIN:-32768,INT16_MAX:32767,INT16_UNSIGNED_MAX:65535,INT24_MIN:-8388608,INT24_MAX:8388607,INT24_UNSIGNED_MAX:16777215,INT32_MIN:-2147483648,INT32_MAX:2147483647,INT32_UNSIGNED_MAX:4294967295,INT48_MIN:-0x800000000000,INT48_MAX:0x7fffffffffff,INT48_UNSIGNED_MAX:0xffffffffffff,INT64_MIN:-9223372036854775808n,INT64_MAX:9223372036854775807n,INT64_UNSIGNED_MAX:18446744073709551615n};function Zo(e,s){return s.includes(e.columnType)}function WUe(e){return"enumValues"in e&&Array.isArray(e.enumValues)&&e.enumValues.length>0}const KUe=qk([it(),_r(),nf(),tY()]),GUe=qk([KUe,sY(BS()),z0(BS())]),YUe=PO(e=>e instanceof Buffer);function Zae(e,s){const r=s?.zodInstance??zhe,n=s?.coerce??{};let a;return WUe(e)&&(a=e.enumValues.length?r.enum(e.enumValues):r.string()),a||(Zo(e,["PgGeometry","PgPointTuple"])?a=r.tuple([r.number(),r.number()]):Zo(e,["PgGeometryObject","PgPointObject"])?a=r.object({x:r.number(),y:r.number()}):Zo(e,["PgHalfVector","PgVector"])?(a=r.array(r.number()),a=e.dimensions?a.length(e.dimensions):a):Zo(e,["PgLine"])?a=r.tuple([r.number(),r.number(),r.number()]):Zo(e,["PgLineABC"])?a=r.object({a:r.number(),b:r.number(),c:r.number()}):Zo(e,["PgArray"])?(a=r.array(Zae(e.baseColumn,r)),a=e.size?a.length(e.size):a):e.dataType==="array"?a=r.array(r.any()):e.dataType==="number"?a=QUe(e,r,n):e.dataType==="bigint"?a=XUe(e,r,n):e.dataType==="boolean"?a=n===!0||n.boolean?r.coerce.boolean():r.boolean():e.dataType==="date"?a=n===!0||n.date?r.coerce.date():r.date():e.dataType==="string"?a=ZUe(e,r,n):e.dataType==="json"?a=GUe:e.dataType==="custom"?a=r.any():e.dataType==="buffer"&&(a=YUe)),a||(a=r.any()),a}function QUe(e,s,r){let n=e.getSQLType().includes("unsigned"),a,i,o=!1;Zo(e,["MySqlTinyInt","SingleStoreTinyInt"])?(a=n?0:bo.INT8_MIN,i=n?bo.INT8_UNSIGNED_MAX:bo.INT8_MAX,o=!0):Zo(e,["PgSmallInt","PgSmallSerial","MySqlSmallInt","SingleStoreSmallInt"])?(a=n?0:bo.INT16_MIN,i=n?bo.INT16_UNSIGNED_MAX:bo.INT16_MAX,o=!0):Zo(e,["PgReal","MySqlFloat","MySqlMediumInt","SingleStoreMediumInt","SingleStoreFloat"])?(a=n?0:bo.INT24_MIN,i=n?bo.INT24_UNSIGNED_MAX:bo.INT24_MAX,o=Zo(e,["MySqlMediumInt","SingleStoreMediumInt"])):Zo(e,["PgInteger","PgSerial","MySqlInt","SingleStoreInt"])?(a=n?0:bo.INT32_MIN,i=n?bo.INT32_UNSIGNED_MAX:bo.INT32_MAX,o=!0):Zo(e,["PgDoublePrecision","MySqlReal","MySqlDouble","SingleStoreReal","SingleStoreDouble","SQLiteReal"])?(a=n?0:bo.INT48_MIN,i=n?bo.INT48_UNSIGNED_MAX:bo.INT48_MAX):Zo(e,["PgBigInt53","PgBigSeri
557al53","MySqlBigInt53","MySqlSerial","SingleStoreBigInt53","SingleStoreSerial","SQLiteInteger"])?(n=n||Zo(e,["MySqlSerial","SingleStoreSerial"]),a=n?0:Number.MIN_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER,o=!0):Zo(e,["MySqlYear","SingleStoreYear"])?(a=1901,i=2155,o=!0):(a=Number.MIN_SAFE_INTEGER,i=Number.MAX_SAFE_INTEGER);let l=r===!0||r?.number?s.coerce.number():s.number();return l=l.min(a).max(i),o?l.int():l}function XUe(e,s,r){const n=e.getSQLType().includes("unsigned"),a=n?0n:bo.INT64_MIN,i=n?bo.INT64_UNSIGNED_MAX:bo.INT64_MAX;return(r===!0||r?.bigint?s.coerce.bigint():s.bigint()).min(a).max(i)}function ZUe(e,s,r){if(Zo(e,["PgUUID"]))return s.string().uuid();let n,a,i=!1;Zo(e,["PgVarchar","SQLiteText"])?n=e.length:Zo(e,["MySqlVarChar","SingleStoreVarChar"])?n=e.length??bo.INT16_UNSIGNED_MAX:Zo(e,["MySqlText","SingleStoreText"])&&(e.textType==="longtext"?n=bo.INT32_UNSIGNED_MAX:e.textType==="mediumtext"?n=bo.INT24_UNSIGNED_MAX:e.textType==="text"?n=bo.INT16_UNSIGNED_MAX:n=bo.INT8_UNSIGNED_MAX),Zo(e,["PgChar","MySqlChar","SingleStoreChar"])&&(n=e.length,i=!0),Zo(e,["PgBinaryVector"])&&(a=/^[01]+$/,n=e.dimensions);let o=r===!0||r?.string?s.coerce.string():s.string();return o=a?o.regex(a):o,n&&i?o.length(n):n?o.max(n):o}function Jae(e){return Hae(e)?YBe(e):QBe(e)}function eie(e,s,r,n){const a={};for(const[i,o]of Object.entries(e)){if(!wl(o,Oj)&&!wl(o,Ki)&&!wl(o,Ki.Aliased)&&typeof o=="object"){const p=Hae(o)||GBe(o)?Jae(o):o;a[i]=eie(p,s[i]??{},r,n);continue}const l=s[i];if(l!==void 0&&typeof l!="function"){a[i]=l;continue}const c=wl(o,Oj)?o:void 0,d=c?Zae(c,n):BS(),h=typeof l=="function"?l(d):d;r.never(c)||(a[i]=h,c&&(r.nullable(c)&&(a[i]=a[i].nullable()),r.optional(c)&&(a[i]=a[i].optional())))}return Gd(a)}const JUe={never:e=>e?.generated?.type==="always"||e?.generatedIdentity?.type==="always",optional:e=>!e.notNull||e.notNull&&e.hasDefault,nullable:e=>!e.notNull},gn=(e,s)=>{const r=Jae(e);return eie(r,{},JUe)};wr("sessions",{sid:ct("sid").primaryKey(),sess:No("sess").notNull(),expire:Tt("expire").notNull()},e=>[Rr("IDX_session_expire").on(e.expire)]);const eze=wr("users",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),email:ct("email").unique(),firstName:ct("first_name"),lastName:ct("last_name"),passwordHash:ct("password_hash"),profileImageUrl:ct("profile_image_url"),disabled:Ss("disabled").default(!1),showLocation:Ss("show_location").default(!0),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()}),tze=Gae({dataType(){return"vector(512)"},toDriver(e){return`[${e.join(",")}]`},fromDriver(e){return typeof e=="string"?JSON.parse(e):e}}),tie=[5,15,30,60,240,480,720,1440],rl=wr("edge_devices",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),serialNumber:ct("serial_number",{length:16}).notNull().unique(),host:Se("host").notNull(),port:As("port").notNull().default(5e3),apiUsername:Se("api_username").notNull(),apiPassword:Se("api_password").notNull(),registeredToResellerId:ct("registered_to_reseller_id"),orderNumber:Se("order_number").notNull(),orderAttachment:Se("order_attachment"),defaultPlanId:ct("default_plan_id"),salesOrderId:ct("sales_order_id"),latitude:xa("latitude"),longitude:xa("longitude"),city:Se("city"),region:Se("region"),country:Se("country"),ipAddress:Se("ip_address"),localIp:Se("local_ip"),lanTlsFingerprint:Se("lan_tls_fingerprint"),edgeSyncApiKey:Se("edge_sync_api_key"),colorMatchingEnabled:Ss("color_matching_enabled").default(!0),useRtc:Ss("use_rtc").default(!0).notNull(),useWebRtc:Ss("use_web_rtc").default(!0).notNull(),useMse:Ss("use_mse").default(!0).notNull(),jpegFps:As("jpeg_fps").default(2).notNull(),jpegQuality:As("jpeg_quality").default(100).notNull(),forceSubStreamLive:Ss("force_sub_stream_live").default(!1).notNull(),hardStallMs:As("hard_stall_ms").default(9e4).notNull(),mseStartTimeoutMs:As("mse_start_timeout_ms").default(15e3).notNull(),connectTimeoutMs:As("connect_timeout_ms").default(1e4).notNull(),jpegDelayMs:As("jpeg_delay_ms").default(3e3).notNull(),jpegStuckMs:As("jpeg_stuck_ms").default(45e3).notNull(),debugWebRtc:Ss("debug_web_rtc").default(!1).notNull(),aiPlusEnabled:Ss("ai_plus_enabled").default(!1).notNull(),aiPlusDailyLimit:As("ai_plus_daily_limit").default(500).notNull(),includeAiPlus:Ss("include_ai_plus").default(!1).notNull(),aiConfigAssistEnabled:Ss("ai_config_assist_enabled").default(!0).notNull(),deviceOfflineAlertEnabled:Ss("device_offline_alert_enabled").default(!0).notNull(),cameraOfflineAlertEnabled:Ss("camera_offline_alert_enabled").default(!0).notNull(),resolvedAlertEnabled:Ss("resolved_alert_enabled").default(!0).notNull(),offlineDetectionMinutes:As("offline_detection_minutes").default(30).notNull(),remoteTerminalEnabled:Ss("remote_terminal_enabled").default(!1).notNull(),allowDiagnosticsIfOffline:Ss("allow_diagnostics_if_offline").default(!1).notNull(),maxCameras:As("max_cameras").default(8).notNull(),recordPreCaptureSec:As("record_pre_capture_sec").default(15).notNull(),recordPostCaptureSec:As("record_post_capture_sec").default(15).notNull(),preferLegacyCloudClip:Ss("prefer_legacy_cloud_clip").default(!0).notNull(),cloudClipDirectStream:Ss("cloud_clip_direct_stream").default(!0).notNull(),timezone:Se("timezone").default("UTC").notNull(),smartAlertsScanIntervalSeconds:As("smart_alerts_scan_interval_seconds").default(60).notNull(),smartAlertsCameraCount:As("smart_alerts_camera_count"),subStreamRolloverEnabled:Ss("sub_stream_rollover_enabled").default(!0).notNull(),subStreamRolloverIntervalMinutes:As("sub_stream_rollover_interval_minutes").default(60).notNull(),globalMotionEnabled:Ss("global_motion_enabled").default(!1).notNull(),globalMotionScope:Se("global_motion_scope").default("all").notNull(),globalMotionCameraNames:No("global_motion_camera_names").$type().notNull().default([]),globalMotionSensitivity:As("global_motion_sensitivity").default(30).notNull(),globalMotionThreshold:As("global_motion_threshold").default(20).notNull(),smartAlertsDailyAiLimit:As("smart_alerts_daily_ai_limit").default(1e3).notNull(),smartAlertsQuotaNotice:No("smart_alerts_quota_notice").$type(),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Rr("idx_edge_devices_sync_api_key").on(e.edgeSyncApiKey)]);gn(rl).omit({id:!0,registeredToResellerId:!0,orderAttachment:!0,latitude:!0,longitude:!0,city:!0,region:!0,country:!0,ipAddress:!0,colorMatchingEnabled:!0,createdAt:!0,updatedAt:!0}).extend({maxCameras:_r().int().min(1).max(128).optional(),smartAlertsQuotaNotice:Gd({date:it(),levels:z0(_r())}).nullable().optional(),smartAlertsDailyAiLimit:_r().int().min(0).max(1e5).optional(),smartAlertsScanIntervalSeconds:_r().int().min(5).max(900).optional(),offlineDetectionMinutes:_r().int().refine(e=>tie.includes(e),"Unsupported device alert detection duration").optional(),subStreamRolloverIntervalMinutes:_r().int().min(1).max(1440).optional(),globalMotionScope:Wc(["all","selected"]).optional(),globalMotionCameraNames:z0(it().regex(/^[A-Za-z0-9_-]+$/)).optional(),globalMotionSensitivity:_r().int().min(1).max(255).optional(),globalMotionThreshold:_r().int().min(10).max(50).optional()});wr("edge_recovery_jobs",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>
557rl.id,{onDelete:"cascade"}),cameraName:Se("camera_name").notNull(),startTime:xa("start_time").notNull(),endTime:xa("end_time").notNull(),payload:No("payload").$type().notNull(),status:Se("status").notNull().default("pending"),attemptCount:As("attempt_count").notNull().default(0),maxAttempts:As("max_attempts").notNull().default(5),nextAttemptAt:Tt("next_attempt_at").defaultNow(),leaseExpiresAt:Tt("lease_expires_at"),result:Se("result"),createdBy:ct("created_by"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow(),completedAt:Tt("completed_at")},e=>[Rr("idx_edge_recovery_jobs_dispatch").on(e.edgeDeviceId,e.status,e.nextAttemptAt),Rr("idx_edge_recovery_jobs_created").on(e.edgeDeviceId,e.createdAt)]);const Kb=wr("companies",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),name:Se("name").notNull(),description:Se("description"),resellerId:ct("reseller_id"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(Kb).omit({id:!0,createdAt:!0,updatedAt:!0});const Gb=wr("sites",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),companyId:ct("company_id").notNull().references(()=>Kb.id,{onDelete:"cascade"}),name:Se("name").notNull(),description:Se("description"),address:Se("address"),latitude:xa("latitude"),longitude:xa("longitude"),locationSource:ct("location_source",{length:32}),locationQuality:ct("location_quality",{length:32}),serialNumber:ct("serial_number",{length:16}).references(()=>rl.serialNumber),isOnline:Ss("is_online").default(!1),lastChecked:Tt("last_checked"),privacyEnabled:Ss("privacy_enabled").default(!1).notNull(),privacyTempSupportExpires:Tt("privacy_temp_support_expires"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Rr("idx_sites_company").on(e.companyId),Zd("uidx_sites_serial_number").on(e.serialNumber)]);gn(Gb).omit({id:!0,isOnline:!0,lastChecked:!0,latitude:!0,longitude:!0,locationSource:!0,locationQuality:!0,privacyEnabled:!0,privacyTempSupportExpires:!0,createdAt:!0,updatedAt:!0});const sze=wr("site_blueprints",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),siteId:ct("site_id").notNull().references(()=>Gb.id,{onDelete:"cascade"}),name:Se("name").notNull(),sortOrder:As("sort_order").notNull().default(0),imageKey:Se("image_key").notNull(),imageContentType:ct("image_content_type",{length:32}).notNull(),createdAt:Tt("created_at").defaultNow().notNull(),updatedAt:Tt("updated_at").defaultNow().notNull()},e=>[Rr("idx_site_blueprints_site_sort").on(e.siteId,e.sortOrder)]);wr("site_blueprint_placements",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),blueprintId:ct("blueprint_id").notNull().references(()=>sze.id,{onDelete:"cascade"}),cameraName:Se("camera_name").notNull(),x:xa("x").notNull(),y:xa("y").notNull(),createdAt:Tt("created_at").defaultNow().notNull(),updatedAt:Tt("updated_at").defaultNow().notNull()},e=>[Zd("uidx_site_blueprint_camera").on(e.blueprintId,e.cameraName)]);const rze=wr("user_roles",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull().unique(),role:Se("role").notNull().default("user"),companyId:ct("company_id").references(()=>Kb.id,{onDelete:"set null"}),isPrimary:Ss("is_primary").notNull().default(!1),permissions:No("permissions"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(rze).omit({id:!0,createdAt:!0,updatedAt:!0});const nze=wr("user_companies",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),companyId:ct("company_id").notNull().references(()=>Kb.id,{onDelete:"cascade"}),createdAt:Tt("created_at").defaultNow()});gn(nze).omit({id:!0,createdAt:!0});const aze=wr("user_sites",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),siteId:ct("site_id").notNull().references(()=>Gb.id,{onDelete:"cascade"}),createdAt:Tt("created_at").defaultNow()},e=>[Rr("idx_user_sites_user").on(e.userId)]);gn(aze).omit({id:!0,createdAt:!0});const ize=wr("distributors",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),name:Se("name").notNull(),contactName:Se("contact_name"),email:Se("email"),phone:Se("phone"),notes:Se("notes"),defaultHardwareMarkupPercent:xa("default_hardware_markup_percent").default(0).notNull(),defaultSubscriptionMarkupPercent:xa("default_subscription_markup_percent").default(0).notNull(),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(ize).omit({id:!0,createdAt:!0,updatedAt:!0});const oze=wr("reseller_profiles",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull().unique(),businessName:Se("business_name").notNull(),contactName:Se("contact_name"),email:Se("email"),phone:Se("phone"),address:Se("address"),city:Se("city"),state:Se("state"),zip:Se("zip"),notes:Se("notes"),distributorId:ct("distributor_id"),hardwareMarkupOverridePercent:xa("hardware_markup_override_percent"),subscriptionMarkupOverridePercent:xa("subscription_markup_override_percent"),hideOrdersQuotes:Ss("hide_orders_quotes").default(!1),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(oze).omit({id:!0,createdAt:!0,updatedAt:!0});const lze=wr("user_settings",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull().unique(),refreshRate:As("refresh_rate").default(30),previewCycleRate:As("preview_cycle_rate").default(5),dashboardPreviewRate:As("dashboard_preview_rate").default(10),companySortOrder:Se("company_
557sort_order").default("asc"),customCompanyOrder:Se("custom_company_order").array(),siteSortOrder:Se("site_sort_order").default("asc"),customSiteOrder:Se("custom_site_order").array(),mfaEnabled:Ss("mfa_enabled").default(!1),mfaMethod:Se("mfa_method"),mfaEmail:Se("mfa_email"),mfaPhone:Se("mfa_phone"),mfaSecret:Se("mfa_secret"),mfaVerified:Ss("mfa_verified").default(!1),autoPlayEnabled:Ss("auto_play_enabled").default(!0),demetriMode:Ss("demetri_mode").default(!1),liveMonitoringIncognito:Ss("live_monitoring_incognito").notNull().default(!1),timelineDetectionColor:Se("timeline_detection_color").default("#3b82f6"),timelineMotionColor:Se("timeline_motion_color").default("#eab308"),showSystemMetrics:Ss("show_system_metrics").default(!1),showOldestRecording:Ss("show_oldest_recording").default(!0),dashboardPreviewLayout:As("dashboard_preview_layout").default(1),classicMatrixLayout:As("classic_matrix_layout").default(9),dashboardPreviewCycling:Ss("dashboard_preview_cycling").default(!1),deviceNotificationsEnabled:Ss("device_notifications_enabled").default(!0),weeklySummaryEnabled:Ss("weekly_summary_enabled").default(!0),pushSmartAlertsOnly:Ss("push_smart_alerts_only").default(!1),maxAlertsPerDay:As("max_alerts_per_day").default(6),aiColorThreshold:As("ai_color_threshold").default(15),aiConfidenceThreshold:xa("ai_confidence_threshold").default(.48),theme:Se("theme").default("dark"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(lze).omit({id:!0,createdAt:!0,updatedAt:!0});const cze=wr("reseller_policies",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),resellerId:ct("reseller_id").notNull().unique(),enforce2fa:Ss("enforce_2fa").default(!1),locationPrivacy:Ss("location_privacy").default(!1),displayAdminAudits:Ss("display_admin_audits").default(!1),displayDbAdminAudits:Ss("display_db_admin_audits").default(!1),disableAuditing:Ss("disable_auditing").default(!1),liveMonitoringEnabled:Ss("live_monitoring_enabled").default(!0).notNull(),liveMonitorSuperadmins:Ss("live_monitor_superadmins").default(!1).notNull(),liveMonitorAdmins:Ss("live_monitor_admins").default(!0).notNull(),liveMonitorLiveView:Ss("live_monitor_live_view").default(!0).notNull(),liveMonitorPlayback:Ss("live_monitor_playback").default(!0).notNull(),liveMonitorDeviceChanges:Ss("live_monitor_device_changes").default(!0).notNull(),liveMonitorAiTerms:Ss("live_monitor_ai_terms").default(!0).notNull(),liveMonitorOther:Ss("live_monitor_other").default(!0).notNull(),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(cze).omit({id:!0,createdAt:!0,updatedAt:!0});const dze=wr("audit_events",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),eventType:Se("event_type").notNull(),actorUserId:ct("actor_user_id"),actorRole:Se("actor_role"),actorEmail:Se("actor_email"),actorName:Se("actor_name"),companyId:ct("company_id"),siteId:ct("site_id"),edgeDeviceId:ct("edge_device_id"),cameras:Se("cameras").array(),ipAddress:Se("ip_address"),summary:Se("summary"),details:No("details").$type().default({}),durationMs:As("duration_ms"),createdAt:Tt("created_at").defaultNow().notNull()},e=>[Rr("idx_audit_events_created").on(e.createdAt),Rr("idx_audit_events_type_created").on(e.eventType,e.createdAt),Rr("idx_audit_events_actor").on(e.actorUserId),Rr("idx_audit_events_company").on(e.companyId),Rr("idx_audit_events_site").on(e.siteId)]);gn(dze).omit({id:!0,createdAt:!0});const uze=wr("local_recording_daily",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull(),siteId:ct("site_id"),recordingDate:vb("recording_date").notNull(),bytes:av("bytes",{mode:"number"}).notNull().default(0),updatedAt:Tt("updated_at").defaultNow().notNull()},e=>[Zd("idx_local_recording_daily_unique").on(e.edgeDeviceId,e.recordingDate),Rr("idx_local_recording_daily_date").on(e.recordingDate)]);gn(uze).omit({id:!0,updatedAt:!0});const mze=wr("email_settings",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),templateKey:Se("template_key").notNull().unique(),subject:Se("subject").notNull(),headerHtml:Se("header_html"),bodyHtml:Se("body_html").notNull(),footerHtml:Se("footer_html"),fromName:Se("from_name"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(mze).omit({id:!0,createdAt:!0,updatedAt:!0});wr("trusted_devices",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),deviceToken:ct("device_token").notNull().unique(),ipAddress:Se("ip_address"),userAgent:Se("user_agent"),browser:Se("browser"),deviceType:Se("device_type"),city:Se("city"),region:Se("region"),country:Se("country"),expiresAt:Tt("expires_at").notNull(),createdAt:Tt("created_at").defaultNow()});const hze=wr("api_settings",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),settingKey:Se("setting_key").notNull().unique(),settingValue:Se("setting_value").notNull(),label:Se("label").notNull(),description:Se("description"),enabled:Ss("enabled").default(!0).notNull(),updatedAt:Tt("updated_at").defaultNow()});wr("places_autocomplete_usage",{userId:ct("user_id").primaryKey().references(()=>
557eze.id,{onDelete:"cascade"}),minuteStartedAt:Tt("minute_started_at",{withTimezone:!0}).notNull(),minuteCount:As("minute_count").notNull(),dayStartedAt:Tt("day_started_at",{withTimezone:!0}).notNull(),dayCount:As("day_count").notNull()});gn(hze).omit({id:!0,updatedAt:!0});const pze=wr("cloud_storage_settings",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),syncEnabled:Ss("sync_enabled").default(!1).notNull(),syncMode:Se("sync_mode").default("continuous").notNull(),syncProvider:Se("sync_provider").default("server").notNull(),syncIntervalMinutes:As("sync_interval_minutes").default(1).notNull(),retentionDays:As("retention_days").default(14).notNull(),clipDurationSeconds:As("clip_duration_seconds").default(180).notNull(),gcsBucketName:Se("gcs_bucket_name"),storageClass:Se("storage_class").default("STANDARD").notNull(),lastSyncAt:Tt("last_sync_at"),lastEdgeSyncAt:Tt("last_edge_sync_at"),avgUploadBytesPerSec:As("avg_upload_bytes_per_sec"),lastBandwidthCheck:Tt("last_bandwidth_check"),bandwidthStatus:Se("bandwidth_status"),edgeSyncScriptVersion:Se("edge_sync_script_version"),recordingsDiscovery:No("recordings_discovery").$type(),segmentTempCleanup:No("segment_temp_cleanup").$type(),hideLocalRecordings:Ss("hide_local_recordings").default(!1).notNull(),hybridRetrievalEnabled:Ss("hybrid_retrieval_enabled").default(!1).notNull(),distinguishHybridSources:Ss("distinguish_hybrid_sources").default(!1).notNull(),hideHybridRetrievalPreferences:Ss("hide_hybrid_retrieval_preferences").default(!1).notNull(),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(pze).omit({id:!0,lastSyncAt:!0,lastEdgeSyncAt:!0,avgUploadBytesPerSec:!0,lastBandwidthCheck:!0,bandwidthStatus:!0,edgeSyncScriptVersion:!0,recordingsDiscovery:!0,segmentTempCleanup:!0,createdAt:!0,updatedAt:!0});const fze=wr("cloud_recordings",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").references(()=>rl.id,{onDelete:"set null"}),serialNumber:Se("serial_number"),siteId:ct("site_id").references(()=>Gb.id,{onDelete:"set null"}),frigateEventId:Se("frigate_event_id"),cameraName:Se("camera_name").notNull(),recordingType:Se("recording_type").notNull(),label:Se("label"),score:xa("score"),startTime:Tt("start_time").notNull(),endTime:Tt("end_time"),clipPath:Se("clip_path"),thumbnailPath:Se("thumbnail_path"),snapshotPath:Se("snapshot_path"),detectionIds:Se("detection_ids").array(),fileSize:As("file_size"),clipDurationSec:xa("clip_duration_sec"),parentEventId:Se("parent_event_id"),chunkIndex:As("chunk_index"),chunkTotal:As("chunk_total"),deletedAt:Tt("deleted_at"),cloudPlayable:Ss("cloud_playable").default(!1).notNull(),createdAt:Tt("created_at").defaultNow()},e=>[Zd("cloud_recordings_unique_event").on(e.edgeDeviceId,e.frigateEventId).where(gr`frigate_event_id IS NOT NULL`),Rr("idx_cloud_recordings_edge_device_start").on(e.edgeDeviceId,e.startTime),Rr("idx_cloud_recordings_site_start").on(e.siteId,e.startTime),Rr("idx_cloud_recordings_camera").on(e.edgeDeviceId,e.cameraName,e.startTime),Rr("idx_cloud_recordings_label").on(e.edgeDeviceId,e.label),Rr("idx_cloud_recordings_parent").on(e.edgeDeviceId,e.parentEventId)]);gn(fze).omit({id:!0,createdAt:!0});wr("cloud_recordings_daily",{edgeDeviceId:ct("edge_device_id").notNull(),day:vb("day").notNull(),totalSize:av("total_size",{mode:"number"}).notNull().default(0),videoCount:As("video_count").notNull().default(0),updatedAt:Tt("updated_at").defaultNow().notNull()},e=>[Zd("idx_cloud_recordings_daily_unique").on(e.edgeDeviceId,e.day)]);wr("cloud_storage_audit_daily",{generation:As("generation").notNull(),day:vb("day").notNull(),siteKey:ct("site_key").notNull(),totalBytes:av("total_bytes",{mode:"number"}).notNull().default(0),recordingCount:av("recording_count",{mode:"number"}).notNull().default(0)},e=>[Zd("idx_cloud_storage_audit_daily_key").on(e.generation,e.day,e.siteKey)]);wr("cloud_storage_audit_state",{id:As("id").primaryKey(),publishedGeneration:As("published_generation"),publishedAt:Tt("published_at"),buildingGeneration:As("building_generation"),nextDay:vb("next_day"),throughDay:vb("through_day"),nextRecordingTime:Tt("next_recording_time"),nextRecordingId:ct("next_recording_id")});const gze=wr("cloud_segments",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").references(()=>rl.id,{onDelete:"set null"}),serialNumber:Se("serial_number"),cameraName:Se("camera_name").notNull(),startTime:xa("start_time").notNull(),endTime:xa("end_time").notNull(),durationSec:xa("duration_sec").notNull(),gcsPath:Se("gcs_path").notNull(),fileSize:As("file_size").notNull(),motion:xa("motion").default(0),objects:As("objects").default(0),createdAt:Tt("created_at").defaultNow()},e=>[Zd("idx_cloud_segments_unique").on(e.edgeDeviceId,e.cameraName,e.startTime),Rr("idx_cloud_segments_device_start").on(e.edgeDeviceId,e.startTime)]);gn(gze).omit({id:!0,createdAt:!0});const xze=wr("camera_name_mappings",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>
557rl.id,{onDelete:"cascade"}),oldName:Se("old_name").notNull(),currentName:Se("current_name").notNull(),renamedAt:Tt("renamed_at").defaultNow()});gn(xze).omit({id:!0,renamedAt:!0});const vze=wr("camera_aliases",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),frigateName:Se("frigate_name").notNull(),displayName:Se("display_name").notNull(),qcBrand:Se("qc_brand"),qcModel:Se("qc_model"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Zd("idx_camera_aliases_unique").on(e.edgeDeviceId,e.frigateName)]);gn(vze).omit({id:!0,createdAt:!0,updatedAt:!0});const sie=wr("subscription_plans",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),scope:Se("scope").notNull(),ownerResellerId:ct("owner_reseller_id"),storageType:Se("storage_type").notNull().default("local"),retentionDays:As("retention_days"),recordingMode:Se("recording_mode"),interval:Se("interval").notNull(),pricePerCamera:As("price_per_camera").notNull(),currency:Se("currency").notNull().default("usd"),active:Ss("active").default(!0).notNull(),stripePriceId:Se("stripe_price_id"),stripeProductId:Se("stripe_product_id"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(sie).omit({id:!0,stripePriceId:!0,stripeProductId:!0,createdAt:!0,updatedAt:!0});const rie=wr("subscriptions",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),scope:Se("scope").notNull(),planId:ct("plan_id").notNull().references(()=>sie.id),resellerId:ct("reseller_id").notNull(),companyId:ct("company_id").references(()=>Kb.id,{onDelete:"set null"}),siteId:ct("site_id").references(()=>Gb.id,{onDelete:"set null"}),edgeDeviceId:ct("edge_device_id").references(()=>rl.id,{onDelete:"set null"}),siteName:Se("site_name"),companyName:Se("company_name"),serialNumber:Se("serial_number"),cameraCount:As("camera_count"),interval:Se("interval").notNull(),status:Se("status").notNull().default("active"),billingMode:Se("billing_mode").notNull().default("manual"),stripeSubscriptionId:Se("stripe_subscription_id"),stripeCustomerId:Se("stripe_customer_id"),activationDate:Tt("activation_date").defaultNow(),canceledAt:Tt("canceled_at"),includeAiPlus:Ss("include_ai_plus").default(!1).notNull(),nextInvoiceAt:Tt("next_invoice_at"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Rr("idx_subscriptions_reseller").on(e.resellerId),Rr("idx_subscriptions_site").on(e.siteId)]);gn(rie).omit({id:!0,stripeSubscriptionId:!0,stripeCustomerId:!0,canceledAt:!0,createdAt:!0,updatedAt:!0});const yze=wr("invoices",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),scope:Se("scope").notNull(),subscriptionId:ct("subscription_id").references(()=>rie.id,{onDelete:"set null"}),resellerId:ct("reseller_id").notNull(),companyId:ct("company_id").references(()=>Kb.id,{onDelete:"set null"}),siteId:ct("site_id").references(()=>Gb.id,{onDelete:"set null"}),amount:As("amount").notNull(),currency:Se("currency").notNull().default("usd"),cameraCount:As("camera_count"),interval:Se("interval").notNull(),periodStart:Tt("period_start").notNull(),periodEnd:Tt("period_end").notNull(),status:Se("status").notNull().default("draft"),stripeInvoiceId:Se("stripe_invoice_id"),paidAt:Tt("paid_at"),dueDate:Tt("due_date"),createdAt:Tt("created_at").defaultNow()},e=>[Rr("idx_invoices_reseller").on(e.resellerId)]);gn(yze).omit({id:!0,stripeInvoiceId:!0,paidAt:!0,createdAt:!0});const bze=wr("reseller_billing_settings",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),resellerId:ct("reseller_id").notNull().unique(),billingMode:Se("billing_mode").notNull().default("manual"),stripeAccountId:Se("stripe_account_id"),stripeOnboardingComplete:Ss("stripe_onboarding_complete").default(!1),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(bze).omit({id:!0,stripeAccountId:!0,stripeOnboardingComplete:!0,createdAt:!0,updatedAt:!0});const wze=wr("device_health_status",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>
557rl.id,{onDelete:"cascade"}),cameraName:Se("camera_name"),cameraDisplayName:Se("camera_display_name"),isOnline:Ss("is_online").default(!0),lastSeen:Tt("last_seen"),lastStatusChange:Tt("last_status_change"),lastChecked:Tt("last_checked"),offlineCandidateSince:Tt("offline_candidate_since"),statusMessage:Se("status_message"),cameraFps:Qae("camera_fps"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Rr("idx_device_health_device").on(e.edgeDeviceId),Rr("idx_device_health_device_camera").on(e.edgeDeviceId,e.cameraName)]);gn(wze).omit({id:!0,createdAt:!0,updatedAt:!0});const jze=wr("device_notification_log",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),alertDate:Se("alert_date").notNull(),alertCount:As("alert_count").default(0),lastAlertAt:Tt("last_alert_at"),lastRecoveryAlertAt:Tt("last_recovery_alert_at"),lastWeeklySummaryAt:Tt("last_weekly_summary_at"),createdAt:Tt("created_at").defaultNow()},e=>[Rr("idx_notification_log_user_date").on(e.userId,e.alertDate)]);gn(jze).omit({id:!0,createdAt:!0});const Nze=wr("device_alert_history",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),alertType:Se("alert_type").notNull(),recipientEmail:Se("recipient_email").notNull(),subject:Se("subject").notNull(),devicesSummary:Se("devices_summary").notNull(),sentAt:Tt("sent_at").defaultNow()},e=>[Rr("idx_alert_history_user").on(e.userId),Rr("idx_alert_history_sent").on(e.sentAt)
557]);gn(Nze).omit({id:!0,sentAt:!0});const Sze=wr("multi_live_views",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),name:Se("name").notNull(),layout:As("layout").notNull().default(4),cameras:Se("cameras").notNull().default("[]"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(Sze).omit({id:!0,createdAt:!0,updatedAt:!0});const Cze=wr("discovered_cameras",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),ipAddress:Se("ip_address").notNull(),port:As("port").default(80),onvifUrl:Se("onvif_url"),manufacturer:Se("manufacturer"),model:Se("model"),hardwareId:Se("hardware_id"),firmwareVersion:Se("firmware_version"),name:Se("name"),macAddress:Se("mac_address"),rtspMainStream:Se("rtsp_main_stream"),rtspSubStream:Se("rtsp_sub_stream"),channels:No("channels").default([]),resolution:Se("resolution"),encoding:Se("encoding"),status:Se("status").notNull().default("discovered"),probeError:Se("probe_error"),ptzCapable:Ss("ptz_capable").default(!1).notNull(),ptzProfileToken:Se("ptz_profile_token"),ptzPresets:No("ptz_presets").default([]),onvifUsername:Se("onvif_username"),onvifPassword:Se("onvif_password"),lastSeenAt:Tt("last_seen_at").defaultNow(),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Rr("idx_discovered_cameras_device").on(e.edgeDeviceId),Rr("idx_discovered_cameras_device_ip").on(e.edgeDeviceId,e.ipAddress)]);gn(Cze).omit({id:!0,createdAt:!0,updatedAt:!0});const kze=wr("edge_camera_ptz",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),channelName:Se("channel_name").notNull(),onvifHost:Se("onvif_host").notNull(),onvifPort:As("onvif_port").default(80).notNull(),ptzCapable:Ss("ptz_capable").default(!1).notNull(),ptzProfileToken:Se("ptz_profile_token"),ptzPresets:No("ptz_presets").default([]),ptzUserEnabled:Ss("ptz_user_enabled").default(!1).notNull(),ptzLastTestAt:Tt("ptz_last_test_at"),ptzLastTestResult:Se("ptz_last_test_result"),ptzLastTestMessage:Se("ptz_last_test_message"),onvifUsername:Se("onvif_username"),onvifPassword:Se("onvif_password"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Zd("uq_edge_camera_ptz_device_channel").on(e.edgeDeviceId,e.channelName)]);gn(kze).omit({id:!0,createdAt:!0,updatedAt:!0});const _ze=wr("camera_stream_health",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),channelName:Se("channel_name").notNull(),mainStreamOk:Ss("main_stream_ok"),subStreamOk:Ss("sub_stream_ok"),recordingSource:Se("recording_source").default("main").notNull(),detectSource:Se("detect_source"),prioritizeStorage:Ss("prioritize_storage").default(!1).notNull(),streamShifting:Ss("stream_shifting").default(!1).notNull(),mainStreamUrl:Se("main_stream_url"),subStreamUrl:Se("sub_stream_url"),lastFailureReason:Se("last_failure_reason"),mainWidth:As("main_width"),mainHeight:As("main_height"),subWidth:As("sub_width"),subHeight:As("sub_height"),resolutionStatus:Se("resolution_status"),resolutionReason:Se("resolution_reason"),recordDisabledByResolution:Ss("record_disabled_by_resolution").default(!1).notNull(),lastCheckedAt:Tt("last_checked_at"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Zd("uq_camera_stream_health_device_channel").on(e.edgeDeviceId,e.channelName)]);gn(_ze).omit({id:!0,createdAt:!0,updatedAt:!0});const Pze=wr("reseller_applications",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),status:Se("status").notNull().default("pending"),companyName:Se("company_name").notNull(),principalContact:Se("principal_contact").notNull(),title:Se("title"),principalPhone:Se("principal_phone").notNull(),billingEmail:Se("billing_email").notNull(),federalTaxId:Se("federal_tax_id"),addressLine1:Se("address_line1").notNull(),addressLine2:Se("address_line2"),city:Se("city").notNull(),state:Se("state").notNull(),postalCode:Se("postal_code").notNull(),country:Se("country").notNull().default("United States"),techFirstName:Se("tech_first_name").notNull(),techLastName:Se("tech_last_name").notNull(),techEmail:Se("tech_email").notNull(),techPhone:Se("tech_phone"),billingFirstName:Se("billing_first_name"),billingLastName:Se("billing_last_name"),billingContactEmail:Se("billing_contact_email"),billingPhone:Se("billing_phone"),passwordHash:Se("password_hash"),acceptedTerms:Ss("accepted_terms").notNull().default(!1),acceptedNda:Ss("accepted_nda").notNull().default(!1),signature:Se("signature"),reviewedBy:ct("reviewed_by"),reviewedAt:Tt("reviewed_at"),rejectionReason:Se("rejection_reason"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(Pze).omit({id:!0,status:!0,reviewedBy:!0,reviewedAt:!0,rejectionReason:!0,createdAt:!0,updatedAt:!0});const Eze=wr("support_tickets",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),ticketType:ct("ticket_type",{length:50}).notNull(),name:Se("name").notNull(),business:Se("business").notNull(),phone:Se("phone").notNull(),email:Se("email").notNull(),status:ct("status",{length:20}).notNull().default("new"),footageDateFrom:Se("footage_date_from"),footageDateTo:Se("footage_date_to"),footageTimeFrom:Se("footage_time_from"),footageTimeTo:Se("footage_time_to"),soOrderNumber:Se("so_order_number"),edgeSerialNumber:Se("edge_serial_number"),attachmentPath:Se("attachment_path"),attachmentFilename:Se("attachment_filename"),attachmentPaths:Se("attachment_paths"),attachmentFilenames:Se("attachment_filenames"),description:Se("description"),internalNotes:Se("internal_notes"),assignedTo:Se("assigned_to"),closedAt:Tt("closed_at"),closedBy:Se("closed_by"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()});gn(Eze).omit({id:!0,status:!0,internalNotes:!0,assignedTo:!0,attachmentPath:!0,attachmentFilename:!0,attachmentPaths:!0,attachmentFilenames:!0,closedAt:!0,closedBy:!0,createdAt:!0,updatedAt:!0});const Gv=["camera-discovery","camera-names","camera-configuration","import-export","live-streaming","record-options","system-time","network-settings","network-stats","cloud-storage","ai-detection","ai-plus","faces-people","device-alerts","smart-alerts","privacy"],U1=["camera-names","faces-people","device-alerts","smart-alerts","privacy"];Wc(Gv);const Tze=wr("device_user_permissions",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),edgeDeviceId:ct("edge_device_id").notNull().references(()=>
557rl.id,{onDelete:"cascade"}),restrictedCameras:Se("restricted_cameras").array().default([]),audioRestricted:Ss("audio_restricted").default(!1).notNull(),downloadRestricted:Ss("download_restricted").default(!1).notNull(),ptzAllowed:Ss("ptz_allowed").default(!1).notNull(),menuPermissions:Se("menu_permissions").array(),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Zd("idx_device_user_perm_unique").on(e.userId,e.edgeDeviceId),Rr("idx_device_user_perm_device").on(e.edgeDeviceId)]);wr("ptz_command_log",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull(),cameraName:Se("camera_name").notNull(),userId:ct("user_id").notNull(),action:Se("action").notNull(),params:No("params").default({}),commandId:ct("command_id"),status:Se("status").notNull().default("pending"),result:Se("result"),createdAt:Tt("created_at").defaultNow().notNull(),completedAt:Tt("completed_at")},e=>[Rr("idx_ptz_log_device_created").on(e.edgeDeviceId,e.createdAt),Rr("idx_ptz_log_command").on(e.commandId)]);gn(Tze).omit({id:!0,createdAt:!0,updatedAt:!0});wr("ai_plus_usage",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),searchDate:Se("search_date").notNull(),engine:ct("engine",{length:16}).default("openai").notNull(),searchCount:As("search_count").default(0).notNull(),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Zd("idx_ai_plus_usage_unique").on(e.userId,e.edgeDeviceId,e.searchDate,e.engine),Rr("idx_ai_plus_usage_device_date").on(e.edgeDeviceId,e.searchDate)]);const ZD=wr("person_labels",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),name:Se("name").notNull(),matchThreshold:xa("match_threshold").default(.6),createdAt:Tt("created_at").defaultNow().notNull()},e=>[Zd("idx_person_labels_unique_name").on(e.edgeDeviceId,gr`lower(${e.name})`),Rr("idx_person_labels_device").on(e.edgeDeviceId)]);gn(ZD).omit({id:!0,createdAt:!0});const nie=wr("person_label_images",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),personLabelId:ct("person_label_id").notNull().references(()=>ZD.id,{onDelete:"cascade"}),objectPath:Se("object_path").notNull(),thumbnailPath:Se("thumbnail_path"),width:As("width"),height:As("height"),embeddingError:Se("embedding_error"),createdAt:Tt("created_at").defaultNow().notNull()},e=>[Rr("idx_person_label_images_label").on(e.personLabelId)]);gn(nie).omit({id:!0,createdAt:!0});const Aze=wr("person_label_embeddings",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),imageId:ct("image_id").notNull().references(()=>nie.id,{onDelete:"cascade"}),personLabelId:ct("person_label_id").notNull().references(()=>ZD.id,{onDelete:"cascade"}),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),embedding:tze("embedding").notNull(),model:Se("model").notNull(),score:xa("score"),embeddedAt:Tt("embedded_at").defaultNow().notNull()},e=>[Zd("idx_ple_image_unique").on(e.imageId),Rr("idx_ple_label").on(e.personLabelId),Rr("idx_ple_device").on(e.edgeDeviceId)]);gn(Aze).omit({id:!0,embeddedAt:!0});wr("edge_quotes",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),ownerUserId:ct("owner_user_id").notNull(),projectName:Se("project_name").notNull(),customerName:Se("customer_name"),customerEmail:Se("customer_email"),cameraCount:As("camera_count").notNull(),storageType:ct("storage_type",{length:16}).notNull(),resolutionTier:ct("resolution_tier",{length:16}),recordingMode:ct("recording_mode",{length:16}),cloudRetentionDays:As("cloud_retention_days"),localRetentionDays:As("local_retention_days"),remoteMonitoring:Ss("remote_monitoring").default(!1).notNull(),smartAlerts:Ss("smart_alerts").default(!1).notNull(),smartAlertsCameraCount:As("smart_alerts_camera_count"),lineItems:No("line_items").notNull(),oneTimeTotal:xa("one_time_total").notNull(),monthlyTotal:xa("monthly_total").notNull(),status:ct("status",{length:16}).notNull().default("new"),lastEmailedAt:Tt("last_emailed_at"),lastEmailedTo:Se("last_emailed_to"),businessName:Se("business_name"),orderNumber:Se("order_number").notNull().unique(),discountPercent:xa("discount_percent").default(0).notNull(),discountScope:ct("discount_scope",{length:16}).default("none").notNull(),promoCode:Se("promo_code"),promoDiscountPercent:xa("promo_discount_percent"),billingFrequency:ct("billing_frequency",{length:16}).default("monthly").notNull(),distributorHardwareMarkupPercent:xa("distributor_hardware_markup_percent").default(0).notNull(),distributorSubscriptionMarkupPercent:xa("distributor_subscription_markup_percent").default(0).notNull(),msrpEnabled:Ss("msrp_enabled").default(!1).notNull(),msrpHardwareMarkupPercent:xa("msrp_hardware_markup_percent").default(50).notNull(),msrpSubscriptionMarkupPercent:xa("msrp_
557subscription_markup_percent").default(100).notNull(),markupSource:ct("markup_source",{length:16}),markupDistributorId:ct("markup_distributor_id"),currency:ct("currency",{length:8}).default("USD").notNull(),fxRate:xa("fx_rate"),fxAsOf:Tt("fx_as_of"),shipCountry:ct("ship_country",{length:8}),shipPostalCode:ct("ship_postal_code",{length:24}),shipService:ct("ship_service",{length:8}),shipBusinessName:Se("ship_business_name"),shipAttnName:Se("ship_attn_name"),shipAddress1:Se("ship_address1"),shipAddress2:Se("ship_address2"),shipCity:Se("ship_city"),shipState:ct("ship_state",{length:32}),shippingAmount:xa("shipping_amount"),shippingAmountOverride:xa("shipping_amount_override"),shippingOverrideReason:Se("shipping_override_reason"),activatedAt:Tt("activated_at"),canceledAt:Tt("canceled_at"),createdAt:Tt("created_at").defaultNow(),updatedAt:Tt("updated_at").defaultNow()},e=>[Rr("idx_edge_quotes_owner").on(e.ownerUserId),Rr("idx_edge_quotes_created").on(e.createdAt),Rr("idx_edge_quotes_status").on(e.status)]);wr("promo_codes",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),code:Se("code").notNull().unique(),discountPercent:xa("discount_percent").notNull(),scope:ct("scope",{length:16}).default("both").notNull(),expiresAt:Tt("expires_at"),notes:Se("notes"),createdByUserId:ct("created_by_user_id").notNull(),createdAt:Tt("created_at").defaultNow()});const Mze=wr("playback_telemetry",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").references(()=>rl.id,{onDelete:"cascade"}),siteId:ct("site_id"),userId:ct("user_id"),eventId:Se("event_id"),camera:Se("camera"),ttffMs:As("ttff_ms"),hlsErrorCount:As("hls_error_count").default(0).notNull(),hlsFatalErrorCount:As("hls_fatal_error_count").default(0).notNull(),stallCount:As("stall_count").default(0).notNull(),totalStallMs:As("total_stall_ms").default(0).notNull(),seekCount:As("seek_count").default(0).notNull(),fallbackUsed:Ss("fallback_used").default(!1).notNull(),finalSource:ct("final_source",{length:16}),playbackFailed:Ss("playback_failed").default(!1).notNull(),sessionDurationMs:As("session_duration_ms").default(0).notNull(),createdAt:Tt("created_at").defaultNow().notNull()},e=>[Rr("idx_playback_telemetry_device_created").on(e.edgeDeviceId,e.createdAt),Rr("idx_playback_telemetry_created").on(e.createdAt)]);gn(Mze).omit({id:!0,createdAt:!0});wr("password_reset_tokens",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),token:ct("token",{length:128}).notNull().unique(),expiresAt:Tt("expires_at").notNull(),usedAt:Tt("used_at"),createdAt:Tt("created_at").defaultNow()});const Rze=wr("alert_groups",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),name:Se("name").notNull(),channels:No("channels").$type().notNull().default({sms:!0,email:!0,push:!0}),recipients:No("recipients").$type().notNull().default([]),createdBy:ct("created_by"),createdAt:Tt("created_at").defaultNow().notNull(),updatedAt:Tt("updated_at").defaultNow().notNull()},e=>[Rr("idx_alert_groups_device").on(e.edgeDeviceId)]);gn(Rze).omit({id:!0,createdAt:!0,updatedAt:!0});const aie=wr("smart_alert_rules",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),name:Se("name").notNull(),enabled:Ss("enabled").notNull().default(!0),triggerType:ct("trigger_type",{length:16}).notNull(),triggerConfig:No("trigger_config").$type().notNull().default({}),scheduleMode:ct("schedule_mode",{length:16}).notNull().default("always"),scheduleStart:Se("schedule_start"),scheduleEnd:Se("schedule_end"),scheduleDays:As("schedule_days").array(),scheduleTimezone:Se("schedule_timezone"),cameraScope:ct("camera_scope",{length:16}).notNull().default("all"),cameras:Se("cameras").array(),cooldownSeconds:As("cooldown_seconds").notNull().default(60),aiEvaluationIntervalSeconds:As("ai_evaluation_interval_seconds").notNull().default(60),lastEvaluatedAt:No("last_evaluated_at").$type().notNull().default({}),maxAlertsPerMinute:As("max_alerts_per_minute").notNull().default(0),alertGroupIds:Se("alert_group_ids").array().notNull().default(gr`ARRAY[]::text[]`),lastFiredAt:No("last_fired_at").$type().notNull().default({}),createdBy:ct("created_by"),createdAt:Tt("created_at").defaultNow().notNull(),updatedAt:Tt("updated_at").defaultNow().notNull()},e=>[Rr("idx_smart_alert_rules_device_enabled").on(e.edgeDeviceId,e.enabled)]);gn(aie).omit({id:!0,createdAt:!0,updatedAt:!0,lastFiredAt:!0,lastEvaluatedAt:!0}).extend({maxAlertsPerMinute:_r().int().min(0).max(60).optional(),cooldownSeconds:_r().int().min(5).max(3600).optional(),aiEvaluationIntervalSeconds:_r().int().min(30).max(3600).optional()});const Ize=wr("push_subscriptions",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),endpoint:Se("endpoint").notNull().unique(),p256dh:Se("p256dh").notNull(),auth:Se("auth").notNull(),ua:Se("ua"),vapidKey:Se("vapid_key"),createdAt:Tt("created_at").defaultNow().notNull(),lastSeenAt:Tt("last_seen_at").defaultNow().notNull()},e=>[Rr("idx_push_subs_user").on(e.userId)]);gn(Ize).omit({id:!0,createdAt:!0,lastSeenAt:!0});wr("smart_alert_events",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),ruleId:ct("rule_id").notNull().references(()=>
557aie.id,{onDelete:"cascade"}),edgeDeviceId:ct("edge_device_id").notNull().references(()=>rl.id,{onDelete:"cascade"}),cameraName:Se("camera_name").notNull(),matchedAt:Tt("matched_at").defaultNow().notNull(),eventSource:ct("event_source",{length:16}).notNull(),frigateEventId:Se("frigate_event_id"),recordingId:ct("recording_id"),payload:No("payload").$type().notNull().default({}),notifiedChannels:No("notified_channels").$type().notNull().default({sms:[],email:[],push:[]}),notifyError:Se("notify_error"),status:ct("status",{length:16}).notNull().default("not_reviewed"),reviewedByUserId:ct("reviewed_by_user_id"),reviewedAt:Tt("reviewed_at"),markedCriticalByUserId:ct("marked_critical_by_user_id"),markedCriticalAt:Tt("marked_critical_at")},e=>[Rr("idx_smart_alert_events_rule_time").on(e.ruleId,e.matchedAt),Rr("idx_smart_alert_events_device_time").on(e.edgeDeviceId,e.matchedAt),Rr("idx_smart_alert_events_status").on(e.status)]);wr("smart_alert_ai_usage",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),ruleId:ct("rule_id"),edgeDeviceId:ct("edge_device_id").notNull(),cameraName:Se("camera_name").notNull(),frigateEventId:Se("frigate_event_id"),evaluatedAt:Tt("evaluated_at").defaultNow().notNull(),conditionType:ct("condition_type",{length:16}).notNull().default("action"),model:ct("model",{length:64}).notNull(),matched:Ss("matched").notNull().default(!1),alerted:Ss("alerted").notNull().default(!1),inputTokens:As("input_tokens"),outputTokens:As("output_tokens"),estimatedCostMicros:As("estimated_cost_micros"),error:Se("error")},e=>[Rr("idx_smart_alert_ai_usage_device_time").on(e.edgeDeviceId,e.evaluatedAt)]);const Oze=wr("blog_posts",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),title:Se("title").notNull(),slug:Se("slug").notNull().unique(),excerpt:Se("excerpt").notNull(),content:Se("content").notNull(),category:Se("category").notNull().default("Industry News"),sourceUrl:Se("source_url"),sourceTitle:Se("source_title"),heroImageUrl:Se("hero_image_url"),heroImageAlt:Se("hero_image_alt"),seoTitle:Se("seo_title"),metaDescription:Se("meta_description"),keywords:Se("keywords").array(),faqJson:No("faq_json").$type(),status:ct("status",{length:16}).notNull().default("draft"),publishedAt:Tt("published_at"),createdAt:Tt("created_at").defaultNow().notNull(),updatedAt:Tt("updated_at").defaultNow().notNull()},e=>[Rr("idx_blog_posts_status_published").on(e.status,e.publishedAt),Rr("idx_blog_posts_slug").on(e.slug)]);gn(Oze).omit({id:!0,createdAt:!0,updatedAt:!0});const Dze=wr("blog_feeds",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),label:Se("label").notNull(),url:Se("url").notNull().unique(),enabled:Ss("enabled").notNull().default(!0),createdAt:Tt("created_at").defaultNow().notNull()});gn(Dze).omit({id:!0,createdAt:!0}).extend({label:it().min(1).max(120),url:it().url().max(2048)});const Lze=wr("video_exports",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),status:Se("status").notNull().default("queued"),format:Se("format").notNull().default("mp4"),combine:Ss("combine").notNull().default(!1),source:Se("source").notNull().default("cloud"),itemCount:As("item_count").notNull().default(0),cloudBytes:av("cloud_bytes",{mode:"number"}).notNull().default(0),totalBytes:av("total_bytes",{mode:"number"}).notNull().default(0),resultObjectPath:Se("result_object_path"),fileName:Se("file_name"),error:Se("error"),scheduleId:ct("schedule_id"),items:No("items").$type().default([]),createdAt:Tt("created_at").defaultNow().notNull(),completedAt:Tt("completed_at"),expiresAt:Tt("expires_at"),shareToken:Se("share_token"),shareCodeHash:Se("share_code_hash")},e=>[Rr("idx_video_exports_user_created").on(e.userId,e.createdAt),Zd("idx_video_exports_share_token").on(e.shareToken)]);gn(Lze).omit({id:!0,status:!0,cloudBytes:!0,totalBytes:!0,resultObjectPath:!0,fileName:!0,error:!0,createdAt:!0,completedAt:!0,shareToken:!0,shareCodeHash:!0});const $ze=wr("video_export_schedules",{id:ct("id").primaryKey().default(gr`gen_random_uuid()`),userId:ct("user_id").notNull(),name:Se("name").notNull(),format:Se("format").notNull().default("mp4"),combine:Ss("combine").notNull().default(!1),siteIds:Se("site_ids").array().default([]),cameraNames:Se("camera_names").array().default([]),includeCloud:Ss("include_cloud").notNull().default(!0),includeLocal:Ss("include_local").notNull().default(!1),lookbackHours:As("lookback_hours").notNull().default(24),rangeStart:Tt("range_start"),rangeEnd:Tt("range_end"),eventType:Se("event_type").notNull().default("all"),recurrence:Se("recurrence").notNull().default("once"),timeOfDay:Se("time_of_day").notNull().default("02:00"),dayOfWeek:As("day_of_week").notNull().default(1),timezone:Se("timezone").notNull().default("America/Ne
557w_York"),runAt:Tt("run_at"),nextRunAt:Tt("next_run_at"),paused:Ss("paused").notNull().default(!1),lastRunAt:Tt("last_run_at"),lastStatus:Se("last_status"),createdAt:Tt("created_at").defaultNow().notNull()},e=>[Rr("idx_video_export_schedules_user").on(e.userId),Rr("idx_video_export_schedules_next").on(e.nextRunAt)]);gn($ze).omit({id:!0,userId:!0,nextRunAt:!0,lastRunAt:!0,lastStatus:!0,createdAt:!0}).extend({name:it().min(1).max(120),format:Hu("zip").default("zip"),recurrence:Hu("once").default("once"),timeOfDay:it().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"Expected HH:MM").optional(),dayOfWeek:_r().int().min(0).max(6).optional(),lookbackHours:_r().int().min(1).max(48).optional(),rangeStart:iS.date(),rangeEnd:iS.date(),runAt:iS.date().nullable().optional(),eventType:Wc(["all","motion","ai"]).default("all")}).refine(e=>e.rangeEnd.getTime()>e.rangeStart.getTime(),{message:"End must be after start.",path:["rangeEnd"]}).refine(e=>e.rangeEnd.getTime()-e.rangeStart.getTime()<=24*3600*1e3,{message:"Footage window cannot exceed 24 hours.",path:["rangeEnd"]});const Fze={Reolink:"zero-pad-2",GeoVision:"zero-pad-3"};function Bze(e){return e.channelFormat??Fze[e.brand]??"int"}function Uze(e,s){const r=Number.isFinite(e)&&e>=1?Math.floor(e):1;switch(s){case"zero-pad-2":return String(r).padStart(2,"0");case"zero-pad-3":return String(r).padStart(3,"0");default:return String(r)}}const Dj=[{brand:"Hikvision",series:"DS-2CD2 Series",model:"DS-2CD2143G2-I",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP AcuSense fixed dome"},{brand:"Hikvision",series:"DS-2CD2 Series",model:"DS-2CD2T47G2-L",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP ColorVu bullet"},{brand:"Hikvision",series:"DS-2CD2 Series",model:"DS-2CD2346G2-I",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP AcuSense dome"},{brand:"Hikvision",series:"DS-2CD2 Series",model:"DS-2CD2T86G2-4I",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"8MP AcuSense bullet"},{brand:"Hikvision",series:"DS-2CD3 Series",model:"DS-2CD3356G2-IS",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"5MP AcuSense dome"},{brand:"Hikvision",series:"DS-2CD3 Series",model:"DS-2CD3T47G2-L",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP ColorVu bullet"},{brand:"Hikvision",series:"DS-2DE Series (PTZ)",model:"DS-2DE4425IWG-E",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP 25× PTZ"},{brand:"Hikvision",series:"DS-2DE Series (PTZ)",model:"DS-2DE5432IW-AE",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP 32× PTZ"},{brand:"Hikvision",series:"DS-7600 NVR Series",model:"DS-7616NI-I2/16P",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]01",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]02",port:554,notes:"16-channel NVR with PoE"},{brand:"Hikvision",series:"DS-7700 NVR Series",model:"DS-7732NI-I4/24P",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]01",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]02",port:554,notes:"32-channel NVR with PoE"},{brand:"Hikvision",series:"DS-7800 NVR Series",model:"DS-7808NI-K2/8P",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]01",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]02",port:554,notes:"8-channel NVR"},{brand:"Hikvision",series:"iDS Series (DeepinView)",model:"iDS-2CD7146G0-AP",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP DeepinView face detection"},{brand:"Dahua",series:"IPC-HDW Series",model:"IPC-HDW2849H-S-IL",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"8MP Smart Dual Light dome"},{brand:"Dahua",series:"IPC-HDW Series",model:"IPC-HDW3849H-ZAS-PV",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"8MP Full-color dome"},{brand:"Dahua",series:"IPC-HFW Series",model:"IPC-HFW2849S-S-IL",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"8MP Smart Dual Light bullet"},{brand:"Dahua",series:"IPC-HFW Series",model:"IPC-HFW3849T1-AS-PV",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"8MP Full-color bullet"},{brand:"Dahua",series:"SD Series (PTZ)",model:"SD49425XB-HNR",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4MP 25× network PTZ"},{brand:"Dahua",series:"SD Series (PTZ)",model:"SD6CE245U-HNI",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4MP 45× PTZ"},{brand:"Dahua",series:"NVR5200 Series",model:"NVR5216-16P-I/L",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=[ch]&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=[ch]&subtype=1",port:554,notes:"16-channel AI NVR"},{brand:"Dahua",series:"NVR4200 Series",model:"NVR4232-16P-I",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=[ch]&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=[ch]&subtype=1",port:554,notes:"32-channel NVR"},{brand:"Dahua",series:"Eyeball Series",model:"IPC-HDW1439T1-LED",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4MP entry-level full-color"},{brand:"Axis",series:"P Series",model:"P3245-V",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264",rtspSub:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264&resolution=640x360",port:554,notes:"2MP fixed dome"},{brand:"Axis",series:"P Series",model:"P3268-LV",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264",rtspSub:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264&resolution=640x360",port:554,notes:"8MP OptimizedIR dome"},{brand:"Axis",series:"P3719-PLE",model:"P3719-PLE",type:"Fisheye",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264",rtspSub:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264&resolution=640x360",port:554,notes:"8MP panoramic fisheye"},{brand:"Axis",series:"Q Series",model:"Q6135-LE",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264",rtspSub:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264&resolution=640x360",port:554,notes:"2MP 32× outdoor PTZ"},{brand:"Axis",series:"Q Series",model:"Q3527-LVE",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264",rtspSub:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264&resolution=640x360",port:554,notes:"5MP outdoor fixed dome"},{brand:"Axis",series:"M Series",model:"M3106-L Mk II",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264",rtspSub:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264&resolution=640x360",port:554,notes:"4MP mini dome"},{brand:"Axis",series:"M Series",model:"M3058-PLVE",type:"Fisheye",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264",rtspSub:"rtsp://[user]:[pass]@[ip]/axis-media/media.amp?videocodec=h264&resolution=640x360",port:554,notes:"12MP OptimizedIR fisheye"},{brand:"Reolink",series:"RLC-810 Series",model:"RLC-810A",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554//h264Preview_01_main",rtspSub:"rtsp://[user]:[pass]@[ip]:554//h264Preview_01_sub",port:554,notes:"8MP Smart Detection bullet"},{brand:"Reolink",series:"RLC-810 Series",model:"RLC-823A",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554//h264Preview_01_main",rtspSub:"rtsp://[user]:[pass]@[ip]:554//h264Preview_01_sub",port:554,notes:"8MP spotlight bullet"},{brand:"Reolink",series:"RLC-520 Series",model:"RLC-520A",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554//h264Preview_01_main",rtspSub:"rtsp://[user]:[pass]@[ip]:554//h264Preview_01_sub",port:554,notes:"5MP Smart Detection dome"},{brand:"Reolink",series:"RLC-842 Series",model:"RLC-842A",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554//h264Preview_01_main",rtspSub:"rtsp://[user]:[pass]@[ip]:554//h264Preview_01_sub",port:554,notes:"8MP 4K bullet with Auto-Track"},{brand:"Reolink",series:"E1 Series",model:"E1 Outdoor Pro",type:"Bullet",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554//h264Preview_01_main",rtspSub:"rtsp://[user]:[pass]@[ip]:554//h264Preview_01_sub",port:554,notes:"5MP Wi-Fi outdoor bullet"},{brand:"Reolink",series:"RLN Series (NVR)",model:"RLN16-410",type:"NVR",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554//h264Preview_[ch]_main",rtspSub:"rtsp://[user]:[pass]@[ip]:554//h264Preview_[ch]_sub",port:554,notes:"16-channel PoE NVR"},{brand:"Reolink",series:"RLN Series (NVR)",model:"RLN8-410",type:"NVR",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554//h264Preview_[ch]_main",rtspSub:"rtsp://[user]:[pass]@[ip]:554//h264Preview_[ch]_sub",port:554,notes:"8-channel PoE NVR"},{brand:"Amcrest",series:"IP8M Series",model:"IP8M-2493EW",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4K bullet, Dahua OEM"},{brand:"Amcrest",series:"IP8M Series",model:"IP8M-2496EW",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4K dome, Dahua OEM"},{brand:"Amcrest",series:"IP5M Series",model:"IP5M-T1179EW",type:"Turret",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"5MP turret, Dahua OEM"},{brand:"Amcrest",series:"UHD Series",model:"UHD369-X",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4K 36× PTZ, Dahua OEM"},{brand:"Amcrest",series:"NV Series (NVR)",model:"NV4116-HS",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=[ch]&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=[ch]&subtype=1",port:554,notes:"16-channel NVR"},{brand:"Hanwha",series:"QNV Series",model:"QNV-8080R",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile2/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile4/media.smp",port:554,notes:"5MP IR dome"},{brand:"Hanwha",series:"QNO Series",model:"QNO-8080R",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile2/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile4/media.smp",port:554,notes:"5MP IR bullet"},{brand:"Hanwha",series:"PNV Series",model:"PNV-9300RX",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile2/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile4/media.smp",port:554,notes:"4K IR bullet"},{brand:"Hanwha",series:"XNV Series (AI)",model:"XNV-8080RSA",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile2/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile4/media.smp",port:554,notes:"5MP AI dome"},{brand:"Hanwha",series:"QNP Series (PTZ)",model:"QNP-6320H",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile2/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile4/media.smp",port:554,notes:"2MP 32× PTZ"},{brand:"Hanwha",series:"QRN Series (NVR)",model:"QRN-1620S",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile2/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile4/media.smp",port:554,notes:"16-channel NVR"},{brand:"Uniview",series:"IPC31 Series",model:"IPC3614SB-ADF28KM-I0",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/media/video1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/media/video2",port:554,notes:"4MP LightHunter dome"}
557,{brand:"Uniview",series:"IPC32 Series",model:"IPC3224SE-DF40K-WL-I0",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/media/video1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/media/video2",port:554,notes:"4MP full-color dome"},{brand:"Uniview",series:"IPC742 Series",model:"IPC742SR9-G40W-NL",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/media/video1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/media/video2",port:554,notes:"2MP laser ultra-long range bullet"},{brand:"Uniview",series:"NVR302 Series",model:"NVR302-16S-P16",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/media/video[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/media/video[ch]",port:554,notes:"16-channel NVR with PoE"},{brand:"Vivotek",series:"FD9 Series",model:"FD9189-HT-v2",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live.sdp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/live2.sdp",port:554,notes:"5MP H.265 outdoor dome"},{brand:"Vivotek",series:"IB9 Series",model:"IB9387-EHT-v2",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live.sdp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/live2.sdp",port:554,notes:"5MP outdoor bullet"},{brand:"Vivotek",series:"SD9 Series (PTZ)",model:"SD9367-EHL-v2",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live.sdp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/live2.sdp",port:554,notes:"2MP 33× outdoor PTZ"},{brand:"Vivotek",series:"MS9 Fisheye",model:"MS9321-EHV",type:"Fisheye",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live.sdp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/live2.sdp",port:554,notes:"12MP fisheye"},{brand:"Bosch",series:"FLEXIDOME 5100i",model:"NIN-53022-A3",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/rtsp_tunnel",rtspSub:"rtsp://[user]:[pass]@[ip]:554/rtsp_tunnel",port:554,notes:"2MP indoor dome"},{brand:"Bosch",series:"FLEXIDOME 8000i",model:"NIN-83055-A3S",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/rtsp_tunnel",rtspSub:"rtsp://[user]:[pass]@[ip]:554/rtsp_tunnel",port:554,notes:"5MP IR outdoor dome"},{brand:"Bosch",series:"AUTODOME 7000i",model:"NEZ-7230-EPCW4",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/rtsp_tunnel",rtspSub:"rtsp://[user]:[pass]@[ip]:554/rtsp_tunnel",port:554,notes:"2MP 30× PTZ"},{brand:"Bosch",series:"DIVAR 3000",model:"DDN-3532-200N00",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/rtsp_tunnel",rtspSub:"rtsp://[user]:[pass]@[ip]:554/rtsp_tunnel",port:554,notes:"32-channel NVR"},{brand:"Pelco",series:"Sarix Enhanced 3",model:"IBE329-1I",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"2MP outdoor bullet"},{brand:"Pelco",series:"Sarix Value",model:"IVE229-1ERS",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"2MP outdoor dome"},{brand:"Pelco",series:"Sarix Value 2",model:"SRXV2",type:"Bullet/Dome/Turret",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"2nd-gen Sarix Value series, up to 8MP, IR illumination"},{brand:"Pelco",series:"Sarix Pro 4",model:"SRXP4",type:"Bullet/Dome/Turret",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"4th-gen Sarix Pro, 4K with smart analytics"},{brand:"Pelco",series:"Sarix Enhanced 4",model:"SRXE4",type:"Bullet/Dome/Turret",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"4th-gen Sarix Enhanced, premium imaging with onboard analytics"},{brand:"Pelco",series:"Sarix Fisheye 3",model:"SRXF3",type:"Fisheye",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"3rd-gen 360° panoramic fisheye, 6/12MP options"},{brand:"Pelco",series:"Sarix Enhanced Duo",model:"SBDE1",type:"Multi-sensor (Dual)",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"Dual-sensor 180°/270° panoramic coverage"}
557,{brand:"Pelco",series:"Sarix Multi Enhanced",model:"SMLE1",type:"Multi-sensor (Quad)",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"Four independently adjustable sensors, up to 32MP total"},{brand:"Pelco",series:"Spectra Enhanced 7 (PTZ)",model:"SE7700-EG0-P",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"2MP 40× PTZ"},{brand:"Pelco",series:"Spectra Enhanced 8 (PTZ)",model:"SPDE8",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"8th-gen Spectra Enhanced 4K PTZ with 30-40× optical zoom"},{brand:"Pelco",series:"VideoXpert Series (NVR)",model:"VideoXpert DX8100",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"16/24-channel NVR appliance"},{brand:"Foscam",series:"G Series",model:"G4EP",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:88/videoMain",rtspSub:"rtsp://[user]:[pass]@[ip]:88/videoSub",port:88,notes:"4MP PoE dome"},{brand:"Foscam",series:"G Series",model:"G4P",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:88/videoMain",rtspSub:"rtsp://[user]:[pass]@[ip]:88/videoSub",port:88,notes:"4MP PoE dome"},{brand:"Foscam",series:"D4Z Series (PTZ)",model:"D4Z",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/videoMain",rtspSub:"rtsp://[user]:[pass]@[ip]:554/videoSub",port:554,notes:"4MP optical zoom PTZ"},{brand:"Foscam",series:"FN Series (NVR)",model:"FN3109H",type:"NVR",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:88/videoMain",rtspSub:"rtsp://[user]:[pass]@[ip]:88/videoSub",port:88,notes:"9-channel NVR"},{brand:"Lorex",series:"E Series",model:"E891AB",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4K bullet, Dahua OEM"},{brand:"Lorex",series:"E Series",model:"E842CD",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4K dome, Dahua OEM"},{brand:"Lorex",series:"LNR Series (NVR)",model:"LNR6164UB",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=[ch]&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=[ch]&subtype=1",port:554,notes:"64-channel NVR, Dahua OEM"},{brand:"GeoVision",series:"GV-EBL Series",model:"GV-EBL4712-2F",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:8554/CH001.sdp",rtspSub:"rtsp://[user]:[pass]@[ip]:8554/CH001.sdp",port:8554,notes:"4MP IR bullet"},{brand:"GeoVision",series:"GV-EVD Series",model:"GV-EVD4712",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:8554/CH001.sdp",rtspSub:"rtsp://[user]:[pass]@[ip]:8554/CH001.sdp",port:8554,notes:"4MP IR dome"},{brand:"GeoVision",series:"GV-SNVR Series",model:"GV-SNVR1611",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:8554/CH[ch].sdp",rtspSub:"rtsp://[user]:[pass]@[ip]:8554/CH[ch].sdp",port:8554,notes:"16-channel NVR"},{brand:"ACTi",series:"E Series",model:"E47",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:7070/track1",rtspSub:"rtsp://[user]:[pass]@[ip]:7070/track2",port:7070,notes:"5MP indoor dome"},{brand:"ACTi",series:"Z Series",model:"Z81",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:7070/track1",rtspSub:"rtsp://[user]:[pass]@[ip]:7070/track2",port:7070,notes:"4MP outdoor bullet"},{brand:"ACTi",series:"ENR Series (NVR)",model:"ENR-190",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:7070/track[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:7070/track[ch]",port:7070,notes:"16-channel NVR"},{brand:"Avigilon",series:"H5A Series",model:"5.0-H5A-DO1-IR",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/defaultPrimary?streamType=u",rtspSub:"rtsp://[user]:[pass]@[ip]/defaultSecondary?streamType=u",port:554,notes:"5MP Self-Learning H5A dome"},{brand:"Avigilon",series:"H5A Series",model:"5.0-H5A-BO2-IR",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/defaultPrimary?streamType=u",rtspSub:"rtsp://[user]:[pass]@[ip]/defaultSecondary?streamType=u",port:554,notes:"5MP Self-Learning H5A bullet"},{brand:"Avigilon",series:"HD PTZ",model:"1.0C-H4PTZ-DP30",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/defaultPrimary?streamType=u",rtspSub:"rtsp://[user]:[pass]@[ip]/defaultSecondary?streamType=u",port:554,notes:"1MP 30× PTZ"},{brand:"Mobotix",series:"Mx-M73 Series",model:"Mx-M73A-4N016",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/control/faststream.jpg?stream=full",rtspSub:"rtsp://[user]:[pass]@[ip]/control/faststream.jpg?stream=preview",port:554,notes:"4K bullet, German made"},{brand:"Mobotix",series:"Mx-D71 Series",model:"Mx-D71A-8N050",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/control/faststream.jpg?stream=full",rtspSub:"rtsp://[user]:[pass]@[ip]/control/faststream.jpg?stream=preview",port:554,notes:"8K dome, German made"},{brand:"Mobotix",series:"Mx-Q71 Series",model:"Mx-Q71A-8DN050",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/control/faststream.jpg?stream=full",rtspSub:"rtsp://[user]:[pass]@[ip]/control/faststream.jpg?stream=preview",port:554,notes:"8K 360° dome"},{brand:"Panasonic",series:"i-PRO WV-S Series",model:"WV-S2536L",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/MediaInput/h264/stream_1",rtspSub:"rtsp://[user]:[pass]@[ip]/MediaInput/h264/stream_2",port:554,notes:"4MP dome"},{brand:"Panasonic",series:"i-PRO WV-X Series",model:"WV-X4171L",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/MediaInput/h264/stream_1",rtspSub:"rtsp://[user]:[pass]@[ip]/MediaInput/h264/stream_2",port:554,notes:"8K outdoor dome"},{brand:"Panasonic",series:"i-PRO WV-S PTZ",model:"WV-S6530N",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/MediaInput/h264/stream_1",rtspSub:"rtsp://[user]:[pass]@[ip]/MediaInput/h264/stream_2",port:554,notes:"2MP outdoor PTZ"},{brand:"FLIR",series:"Quasar Series",model:"FB-337 HD",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"2MP outdoor IR bullet"},{brand:"FLIR",series:"Elara Series (Thermal)",model:"FC-317 ID-T",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"Thermal + visible bullet"},{brand:"Annke",series:"C800 Series",model:"C800 4K",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4K bullet, Hikvision OEM"},{brand:"Annke",series:"C500 Series",model:"C500",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"5MP dome, Hikvision OEM"},{brand:"Annke",series:"N Series (NVR)",model:"N48PAW",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]01",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]02",port:554,notes:"8-channel NVR, Hikvision OEM"},{brand:"Swann",series:"PRO-4KMSB",model:"PRO-4KMSB",type:"Bullet",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4K bullet"},{brand:"Swann",series:"NHD-875 Series",model:"NHD-875MSB",type:"Bullet",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4K bullet"},{brand:"Swann",series:"DVR Series",model:"DVR-16580V",type:"DVR",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=[ch]&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=[ch]&subtype=1",port:554,notes:"16-channel DVR"},{brand:"IndigoVision",series:"BX Series",model:"BX400-4W-b",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/primary",rtspSub:"rtsp://[user]:[pass]@[ip]/secondary",port:554,notes:"4MP wide-angle bullet"},{brand:"IndigoVision",series:"NVMS (NVR)",model:"NVR-AS 8000",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/primary",rtspSub:"rtsp://[user]:[pass]@[ip]/secondary",port:554,notes:"Network video recording appliance"},{brand:"Sony",series:"SNC-WX Series",model:"SNC-WX640",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/media/video1",rtspSub:"rtsp://[user]:[pass]@[ip]/media/video2",port:554,notes:"4MP outdoor dome"},{brand:"Sony",series:"SNC-EM Series",model:"SNC-EM630",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]/media/video1",rtspSub:"rtsp://[user]:[pass]@[ip]/media/video2",port:554,notes:"2MP indoor dome"}
557,{brand:"Eagle Eye Networks",series:"A-Series",model:"A100",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live",rtspSub:"rtsp://[user]:[pass]@[ip]:554/live2",port:554,notes:"Eagle Eye cloud-managed dome; requires Eagle Eye Bridge"},{brand:"Eagle Eye Networks",series:"A-Series",model:"A150",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live",rtspSub:"rtsp://[user]:[pass]@[ip]:554/live2",port:554,notes:"Eagle Eye cloud-managed bullet"},{brand:"Eagle Eye Networks",series:"CMVR (Bridge)",model:"EEN-CMVR-8",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",port:554,notes:"Cloud Managed Video Recorder — bridges 3rd-party ONVIF cameras"},{brand:"Eagle Eye Networks",series:"CMVR (Bridge)",model:"EEN-CMVR-16",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",port:554,notes:"16-channel cloud bridge"},{brand:"Verkada",series:"CD Series (Dome)",model:"CD31",type:"Dome",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:8554/live",rtspSub:"rtsp://[user]:[pass]@[ip]:8554/live_sub",port:8554,notes:"Verkada cloud dome; RTSP available via Command portal"},{brand:"Verkada",series:"CD Series (Dome)",model:"CD52",type:"Dome",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:8554/live",rtspSub:"rtsp://[user]:[pass]@[ip]:8554/live_sub",port:8554,notes:"1080p cloud dome"},{brand:"Verkada",series:"CD Series (Dome)",model:"CD62",type:"Dome",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:8554/live",rtspSub:"rtsp://[user]:[pass]@[ip]:8554/live_sub",port:8554,notes:"4K cloud dome"},{brand:"Verkada",series:"CB Series (Bullet)",model:"CB61-E",type:"Bullet",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:8554/live",rtspSub:"rtsp://[user]:[pass]@[ip]:8554/live_sub",port:8554,notes:"4K outdoor cloud bullet"},{brand:"Verkada",series:"CM Series (Mini)",model:"CM61-E",type:"Dome",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:8554/live",rtspSub:"rtsp://[user]:[pass]@[ip]:8554/live_sub",port:8554,notes:"4K mini cloud dome"},{brand:"Verkada",series:"CT Series (Fisheye)",model:"CT62-E",type:"Fisheye",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:8554/live",rtspSub:"rtsp://[user]:[pass]@[ip]:8554/live_sub",port:8554,notes:"Panoramic fisheye cloud camera"},{brand:"OpenEye",series:"OW Series (Cloud-Managed NVR)",model:"OW-NVR-108",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]01",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]02",port:554,notes:"8-channel cloud-managed NVR"},{brand:"OpenEye",series:"OW Series (Cloud-Managed NVR)",model:"OW-NVR-116",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]01",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]02",port:554,notes:"16-channel cloud-managed NVR"},{brand:"OpenEye",series:"WEB Series (Onsite NVR)",model:"WEB-NVR-832",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]01",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]02",port:554,notes:"32-channel web-managed NVR"},{brand:"OpenEye",series:"OE-Series Cameras",model:"OE-D1MF28-P4W",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP PoE dome"},{brand:"OpenEye",series:"OE-Series Cameras",model:"OE-B4MF28-P4W",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP PoE bullet"},{brand:"CamCloud",series:"CamCloud Bridge",model:"CC-BRIDGE-8",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",port:554,notes:"Cloud VMS bridge; aggregates any ONVIF/RTSP cameras"},{brand:"CamCloud",series:"CamCloud Bridge",model:"CC-BRIDGE-16",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",port:554,notes:"16-ch cloud bridge"},{brand:"Digital Watchdog",series:"MEGApix Series",model:"DWC-B6563TIR",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile1/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile3/media.smp",port:554,notes:"5MP IR bullet"},{brand:"Digital Watchdog",series:"MEGApix Series",model:"DWC-D4563TIR",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile1/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile3/media.smp",port:554,notes:"5MP IR dome"},{brand:"Digital Watchdog",series:"MEGApix AI Series",model:"DWC-VS853W",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile1/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile3/media.smp",port:554,notes:"4K AI vandal-resistant bullet"},{brand:"Digital Watchdog",series:"Spectrum NVR",model:"DW-BJEVS16T8P",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile1/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile3/media.smp",port:554,notes:"16-channel NVR, 8 PoE"},{brand:"Digital Watchdog",series:"Spectrum NVR",model:"DW-BJDVS32T",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile1/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile3/media.smp",port:554,notes:"32-channel NVR"},{brand:"Speco Technologies",series:"O-Series",model:"O4B3",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"4MP IR bullet"},{brand:"Speco Technologies",series:"O-Series",model:"O8D6",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"8MP IR dome"},{brand:"Speco Technologies",series:"O-Series PTZ",model:"O4P28X",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"4MP 28× PTZ"},{brand:"Speco Technologies",series:"N-Series NVR",model:"N16NU6TB",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",port:554,notes:"16-channel NVR"}
557,{brand:"March Networks",series:"MegaPX Series",model:"MegaPX ATM Dome",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"ATM-grade vandal dome"},{brand:"March Networks",series:"8000 NVR Series",model:"8108 NVR",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",port:554,notes:"8-channel NVR"},{brand:"March Networks",series:"ME6 Dual NVR",model:"ME6 Dual 32",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",port:554,notes:"32-channel dual-server NVR"},{brand:"Vicon",series:"SVFT Series",model:"SVFT-C51V",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live/ch0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/live/ch0_sub",port:554,notes:"5MP outdoor dome"},{brand:"Vicon",series:"V1000 Series",model:"V1010D-DP",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live/ch0",rtspSub
557:"rtsp://[user]:[pass]@[ip]:554/live/ch0_sub",port:554,notes:"4K dome"},{brand:"Vicon",series:"Roughneck (PTZ)",model:"SVPTZ-28X",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live/ch0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/live/ch0_sub",port:554,notes:"2MP 28× outdoor PTZ"},{brand:"Illustra",series:"Flex Series",model:"IFS02-V10-OT01",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/video1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/video2",port:554,notes:"2MP outdoor dome (Tyco/JCI)"},{brand:"Illustra",series:"Pro Series",model:"IPS02-V13-OT01",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/video1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/video2",port:554,notes:"2MP outdoor Pro dome"},{brand:"Illustra",series:"Insight PTZ",model:"IFS16-V10-OT01",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/video1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/video2",port:554,notes:"16× PTZ"},{brand:"IC Realtime",series:"CAT Series",model:"ICIP-B4000-28IR",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP IR bullet, Hikvision-compatible"},{brand:"IC Realtime",series:"CAT Series",model:"ICIP-D4000-28IR",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP IR dome"},{brand:"IC Realtime",series:"ICAT NVR",model:"ICAT-NVR16P",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]01",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/[ch]02",port:554,notes:"16-channel NVR"},{brand:"Provision-ISR",series:"DI Series",model:"DI-340IPE-MVF",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"4MP motor-zoom dome"},{brand:"Provision-ISR",series:"I4 Series",model:"I4-340IPN-MVF",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"4MP bullet"},{brand:"Provision-ISR",series:"NVR4 Series",model:"NVR4-16400P-16",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",port:554,notes:"16-channel NVR"},{brand:"Tiandy",series:"TC-C32 Series",model:"TC-C32JP-6Y3E",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/1/1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/1/2",port:554,notes:"2MP 30× PTZ"},{brand:"Tiandy",series:"TC-C34 Series",model:"TC-C34WP-E3Y3E",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/1/1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/1/2",port:554,notes:"4MP IR dome"},{brand:"Tiandy",series:"TC-NR Series (NVR)",model:"TC-NR5016M7",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/[ch]/1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/[ch]/2",port:554,notes:"16-channel NVR"},{brand:"Wisenet",series:"P-Series",model:"PNV-A9081R",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile2/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile4/media.smp",port:554,notes:"4K AI IR outdoor dome"},{brand:"Wisenet",series:"X-Series AI",model:"XNO-9300RW",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile2/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile4/media.smp",port:554,notes:"4K AI IR outdoor bullet"},{brand:"Wisenet",series:"Q-Series",model:"QNE-8080RVW",type:"Turret",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile2/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile4/media.smp",port:554,notes:"5MP IR turret"},{brand:"Milesight",series:"MS-C Series",model:"MS-C5382-FIPD",type:"Fisheye",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/main",rtspSub:"rtsp://[user]:[pass]@[ip]:554/sub",port:554,notes:"5MP fisheye"},{brand:"Milesight",series:"MS-C Series",model:"MS-C8163-FIPB",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/main",rtspSub:"rtsp://[user]:[pass]@[ip]:554/sub",port:554,notes:"8MP AI IR bullet"},{brand:"Milesight",series:"MS-C Series",model:"MS-C8181-PD",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/main",rtspSub:"rtsp://[user]:[pass]@[ip]:554/sub",port:554,notes:"4K 36× PTZ"},{brand:"Milesight",series:"MS-N Series (NVR)",model:"MS-N8032-H",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/main[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/sub[ch]",port:554,notes:"32-channel 4K NVR"},{brand:"EZVIZ",series:"C3W Pro Series",model:"CS-C3W-A0-3H4WFRL",type:"Bullet",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554/h264/ch01/main/av_stream",rtspSub:"rtsp://[user]:[pass]@[ip]:554/h264/ch01/sub/av_stream",port:554,notes:"4MP color night Wi-Fi bullet (Hikvision sub-brand)"},{brand:"EZVIZ",series:"C8 Series (PTZ)",model:"CS-C8PF-B0-142W4K",type:"PTZ Camera",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554/h264/ch01/main/av_stream",rtspSub:"rtsp://[user]:[pass]@[ip]:554/h264/ch01/sub/av_stream",port:554,notes:"4K 4× outdoor PTZ (Hikvision sub-brand)"},{brand:"EZVIZ",series:"BC1C Series",model:"CS-BC1C-B0-2C2WKFL",type:"Bullet",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554/h264/ch01/main/av_stream",rtspSub:"rtsp://[user]:[pass]@[ip]:554/h264/ch01/sub/av_stream",port:554,notes:"2MP color night battery cam"},{brand:"TP-Link VIGI",series:"VIGI C-Series",model:"VIGI C340",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"4MP PoE bullet"},{brand:"TP-Link VIGI",series:"VIGI C-Series",model:"VIGI C440",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"4MP PoE dome"},{brand:"TP-Link VIGI",series:"VIGI NVR",model:"VIGI NVR1016H",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",port:554,notes:"16-channel PoE NVR"},{brand:"IMOU",series:"Bullet 2E Series",model:"IPC-F42FEP-D",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"4MP Wi-Fi bullet (Dahua sub-brand)"},{brand:"IMOU",series:"Cruiser 2 PTZ",model:"IPC-GS2EP-3M0WE",type:"PTZ Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"3MP Wi-Fi PTZ (Dahua sub-brand)"},{brand:"Uniview",series:"Prime Series",model:"IPC2228SE-DF40K-WL-I0",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/media/video1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/media/video2",port:554,notes:"8MP full-color AI bullet"},{brand:"Uniview",series:"Easy Plus",model:"IPC3614SB-ADF28KM-I1",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/media/video1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/media/video2",port:554,notes:"4MP LightHunter easy dome"},{brand:"Q-See",series:"QT Series",model:"QT5682B-2",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"5MP outdoor bullet"},{brand:"Q-See",series:"QT NVR",model:"QT848-8E-2",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream[ch]",port:554,notes:"8-channel NVR"},{brand:"Zmodo",series:"ZM Series",model:"ZM-W0002-C",type:"Dome",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live/ch0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/live/ch0_sub",port:554,notes:"720P Wi-Fi indoor dome"},{brand:"Zmodo",series:"Pivot",model:"ZM-SH75D001-WA",type:"Dome",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554/live/ch0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/live/ch0_sub",port:554,notes:"1080P motorized indoor dome"},{brand:"Hanwha",series:"TNV Series (NVR)",model:"TNV-8300S",type:"NVR",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/profile2/media.smp",rtspSub:"rtsp://[user]:[pass]@[ip]:554/profile4/media.smp",port:554,notes:"32-channel 4K NVR"},{brand:"Grundig Security",series:"GD-CI-AT Series",model:"GD-CI-AT3616T",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/main",rtspSub:"rtsp://[user]:[pass]@[ip]:554/sub",port:554,notes:"3MP IR bullet"},{brand:"Grundig Security",series:"GD-CI-AT Series (Dome)",model:"GD-CI-AT4616D",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/main",rtspSub:"rtsp://[user]:[pass]@[ip]:554/sub",port:554,notes:"4MP IR dome"},{brand:"Hikvision",series:"DS-2CD2 ColorVu",model:"DS-2CD2T47G2-LSU/SL",type:"Bullet",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"4MP strobe-light ColorVu bullet"},{brand:"Hikvision",series:"DS-2CD2 ColorVu",model:"DS-2CD2387G2P-LSU/SL",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/101",rtspSub:"rtsp://[user]:[pass]@[ip]:554/Streaming/Channels/102",port:554,notes:"8MP strobe-light ColorVu dome"},{brand:"Dahua",series:"Starlight+ Series",model:"IPC-HDW3849H-AS-PV",type:"Dome",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=0",rtspSub:"rtsp://[user]:[pass]@[ip]:554/cam/realmonitor?channel=1&subtype=1",port:554,notes:"8MP full-color starlight dome"},{brand:"Generic / Unknown",series:"ONVIF-Compatible Camera",model:"Any ONVIF Profile S",type:"IP Camera",onvif:!0,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream1",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream2",port:554,notes:"Any camera advertising ONVIF Profile S compliance"},{brand:"Generic / Unknown",series:"RTSP Camera",model:"Any RTSP-Compatible",type:"IP Camera",onvif:!1,rtspMain:"rtsp://[user]:[pass]@[ip]:554/stream",rtspSub:"rtsp://[user]:[pass]@[ip]:554/stream",port:554,notes:"Any camera with RTSP capability"}],JR=Array.from(new Set(Dj.map(e=>e.brand))).sort();
557function zze({value:e,onChange:s}){const r=u.useRef(null),n=u.useRef(null),i=e.split(`
558`).length;u.useEffect(()=>{const l=r.current,c=n.current;if(!l||!c)return;const d=()=>{c.scrollTop=l.scrollTop};return l.addEventListener("scroll",d),()=>l.removeEventListener("scroll",d)},[]);const o=l=>{if(l.key==="Tab"){l.preventDefault();const c=l.currentTarget,d=c.selectionStart,h=c.selectionEnd,p=e.substring(0,d)+"  "+e.substring(h);s(p),requestAnimationFrame(()=>{c.selectionStart=c.selectionEnd=d+2})}};return t.jsx("div",{className:"relative rounded-lg border border-border overflow-hidden bg-background",style:{fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},"data-testid":"yaml-editor-container",children:t.jsxs("div",{className:"flex",style:{minHeight:"500px",maxHeight:"calc(100vh - 16rem)"},children:[t.jsx("div",{ref:n,className:"shrink-0 select-none text-right pr-3 pl-3 py-2 text-xs leading-[20px] text-muted-foreground bg-muted/50 border-r border-border overflow-hidden",style:{minWidth:"3.5rem"},"aria-hidden":"true",children:Array.from({length:i},(l,c)=>t.jsx("div",{children:c+1},c))}),t.jsx("textarea",{ref:r,value:e,onChange:l=>s(l.target.value),onKeyDown:o,spellCheck:!1,className:"flex-1 resize-none bg-transparent text-foreground text-xs leading-[20px] p-2 outline-none focus:ring-0 border-0",style:{fontFamily:"inherit",tabSize:2,whiteSpace:"pre",overflowX:"auto",overflowY:"auto"},"data-testid":"yaml-editor-textarea"})]})})}function tf(e){if(e.triggerType==="action")return!0;if(e.triggerType!=="combined")return!1;const s=e.triggerConfig;return!s||!Array.isArray(s.allOf)?!1:s.allOf.some(r=>r&&typeof r=="object"&&"action"in r)}function iie(e,s){const[r,n]=e.split(":").map(Number),[a,i]=s.split(":").map(Number),o=(r||0)*60+(n||0),l=(a||0)*60+(i||0);return l>o?l-o:l+1440-o}function oie(e){const s=Math.floor(e/60),r=e%60;return s===0?`${r} m`:r===0?`${s} h`:`${s} h ${r} m`}function Hze(e,s,r){if(!tf(e))return null;if(s==null)return"Needs a Smart Alerts subscription.";if(e.scheduleCapViolation){if(e.scheduleMode==="always")return"Only 2 AI rules may run 24/7 — switch to a scheduled window (≤ 12 h).";if(e.scheduleStart&&e.scheduleEnd){const a=iie(e.scheduleStart,e.scheduleEnd);return`Window exceeds 12 h (${oie(a)}).`}return"Violates the AI schedule limits."}if(e.cameraScope!=="selected")return"Must target selected cameras, not all.";const n=e.cameras?.length??0;return n<1?"Must target at least 1 camera.":n>s?`Camera count (${n}) exceeds subscription (${s}).`:e.enabled&&r>5?`Device has ${r} AI-enabled rules (max 5). Disable some to comply.`:null}const qze=["motion","person","car","truck","bicycle","motorcycle","dog","cat","package","bird"],J4=["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Phoenix","America/Anchorage","Pacific/Honolulu","UTC","Europe/London","Europe/Paris","Europe/Berlin","Europe/Madrid","Asia/Tokyo","Asia/Singapore","Asia/Hong_Kong","Asia/Dubai","Australia/Sydney"],Vze=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Wze({edgeDeviceId:e,hasAnyEnabledAiRule:s}){const{toast:r}=Hs(),a=ze({queryKey:["/api/edge-devices",e]}).data?.smartAlertsScanIntervalSeconds??60,[i,o]=u.useState(a);u.useEffect(()=>{o(a)},[a]);const l=s?30:5,c=Math.min(900,Math.max(l,i));u.useEffect(()=>{i<l&&o(l)},[l]);const d=Et({mutationFn:async p=>Ze("PATCH",`/api/edge-devices/${e}`,{smartAlertsScanIntervalSeconds:p}),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/edge-devices",e]}),r({title:"Scan interval updated"})},onError:p=>r({title:"Save failed",description:p?.message||"",variant:"destructive"})}),h=i!==a;return t.jsx(ut,{children:t.jsxs(mt,{className:"pt-4 space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(re,{children:"Scan interval"}),t.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground","data-testid":"text-scan-interval-value",children:["every ",c,"s",c!==i?` (clamped from ${i}s)`:""]})]}),t.jsx(km,{min:l,max:900,step:5,value:[Math.max(l,i)],onValueChange:p=>o(p[0]??60),"data-testid":"input-scan-interval"}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"How often the server polls for new events. Minimum 30s while any AI Actions & Search rule is enabled."}),t.jsx(L,{size:"sm",disabled:!h||d.isPending,onClick:()=>d.mutate(c),"data-testid":"button-save-scan-interval",children:d.isPending?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):"Save"})]})]})})}function Kze({edgeDeviceId:e,hasAiRules:s}){const{toast:r}=Hs(),{can:n}=aN(),a=n("ai-usage","read"),i=n("ai-usage","write"),o=ze({queryKey:["/api/edge-devices",e,"smart-alerts-ai-usage"],enabled:s&&a,refetchInterval:6e4}),[l,c]=u.useState(!1),[d,h]=u.useState(""),p=Et({mutationFn:async j=>Ze("PUT",`/api/edge-devices/${e}/smart-alerts-ai-quota`,{dailyLimit:j}),onSuccess:()=>
558{Je.invalidateQueries({queryKey:["/api/edge-devices",e,"smart-alerts-ai-usage"]}),c(!1),r({title:"Daily AI limit updated"})},onError:j=>r({title:"Save failed",description:j?.message||"",variant:"destructive"})});if(!s||!a||!o.data)return null;const g=o.data,v=g.exhausted?"bg-destructive":g.percent>=80?"bg-amber-500":"bg-primary",b=parseInt(d,10),y=Number.isFinite(b)&&b>=0&&b<=1e5&&String(b)===d.trim(),w=()=>{y&&p.mutate(b)};return t.jsx(ut,{"data-testid":"card-ai-usage",children:t.jsxs(mt,{className:"pt-4 space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(re,{children:"AI evaluations today"}),t.jsxs("span",{className:"text-xs tabular-nums text-muted-foreground","data-testid":"text-ai-usage-count",children:[g.used," / ",g.limit,g.exhausted?" — quota reached":""]})]}),t.jsx("div",{className:"h-1.5 rounded bg-muted overflow-hidden",children:t.jsx("div",{className:`h-full ${v}`,style:{width:`${Math.min(100,g.percent)}%`}})}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("span",{className:"text-xs text-muted-foreground","data-testid":"text-ai-usage-cost",children:["Est. cost today: $",g.estimatedCostUsd.toFixed(2)]}),i&&!l&&t.jsxs(L,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:()=>{h(String(g.limit)),c(!0)},"data-testid":"button-edit-ai-limit",children:[t.jsx(ga,{className:"w-3 h-3 mr-1"})," Edit limit"]})]}),i&&l&&t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(re,{className:"text-xs whitespace-nowrap",children:"Daily limit"}),t.jsx(ke,{type:"number",min:0,max:1e5,step:1,value:d,onChange:j=>h(j.target.value),onKeyDown:j=>{j.key==="Enter"&&w()},className:"h-7 w-28 text-xs","data-testid":"input-ai-daily-limit"}),t.jsx(L,{size:"sm",className:"h-7 text-xs",disabled:!y||p.isPending,onClick:w,"data-testid":"button-save-ai-limit",children:p.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):"Save"}),t.jsx(L,{size:"sm",variant:"ghost",className:"h-7 text-xs",disabled:p.isPending,onClick:()=>c(!1),"data-testid":"button-cancel-ai-limit",children:"Cancel"}),!y&&d.trim()!==""&&t.jsx("span",{className:"text-xs text-destructive","data-testid":"text-ai-limit-error",children:"Must be 0–100000"})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Daily evaluation quota for this device (resets at midnight ",g.timezone,").",g.exhausted?" AI rules are paused until the reset; object and face rules keep running.":""]})]})})}function Gze({edgeDeviceId:e,hasAiRules:s}){const{can:r}=aN(),n=r("ai-usage","read"),[a,i]=u.useState("14"),[o,l]=u.useState("all"),c=ze({queryKey:["/api/edge-devices",e,"smart-alerts-ai-usage","history",{days:a,ruleId:o}],queryFn:async()=>{const b=new URLSearchParams({days:a});return o!=="all"&&b.set("ruleId",o),(await Ze("GET",`/api/edge-devices/${e}/smart-alerts-ai-usage/history?${b}`)).json()},enabled:s&&n,staleTime:3e4,refetchInterval:6e4});if(!s||!n)return null;const d=c.data,h=b=>b==null?"(no rule)":d?.rules.find(y=>y.id===b)?.name??"Deleted rule",p=d?.rows??[],g=p.reduce((b,y)=>({evaluations:b.evaluations+y.evaluations,matches:b.matches+y.matches,alerts:b.alerts+y.alerts,errors:b.errors+y.errors,cost:b.cost+y.estimatedCostMicros}),{evaluations:0,matches:0,alerts:0,errors:0,cost:0}),v=b=>`$${(b/1e6).toFixed(b>0&&b<1e4?4:2)}`;return t.jsxs(ut,{"data-testid":"card-ai-usage-history",children:[t.jsxs(xs,{className:"pb-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx(ys,{className:"text-sm",children:"AI usage history"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Us,{value:o,onValueChange:l,children:[t.jsx($s,{className:"h-8 w-[180px] text-xs","data-testid":"select-ai-usage-rule",children:t.jsx(zs,{placeholder:"All rules"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All rules"}),(d?.rules??[]).map(b=>t.jsx(rt,{value:b.id,children:b.name},b.id))]})]}),t.jsxs(Us,{value:a,onValueChange:i,children:[t.jsx($s,{className:"h-8 w-[130px] text-xs","data-testid":"select-ai-usage-days",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"7",children:"Last 7 days"}),t.jsx(rt,{value:"14",children:"Last 14 days"}),t.jsx(rt,{value:"30",children:"Last 30 days"}),t.jsx(rt,{value:"90",children:"Last 90 days"})]})]})]})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Evaluations and estimated spend per rule per day",d?.timezone?` (days in ${d.timezone})`:"","."]})]}),t.jsxs(mt,{className:"pt-0",children:[c.isLoading&&t.jsx("div",{className:"py-8 text-center text-muted-foreground",children:t.jsx(Fe,{className:"w-5 h-5 mx-auto animate-spin"})}),c.isError&&t.jsx("p",{className:"text-xs text-destructive py-4","data-testid":"text-ai-usage-history-error",children:"Failed to load usage history."}),!c.isLoading&&!c.isError&&p.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground py-4","data-testid":"text-ai-usage-history-empty",children:"No AI evaluations recorded in this period."}),p.length>0&&t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-xs","data-testid":"table-ai-usage-history",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-muted-foreground border-b border-border",children:[t.jsx("th",{className:"text-left font-medium py-1.5 pr-2",children:"Date"}),t.jsx("th",{className:"text-left font-medium py-1.5 pr-2",children:"Rule"}),t.jsx("th",{className:"text-right font-medium py-1.5 pr-2",children:"Evals"}),t.jsx("th",{className:"text-right font-medium py-1.5 pr-2",children:"Matches"}),t.jsx("th",{className:"text-right font-medium py-1.5 pr-2",children:"Alerts"}),t.jsx("th",{className:"text-right font-medium py-1.5 pr-2",children:"Errors"}),t.jsx("th",{className:"text-right font-medium py-1.5",children:"Est. cost"})]})}),t.jsx("tbody",{children:p.map((b,y)=>t.jsxs("tr",{className:"border-b border-border/50","data-testid":`row-ai-usage-${y}`,children:[t.jsx("td",{className:"py-1.5 pr-2 tabular-nums whitespace-nowrap",children:b.date}),t.jsx("td",{className:"py-1.5 pr-2 max-w-[200px] truncate",title:h(b.ruleId),children:h(b.ruleId)}),t.jsx("td",{className:"py-1.5 pr-2 text-right tabular-nums",children:b.evaluations}),t.jsx("td",{className:"py-1.5 pr-2 text-right tabular-nums",children:b.matches}),t.jsx("td",{className:"py-1.5 pr-2 text-right tabular-nums",children:b.alerts}),t.jsx("td",{className:`py-1.5 pr-2 text-right tabular-nums ${b.errors>0?"text-destructive font-medium":""}`,children:b.errors}),t.jsx("td",{className:"py-1.5 text-right tabular-nums",children:v(b.estimatedCostMicros)})]},`${b.date}-${b.ruleId??"none"}-${y}`))}),t.jsx("tfoot",{children:t.jsxs("tr",{className:"font-medium","data-testid":"row-ai-usage-totals",children:[t.jsx("td",{className:"py-1.5 pr-2",colSpan:2,children:"Total"}),t.jsx("td",{className:"py-1.5 pr-2 text-right tabular-nums",children:g.evaluations}),t.jsx("td",{className:"py-1.5 pr-2 text-right tabular-nums",children:g.matches}),t.jsx("td",{className:"py-1.5 pr-2 text-right tabular-nums",children:g.alerts}),t.jsx("td",{className:`py-1.5 pr-2 text-right tabular-nums ${g.errors>0?"text-destructive":""}`,children:g.errors}),t.jsx("td",{className:"py-1.5 text-right tabular-nums",children:v(g.cost)})]})})]})})]})]})}function Yze({edgeDeviceId:e,cameraNames:s}){const{toast:r}=Hs(),[n,a]=u.useState("groups"),i=ze({queryKey:["/api/edge-devices",e,"smart-alerts"]}),o=ze({queryKey:["/api/edge-devices",e,"alert-groups"]}),l=ze({queryKey:["/api/edge-devices",e]}),{data:c}=ze({queryKey:["/api/twilio/status"]}),d=c?.configured??!1,h=l.data?.smartAlertsCameraCount??null,p=(i.data??[]).filter(S=>S.enabled&&tf(S)).length,[g,v]=u.useState({open:!1}),[b,y]=u.useState({open:!1}),w=Et({mutationFn:async({id:S,enabled:_})=>Ze("PATCH",`/api/edge-devices/${e}/smart-alerts/${S}/enabled`,{enabled:_}),onSuccess:()=>
558Je.invalidateQueries({queryKey:["/api/edge-devices",e,"smart-alerts"]}),onError:S=>{const _=S?.message||"Failed to update rule";r({title:"Cannot update rule",description:_,variant:"destructive"})}}),j=Et({mutationFn:async S=>Ze("DELETE",`/api/edge-devices/${e}/smart-alerts/${S}`),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/edge-devices",e,"smart-alerts"]}),r({title:"Rule deleted"})}}),x=Et({mutationFn:async S=>Ze("DELETE",`/api/edge-devices/${e}/alert-groups/${S}`),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/edge-devices",e,"alert-groups"]}),r({title:"Group deleted"})}}),C=Et({mutationFn:async S=>(await Ze("POST",`/api/edge-devices/${e}/smart-alerts/${S}/test`,{})).json(),onSuccess:S=>{if(S.matched===!1){r({title:"Rule did not match",description:S.message||"No recent recordings matched this rule.",variant:"destructive"});return}if(S.rateLimited){const $=S.recording,O=$?.personName||$?.label,q=$?`${$.camera}${O?` · ${O}`:""}`:"";r({title:"Rule matched — rate-limited (not dispatched)",description:[q,"Hit the rule's max alerts per minute. No notifications sent."].filter(Boolean).join(" — ")}),Je.invalidateQueries({queryKey:["/api/edge-devices",e,"smart-alerts"]});return}const _=S.notified||{sms:[],email:[],push:[]},A=_.sms.length+_.email.length+_.push.length,T=(S.errors||[]).length,M=S.recording,R=M?.personName||M?.label,D=M?`${M.camera}${R?` · ${R}`:""}${M.score!=null?` (${(M.score*100).toFixed(0)}%)`:""}`:"";r({title:"Rule matched — alert dispatched",description:[D,`${A} delivered${T?`, ${T} failed`:""}`].filter(Boolean).join(" — "),variant:T&&!A?"destructive":"default"}),Je.invalidateQueries({queryKey:["/api/edge-devices",e,"smart-alerts"]})},onError:S=>r({title:"Test failed",description:S?.message||"",variant:"destructive"})}),k=Et({mutationFn:async S=>(await Ze("POST",`/api/edge-devices/${e}/alert-groups/${S}/test`,{})).json(),onSuccess:S=>{const _=(S.results||[]).filter(T=>T.ok).length,A=(S.results||[]).length-_;r({title:"Test alert sent",description:`${_} delivered, ${A} failed`})},onError:S=>r({title:"Test failed",description:S?.message||"",variant:"destructive"})});return t.jsxs("div",{className:"space-y-6","data-testid":"tab-smart-alerts",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-base font-semibold flex items-center gap-2",children:[t.jsx(mi,{className:"w-4 h-4"})," Smart Alerts"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Get notified when AI detects events on your cameras. Build rules that target the right cameras during the right hours and notify the right people."})]}),t.jsx(Wze,{edgeDeviceId:e,hasAnyEnabledAiRule:(i.data||[]).some(S=>S.enabled&&tf(S))}),t.jsxs(_h,{value:n,onValueChange:S=>a(S),children:[t.jsxs(Dm,{children:[t.jsx(_n,{value:"groups","data-testid":"tab-smart-alerts-groups",children:"Alert Groups"}),t.jsx(_n,{value:"rules","data-testid":"tab-smart-alerts-rules",children:"Rules"})]}),t.jsxs(ea,{value:"rules",className:"space-y-3",children:[t.jsx(Kze,{edgeDeviceId:e,hasAiRules:(i.data||[]).some(S=>tf(S))}),t.jsx(Gze,{edgeDeviceId:e,hasAiRules:(i.data||[]).some(S=>tf(S))}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"text-sm text-muted-foreground",children:[(i.data||[]).length," rule",(i.data||[]).length===1?"":"s"]}),t.jsxs(L,{size:"sm",onClick:()=>v({open:!0,rule:null}),"data-testid":"button-new-smart-alert-rule",children:[t.jsx(Fo,{className:"w-3.5 h-3.5 mr-1"})," New Rule"]})]}),i.isLoading&&t.jsx("div",{className:"py-12 text-center text-muted-foreground",children:t.jsx(Fe,{className:"w-5 h-5 mx-auto animate-spin"})}),!i.isLoading&&(i.data||[]).length===0&&t.jsxs("div",{className:"text-center py-12 border border-dashed rounded-lg border-border",children:[t.jsx(mi,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:'No rules yet. Click "New Rule" to get started.'})]}),t.jsx("div",{className:"space-y-2",children:(i.data||[]).map(S=>t.jsx(ut,{"data-testid":`card-rule-${S.id}`,children:t.jsxs(mt,{className:"p-4 flex items-center gap-4",children:[t.jsx(sr,{checked:S.enabled,onCheckedChange:_=>w.mutate({id:S.id,enabled:_}),"data-testid":`switch-rule-enabled-${S.id}`}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"font-medium text-sm flex items-center gap-2","data-testid":`text-rule-name-${S.id}`,children:[S.name,(()=>{const _=Hze(S,h,p);return _?t.jsxs(Ke,{variant:"destructive",className:"gap-1 text-xs font-normal",title:_,"data-testid":`badge-rule-violation-${S.id}`,children:[t.jsx(Pn,{className:"w-3 h-3"})," Needs attention — edit to comply"]}):null})()]}),t.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5 flex flex-wrap gap-2",children:[t.jsx(Ke,{variant:"outline",children:S.triggerType}),t.jsx("span",{children:S.scheduleMode==="always"?"Always":`${S.scheduleStart}–${S.scheduleEnd}`}),t.jsx("span",{children:S.cameraScope==="all"?"All cameras":`${S.cameras?.length||0} cameras`}),t.jsxs("span",{children:[(S.alertGroupIds||[]).length," group",(S.alertGroupIds||[]).length===1?"":"s"]}),(()=>{const _=Object.values(S.lastFiredAt||{});if(_.length===0)return null;const A=_.sort().slice(-1)[0];return t.jsxs("span",{"data-testid":`text-rule-lastfired-${S.id}
558`,children:["Last fired: ",new Date(A).toLocaleString()]})})()]})]}),t.jsx(L,{size:"sm",variant:"ghost",title:"Test fire",onClick:()=>C.mutate(S.id),disabled:C.isPending,"data-testid":`button-test-rule-${S.id}`,children:C.isPending&&C.variables===S.id?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):t.jsx(Ja,{className:"w-3.5 h-3.5"})}),t.jsx(L,{size:"sm",variant:"ghost",onClick:()=>v({open:!0,rule:S}),"data-testid":`button-edit-rule-${S.id}`,children:t.jsx(ga,{className:"w-3.5 h-3.5"})}),t.jsx(L,{size:"sm",variant:"ghost",onClick:()=>{confirm(`Delete rule "${S.name}"?`)&&j.mutate(S.id)},"data-testid":`button-delete-rule-${S.id}`,children:t.jsx(sa,{className:"w-3.5 h-3.5 text-destructive"})})]})},S.id))})]}),t.jsxs(ea,{value:"groups",className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"text-sm text-muted-foreground",children:[(o.data||[]).length," group",(o.data||[]).length===1?"":"s"]}),t.jsxs(L,{size:"sm",onClick:()=>y({open:!0,group:null}),"data-testid":"button-new-alert-group",children:[t.jsx(Fo,{className:"w-3.5 h-3.5 mr-1"})," New Group"]})]}),o.isLoading&&t.jsx("div",{className:"py-12 text-center text-muted-foreground",children:t.jsx(Fe,{className:"w-5 h-5 mx-auto animate-spin"})}),!o.isLoading&&(o.data||[]).length===0&&t.jsxs("div",{className:"text-center py-12 border border-dashed rounded-lg border-border",children:[t.jsx(qi,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No alert groups yet. Create one and add Email / Push recipients."})]}),t.jsx("div",{className:"space-y-2",children:(o.data||[]).map(S=>t.jsx(ut,{"data-testid":`card-group-${S.id}`,children:t.jsxs(mt,{className:"p-4 flex items-center gap-4",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium text-sm","data-testid":`text-group-name-${S.id}`,children:S.name}),t.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5 flex flex-wrap gap-2 items-center",children:[S.channels.email&&t.jsxs(Ke,{variant:"outline",className:"gap-1",children:[t.jsx(qi,{className:"w-3 h-3"}),"Email"]}),S.channels.sms&&d&&t.jsxs(Ke,{variant:"outline",className:"gap-1",children:[t.jsx(qx,{className:"w-3 h-3"}),"SMS"]}),S.channels.push&&t.jsxs(Ke,{variant:"outline",className:"gap-1",children:[t.jsx(Yc,{className:"w-3 h-3"}),"Push"]}),t.jsxs("span",{children:[(S.recipients||[]).length," recipient",(S.recipients||[]).length===1?"":"s"]})]})]}),t.jsx(L,{size:"sm",variant:"outline",onClick:()=>k.mutate(S.id),disabled:k.isPending,"data-testid":`button-test-group-${S.id}`,children:k.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-3.5 h-3.5 mr-1"}),"Test"]})}),t.jsx(L,{size:"sm",variant:"ghost",onClick:()=>y({open:!0,group:S}),"data-testid":`button-edit-group-${S.id}`,children:t.jsx(ga,{className:"w-3.5 h-3.5"})}),t.jsx(L,{size:"sm",variant:"ghost",onClick:()=>{confirm(`Delete group "${S.name}"?`)&&x.mutate(S.id)},"data-testid":`button-delete-group-${S.id}`,children:t.jsx(sa,{className:"w-3.5 h-3.5 text-destructive"})})]})},S.id))})]})]}),g.open&&t.jsx(Xze,{edgeDeviceId:e,cameraNames:s,groups:o.data||[],existingRules:i.data||[],rule:g.rule||null,subscriptionCameraCount:h,onClose:()=>v({open:!1})}),b.open&&t.jsx(Zze,{edgeDeviceId:e,group:b.group||null,onClose:()=>y({open:!1})})]})}function Qze(e){const s=[];if(!e||typeof e!="object"||!("allOf"in e)||!Array.isArray(e.allOf))return s;for(const r of e.allOf)r?.object?s.push({kind:"object",labels:r.object.labels||[],minScore:r.object.minScore??.4}):r?.face?s.push({kind:"face",personLabelIds:r.face.personLabelIds||[],minScore:r.face.minScore??.85}):r?.action&&s.push({kind:"action",prompt:r.action.prompt||""});return s}function Xze({edgeDeviceId:e,cameraNames:s,groups:r,existingRules:n,rule:a,subscriptionCameraCount:i,onClose:o}){const{toast:l}=Hs(),[c,d]=u.useState(a?.name||""),[h,p]=u.useState(a?.enabled??!0),[g,v]=u.useState(a?.triggerType||"object"),b=a?.triggerConfig||{},[y,w]=u.useState(b.labels||b.object?.labels||["person"]),[j,x]=u.useState(b.minScore??.4),[C,k]=u.useState(b.prompt||""),[S,_]=u.useState(b.personLabelIds||[]),[A,T]=u.useState(b.minScore??.85),[M,R]=u.useState(a?.triggerType==="combined"?Qze(a.triggerConfig):[{kind:"object",labels:["person"],minScore:.4}]),$=ze({queryKey:["/api/edge-devices",e,"person-labels"],enabled:g==="face"||g==="combined"}).data?.labels||[],O=ze({queryKey:["/api/edge-devices",e,"ai-objects"],enabled:g==="object"||g==="combined"}),q=(()=>{const dt=O.data?.trackedObjects,Qt=dt&&dt.length>0?dt:qze;return Qt.includes("motion")?Qt:["motion",...Qt]})(),[V,K]=u.useState(a?.scheduleMode||"always"),[G,z]=u.useState(a?.scheduleStart||"21:00"),[Z,ee]=u.useState(a?.scheduleEnd||"05:00"),[Q,Y]=u.useState(a?.scheduleDays||[0,1,2,3,4,5,6]),[oe,he]=u.useState(a?.scheduleTimezone||Intl.DateTimeFormat().resolvedOptions().timeZone),[je,pe]=u.useState(a?.cameraScope||"all"),[le,ue]=u.useState(a?.cameras||[]),[fe,H]=u.useState(a?.cooldownSeconds||60),[se,me]=u.useState(a?.aiEvaluationIntervalSeconds??60),[ge,be]=u.useState(a?.maxAlertsPerMinute??0),[ce,Pe]=u.useState(a?.alertGroupIds||[]),et=g==="action"||g==="combined"&&M.some(dt=>dt.kind==="action"),$e=i??0,bt=n.filter(dt=>dt.enabled&&dt.id!==a?.id&&tf(dt)&&dt.scheduleMode==="always").length,Ae=a!=null&&a.enabled&&a.scheduleMode==="always"&&tf(a),Be=et&&!Ae&&bt>=2;u.useEffect(()=>{et&&(je!=="selected"&&pe("selected"),i!=null&&le.length>i&&ue(dt=>dt.slice(0,i)),V==="always"&&Be&&K("window"))},[et,je,le.length,i,V,Be]);const J=Et({mutationFn:async()=>{let dt;g==="object"?dt={labels:y,minScore:j}:g==="face"?dt={personLabelIds:S,minScore:A}:g==="action"?dt={prompt:C}:dt={allOf:M.map(Re=>Re.kind==="object"?{object:{labels:Re.labels,minScore:Re.minScore}}:Re.kind==="face"?{face:{personLabelIds:Re.personLabelIds,minScore:Re.minScore}}:{action:{prompt:Re.prompt}})};const Qt={name:c,enabled:h,triggerType:g,triggerConfig:dt,scheduleMode:V,scheduleStart:V==="window"?G:null,scheduleEnd:V==="window"?Z:null,scheduleDays:V==="window"?Q:null,scheduleTimezone:V==="window"?oe:null,cameraScope:je,cameras:je==="selected"?le:null,cooldownSeconds:fe,maxAlertsPerMinute:ge,aiEvaluationIntervalSeconds:se,alertGroupIds:ce};return a?Ze("PUT",`/api/edge-devices/${e}/smart-alerts/${a.id}`,Qt):Ze("POST",`/api/edge-devices/${e}/smart-alerts`,Qt)},onSuccess:()=>
558{Je.invalidateQueries({queryKey:["/api/edge-devices",e,"smart-alerts"]}),l({title:a?"Rule updated":"Rule created"}),o()},onError:dt=>l({title:"Save failed",description:dt?.message||"",variant:"destructive"})});let ae=!0;g==="object"?ae=y.length>0:g==="face"?ae=S.length>0:g==="action"?ae=C.trim().length>0:g==="combined"&&(ae=M.length>0&&M.every(dt=>dt.kind==="object"?dt.labels.length>0:dt.kind==="face"?dt.personLabelIds.length>0:dt.prompt.trim().length>0));const we=et&&i==null,Qe=!et||!we&&je==="selected"&&le.length>=1&&le.length<=$e,ye=V==="window"&&G&&Z?iie(G,Z):null,te=et&&ye!==null&&ye>720,Ue=!et||(V==="always"?!Be:!te),We=n.filter(dt=>dt.enabled&&dt.id!==a?.id&&tf(dt)).length,St=a!=null&&a.enabled&&tf(a),It=et&&h&&!St&&We>=5,ns=c.trim().length>0&&ce.length>0&&ae&&(je==="all"||le.length>0)&&Qe&&Ue&&!we&&!It;return t.jsx(Ys,{open:!0,onOpenChange:dt=>!dt&&o(),children:t.jsxs(Ws,{className:"max-w-xl max-h-[90vh] overflow-y-auto",children:[t.jsx(Zs,{children:t.jsx(Ks,{children:a?"Edit rule":"New Smart Alert rule"})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"rule-name",children:"Rule name"}),t.jsx(ke,{id:"rule-name",value:c,onChange:dt=>d(dt.target.value),placeholder:"e.g. After-hours person at front door","data-testid":"input-rule-name"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"Trigger"}),t.jsxs(Us,{value:g,onValueChange:dt=>v(dt),children:[t.jsx($s,{"data-testid":"select-trigger-type",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"object",children:"Basic Object Detection"}),t.jsx(rt,{value:"face",children:"Known Faces"}),t.jsx(rt,{value:"action",children:"AI Actions & Search"}),t.jsx(rt,{value:"combined",children:"Multiple Conditions"})]})]}),g==="object"&&t.jsxs("div",{className:"pl-1 pt-2 space-y-2",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Match these labels (any):"}),q.length===0?t.jsx("div",{className:"text-xs text-muted-foreground",children:"No objects enabled in AI Object Detection. Enable some in Device Settings → AI Object Detection."}):t.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(dt=>t.jsx(Ke,{variant:y.includes(dt)?"default":"outline",className:"cursor-pointer",onClick:()=>w(Qt=>Qt.includes(dt)?Qt.filter(Re=>Re!==dt):[...Qt,dt]),"data-testid":`badge-label-${dt}`,title:dt==="motion"?"Triggers on any new detection regardless of label or confidence":void 0,children:dt},dt))}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(re,{className:"text-xs",children:"Minimum confidence"}),t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground","data-testid":"text-min-score-value",children:j.toFixed(2)})]}),t.jsx(km,{min:0,max:1,step:.05,value:[j],onValueChange:dt=>x(dt[0]??.4),"data-testid":"input-min-score"})]})]}),g==="action"&&t.jsxs("div",{className:"pl-1 pt-2 space-y-1",children:[t.jsx(re,{className:"text-xs",children:"Describe what should trigger:"}),t.jsx(Nn,{value:C,onChange:dt=>k(dt.target.value),placeholder:"e.g. person riding a bicycle on the sidewalk","data-testid":"input-action-prompt"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Requires AI+ Features."})]}),g==="face"&&t.jsxs("div",{className:"pl-1 pt-2 space-y-2",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Match these enrolled people (any):"}),$.length===0?t.jsxs("div",{className:"text-xs text-muted-foreground",children:["No people enrolled yet. Add reference photos in ",t.jsx("strong",{children:"Faces & People"})," first."]}):t.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-32 overflow-y-auto",children:$.map(dt=>t.jsx(Ke,{variant:S.includes(dt.id)?"default":"outline",className:"cursor-pointer",onClick:()=>_(Qt=>Qt.includes(dt.id)?Qt.filter(Re=>Re!==dt.id):[...Qt,dt.id]),"data-testid":`badge-person-${dt.id}`,children:dt.name},dt.id))}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(re,{className:"text-xs",children:"Match distance (lower = stricter)"}),t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground","data-testid":"text-face-min-score-value",children:A.toFixed(2)})]}
558),t.jsx(km,{min:.3,max:1,step:.05,value:[A],onValueChange:dt=>T(dt[0]??.85),"data-testid":"input-face-min-score"})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Requires configured faces setup in 'Faces & People'"})]}),g==="combined"&&t.jsxs("div",{className:"pl-1 pt-2 space-y-2",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"All conditions below must match:"}),M.map((dt,Qt)=>t.jsxs("div",{className:"border rounded p-2 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Us,{value:dt.kind,onValueChange:Re=>R(pt=>pt.map((Ft,Es)=>Es===Qt?Re==="object"?{kind:"object",labels:["person"],minScore:.4}:Re==="face"?{kind:"face",personLabelIds:[],minScore:.85}:{kind:"action",prompt:""}:Ft)),children:[t.jsx($s,{className:"h-8 w-40",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"object",children:"Basic Object Detection"}),t.jsx(rt,{value:"face",children:"Known Faces"}),t.jsx(rt,{value:"action",children:"AI Actions & Search"})]})]}),t.jsx(L,{size:"sm",variant:"ghost",onClick:()=>R(Re=>Re.filter((pt,Ft)=>Ft!==Qt)),"data-testid":`button-remove-leaf-${Qt}`,children:t.jsx(sa,{className:"w-4 h-4"})})]}),dt.kind==="object"&&(q.length===0?t.jsx("div",{className:"text-xs text-muted-foreground",children:"No objects enabled in AI Object Detection."}):t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"flex flex-wrap gap-1",children:q.map(Re=>t.jsx(Ke,{variant:dt.labels.includes(Re)?"default":"outline",className:"cursor-pointer text-xs",title:Re==="motion"?"Triggers on any new detection regardless of label or confidence":void 0,onClick:()=>R(pt=>pt.map((Ft,Es)=>Es===Qt&&Ft.kind==="object"?{...Ft,labels:Ft.labels.includes(Re)?Ft.labels.filter(Ge=>Ge!==Re):[...Ft.labels,Re]}:Ft)),children:Re},Re))}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(re,{className:"text-xs",children:"Minimum confidence"}),t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground","data-testid":`text-leaf-min-score-value-${Qt}`,children:dt.minScore.toFixed(2)})]}),t.jsx(km,{min:0,max:1,step:.05,value:[dt.minScore],onValueChange:Re=>R(pt=>pt.map((Ft,Es)=>Es===Qt&&Ft.kind==="object"?{...Ft,minScore:Re[0]??.4}:Ft)),"data-testid":`input-leaf-min-score-${Qt}`})]})]})),dt.kind==="face"&&t.jsxs("div",{className:"space-y-2",children:[$.length===0?t.jsx("div",{className:"text-xs text-muted-foreground",children:"No people enrolled. Add references in Faces & People."}):t.jsx("div",{className:"flex flex-wrap gap-1",children:$.map(Re=>t.jsx(Ke,{variant:dt.personLabelIds.includes(Re.id)?"default":"outline",className:"cursor-pointer text-xs",onClick:()=>R(pt=>pt.map((Ft,Es)=>Es===Qt&&Ft.kind==="face"?{...Ft,personLabelIds:Ft.personLabelIds.includes(Re.id)?Ft.personLabelIds.filter(Ge=>Ge!==Re.id):[...Ft.personLabelIds,Re.id]}:Ft)),children:Re.name},Re.id))}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(re,{className:"text-xs",children:"Match distance (lower = stricter)"}),t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground","data-testid":`text-leaf-face-min-score-value-${Qt}`,children:dt.minScore.toFixed(2)})]}),t.jsx(km,{min:.3,max:1,step:.05,value:[dt.minScore],onValueChange:Re=>R(pt=>pt.map((Ft,Es)=>Es===Qt&&Ft.kind==="face"?{...Ft,minScore:Re[0]??.85}:Ft)),"data-testid":`input-leaf-face-min-score-${Qt}`})]})]}),dt.kind==="action"&&t.jsx(Nn,{value:dt.prompt,placeholder:"e.g. person carrying a package",className:"text-sm",onChange:Re=>R(pt=>pt.map((Ft,Es)=>Es===Qt&&Ft.kind==="action"?{...Ft,prompt:Re.target.value}:Ft))})]},Qt)),t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>R(dt=>[...dt,{kind:"object",labels:["person"],minScore:.4}]),"data-testid":"button-add-leaf",children:[t.jsx(Fo,{className:"w-4 h-4 mr-1"})," Add condition"]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Object and face conditions are available with any cloud or plus subscription. Action (text-prompt) conditions additionally require AI+ Features and a Smart Alerts subscription."})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"Schedule"}),t.jsxs(Us,{value:V,onValueChange:dt=>K(dt),children:[t.jsx($s,{"data-testid":"select-schedule-mode",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"always",disabled:Be,children:"Always on"}),t.jsx(rt,{value:"window",children:"Time window"})]})]}
558),et&&t.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:Be?"This device already has 2 AI rules running 24/7 — additional AI rules must use a scheduled window (maximum 12 hours per day).":`Up to 2 AI rules may run 24/7 per device (${bt} in use). Other AI rules must use a scheduled window of 12 hours or less.`}),V==="window"&&t.jsxs("div",{className:"space-y-2 pl-1 pt-2",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(ke,{type:"time",value:G,onChange:dt=>z(dt.target.value),className:"w-32","data-testid":"input-schedule-start"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"to"}),t.jsx(ke,{type:"time",value:Z,onChange:dt=>ee(dt.target.value),className:"w-32","data-testid":"input-schedule-end"}),et&&ye!==null&&t.jsxs("span",{className:`text-xs tabular-nums ${te?"text-destructive font-medium":"text-muted-foreground"}`,"data-testid":"text-window-span",children:[oie(ye),te?" — exceeds 12 h cap":" of 12 h max"]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"If end is earlier than start, the window wraps overnight."}),t.jsx("div",{className:"flex flex-wrap gap-1",children:Vze.map((dt,Qt)=>t.jsx(Ke,{variant:Q.includes(Qt)?"default":"outline",className:"cursor-pointer",onClick:()=>Y(Re=>Re.includes(Qt)?Re.filter(pt=>pt!==Qt):[...Re,Qt].sort()),"data-testid":`badge-day-${Qt}`,children:dt},Qt))}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{className:"text-xs",children:"Timezone"}),t.jsxs(Us,{value:oe,onValueChange:he,children:[t.jsx($s,{className:"text-xs","data-testid":"select-timezone",children:t.jsx(zs,{})}),t.jsx(Fs,{children:(J4.includes(oe)?J4:[oe,...J4]).map(dt=>t.jsx(rt,{value:dt,children:dt.replace(/_/g," ")},dt))})]})]})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"Cameras"}),t.jsxs(Us,{value:je,onValueChange:dt=>pe(dt),disabled:et,children:[t.jsx($s,{"data-testid":"select-camera-scope",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All cameras"}),t.jsx(rt,{value:"selected",children:"Selected cameras"})]})]}),je==="selected"&&t.jsxs("div",{className:"pl-1 pt-2 flex flex-wrap gap-1.5 max-h-32 overflow-y-auto",children:[s.length===0&&t.jsx("div",{className:"text-xs text-muted-foreground",children:"No cameras configured yet."}),s.map(dt=>t.jsx(Ke,{variant:le.includes(dt)?"default":"outline",className:"cursor-pointer",onClick:()=>{ue(et?Qt=>Qt.includes(dt)?Qt.filter(Re=>Re!==dt):Qt.length>=$e?Qt:[...Qt,dt]:Qt=>Qt.includes(dt)?Qt.filter(Re=>Re!==dt):[...Qt,dt])},"data-testid":`badge-camera-${dt}`,children:dt},dt))]}),et&&we&&t.jsx("p",{className:"text-xs text-destructive",children:"A Smart Alerts subscription is required to use AI-powered rules."}),et&&!we&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["AI Actions & Search rules must target between 1 and ",i," camera",i===1?"":"s"," (your Smart Alerts subscription covers ",i,")."]})]}),et&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"AI evaluation interval"}),t.jsxs(Us,{value:String(se),onValueChange:dt=>me(parseInt(dt,10)||60),children:[t.jsx($s,{"data-testid":"select-ai-eval-interval",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"30",children:"Every 30 seconds"}),t.jsx(rt,{value:"60",children:"Every 1 minute"}),t.jsx(rt,{value:"120",children:"Every 2 minutes"}),t.jsx(rt,{value:"300",children:"Every 5 minutes"})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Minimum time between evaluations per camera for this rule. When several events land inside the interval, only the newest one is evaluated."})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"Cooldown"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ke,{type:"number",min:5,max:3600,value:fe,onChange:dt=>H(parseInt(dt.target.value,10)||60),className:"w-32","data-testid":"input-cooldown"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"seconds"})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Minimum time between alerts per camera for this rule. If a match occurs during the cooldown window, no notification is sent but the event is still logged. Set to 0 to disable."})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(re,{children:"Max alerts per 5 minutes"}),t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground","data-testid":"text-max-alerts-value",children:ge===0?"No limit":`${ge}/5 min`})]}),t.jsx(km,{min:0,max:60,step:1,value:[ge],onValueChange:dt=>be(dt[0]??0),"data-testid":"input-max-alerts-per-minute"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"Notify these groups"}),r.length===0&&t.jsx("div",{className:"text-xs text-muted-foreground",children:"No alert groups yet — switch to the Alert Groups tab to add one."}),t.jsx("div",{className:"space-y-1.5",children:r.map(dt=>t.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer","data-testid":`check-group-${dt.id}
558`,children:[t.jsx(On,{checked:ce.includes(dt.id),onCheckedChange:Qt=>Pe(Re=>Qt?Array.from(new Set([...Re,dt.id])):Re.filter(pt=>pt!==dt.id))}),t.jsx("span",{children:dt.name}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(dt.recipients||[]).length," recipients)"]})]},dt.id))})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{checked:h,onCheckedChange:p,"data-testid":"switch-rule-enabled"}),t.jsx(re,{children:"Enabled"})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:o,children:"Cancel"}),(()=>{const dt=c.trim()?ae?we?"A Smart Alerts subscription is required for AI-powered rules.":It?"This device has reached the limit of 5 AI-powered alert rules.":je==="selected"&&le.length===0?"Pick at least one camera.":Qe?V==="always"&&et&&Be?"This device already has 2 always-on AI rules — use a scheduled window (≤ 12 h).":te?"Schedule window exceeds the 12-hour cap for AI-powered rules.":ce.length===0?"Pick at least one alert group to notify.":"":`AI Actions & Search rules must target 1–${$e} cameras.`:"Configure the trigger (pick at least one label / person / prompt).":"Add a rule name.";return t.jsxs("div",{className:"flex items-center gap-3",children:[dt&&t.jsx("span",{className:"text-xs text-muted-foreground max-w-[16rem] text-right","data-testid":"text-save-disabled-reason",children:dt}),t.jsxs(L,{onClick:()=>J.mutate(),disabled:!ns||J.isPending,title:dt||void 0,"data-testid":"button-save-rule",children:[J.isPending&&t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),"Save rule"]})]})})()]})]})})}function Zze({edgeDeviceId:e,group:s,onClose:r}){const{toast:n}=Hs(),[a,i]=u.useState(s?.name||""),[o,l]=u.useState(s?.channels||{sms:!0,email:!0,push:!0}),{data:c}=ze({queryKey:["/api/twilio/status"]}),d=c?.configured??!1,[h,p]=u.useState(s?.recipients||[]),[g,v]=u.useState(""),[b,y]=u.useState(""),w=Et({mutationFn:async()=>{const x={name:a,channels:o,recipients:h};return s?Ze("PUT",`/api/edge-devices/${e}/alert-groups/${s.id}`,x):Ze("POST",`/api/edge-devices/${e}/alert-groups`,x)},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/edge-devices",e,"alert-groups"]}),n({title:s?"Group updated":"Group created"}),r()},onError:x=>n({title:"Save failed",description:x?.message||"",variant:"destructive"})}),{data:j=[]}=ze({queryKey:["/api/edge-devices",e,"push-users"]});return t.jsx(Ys,{open:!0,onOpenChange:x=>!x&&r(),children:t.jsxs(Ws,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[t.jsx(Zs,{children:t.jsx(Ks,{children:s?"Edit alert group":"New alert group"})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"Group name"}),t.jsx(ke,{value:a,onChange:x=>i(x.target.value),placeholder:"e.g. Night Manager","data-testid":"input-group-name"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"Channels"}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs("label",{className:"flex items-center gap-1.5 text-sm",children:[t.jsx(On,{checked:o.email,onCheckedChange:x=>l({...o,email:!!x}),"data-testid":"check-channel-email"}),"Email"]}),d&&t.jsxs("label",{className:"flex items-center gap-1.5 text-sm",children:[t.jsx(On,{checked:o.sms,onCheckedChange:x=>l({...o,sms:!!x}),"data-testid":"check-channel-sms"}),"SMS"]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-sm",children:[t.jsx(On,{checked:o.push,onCheckedChange:x=>l({...o,push:!!x}),"data-testid":"check-channel-push"}),"Push (PWA)"]})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"Email recipients"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ke,{type:"email",value:g,onChange:x=>v(x.target.value),placeholder:"[email protected]","data-testid":"input-add-email"}),t.jsx(L,{size:"sm",variant:"outline",onClick:()=>{g.trim()&&(p(x=>[...x,{kind:"email",email:{address:g.trim()}}]),l(x=>({...x,email:!0})),v(""))},"data-testid":"button-add-email",children:"Add"})]})]}),d&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"SMS recipients"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ke,{type:"tel",value:b,onChange:x=>y(x.target.value),placeholder:"+15551234567","data-testid":"input-add-phone"}),t.jsx(L,{size:"sm",variant:"outline",onClick:()=>{const x=b.trim();if(x){if(!/^\+[1-9]\d{6,14}$/.test(x)){n({title:"Invalid phone number",description:"Use E164 format: +15551234567 (must start with + and country code)",variant:"destructive"});return}p(C=>[...C,{kind:"sms",sms:{phoneE164:x}}]),l(C=>({...C,sms:!0})),y("")}},"data-testid":"button-add-phone",children:"Add"})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:"Push recipients"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Select a user — all their enrolled devices receive the alert, including any they enroll later."}),j.length===0?t.jsxs("p",{className:"text-xs text-muted-foreground",children:["No users with enrolled devices yet. Users can enroll from their ",t.jsx("a",{href:"/account",className:"underline hover:text-foreground",children:"Account"})," page."]}):t.jsx("div",{className:"space-y-1",children:j.map(x=>{const C=h.some(k=>k.kind==="push-user"&&k.pushUser.userId===x.userId);return t.jsxs("div",{className:"flex items-center justify-between text-sm border rounded px-2 py-1.5","data-testid":`push-user-option-${x.userId}`,children:[t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Yc,{className:"w-3.5 h-3.5 text-muted-foreground"}),t.jsx("span",{className:"font-medium",children:x.displayName}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[x.deviceCount," device",x.deviceCount!==1?"s":""]})]}),C?t.jsx(Ke,{variant:"secondary",className:"text-xs",children:"Added"}):t.jsx(L,{size:"sm",variant:"outline",className:"h-6 text-xs px-2",onClick:()=>{p(k=>[...k,{kind:"push-user",pushUser:{userId:x.userId,displayName:x.displayName}}]),l(k=>({...k,push:!0}))},"data-testid":`button-add-push-user-${x.userId}`,children:"Add"})]},x.userId)})})]}),h.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{children:["Current recipients (",h.length,")"]}),t.jsx("div",{className:"space-y-1",children:h.map((x,C)=>t.jsxs("div",{className:"flex items-center justify-between text-sm border rounded px-2 py-1","data-testid":`row-recipient-${C}`,children:[t.jsxs("span",{className:"flex items-center gap-2",children:[x.kind==="email"&&t.jsxs(t.Fragment,{children:[t.jsx(qi,{className:"w-3.5 h-3.5"}),x.email.address]}),x.kind==="sms"&&t.jsxs(t.Fragment,{children:[t.jsx(qx,{className:"w-3.5 h-3.5"}),x.sms.phoneE164]}),x.kind==="push"&&t.jsxs(t.Fragment,{children:[t.jsx(Yc,{className:"w-3.5 h-3.5"}),"Push device (legacy)"]}),x.kind==="push-user"&&t.jsxs(t.Fragment,{children:[t.jsx(Yc,{className:"w-3.5 h-3.5"}
558),x.pushUser.displayName," (all devices)"]})]}),t.jsx(L,{size:"sm",variant:"ghost",onClick:()=>p(k=>k.filter((S,_)=>_!==C)),"data-testid":`button-remove-recipient-${C}`,children:t.jsx(sa,{className:"w-3.5 h-3.5 text-destructive"})})]},C))})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:r,children:"Cancel"}),t.jsxs(L,{onClick:()=>w.mutate(),disabled:!a.trim()||w.isPending,"data-testid":"button-save-group",children:[w.isPending&&t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),"Save group"]})]})]})})}const Jze={5:"5 minutes",15:"15 minutes",30:"30 minutes",60:"1 hour",240:"4 hours",480:"8 hours",720:"12 hours",1440:"24 hours"};function eHe({edgeDeviceId:e}){const{toast:s}=Hs(),r=["/api/edge-devices",e,"device-alerts"],{data:n,isPending:a,isError:i,refetch:o}=ze({queryKey:r,queryFn:async()=>{const d=await fetch(`/api/edge-devices/${e}/device-alerts`,{credentials:"include"});if(!d.ok)throw new Error("Could not load device alert settings");return d.json()}}),l=Et({mutationFn:async d=>(await Ze("PUT",`/api/edge-devices/${e}/device-alerts`,d)).json(),onSuccess:d=>Je.setQueryData(r,d),onError:d=>s({title:"Could not save Device Alerts",description:d.message,variant:"destructive"})});if(a)return t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground","data-testid":"tab-device-alerts",children:[t.jsx(Fe,{className:"w-4 h-4 animate-spin"}),"Loading Device Alerts…"]});if(i||!n)return t.jsxs("div",{className:"text-sm text-destructive","data-testid":"tab-device-alerts",children:["Could not load Device Alerts. ",t.jsx("button",{className:"underline",onClick:()=>o(),children:"Retry"})]});const c=[{key:"deviceOfflineAlertEnabled",label:"Edge Device Offline",help:"Notify when the Edge device stays offline for the selected duration."},{key:"cameraOfflineAlertEnabled",label:"Camera Offline",help:"Notify when a camera stays offline for the selected duration."},{key:"resolvedAlertEnabled",label:"Resolved Alerts",help:"Notify when a confirmed offline device or camera comes back online."}];return t.jsxs("div",{className:"max-w-4xl space-y-4","data-testid":"tab-device-alerts",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"Device Alerts"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Choose which device health notifications are sent and when an outage is confirmed."})]}),t.jsxs("div",{className:"rounded-lg border border-border divide-y divide-border",children:[c.map(({key:d,label:h,help:p})=>t.jsxs("div",{className:"flex items-center justify-between gap-4 p-4",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(mi,{className:"w-4 h-4 mt-0.5 text-muted-foreground shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:h}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:p})]})]}),t.jsx(sr,{"aria-label":h,checked:n[d],disabled:l.isPending,onCheckedChange:g=>l.mutate({[d]:g}),"data-testid":`switch-${d}`})]},d)),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Detection duration"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"How long a device or camera must stay offline before it is confirmed offline."})]}),t.jsxs(Us,{value:String(n.offlineDetectionMinutes),disabled:l.isPending,onValueChange:d=>l.mutate({offlineDetectionMinutes:Number(d)}),children:[t.jsx($s,{className:"w-36","aria-label":"Detection duration","data-testid":"select-device-alert-duration",children:t.jsx(zs,{})}),t.jsx(Fs,{children:tie.map(d=>t.jsx(rt,{value:String(d),children:Jze[d]},d))})]})]})]})]})}var JD="Radio",[tHe,lie]=oo(JD),[sHe,rHe]=tHe(JD),cie=u.forwardRef((e,s)=>{const{__scopeRadio:r,name:n,checked:a=!1,required:i,disabled:o,value:l="on",onCheck:c,form:d,...h}=e,[p,g]=u.useState(null),v=mr(s,w=>g(w)),b=u.useRef(!1),y=p?d||!!p.closest("form"):!0;return t.jsxs(sHe,{scope:r,checked:a,disabled:o,children:[t.jsx(Cr.button,{type:"button",role:"radio","aria-checked":a,"data-state":mie(a),"data-disabled":o?"":void 0,disabled:o,value:l,...h,ref:v,onClick:Ms(e.onClick,w=>{a||c?.(),y&&(b.current=w.isPropagationStopped(),b.current||w.stopPropagation())})}),y&&t.jsx(nHe,{control:p,bubbles:!b.current,name:n,value:l,checked:a,required:i,disabled:o,form:d,style:{transform:"translateX(-100%)"}})]})});cie.displayName=JD;var die="RadioIndicator",uie=u.forwardRef((e,s)=>{const{__scopeRadio:r,forceMount:n,...a}=e,i=rHe(die,r);return t.jsx($m,{present:n||i.checked,children:t.jsx(Cr.span,{"data-state":mie(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:s})})});uie.displayName=die;var nHe=e=>{const{control:s,checked:r,bubbles:n=!0,...a}=e,i=u.useRef(null),o=Gj(r),l=_b(s);return u.useEffect(()=>{const c=i.current,d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"checked").set;if(o!==r&&p){const g=new Event("click",{bubbles:n});p.call(c,r),c.dispatchEvent(g)}},[o,r,n]),t.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:i,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function mie(e){return e?"checked":"unchecked"}var aHe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],eL="RadioGroup",[iHe]=oo(eL,[Xk,lie]),hie=Xk(),pie=lie(),[oHe,lHe]=iHe(eL),fie=u.forwardRef((e,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:a,value:i,required:o=!1,disabled:l=!1,orientation:c,dir:d,loop:h=!0,onValueChange:p,...g}=e,v=hie(r),b=Og(d),[y,w]=ip({prop:i,defaultProp:a,onChange:p});return t.jsx(oHe,{scope:r,name:n,required:o,disabled:l,value:y,onValueChange:w,children:t.jsx(SQ,{asChild:!0,...v,orientation:c,dir:b,loop:h,children:t.jsx(Cr.div,{role:"radiogroup","aria-required":o,"aria-orientation":c,"data-disabled":l?"":void 0,dir:b,...g,ref:s})})})});fie.displayName=eL;var gie="RadioGroupItem",xie=u.forwardRef((e,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=e,i=lHe(gie,r),o=i.disabled||n,l=hie(r),c=pie(r),d=u.useRef(null),h=mr(s,d),p=i.value===a.value,g=u.useRef(!1);return u.useEffect(()=>{const v=y=>{aHe.includes(y.key)&&(g.current=!0)},b=()=>g.current=!1;return document.addEventListener("keydown",v),document.addEventListener("keyup",b),()=>{document.removeEventListener("keydown",v),document.removeEventListener("keyup",b)}},[]),t.jsx(CQ,{asChild:!0,...l,focusable:!o,active:p,children:t.jsx(cie,{disabled:o,required:i.required,
558checked:p,...c,...a,name:i.name,ref:h,onCheck:()=>i.onValueChange(a.value),onKeyDown:Ms(v=>{v.key==="Enter"&&v.preventDefault()}),onFocus:Ms(a.onFocus,()=>{g.current&&d.current?.click()})})})});xie.displayName=gie;var cHe="RadioGroupIndicator",vie=u.forwardRef((e,s)=>{const{__scopeRadioGroup:r,...n}=e,a=pie(r);return t.jsx(uie,{...a,...n,ref:s})});vie.displayName=cHe;var yie=fie,bie=xie,dHe=vie;const b0=u.forwardRef(({className:e,...s},r)=>t.jsx(yie,{className:Cs("grid gap-2",e),...s,ref:r}));b0.displayName=yie.displayName;const Gh=u.forwardRef(({className:e,...s},r)=>t.jsx(bie,{ref:r,className:Cs("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),...s,children:t.jsx(dHe,{className:"flex items-center justify-center",children:t.jsx(PK,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Gh.displayName=bie.displayName;const uHe=3e3,mHe=2.5*60*1e3;function hHe({open:e,onOpenChange:s,edgeDeviceId:r,onAssigned:n}){const{toast:a}=Hs(),[i,o]=u.useState("questions"),[l,c]=u.useState(!1),[d,h]=u.useState(""),[p,g]=u.useState(null),[v,b]=u.useState(""),[y,w]=u.useState("unsure"),[j,x]=u.useState(""),[C,k]=u.useState(""),[S,_]=u.useState([]),[A,T]=u.useState([]),[M,R]=u.useState(new Set),[D,$]=u.useState(""),[O,q]=u.useState(0),V=u.useRef(null),K=u.useRef(null),G=()=>{o("questions"),c(!1),h(""),g(null),_([]),T([]),R(new Set),$(""),q(0),x(""),k("")},z=async H=>{try{await Ze("POST",`/api/edge-devices/${r}/commands/${H}/cancel-discovery`)}catch{a({title:"Could not cancel the device scan",description:"The device may finish scanning in the background.",variant:"destructive"})}},Z=()=>{V.current?.abort(),V.current=null;const H=K.current;K.current=null,H&&z(H)};u.useEffect(()=>()=>{Z()},[r]);const ee=H=>{if(H){s(!0);return}l&&i==="review"||(Z(),s(!1),G())},Q=H=>{if(H.aborted)throw new DOMException("Setup cancelled","AbortError")},Y=async(H,se,me)=>{const ge=await Ze("POST",H,se),{commandId:be}=await ge.json();if(!be)throw new Error("Device did not return a command ID");return me.aborted&&(z(be),Q(me)),K.current=be,be},oe=async(H,se)=>{const me=Date.now()+mHe;try{for(;Date.now()<me;){Q(se),await new Promise(ce=>setTimeout(ce,uHe)),Q(se);const ge=await fetch(`/api/edge-devices/${r}/commands/${H}/status`,{credentials:"include",signal:se});if(!ge.ok)continue;const be=await ge.json();if(Q(se),be.status==="completed")return{ok:!0,message:be.result||void 0};if(be.status==="failed"||be.status==="cancelled")return{ok:!1,message:be.result||"Command failed"}}return{ok:!1,message:"Timed out waiting for the device"}}finally{K.current===H&&(K.current=null)}},he=async H=>{const se=await fetch(`/api/edge-devices/${r}/discovered-cameras`,{credentials:"include",signal:H});if(!se.ok)throw new Error("Failed to load discovered cameras");const me=await se.json();return Q(H),me},je=async()=>{const H=new AbortController;V.current=H;const{signal:se}=H;c(!0),g(null),o("scan"),h("Scanning the network for cameras…");try{const me=await Y(`/api/edge-devices/${r}/camera-scan`,{extraSubnets:[]},se),ge=await oe(me,se);if(!ge.ok)throw new Error(ge.message||"Scan failed");const be=await he(se);if(_(be),be.length===0)throw new Error("No cameras were found on the network. Make sure your cameras are powered on and connected, then try again.");await pe(be,se)}catch(me){if(se.aborted)return;V.current=null,g(me.message||"Scan failed"),c(!1)}},pe=async(H,se)=>{Q(se),o("probe"),h(`Found ${H.length} device(s). Connecting with your credentials to retrieve stream URLs…`);try{const me=H.filter(ce=>!ce.rtspMainStream).map(ce=>({ip:ce.ipAddress,port:ce.port||80}));if(me.length>0){const ce=await Y(`/api/edge-devices/${r}/camera-probe`,{targets:me,username:j,password:C},se),Pe=await oe(ce,se);if(!Pe.ok)throw new Error(Pe.message||"Probe failed")}const ge=await he(se);if(_(ge),ge.filter(ce=>ce.rtspMainStream||Array.isArray(ce.channels)&&ce.channels.length>0).length===0)throw new Error("None of the discovered devices responded with stream URLs. Check the camera username and password and try again.");await le(se)}catch(me){if(se.aborted)return;V.current=null,g(me.message||"Probe failed"),c(!1)}},le=async H=>{Q(H),o("propose"),h("Asking the AI to map your cameras to channels…");try{const me=await(await Ze("POST",`/api/edge-devices/${r}
558/ai-config-assist/propose-assignments`,{cameraCount:v?Number(v):void 0,setupType:y})).json();Q(H);const ge=me.proposals||[];T(ge),R(new Set(ge.map(be=>be.channelName))),$(me.summary||""),o("review"),c(!1),V.current=null}catch(se){if(H.aborted)return;V.current=null,g(se.message||"The AI assistant could not generate a proposal."),c(!1)}},ue=async()=>{const H=A.filter(se=>M.has(se.channelName));if(H.length!==0){c(!0),g(null);try{const se=H.map((ce,Pe)=>({proposal:ce,unitKey:`ai:${ce.discoveredCameraId||Pe}:${ce.channelName}`})),ge=await(await Ze("POST",`/api/edge-devices/${r}/frigate-config/assign-cameras`,{selectedUnitKeys:se.map(({unitKey:ce})=>ce),assignments:se.map(({proposal:ce,unitKey:Pe})=>({unitKey:Pe,channelName:ce.channelName,mainStreamUrl:ce.mainStreamUrl,subStreamUrl:ce.subStreamUrl,displayName:ce.displayName,useGo2rtc:!0,discoveredCameraId:ce.discoveredCameraId}))})).json(),be=Array.isArray(ge.results)?ge.results.filter(ce=>ce.ok).length:H.length;q(be),o("done"),c(!1),n()}catch(se){g(se.message||"Failed to queue camera assignments"),c(!1)}}},fe=!j.trim();return t.jsx(Ys,{open:e,onOpenChange:ee,children:t.jsxs(Ws,{className:"max-w-lg","data-testid":"dialog-ai-config-wizard",children:[t.jsxs(Zs,{children:[t.jsxs(Ks,{className:"flex items-center gap-2",children:[t.jsx(Do,{className:"w-4 h-4 text-primary"}),"AI Camera Setup"]}),i==="questions"&&t.jsx(cr,{children:"Answer a few questions and the assistant will scan your network, connect to your cameras, and propose channel assignments for your review. Nothing is applied until you confirm and click Apply Changes."})]}),i==="questions"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"How many cameras do you expect? (optional)"}),t.jsx(ke,{type:"number",min:1,max:128,value:v,onChange:H=>b(H.target.value),placeholder:"e.g. 8",className:"h-8 text-sm mt-1","data-testid":"input-wizard-camera-count"})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"What kind of setup do you have?"}),t.jsxs(b0,{value:y,onValueChange:H=>w(H),className:"mt-1.5 space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Gh,{value:"nvr",id:"ai-setup-nvr"}),t.jsx(re,{htmlFor:"ai-setup-nvr",className:"text-sm font-normal",children:"Cameras connected through an NVR / DVR"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Gh,{value:"standalone",id:"ai-setup-standalone"}),t.jsx(re,{htmlFor:"ai-setup-standalone",className:"text-sm font-normal",children:"Standalone IP cameras"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Gh,{value:"mixed",id:"ai-setup-mixed"}),t.jsx(re,{htmlFor:"ai-setup-mixed",className:"text-sm font-normal",children:"A mix of both"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Gh,{value:"unsure",id:"ai-setup-unsure"}),t.jsx(re,{htmlFor:"ai-setup-unsure",className:"text-sm font-normal",children:"Not sure"})]})]})]}),t.jsxs("div",{children:[t.jsxs(re,{className:"text-xs flex items-center gap-1",children:[t.jsx($w,{className:"w-3 h-3"})," Camera / NVR credentials"]}),t.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:"Used only to connect to your cameras and retrieve stream URLs. Never shared with the AI."}),t.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 mt-1.5",children:[t.jsx(ke,{placeholder:"Username",value:j,onChange:H=>x(H.target.value),className:"h-8 text-sm",autoComplete:"off","data-testid":"input-wizard-username"}),t.jsx(ke,{type:"password",placeholder:"Password",value:C,onChange:H=>k(H.target.value),className:"h-8 text-sm",autoComplete:"new-password","data-testid":"input-wizard-password"})]})]}),p&&t.jsxs("p",{className:"text-xs text-destructive flex items-start gap-1",children:[t.jsx(Pn,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),p]})]}),(i==="scan"||i==="probe"||i==="propose")&&t.jsx("div",{className:"py-6 text-center space-y-3",children:p?t.jsxs(t.Fragment,{children:[t.jsx(Pn,{className:"w-6 h-6 mx-auto text-destructive"}),t.jsx("p",{className:"text-sm text-destructive","data-testid":"text-wizard-error",children:p})]}):t.jsxs(t.Fragment,{children:[i==="scan"?t.jsx(Wh,{className:"w-6 h-6 mx-auto text-primary animate-pulse"}):t.jsx(Fe,{className:"w-6 h-6 mx-auto text-primary animate-spin"}),t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-wizard-status",children:d}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"This can take a minute or two."})]})}),i==="review"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[t.jsx(dde,{className:"w-4 h-4 text-primary"})," Proposed channel assignments"]}),D&&t.jsx("p",{className:"text-xs text-muted-foreground",children:D}),t.jsx("div",{className:"space-y-1.5 max-h-64 overflow-y-auto pr-1",children:A.map(H=>t.jsxs("label",{className:"flex items-center gap-2.5 p-2 rounded-md border border-border text-sm cursor-pointer","data-testid":`row-proposal-${H.channelName}`,children:[t.jsx(On,{checked:M.has(H.channelName),onCheckedChange:se=>{R(me=>{const ge=new Set(me);return se?ge.add(H.channelName):ge.delete(H.channelName),ge})}}),t.jsx("span",{className:"font-mono text-xs text-muted-foreground shrink-0",children:H.channelName}),t.jsx("span",{className:"flex-1 min-w-0 truncate",children:H.displayName}),t.jsxs("span",{className:"text-[11px] text-muted-foreground shrink-0",children:[H.ip,H.nvrChannel!=null?` · ch ${H.nvrChannel}`:""]})]},H.channelName))}),t.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Confirming stages these as pending changes. You still need to click ",t.jsx("strong",{children:"Apply Changes"})," on the Streams tab to make them live."]}),p&&t.jsx("p",{className:"text-xs text-destructive",children:p})]}),i==="done"&&t.jsxs("div",{className:"py-4 text-center space-y-2",children:[t.jsx(Do,{
558className:"w-6 h-6 mx-auto text-primary"}),t.jsxs("p",{className:"text-sm","data-testid":"text-wizard-done",children:[O," camera",O===1?"":"s"," staged as pending changes."]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Go to the Streams tab and click Apply Changes to make them live."})]}),t.jsxs(In,{children:[i==="questions"&&t.jsxs(t.Fragment,{children:[t.jsx(L,{variant:"ghost",onClick:()=>ee(!1),"data-testid":"button-wizard-cancel",children:"Cancel"}),t.jsxs(L,{onClick:je,disabled:fe||l,"data-testid":"button-wizard-start",children:[l?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(Wh,{className:"w-3.5 h-3.5 mr-1"}),"Start Setup"]})]}),(i==="scan"||i==="probe"||i==="propose")&&(p?t.jsxs(t.Fragment,{children:[t.jsx(L,{variant:"ghost",onClick:()=>ee(!1),children:"Close"}),t.jsx(L,{onClick:()=>{g(null),o("questions")},"data-testid":"button-wizard-retry",children:"Back"})]}):t.jsx(L,{variant:"ghost",onClick:()=>ee(!1),"data-testid":"button-wizard-cancel-scan",children:"Cancel setup"})),i==="review"&&t.jsxs(t.Fragment,{children:[t.jsx(L,{variant:"ghost",onClick:()=>ee(!1),disabled:l,children:"Cancel"}),t.jsxs(L,{onClick:ue,disabled:l||M.size===0,"data-testid":"button-wizard-confirm",children:[l&&t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),"Confirm ",M.size," Assignment",M.size===1?"":"s"]})]}),i==="done"&&t.jsx(L,{onClick:()=>ee(!1),"data-testid":"button-wizard-close",children:"Done"})]})]})})}function e5({edgeDeviceId:e,context:s,errorText:r,camera:n,compact:a}){const[i,o]=u.useState(!1),[l,c]=u.useState(!1),[d,h]=u.useState(null),[p,g]=u.useState(null),v=async()=>{if(o(!0),!(d||l)){c(!0),g(null);try{const b=await Ze("POST",`/api/edge-devices/${e}/ai-config-assist/diagnose-failure`,{context:s,errorText:r,camera:n});h(await b.json())}catch(b){g(b.message||"The AI assistant could not diagnose this error.")}finally{c(!1)}}};return t.jsxs(t.Fragment,{children:[t.jsxs(L,{variant:"ghost",size:"sm",className:a?"h-5 px-1.5 text-[10px]":"h-6 px-2 text-[11px]",onClick:v,"data-testid":"button-ai-explain-error",children:[t.jsx(Do,{className:"w-3 h-3 mr-1 text-primary"}),"Explain with AI"]}),t.jsx(Ys,{open:i,onOpenChange:o,children:t.jsxs(Ws,{className:"max-w-md","data-testid":"dialog-ai-diagnosis",children:[t.jsx(Zs,{children:t.jsxs(Ks,{className:"flex items-center gap-2 text-base",children:[t.jsx(Do,{className:"w-4 h-4 text-primary"}),"What went wrong?"]})}),l&&t.jsxs("div",{className:"py-6 text-center",children:[t.jsx(Fe,{className:"w-5 h-5 mx-auto animate-spin text-primary"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Analyzing the error…"})]}),p&&t.jsx("p",{className:"text-sm text-destructive","data-testid":"text-ai-diagnosis-error",children:p}),d&&t.jsxs("div",{className:"space-y-3 text-sm",children:[d.likelyCause&&t.jsx(Ke,{variant:"secondary",className:"text-xs","data-testid":"badge-ai-likely-cause",children:d.likelyCause}),t.jsx("p",{"data-testid":"text-ai-explanation",children:d.explanation}),d.nextSteps.length>0&&t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Try this next:"}),t.jsx("ul",{className:"space-y-1",children:d.nextSteps.map((b,y)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-xs",children:[t.jsx(ar,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-primary"}),t.jsx("span",{children:b})]},y))})]})]}),t.jsx(In,{children:t.jsx(L,{size:"sm",onClick:()=>o(!1),"data-testid":"button-ai-diagnosis-close",children:"Close"})})]})})]})}function pHe({edgeDeviceId:e}){const[s,r]=u.useState(!1),[n,a]=u.useState(!1),[i,o]=u.useState(null),[l,c]=u.useState(null),d=async()=>{r(!0),a(!0),o(null),c(null);try{const h=await Ze("POST",`/api/edge-devices/${e}/ai-config-assist/review-config`,{});c(await h.json())}catch(h){o(h.message||"The AI assistant could not review the configuration.")}finally{a(!1)}};return t.jsxs(t.Fragment,{children:[t.jsxs(L,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:d,"data-testid":"button-ai-review-config",children:[t.jsx(Do,{className:"w-3.5 h-3.5 mr-1 text-primary"}),"AI Review"]}),t.jsx(Ys,{open:s,onOpenChange:r,children:t.jsxs(Ws,{className:"max-w-md","data-testid":"dialog-ai-config-review",children:[t.jsxs(Zs,{children:[t.jsxs(Ks,{className:"flex items-center gap-2 text-base",children:[t.jsx(Do,{
558className:"w-4 h-4 text-primary"}),"AI Config Review"]}),t.jsx(cr,{children:"Advisory only — you can apply your changes regardless of what the review finds."})]}),n&&t.jsxs("div",{className:"py-6 text-center",children:[t.jsx(Fe,{className:"w-5 h-5 mx-auto animate-spin text-primary"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Reviewing your pending camera configuration…"})]}),i&&t.jsx("p",{className:"text-sm text-destructive","data-testid":"text-ai-review-error",children:i}),l&&t.jsxs("div",{className:"space-y-3 text-sm",children:[l.summary&&t.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"text-ai-review-summary",children:l.summary}),l.findings.length===0?t.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 dark:text-emerald-400","data-testid":"text-ai-review-clean",children:[t.jsx(ar,{className:"w-4 h-4"}),t.jsxs("span",{children:["No issues found across ",l.camerasReviewed," camera",l.camerasReviewed===1?"":"s","."]})]}):t.jsx("ul",{className:"space-y-1.5 max-h-64 overflow-y-auto pr-1",children:l.findings.map((h,p)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-xs","data-testid":`row-ai-finding-${p}`,children:[h.severity==="warning"?t.jsx(Pn,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-amber-500"}):t.jsx(Sy,{className:"w-3.5 h-3.5 mt-0.5 shrink-0 text-sky-500"}),t.jsxs("span",{children:[h.channel&&t.jsx("span",{className:"font-mono text-muted-foreground mr-1",children:h.channel}),h.message]})]},p))})]}),t.jsx(In,{children:t.jsx(L,{size:"sm",onClick:()=>r(!1),"data-testid":"button-ai-review-close",children:"Close"})})]})})]})}var wie=Object.defineProperty,fHe=Object.getOwnPropertyDescriptor,gHe=(e,s)=>{for(var r in s)wie(e,r,{get:s[r],enumerable:!0})},Bo=(e,s,r,n)=>{for(var a=n>1?void 0:n?fHe(s,r):s,i=e.length-1,o;i>=0;i--)(o=e[i])&&(a=(n?o(s,r,a):o(a))||a);return n&&a&&wie(s,r,a),a},Js=(e,s)=>(r,n)=>s(r,n,e),j9="Terminal input",eI={get:()=>j9,set:e=>j9=e},N9="Too much output to announce, navigate to rows manually to read",tI={get:()=>N9,set:e=>N9=e};function xHe(e){return e.replace(/\r?\n/g,"\r")}function vHe(e,s){return s?"\x1B[200~"+e+"\x1B[201~":e}function yHe(e,s){e.clipboardData&&e.clipboardData.setData("text/plain",s.selectionText),e.preventDefault()}function bHe(e,s,r,n){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");jie(a,s,r,n)}}function jie(e,s,r,n){e=xHe(e),e=vHe(e,r.decPrivateModes.bracketedPasteMode&&n.rawOptions.ignoreBracketedPasteMode!==!0),r.triggerDataEvent(e,!0),s.value=""}function Nie(e,s,r){let n=r.getBoundingClientRect(),a=e.clientX-n.left-10,i=e.clientY-n.top-10;s.style.width="20px",s.style.height="20px",s.style.left=`${a}px`,s.style.top=`${i}px`,s.style.zIndex="1000",s.focus()}function S9(e,s,r,n,a){Nie(e,s,r),a&&n.rightClickSelect(e),s.value=n.selectionText,s.select()}function lg(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function d2(e,s=0,r=e.length){let n="";for(let a=s;a<r;++a){let i=e[a];i>65535?(i-=65536,n+=String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):n+=String.fromCharCode(i)}return n}var wHe=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,s){let r=e.length;if(!r)return 0;let n=0,a=0;if(this._interim){let i=e.charCodeAt(a++);56320<=i&&i<=57343?s[n++]=(this._interim-55296)*1024+i-56320+65536:(s[n++]=this._interim,s[n++]=i),this._interim=0}for(let i=a;i<r;++i){let o=e.charCodeAt(i);if(55296<=o&&o<=56319){if(++i>=r)return this._interim=o,n;let l=e.charCodeAt(i);56320<=l&&l<=57343?s[n++]=(o-55296)*1024+l-56320+65536:(s[n++]=o,s[n++]=l);continue}o!==65279&&(s[n++]=o)}return n}},jHe=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,s){let r=e.length;if(!r)return 0;let n=0,a,i,o,l,c=0,d=0;if(this.interim[0]){let g=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let b=0,y;for(;(y=this.interim[++b]&63)&&b<4;)v<<=6,v|=y;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,j=w-b;for(;d<j;){if(d>=r)return 0;if(y=e[d++],(y&192)!==128){d--,g=!0;break}else this.interim[b++]=y,v<<=6,v|=y&63}g||(w===2?v<128?d--:s[n++]=v:w===3?v<2048||v>=55296&&v<=57343||v===65279||(s[n++]=v):v<65536||v>1114111||(s[n++]=v)),this.interim.fill(0)}let h=r-4,p=d;for(;p<r;){for(;p<h&&!((a=e[p])&128)&&!((i=e[p+1])&128)&&!((o=e[p+2])&128)&&!((l=e[p+3])&128);)s[n++]=a,s[n++]=i,s[n++]=o,s[n++]=l,p+=4;if(a=e[p++],a<128)s[n++]=a;else if((a&224)===192){if(p>=r)return this.interim[0]=a,n;if(i=e[p++],(i&192)!==128){p--;continue}if(c=(a&31)<<6|i&63,c<128){p--;continue}s[n++]=c}else if((a&240)===224){if(p>=r)return this.interim[0]=a,n;if(i=e[p++],(i&192)!==128){p--;continue}if(p>=r)return this.interim[0]=a,this.interim[1]=i,n;if(o=e[p++],(o&192)!==128){p--;continue}if(c=(a&15)<<12|(i&63)<<6|o&63,c<2048||c>
558=55296&&c<=57343||c===65279)continue;s[n++]=c}else if((a&248)===240){if(p>=r)return this.interim[0]=a,n;if(i=e[p++],(i&192)!==128){p--;continue}if(p>=r)return this.interim[0]=a,this.interim[1]=i,n;if(o=e[p++],(o&192)!==128){p--;continue}if(p>=r)return this.interim[0]=a,this.interim[1]=i,this.interim[2]=o,n;if(l=e[p++],(l&192)!==128){p--;continue}if(c=(a&7)<<18|(i&63)<<12|(o&63)<<6|l&63,c<65536||c>1114111)continue;s[n++]=c}}return n}},Sie="",vg=" ",wN=class Cie{constructor(){this.fg=0,this.bg=0,this.extended=new jk}static toColorRGB(s){return[s>>>16&255,s>>>8&255,s&255]}static fromColorRGB(s){return(s[0]&255)<<16|(s[1]&255)<<8|s[2]&255}clone(){let s=new Cie;return s.fg=this.fg,s.bg=this.bg,s.extended=this.extended.clone(),s}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},jk=class kie{constructor(s=0,r=0){this._ext=0,this._urlId=0,this._ext=s,this._urlId=r}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(s){this._ext=s}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(s){this._ext&=-469762049,this._ext|=s<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(s){this._ext&=-67108864,this._ext|=s&67108863}get urlId(){return this._urlId}set urlId(s){this._urlId=s}get underlineVariantOffset(){let s=(this._ext&3758096384)>>29;return s<0?s^4294967288:s}set underlineVariantOffset(s){this._ext&=536870911,this._ext|=s<<29&3758096384}clone(){return new kie(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Im=class _ie extends wN{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new jk,this.combinedData=""}static fromCharData(s){let r=new _ie;return r.setFromCharData(s),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?lg(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(s){this.fg=s[0],this.bg=0;let r=!1;if(s[1].length>2)r=!0;
558else if(s[1].length===2){let n=s[1].charCodeAt(0);if(55296<=n&&n<=56319){let a=s[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(n-55296)*1024+a-56320+65536|s[2]<<22:r=!0}else r=!0}else this.content=s[1].charCodeAt(0)|s[2]<<22;r&&(this.combinedData=s[1],this.content=2097152|s[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},C9="di$target",sI="di$dependencies",t5=new Map;function NHe(e){return e[sI]||[]}function jc(e){if(t5.has(e))return t5.get(e);let s=function(r,n,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");SHe(s,r,a)};return s._id=e,t5.set(e,s),s}function SHe(e,s,r){s[C9]===s?s[sI].push({id:e,index:r}):(s[sI]=[{id:e,index:r}],s[C9]=s)}var Jd=jc("BufferService"),Pie=jc("CoreMouseService"),vv=jc("CoreService"),CHe=jc("CharsetService"),tL=jc("InstantiationService"),Eie=jc("LogService"),eu=jc("OptionsService"),Tie=jc("OscLinkService"),kHe=jc("UnicodeService"),jN=jc("DecorationService"),rI=class{constructor(e,s,r){this._bufferService=e,this._optionsService=s,this._oscLinkService=r}provideLinks(e,s){let r=this._bufferService.buffer.lines.get(e-1);if(!r){s(void 0);return}let n=[],a=this._optionsService.rawOptions.linkHandler,i=new Im,o=r.getTrimmedLength(),l=-1,c=-1,d=!1;for(let h=0;h<o;h++)if(!(c===-1&&!r.hasContent(h))){if(r.loadCell(h,i),i.hasExtendedAttrs()&&i.extended.urlId)if(c===-1){c=h,l=i.extended.urlId;continue}else d=i.extended.urlId!==l;else c!==-1&&(d=!0);if(d||c!==-1&&h===o-1){let p=this._oscLinkService.getLinkData(l)?.uri;if(p){let g={start:{x:c+1,y:e},end:{x:h+(!d&&h===o-1?1:0),y:e}},v=!1;if(!a?.allowNonHttpProtocols)try{let b=new URL(p);["http:","https:"].includes(b.protocol)||(v=!0)}catch{v=!0}v||n.push({text:p,range:g,activate:(b,y)=>a?a.activate(b,y,g):_He(b,y),hover:(b,y)=>a?.hover?.(b,y,g),leave:(b,y)=>a?.leave?.(b,y,g)})}d=!1,i.hasExtendedAttrs()&&i.extended.urlId?(c=h,l=i.extended.urlId):(c=-1,l=-1)}}s(n)}};rI=Bo([Js(0,Jd),Js(1,eu),Js(2,Tie)],rI);function _He(e,s){if(confirm(`Do you want to navigate to ${s}?
559
560WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=s}else console.warn("Opening link blocked as opener could not be cleared")}}var u2=jc("CharSizeService"),Ef=jc("CoreBrowserService"),sL=jc("MouseService"),Tf=jc("RenderService"),PHe=jc("SelectionService"),Aie=jc("CharacterJoinerService"),Yb=jc("ThemeService"),Mie=jc("LinkProviderService"),EHe=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?k9.isErrorNoTelemetry(e)?new k9(e.message+`
561
562`+e.stack):new Error(e.message+`
563
564`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(s=>{s(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},THe=new EHe;function xS(e){AHe(e)||THe.onUnexpectedError(e)}var nI="Canceled";function AHe(e){return e instanceof MHe?!0:e instanceof Error&&e.name===nI&&e.message===nI}var MHe=class extends Error{constructor(){super(nI),this.name=this.message}};function RHe(e){return new Error(`Illegal argument: ${e}`)}var k9=class aI extends Error{constructor(s){super(s),this.name="CodeExpectedError"}static fromError(s){if(s instanceof aI)return s;let r=new aI;return r.message=s.message,r.stack=s.stack,r}static isErrorNoTelemetry(s){return s.name==="CodeExpectedError"}},iI=class Rie extends Error{constructor(s){super(s||"An unexpected bug occurred."),Object.setPrototypeOf(this,Rie.prototype)}};function Bu(e,s=0){return e[e.length-(1+s)]}var IHe;(e=>{function s(i){return i<0}e.isLessThan=s;function r(i){return i<=0}e.isLessThanOrEqual=r;function n(i){return i>0}e.isGreaterThan=n;function a(i){return i===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(IHe||={});function OHe(e,s){let r=this,n=!1,a;return function(){return n||(n=!0,s||(a=e.apply(r,arguments))),a}}var Iie;(e=>{function s(k){return k&&typeof k=="object"&&typeof k[Symbol.iterator]=="function"}e.is=s;let r=Object.freeze([]);function n(){return r}e.empty=n;function*a(k){yield k}e.single=a;function i(k){return s(k)?k:a(k)}e.wrap=i;function o(k){return k||r}e.from=o;function*l(k){for(let S=k.length-1;S>=0;S--)yield k[S]}e.reverse=l;function c(k){return!k||k[Symbol.iterator]().next().done===!0}e.isEmpty=c;function d(k){return k[Symbol.iterator]().next().value}e.first=d;function h(k,S){let _=0;for(let A of k)if(S(A,_++))return!0;return!1}e.some=h;function p(k,S){for(let _ of k)if(S(_))return _}e.find=p;function*g(k,S){for(let _ of k)S(_)&&(yield _)}e.filter=g;function*v(k,S){let _=0;for(let A of k)yield S(A,_++)}e.map=v;function*b(k,S){let _=0;for(let A of k)yield*S(A,_++)}e.flatMap=b;function*y(...k){for(let S of k)yield*S}e.concat=y;function w(k,S,_){let A=_;for(let T of k)A=S(A,T);return A}e.reduce=w;function*j(k,S,_=k.length){for(S<0&&(S+=k.length),_<0?_+=k.length:_>k.length&&(_=k.length);S<_;S++)yield k[S]}e.slice=j;function x(k,S=Number.POSITIVE_INFINITY){let _=[];
564if(S===0)return[_,k];let A=k[Symbol.iterator]();for(let T=0;T<S;T++){let M=A.next();if(M.done)return[_,e.empty()];_.push(M.value)}return[_,{[Symbol.iterator](){return A}}]}e.consume=x;async function C(k){let S=[];for await(let _ of k)S.push(_);return Promise.resolve(S)}e.asyncToArray=C})(Iie||={});function iv(e){if(Iie.is(e)){let s=[];for(let r of e)if(r)try{r.dispose()}catch(n){s.push(n)}if(s.length===1)throw s[0];if(s.length>1)throw new AggregateError(s,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function DHe(...e){return io(()=>iv(e))}function io(e){return{dispose:OHe(()=>{e()})}}var Oie=class Die{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{iv(this._toDispose)}finally{this._toDispose.clear()}}add(s){if(!s)return s;if(s===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Die.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(s),s}delete(s){if(s){if(s===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(s),s.dispose()}}deleteAndLeak(s){s&&this._toDispose.has(s)&&(this._toDispose.delete(s),void 0)}};Oie.DISABLE_DISPOSED_WARNING=!1;var Sg=Oie,Yn=class{constructor(){this._store=new Sg,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Yn.None=Object.freeze({dispose(){}});var yb=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},sf=typeof window=="object"?window:globalThis,oI=class lI{constructor(s){this.element=s,this.next=lI.Undefined,this.prev=lI.Undefined}};oI.Undefined=new oI(void 0);var vo=oI,_9=class{constructor(){this._first=vo.Undefined,this._last=vo.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===vo.Undefined}clear(){let e=this._first;for(;e!==vo.Undefined;){let s=e.next;e.prev=vo.Undefined,e.next=vo.Undefined,e=s}this._first=vo.Undefined,this._last=vo.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,s){let r=new vo(e);if(this._first===vo.Undefined)this._first=r,this._last=r;else if(s){let a=this._last;this._last=r,r.prev=a,a.next=r}else{let a=this._first;this._first=r,r.next=a,a.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==vo.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==vo.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==vo.Undefined&&e.next!==vo.Undefined){let s=e.prev;s.next=e.next,e.next.prev=s}else e.prev===vo.Undefined&&e.next===vo.Undefined?(this._first=vo.Undefined,this._last=vo.Undefined):e.next===vo.Undefined?(this._last=this._last.prev,this._last.next=vo.Undefined):e.prev===vo.Undefined&&(this._first=this._first.next,this._first.prev=vo.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==vo.Undefined;)yield e.element,e=e.next}},LHe=globalThis.performance&&typeof globalThis.performance.now=="function",$He=class Lie{static create(s){return new Lie(s)}constructor(s){this._now=LHe&&s===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Qc;(e=>{e.None=()=>Yn.None;function s($,O){return p($,()=>{},0,void 0,!0,void 0,O)}e.defer=s;function r($){return(O,q=null,V)=>{let K=!1,G;return G=$(z=>{if(!K)return G?G.dispose():K=!0,O.call(q,z)},null,V),K&&G.dispose(),G}}e.once=r;function n($,O,q){return d((V,K=null,G)=>$(z=>V.call(K,O(z)),null,G),q)}e.map=n;function a($,O,q){return d((V,K=null,G)=>$(z=>{O(z),V.call(K,z)},null,G),q)}e.forEach=a;function i($,O,q){return d((V,K=null,G)=>$(z=>O(z)&&V.call(K,z),null,G),q)}e.filter=i;function o($){return $}e.signal=o;function l(...$){return(O,q=null,V)=>{let K=DHe(...$.map(G=>
vendor: 5,069 bytes, lines 564-566
564G(z=>O.call(q,z))));return h(K,V)}}e.any=l;function c($,O,q,V){let K=q;return n($,G=>(K=O(K,G),K),V)}e.reduce=c;function d($,O){let q,V={onWillAddFirstListener(){q=$(K.fire,K)},onDidRemoveLastListener(){q?.dispose()}},K=new Ps(V);return O?.add(K),K.event}function h($,O){return O instanceof Array?O.push($):O&&O.add($),$}function p($,O,q=100,V=!1,K=!1,G,z){let Z,ee,Q,Y=0,oe,he={leakWarningThreshold:G,onWillAddFirstListener(){Z=$(pe=>{Y++,ee=O(ee,pe),V&&!Q&&(je.fire(ee),ee=void 0),oe=()=>{let le=ee;ee=void 0,Q=void 0,(!V||Y>1)&&je.fire(le),Y=0},typeof q=="number"?(clearTimeout(Q),Q=setTimeout(oe,q)):Q===void 0&&(Q=0,queueMicrotask(oe))})},onWillRemoveListener(){K&&Y>0&&oe?.()},onDidRemoveLastListener(){oe=void 0,Z.dispose()}},je=new Ps(he);return z?.add(je),je.event}e.debounce=p;function g($,O=0,q){return e.debounce($,(V,K)=>V?(V.push(K),V):[K],O,void 0,!0,void 0,q)}e.accumulate=g;function v($,O=(V,K)=>V===K,q){let V=!0,K;return i($,G=>{let z=V||!O(G,K);return V=!1,K=G,z},q)}e.latch=v;function b($,O,q){return[e.filter($,O,q),e.filter($,V=>!O(V),q)]}e.split=b;function y($,O=!1,q=[],V){let K=q.slice(),G=$(ee=>{K?K.push(ee):Z.fire(ee)});V&&V.add(G);let z=()=>{K?.forEach(ee=>Z.fire(ee)),K=null},Z=new Ps({onWillAddFirstListener(){G||(G=$(ee=>Z.fire(ee)),V&&V.add(G))},onDidAddFirstListener(){K&&(O?setTimeout(z):z())},onDidRemoveLastListener(){G&&G.dispose(),G=null}});return V&&V.add(Z),Z.event}e.buffer=y;function w($,O){return(q,V,K)=>{let G=O(new x);return $(function(z){let Z=G.evaluate(z);Z!==j&&q.call(V,Z)},void 0,K)}}e.chain=w;let j=Symbol("HaltChainable");class x{constructor(){this.steps=[]}map(O){return this.steps.push(O),this}forEach(O){return this.steps.push(q=>(O(q),q)),this}filter(O){return this.steps.push(q=>O(q)?q:j),this}reduce(O,q){let V=q;return this.steps.push(K=>(V=O(V,K),V)),this}latch(O=(q,V)=>q===V){let q=!0,V;return this.steps.push(K=>{let G=q||!O(K,V);return q=!1,V=K,G?K:j}),this}evaluate(O){for(let q of this.steps)if(O=q(O),O===j)break;return O}}function C($,O,q=V=>V){let V=(...Z)=>z.fire(q(...Z)),K=()=>$.on(O,V),G=()=>$.removeListener(O,V),z=new Ps({onWillAddFirstListener:K,onDidRemoveLastListener:G});return z.event}e.fromNodeEventEmitter=C;function k($,O,q=V=>V){let V=(...Z)=>z.fire(q(...Z)),K=()=>$.addEventListener(O,V),G=()=>$.removeEventListener(O,V),z=new Ps({onWillAddFirstListener:K,onDidRemoveLastListener:G});return z.event}e.fromDOMEventEmitter=k;function S($){return new Promise(O=>r($)(O))}e.toPromise=S;function _($){let O=new Ps;return $.then(q=>{O.fire(q)},()=>{O.fire(void 0)}).finally(()=>{O.dispose()}),O.event}e.fromPromise=_;function A($,O){return $(q=>O.fire(q))}e.forward=A;function T($,O,q){return O(q),$(V=>O(V))}e.runAndSubscribe=T;class M{constructor(O,q){this._observable=O,this._counter=0,this._hasChanged=!1;let V={onWillAddFirstListener:()=>{O.addObserver(this)},onDidRemoveLastListener:()=>{O.removeObserver(this)}};this.emitter=new Ps(V),q&&q.add(this.emitter)}beginUpdate(O){this._counter++}handlePossibleChange(O){}handleChange(O,q){this._hasChanged=!0}endUpdate(O){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function R($,O){return new M($,O).emitter.event}e.fromObservable=R;function D($){return(O,q,V)=>{let K=0,G=!1,z={beginUpdate(){K++},endUpdate(){K--,K===0&&($.reportChanges(),G&&(G=!1,O.call(q)))},handlePossibleChange(){},handleChange(){G=!0}};$.addObserver(z),$.reportChanges();let Z={dispose(){$.removeObserver(z)}};return V instanceof Sg?V.add(Z):Array.isArray(V)&&V.push(Z),Z}}e.fromObservableLight=D})(Qc||={});var cI=class dI{constructor(s){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${s}_${dI._idPool++}`,dI.all.add(this)}start(s){this._stopWatch=new $He,this.listenerCount=s}stop(){if(this._stopWatch){let s=this._stopWatch.elapsed();this.durations.push(s),this.elapsedOverall+=s,this.invocationCount+=1,this._stopWatch=void 0}}};cI.all=new Set,cI._idPool=0;var FHe=cI,BHe=-1,$ie=class Fie{constructor(s,r,n=(Fie._idPool++).toString(16).padStart(3,"0")){this._errorHandler=s,this.threshold=r,this.name=n,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(s,r){let n=this.threshold;if(n<=0||r<n)return;this._stacks||(this._stacks=new Map);let a=this._stacks.get(s.value)||0;if(this._stacks.set(s.value,a+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=n*.5;let[i,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(i);let c=new HHe(l,i);this._errorHandler(c)}return()=>{let i=this._stacks.get(s.value)||0;this._stacks.set(s.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let s,r=0;for(let[n,a]of this._stacks)(!s||r<a)&&(s=[n,a],r=a);return s}};$ie._idPool=1;var UHe=$ie,zHe=class Bie{constructor(s){this.value=s}static create(){let s=new Error;return new Bie(s.stack??"")}print(){console.warn(this.value.split(`
565`).slice(2).join(`
566`))}}
566,HHe=class extends Error{constructor(e,s){super(e),this.name="ListenerLeakError",this.stack=s}},qHe=class extends Error{constructor(e,s){super(e),this.name="ListenerRefusalError",this.stack=s}},VHe=0,s5=class{constructor(e){this.value=e,this.id=VHe++}},WHe=2,KHe,Ps=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new UHe(e?.onListenerError??xS,this._options?.leakWarningThreshold??BHe):void 0,this._perfMon=this._options?._profName?new FHe(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,s,r)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let o=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(o);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],c=new qHe(`${o}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||xS)(c),Yn.None}if(this._disposed)return Yn.None;s&&(e=e.bind(s));let n=new s5(e),a;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=zHe.create(),a=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof s5?(this._deliveryQueue??=new GHe,this._listeners=[this._listeners,n]):this._listeners.push(n):(this._options?.onWillAddFirstListener?.(this),this._listeners=n,this._options?.onDidAddFirstListener?.(this)),this._size++;let i=io(()=>{a?.(),this._removeListener(n)});return r instanceof Sg?r.add(i):Array.isArray(r)&&r.push(i),i},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let s=this._listeners,r=s.indexOf(e);if(r===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[r]=void 0;let n=this._deliveryQueue.current===this;if(this._size*WHe<=s.length){let a=0;for(let i=0;i<s.length;i++)s[i]?s[a++]=s[i]:n&&(this._deliveryQueue.end--,a<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=a}}_deliver(e,s){if(!e)return;let r=this._options?.onListenerError||xS;if(!r){e.value(s);return}try{e.value(s)}catch(n){r(n)}}_deliverQueue(e){let s=e.current._listeners;for(;e.i<e.end;)this._deliver(s[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof s5)this._deliver(this._listeners,e);else{let s=this._deliveryQueue;s.enqueue(this,e,this._listeners.length),this._deliverQueue(s)}this._perfMon?.stop()}hasListeners(){return this._size>0}},GHe=class{constructor(){this.i=-1,this.end=0}enqueue(e,s,r){this.i=0,this.end=r,this.current=e,this.value=s}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},uI=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Ps,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Ps,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(s){return this.mapWindowIdToZoomLevel.get(this.getWindowId(s))??0}setZoomLevel(s,r){if(this.getZoomLevel(r)===s)return;let n=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(n,s),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(s){return this.mapWindowIdToZoomFactor.get(this.getWindowId(s))??1}setZoomFactor(s,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),s)}setFullscreen(s,r){if(this.isFullscreen(r)===s)return;let n=this.getWindowId(r);this.mapWindowIdToFullScreen.set(n,s),this._onDidChangeFullscreen.fire(n)}isFullscreen(s){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(s))}getWindowId(s){return s.vscodeWindowId}};uI.INSTANCE=new uI;var rL=uI;function YHe(e,s,r){typeof s=="string"&&(s=e.matchMedia(s)),s.addEventListener("change",r)}rL.INSTANCE.onDidChangeZoomLevel;function QHe(e){return rL.INSTANCE.getZoomFactor(e)}rL.INSTANCE.onDidChangeFullscreen;var Qb=typeof navigator=="object"?navigator.userAgent:"",mI=Qb.indexOf("Firefox")>=0,XHe=Qb.indexOf("AppleWebKit")>=0,nL=Qb.indexOf("Chrome")>=0,ZHe=!nL&&Qb.indexOf("Safari")>=0;Qb.indexOf("Electron/")>=0;Qb.indexOf("Android")>=0;var r5=!1;if(typeof sf.matchMedia=="function"){let e=sf.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),s=sf.matchMedia("(display-mode: fullscreen)");r5=e.matches,YHe(sf,e,({matches:r})=>{r5&&s.matches||(r5=r)})}var sy="en",hI=!1,pI=!1,vS=!1,Uie=!1,z1,yS=sy,P9=sy,JHe,qp,Fx=globalThis,Vu;typeof Fx.vscode<"u"&&typeof Fx.vscode.process<"u"?Vu=Fx.vscode.process:typeof process<"u"&&typeof process?.versions?.n
566ode=="string"&&(Vu=process);var e7e=typeof Vu?.versions?.electron=="string",t7e=e7e&&Vu?.type==="renderer";if(typeof Vu=="object"){hI=Vu.platform==="win32",pI=Vu.platform==="darwin",vS=Vu.platform==="linux",vS&&Vu.env.SNAP&&Vu.env.SNAP_REVISION,Vu.env.CI||Vu.env.BUILD_ARTIFACTSTAGINGDIRECTORY,z1=sy,yS=sy;let e=Vu.env.VSCODE_NLS_CONFIG;if(e)try{let s=JSON.parse(e);z1=s.userLocale,P9=s.osLocale,yS=s.resolvedLanguage||sy,JHe=s.languagePack?.translationsConfigFile}catch{}Uie=!0}else typeof navigator=="object"&&!t7e?(qp=navigator.userAgent,hI=qp.indexOf("Windows")>=0,pI=qp.indexOf("Macintosh")>=0,(qp.indexOf("Macintosh")>=0||qp.indexOf("iPad")>=0||qp.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,vS=qp.indexOf("Linux")>=0,qp?.indexOf("Mobi")>=0,yS=globalThis._VSCODE_NLS_LANGUAGE||sy,z1=navigator.language.toLowerCase(),P9=z1):console.error("Unable to resolve platform.");var zie=hI,ap=pI,s7e=vS,E9=Uie,pp=qp,Zf=yS,r7e;(e=>{function s(){return Zf}e.value=s;function r(){return Zf.length===2?Zf==="en":Zf.length>=3?Zf[0]==="e"&&Zf[1]==="n"&&Zf[2]==="-":!1}e.isDefaultVariant=r;function n(){return Zf==="en"}e.isDefault=n})(r7e||={});var n7e=typeof Fx.postMessage=="function"&&!Fx.importScripts;(()=>{if(n7e){let e=[];Fx.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let n=0,a=e.length;n<a;n++){let i=e[n];if(i.id===r.data.vscodeScheduleAsyncWork){e.splice(n,1),i.callback();return}}});let s=0;return r=>{let n=++s;e.push({id:n,callback:r}),Fx.postMessage({vscodeScheduleAsyncWork:n},"*")}}return e=>setTimeout(e)})();var a7e=!!(pp&&pp.indexOf("Chrome")>=0);pp&&pp.indexOf("Firefox")>=0;!a7e&&pp&&pp.indexOf("Safari")>=0;pp&&pp.indexOf("Edg/")>=0;pp&&pp.indexOf("Android")>=0;var Vv=typeof navigator=="object"?navigator:{};E9||document.queryCommandSupported&&document.queryCommandSupported("copy")||Vv&&Vv.clipboard&&Vv.clipboard.writeText,E9||Vv&&Vv.clipboard&&Vv.clipboard.readText;var aL=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,s){this._keyCodeToStr[e]=s,this._strToKeyCode[s.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},n5=new aL,T9=new aL,A9=new aL,i7e=new Array(230),Hie;(e=>{function s(l){return n5.keyCodeToStr(l)}e.toString=s;function r(l){return n5.strToKeyCode(l)}e.fromString=r;function n(l){return T9.keyCodeToStr(l)}e.toUserSettingsUS=n;function a(l){return A9.keyCodeToStr(l)}e.toUserSettingsGeneral=a;function i(l){return T9.strToKeyCode(l)||A9.strToKeyCode(l)}e.fromUserSettings=i;function o(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return n5.keyCodeToStr(l)}e.toElectronAccelerator=o})(Hie||={});var o7e=class qie{constructor(s,r,n,a,i){this.ctrlKey=s,this.shiftKey=r,this.altKey=n,this.metaKey=a,this.keyCode=i}equals(s){return s instanceof qie&&this.ctrlKey===s.ctrlKey&&this.shiftKey===s.shiftKey&&this.altKey===s.altKey&&this.metaKey===s.metaKey&&this.keyCode===s.keyCode}getHashCode(){let s=this.ctrlKey?"1":"0",r=this.shiftKey?"1":"0",n=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${s}${r}${n}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new l7e([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},l7e=class{constructor(e){if(e.length===0)throw RHe("chords");this.chords=e}getHashCode(){let e="";for(let s=0,r=this.chords.length;s<r;s++)s!==0&&(e+=";"),e+=this.chords[s].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let s=0;s<this.chords.length;s++)if(!this.chords[s].equals(e.chords[s]))return!1;return!0}};function c7e(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return Hie.fromString(r)}let s=e.keyCode;if(s===3)return 7;if(mI)switch(s){case 59:return 85;case 60:if(s7e)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ap)return 57;break}else if(XHe&&(ap&&s===93||!ap&&s===92))return 57;return i7e[s]||0}var d7e=ap?256:2048,u7e=512,m7e=1024,h7e=ap?2048:256,M9=class{constructor(e){this._standardKeyboardEventBrand=!0;let s=e;
vendor: 46,713 bytes, line 566
566this.browserEvent=s,this.target=s.target,this.ctrlKey=s.ctrlKey,this.shiftKey=s.shiftKey,this.altKey=s.altKey,this.metaKey=s.metaKey,this.altGraphKey=s.getModifierState?.("AltGraph"),this.keyCode=c7e(s),this.code=s.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let s=0;return this.ctrlKey&&(s|=d7e),this.altKey&&(s|=u7e),this.shiftKey&&(s|=m7e),this.metaKey&&(s|=h7e),s|=e,s}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new o7e(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},R9=new WeakMap;function p7e(e){if(!e.parent||e.parent===e)return null;try{let s=e.location,r=e.parent.location;if(s.origin!=="null"&&r.origin!=="null"&&s.origin!==r.origin)return null}catch{return null}return e.parent}var f7e=class{static getSameOriginWindowChain(e){let s=R9.get(e);if(!s){s=[],R9.set(e,s);let r=e,n;do n=p7e(r),n?s.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):s.push({window:new WeakRef(r),iframeElement:null}),r=n;while(r)}return s.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,s){if(!s||e===s)return{top:0,left:0};let r=0,n=0,a=this.getSameOriginWindowChain(e);for(let i of a){let o=i.window.deref();if(r+=o?.scrollY??0,n+=o?.scrollX??0,o===s||!i.iframeElement)break;let l=i.iframeElement.getBoundingClientRect();r+=l.top,n+=l.left}return{top:r,left:n}}},H1=class{constructor(e,s){this.timestamp=Date.now(),this.browserEvent=s,this.leftButton=s.button===0,this.middleButton=s.button===1,this.rightButton=s.button===2,this.buttons=s.buttons,this.target=s.target,this.detail=s.detail||1,s.type==="dblclick"&&(this.detail=2),this.ctrlKey=s.ctrlKey,this.shiftKey=s.shiftKey,this.altKey=s.altKey,this.metaKey=s.metaKey,typeof s.pageX=="number"?(this.posx=s.pageX,this.posy=s.pageY):(this.posx=s.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=s.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let r=f7e.getPositionOfChildWindowRelativeToAncestorWindow(e,s.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},I9=class{constructor(e,s=0,r=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=s;let n=!1;if(nL){let a=navigator.userAgent.match(/Chrome\/(\d+)/);n=(a?parseInt(a[1]):123)<=122}if(e){let a=e,i=e,o=e.view?.devicePixelRatio||1;if(typeof a.wheelDeltaY<"u")n?this.deltaY=a.wheelDeltaY/(120*o):this.deltaY=a.wheelDeltaY/120;else if(typeof i.VERTICAL_AXIS<"u"&&i.axis===i.VERTICAL_AXIS)this.deltaY=-i.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?mI&&!ap?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof a.wheelDeltaX<"u")ZHe&&zie?this.deltaX=-(a.wheelDeltaX/120):n?this.deltaX=a.wheelDeltaX/(120*o):this.deltaX=a.wheelDeltaX/120;else if(typeof i.HORIZONTAL_AXIS<"u"&&i.axis===i.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let l=e;l.deltaMode===l.DOM_DELTA_LINE?mI&&!ap?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(n?this.deltaY=e.wheelDelta/(120*o):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Vie=Object.freeze(function(e,s){let r=setTimeout(e.bind(s),0);return{dispose(){clearTimeout(r)}}}),g7e;(e=>{function s(r){return r===e.None||r===e.Cancelled||r instanceof x7e?!0:!r||typeof r!="object"?!1:typeof r.isCancellationRequested=="boolean"&&typeof r.onCancellationRequested=="function"}e.isCancellationToken=s,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Qc.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vie})})(g7e||={});var x7e=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Vie:(this._emitter||(this._emitter=new Ps),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},iL=class{constructor(e,s){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof s=="number"&&this.setIfNotSet(e,s)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,s){if(this._isDisposed)throw new iI("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},s)}setIfNotSet(e,s){if(this._isDisposed)throw new iI("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},s))}},v7e=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,s,r=globalThis){if(this.isDisposed)throw new iI("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let n=r.setInterval(()=>{e()},s);this.disposable=io(()=>{r.clearInterval(n),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},y7e;(e=>{async function s(n){let a,i=await Promise.all(n.map(o=>o.then(l=>l,l=>{a||(a=l)})));if(typeof a<"u")throw a;return i}e.settled=s;function r(n){return new Promise(async(a,i)=>{try{await n(a,i)}catch(o){i(o)}})}e.withAsyncBody=r})(y7e||={});var O9=class ym{static fromArray(s){return new ym(r=>{r.emitMany(s)})}static fromPromise(s){return new ym(async r=>{r.emitMany(await s)})}static fromPromises(s){return new ym(async r=>{await Promise.all(s.map(async n=>r.emitOne(await n)))})}static merge(s){return new ym(async r=>{await Promise.all(s.map(async n=>{for await(let a of n)r.emitOne(a)}))})}constructor(s,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new Ps,queueMicrotask(async()=>{let n={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(s(n)),this.resolve()}catch(a){this.reject(a)}finally{n.emitOne=void 0,n.emitMany=void 0,n.reject=void 0}})}[Symbol.asyncIterator](){let s=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(s<this._results.length)return{done:!1,value:this._results[s++]};if(this._state===1)return{done:!0,value:void 0};await Qc.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(s,r){return new ym(async n=>{for await(let a of s)n.emitOne(r(a))})}map(s){return ym.map(this,s)}static filter(s,r){return new ym(async n=>{for await(let a of s)r(a)&&n.emitOne(a)})}filter(s){return ym.filter(this,s)}static coalesce(s){return ym.filter(s,r=>!!r)}coalesce(){return ym.coalesce(this)}static async toPromise(s){let r=[];for await(let n of s)r.push(n);return r}toPromise(){return ym.toPromise(this)}emitOne(s){this._state===0&&(this._results.push(s),this._onStateChanged.fire())}emitMany(s){this._state===0&&(this._results=this._results.concat(s),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(s){this._state===0&&(this._state=2,this._error=s,this._onStateChanged.fire())}};O9.EMPTY=O9.fromArray([]);var{getWindow:ep,getWindowId:b7e,onDidRegisterWindow:w7e}=(function(){let e=new Map,s={window:sf,disposables:new Sg};e.set(sf.vscodeWindowId,s);let r=new Ps,n=new Ps,a=new Ps;function i(o,l){return(typeof o=="number"?e.get(o):void 0)??(l?s:void 0)}return{onDidRegisterWindow:r.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:n.event,registerWindow(o){if(e.has(o.vscodeWindowId))return Yn.None;let l=new Sg,c={window:o,disposables:l.add(new Sg)};return e.set(o.vscodeWindowId,c),l.add(io(()=>{e.delete(o.vscodeWindowId),n.fire(o)})),l.add(ln(o,dc.BEFORE_UNLOAD,()=>{a.fire(o)})),r.fire(c),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:i,getWindow(o){let l=o;if(l?.ownerDocument?.defaultView)return l.ownerDocument.defaultView.window;let c=o;return c?.view?c.view.window:sf},getDocument(o){return ep(o).document}}})(),j7e=class{constructor(e,s,r,n){this._node=e,this._type=s,this._handler=r,this._options=n||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function ln(e,s,r,n){return new j7e(e,s,r,n)}var D9=function(e,s,r,n){return ln(e,s,r,n)},oL,N7e=class extends v7e{constructor(e){super(),this.defaultTarget=e&&ep(e)}cancelAndSet(e,s,r){return super.cancelAndSet(e,s,r??this.defaultTarget)}},L9=class{constructor(e,s=0){this._runner=e,this.priority=s,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){xS(e)}}static sort(e,s){return s.priority-e.priority}};(function(){let e=new Map,s=new Map,r=new Map,n=new Map,a=i=>{r.set(i,!1);let o=e.get(i)??[];for(s.set(i,o),e.set(i,[]),n.set(i,!0);o.length>0;)o.sort(L9.sort),o.shift().execute();n.set(i,!1)};oL=(i,o,l=0)=>{let c=b7e(i),d=new L9(o,l),h=e.get(c);return h||(h=[],e.set(c,h)),h.push(d),r.get(c)||(r.set(c,!0),i.requestAnimationFrame(()=>a(c))),d}})();function S7e(e){let s=e.getBoundingClientRect(),r=ep(e);return{left:s.left+r.scrollX,top:s.top+r.scrollY,width:s.width,height:s.height}}var dc={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},C7e=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let s=mu(e);this._maxWidth!==s&&(this._maxWidth=s,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let s=mu(e);this._width!==s&&(this._width=s,this.domNode.style.width=this._width)}setHeight(e){let s=mu(e);this._height!==s&&(this._height=s,this.domNode.style.height=this._height)}setTop(e){let s=mu(e);this._top!==s&&(this._top=s,this.domNode.style.top=this._top)}setLeft(e){let s=mu(e);this._left!==s&&(this._left=s,this.domNode.style.left=this._left)}setBottom(e){let s=mu(e);this._bottom!==s&&(this._bottom=s,this.domNode.style.bottom=this._bottom)}setRight(e){let s=mu(e);this._right!==s&&(this._right=s,this.domNode.style.right=this._right)}setPaddingTop(e){let s=mu(e);this._paddingTop!==s&&(this._paddingTop=s,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let s=mu(e);this._paddingLeft!==s&&(this._paddingLeft=s,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let s=mu(e);this._paddingBottom!==s&&(this._paddingBottom=s,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let s=mu(e);this._paddingRight!==s&&(this._paddingRight=s,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let s=mu(e);this._fontSize!==s&&(this._fontSize=s,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let s=mu(e);this._lineHeight!==s&&(this._lineHeight=s,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let s=mu(e);this._letterSpacing!==s&&(this._letterSpacing=s,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,s){this.domNode.classList.toggle(e,s),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,s){this.domNode.setAttribute(e,s)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function mu(e){return typeof e=="number"?`${e}px`:e}function w0(e){return new C7e(e)}var Wie=class{constructor(){this._hooks=new Sg,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,s){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(s)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,s,r,n,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=n,this._onStopCallback=a;let i=e;try{e.setPointerCapture(s),this._hooks.add(io(()=>{try{e.releasePointerCapture(s)}catch{}}))}catch{i=ep(e)}this._hooks.add(ln(i,dc.POINTER_MOVE,o=>{if(o.buttons!==r){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(ln(i,dc.POINTER_UP,o=>this.stopMonitoring(!0)))}};function k7e(e,s,r){let n=null,a=null;if(typeof r.value=="function"?(n="value",a=r.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof r.get=="function"&&(n="get",a=r.get),!a)throw new Error("not supported");let i=`$memoize$${s}`;r[n]=function(...o){return this.hasOwnProperty(i)||Object.defineProperty(this,i,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,o)}),this[i]}}var Vh;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Vh||={});var Gw=class fd extends Yn{constructor(){super(),this.dispatched=!1,this.targets=new _9,this.ignoreTargets=new _9,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Qc.runAndSubscribe(w7e,({window:s,disposables:r})=>{r.add(ln(s.document,"touchstart",n=>this.onTouchStart(n),{passive:!1})),r.add(ln(s.document,"touchend",n=>this.onTouchEnd(s,n))),r.add(ln(s.document,"touchmove",n=>this.onTouchMove(n),{passive:!1}))},{window:sf,disposables:this._store}))}static addTarget(s){if(!fd.isTouchDevice())return Yn.None;fd.INSTANCE||(fd.INSTANCE=new fd);let r=fd.INSTANCE.targets.push(s);return io(r)}static ignoreTarget(s){if(!fd.isTouchDevice())return Yn.None;fd.INSTANCE||(fd.INSTANCE=new fd);let r=fd.INSTANCE.ignoreTargets.push(s);return io(r)}static isTouchDevice(){return"ontouchstart"in sf||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(s){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let n=0,a=s.targetTouches.length;n<a;n++){let i=s.targetTouches.item(n);this.activeTouches[i.identifier]={id:i.identifier,initialTarget:i.target,initialTimeStamp:r,initialPageX:i.pageX,initialPageY:i.pageY,rollingTimestamps:[r],rollingPageX:[i.pageX],rollingPageY:[i.pageY]};let o=this.newGestureEvent(Vh.Start,i.target);o.pageX=i.pageX,o.pageY=i.pageY,this.dispatchEvent(o)}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}onTouchEnd(s,r){let n=Date.now(),a=Object.keys(this.activeTouches).length;for(let i=0,o=r.changedTouches.length;i<o;i++){let l=r.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],d=Date.now()-c.initialTimeStamp;if(d<fd.HOLD_DELAY&&Math.abs(c.initialPageX-Bu(c.rollingPageX))<30&&Math.abs(c.initialPageY-Bu(c.rollingPageY))<30){let h=this.newGestureEvent(Vh.Tap,c.initialTarget);h.pageX=Bu(c.rollingPageX),h.pageY=Bu(c.rollingPageY),this.dispatchEvent(h)}else if(d>=fd.HOLD_DELAY&&Math.abs(c.initialPageX-Bu(c.rollingPageX))<30&&Math.abs(c.initialPageY-Bu(c.rollingPageY))<30){let h=this.newGestureEvent(Vh.Contextmenu,c.initialTarget);h.pageX=Bu(c.rollingPageX),h.pageY=Bu(c.rollingPageY),this.dispatchEvent(h)}else if(a===1){let h=Bu(c.rollingPageX),p=Bu(c.rollingPageY),g=Bu(c.rollingTimestamps)-c.rollingTimestamps[0],v=h-c.rollingPageX[0],b=p-c.rollingPageY[0],y=[...this.targets].filter(w=>c.initialTarget instanceof Node&&w.contains(c.initialTarget));this.inertia(s,y,n,Math.abs(v)/g,v>0?1:-1,h,Math.abs(b)/g,b>0?1:-1,p)}this.dispatchEvent(this.newGestureEvent(Vh.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(s,r){let n=document.createEvent("CustomEvent");return n.initEvent(s,!1,!0),n.initialTarget=r,n.tapCount=0,n}dispatchEvent(s){if(s.type===Vh.Tap){let r=new Date().getTime(),n=0;r-this._lastSetTapCountTime>fd.CLEAR_TAP_COUNT_TIME?n=1:n=2,this._lastSetTapCountTime=r,s.tapCount=n}else(s.type===Vh.Change||s.type===Vh.Contextmenu)&&(this._lastSetTapCountTime=0);if(s.initialTarget instanceof Node){for(let n of this.ignoreTargets)if(n.contains(s.initialTarget))return;let r=[];for(let n of this.targets)if(n.contains(s.initialTarget)){let a=0,i=s.initialTarget;for(;i&&i!==n;)a++,i=i.parentElement;r.push([a,n])}r.sort((n,a)=>n[0]-a[0]);for(let[n,a]of r)a.dispatchEvent(s),this.dispatched=!0}}inertia(s,r,n,a,i,o,l,c,d){this.handle=oL(s,()=>{let h=Date.now(),p=h-n,g=0,v=0,b=!0;a+=fd.SCROLL_FRICTION*p,l+=fd.SCROLL_FRICTION*p,a>0&&(b=!1,g=i*a*p),l>0&&(b=!1,v=c*l*p);let y=this.newGestureEvent(Vh.Change);y.translationX=g,y.translationY=v,r.forEach(w=>w.dispatchEvent(y)),b||this.inertia(s,r,h,a,i,o+g,l,c,d+v)})}onTouchMove(s){let r=Date.now();for(let n=0,a=s.changedTouches.length;n<a;n++){let i=s.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(i.identifier))){console.warn("end of an UNKNOWN touch",i);continue}let o=this.activeTouches[i.identifier],l=this.newGestureEvent(Vh.Change,o.initialTarget);l.translationX=i.pageX-Bu(o.rollingPageX),l.translationY=i.pageY-Bu(o.rollingPageY),l.pageX=i.pageX,l.pageY=i.pageY,this.dispatchEvent(l),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(i.pageX),o.rollingPageY.push(i.pageY),o.rollingTimestamps.push(r)}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}};Gw.SCROLL_FRICTION=-.005,Gw.HOLD_DELAY=700,Gw.CLEAR_TAP_COUNT_TIME=400,Bo([k7e],Gw,"isTouchDevice",1);var _7e=Gw,lL=class extends Yn{onclick(e,s){this._register(ln(e,dc.CLICK,r=>s(new H1(ep(e),r))))}onmousedown(e,s){this._register(ln(e,dc.MOUSE_DOWN,r=>s(new H1(ep(e),r))))}onmouseover(e,s){this._register(ln(e,dc.MOUSE_OVER,r=>s(new H1(ep(e),r))))}onmouseleave(e,s){this._register(ln(e,dc.MOUSE_LEAVE,r=>s(new H1(ep(e),r))))}onkeydown(e,s){this._register(ln(e,dc.KEY_DOWN,r=>s(new M9(r))))}onkeyup(e,s){this._register(ln(e,dc.KEY_UP,r=>s(new M9(r))))}oninput(e,s){this._register(ln(e,dc.INPUT,s))}onblur(e,s){this._register(ln(e,dc.BLUR,s))}onfocus(e,s){this._register(ln(e,dc.FOCUS,s))}onchange(e,s){this._register(ln(e,dc.CHANGE,s))}ignoreGesture(e){return _7e.ignoreTarget(e)}},$9=11,P7e=class extends lL{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=$9+"px",this.domNode.style.height=$9+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Wie),this._register(D9(this.bgDomNode,dc.POINTER_DOWN,s=>this._arrowPointerDown(s))),this._register(D9(this.domNode,dc.POINTER_DOWN,s=>this._arrowPointerDown(s))),this._pointerdownRepeatTimer=this._register(new N7e),this._pointerdownScheduleRepeatTimer=this._register(new iL)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let s=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ep(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(s,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},E7e=class fI{constructor(s,r,n,a,i,o,l){this._forceIntegerValues=s,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r=r|0,n=n|0,a=a|0,i=i|0,o=o|0,l=l|0),this.rawScrollLeft=a,this.rawScrollTop=l,r<0&&(r=0),a+r>n&&(a=n-r),a<0&&(a=0),i<0&&(i=0),l+i>o&&(l=o-i),l<0&&(l=0),this.width=r,this.scrollWidth=n,this.scrollLeft=a,this.height=i,this.scrollHeight=o,this.scrollTop=l}equals(s){return this.rawScrollLeft===s.rawScrollLeft&&this.rawScrollTop===s.rawScrollTop&&this.width===s.width&&this.scrollWidth===s.scrollWidth&&this.scrollLeft===s.scrollLeft&&this.height===s.height&&this.scrollHeight===s.scrollHeight&&this.scrollTop===s.scrollTop}withScrollDimensions(s,r){return new fI(this._forceIntegerValues,typeof s.width<"u"?s.width:this.width,typeof s.scrollWidth<"u"?s.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,typeof s.height<"u"?s.height:this.height,typeof s.scrollHeight<"u"?s.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(s){return new fI(this._forceIntegerValues,this.width,this.scrollWidth,typeof s.scrollLeft<"u"?s.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof s.scrollTop<"u"?s.scrollTop:this.rawScrollTop)}createScrollEvent(s,r){let n=this.width!==s.width,a=this.scrollWidth!==s.scrollWidth,i=this.scrollLeft!==s.scrollLeft,o=this.height!==s.height,l=this.scrollHeight!==s.scrollHeight,c=this.scrollTop!==s.scrollTop;return{inSmoothScrolling:r,oldWidth:s.width,oldScrollWidth:s.scrollWidth,oldScrollLeft:s.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:s.height,oldScrollHeight:s.scrollHeight,oldScrollTop:s.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:a,scrollLeftChanged:i,heightChanged:o,scrollHeightChanged:l,scrollTopChanged:c}}},T7e=class extends Yn{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Ps),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new E7e(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,s){let r=this._state.withScrollDimensions(e,s);this._setState(r,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let s=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(s,!1)}setScrollPositionSmooth(e,s){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;let n;s?n=new B9(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):n=this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=n}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=B9.start(this._state,r,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),s=this._state.withScrollPosition(e);if(this._setState(s,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,s){let r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,s)))}},F9=class{constructor(e,s,r){this.scrollLeft=e,this.scrollTop=s,this.isDone=r}};function a5(e,s){let r=s-e;return function(n){return e+r*R7e(n)}}function A7e(e,s,r){return function(n){return n<r?e(n/r):s((n-r)/(1-r))}}var B9=class gI{constructor(s,r,n,a){this.from=s,this.to=r,this.duration=a,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(s,r,n){if(Math.abs(s-r)>2.5*n){let a,i;return s<r?(a=s+.75*n,i=r-.75*n):(a=s-.75*n,i=r+.75*n),A7e(a5(s,a),a5(i,r),.33)}return a5(s,r)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(s){this.to=s.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(s){let r=(s-this.startTime)/this.duration;if(r<1){let n=this.scrollLeft(r),a=this.scrollTop(r);return new F9(n,a,!1)}return new F9(this.to.scrollLeft,this.to.scrollTop,!0)}combine(s,r,n){return gI.start(s,r,n)}static start(s,r,n){n=n+10;let a=Date.now()-10;return new gI(s,r,a,n)}};function M7e(e){return Math.pow(e,3)}function R7e(e){return 1-M7e(1-e)}var I7e=class extends Yn{constructor(e,s,r){super(),this._visibility=e,this._visibleClassName=s,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new iL)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},O7e=140,Kie=class extends lL{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new I7e(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Wie),this._shouldRender=!0,this.domNode=w0(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(ln(this.domNode.domNode,dc.POINTER_DOWN,s=>this._domNodePointerDown(s)))}_createArrow(e){let s=this._register(new P7e(e));this.domNode.domNode.appendChild(s.bgDomNode),this.domNode.domNode.appendChild(s.domNode)}_createSlider(e,s,r,n){this.slider=w0(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(s),typeof r=="number"&&this.slider.setWidth(r),typeof n=="number"&&this.slider.setHeight(n),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(ln(this.slider.domNode,dc.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let s=this.domNode.domNode.getClientRects()[0].top,r=s+this._scrollbarState.getSliderPosition(),n=s+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);r<=a&&a<=n?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let s,r;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")s=e.offsetX,r=e.offsetY;else{let a=S7e(this.domNode.domNode);s=e.pageX-a.left,r=e.pageY-a.top}let n=this._pointerDownRelativePosition(s,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let s=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),n=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let i=this._sliderOrthogonalPointerPosition(a),o=Math.abs(i-r);if(zie&&o>O7e){this._setDesiredScrollPositionNow(n.getScrollPosition());return}let l=this._sliderPointerPosition(a)-s;this._setDesiredScrollPositionNow(n.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let s={};this.writeScrollPosition(s,e),this._scrollable.setScrollPositionNow(s)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Gie=class xI{constructor(s,r,n,a,i,o){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(s),this._visibleSize=a,this._scrollSize=i,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new xI(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(s){let r=Math.round(s);return this._visibleSize!==r?(this._visibleSize=r,this._refreshComputedValues(),!0):!1}setScrollSize(s){let r=Math.round(s);return this._scrollSize!==r?(this._scrollSize=r,this._refreshComputedValues(),!0):!1}setScrollPosition(s){let r=Math.round(s);return this._scrollPosition!==r?(this._scrollPosition=r,this._refreshComputedValues(),!0):!1}setScrollbarSize(s){this._scrollbarSize=Math.round(s)}setOppositeScrollbarSize(s){this._oppositeScrollbarSize=Math.round(s)}static _computeValues(s,r,n,a,i){let o=Math.max(0,n-s),l=Math.max(0,o-2*r),c=a>0&&a>n;if(!c)return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let d=Math.round(Math.max(20,Math.floor(n*l/a))),h=(l-d)/(a-n),p=i*h;return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(d),computedSliderRatio:h,computedSliderPosition:Math.round(p)}}_refreshComputedValues(){let s=xI._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=s.computedAvailableSize,this._computedIsNeeded=s.computedIsNeeded,this._computedSliderSize=s.computedSliderSize,this._computedSliderRatio=s.computedSliderRatio,this._computedSliderPosition=s.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(s){if(!this._computedIsNeeded)return 0;let r=s-this._arrowSize-this._computedSliderSize/2;return Math.round(r/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(s){if(!this._computedIsNeeded)return 0;let r=s-this._arrowSize,n=this._scrollPosition;return r<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(s){if(!this._computedIsNeeded)return 0;let r=this._computedSliderPosition+s;return Math.round(r/this._computedSliderRatio)}},D7e=class extends Kie{constructor(e,s,r){let n=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:s.lazyRender,host:r,scrollbarState:new Gie(s.horizontalHasArrows?s.arrowSize:0,s.horizontal===2?0:s.horizontalScrollbarSize,s.vertical===2?0:s.verticalScrollbarSize,n.width,n.scrollWidth,a.scrollLeft),visibility:s.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:s.scrollByPage}),s.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((s.horizontalScrollbarSize-s.horizontalSliderSize)/2),0,void 0,s.horizontalSliderSize)}_updateSlider(e,s){this.slider.setWidth(e),this.slider.setLeft(s)}_renderDomNode(e,s){this.domNode.setWidth(e),this.domNode.setHeight(s),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,s){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,s){e.scrollLeft=s}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},L7e=class extends Kie{constructor(e,s,r){let n=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:s.lazyRender,host:r,scrollbarState:new Gie(s.verticalHasArrows?s.arrowSize:0,s.vertical===2?0:s.verticalScrollbarSize,0,n.height,n.scrollHeight,a.scrollTop),visibility:s.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:s.scrollByPage}),s.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((s.verticalScrollbarSize-s.verticalSliderSize)/2),s.verticalSliderSize,void 0)}_updateSlider(e,s){this.slider.setHeight(e),this.slider.setTop(s)}_renderDomNode(e,s){this.domNode.setWidth(s),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,s){return s}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,s){e.scrollTop=s}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},$7e=500,U9=50,F7e=class{constructor(e,s,r){this.timestamp=e,this.deltaX=s,this.deltaY=r,this.score=0}},vI=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let s=1,r=0,n=1,a=this._rear;do{let i=a===this._front?s:Math.pow(2,-n);if(s-=i,r+=this._memory[a].score*i,a===this._front)break;a=(this._capacity+a-1)%this._capacity,n++}while(!0);return r<=.5}acceptStandardWheelEvent(s){if(nL){let r=ep(s.browserEvent),n=QHe(r);this.accept(Date.now(),s.deltaX*n,s.deltaY*n)}else this.accept(Date.now(),s.deltaX,s.deltaY)}accept(s,r,n){let a=null,i=new F7e(s,r,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(a=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,a)}_computeScore(s,r){if(Math.abs(s.deltaX)>0&&Math.abs(s.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(s.deltaX)||!this._isAlmostInt(s.deltaY))&&(n+=.25),r){let a=Math.abs(s.deltaX),i=Math.abs(s.deltaY),o=Math.abs(r.deltaX),l=Math.abs(r.deltaY),c=Math.max(Math.min(a,o),1),d=Math.max(Math.min(i,l),1),h=Math.max(a,o),p=Math.max(i,l);h%c===0&&p%d===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(s){return Math.abs(Math.round(s)-s)<.01}};vI.INSTANCE=new vI;var B7e=vI,U7e=class extends lL{constructor(e,s,r){super(),this._onScroll=this._register(new Ps),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Ps),this.onWillScroll=this._onWillScroll.event,this._options=H7e(s),this._scrollable=r,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let n={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new L7e(this._scrollable,this._options,n)),this._horizontalScrollbar=this._register(new D7e(this._scrollable,this._options,n)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=w0(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=w0(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=w0(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new iL),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=iv(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,ap&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new I9(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=iv(this._mouseWheelToDispose),e)){let s=r=>{this._onMouseWheel(new I9(r))};this._mouseWheelToDispose.push(ln(this._listenOnDomNode,dc.MOUSE_WHEEL,s,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let s=B7e.INSTANCE;s.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let a=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+a===0?i=a=0:Math.abs(a)>=Math.abs(i)?i=0:a=0),this._options.flipAxes&&([a,i]=[i,a]);let o=!ap&&e.browserEvent&&e.browserEvent.shiftKey;
566(this._options.scrollYToX||o)&&!i&&(i=a,a=0),e.browserEvent&&e.browserEvent.altKey&&(i=i*this._options.fastScrollSensitivity,a=a*this._options.fastScrollSensitivity);let l=this._scrollable.getFutureScrollPosition(),c={};if(a){let d=U9*a,h=l.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(c,h)}if(i){let d=U9*i,h=l.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(l.scrollLeft!==c.scrollLeft||l.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&s.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),r=!0)}let n=r;!n&&this._options.alwaysConsumeMouseWheel&&(n=!0),!n&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(n=!0),n&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),s=e.scrollTop>0,r=e.scrollLeft>0,n=r?" left":"",a=s?" top":"",i=r||s?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${n}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${i}${a}${n}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),$7e)}},z7e=class extends U7e{constructor(e,s,r){super(e,s,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function H7e(e){let s={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return s.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:s.horizontalScrollbarSize,s.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:s.verticalScrollbarSize,ap&&(s.className+=" mac"),s}var yI=class extends Yn{constructor(e,s,r,n,a,i,o,l){super(),this._bufferService=r,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new Ps),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new T7e({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:d=>oL(n.window,d)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new z7e(s,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(d=>{this._scrollableElement.updateOptions({handleMouseWheel:!(d&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Qc.runAndSubscribe(i.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=i.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(io(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=n.mainDocument.createElement("style"),s.appendChild(this._styleElement),this._register(io(()=>this._styleElement.remove())),this._register(Qc.runAndSubscribe(i.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar >
566 .slider {",`  background: ${i.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",`  background: ${i.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",`  background: ${i.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
567`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(d=>this._handleScroll(d)))}scrollLines(e){let s=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:s.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,s){s&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!s,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let s=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),r=s-this._bufferService.buffer.ydisp;r!==0&&(this._latestYDisp=s,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};yI=Bo([Js(2,Jd),Js(3,Ef),Js(4,Pie),Js(5,Yb),Js(6,eu),Js(7,Tf)],yI);var bI=class extends Yn{constructor(e,s,r,n,a){super(),this._screenElement=e,this._bufferService=s,this._coreBrowserService=r,this._decorationService=n,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>
567this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(i=>this._removeDecoration(i))),this._register(io(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let s=this._coreBrowserService.mainDocument.createElement("div");s.classList.add("xterm-decoration"),s.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let r=e.options.x??0;return r&&r>this._bufferService.cols&&(s.style.display="none"),this._refreshXPosition(e,s),s}_refreshStyle(e){let s=e.marker.line-this._bufferService.buffers.active.ydisp;if(s<0||s>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${s*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,s=e.element){if(!s)return;let r=e.options.x??0;(e.options.anchor||"left")==="right"?s.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":s.style.left=r?`${r*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};bI=Bo([Js(1,Jd),Js(2,Ef),Js(3,jN),Js(4,Tf)],bI);var q7e=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let s of this._zones)if(s.color===e.options.overviewRulerOptions.color&&s.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(s,e.marker.line))return;if(this._lineAdjacentToZone(s,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(s,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,s){return s>=e.startBufferLine&&s<=e.endBufferLine}_lineAdjacentToZone(e,s,r){return s>=e.startBufferLine-this._linePadding[r||"full"]&&s<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,s){e.startBufferLine=Math.min(e.startBufferLine,s),e.endBufferLine=Math.max(e.endBufferLine,s)}},Hh={full:0,left:0,center:0,right:0},Jf={full:0,left:0,center:0,right:0},Aw={full:0,left:0,center:0,right:0},Nk=class extends Yn{constructor(e,s,r,n,a,i,o,l){super(),this._viewportElement=e,this._screenElement=s,this._bufferService=r,this._decorationService=n,this._renderService=a,this._optionsService=i,this._themeService=o,this._coreBrowserService=l,this._colorZoneStore=new q7e,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(io(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>
567this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),s=Math.ceil((this._canvas.width-1)/3);Jf.full=this._canvas.width,Jf.left=e,Jf.center=s,Jf.right=e,this._refreshDrawHeightConstants(),Aw.full=1,Aw.left=1,Aw.center=1+Jf.left,Aw.right=1+Jf.left+Jf.center}_refreshDrawHeightConstants(){Hh.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,s=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Hh.left=s,Hh.center=s,Hh.right=s}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hh.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hh.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hh.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Hh.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let s of this._decorationService.decorations)this._colorZoneStore.addDecoration(s);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let s of e)s.position!=="full"&&this._renderColorZone(s);for(let s of e)s.position==="full"&&this._renderColorZone(s);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Aw[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Hh[e.position||"full"]/2),Jf[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Hh[e.position||"full"]))}_queueRefresh(e,s){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=s||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Nk=Bo([Js(2,Jd),Js(3,jN),Js(4,Tf),Js(5,eu),Js(6,Yb),Js(7,Ef)],Nk);var Vt;(e=>(e.NUL="\0",e.SOH="�",e.STX="�",e.ETX="�",e.EOT="�",e.ENQ="�",e.ACK="�",e.BEL="\x07",e.BS="\b",e.HT="	",e.LF=`
568`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="�",e.SI="�",e.DLE="�",e.DC1="�",e.DC2="�",e.DC3="�",e.DC4="�",e.NAK="�",e.SYN="�",e.ETB="�",e.CAN="�",e.EM="�",e.SUB="�",e.ESC="\x1B",e.FS="�",e.GS="�",e.RS="�",e.US="�",e.SP=" ",e.DEL="�"))(Vt||={});var bS;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(bS||={});var Yie;(e=>e.ST=`${Vt.ESC}\\`)(Yie||={});var wI=class{constructor(e,s,r,n,a,i){this._textarea=e,this._compositionView=s,this._bufferService=r,this._optionsService=n,this._coreService=a,this._renderService=i,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0}
568,this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let s={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let r;s.start+=this._dataAlreadySent.length,this._isComposing?r=this._textarea.value.substring(s.start,this._compositionPosition.start):r=this._textarea.value.substring(s.start),r.length>0&&this._coreService.triggerDataEvent(r,!0)}},0)}else{this._isSendingComposition=!1;let s=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(s,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let s=this._textarea.value,r=s.replace(e,"");this._dataAlreadySent=r,s.length>e.length?this._coreService.triggerDataEvent(r,!0):s.length<e.length?this._coreService.triggerDataEvent(`${Vt.DEL}`,!0):s.length===e.length&&s!==e&&this._coreService.triggerDataEvent(s,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let s=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,a=s*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=a+"px",this._compositionView.style.top=n+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=a+"px",this._textarea.style.top=n+"px",this._textarea.style.width=Math.max(i.width,1)+"px",this._textarea.style.height=Math.max(i.height,1)+"px",this._textarea.style.lineHeight=i.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};wI=Bo([Js(2,Jd),Js(3,eu),Js(4,vv),Js(5,Tf)],wI);var pc=0,fc=0,gc=0,Io=0,z9={css:"#00000000",rgba:0},Nl;(e=>{function s(a,i,o,l){return l!==void 0?`#${gx(a)}${gx(i)}${gx(o)}${gx(l)}`:`#${gx(a)}${gx(i)}${gx(o)}`}e.toCss=s;function r(a,i,o,l=255){return(a<<24|i<<16|o<<8|l)>>>0}e.toRgba=r;function n(a,i,o,l){return{css:e.toCss(a,i,o,l),rgba:e.toRgba(a,i,o,l)}}e.toColor=n})(Nl||={});var Ui;(e=>{function s(c,d){if(Io=(d.rgba&255)/255,Io===1)return{css:d.css,rgba:d.rgba};let h=d.rgba>>24&255,p=d.rgba>>16&255,g=d.rgba>>8&255,v=c.rgba>>24&255,b=c.rgba>>16&255,y=c.rgba>>8&255;pc=v+Math.round((h-v)*Io),fc=b+Math.round((p-b)*Io),gc=y+Math.round((g-y)*Io);let w=Nl.toCss(pc,fc,gc),j=Nl.toRgba(pc,fc,gc);return{css:w,rgba:j}}e.blend=s;function r(c){return(c.rgba&255)===255}e.isOpaque=r;function n(c,d,h){let p=wS.ensureContrastRatio(c.rgba,d.rgba,h);if(p)return Nl.toColor(p>>24&255,p>>16&255,p>>8&255)}e.ensureContrastRatio=n;function a(c){let d=(c.rgba|255)>>>0;return[pc,fc,gc]=wS.toChannels(d),{css:Nl.toCss(pc,fc,gc),rgba:d}}e.opaque=a;function i(c,d){return Io=Math.round(d*255),[pc,fc,gc]=wS.toChannels(c.rgba),{css:Nl.toCss(pc,fc,gc,Io),rgba:Nl.toRgba(pc,fc,gc,Io)}}e.opacity=i;function o(c,d){return Io=c.rgba&255,i(c,Io*d/255)}e.multiplyOpacity=o;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=l})(Ui||={});var yo;(e=>{let s,r;try{let a=document.createElement("canvas");a.width=1,a.height=1;let i=a.getContext("2d",{willReadFrequently:!0});i&&(s=i,s.globalCompositeOperation="copy",r=s.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return pc=parseInt(a.slice(1,2).repeat(2),16),fc=parseInt(a.slice(2,3).repeat(2),16),gc=parseInt(a.slice(3,4).repeat(2),16),Nl.toColor(pc,fc,gc);case 5:return pc=parseInt(a.slice(1,2).repeat(2),16),fc=parseInt(a.slice(2,3).repeat(2),16),gc=parseInt(a.slice(3,4).repeat(2),16),Io=parseInt(a.slice(4,5).repeat(2),16),Nl.toColor(pc,fc,gc,Io);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let i=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(i)return pc=parseInt(i[1]),fc=parseInt(i[2]),gc=parseInt(i[3]),Io=Math.round((i[5]===void 0?1:parseFloat(i[5]))*255),Nl.toColor(pc,fc,gc,Io);if(!s||!r)throw new Error("css.toColor: Unsupported css format");if(s.fillStyle=r,s.fillStyle=a,typeof s.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(s.fillRect(0,0,1,1),[pc,fc,gc,Io]=s.getImageData(0,0,1,1).data,Io!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Nl.toRgba(pc,fc,gc,Io),css:a}}e.toColor=n})(yo||={});var $d;(e=>{function s(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=s;function r(n,a,i){let o=n/255,l=a/255,c=i/255,d=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),h=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),p=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return d*.2126+h*.7152+p*.0722}e.relativeLuminance2=r})($d||={});var wS;(e=>{function s(o,l){if(Io=(l&255)/255,Io===1)return l;let c=l>>24&255,d=l>>16&255,h=l>>8&255,p=o>>24&255,g=o>>16&255,v=o>>8&255;return pc=p+Math.round((c-p)*Io),fc=g+Math.round((d-g)*Io),gc=v+Math.round((h-v)*Io),Nl.toRgba(pc,fc,gc)}e.blend=s;function r(o,l,c){let d=$d.relativeLuminance(o>>8),h=$d.relativeLuminance(l>>8);if(Bp(d,h)<c){if(h<d){let v=n(o,l,c),b=Bp(d,$d.relativeLuminance(v>>8));if(b<c){let y=a(o,l,c),w=Bp(d,$d.relativeLuminance(y>>8));return b>w?v:y}return v}let p=a(o,l,c),g=Bp(d,$d.relativeLuminance(p>>8));if(g<c){let v=n(o,l,c),b=Bp(d,$d.relativeLuminance(v>>8));return g>b?p:v}return p}}e.ensureContrastRatio=r;function n(o,l,c){let d=o>>24&255,h=o>>16&255,p=o>>8&255,g=l>>24&255,v=l>>16&255,b=l>>8&255,y=Bp($d.relativeLuminance2(g,v,b),$d.relativeLuminance2(d,h,p));for(;y<c&&(g>0||v>0||b>0);)g-=Math.max(0,Math.ceil(g*.1)),v-=Math.max(0,Math.ceil(v*.1)),b-=Math.max(0,Math.ceil(b*.1)),y=Bp($d.relativeLuminance2(g,v,b),$d.relativeLuminance2(d,h,p));return(g<<24|v<<16|b<<8|255)>>>0}e.reduceLuminance=n;function a(o,l,c){let d=o>>24&255,h=o>>16&255,p=o>>8&255,g=l>>24&255,v=l>>16&255,b=l>>8&255,y=Bp($d.relativeLuminance2(g,v,b),$d.relativeLuminance2(d,h,p));for(;y<c&&(g<255||v<255||b<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),y=Bp($d.relativeLuminance2(g,v,b),$d.relativeLuminance2(d,h,p));return(g<<24|v<<16|b<<8|255)>>>0}e.increaseLuminance=a;function i(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=i})(wS||={});function gx(e){let s=e.toString(16);return s.length<2?"0"+s:s}
568function Bp(e,s){return e<s?(s+.05)/(e+.05):(e+.05)/(s+.05)}var V7e=class extends wN{constructor(e,s,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=s,this._width=r}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Sk=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Im}register(e){let s={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(s),s.id}deregister(e){for(let s=0;s<this._characterJoiners.length;s++)if(this._characterJoiners[s].id===e)return this._characterJoiners.splice(s,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let s=this._bufferService.buffer.lines.get(e);if(!s||s.length===0)return[];let r=[],n=s.translateToString(!0),a=0,i=0,o=0,l=s.getFg(0),c=s.getBg(0);for(let d=0;d<s.getTrimmedLength();d++)if(s.loadCell(d,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(d-a>1){let h=this._getJoinedRanges(n,o,i,s,a);for(let p=0;p<h.length;p++)r.push(h[p])}a=d,o=i,l=this._workCell.fg,c=this._workCell.bg}i+=this._workCell.getChars().length||vg.length}if(this._bufferService.cols-a>1){let d=this._getJoinedRanges(n,o,i,s,a);for(let h=0;h<d.length;h++)r.push(d[h])}return r}_getJoinedRanges(e,s,r,n,a){let i=e.substring(s,r),o=[];try{o=this._characterJoiners[0].handler(i)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(i);for(let d=0;d<c.length;d++)Sk._mergeRanges(o,c[d])}catch(c){console.error(c)}return this._stringRangesToCellRanges(o,n,a),o}_stringRangesToCellRanges(e,s,r){let n=0,a=!1,i=0,o=e[n];if(o){for(let l=r;l<this._bufferService.cols;l++){let c=s.getWidth(l),d=s.getString(l).length||vg.length;if(c!==0){if(!a&&o[0]<=i&&(o[0]=l,a=!0),o[1]<=i){if(o[1]=l,o=e[++n],!o)break;o[0]<=i?(o[0]=l,a=!0):a=!1}i+=d}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,s){let r=!1;for(let n=0;n<e.length;n++){let a=e[n];if(r){if(s[1]<=a[0])return e[n-1][1]=s[1],e;if(s[1]<=a[1])return e[n-1][1]=Math.max(s[1],a[1]),e.splice(n,1),e;e.splice(n,1),n--}else{if(s[1]<=a[0])return e.splice(n,0,s),e;if(s[1]<=a[1])return a[0]=Math.min(s[0],a[0]),e;s[0]<a[1]&&(a[0]=Math.min(s[0],a[0]),r=!0);continue}}return r?e[e.length-1][1]=s[1]:e.push(s),e}};Sk=Bo([Js(0,Jd)],Sk);function W7e(e){return 57508<=e&&e<=57558}function K7e(e){return 9472<=e&&e<=9631}function G7e(e){return W7e(e)||K7e(e)}function Y7e(){return{css:{canvas:q1(),cell:q1()},device:{canvas:q1(),cell:q1(),char:{width:0,height:0,left:0,top:0}}}}function q1(){return{width:0,height:0}}var jI=class{constructor(e,s,r,n,a,i,o){this._document=e,this._characterJoinerService=s,this._optionsService=r,this._coreBrowserService=n,this._coreService=a,this._decorationService=i,this._themeService=o,this._workCell=new Im,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,s,r){this._selectionStart=e,this._selectionEnd=s,this._columnSelectMode=r}createRow(e,s,r,n,a,i,o,l,c,d,h){let p=[],g=this._characterJoinerService.getJoinedCharacters(s),v=this._themeService.colors,b=e.getNoBgTrimmedLength();r&&b<i+1&&(b=i+1);let y,w=0,j="",x=0,C=0,k=0,S=0,_=!1,A=0,T=!1,M=0,R=0,D=[],$=d!==-1&&h!==-1;for(let O=0;O<b;O++){e.loadCell(O,this._workCell);let q=this._workCell.getWidth();if(q===0)continue;let V=!1,K=O>=R,G=O,z=this._workCell;if(g.length>0&&O===g[0][0]&&K){let ge=g.shift(),be=this._isCellInSelection(ge[0],s);for(x=ge[0]+1;x<ge[1];x++)K&&=be===this._isCellInSelection(x,s);K&&=!r||i<ge[0]||i>=ge[1],K?(V=!0,z=new V7e(this._workCell,e.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),G=ge[1]-1,q=z.getWidth()):R=ge[1]}let Z=this._isCellInSelection(O,s),ee=r&&O===i,Q=$&&O>=d&&O<=h,Y=!1;this._decorationService.forEachDecorationAtCell(O,s,void 0,ge=>{Y=!0});let oe=z.getChars()||vg;if(oe===" "&&(z.isUnderline()||z.isOverline())&&(oe=" "),M=q*l-c.get(oe,z.isBold(),z.isItalic()),!y)y=this._document.createElement("span");else if(w&&(Z&&T||!Z&&!T&&z.bg===C)&&(Z&&T&&v.selectionForeground||z.fg===k)&&z.extended.ext===S&&Q===_&&M===A&&!ee&&!V&&!Y&&K){z.isInvisible()?j+=vg:j+=oe,w++;continue}else w&&(y.textContent=j),y=this._document.createElement("span"),w=0,j="";if(C=z.bg,k=z.fg,S=z.extended.ext,_=Q,A=M,T=Z,V&&i>=O&&i<=G&&(i=O),!this._coreService.isCursorHidden&&ee&&this._coreService.isCursorInitialized){if(D.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&D.push("xterm-cursor-blink"),D.push(n==="bar"?"xterm-cursor-bar":n==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":D.push("xterm-cursor-outline");break;case"block":D.push("xterm-cursor-block");break;case"bar":D.push("xterm-cursor-bar");break;case"underline":D.push("xterm-cursor-underline");break}}if(z.isBold()&&D.push("xterm-bold"),z.isItalic()&&D.push("xterm-italic"),z.isDim()&&D.push("xterm-dim"),z.isInvisible()?j=vg:j=z.getChars()||vg,z.isUnderline()&&(D.push(`xterm-underline-${z.extended.underlineStyle}`),j===" "&&(j=" "),!z.isUnderlineColorDefault()))if(z.isUnderlineColorRGB())y.style.textDecorationColor=`rgb(${wN.toColorRGB(z.getUnderlineColor()).join(",")})`;else{let ge=z.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&z.isBold()&&ge<8&&(ge+=8),y.style.textDecorationColor=v.ansi[ge].css}z.isOverline()&&(D.push("xterm-overline"),j===" "&&(j=" ")),z.isStrikethrough()&&D.push("xterm-strikethrough"),Q&&(y.style.textDecoration="underline");let he=z.getFgColor(),je=z.getFgColorMode(),pe=z.getBgColor(),le=z.getBgColorMode(),ue=!!z.isInverse();if(ue){let ge=he;he=pe,pe=ge;let be=je;je=le,le=be}let fe,H,se=!1;this._decorationService.forEachDecorationAtCell(O,s,void 0,ge=>{ge.options.layer!=="top"&&se||(ge.backgroundColorRGB&&(le=50331648,pe=ge.backgroundColorRGB.rgba>>8&16777215,fe=ge.backgroundColorRGB),ge.foregroundColorRGB&&(je=50331648,he=ge.foregroundColorRGB.rgba>>8&16777215,H=ge.foregroundColorRGB),se=ge.options.layer==="top")}),!se&&Z&&(fe=this._coreBrowserService.isFocused?v.selectionBackgroun
568dOpaque:v.selectionInactiveBackgroundOpaque,pe=fe.rgba>>8&16777215,le=50331648,se=!0,v.selectionForeground&&(je=50331648,he=v.selectionForeground.rgba>>8&16777215,H=v.selectionForeground)),se&&D.push("xterm-decoration-top");let me;switch(le){case 16777216:case 33554432:me=v.ansi[pe],D.push(`xterm-bg-${pe}`);break;case 50331648:me=Nl.toColor(pe>>16,pe>>8&255,pe&255),this._addStyle(y,`background-color:#${H9((pe>>>0).toString(16),"0",6)}`);break;default:ue?(me=v.foreground,D.push("xterm-bg-257")):me=v.background}switch(fe||z.isDim()&&(fe=Ui.multiplyOpacity(me,.5)),je){case 16777216:case 33554432:z.isBold()&&he<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(he+=8),this._applyMinimumContrast(y,me,v.ansi[he],z,fe,void 0)||D.push(`xterm-fg-${he}`);break;case 50331648:let ge=Nl.toColor(he>>16&255,he>>8&255,he&255);this._applyMinimumContrast(y,me,ge,z,fe,H)||this._addStyle(y,`color:#${H9(he.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(y,me,v.foreground,z,fe,H)||ue&&D.push("xterm-fg-257")}D.length&&(y.className=D.join(" "),D.length=0),!ee&&!V&&!Y&&K?w++:y.textContent=j,M!==this.defaultSpacing&&(y.style.letterSpacing=`${M}px`),p.push(y),O=G}return y&&w&&(y.textContent=j),p}_applyMinimumContrast(e,s,r,n,a,i){if(this._optionsService.rawOptions.minimumContrastRatio===1||G7e(n.getCode()))return!1;let o=this._getContrastCache(n),l;if(!a&&!i&&(l=o.getColor(s.rgba,r.rgba)),l===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(n.isDim()?2:1);l=Ui.ensureContrastRatio(a||s,i||r,c),o.setColor((a||s).rgba,(i||r).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,s){e.setAttribute("style",`${e.getAttribute("style")||""}${s};`)}_isCellInSelection(e,s){let r=this._selectionStart,n=this._selectionEnd;return!r||!n?!1:this._columnSelectMode?r[0]<=n[0]?e>=r[0]&&s>=r[1]&&e<n[0]&&s<=n[1]:e<r[0]&&s>=r[1]&&e>=n[0]&&s<=n[1]:s>r[1]&&s<n[1]||r[1]===n[1]&&s===r[1]&&e>=r[0]&&e<n[0]||r[1]<n[1]&&s===n[1]&&e<n[0]||r[1]<n[1]&&s===r[1]&&e>=r[0]}};jI=Bo([Js(1,Aie),Js(2,eu),Js(3,Ef),Js(4,vv),Js(5,jN),Js(6,Yb)],jI);function H9(e,s,r){for(;e.length<r;)e=s+e;return e}var Q7e=class{constructor(e,s){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let r=e.createElement("span");r.classList.add("xterm-char-measure-element");let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontStyle="italic";let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold",i.style.fontStyle="italic",this._measureElements=[r,n,a,i],this._container.appendChild(r),this._container.appendChild(n),this._container.appendChild(a),this._container.appendChild(i),s.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,s,r,n){e===this._font&&s===this._fontSize&&r===this._weight&&n===this._weightBold||(this._font=e,this._fontSize=s,this._weight=r,this._weightBold=n,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${n}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${n}`,this.clear())}get(e,s,r){let n=0;if(!s&&!r&&e.length===1&&(n=e.charCodeAt(0))<256){if(this._flat[n]!==-9999)return this._flat[n];let o=this._measure(e,0);return o>0&&(this._flat[n]=o),o}let a=e;s&&(a+="B"),r&&(a+="I");let i=this._holey.get(a);if(i===void 0){let o=0;
568s&&(o|=1),r&&(o|=2),i=this._measure(e,o),i>0&&this._holey.set(a,i)}return i}_measure(e,s){let r=this._measureElements[s];return r.textContent=e.repeat(32),r.offsetWidth/32}},X7e=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,s,r,n=!1){if(this.selectionStart=s,this.selectionEnd=r,!s||!r||s[0]===r[0]&&s[1]===r[1]){this.clear();return}let a=e.buffers.active.ydisp,i=s[1]-a,o=r[1]-a,l=Math.max(i,0),c=Math.min(o,e.rows-1);if(l>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=n,this.viewportStartRow=i,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=s[0],this.endCol=r[0]}isCellSelected(e,s,r){return this.hasSelection?(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?s>=this.startCol&&r>=this.viewportCappedStartRow&&s<this.endCol&&r<=this.viewportCappedEndRow:s<this.startCol&&r>=this.viewportCappedStartRow&&s>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&s>=this.startCol&&s<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&s<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&s>=this.startCol):!1}};function Z7e(){return new X7e}var i5="xterm-dom-renderer-owner-",gm="xterm-rows",V1="xterm-fg-",q9="xterm-bg-",Mw="xterm-focus",W1="xterm-selection",J7e=1,NI=class extends Yn{constructor(e,s,r,n,a,i,o,l,c,d,h,p,g,v){super(),this._terminal=e,this._document=s,this._element=r,this._screenElement=n,this._viewportElement=a,this._helperContainer=i,this._linkifier2=o,this._charSizeService=c,this._optionsService=d,this._bufferService=h,this._coreService=p,this._coreBrowserService=g,this._themeService=v,this._terminalClass=J7e++,this._rowElements=[],this._selectionRenderModel=Z7e(),this.onRequestRedraw=this._register(new Ps).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(gm),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(W1),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Y7e(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(b=>this._injectCss(b))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(jI,document),this._element.classList.add(i5+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(b=>this._handleLinkHover(b))),this._register(this._linkifier2.onHideLinkUnderline(b=>this._handleLinkLeave(b))),this._register(io(()=>{this._element.classList.remove(i5+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Q7e(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.
vendor: 8,546 bytes, line 568
568canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let r of this._rowElements)r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let s=`${this._terminalSelector} .${gm} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=s,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let s=`${this._terminalSelector} .${gm} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;s+=`${this._terminalSelector} .${gm} .xterm-dim { color: ${Ui.multiplyOpacity(e.foreground,.5).css};}`,s+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let r=`blink_underline_${this._terminalClass}`,n=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;s+=`@keyframes ${r} { 50% {  border-bottom-style: hidden; }}`,s+=`@keyframes ${n} { 50% {  box-shadow: none; }}`,s+=`@keyframes ${a} { 0% {  background-color: ${e.cursor.css};  color: ${e.cursorAccent.css}; } 50% {  background-color: inherit;  color: ${e.cursor.css}; }}`,s+=`${this._terminalSelector} .${gm}.${Mw} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${gm}.${Mw} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${gm}.${Mw} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${gm} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${gm} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${gm} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${gm} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${gm} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,s+=`${this._terminalSelector} .${W1} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${W1} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${W1} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[i,o]of e.ansi.entries())s+=`${this._terminalSelector} .${V1}${i} { color: ${o.css}; }${this._terminalSelector} .${V1}${i}.xterm-dim { color: ${Ui.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${q9}${i} { background-color: ${o.css}; }`;s+=`${this._terminalSelector} .${V1}257 { color: ${Ui.opaque(e.background).css}; }${this._terminalSelector} .${V1}257.xterm-dim { color: ${Ui.multiplyOpacity(Ui.opaque(e.background),.5).css}; }${this._terminalSelector} .${q9}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=s}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,s){for(let r=this._rowElements.length;r<=s;r++){let n=this._document.createElement("div");this._rowContainer.appendChild(n),this._rowElements.push(n)}for(;this._rowElements.length>s;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,s){this._refreshRowElements(e,s),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Mw),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Mw),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,s,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,s,r),this.renderRows(0,this._bufferService.rows-1),!e||!s||(this._selectionRenderModel.update(this._terminal,e,s,r),!this._selectionRenderModel.hasSelection))return;let n=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,i=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(r){let c=e[0]>s[0];l.appendChild(this._createSelectionElement(i,c?s[0]:e[0],c?e[0]:s[0],o-i+1))}else{let c=n===i?e[0]:0,d=i===a?s[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(i,c,d));let h=o-i-1;if(l.appendChild(this._createSelectionElement(i+1,0,this._bufferService.cols,h)),i!==o){let p=a===o?s[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,0,p))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,s,r,n=1){let a=this._document.createElement("div"),i=s*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(r-s);return i+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-i),a.style.height=`${n*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${i}px`,a.style.width=`${o}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,s){let r=this._bufferService.buffer,n=r.ybase+r.y,a=Math.min(r.x,this._bufferService.cols-1),i=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=s;c++){let d=c+r.ydisp,h=this._rowElements[c],p=r.lines.get(d);if(!h||!p)break;h.replaceChildren(...this._rowFactory.createRow(p,d,d===n,o,l,a,i,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${i5}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,s,r,n,a,i){r<0&&(e=0),n<0&&(s=0);let o=this._bufferService.rows-1;r=Math.max(Math.min(r,o),0),n=Math.max(Math.min(n,o),0),a=Math.min(a,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,d=Math.min(l.x,a-1),h=this._optionsService.rawOptions.cursorBlink,p=this._optionsService.rawOptions.cursorStyle,g=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=r;v<=n;++v){let b=v+l.ydisp,y=this._rowElements[v],w=l.lines.get(b);if(!y||!w)break;y.replaceChildren(...this._rowFactory.createRow(w,b,b===c,p,g,d,h,this.dimensions.css.
568cell.width,this._widthCache,i?v===r?e:0:-1,i?(v===n?s:a)-1:-1))}}};NI=Bo([Js(7,tL),Js(8,u2),Js(9,eu),Js(10,Jd),Js(11,vv),Js(12,Ef),Js(13,Yb)],NI);var SI=class extends Yn{constructor(e,s,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Ps),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new tqe(this._optionsService))}catch{this._measureStrategy=this._register(new eqe(e,s,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};SI=Bo([Js(2,eu)],SI);var Qie=class extends Yn{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,s){e!==void 0&&e>0&&s!==void 0&&s>0&&(this._result.width=e,this._result.height=s)}},eqe=class extends Qie{constructor(e,s,r){super(),this._document=e,this._parentElement=s,this._optionsService=r,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},tqe=class extends Qie{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let s=this._ctx.measureText("W");if(!("width"in s&&"fontBoundingBoxAscent"in s&&"fontBoundingBoxDescent"in s))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},sqe=class extends Yn{constructor(e,s,r){super(),this._textarea=e,this._window=s,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new rqe(this._window)),this._onDprChange=this._register(new Ps),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Ps),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(n=>this._screenDprMonitor.setWindow(n))),this._register(Qc.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ln(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ln(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},rqe=class extends Yn{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new yb),this._onDprChange=this._register(new Ps),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(io(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=ln(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},nqe=class extends Yn{constructor(){super(),this.linkProviders=[],this._register(io(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let s=this.linkProviders.indexOf(e);s!==-1&&this.linkProviders.splice(s,1)}}}};function cL(e,s,r){let n=r.getBoundingClientRect(),a=e.getComputedStyle(r),i=parseInt(a.getPropertyValue("padding-left")),o=parseInt(a.getPropertyValue("padding-top"));return[s.clientX-n.left-i,s.clientY-n.top-o]}function aqe(e,s,r,n,a,i,o,l,c){if(!i)return;let d=cL(e,s,r);if(d)return d[0]=Math.ceil((d[0]+(c?o/2:0))/o),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),n+(c?1:0)),d[1]=Math.min(Math.max(d[1],1),a),d}var CI=class{constructor(e,s){this._renderService=e,this._charSizeService=s}getCoords(e,s,r,n,a){return aqe(window,e,s,r,n,this._charSizeService.hasValidSize,this._renderService.dimensions.css.
568cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,s){let r=cL(window,e,s);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};CI=Bo([Js(0,Tf),Js(1,u2)],CI);var iqe=class{constructor(e,s){this._renderCallback=e,this._coreBrowserService=s,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,s,r){this._rowCount=r,e=e!==void 0?e:0,s=s!==void 0?s:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,s):s,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),s=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,s),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Xie={};gHe(Xie,{getSafariVersion:()=>lqe,isChromeOS:()=>toe,isFirefox:()=>Zie,isIpad:()=>cqe,isIphone:()=>dqe,isLegacyEdge:()=>oqe,isLinux:()=>dL,isMac:()=>Ck,isNode:()=>m2,isSafari:()=>Jie,isWindows:()=>eoe});var m2=typeof process<"u"&&"title"in process,NN=m2?"node":navigator.userAgent,SN=m2?"node":navigator.platform,Zie=NN.includes("Firefox"),oqe=NN.includes("Edge"),Jie=/^((?!chrome|android).)*safari/i.test(NN);function lqe(){if(!Jie)return 0;let e=NN.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Ck=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(SN),cqe=SN==="iPad",dqe=SN==="iPhone",eoe=["Windows","Win16","Win32","WinCE"].includes(SN),dL=SN.indexOf("Linux")>=0,toe=/\bCrOS\b/.test(NN),soe=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let s=0,r=0,n=e.timeRemaining(),a=0;for(;this._i<this._tasks.length;){if(s=performance.now(),this._tasks[this._i]()||this._i++,s=Math.max(1,performance.now()-s),r=Math.max(s,r),a=e.timeRemaining(),r*1.5>a){n-s<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-s))}ms`),this._start();return}n=a}this.clear()}},uqe=class extends soe{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let s=performance.now()+e;return{timeRemaining:()=>Math.max(0,s-performance.now())}}},mqe=class extends soe{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},kk=!m2&&"requestIdleCallback"in window?mqe:uqe,hqe=class{constructor(){this._queue=new kk}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},kI=class extends Yn{constructor(e,s,r,n,a,i,o,l,c){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=n,this._coreService=a,this._coreBrowserService=l,this._renderer=this._register(new yb),this._pausedResizeTask=new hqe,this._observerDisposable=this._register(new yb),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Ps),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Ps),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Ps),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Ps),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new iqe((d,h)=>this._renderRows(d,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new pqe(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(io(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>
568this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(i.onDecorationRegistered(()=>this._fullRefresh())),this._register(i.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,s),this._register(this._coreBrowserService.onWindowChange(d=>this._registerIntersectionObserver(d,s)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,s){if("IntersectionObserver"in e){let r=new e.IntersectionObserver(n=>this._handleIntersectionChange(n[n.length-1]),{threshold:0});r.observe(s),this._observerDisposable.value=io(()=>r.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,s,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,s);return}let n=this._syncOutputHandler.flush();n&&(e=Math.min(e,n.start),s=Math.max(s,n.end)),r||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,s,this._rowCount)}_renderRows(e,s){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,s);return}e=Math.min(e,this._rowCount-1),s=Math.min(s,this._rowCount-1),this._renderer.value.renderRows(e,s),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:s}),this._onRender.fire({start:e,end:s}),this._isNextRenderRedrawOnly=!0}}resize(e,s){this._rowCount=s,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(s=>this.refreshRows(s.start,s.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,s){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,s)):this._renderer.value.handleResize(e,s),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,s,r){this._selectionState.start=e,this._selectionState.end=s,this._selectionState.columnSelectMode=r,this._renderer.value?.handleSelectionChanged(e,s,r)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};kI=Bo([Js(2,eu),Js(3,u2),Js(4,vv),Js(5,jN),Js(6,Jd),Js(7,Ef),Js(8,Yb)],kI);var pqe=class{constructor(e,s,r){this._coreBrowserService=e,this._coreService=s,this._onTimeout=r,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,s){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,s)):(this._start=e,this._end=s,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function fqe(e,s,r,n){let a=r.buffer.x,i=r.buffer.y;if(!r.buffer.hasScrollback)return vqe(a,i,e,s,r,n)+h2(i,s,r,n)+yqe(a,i,e,s,r,n);let o;if(i===s)return o=a>e?"D":"C",$j(Math.abs(a-e),Lj(o,n));o=i>s?"D":"C";let l=Math.abs(i-s),c=xqe(i>s?e:a,r)+(l-1)*r.cols+1+gqe(i>s?a:e);return $j(c,Lj(o,n))}function gqe(e,s){return e-1}function xqe(e,s){return s.cols-e}function vqe(e,s,r,n,a,i){return h2(s,n,a,i).length===0?"":$j(noe(e,s,e,s-ov(s,a),!1,a).length,Lj("D",i))}function h2(e,s,r,n){let a=e-ov(e,r),i=s-ov(s,r),o=Math.abs(a-i)-bqe(e,s,r);return $j(o,Lj(roe(e,s),n))}function yqe(e,s,r,n,a,i){let o;h2(s,n,a,i).length>0?o=n-ov(n,a):o=s;let l=n,c=wqe(e,s,r,n,a,i);return $j(noe(e,o,r,l,c==="C",a).length,Lj(c,i))}function bqe(e,s,r){let n=0,a=e-ov(e,r),i=s-ov(s,r);for(let o=0;o<Math.abs(a-i);o++){let l=roe(e,s)==="A"?-1:1;r.buffer.lines.get(a+l*o)?.isWrapped&&n++}
568return n}function ov(e,s){let r=0,n=s.buffer.lines.get(e),a=n?.isWrapped;for(;a&&e>=0&&e<s.rows;)r++,n=s.buffer.lines.get(--e),a=n?.isWrapped;return r}function wqe(e,s,r,n,a,i){let o;return h2(r,n,a,i).length>0?o=n-ov(n,a):o=s,e<r&&o<=n||e>=r&&o<n?"C":"D"}function roe(e,s){return e>s?"A":"B"}function noe(e,s,r,n,a,i){let o=e,l=s,c="";for(;(o!==r||l!==n)&&l>=0&&l<i.buffer.lines.length;)o+=a?1:-1,a&&o>i.cols-1?(c+=i.buffer.translateBufferLineToString(l,!1,e,o),o=0,e=0,l++):!a&&o<0&&(c+=i.buffer.translateBufferLineToString(l,!1,0,e+1),o=i.cols-1,e=o,l--);return c+i.buffer.translateBufferLineToString(l,!1,e,o)}function Lj(e,s){let r=s?"O":"[";return Vt.ESC+r+e}function $j(e,s){e=Math.floor(e);let r="";for(let n=0;n<e;n++)r+=s;return r}var jqe=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,s=this.selectionEnd;return!e||!s?!1:e[1]>s[1]||e[1]===s[1]&&e[0]>s[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function V9(e,s){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return s*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var o5=50,Nqe=15,Sqe=50,Cqe=500,kqe=" ",_qe=new RegExp(kqe,"g"),_I=class extends Yn{constructor(e,s,r,n,a,i,o,l,c){super(),this._element=e,this._screenElement=s,this._linkifier=r,this._bufferService=n,this._coreService=a,this._mouseService=i,this._optionsService=o,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Im,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Ps),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Ps),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Ps),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Ps),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=d=>this._handleMouseMove(d),this._mouseUpListener=d=>this._handleMouseUp(d),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(d=>this._handleTrim(d)),this._register(this._bufferService.buffers.onBufferActivate(d=>this._handleBufferActivate(d))),this.enable(),this._model=new jqe(this._bufferService),this._activeSelectionMode=0,this._register(io(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(d=>{d.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!e||!s?!1:e[0]!==s[0]||e[1]!==s[1]}get selectionText(){let e=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;if(!e||!s)return"";let r=this._bufferService.buffer,n=[];if(this._activeSelectionMode===3){if(e[0]===s[0])return"";let a=e[0]<s[0]?e[0]:s[0],i=e[0]<s[0]?s[0]:e[0];for(let o=e[1];o<=s[1];o++){let l=r.translateBufferLineToString(o,!0,a,i);n.push(l)}}else{let a=e[1]===s[1]?s[0]:void 0;n.push(r.translateBufferLineToString(e[1],!0,e[0],a));for(let i=e[1]+1;i<=s[1]-1;i++){let o=r.lines.get(i),l=r.translateBufferLineToString(i,!0);o?.isWrapped?n[n.length-1]+=l:n.push(l)}if(e[1]!==s[1]){let i=r.lines.get(s[1]),o=r.translateBufferLineToString(s[1],!0,0,s[0]);i&&i.isWrapped?n[n.length-1]+=o:n.push(o)}}return n.map(a=>a.replace(_qe," ")).join(eoe?`\r
569`:`
570`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>
570this._refresh())),dL&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let s=this._getMouseBufferCoords(e),r=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!r||!n||!s?!1:this._areCoordsInSelection(s,r,n)}isCellInSelection(e,s){let r=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!r||!n?!1:this._areCoordsInSelection([e,s],r,n)}_areCoordsInSelection(e,s,r){return e[1]>s[1]&&e[1]<r[1]||s[1]===r[1]&&e[1]===s[1]&&e[0]>=s[0]&&e[0]<r[0]||s[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||s[1]<r[1]&&e[1]===s[1]&&e[0]>=s[0]}_selectWordAtCursor(e,s){let r=this._linkifier.currentLink?.link?.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=V9(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let n=this._getMouseBufferCoords(e);return n?(this._selectWordAt(n,s),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,s){this._model.clearSelection(),e=Math.max(e,0),s=Math.min(s,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,s],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let s=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(s)return s[0]--,s[1]--,s[1]+=this._bufferService.buffer.ydisp,s}_getMouseEventScrollAmount(e){let s=cL(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return s>=0&&s<=r?0:(s>r&&(s-=r),s=Math.min(Math.max(s,-o5),o5),s/=o5,s/Math.abs(s)+Math.round(s*(Nqe-1)))}shouldForceSelection(e){return Ck?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Sqe)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let s=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);s&&s.length!==this._model.selectionStart[0]&&s.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let s=this._getMouseBufferCoords(e);s&&(this._activeSelectionMode=2,this._selectLineAt(s[1]))}shouldColumnSelect(e){return e.altKey&&!(Ck&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let s=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let n=r.lines.get(this._model.selectionEnd[1]);n&&n.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}
570(!s||s[0]!==this._model.selectionEnd[0]||s[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let s=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&s<Cqe&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let n=fqe(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(n,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,s=this._model.finalSelectionEnd,r=!!e&&!!s&&(e[0]!==s[0]||e[1]!==s[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,s,r);return}!e||!s||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||s[0]!==this._oldSelectionEnd[0]||s[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,s,r)}_fireOnSelectionChange(e,s,r){this._oldSelectionStart=e,this._oldSelectionEnd=s,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(s=>this._handleTrim(s))}_convertViewportColToCharacterIndex(e,s){let r=s;for(let n=0;s>=n;n++){let a=e.loadCell(n,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:a>1&&s!==n&&(r+=a-1)}return r}setSelection(e,s,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,s],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,s,r=!0,n=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,i=a.lines.get(e[1]);if(!i)return;let o=a.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(i,e[0]),c=l,d=e[0]-l,h=0,p=0,g=0,v=0;if(o.charAt(l)===" "){for(;l>0&&o.charAt(l-1)===" ";)l--;for(;c<o.length&&o.charAt(c+1)===" ";)c++}else{let w=e[0],j=e[0];i.getWidth(w)===0&&(h++,w--),i.getWidth(j)===2&&(p++,j++);let x=i.getString(j).length;for(x>1&&(v+=x-1,c+=x-1);w>0&&l>0&&!this._isCharWordSeparator(i.loadCell(w-1,this._workCell));){i.loadCell(w-1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,w--):C>1&&(g+=C-1,l-=C-1),l--,w--}for(;j<i.length&&c+1<o.length&&!this._isCharWordSeparator(i.loadCell(j+1,this._workCell));){i.loadCell(j+1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===2?(p++,j++):C>1&&(v+=C-1,c+=C-1),c++,j++}}c++;let b=l+d-h+g,y=Math.min(this._bufferService.cols,c-l+h+p-g-v);if(!(!s&&o.slice(l,c).trim()==="")){if(r&&b===0&&i.getCodePoint(0)!==32){let w=a.lines.get(e[1]-1);if(w&&i.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let j=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(j){let x=this._bufferService.cols-j.start;b-=x,y+=x}}}if(n&&b+y===this._bufferService.cols&&i.getCodePoint(this._bufferService.cols-1)!==32){let w=a.lines.get(e[1]+1);if(w?.isWrapped&&w.getCodePoint(0)!==32){let j=this._getWordAt([0,e[1]+1],!1,!1,!0);j&&(y+=j.length)}}return{start:b,length:y}}}_selectWordAt(e,s){let r=this._getWordAt(e,s);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let s=this._getWordAt(e,!0);if(s){let r=e[1];for(;s.start<0;)s.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;s.start+s.length>this._bufferService.cols;)s.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?s.start:s.start+s.length,r]}}
570_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let s=this._bufferService.buffer.getWrappedRangeForLine(e),r={start:{x:0,y:s.first},end:{x:this._bufferService.cols-1,y:s.last}};this._model.selectionStart=[0,s.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=V9(r,this._bufferService.cols)}};_I=Bo([Js(3,Jd),Js(4,vv),Js(5,sL),Js(6,eu),Js(7,Tf),Js(8,Ef)],_I);var W9=class{constructor(){this._data={}}set(e,s,r){this._data[e]||(this._data[e]={}),this._data[e][s]=r}get(e,s){return this._data[e]?this._data[e][s]:void 0}clear(){this._data={}}},K9=class{constructor(){this._color=new W9,this._css=new W9}setCss(e,s,r){this._css.set(e,s,r)}getCss(e,s){return this._css.get(e,s)}setColor(e,s,r){this._color.set(e,s,r)}getColor(e,s){return this._color.get(e,s)}clear(){this._color.clear(),this._css.clear()}},Fl=Object.freeze((()=>{let e=[yo.toColor("#2e3436"),yo.toColor("#cc0000"),yo.toColor("#4e9a06"),yo.toColor("#c4a000"),yo.toColor("#3465a4"),yo.toColor("#75507b"),yo.toColor("#06989a"),yo.toColor("#d3d7cf"),yo.toColor("#555753"),yo.toColor("#ef2929"),yo.toColor("#8ae234"),yo.toColor("#fce94f"),yo.toColor("#729fcf"),yo.toColor("#ad7fa8"),yo.toColor("#34e2e2"),yo.toColor("#eeeeec")],s=[0,95,135,175,215,255];for(let r=0;r<216;r++){let n=s[r/36%6|0],a=s[r/6%6|0],i=s[r%6];e.push({css:Nl.toCss(n,a,i),rgba:Nl.toRgba(n,a,i)})}for(let r=0;r<24;r++){let n=8+r*10;e.push({css:Nl.toCss(n,n,n),rgba:Nl.toRgba(n,n,n)})}return e})()),jx=yo.toColor("#ffffff"),Yw=yo.toColor("#000000"),G9=yo.toColor("#ffffff"),Y9=Yw,Rw={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Pqe=jx,PI=class extends Yn{constructor(e){super(),this._optionsService=e,this._contrastCache=new K9,this._halfContrastCache=new K9,this._onChangeColors=this._register(new Ps),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:jx,background:Yw,cursor:G9,cursorAccent:Y9,selectionForeground:void 0,selectionBackgroundTransparent:Rw,selectionBackgroundOpaque:Ui.blend(Yw,Rw),selectionInactiveBackgroundTransparent:Rw,selectionInactiveBackgroundOpaque:Ui.blend(Yw,Rw),scrollbarSliderBackground:Ui.opacity(jx,.2),scrollbarSliderHoverBackground:Ui.opacity(jx,.4),scrollbarSliderActiveBackground:Ui.opacity(jx,.5),overviewRulerBorder:jx,ansi:Fl.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let s=this._colors;if(s.foreground=di(e.foreground,jx),s.background=di(e.background,Yw),s.cursor=Ui.blend(s.background,di(e.cursor,G9)),s.cursorAccent=Ui.blend(s.background,di(e.cursorAccent,Y9)),s.selectionBackgroundTransparent=di(e.selectionBackground,Rw),s.selectionBackgroundOpaque=Ui.blend(s.background,s.selectionBackgroundTransparent),s.selectionInactiveBackgroundTransparent=di(e.selectionInactiveBackground,s.selectionBackgroundTransparent),s.selectionInactiveBackgroundOpaque=Ui.blend(s.background,s.selectionInactiveBackgroundTransparent),s.selectionForeground=e.selectionForeground?di(e.selectionForeground,z9):void 0,s.selectionForeground===z9&&(s.selectionForeground=void 0),Ui.isOpaque(s.selectionBackgroundTransparent)&&(s.selectionBackgroundTransparent=Ui.opacity(s.selectionBackgroundTransparent,.3)),Ui.isOpaque(s.selectionInactiveBackgroundTransparent)&&(s.selectionInactiveBackgroundTransparent=Ui.opacity(s.selectionInactiveBackgroundTransparent,.3)),s.scrollbarSliderBackground=di(e.scrollbarSliderBackground,Ui.opacity(s.foreground,.2)),s.scrollbarSliderHoverBackground=di(e.scrollbarSliderHoverBackground,Ui.opacity(s.foreground,.4)),s.scrollbarSliderActiveBackground=di(e.scrollbarSliderActiveBackground,Ui.opacity(s.foreground,.5)),s.overviewRulerBorder=di(e.overviewRulerBorder,Pqe),s.ansi=Fl.slice(),s.ansi[0]=di(e.black,Fl[0]),s.ansi[1]=di(e.red,Fl[1]),s.ansi[2]=di(e.green,Fl[2]),s.ansi[3]=di(e.yellow,Fl[3]),s.ansi[4]=di(e.blue,Fl[4]),s.ansi[5]=di(e.magenta,Fl[5]),s.ansi[6]=di(e.cyan,Fl[6]),s.ansi[7]=di(e.white,Fl[7]),s.ansi[8]=di(e.brightBlack,Fl[8]),s.ansi[9]=di(e.brightRed,Fl[9]),s.ansi[10]=di(e.brightGreen,Fl[10]),s.ansi[11]=di(e.brightYellow,Fl[11]),s.ansi[12]=di(e.brightBlue,Fl[12]),s.ansi[13]=di(e.brightMagenta,Fl[13]),s.ansi[14]=di(e.brightCyan,Fl[14]),s.ansi[15]=di(e.brightWhite,Fl[15]),e.extendedAnsi){let r=Math.min(s.ansi.length-16,e.extendedAnsi.length);for(let n=0;n<r;n++)s.ansi[n+16]=di(e.extendedAnsi[n],Fl[n+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let s=0;s<this._restoreColors.ansi.length;++s)this._colors.ansi[s]=this._restoreColors.ansi[s];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};PI=Bo([Js(0,eu)],PI);function di(e,s){if(e!==void 0)try{return yo.toColor(e)}catch{}return s}var Eqe=class{constructor(...e){this._entries=new Map;for(let[s,r]of e)this.set(s,r)}set(e,s){let r=this._entries.get(e);return this._entries.set(e,s),r}forEach(e){for(let[s,r]of this._entries.entries())e(s,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Tqe=class{constructor(){this._services=new Eqe,this._services.set(tL,this)}setService(e,s){this._services.set(e,s)}getService(e){return this._services.get(e)}createInstance(e,...s){let r=NHe(e).sort((i,o)=>i.index-o.index),n=[];for(let i of r){let o=this._services.get(i.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${i.id._id}.`);n.push(o)}let a=r.length>0?r[0].index:s.length;if(s.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1}
570 conflicts with ${s.length} static arguments`);return new e(...s,...n)}},Aqe={trace:0,debug:1,info:2,warn:3,error:4,off:5},Mqe="xterm.js: ",EI=class extends Yn{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Aqe[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let s=0;s<e.length;s++)typeof e[s]=="function"&&(e[s]=e[s]())}_log(e,s,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":Mqe)+s,...r)}trace(e,...s){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,s)}debug(e,...s){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,s)}info(e,...s){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,s)}warn(e,...s){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,s)}error(e,...s){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,s)}};EI=Bo([Js(0,eu)],EI);var Q9=class extends Yn{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Ps),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Ps),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Ps),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let s=new Array(e);for(let r=0;r<Math.min(e,this.length);r++)s[r]=this._array[this._getCyclicIndex(r)];this._array=s,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let s=this._length;s<e;s++)this._array[s]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,s){this._array[this._getCyclicIndex(e)]=s}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,s,...r){if(s){for(let n=e;n<this._length-s;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+s)];this._length-=s,this.onDeleteEmitter.fire({index:e,amount:s})}for(let n=this._length-1;n>=e;n--)this._array[this._getCyclicIndex(n+r.length)]=this._array[this._getCyclicIndex(n)];for(let n=0;n<r.length;n++)this._array[this._getCyclicIndex(e+n)]=r[n];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let n=this._length+r.length-this._maxLength;this._startIndex+=n,this._length=this._maxLength,this.onTrimEmitter.fire(n)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,s,r){if(!(s<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let a=s-1;a>=0;a--)this.set(e+a+r,this.get(e+a));let n=e+s+r-this._length;if(n>0)for(this._length+=n;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let n=0;n<s;n++)this.set(e+n+r,this.get(e+n))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Kn=3,jl=Object.freeze(new wN),K1=0,l5=2,Qw=class aoe{constructor(s,r,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(s*Kn);let a=r||Im.fromCharData([0,Sie,1,0]);for(let i=0;i<s;++i)this.setCell(i,a);this.length=s}get(s){let r=this._data[s*Kn+0],n=r&2097151;return[this._data[s*Kn+1],r&2097152?this._combined[s]:n?lg(n):"",r>>
57022,r&2097152?this._combined[s].charCodeAt(this._combined[s].length-1):n]}set(s,r){this._data[s*Kn+1]=r[0],r[1].length>1?(this._combined[s]=r[1],this._data[s*Kn+0]=s|2097152|r[2]<<22):this._data[s*Kn+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(s){return this._data[s*Kn+0]>>22}hasWidth(s){return this._data[s*Kn+0]&12582912}getFg(s){return this._data[s*Kn+1]}getBg(s){return this._data[s*Kn+2]}hasContent(s){return this._data[s*Kn+0]&4194303}getCodePoint(s){let r=this._data[s*Kn+0];return r&2097152?this._combined[s].charCodeAt(this._combined[s].length-1):r&2097151}isCombined(s){return this._data[s*Kn+0]&2097152}getString(s){let r=this._data[s*Kn+0];return r&2097152?this._combined[s]:r&2097151?lg(r&2097151):""}isProtected(s){return this._data[s*Kn+2]&536870912}loadCell(s,r){return K1=s*Kn,r.content=this._data[K1+0],r.fg=this._data[K1+1],r.bg=this._data[K1+2],r.content&2097152&&(r.combinedData=this._combined[s]),r.bg&268435456&&(r.extended=this._extendedAttrs[s]),r}setCell(s,r){r.content&2097152&&(this._combined[s]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[s]=r.extended),this._data[s*Kn+0]=r.content,this._data[s*Kn+1]=r.fg,this._data[s*Kn+2]=r.bg}setCellFromCodepoint(s,r,n,a){a.bg&268435456&&(this._extendedAttrs[s]=a.extended),this._data[s*Kn+0]=r|n<<22,this._data[s*Kn+1]=a.fg,this._data[s*Kn+2]=a.bg}addCodepointToCell(s,r,n){let a=this._data[s*Kn+0];a&2097152?this._combined[s]+=lg(r):a&2097151?(this._combined[s]=lg(a&2097151)+lg(r),a&=-2097152,a|=2097152):a=r|1<<22,n&&(a&=-12582913,a|=n<<22),this._data[s*Kn+0]=a}insertCells(s,r,n){if(s%=this.length,s&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s-1,0,1,n),r<this.length-s){let a=new Im;for(let i=this.length-s-r-1;i>=0;--i)this.setCell(s+r+i,this.loadCell(s+i,a));for(let i=0;i<r;++i)this.setCell(s+i,n)}else for(let a=s;a<this.length;++a)this.setCell(a,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(s,r,n){if(s%=this.length,r<this.length-s){let a=new Im;for(let i=0;i<this.length-s-r;++i)this.setCell(s+i,this.loadCell(s+r+i,a));for(let i=this.length-r;i<this.length;++i)this.setCell(i,n)}else for(let a=s;a<this.length;++a)this.setCell(a,n);s&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s-1,0,1,n),this.getWidth(s)===0&&!this.hasContent(s)&&this.setCellFromCodepoint(s,0,1,n)}replaceCells(s,r,n,a=!1){if(a){for(s&&this.getWidth(s-1)===2&&!this.isProtected(s-1)&&this.setCellFromCodepoint(s-1,0,1,n),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,n);s<r&&s<this.length;)this.isProtected(s)||this.setCell(s,n),s++;return}for(s&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s-1,0,1,n),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,n);s<r&&s<this.length;)this.setCell(s++,n)}resize(s,r){if(s===this.length)return this._data.length*4*l5<this._data.buffer.byteLength;let n=s*Kn;if(s>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let a=new Uint32Array(n);a.set(this._data),this._data=a}for(let a=this.length;a<s;++a)this.setCell(a,r)}else{this._data=this._data.subarray(0,n);let a=Object.keys(this._combined);for(let o=0;o<a.length;o++){let l=parseInt(a[o],10);l>=s&&delete this._combined[l]}let i=Object.keys(this._extendedAttrs);for(let o=0;o<i.length;o++){let l=parseInt(i[o],10);l>=s&&delete this._extendedAttrs[l]}}return this.length=s,n*4*l5<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*l5<this._data.buffer.byteLength){let s=new Uint32Array(this._data.length);return s.set(this._data),this._data=s,1}return 0}fill(s,r=!1){if(r){for(let n=0;n<this.length;++n)this.isProtected(n)||this.setCell(n,s);return}this._combined={},this._extendedAttrs={};for(let n=0;n<this.length;++n)this.setCell(n,s)}copyFrom(s){this.length!==s.length?this._data=new Uint32Array(s._data):this._data.set(s._data),this.length=s.length,this._combined={};for(let r in s._combined)this._combined[r]=s._combined[r];this._extendedAttrs={};for(let r in s._extendedAttrs)this._extendedAttrs[r]=s._extendedAttrs[r];this.isWrapped=s.isWrapped}clone(){let s=new aoe(0);s._data=new Uint32Array(this._data),s.length=this.length;for(let r in this._combined)s._combined[r]=this._combined[r];for(let r in this._extendedAttrs)s._extendedAttrs[r]=this._extendedAttrs[r];return s.isWrapped=this.isWrapped,s}getTrimmedLength(){for(let s=this.length-1;s>=0;--s)if(this._data[s*Kn+0]&4194303)return s+(this._data[s*Kn+0]>>22);return 0}getNoBgTrimmedLength(){for(let s=this.length-1;s>=0;--s)if(this._data[s*Kn+0]&4194303||this._data[s*Kn+2]&50331648)return s+(this._data[s*Kn+0]>>22);return 0}copyCellsFrom(s,r,n,a,i){let o=s._data;if(i)for(let c=a-1;c>=0;c--){for(let d=0;d<Kn;d++)this._data[(n+c)*Kn+d]=o[(r+c)*Kn+d];o[(r+c)*Kn+2]&268435456&&(this._extendedAttrs[n+c]=s._extendedAttrs[r+c])}else for(let c=0;c<a;c++){for(let d=0;d<Kn;d++)this._data[(n+c)*Kn+d]=o[(r+c)*Kn+d];o[(r+c)*Kn+2]&268435456&&(this._extendedAttrs[n+c]=s._extendedAttrs[r+c])}let l=Object.keys(s._combined);for(let c=0;c<l.length;c++){let d=parseInt(l[c],10);d>=r&&(this._combined[d-r+n]=s._combined[d])}}translateToString(s,r,n,a){r=r??0,n=n??this.length,s&&(n=Math.min(n,this.getTrimmedLength())),a&&(a.length=0);let i="";for(;r<n;){let o=this._data[r*Kn+0],l=o&2097151,c=o&2097152?this._combined[r]:l?lg(l):vg;if(i+=c,a)for(let d=0;d<c.length;++d)a.push(r);r+=o>>22||1}return a&&a.push(r),i}};function Rqe(e,s,r,n,a,i){let o=[];for(let l=0;l<e.length-1;l++){let c=l,d=e.get(++c);if(!d.isWrapped)continue;let h=[e.get(l)];for(;c<e.length&&d.isWrapped;)h.push(d),d=e.get(++c);if(!i&&n>=l&&n<c){l+=h.length-1;continue}let p=0,g=Fj(h,p,s),v=1,b=0;for(;v<h.length;){let w=Fj(h,v,s),j=w-b,x=r-g,C=Math.min(j,x);h[p].copyCellsFrom(h[v],b,g,C,!1),g+=C,g===r&&(p++,g=0),b+=C,b===w&&(v++,b=0),g===0&&p!==0&&h[p-1].getWidth(r-1)===2&&(h[p].copyCellsFrom(h[p-1],r-1,g++,1,!1),h[p-1].setCell(r-1,a))}h[p].replaceCells(g,r,a);let y=0;for(let w=h.length-1;w>0&&(w>p||h[w].getTrimmedLength()===0);w--)y++;y>0&&(o.push(l+h.length-y),o.push(y)),l+=h.length-1}return o}function Iqe(e,s){let r=[],n=0,a=s[n],i=0;for(let o=0;o<e.length;o++)if(a===o){let l=s[++n];
570e.onDeleteEmitter.fire({index:o-i,amount:l}),o+=l-1,i+=l,a=s[++n]}else r.push(o);return{layout:r,countRemoved:i}}function Oqe(e,s){let r=[];for(let n=0;n<s.length;n++)r.push(e.get(s[n]));for(let n=0;n<r.length;n++)e.set(n,r[n]);e.length=s.length}function Dqe(e,s,r){let n=[],a=e.map((c,d)=>Fj(e,d,s)).reduce((c,d)=>c+d),i=0,o=0,l=0;for(;l<a;){if(a-l<r){n.push(a-l);break}i+=r;let c=Fj(e,o,s);i>c&&(i-=c,o++);let d=e[o].getWidth(i-1)===2;d&&i--;let h=d?r-1:r;n.push(h),l+=h}return n}function Fj(e,s,r){if(s===e.length-1)return e[s].getTrimmedLength();let n=!e[s].hasContent(r-1)&&e[s].getWidth(r-1)===1,a=e[s+1].getWidth(0)===2;return n&&a?r-1:r}var ioe=class ooe{constructor(s){this.line=s,this.isDisposed=!1,this._disposables=[],this._id=ooe._nextId++,this._onDispose=this.register(new Ps),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),iv(this._disposables),this._disposables.length=0)}register(s){return this._disposables.push(s),s}};ioe._nextId=1;var Lqe=ioe,Yl={},Nx=Yl.B;Yl[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Yl.A={"#":"£"};Yl.B=void 0;Yl[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Yl.C=Yl[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Yl.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Yl.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Yl.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Yl.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Yl.E=Yl[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Yl.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Yl.H=Yl[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Yl["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var X9=4294967295,Z9=class{constructor(e,s,r){this._hasScrollback=e,this._optionsService=s,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=jl.clone(),this.savedCharset=Nx,this.markers=[],this._nullCell=Im.fromCharData([0,Sie,1,0]),this._whitespaceCell=Im.fromCharData([0,vg,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new kk,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Q9(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new jk),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new jk),this._whitespaceCell}getBlankLine(e,s){return new Qw(this._bufferService.cols,this.getNullCell(e),s)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let s=e+this._optionsService.rawOptions.scrollback;return s>X9?X9:s}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=jl);let s=this._rows;for(;s--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Q9(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}
570resize(e,s){let r=this.getNullCell(jl),n=0,a=this._getCorrectBufferLength(s);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)n+=+this.lines.get(o).resize(e,r);let i=0;if(this._rows<s)for(let o=this._rows;o<s;o++)this.lines.length<s+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new Qw(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+i+1?(this.ybase--,i++,this.ydisp>0&&this.ydisp--):this.lines.push(new Qw(e,r)));else for(let o=this._rows;o>s;o--)this.lines.length>s+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a<this.lines.maxLength){let o=this.lines.length-a;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,s-1),i&&(this.y+=i),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=s-1,this._isReflowEnabled&&(this._reflow(e,s),this._cols>e))for(let i=0;i<this.lines.length;i++)n+=+this.lines.get(i).resize(e,r);this._cols=e,this._rows=s,this._memoryCleanupQueue.clear(),n>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let s=0;for(;this._memoryCleanupPosition<this.lines.length;)if(s+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),s>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,s){this._cols!==e&&(e>this._cols?this._reflowLarger(e,s):this._reflowSmaller(e,s))}_reflowLarger(e,s){let r=this._optionsService.rawOptions.reflowCursorLine,n=Rqe(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(jl),r);if(n.length>0){let a=Iqe(this.lines,n);Oqe(this.lines,a.layout),this._reflowLargerAdjustViewport(e,s,a.countRemoved)}}_reflowLargerAdjustViewport(e,s,r){let n=this.getNullCell(jl),a=r;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<s&&this.lines.push(new Qw(e,n))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,s){let r=this._optionsService.rawOptions.reflowCursorLine,n=this.getNullCell(jl),a=[],i=0;for(let o=this.lines.length-1;o>=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let c=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),c.unshift(l);if(!r){let C=this.ybase+this.y;if(C>=o&&C<o+c.length)continue}let d=c[c.length-1].getTrimmedLength(),h=Dqe(c,this._cols,e),p=h.length-c.length,g;this.ybase===0&&this.y!==this.lines.length-1?g=Math.max(0,this.y-this.lines.maxLength+p):g=Math.max(0,this.lines.length-this.lines.maxLength+p);let v=[];for(let C=0;C<p;C++){let k=this.getBlankLine(jl,!0);v.push(k)}v.length>0&&(a.push({start:o+c.length+i,newLines:v}),i+=v.length),c.push(...v);let b=h.length-1,y=h[b];y===0&&(b--,y=h[b]);let w=c.length-p-1,j=d;for(;w>=0;){let C=Math.min(j,y);if(c[b]===void 0)break;if(c[b].copyCellsFrom(c[w],j-C,y-C,C,!0),y-=C,y===0&&(b--,y=h[b]),j-=C,j===0){w--;let k=Math.max(w,0);j=Fj(c,k,this._cols)}}for(let C=0;C<c.length;C++)h[C]<e&&c[C].setCell(h[C],n);let x=p-g;for(;x-- >0;)this.ybase===0?this.y<s-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+i)-s&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+p,this.ybase+s-1)}if(a.length>0){let o=[],l=[];for(let y=0;y<this.lines.length;y++)l.push(this.lines.get(y));let c=this.lines.length,d=c-1,h=0,p=a[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+i);let g=0;for(let y=Math.min(this.lines.maxLength-1,c+i-1);y>=0;y--)if(p&&p.start>d+g){for(let w=p.newLines.length-1;w>=0;w--)this.lines.set(y--,p.newLines[w]);y++,o.push({index:d+1,amount:p.newLines.length}),g+=p.newLines.length,p=a[++h]}else this.lines.set(y,l[d--]);let v=0;for(let y=o.length-1;y>=0;
570y--)o[y].index+=v,this.lines.onInsertEmitter.fire(o[y]),v+=o[y].amount;let b=Math.max(0,c+i-this.lines.maxLength);b>0&&this.lines.onTrimEmitter.fire(b)}}translateBufferLineToString(e,s,r=0,n){let a=this.lines.get(e);return a?a.translateToString(s,r,n):""}getWrappedRangeForLine(e){let s=e,r=e;for(;s>0&&this.lines.get(s).isWrapped;)s--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:s,last:r}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let s=0;s<this.markers.length;s++)this.markers[s].line===e&&(this.markers[s].dispose(),this.markers.splice(s--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}
570addMarker(e){let s=new Lqe(e);return this.markers.push(s),s.register(this.lines.onTrim(r=>{s.line-=r,s.line<0&&s.dispose()})),s.register(this.lines.onInsert(r=>{s.line>=r.index&&(s.line+=r.amount)})),s.register(this.lines.onDelete(r=>{s.line>=r.index&&s.line<r.index+r.amount&&s.dispose(),s.line>r.index&&(s.line-=r.amount)})),s.register(s.onDispose(()=>this._removeMarker(s))),s}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},$qe=class extends Yn{constructor(e,s){super(),this._optionsService=e,this._bufferService=s,this._onBufferActivate=this._register(new Ps),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Z9(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Z9(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,s){this._normal.resize(e,s),this._alt.resize(e,s),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},loe=2,coe=1,TI=class extends Yn{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Ps),this.onResize=this._onResize.event,this._onScroll=this._register(new Ps),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,loe),this.rows=Math.max(e.rawOptions.rows||0,coe),this.buffers=this._register(new $qe(e,this)),this._register(this.buffers.onBufferActivate(s=>{this._onScroll.fire(s.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,s){let r=this.cols!==e,n=this.rows!==s;this.cols=e,this.rows=s,this.buffers.resize(e,s),this._onResize.fire({cols:e,rows:s,colsChanged:r,rowsChanged:n})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,s=!1){let r=this.buffer,n;n=this._cachedBlankLine,(!n||n.length!==this.cols||n.getFg(0)!==e.fg||n.getBg(0)!==e.bg)&&(n=r.getBlankLine(e,s),this._cachedBlankLine=n),n.isWrapped=s;let a=r.ybase+r.scrollTop,i=r.ybase+r.scrollBottom;if(r.scrollTop===0){let o=r.lines.isFull;i===r.lines.length-1?o?r.lines.recycle().copyFrom(n):r.lines.push(n.clone()):r.lines.splice(i+1,0,n.clone()),o?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let o=i-a+1;r.lines.shiftElements(a+1,o-1,-1),r.lines.set(i,n.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,s){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let n=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),n!==r.ydisp&&(s||this._onScroll.fire(r.ydisp))}};TI=Bo([Js(0,eu)],TI);var Wv={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Ck,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Fqe=["normal","bold","100","200","300","400","500","600","700","800","900"],Bqe=class extends Yn{constructor(e){super(),this._onOptionChange=this._register(new Ps),this.onOptionChange=this._onOptionChange.event;let s={...Wv};for(let r in e)if(r in s)try{let n=e[r];s[r]=this._sanitizeAndValidateOption(r,n)}catch(n){console.error(n)}this.rawOptions=s,this.options={...s},this._setupOptions(),this._register(io(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,s){return this.onOptionChange(r=>{r===e&&s(this.rawOptions[e])})}onMultipleOptionChange(e,s){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&s()})}_setupOptions(){let e=r=>{if(!(r in Wv))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},s=(r,n)=>{if(!(r in Wv))throw new Error(`No option with key "${r}"`);n=this._sanitizeAndValidateOption(r,n),this.rawOptions[r]!==n&&(this.rawOptions[r]=n,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let n={get:e.bind(this,r),set:s.bind(this,r)};Object.defineProperty(this.options,r,n)}}_sanitizeAndValidateOption(e,s){switch(e){case"cursorStyle":if(s||(s=Wv[e]),!Uqe(s))throw new Error(`"${s}" is not a valid value for ${e}`);break;case"wordSeparator":s||(s=Wv[e]);break;case"fontWeight":case"fontWeightBold":if(typeof s=="number"&&1<=s&&s<=1e3)break;s=Fqe.includes(s)?s:Wv[e];break;case"cursorWidth":s=Math.floor(s);case"lineHeight":case"tabStopWidth":if(s<1)throw new Error(`${e} cannot be less than 1, value: ${s}`);break;case"minimumContrastRatio":s=Math.max(1,Math.min(21,Math.round(s*10)/10));break;case"scrollback":if(s=Math.min(s,4294967295),s<0)throw new Error(`${e} cannot be less than 0, value: ${s}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(s<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${s}`);break;case"rows":case"cols":if(!s&&s!==0)throw new Error(`${e} must be numeric, value: ${s}`);break;case"windowsPty":s=s??{};break}return s}};function Uqe(e){return e==="block"||e==="underline"||e==="bar"}function Xw(e,s=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let n in e)r[n]=s<=1?e[n]:e[n]&&Xw(e[n],s-1);return r}var J9=Object.freeze({insertMode:!1}),eV=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),AI=class extends Yn{constructor(e,s,r){super(),this._bufferService=e,this._logService=s,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Ps),this.onData=this._onData.event,this._onUserInput=this._register(new Ps),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Ps),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Ps),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Xw(J9),this.decPrivateModes=Xw(eV)}reset(){this.modes=Xw(J9),this.decPrivateModes=Xw(eV)}triggerDataEvent(e,s=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;s&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.f
570ire(),s&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(n=>n.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onBinary.fire(e))}};AI=Bo([Js(0,Jd),Js(1,Eie),Js(2,eu)],AI);var tV={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function c5(e,s){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!s&&(r|=3)),r}var d5=String.fromCharCode,sV={DEFAULT:e=>{let s=[c5(e,!1)+32,e.col+32,e.row+32];return s[0]>255||s[1]>255||s[2]>255?"":`\x1B[M${d5(s[0])}${d5(s[1])}${d5(s[2])}`},SGR:e=>{let s=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${c5(e,!0)};${e.col};${e.row}${s}`},SGR_PIXELS:e=>{let s=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${c5(e,!0)};${e.x};${e.y}${s}`}},MI=class extends Yn{constructor(e,s,r){super(),this._bufferService=e,this._coreService=s,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Ps),this.onProtocolChange=this._onProtocolChange.event;for(let n of Object.keys(tV))this.addProtocol(n,tV[n]);for(let n of Object.keys(sV))this.addEncoding(n,sV[n]);this.reset()}addProtocol(e,s){this._protocols[e]=s}addEncoding(e,s){this._encodings[e]=s}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,s,r){if(e.deltaY===0||e.shiftKey||s===void 0||r===void 0)return 0;let n=s/r,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=n+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,s){return s.altKey||s.ctrlKey||s.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let s=this._encodings[this._activeEncoding](e);return s&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(s):this._coreService.triggerDataEvent(s,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,s,r){if(r){if(e.x!==s.x||e.y!==s.y)return!1}else if(e.col!==s.col||e.row!==s.row)return!1;return!(e.button!==s.button||e.action!==s.action||e.ctrl!==s.ctrl||e.alt!==s.alt||e.shift!==s.shift)}};MI=Bo([Js(0,Jd),Js(1,vv),Js(2,eu)],MI);var u5=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3
570021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],zqe=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Bl;function Hqe(e,s){let r=0,n=s.length-1,a;if(e<s[0][0]||e>s[n][1])return!1;for(;n>=r;)if(a=r+n>>1,e>s[a][1])r=a+1;else if(e<s[a][0])n=a-1;else return!0;return!1}var qqe=class{constructor(){if(this.version="6",!Bl){Bl=new Uint8Array(65536),Bl.fill(1),Bl[0]=0,Bl.fill(0,1,32),Bl.fill(0,127,160),Bl.fill(2,4352,4448),Bl[9001]=2,Bl[9002]=2,Bl.fill(2,11904,42192),Bl[12351]=1,Bl.fill(2,44032,55204),Bl.fill(2,63744,64256),Bl.fill(2,65040,65050),Bl.fill(2,65072,65136),Bl.fill(2,65280,65377),Bl.fill(2,65504,65511);for(let e=0;e<u5.length;++e)Bl.fill(0,u5[e][0],u5[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Bl[e]:Hqe(e,zqe)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,s){let r=this.wcwidth(e),n=r===0&&s!==0;if(n){let a=Mx.extractWidth(s);a===0?n=!1:a>r&&(r=a)}return Mx.createPropertyValue(0,r,n)}},Mx=class jS{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Ps,this.onChange=this._onChange.event;let s=new qqe;this.register(s),this._active=s.version,this._activeProvider=s}static extractShouldJoin(s){return(s&1)!==0}static extractWidth(s){return s>>1&3}static extractCharKind(s){return s>>3}static createPropertyValue(s,r,n=!1){return(s&16777215)<<3|(r&3)<<1|(n?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(s){if(!this._providers[s])throw new Error(`unknown Unicode version "${s}"`);this._active=s,this._activeProvider=this._providers[s],this._onChange.fire(s)}register(s){this._providers[s.version]=s}wcwidth(s){return this._activeProvider.wcwidth(s)}getStringCellWidth(s){let r=0,n=0,a=s.length;for(let i=0;i<a;++i){let o=s.charCodeAt(i);if(55296<=o&&o<=56319){if(++i>=a)return r+this.wcwidth(o);let d=s.charCodeAt(i);56320<=d&&d<=57343?o=(o-55296)*1024+d-56320+65536:r+=this.wcwidth(d)}let l=this.charProperties(o,n),c=jS.extractWidth(l);jS.extractShouldJoin(l)&&(c-=jS.extractWidth(n)),r+=c,n=l}return r}charProperties(s,r){return this._activeProvider.charProperties(s,r)}},Vqe=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,s){this._charsets[e]=s,this.glevel===e&&(this.charset=s)}};function rV(e){let s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&s&&(r.isWrapped=s[3]!==0&&s[3]!==32)}var Iw=2147483647,Wqe=256,doe=class RI{constructor(s=32,r=32){if(this.maxLength=s,this.maxSubParamsLength=r,r>Wqe)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(s),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(s),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(s){let r=new RI;if(!s.length)return r;for(let n=Array.isArray(s[0])?1:0;n<s.length;++n){let a=s[n];if(Array.isArray(a))for(let i=0;i<a.length;++i)r.addSubParam(a[i]);else r.addParam(a)}return r}clone(){let s=new RI(this.maxLength,this.maxSubParamsLength);return s.params.set(this.params),s.length=this.length,s._subParams.set(this._subParams),s._subParamsLength=this._subParamsLength,s._subParamsIdx.set(this._subParamsIdx),s._rejectDigits=this._rejectDigits,s._rejectSubDigits=this._rejectSubDigits,s._digitIsSub=this._digitIsSub,s}toArray(){let s=[];for(let r=0;r<this.length;++r){s.push(this.params[r]);let n=this._subParamsIdx[r]>>8,a=this._subParamsIdx[r]&255;a-n>0&&s.push(Array.prototype.slice.call(this._subParams,n,a))}return s}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(s){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(s<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=s>Iw?Iw:s}addSubParam(s){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(s<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=s>Iw?Iw:s,this._subParamsIdx[this.length-1]++}}hasSubParams(s){return(this._subParamsIdx[s]&255)-(this._subParamsIdx[s]>>8)>0}getSubParams(s){let r=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;return n-r>0?this._subParams.subarray(r,n):null}getSubParamsAll(){let s={};for(let r=0;r<this.length;++r){let n=this._subParamsIdx[r]>>8,a=this._subParamsIdx[r]&255;a-n>0&&(s[r]=this._subParams.slice(n,a))}return s}addDigit(s){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,a=n[r-1];n[r-1]=~a?Math.min(a*10+s,Iw):s}},Ow=[],Kqe=class{constructor(){this._state=0,this._active=Ow,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,s){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(s),{dispose:()=>{let n=r.indexOf(s);n!==-1&&r.splice(n,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ow}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Ow,this._id=-1,this._state=0}
570_start(){if(this._active=this._handlers[this._id]||Ow,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,s,r){if(!this._active.length)this._handlerFb(this._id,"PUT",d2(e,s,r));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,s,r)}start(){this.reset(),this._state=1}put(e,s,r){if(this._state!==3){if(this._state===1)for(;s<r;){let n=e[s++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&r-s>0&&this._put(e,s,r)}}end(e,s=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let r=!1,n=this._active.length-1,a=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,r=s,a=this._stack.fallThrough,this._stack.paused=!1),!a&&r===!1){for(;n>=0&&(r=this._active[n].end(e),r!==!0);n--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,r;n--}for(;n>=0;n--)if(r=this._active[n].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,r}this._active=Ow,this._id=-1,this._state=0}}},Uu=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,s,r){this._hitLimit||(this._data+=d2(e,s,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let s=!1;if(this._hitLimit)s=!1;else if(e&&(s=this._handler(this._data),s instanceof Promise))return s.then(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,s}},Dw=[],Gqe=class{constructor(){this._handlers=Object.create(null),this._active=Dw,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Dw}registerHandler(e,s){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(s),{dispose:()=>{let n=r.indexOf(s);n!==-1&&r.splice(n,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Dw,this._ident=0}hook(e,s){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Dw,!this._active.length)this._handlerFb(this._ident,"HOOK",s);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(s)}put(e,s,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",d2(e,s,r));else for(let n=this._active.length-1;n>=0;n--)this._active[n].put(e,s,r)}unhook(e,s=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,n=this._active.length-1,a=!1;if(this._stack.paused&&(n=this._stack.loopPosition-1,r=s,a=this._stack.fallThrough,this._stack.paused=!1),!a&&r===!1){for(;n>=0&&(r=this._active[n].unhook(e),r!==!0);n--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!1,r;n--}for(;n>=0;n--)if(r=this._active[n].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=n,this._stack.fallThrough=!0,r}this._active=Dw,this._ident=0}},Zw=new doe;Zw.addParam(0);var nV=class{constructor(e){this._handler=e,this._data="",this._params=Zw,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Zw,this._data="",this._hitLimit=!1}put(e,s,r){this._hitLimit||(this._data+=d2(e,s,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let s=!1;if(this._hitLimit)s=!1;else if(e&&(s=this._handler(this._data,this._params),s instanceof Promise))return s.then(r=>(this._params=Zw,this._data="",this._hitLimit=!1,r));return this._params=Zw,this._data="",this._hitLimit=!1,s}},Yqe=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,s){this.table.fill(e<<4|s)}add(e,s,r,n){this.table[s<<8|e]=r<<4|n}addMany(e,s,r,n){for(let a=0;a<e.length;a++)this.table[s<<8|e[a]]=r<<4|n}},Cm=160,Qqe=(function(){let e=new Yqe(4095),s=Array.apply(null,Array(256)).map((l,c)=>c),r=(l,c)=>s.slice(l,c),n=r(32,127),a=r(0,24);a.push(25),a.push.apply(a,r(28,32));let i=r(0,14),o;e.setDefault(1,0),e.addMany(n,0,2,0);for(o in i)e.addMany([24,26,153,154],o,3,0),e.addMany(r(128,144),o,3,0),e.addMany(r(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(n,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(n,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(n,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Cm,0,2,0),e.add(Cm,8,5,8),e.add(Cm,6,0,6),e.add(Cm,11,0,11),e.add(Cm,13,13,13),e})(),Xqe=class extends Yn{constructor(e=Qqe){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,
570chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new doe,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(s,r,n)=>{},this._executeHandlerFb=s=>{},this._csiHandlerFb=(s,r)=>{},this._escHandlerFb=s=>{},this._errorHandlerFb=s=>s,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(io(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Kqe),this._dcsParser=this._register(new Gqe),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,s=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;a<e.intermediates.length;++a){let i=e.intermediates.charCodeAt(a);if(32>i||i>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=i}}if(e.final.length!==1)throw new Error("final must be a single byte");let n=e.final.charCodeAt(0);if(s[0]>n||n>s[1])throw new Error(`final must be in range ${s[0]} .. ${s[1]}`);return r<<=8,r|=n,r}identToString(e){let s=[];for(;e;)s.push(String.fromCharCode(e&255)),e>>=8;return s.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,s){let r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let n=this._escHandlers[r];return n.push(s),{dispose:()=>{let a=n.indexOf(s);a!==-1&&n.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,s){this._executeHandlers[e.charCodeAt(0)]=s}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,s){let r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let n=this._csiHandlers[r];return n.push(s),{dispose:()=>{let a=n.indexOf(s);a!==-1&&n.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,s){return this._dcsParser.registerHandler(this._identifier(e),s)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,s){return this._oscParser.registerHandler(e,s)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,s,r,n,a){this._parseStack.state=e,this._parseStack.handlers=s,this._parseStack.handlerPos=r,this._parseStack.transition=n,this._parseStack.chunkPos=a}parse(e,s,r){let n=0,a=0,i=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,i=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&c>-1){for(;c>=0&&(o=l[c](this._params),o!==!0);c--)if(o instanceof Promise)return this._parseStack.handlerPos=c,o}this._parseStack.handlers=[];break;case 4:if(r===!1&&c>-1){for(;c>=0&&(o=l[c](),o!==!0);c--)if(o instanceof Promise)return this._parseStack.handlerPos=c,o}this._parseStack.handlers=[];break;case 6:if(n=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(n!==24&&n!==26,r),o)return o;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(n=e[this._parseStack.chunkPos],o=this._oscParser.end(n!==24&&n!==26,r),o)return o;n===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,i=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=i;l<s;++l){switch(n=e[l],a=this._transitions.table[this.currentState<<8|(n<160?n:Cm)],a>>4){case 2:for(let g=l+1;;++g){if(g>=s||(n=e[g])<32||n>126&&n<Cm){this._printHandler(e,l,g),l=g-1;break}if(++g>=s||(n=e[g])<32||n>126&&n<Cm){this._printHandler(e,l,g),l=g-1;break}if(++g>=s||(n=e[g])<32||n>126&&n<Cm){this._printHandler(e,l,g),l=g-1;break}if(++g>=s||(n=e[g])<32||n>126&&n<Cm){this._printHandler(e,l,g),l=g-1;break}}break;case 3:this._executeHandlers[n]?this._executeHandlers[n]():this._executeHandlerFb(n),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:n,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|n],d=c?c.length-1:-1;for(;d>=0&&(o=c[d](this._params),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(3,c,d,a,l),o;d<0&&this._csiHandlerFb(this._collect<<8|n,this._params),this.precedingJoinState=0;break;case 8:do switch(n){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;
570default:this._params.addDigit(n-48)}while(++l<s&&(n=e[l])>47&&n<60);l--;break;case 9:this._collect<<=8,this._collect|=n;break;case 10:let h=this._escHandlers[this._collect<<8|n],p=h?h.length-1:-1;for(;p>=0&&(o=h[p](),o!==!0);p--)if(o instanceof Promise)return this._preserveStack(4,h,p,a,l),o;p<0&&this._escHandlerFb(this._collect<<8|n),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|n,this._params);break;case 13:for(let g=l+1;;++g)if(g>=s||(n=e[g])===24||n===26||n===27||n>127&&n<Cm){this._dcsParser.put(e,l,g),l=g-1;break}break;case 14:if(o=this._dcsParser.unhook(n!==24&&n!==26),o)return this._preserveStack(6,[],0,a,l),o;n===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let g=l+1;;g++)if(g>=s||(n=e[g])<32||n>127&&n<Cm){this._oscParser.put(e,l,g),l=g-1;break}break;case 6:if(o=this._oscParser.end(n!==24&&n!==26),o)return this._preserveStack(5,[],0,a,l),o;n===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=a&15}}},Zqe=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,Jqe=/^[\da-f]+$/;function aV(e){if(!e)return;let s=e.toLowerCase();if(s.indexOf("rgb:")===0){s=s.slice(4);let r=Zqe.exec(s);if(r){let n=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/n*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/n*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/n*255)]}}else if(s.indexOf("#")===0&&(s=s.slice(1),Jqe.exec(s)&&[3,6,9,12].includes(s.length))){let r=s.length/3,n=[0,0,0];for(let a=0;a<3;++a){let i=parseInt(s.slice(r*a,r*a+r),16);n[a]=r===1?i<<4:r===2?i:r===3?i>>4:i>>8}return n}}function m5(e,s){let r=e.toString(16),n=r.length<2?"0"+r:r;switch(s){case 4:return r[0];case 8:return n;case 12:return(n+n).slice(0,3);default:return n+n}}function e9e(e,s=16){let[r,n,a]=e;return`rgb:${m5(r,s)}/${m5(n,s)}/${m5(a,s)}`}var t9e={"(":0,")":1,"*":2,"+":3,"-":1,".":2},eg=131072,iV=10;function oV(e,s){if(e>24)return s.setWinLines||!1;switch(e){case 1:return!!s.restoreWin;case 2:return!!s.minimizeWin;case 3:return!!s.setWinPosition;case 4:return!!s.setWinSizePixels;case 5:return!!s.raiseWin;case 6:return!!s.lowerWin;case 7:return!!s.refreshWin;case 8:return!!s.setWinSizeChars;case 9:return!!s.maximizeWin;case 10:return!!s.fullscreenWin;case 11:return!!s.getWinState;case 13:return!!s.getWinPosition;case 14:return!!s.getWinSizePixels;case 15:return!!s.getScreenSizePixels;case 16:return!!s.getCellSizePixels;case 18:return!!s.getWinSizeChars;case 19:return!!s.getScreenSizeChars;case 20:return!!s.getIconTitle;case 21:return!!s.getWinTitle;case 22:return!!s.pushTitle;case 23:return!!s.popTitle;case 24:return!!s.setWinLines}return!1}var lV=5e3,cV=0,s9e=class extends Yn{constructor(e,s,r,n,a,i,o,l,c=new Xqe){super(),this._bufferService=e,this._charsetService=s,this._coreService=r,this._logService=n,this._optionsService=a,this._oscLinkService=i,this._coreMouseService=o,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new wHe,this._utf8Decoder=new jHe,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=jl.clone(),this._eraseAttrDataInternal=jl.clone(),this._onRequestBell=this._register(new Ps),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Ps),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Ps),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Ps),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Ps),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Ps),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Ps),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Ps),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Ps),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Ps),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Ps),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Ps),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Ps),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new II(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(d=>
vendor: 4,087 bytes, line 570
570this._activeBuffer=d.activeBuffer)),this._parser.setCsiHandlerFallback((d,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(d),params:h.toArray()})}),this._parser.setEscHandlerFallback(d=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(d)})}),this._parser.setExecuteHandlerFallback(d=>{this._logService.debug("Unknown EXECUTE code: ",{code:d})}),this._parser.setOscHandlerFallback((d,h,p)=>{this._logService.debug("Unknown OSC code: ",{identifier:d,action:h,data:p})}),this._parser.setDcsHandlerFallback((d,h,p)=>{h==="HOOK"&&(p=p.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(d),action:h,payload:p})}),this._parser.setPrintHandler((d,h,p)=>this.print(d,h,p)),this._parser.registerCsiHandler({final:"@"},d=>this.insertChars(d)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},d=>this.scrollLeft(d)),this._parser.registerCsiHandler({final:"A"},d=>this.cursorUp(d)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},d=>this.scrollRight(d)),this._parser.registerCsiHandler({final:"B"},d=>this.cursorDown(d)),this._parser.registerCsiHandler({final:"C"},d=>this.cursorForward(d)),this._parser.registerCsiHandler({final:"D"},d=>this.cursorBackward(d)),this._parser.registerCsiHandler({final:"E"},d=>this.cursorNextLine(d)),this._parser.registerCsiHandler({final:"F"},d=>this.cursorPrecedingLine(d)),this._parser.registerCsiHandler({final:"G"},d=>this.cursorCharAbsolute(d)),this._parser.registerCsiHandler({final:"H"},d=>this.cursorPosition(d)),this._parser.registerCsiHandler({final:"I"},d=>this.cursorForwardTab(d)),this._parser.registerCsiHandler({final:"J"},d=>this.eraseInDisplay(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},d=>this.eraseInDisplay(d,!0)),this._parser.registerCsiHandler({final:"K"},d=>this.eraseInLine(d,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},d=>this.eraseInLine(d,!0)),this._parser.registerCsiHandler({final:"L"},d=>this.insertLines(d)),this._parser.registerCsiHandler({final:"M"},d=>this.deleteLines(d)),this._parser.registerCsiHandler({final:"P"},d=>this.deleteChars(d)),this._parser.registerCsiHandler({final:"S"},d=>this.scrollUp(d)),this._parser.registerCsiHandler({final:"T"},d=>this.scrollDown(d)),this._parser.registerCsiHandler({final:"X"},d=>this.eraseChars(d)),this._parser.registerCsiHandler({final:"Z"},d=>this.cursorBackwardTab(d)),this._parser.registerCsiHandler({final:"`"},d=>this.charPosAbsolute(d)),this._parser.registerCsiHandler({final:"a"},d=>this.hPositionRelative(d)),this._parser.registerCsiHandler({final:"b"},d=>this.repeatPrecedingCharacter(d)),this._parser.registerCsiHandler({final:"c"},d=>this.sendDeviceAttributesPrimary(d)),this._parser.registerCsiHandler({prefix:">",final:"c"},d=>this.sendDeviceAttributesSecondary(d)),this._parser.registerCsiHandler({final:"d"},d=>this.linePosAbsolute(d)),this._parser.registerCsiHandler({final:"e"},d=>this.vPositionRelative(d)),this._parser.registerCsiHandler({final:"f"},d=>this.hVPosition(d)),this._parser.registerCsiHandler({final:"g"},d=>this.tabClear(d)),this._parser.registerCsiHandler({final:"h"},d=>this.setMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"h"},d=>this.setModePrivate(d)),this._parser.registerCsiHandler({final:"l"},d=>this.resetMode(d)),this._parser.registerCsiHandler({prefix:"?",final:"l"},d=>this.resetModePrivate(d)),this._parser.registerCsiHandler({final:"m"},d=>this.charAttributes(d)),this._parser.registerCsiHandler({final:"n"},d=>this.deviceStatus(d)),this._parser.registerCsiHandler({prefix:"?",final:"n"},d=>this.deviceStatusPrivate(d)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},d=>this.softReset(d)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},d=>this.setCursorStyle(d)),this._parser.registerCsiHandler({final:"r"},d=>this.setScrollRegion(d)),this._parser.registerCsiHandler({final:"s"},d=>this.saveCursor(d)),this._parser.registerCsiHandler({final:"t"},d=>this.windowOptions(d)),this._parser.registerCsiHandler({final:"u"},d=>
570this.restoreCursor(d)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},d=>this.insertColumns(d)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},d=>this.deleteColumns(d)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},d=>this.selectProtected(d)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},d=>this.requestMode(d,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},d=>this.requestMode(d,!1)),this._parser.setExecuteHandler(Vt.BEL,()=>this.bell()),this._parser.setExecuteHandler(Vt.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Vt.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Vt.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Vt.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Vt.BS,()=>this.backspace()),this._parser.setExecuteHandler(Vt.HT,()=>this.tab()),this._parser.setExecuteHandler(Vt.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Vt.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(bS.IND,()=>this.index()),this._parser.setExecuteHandler(bS.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(bS.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Uu(d=>(this.setTitle(d),this.setIconName(d),!0))),this._parser.registerOscHandler(1,new Uu(d=>this.setIconName(d))),this._parser.registerOscHandler(2,new Uu(d=>this.setTitle(d))),this._parser.registerOscHandler(4,new Uu(d=>this.setOrReportIndexedColor(d))),this._parser.registerOscHandler(8,new Uu(d=>this.setHyperlink(d))),this._parser.registerOscHandler(10,new Uu(d=>this.setOrReportFgColor(d))),this._parser.registerOscHandler(11,new Uu(d=>this.setOrReportBgColor(d))),this._parser.registerOscHandler(12,new Uu(d=>this.setOrReportCursorColor(d))),this._parser.registerOscHandler(104,new Uu(d=>this.restoreIndexedColor(d))),this._parser.registerOscHandler(110,new Uu(d=>this.restoreFgColor(d))),this._parser.registerOscHandler(111,new Uu(d=>this.restoreBgColor(d))),this._parser.registerOscHandler(112,new Uu(d=>this.restoreCursorColor(d))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let d in Yl)this._parser.registerEscHandler({intermediates:"(",final:d},()=>this.selectCharset("("+d)),this._parser.registerEscHandler({intermediates:")",final:d},()=>this.selectCharset(")"+d)),this._parser.registerEscHandler({intermediates:"*",final:d},()=>this.selectCharset("*"+d)),this._parser.registerEscHandler({intermediates:"+",final:d},()=>this.selectCharset("+"+d)),this._parser.registerEscHandler({intermediates:"-",final:d},()=>this.selectCharset("-"+d)),this._parser.registerEscHandler({intermediates:".",final:d},()=>this.selectCharset("."+d)),this._parser.registerEscHandler({intermediates:"/",final:d},()=>this.selectCharset("/"+d));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(d=>(this._logService.error("Parsing error: ",d),d)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new nV((d,h)=>this.requestStatusString(d,h)))}getAttrData(){return this._curAttrData}_preserveStack(e,s,r,n){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=s,this._parseStack.decodedLength=r,this._parseStack.position=n}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((s,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),lV))]).catch(s=>{if(s!=="#SLOW_TIMEOUT")throw s;console.warn(`async parser handler taking longer than ${lV} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,s){let r,n=this._activeBuffer.x,a=this._activeBuffer.y,i=0,o=this._parseStack.paused;if(o){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,s))return this._logSlowResolvingAsync(r),r;n=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>eg&&(i=this._parseStack.position+eg)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,d=>String.fromCharCode(d)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(d=>
570d.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<eg&&(this._parseBuffer=new Uint32Array(Math.min(e.length,eg))),o||this._dirtyRowTracker.clearRange(),e.length>eg)for(let d=i;d<e.length;d+=eg){let h=d+eg<e.length?d+eg:e.length,p=typeof e=="string"?this._stringDecoder.decode(e.substring(d,h),this._parseBuffer):this._utf8Decoder.decode(e.subarray(d,h),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,p))return this._preserveStack(n,a,p,d),this._logSlowResolvingAsync(r),r}else if(!o){let d=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,d))return this._preserveStack(n,a,d,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==n||this._activeBuffer.y!==a)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,s,r){let n,a,i=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,d=this._coreService.modes.insertMode,h=this._curAttrData,p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-s>0&&p.getWidth(this._activeBuffer.x-1)===2&&p.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let g=this._parser.precedingJoinState;for(let v=s;v<r;++v){if(n=e[v],n<127&&i){let j=i[String.fromCharCode(n)];j&&(n=j.charCodeAt(0))}let b=this._unicodeService.charProperties(n,g);a=Mx.extractWidth(b);let y=Mx.extractShouldJoin(b),w=y?Mx.extractWidth(g):0;if(g=b,o&&this._onA11yChar.fire(lg(n)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+a-w>l){if(c){let j=p,x=this._activeBuffer.x-w;for(this._activeBuffer.x=w,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),w>0&&p instanceof Qw&&p.copyCellsFrom(j,x,0,w,!1);x<l;)j.setCellFromCodepoint(x++,0,1,h)}else if(this._activeBuffer.x=l-1,a===2)continue}if(y&&this._activeBuffer.x){let j=p.getWidth(this._activeBuffer.x-1)?1:2;p.addCodepointToCell(this._activeBuffer.x-j,n,a);for(let x=a-w;--x>=0;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(d&&(p.insertCells(this._activeBuffer.x,a-w,this._activeBuffer.getNullCell(h)),p.getWidth(l-1)===2&&p.setCellFromCodepoint(l-1,0,1,h)),p.setCellFromCodepoint(this._activeBuffer.x++,n,a,h),a>0)for(;--a;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=g,this._activeBuffer.x<l&&r-s>0&&p.getWidth(this._activeBuffer.x)===0&&!p.hasContent(this._activeBuffer.x)&&p.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,s){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,r=>oV(r.params[0],this._optionsService.rawOptions.windowOptions)?s(r):!0):this._parser.registerCsiHandler(e,s)}registerDcsHandler(e,s){return this._parser.registerDcsHandler(e,new nV(s))}registerEscHandler(e,s){return this._parser.registerEscHandler(e,s)}registerOscHandler(e,s){return this._parser.registerOscHandler(e,new Uu(s))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>
vendor: 15,801 bytes, line 570
570=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,s){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+s):(this._activeBuffer.x=e,this._activeBuffer.y=s),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,s){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+s)}cursorUp(e){let s=this._activeBuffer.y-this._activeBuffer.scrollTop;return s>=0?this._moveCursor(0,-Math.min(s,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let s=this._activeBuffer.scrollBottom-this._activeBuffer.y;return s>=0?this._moveCursor(0,Math.min(s,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let s=e.params[0];return s===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:s===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let s=e.params[0]||1;for(;s--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let s=e.params[0]||1;for(;s--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let s=e.params[0];return s===1&&(this._curAttrData.bg|=536870912),(s===2||s===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,s,r,n=!1,a=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i.replaceCells(s,r,this._activeBuffer.getNullCell(this._eraseAttrData()),a),n&&(i.isWrapped=!1)}_resetBufferLine(e,s=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),s),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,s=!1){this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,s);r<this._bufferService.rows;r++)this._resetBufferLine(r,s);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,s),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,s);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+r)?.getTrimmedLength(););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,s);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,s=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,s);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,s);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,s);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let s=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,a=this._bufferService.rows-1+this._activeBuffer.ybase-n+1;for(;s--;)this._activeBuffer.lines.splice(a-1,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let s=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,n;for(n=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-n;s--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return s&&(s.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return s&&(s.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let s=e.params[0]||1;for(;s--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let s=e.params[0]||1;for(;s--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(jl));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.deleteCells(0,s,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.insertCells(0,s,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.insertCells(this._activeBuffer.x,s,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);n.deleteCells(this._activeBuffer.x,s,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return s&&(s.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let s=this._parser.precedingJoinState;if(!s)return!0;let r=e.params[0]||1,n=Mx.extractWidth(s),a=this._activeBuffer.x-n,i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(a),o=new Uint32Array(i.length*r),l=0;for(let d=0;d<i.length;){let h=i.codePointAt(d)||0;o[l++]=h,d+=h>65535?2:1}let c=l;for(let d=1;d<r;++d)o.copyWithin(c,0,l),c+=l;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(Vt.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(Vt.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(Vt.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(Vt.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(Vt.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let s=0;s<e.length;s++)switch(e.params[s]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let s=0;s<e.length;s++)switch(e.params[s]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Nx),this._charsetService.setgCharset(1,Nx),this._charsetService.setgCharset(2,Nx),this._charsetService.setgCharset(3,Nx);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let s=0;s<e.length;s++)switch(e.params[s]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let s=0;s<e.length;s++)switch(e.params[s]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;
570case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[s]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,s){let r;(y=>(y[y.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",y[y.SET=1]="SET",y[y.RESET=2]="RESET",y[y.PERMANENTLY_SET=3]="PERMANENTLY_SET",y[y.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(r||={});let n=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:i}=this._coreMouseService,o=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:d,alt:h}=l,p=this._optionsService.rawOptions,g=(y,w)=>(o.triggerDataEvent(`${Vt.ESC}[${s?"":"?"}${y};${w}$y`),!0),v=y=>y?1:2,b=e.params[0];return s?b===2?g(b,4):b===4?g(b,v(o.modes.insertMode)):b===12?g(b,3):b===20?g(b,v(p.convertEol)):g(b,0):b===1?g(b,v(n.applicationCursorKeys)):b===3?g(b,p.windowOptions.setWinLines?c===80?2:c===132?1:0:0):b===6?g(b,v(n.origin)):b===7?g(b,v(n.wraparound)):b===8?g(b,3):b===9?g(b,v(a==="X10")):b===12?g(b,v(p.cursorBlink)):b===25?g(b,v(!o.isCursorHidden)):b===45?g(b,v(n.reverseWraparound)):b===66?g(b,v(n.applicationKeypad)):b===67?g(b,4):b===1e3?g(b,v(a==="VT200")):b===1002?g(b,v(a==="DRAG")):b===1003?g(b,v(a==="ANY")):b===1004?g(b,v(n.sendFocus)):b===1005?g(b,4):b===1006?g(b,v(i==="SGR")):b===1015?g(b,4):b===1016?g(b,v(i==="SGR_PIXELS")):b===1048?g(b,1):b===47||b===1047||b===1049?g(b,v(d===h)):b===2004?g(b,v(n.bracketedPasteMode)):b===2026?g(b,v(n.synchronizedOutput)):g(b,0)}_updateAttrColor(e,s,r,n,a){return s===2?(e|=50331648,e&=-16777216,e|=wN.fromColorRGB([r,n,a])):s===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,s,r){let n=[0,0,-1,0,0,0],a=0,i=0;do{if(n[i+a]=e.params[s+i],e.hasSubParams(s+i)){let o=e.getSubParams(s+i),l=0;do n[1]===5&&(a=1),n[i+l+1+a]=o[l];while(++l<o.length&&l+i+1+a<n.length);break}if(n[1]===5&&i+a>=2||n[1]===2&&i+a>=5)break;n[1]&&(a=1)}while(++i+s<e.length&&i+a<n.length);for(let o=2;o<n.length;++o)n[o]===-1&&(n[o]=0);switch(n[0]){case 38:r.fg=this._updateAttrColor(r.fg,n[1],n[3],n[4],n[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,n[1],n[3],n[4],n[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,n[1],n[3],n[4],n[5])}return i}_processUnderline(e,s){s.extended=s.extended.clone(),(!~e||e>5)&&(e=1),s.extended.underlineStyle=e,s.fg|=268435456,e===0&&(s.fg&=-268435457),s.updateExtended()}_processSGR0(e){e.fg=jl.fg,e.bg=jl.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let s=e.length,r,n=this._curAttrData;for(let a=0;a<s;a++)r=e.params[a],r>=30&&r<=37?(n.fg&=-50331904,n.fg|=16777216|r-30):r>=40&&r<=47?(n.bg&=-50331904,n.bg|=16777216|r-40):r>=90&&r<=97?(n.fg&=-50331904,n.fg|=16777216|r-90|8):r>=100&&r<=107?(n.bg&=-50331904,n.bg|=16777216|r-100|8):r===0?this._processSGR0(n):r===1?n.fg|=134217728:r===3?n.bg|=67108864:r===4?(n.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,n)):r===5?n.fg|=536870912:r===7?n.fg|=67108864:r===8?n.fg|=1073741824:r===9?n.fg|=2147483648:r===2?n.bg|=134217728:r===21?this._processUnderline(2,n):r===22?(n.fg&=-134217729,n.bg&=-134217729):r===23?n.bg&=-67108865:r===24?(n.fg&=-268435457,this._processUnderline(0,n)):r===25?n.fg&=-536870913:r===27?n.fg&=-67108865:r===28?n.fg&=-1073741825:r===29?n.fg&=2147483647:r===39?(n.fg&=-67108864,n.fg|=jl.fg&16777215):r===49?(n.bg&=-67108864,n.bg|=jl.bg&16777215):r===38||r===48||r===58?a+=this._extractColor(e,a,n):r===53?n.bg|=1073741824:r===55?n.bg&=-1073741825:r===59?(n.extended=n.extended.clone(),n.extended.underlineColor=-1,n.updateExtended()):r===100?(n.fg&=-67108864,n.fg|=jl.fg&16777215,n.bg&=-67108864,n.bg|=jl.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Vt.ESC}[0n`);break;case 6:let s=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Vt.ESC}[${s};${r}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let s=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Vt.ESC}[?${s};${r}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=jl.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let s=e.length===0?1:e.params[0];if(s===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(s){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;
570case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let r=s%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let s=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>s&&(this._activeBuffer.scrollTop=s-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!oV(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let s=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:s!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Vt.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(s===0||s===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>iV&&this._windowTitleStack.shift()),(s===0||s===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>iV&&this._iconNameStack.shift());break;case 23:(s===0||s===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(s===0||s===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let s=[],r=e.split(";");for(;r.length>1;){let n=r.shift(),a=r.shift();if(/^\d+$/.exec(n)){let i=parseInt(n);if(dV(i))if(a==="?")s.push({type:0,index:i});else{let o=aV(a);o&&s.push({type:1,index:i,color:o})}}}return s.length&&this._onColor.fire(s),!0}setHyperlink(e){let s=e.indexOf(";");if(s===-1)return!0;let r=e.slice(0,s).trim(),n=e.slice(s+1);return n?this._createHyperlink(r,n):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,s){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),n,a=r.findIndex(i=>i.startsWith("id="));return a!==-1&&(n=r[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:n,uri:s}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,s){let r=e.split(";");for(let n=0;n<r.length&&!(s>=this._specialColors.length);++n,++s)if(r[n]==="?")this._onColor.fire([{type:0,index:this._specialColors[s]}]);else{let a=aV(r[n]);a&&this._onColor.fire([{type:1,index:this._specialColors[s],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let s=[],r=e.split(";");for(let n=0;n<r.length;++n)if(/^\d+$/.exec(r[n])){let a=parseInt(r[n]);dV(a)&&s.push({type:2,index:a})}return s.length&&this._onColor.fire(s),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Nx),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(t9e[e[0]],Yl[e[1]]||Nx),!0)}
570index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=jl.clone(),this._eraseAttrDataInternal=jl.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Im;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let s=0;s<this._bufferService.rows;++s){let r=this._activeBuffer.ybase+this._activeBuffer.y+s,n=this._activeBuffer.lines.get(r);n&&(n.fill(e),n.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,s){let r=o=>(this._coreService.triggerDataEvent(`${Vt.ESC}${o}${Vt.ESC}\\`),!0),n=this._bufferService.buffer,a=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${n.scrollTop+1};${n.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,s){this._dirtyRowTracker.markRangeDirty(e,s)}},II=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,s){e>s&&(cV=e,e=s,s=cV),e<this.start&&(this.start=e),s>this.end&&(this.end=s)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};II=Bo([Js(0,Jd)],II);function dV(e){return 0<=e&&e<256}var r9e=5e7,uV=12,n9e=50,a9e=class extends Yn{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Ps),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,s){if(s!==void 0&&this._syncCalls>s){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let r;for(;r=this._writeBuffer.shift();){this._action(r);let n=this._callbacks.shift();n&&n()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,s){if(this._pendingData>r9e)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(s),this._innerWrite();return}setTimeout(()=>this._innerWrite())}
570this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(s)}_innerWrite(e=0,s=!0){let r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let n=this._writeBuffer[this._bufferOffset],a=this._action(n,s);if(a){let o=l=>performance.now()-r>=uV?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(r,l);a.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(o);return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=n.length,performance.now()-r>=uV)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>n9e&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},OI=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let s=this._bufferService.buffer;if(e.id===void 0){let l=s.addMarker(s.ybase+s.y),c={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._dataByLinkId.set(c.id,c),c.id}let r=e,n=this._getEntryIdKey(r),a=this._entriesWithId.get(n);if(a)return this.addLineToLink(a.id,s.ybase+s.y),a.id;let i=s.addMarker(s.ybase+s.y),o={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[i]};return i.onDispose(()=>this._removeMarkerFromLink(o,i)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,s){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(n=>n.line!==s)){let n=this._bufferService.buffer.addMarker(s);r.lines.push(n),n.onDispose(()=>this._removeMarkerFromLink(r,n))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,s){let r=e.lines.indexOf(s);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};OI=Bo([Js(0,Jd)],OI);var mV=!1,i9e=class extends Yn{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new yb),this._onBinary=this._register(new Ps),this.onBinary=this._onBinary.event,this._onData=this._register(new Ps),this.onData=this._onData.event,this._onLineFeed=this._register(new Ps),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Ps),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Ps),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Ps),this._instantiationService=new Tqe,this.optionsService=this._register(new Bqe(e)),this._instantiationService.setService(eu,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(TI)),this._instantiationService.setService(Jd,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(EI)),this._instantiationService.setService(Eie,this._logService),this.coreService=this._register(this._instantiationService.createInstance(AI)),this._instantiationService.setService(vv,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(MI)),this._instantiationService.setService(Pie,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Mx)),this._instantiationService.setService(kHe,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Vqe),this._instantiationService.setService(CHe,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(OI),this._instantiationService.setService(Tie,this._oscLinkService),this._inputHandler=this._register(new s9e(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Qc.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Qc.forward(this._bufferService.onResize,this._onResize)),this._register(Qc.forward(this.coreService.onData,this._onData)),this._register(Qc.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new a9e((s,r)=>this._inputHandler.parse(s,r))),this._register(Qc.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Ps),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}
570get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let s in e)this.optionsService.options[s]=e[s]}write(e,s){this._writeBuffer.write(e,s)}writeSync(e,s){this._logService.logLevel<=3&&!mV&&(this._logService.warn("writeSync is unreliable and will be removed soon."),mV=!0),this._writeBuffer.writeSync(e,s)}input(e,s=!0){this.coreService.triggerDataEvent(e,s)}resize(e,s){isNaN(e)||isNaN(s)||(e=Math.max(e,loe),s=Math.max(s,coe),this._bufferService.resize(e,s))}scroll(e,s=!1){this._bufferService.scroll(e,s)}scrollLines(e,s){this._bufferService.scrollLines(e,s)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let s=e-this._bufferService.buffer.ydisp;s!==0&&this.scrollLines(s)}registerEscHandler(e,s){return this._inputHandler.registerEscHandler(e,s)}registerDcsHandler(e,s){return this._inputHandler.registerDcsHandler(e,s)}registerCsiHandler(e,s){return this._inputHandler.registerCsiHandler(e,s)}registerOscHandler(e,s){return this._inputHandler.registerOscHandler(e,s)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,s=this.optionsService.rawOptions.windowsPty;s&&s.buildNumber!==void 0&&s.buildNumber!==void 0?e=s.backend==="conpty"&&s.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(rV.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(rV(this._bufferService),!1))),this._windowsWrappingHeuristics.value=io(()=>{for(let s of e)s.dispose()})}}},o9e={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function l9e(e,s,r,n){let a={type:0,cancel:!1,key:void 0},i=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?s?a.key=Vt.ESC+"OA":a.key=Vt.ESC+"[A":e.key==="UIKeyInputLeftArrow"?s?a.key=Vt.ESC+"OD":a.key=Vt.ESC+"[D":e.key==="UIKeyInputRightArrow"?s?a.key=Vt.ESC+"OC":a.key=Vt.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(s?a.key=Vt.ESC+"OB":a.key=Vt.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":Vt.DEL,e.altKey&&(a.key=Vt.ESC+a.key);break;case 9:if(e.shiftKey){a.key=Vt.ESC+"[Z";break}a.key=Vt.HT,a.cancel=!0;break;case 13:a.key=e.altKey?Vt.ESC+Vt.CR:Vt.CR,a.cancel=!0;break;case 27:a.key=Vt.ESC,e.altKey&&(a.key=Vt.ESC+Vt.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;i?a.key=Vt.ESC+"[1;"+(i+1)+"D":s?a.key=Vt.ESC+"OD":a.key=Vt.ESC+"[D";break;case 39:if(e.metaKey)break;i?a.key=Vt.ESC+"[1;"+(i+1)+"C":s?a.key=Vt.ESC+"OC":a.key=Vt.ESC+"[C";break;case 38:if(e.metaKey)break;i?a.key=Vt.ESC+"[1;"+(i+1)+"A":s?a.key=Vt.ESC+"OA":a.key=Vt.ESC+"[A";break;case 40:if(e.metaKey)break;i?a.key=Vt.ESC+"[1;"+(i+1)+"B":s?a.key=Vt.ESC+"OB":a.key=Vt.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=Vt.ESC+"[2~");break;case 46:i?a.key=Vt.ESC+"[3;"+(i+1)+"~":a.key=Vt.ESC+"[3~";break;case 36:i?a.key=Vt.ESC+"[1;"+(i+1)+"H":s?a.key=Vt.ESC+"OH":a.key=Vt.ESC+"[H";break;case 35:i?a.key=Vt.ESC+"[1;"+(i+1)+"F":s?a.key=Vt.ESC+"OF":a.key=Vt.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=Vt.ESC+"[5;"+(i+1)+"~":a.key=Vt.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=Vt.ESC+"[6;"+(i+1)+"~":a.key=Vt.ESC+"[6~";break;case 112:i?a.key=Vt.ESC+"[1;"+(i+1)+"P":a.key=Vt.ESC+"OP";break;case 113:i?a.key=Vt.ESC+"[1;"+(i+1)+"Q":a.key=Vt.ESC+"OQ";break;case 114:i?a.key=Vt.ESC+"[1;"+(i+1)+"R":a.key=Vt.ESC+"OR";break;case 115:i?a.key=Vt.ESC+"[1;"+(i+1)+"S":a.key=Vt.ESC+"OS";break;case 116:i?a.key=Vt.ESC+"[15;"+(i+1)+"~":a.key=Vt.ESC+"[15~";break;case 117:i?a.key=Vt.ESC+"[17;"+(i+1)+"~":a.key=Vt.ESC+"[17~";break;case 118:i?a.key=Vt.ESC+"[18;"+(i+1)+"~":a.key=Vt.ESC+"[18~";break;case 119:i?a.key=Vt.ESC+"[19;"+(i+1)+"~":a.key=Vt.ESC+"[19~";break;case 120:i?a.key=Vt.ESC+"[20;"+(i+1)+"~":a.key=Vt.ESC+"[20~";break;case 121:i?a.key=Vt.ESC+"[21;"+(i+1)+"~":a.key=Vt.ESC+"[21~";break;case 122:i?a.key=Vt.ESC+"[23;"+(i+1)+"~":a.key=Vt.ESC+"[23~";break;case 123:i?a.key=Vt.ESC+"[24;"+(i+1)+"~":a.key=Vt.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=Vt.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=Vt.DEL:e.ke
570yCode===219?a.key=Vt.ESC:e.keyCode===220?a.key=Vt.FS:e.keyCode===221&&(a.key=Vt.GS);else if((!r||n)&&e.altKey&&!e.metaKey){let o=o9e[e.keyCode]?.[e.shiftKey?1:0];if(o)a.key=Vt.ESC+o;else if(e.keyCode>=65&&e.keyCode<=90){let l=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(l);e.shiftKey&&(c=c.toUpperCase()),a.key=Vt.ESC+c}else if(e.keyCode===32)a.key=Vt.ESC+(e.ctrlKey?Vt.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let l=e.code.slice(3,4);e.shiftKey||(l=l.toLowerCase()),a.key=Vt.ESC+l,a.cancel=!0}}else r&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=Vt.US),e.key==="@"&&(a.key=Vt.NUL));break}return a}var Xo=0,c9e=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new kk,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new kk,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,i)=>this._getKey(a)-this._getKey(i)),s=0,r=0,n=new Array(this._array.length+this._insertedValues.length);for(let a=0;a<n.length;a++)r>=this._array.length||this._getKey(e[s])<=this._getKey(this._array[r])?(n[a]=e[s],s++):n[a]=this._array[r++];this._array=n,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let s=this._getKey(e);if(s===void 0||(Xo=this._search(s),Xo===-1)||this._getKey(this._array[Xo])!==s)return!1;do if(this._array[Xo]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Xo),!0;while(++Xo<this._array.length&&this._getKey(this._array[Xo])===s);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((a,i)=>a-i),s=0,r=new Array(this._array.length-e.length),n=0;for(let a=0;a<this._array.length;a++)e[s]===a?s++:r[n++]=this._array[a];this._array=r,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Xo=this._search(e),!(Xo<0||Xo>=this._array.length)&&this._getKey(this._array[Xo])===e))do yield this._array[Xo];while(++Xo<this._array.length&&this._getKey(this._array[Xo])===e)}forEachByKey(e,s){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Xo=this._search(e),!(Xo<0||Xo>=this._array.length)&&this._getKey(this._array[Xo])===e))do s(this._array[Xo]);while(++Xo<this._array.length&&this._getKey(this._array[Xo])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let s=0,r=this._array.length-1;for(;r>=s;){let n=s+r>>1,a=this._getKey(this._array[n]);if(a>e)r=n-1;else if(a<e)s=n+1;else{for(;n>0&&this._getKey(this._array[n-1])===e;)n--;return n}}return s}},h5=0,hV=0,d9e=class extends Yn{constructor(){super(),this._decorations=new c9e(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Ps),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Ps),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(io(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let s=new u9e(e);if(s){let r=s.marker.onDispose(()=>s.dispose()),n=s.onDispose(()=>{n.dispose(),s&&(this._decorations.delete(s)&&this._onDecorationRemoved.fire(s),r.dispose())});this._decorations.insert(s),this._onDecorationRegistered.fire(s)}return s}
570reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,s,r){let n=0,a=0;for(let i of this._decorations.getKeyIterator(s))n=i.options.x??0,a=n+(i.options.width??1),e>=n&&e<a&&(!r||(i.options.layer??"bottom")===r)&&(yield i)}forEachDecorationAtCell(e,s,r,n){this._decorations.forEachByKey(s,a=>{h5=a.options.x??0,hV=h5+(a.options.width??1),e>=h5&&e<hV&&(!r||(a.options.layer??"bottom")===r)&&n(a)})}},u9e=class extends Sg{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Ps),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Ps),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=yo.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=yo.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},m9e=1e3,h9e=class{constructor(e,s=m9e){this._renderCallback=e,this._debounceThresholdMS=s,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,s,r){this._rowCount=r,e=e!==void 0?e:0,s=s!==void 0?s:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,s):s;let n=performance.now();if(n-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=n,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=n-this._lastRefreshMs,i=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},i)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),s=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,s)}},pV=20,_k=class extends Yn{constructor(e,s,r,n){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=n,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let i=0;i<this._terminal.rows;i++)this._rowElements[i]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[i]);if(this._topBoundaryFocusListener=i=>this._handleBoundaryFocus(i,0),this._bottomBoundaryFocusListener=i=>this._handleBoundaryFocus(i,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new h9e(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(i=>this._handleResize(i.rows))),this._register(this._terminal.onRender(i=>this._refreshRows(i.start,i.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(i=>this._handleChar(i))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
571`))),this._register(this._terminal.onA11yTab(i=>this._handleTab(i))),this._register(this._terminal.onKey(i=>this._handleKey(i.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ln(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(io(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let s=0;s<e;s++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<pV+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
572`&&(this._liveRegionLineCount++,this._liveRegionLineCount===pV+1&&(this._liveRegion.textContent+=tI.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,s){this._liveRegionDebouncer.refresh(e,s,this._terminal.rows)}_renderRows(e,s){let r=this._terminal.buffer,n=r.lines.length.toString();for(let a=e;a<=s;a++){let i=r.lines.get(r.ydisp+a),o=[],l=i?.translateToString(!0,void 0,void 0,o)||"",c=(r.ydisp+a+1).toString(),d=this._rowElements[a];d&&(l.length===0?(d.textContent=" ",this._rowColumns.set(d,[0,1])):(d.textContent=l,this._rowColumns.set(d,o)),d.setAttribute("aria-posinset",c),d.setAttribute("aria-setsize",n),this._alignRowWidth(d))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce
572="")}_handleBoundaryFocus(e,s){let r=e.target,n=this._rowElements[s===0?1:this._rowElements.length-2],a=r.getAttribute("aria-posinset"),i=s===0?"1":`${this._terminal.buffer.lines.length}`;if(a===i||e.relatedTarget!==n)return;let o,l;if(s===0?(o=r,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(o=this._rowElements.shift(),l=r,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),s===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(s===0?-1:1),this._rowElements[s===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let s={node:e.anchorNode,offset:e.anchorOffset},r={node:e.focusNode,offset:e.focusOffset};if((s.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||s.node===r.node&&s.offset>r.offset)&&([s,r]=[r,s]),s.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(s={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(s.node))return;let n=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:n,offset:n.textContent?.length??0}),!this._rowContainer.contains(r.node))return;let a=({node:l,offset:c})=>{let d=l instanceof Text?l.parentNode:l,h=parseInt(d?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let p=this._rowColumns.get(d);if(!p)return console.warn("columns is null. Race condition?"),null;let g=c<p.length?p[c]:p.slice(-1)[0]+1;return g>=this._terminal.cols&&(++h,g=0),{row:h,column:g}},i=a(s),o=a(r);if(!(!i||!o)){if(i.row>o.row||i.row===o.row&&i.column>=o.column)throw new Error("invalid range");this._terminal.select(i.column,i.row,(o.row-i.row)*this._terminal.cols-i.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let s=this._rowContainer.children.length;s<this._terminal.rows;s++)this._rowElements[s]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[s]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let s=e.getBoundingClientRect().width,r=this._rowColumns.get(e)?.slice(-1)?.[0];if(!r)return;
572let n=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${n/s})`}};_k=Bo([Js(1,tL),Js(2,Ef),Js(3,Tf)],_k);var DI=class extends Yn{constructor(e,s,r,n,a){super(),this._element=e,this._mouseService=s,this._renderService=r,this._bufferService=n,this._linkProviderService=a,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Ps),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Ps),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(io(()=>{iv(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(ln(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ln(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ln(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ln(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let s=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!s)return;this._isMouseOut=!1;let r=e.composedPath();for(let n=0;n<r.length;n++){let a=r[n];if(a.classList.contains("xterm"))break;if(a.classList.contains("xterm-hover"))return}(!this._lastBufferCell||s.x!==this._lastBufferCell.x||s.y!==this._lastBufferCell.y)&&(this._handleHover(s),this._lastBufferCell=s)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,s){(!this._activeProviderReplies||!s)&&(this._activeProviderReplies?.forEach(n=>{n?.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[n,a]of this._linkProviderService.linkProviders.entries())s?this._activeProviderReplies?.get(n)&&(r=this._checkLinkProviderResult(n,e,r)):a.provideLinks(e.y,i=>{if(this._isMouseOut)return;let o=i?.map(l=>({link:l}));this._activeProviderReplies?.set(n,o),r=this._checkLinkProviderResult(n,e,r),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,s){let r=new Set;for(let n=0;n<s.size;n++){let a=s.get(n);if(a)for(let i=0;i<a.length;i++){let o=a[i],l=o.link.range.start.y<e?0:o.link.range.start.x,c=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let d=l;d<=c;d++){if(r.has(d)){a.splice(i--,1);break}r.add(d)}}}}_checkLinkProviderResult(e,s,r){if(!this._activeProviderReplies)return r;let n=this._activeProviderReplies.get(e),a=!1;for(let i=0;i<e;i++)(!this._activeProviderReplies.has(i)||this._activeProviderReplies.get(i))&&(a=!0);if(!a&&n){let i=n.find(o=>this._linkAtPosition(o.link,s));i&&(r=!0,this._handleNewLink(i))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let i=0;i<this._activeProviderReplies.size;i++){let o=this._activeProviderReplies.get(i)?.find(l=>this._linkAtPosition(l.link,s));if(o){r=!0,this._handleNewLink(o);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let s=this._positionFromMouseEvent(e,this._element,this._mouseService);s&&this._mouseDownLink&&p9e(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,s)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,s){!this._currentLink||!this._lastMouseEvent||(!e||!s||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=s)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,iv(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let s=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);s&&this._linkAtPosition(e.link,s)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:r=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:r=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let n=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=n&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(n,a),this._lastMouseEvent)){let i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._askForLink(i,!1)}})))}_linkHover(e,s,r){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(s,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),s.hover&&s.hover(r,s.text)}_fireUnderlineEvent(e,s){let r=e.range,n=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-n-1,r.end.x,r.end.y-n-1,void 0);(s?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,s,r){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(s,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),s.leave&&s.leave(r,s.text)}_linkAtPosition(e,s){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,n=e.range.end.y*this._bufferService.cols+e.range.end.x,a=s.y*this._bufferService.cols+s.x;return r<=a&&a<=n}_positionFromMouseEvent(e,s,r){let n=r.getCoords(e,s,this._bufferService.cols,this._bufferService.rows);if(n)return{x:n[0],y:n[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,s,r,n,a){return{x1:e,y1:s,x2:r,y2:n,cols:this._bufferService.cols,fg:a}}};DI=Bo([Js(1,sL),Js(2,Tf),Js(3,Jd),Js(4,Mie)],DI);function p9e(e,s){return e.text===s.text&&e.range.start.x===s.range.start.x&&e.range.start.y===s.range.start.y&&e.range.end.x===s.range.end.x&&e.range.end.y===s.range.end.y}var f9e=class extends i9e{constructor(e={}){super(e),this._linkifier=this._register(new yb),this.browser=Xie,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new yb),this._onCursorMove=this._register(new Ps),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Ps),this.onKey=this._onKey.event,this._onRender=this._register(new Ps),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Ps),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Ps),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Ps),this.onBell=this._onBell.event,this._onFocus=this._register(new Ps),this._onBlur=this._register(new Ps),this._onA11yCharEmitter=this._register(new Ps),this._onA11yTabEmitter=this._register(new Ps),this._onWillOpen=this._register(new Ps),this._setup(),this._decorationService=this._instantiationService.createInstance(d9e),this._instantiationService.setService(jN,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(nqe),this._instantiationService.setService(Mie,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(rI)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(s=>this.refresh(s?.start??0,s?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(s=>this._reportWindowsOptions(s))),this._register(this._inputHandler.onColor(s=>this._handleColorEvent(s))),this._register(Qc.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Qc.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Qc.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Qc.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(s=>this._afterResize(s.cols,s.rows))),this._register(io(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}
572get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let s of e){let r,n="";switch(s.index){case 256:r="foreground",n="10";break;case 257:r="background",n="11";break;case 258:r="cursor",n="12";break;default:r="ansi",n="4;"+s.index}switch(s.type){case 0:let a=Ui.toColorRGB(r==="ansi"?this._themeService.colors.ansi[s.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${Vt.ESC}]${n};${e9e(a)}${Yie.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(i=>i.ansi[s.index]=Nl.toColor(...s.color));else{let i=r;this._themeService.modifyColors(o=>o[i]=Nl.toColor(...s.color))}break;case 2:this._themeService.restoreColor(s.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(_k,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Vt.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Vt.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,s=this.buffer.lines.get(e);if(!s)return;let r=Math.min(this.buffer.x,this.cols-1),n=this._renderService.dimensions.css.cell.height,a=s.getWidth(r),i=this._renderService.dimensions.css.cell.width*a,o=this.buffer.y*this._renderService.dimensions.css.cell.height,l=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=o+"px",this.textarea.style.width=i+"px",this.textarea.style.height=n+"px",this.textarea.style.lineHeight=n+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ln(this.element,"copy",s=>{this.hasSelection()&&yHe(s,this._selectionService)}));let e=s=>bHe(s,this.textarea,this.coreService,this.optionsService);this._register(ln(this.textarea,"paste",e)),this._register(ln(this.element,"paste",e)),Zie?this._register(ln(this.element,"mousedown",s=>{s.button===2&&S9(s,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ln(this.element,"contextmenu",s=>{S9(s,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),dL&&this._register(ln(this.element,"auxclick",s=>{s.button===1&&Nie(s,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ln(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ln(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ln(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ln(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ln(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ln(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ln(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let s=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),s.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(ln(this.screenElement,"mousemove",a=>this.updateCursorStyle(a))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),s.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",eI.get()),toe||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","fal
572se"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(sqe,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Ef,this._coreBrowserService),this._register(ln(this.textarea,"focus",a=>this._handleTextAreaFocus(a))),this._register(ln(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(SI,this._document,this._helperContainer),this._instantiationService.setService(u2,this._charSizeService),this._themeService=this._instantiationService.createInstance(PI),this._instantiationService.setService(Yb,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Sk),this._instantiationService.setService(Aie,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(kI,this.rows,this.screenElement)),this._instantiationService.setService(Tf,this._renderService),this._register(this._renderService.onRenderedViewportChange(a=>this._onRender.fire(a))),this.onResize(a=>this._renderService.resize(a.cols,a.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(wI,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(CI),this._instantiationService.setService(sL,this._mouseService);let n=this._linkifier.value=this._register(this._instantiationService.createInstance(DI,this.screenElement));this.element.appendChild(s);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(yI,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(a=>{super.scrollLines(a,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(_I,this.element,this.screenElement,n)),this._instantiationService.setService(PHe,this._selectionService),this._register(this._selectionService.onRequestScrollLines(a=>this.scrollLines(a.amount,a.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(a=>this._renderService.handleSelectionChanged(a.start,a.end,a.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(a=>{this.textarea.value=a,this.textarea.focus(),this.textarea.select()}
572)),this._register(Qc.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(bI,this.screenElement)),this._register(ln(this.element,"mousedown",a=>this._selectionService.handleMouseDown(a))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(_k,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",a=>this._handleScreenReaderModeOptionChange(a))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Nk,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",a=>{!this._overviewRulerRenderer&&a&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Nk,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(NI,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,s=this.element;function r(i){let o=e._mouseService.getMouseReportCoords(i,e.screenElement);if(!o)return!1;let l,c;switch(i.overrideType||i.type){case"mousemove":c=32,i.buttons===void 0?(l=3,i.button!==void 0&&(l=i.button<3?i.button:3)):l=i.buttons&1?0:i.buttons&4?1:i.buttons&2?2:3;break;case"mouseup":c=0,l=i.button<3?i.button:3;break;case"mousedown":c=1,l=i.button<3?i.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(i)===!1)return!1;let d=i.deltaY;if(d===0||e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;c=d<0?0:1,l=4;break;default:return!1}return c===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:l,action:c,ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey})}let n={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:i=>(r(i),i.buttons||(this._document.removeEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.removeEventListener("mousemove",n.mousedrag)),this.cancel(i)),wheel:i=>(r(i),this.cancel(i,!0)),mousedrag:i=>{i.buttons&&r(i)},mousemove:i=>{i.buttons||r(i)}};this._register(this.coreMouseService.onProtocolChange(i=>{i?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(i)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),i&8?n.mousemove||(s.addEventListener("mousemove",a.mousemove),n.mousemove=a.mousemove):(s.removeEventListener("mousemove",n.mousemove),n.mousemove=null),i&16?n.wheel||(s.addEventListener("wheel",a.wheel,{passive:!1}),n.wheel=a.wheel):(s.removeEventListener("wheel",n.wheel),n.wheel=null),i&2?n.mouseup||(n.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",n.mouseup),n.mouseup=null),i&4?n.mousedrag||(n.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",n.mousedrag),n.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ln(s,"mousedown",i=>{if(i.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(i)))return r(i),n.mouseup&&this._document.addEventListener("mouseup",n.mouseup),n.mousedrag&&this._document.addEventListener("mousemove",n.mousedrag),this.cancel(i)})),this._register(ln(s,"wheel",i=>{if(!n.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(i)===!1)return!1;if(!this.buffer.hasScrollback){if(i.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(i,!0);let o=Vt.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(i.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(o,!0),this.cancel(i,!0)}}},{passive:!1}))}refresh(e,s){this._renderService?.refreshRows(e,s)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,s){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,s),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let s=e-this._bufferService.buffer.ydisp;s!==0&&this.scrollLines(s)}paste(e){jie(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let s=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),s}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,s,r){this._selectionService.setSelection(e,s,r)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,s){this._selectionService?.selectLines(e,s)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let s=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!s&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!s&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let r=l9e(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let n=this.rows-1;return this.scrollLines(r.type===2?-n:n),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCo
572deAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((r.key===Vt.ETX||r.key===Vt.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,s){let r=e.isMac&&!this.options.macOptionIsMeta&&s.altKey&&!s.ctrlKey&&!s.metaKey||e.isWindows&&s.altKey&&s.ctrlKey&&!s.metaKey||e.isWindows&&s.getModifierState("AltGraph");return s.type==="keypress"?r:r&&(!s.keyCode||s.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(g9e(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let s;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)s=e.charCode;else if(e.which===null||e.which===void 0)s=e.keyCode;else if(e.which!==0&&e.charCode!==0)s=e.which;else return!1;return!s||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(s=String.fromCharCode(s),this._onKey.fire({key:s,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let s=e.data;return this.coreService.triggerDataEvent(s,!0),this.cancel(e),!0}return!1}resize(e,s){if(e===this.cols&&s===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,s)}_afterResize(e,s){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(jl));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(Vt.ESC+"[I"):this.coreService.triggerDataEvent(Vt.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let s=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Vt.ESC}[4;${r};${s}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),a=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Vt.ESC}[6;${a};${n}t`);break}}cancel(e,s){if(!(!this.options.cancelEvents&&!s))return e.preventDefault(),e.stopPropagation(),!1}};function g9e(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var x9e=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,s){let r={instance:s,dispose:s.dispose,isDisposed:!1};this._addons.push(r),s.dispose=()=>this._wrappedAddonDispose(r),s.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let s=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){s=r;break}if(s===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(s,1)}},v9e=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,s){if(!(e<0||e>=this._line.length))return s?(this._line.loadCell(e,s),s):this._line.loadCell(e,new Im)}translateToString(e,s,r){return this._line.translateToString(e,s,r)}},fV=class{constructor(e,s){this._buffer=e,this.type=s}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let s=this._buffer.lines.get(e);if(s)return new v9e(s)}getNullCell(){return new Im}},y9e=class extends Yn{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Ps),this.onBufferChange=this._onBufferChange.event,this._normal=new fV(this._core.buffers.normal,"normal"),this._alternate=new fV(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},b9e=class{constructor(e){this._core=e}
572registerCsiHandler(e,s){return this._core.registerCsiHandler(e,r=>s(r.toArray()))}addCsiHandler(e,s){return this.registerCsiHandler(e,s)}registerDcsHandler(e,s){return this._core.registerDcsHandler(e,(r,n)=>s(r,n.toArray()))}addDcsHandler(e,s){return this.registerDcsHandler(e,s)}registerEscHandler(e,s){return this._core.registerEscHandler(e,s)}addEscHandler(e,s){return this.registerEscHandler(e,s)}registerOscHandler(e,s){return this._core.registerOscHandler(e,s)}addOscHandler(e,s){return this.registerOscHandler(e,s)}},w9e=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},j9e=["cols","rows"],qh=0,N9e=class extends Yn{constructor(e){super(),this._core=this._register(new f9e(e)),this._addonManager=this._register(new x9e),this._publicOptions={...this._core.options};let s=n=>this._core.options[n],r=(n,a)=>{this._checkReadonlyOptions(n),this._core.options[n]=a};for(let n in this._core.options){let a={get:s.bind(this,n),set:r.bind(this,n)};Object.defineProperty(this._publicOptions,n,a)}}_checkReadonlyOptions(e){if(j9e.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new b9e(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new w9e(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new y9e(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,s="none";switch(this._core.coreMouseService.activeProtocol){case"X10":s="x10";break;case"VT200":s="vt200";break;case"DRAG":s="drag";break;case"ANY":s="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:s,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let s in e)this._publicOptions[s]=e[s]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,s=!0){this._core.input(e,s)}resize(e,s){this._verifyIntegers(e,s),this._core.resize(e,s)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,s,r){this._verifyIntegers(e,s,r),this._core.select(e,s,r)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}
572selectLines(e,s){this._verifyIntegers(e,s),this._core.selectLines(e,s)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,s){this._core.write(e,s)}writeln(e,s){this._core.write(e),this._core.write(`\r
573`,s)}paste(e){this._core.paste(e)}refresh(e,s){this._verifyIntegers(e,s),this._core.refresh(e,s)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return eI.get()},set promptLabel(e){eI.set(e)},get tooMuchOutput(){return tI.get()},set tooMuchOutput(e){tI.set(e)}}}_verifyIntegers(...e){for(qh of e)if(qh===1/0||isNaN(qh)||qh%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qh of e)if(qh&&(qh===1/0||isNaN(qh)||qh%1!==0||qh<0))throw new Error("This API only accepts positive integers")}};var S9e=2,C9e=1,k9e=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),n=parseInt(r.getPropertyValue("height")),a=Math.max(0,parseInt(r.getPropertyValue("width"))),i=window.getComputedStyle(this._terminal.element),o={top:parseInt(i.getPropertyValue("padding-top")),bottom:parseInt(i.getPropertyValue("padding-bottom")),right:parseInt(i.getPropertyValue("padding-right")),left:parseInt(i.getPropertyValue("padding-left"))},l=o.top+o.bottom,c=o.right+o.left,d=n-l,h=a-c-s;return{cols:Math.max(S9e,Math.floor(h/e.css.cell.width)),rows:Math.max(C9e,Math.floor(d/e.css.cell.height))}}};const Up=e=>`/api/edge-devices/${e}/terminal`;function uoe({edgeDeviceId:e,handoff:s,expanded:r=!1}){const[n,a]=u.useState(null),[i,o]=u.useState(!0),[l,c]=u.useState(""),[d,h]=u.useState(!1),[p,g]=u.useState(!1),[v,b]=u.useState(""),[y,w]=u.useState(""),[j,x]=u.useState(""),[C,k]=u.useState(""),[S,_]=u.useState(!1),[A,T]=u.useState(null),[M,R]=u.useState(null),[D,$]=u.useState("closed"),[O,q]=u.useState([]),[V,K]=u.useState(0),[G,z]=u.useState(""),[Z,ee]=u.useState(!1),[Q,Y]=u.useState(!1),oe=u.useRef(null),he=u.useRef(null),je=u.useRef(null),pe=u.useRef(new Set),le=u.useRef(Promise.resolve()),ue=u.useRef(async()=>{}),fe=u.useRef(""),H=u.useRef(null),se=u.useCallback(async()=>{o(!0);try{const Be=await fetch(`${Up(e)}/config`,{credentials:"include"});if(!Be.ok)throw new Error("Unable to load terminal availability");a(await Be.json()),c("")}catch(Be){c(Be.message||"Unable to load terminal availability")}finally{o(!1)}},[e]);u.useEffect(()=>{se()},[se]),u.useEffect(()=>{s&&fetch(`${Up(e)}/handoff/consume`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({handoff:s})}).then(async Be=>{if(!Be.ok)throw new Error((await Be.json()).message||"Terminal handoff expired");const J=await Be.json();T(J.sessionId),R(J.token),$(J.status||"pending")}).catch(Be=>z(Be.message||"Unable to attach terminal session"))},[e,s]);const me=async Be=>{h(!0),c("");try{const J=await fetch(`${Up(e)}/config`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json","X-Device-Settings-Context":"diagnostics"},body:JSON.stringify({enabled:Be})});if(!J.ok)throw new Error((await J.json().catch(()=>null))?.message||"Unable to update terminal setting");const ae=await J.json();a(we=>({...we||{supported:!0,online:!1},...ae}))}catch(J){c(J.message||"Unable to update terminal setting")}finally{h(!1)}},ge=Be=>{if(!Be.length)return;q(ae=>{const we=new Set(ae.map(Qe=>String(Qe.id)));return[...ae,...Be.filter(Qe=>!we.has(String(Qe.id)))]});const J=Be[Be.length-1];K(J.id)},be=u.useCallback(async()=>
573{if(!(!A||!M))try{const Be=new URLSearchParams({after:String(V)}),J=await fetch(`${Up(e)}/sessions/${A}?${Be}`,{credentials:"include",headers:{"X-Terminal-Token":M}});if(!J.ok)throw new Error(J.status===404?"Terminal session not found":"Unable to read terminal session");const ae=await J.json();ee(!1),$(ae.status||"closed"),ge(ae.messages||[]),ae.terminationReason&&ae.status!=="active"&&z(ae.terminationReason)}catch(Be){ee(!0),z(Be.message||"Terminal connection interrupted")}},[V,e,A,M]);u.useEffect(()=>{if(!A||!M||D==="closed"||D==="failed"||D==="terminated")return;be();const Be=window.setInterval(()=>{be()},250);return()=>window.clearInterval(Be)},[be,A,D,M]),u.useEffect(()=>{if(!A||!oe.current||he.current)return;const Be=new N9e({convertEol:!1,cursorBlink:!0,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,scrollback:5e3,theme:{background:"#09090b",foreground:"#f4f4f5"}}),J=new k9e;Be.loadAddon(J),Be.open(oe.current),J.fit(),he.current=Be,je.current=J;const ae=()=>{H.current!==null&&(window.clearTimeout(H.current),H.current=null);const te=fe.current;if(fe.current="",!te)return;const Ue=new TextEncoder;let We="",St=0;for(const It of te){const ns=Ue.encode(It).byteLength;St+ns>12e3?(ue.current(We),We=It,St=ns):(We+=It,St+=ns)}We&&ue.current(We)},we=Be.onData(te=>{if(fe.current+=te,te.includes("\r")||te.includes(`
574`)||new TextEncoder().encode(fe.current).byteLength>=8e3){ae();return}H.current!==null&&window.clearTimeout(H.current),H.current=window.setTimeout(ae,200)}),Qe=()=>{ae(),J.fit(),ue.current(JSON.stringify({rows:Be.rows,cols:Be.cols}),"resize")},ye=new ResizeObserver(Qe);return ye.observe(oe.current),Qe(),Be.focus(),()=>{ae(),ye.disconnect(),we.dispose(),Be.dispose(),he.current=null,je.current=null}},[A]),u.useEffect(()=>{if(he.current)for(const Be of O){const J=String(Be.id);pe.current.has(J)||(pe.current.add(J),Be.direction!=="input"&&he.current.write(Be.content))}},[O]);const ce=async()=>{z(""),_(!0);try{const Be=await fetch(`${Up(e)}/reauth`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Device-Settings-Context":"diagnostics"},body:JSON.stringify({password:v})});if(!Be.ok)throw new Error((await Be.json().catch(()=>null))?.message||"Unable to send the MFA verification code");const J=await Be.json();w(J.challengeId),k(J.maskedTarget||"your configured MFA destination"),b("")}catch(Be){z(Be.message||"Unable to send the MFA verification code")}finally{_(!1)}},Pe=async()=>{z(""),_(!0);try{const Be=await fetch(`${Up(e)}/sessions`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Device-Settings-Context":"diagnostics"},body:JSON.stringify({challengeId:y,code:j})});if(!Be.ok)throw new Error((await Be.json().catch(()=>null))?.message||"Unable to open terminal");const J=await Be.json();T(J.sessionId),R(J.token),$(J.status||"pending"),q([]),pe.current.clear(),K(0),b(""),w(""),x(""),k(""),g(!1)}catch(Be){z(Be.message||"Unable to open terminal")}finally{_(!1)}},et=(Be,J="stdin")=>{if(!A||!M||!Be&&J==="stdin")return Promise.resolve();const ae=async()=>{Y(!0),z("");try{const we=await Ze("POST",`${Up(e)}/sessions/${A}/input`,{token:M,input:Be,type:J});if(J==="stdin"){const Qe=await we.json();ge(Qe.message?[Qe.message]:[])}}catch(we){z(we.message||"Unable to send terminal input")}finally{Y(!1)}};return le.current=le.current.then(ae,ae),le.current};ue.current=et;const $e=async()=>{if(A&&M)try{await fetch(`${Up(e)}/sessions/${A}`,{method:"DELETE",credentials:"include",headers:{"X-Terminal-Token":M}})}catch{}T(null),R(null),$("closed")},bt=async()=>{if(!A||!M)return;const Be=window.open(`/edge-terminal/${encodeURIComponent(e)}`,"_blank");if(!Be){z("Your browser blocked the terminal window. Allow pop-ups and try again.");return}let J="";const ae=()=>{!J||Be.closed||Be.postMessage({type:"edge-terminal-handoff",edgeDeviceId:e,handoff:J},window.location.origin)},we=ye=>{ye.origin!==window.location.origin||ye.source!==Be||ye.data?.type!=="edge-terminal-ready"||ae()};window.addEventListener("message",we);const Qe=window.setTimeout(()=>window.removeEventListener("message",we),6e4);try{const ye=await fetch(`${Up(e)}/sessions/${A}/handoff`,{method:"POST",credentials:"include",headers:{"X-Terminal-Token":M}});if(!ye.ok)throw new Error("Unable to create terminal handoff");J=(await ye.json()).handoff,ae()}catch(ye){window.clearTimeout(Qe),window.removeEventListener("message",we),Be.close(),z(ye.message||"Unable to open terminal in a 
574new tab")}},Ae=l||!n?l:n.supported?n.online?n.enabled?"":"Enable the capability below before opening a terminal.":"This Edge device is offline.":"This Edge agent does not support the Linux terminal. Update the Edge agent first.";return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-6 p-4 rounded-lg border border-border bg-card",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-sm font-medium flex items-center gap-2",children:[t.jsx(D5,{className:"w-4 h-4"})," Remote Linux Terminal"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Allow superadmins to run commands directly on this Edge device. This is disabled by default and can make system-level changes."}),Ae&&t.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:Ae})]}),t.jsx(sr,{checked:!!n?.enabled,disabled:i||d||!n?.supported,onCheckedChange:me,"data-testid":"switch-remote-linux-terminal"})]}),!A&&t.jsxs(L,{variant:"outline",disabled:i||!n?.enabled||!n?.supported||!n?.online,onClick:()=>{z(""),g(!0)},"data-testid":"button-open-linux-terminal",children:[t.jsx(D5,{className:"w-4 h-4 mr-2"})," Open Linux Terminal"]}),G&&t.jsxs("div",{className:"flex items-start gap-2 text-sm text-destructive",role:"alert","data-testid":"text-terminal-error",children:[t.jsx(Pn,{className:"w-4 h-4 mt-0.5 shrink-0"})," ",t.jsx("span",{children:G})]}),A&&t.jsxs("div",{className:"space-y-2","data-testid":"panel-linux-terminal",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Ke,{variant:D==="active"?"default":"secondary",children:D}),Z&&t.jsx("span",{className:"text-xs text-muted-foreground",children:"Reconnecting…"}),D==="active"&&t.jsx(ar,{className:"w-4 h-4 text-green-500"}),t.jsxs("div",{className:"ml-auto flex gap-2",children:[t.jsxs(L,{size:"sm",variant:"ghost",onClick:()=>{q([]),pe.current.clear(),he.current?.clear()},"data-testid":"button-clear-linux-terminal",children:[t.jsx(tde,{className:"w-4 h-4 mr-1"})," Clear"]}),D==="active"&&!r&&t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>{bt()},"data-testid":"button-open-linux-terminal-new-tab",children:[t.jsx(op,{className:"w-4 h-4 mr-1"})," Open in new tab"]}),t.jsxs(L,{size:"sm",variant:"destructive",onClick:$e,"data-testid":"button-close-linux-terminal",children:[t.jsx(va,{className:"w-4 h-4 mr-1"})," Close"]})]})]}),t.jsx("div",{ref:oe,className:`${r?"h-[calc(100vh-13rem)] min-h-[28rem]":"h-72"} overflow-hidden rounded-md bg-zinc-950 p-2`,"aria-label":"Interactive Linux terminal","data-testid":"output-linux-terminal"}),t.jsx("div",{className:"flex gap-2",children:t.jsx(L,{variant:"outline",onClick:()=>{et("�","interrupt")},disabled:Q||D!=="active",title:"Interrupt current command","data-testid":"button-interrupt-linux-terminal",children:t.jsx(Yce,{className:"w-4 h-4"})})})]}),t.jsx(zd,{open:p,onOpenChange:Be=>{g(Be),Be||(b(""),w(""),x(""),k(""))},children:t.jsxs(bd,{"data-testid":"dialog-open-linux-terminal",children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:"Open remote Linux terminal?"}),t.jsx(Sd,{children:"This gives you direct command-line access to the Edge device. Commands may change or stop services, modify files, or affect recordings. A fresh password and MFA confirmation are required."})]}),t.jsxs("div",{className:"space-y-2 py-2",children:[y?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Enter the six-digit code sent to ",C,"."]}),t.jsx(re,{htmlFor:"terminal-verification-code",children:"MFA verification code"}),t.jsx(ke,{id:"terminal-verification-code",inputMode:"numeric",autoComplete:"one-time-code",maxLength:6,value:j,onChange:Be=>x(Be.target.value.replace(/\D/g,"").slice(0,6)),"data-testid":"input-terminal-verification-code"})]}):t.jsxs(t.Fragment,{children:[t.jsx(re,{htmlFor:"terminal-password",children:"Account password"}),t.jsx(ke,{id:"terminal-password",type:"password",value:v,onChange:Be=>b(Be.target.value),autoComplete:"current-password","data-testid":"input-terminal-password"})]}),G&&t.jsx("p",{className:"text-sm text-destructive",role:"alert",children:G})]}),t.jsxs(jd,{children:[t.jsx(Gc,{disabled:S,children:"Cancel"}),t.jsx(Cd,{disabled:S||(y?j.length!==6:!v),onClick:Be=>{Be.preventDefault(),y?Pe():ce()},"data-testid":"button-confirm-open-linux-terminal",children:S?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):y?"Open Terminal":"Send MFA Code"})]})]})})]})}const _9e={hikvision:[{username:"admin",password:"12345",note:"Legacy default; newer units force a password at setup."}],dahua:[{username:"admin",password:"admin",note:"Legacy default; newer units force a password at setup."}],amcrest:[{username:"admin",password:"admin",note:"Legacy default; newer units force a password at setup."}],axis:[{username:"root",password:"pass",note:"Only on un-initialized units."}],reolink:[{username:"admin",password:"",note:"Blank password on un-initialized units."}],uniview:[{username:"admin",password:"123456"}],lorex:[{username:"admin",password:"000000",note:"Legacy default."}],swann:[{username:"admin",password:"12345"}],vivotek:[{username:"root",password:""}],bosch:[{username:"service",password:"service"}],hanwha:[{username:"admin",password:"4321",note:"Legacy Samsung/Hanwha default."}],samsung:[{username:"admin",password:"4321",note:"Legacy default."}],foscam:[{username:"admin",password:"",note:"Blank password on legacy units."}],tplink:[{username:"admin",password:"admin"}],tvt:[{username:"admin",password:"123456"}],panasonic:[{username:"admin",password:"12345"}]},P9e=[{username:"admin",password:"admin"},{username:"admin",password:"12345"},{username:"admin",password:"123456"}];function p5(e,s=3){const r=[e.manufacturer,e.model,e.name].filter(o=>
574typeof o=="string").join(" ").toLowerCase(),n=[],a=new Set,i=o=>{const l=`${o.username}:${o.password}`;a.has(l)||(a.add(l),n.push(o))};if(r)for(const[o,l]of Object.entries(_9e))r.includes(o)&&l.forEach(i);for(const o of P9e){if(n.length>=s)break;i(o)}return n.slice(0,s)}function G1(e){if(typeof e!="string"||!/%[0-9a-fA-F]{2}/.test(e))return e;try{return decodeURIComponent(e)}catch{return e}}const gV=["UTC","America/New_York","America/Detroit","America/Chicago","America/Denver","America/Phoenix","America/Los_Angeles","America/Anchorage","America/Halifax","America/Toronto","America/Vancouver","America/Mexico_City","America/Bogota","America/Lima","America/Sao_Paulo","America/Argentina/Buenos_Aires","Atlantic/Reykjavik","Europe/London","Europe/Dublin","Europe/Lisbon","Europe/Madrid","Europe/Paris","Europe/Brussels","Europe/Amsterdam","Europe/Berlin","Europe/Zurich","Europe/Rome","Europe/Vienna","Europe/Prague","Europe/Warsaw","Europe/Stockholm","Europe/Oslo","Europe/Copenhagen","Europe/Helsinki","Europe/Athens","Europe/Bucharest","Europe/Istanbul","Europe/Kyiv","Europe/Moscow","Africa/Casablanca","Africa/Lagos","Africa/Cairo","Africa/Johannesburg","Africa/Nairobi","Asia/Jerusalem","Asia/Riyadh","Asia/Dubai","Asia/Tehran","Asia/Karachi","Asia/Kolkata","Asia/Dhaka","Asia/Bangkok","Asia/Jakarta","Asia/Singapore","Asia/Hong_Kong","Asia/Shanghai","Asia/Taipei","Asia/Tokyo","Asia/Seoul","Australia/Perth","Australia/Adelaide","Australia/Sydney","Australia/Brisbane","Pacific/Auckland","Pacific/Honolulu"],xV={"camera-discovery":"Camera Discovery","camera-names":"Camera Names","camera-configuration":"Camera Configuration","import-export":"Import / Export","live-streaming":"Live Streaming","record-options":"Record Options","system-time":"System Time","network-settings":"Network Settings","network-stats":"Network Stats","cloud-storage":"Cloud Storage","ai-detection":"AI Object Detection","ai-plus":"AI+ Features","faces-people":"Faces & People","device-alerts":"Device Alerts","smart-alerts":"Smart Alerts",privacy:"Privacy"};function E9e({value:e,onCommit:s,testId:r}){const[n,a]=u.useState(e);return u.useEffect(()=>{a(e)},[e]),t.jsxs("div",{className:"flex items-center gap-2 min-w-[180px]",children:[t.jsx(km,{min:.3,max:.75,step:.01,value:[n],onValueChange:i=>a(i[0]),onValueCommit:i=>s(i[0]),className:"w-32","data-testid":r}),t.jsx("span",{className:"text-xs tabular-nums w-10 text-right","data-testid":`${r}-value`,children:n.toFixed(2)})]})}function T9e({edgeDeviceId:e,isSuperAdmin:s,isAdmin:r}){const{toast:n}=Hs(),{data:a,isLoading:i}=ze({queryKey:["/api/edge-devices",e,"ai-plus","status"],queryFn:()=>fetch(`/api/edge-devices/${e}/ai-plus/status`).then(b=>b.json())}),{data:o}=ze({queryKey:["/api/edge-devices",e,"ai-plus","usage"],queryFn:()=>fetch(`/api/edge-devices/${e}/ai-plus/usage`).then(b=>b.json()),enabled:r}),[l,c]=u.useState(!1),[d,h]=u.useState(""),p=async b=>{try{await Ze("PUT",`/api/edge-devices/${e}/ai-plus/toggle`,{enabled:b}),Je.invalidateQueries({queryKey:["/api/edge-devices",e,"ai-plus"]}),n({title:b?"AI+ Enabled":"AI+ Disabled"})}catch(y){n({title:"Error",description:y.message,variant:"destructive"})}},g=async()=>{const b=Number(d);if(!b||b<1||b>1e4){n({title:"Invalid limit",description:"Must be between 1 and 10,000",variant:"destructive"});return}try{await Ze("PUT",`/api/edge-devices/${e}/ai-plus/daily-limit`,{limit:b}),Je.invalidateQueries({queryKey:["/api/edge-devices",e,"ai-plus"]}),c(!1),n({title:"Daily limit updated"})}catch(y){n({title:"Error",description:y.message,variant:"destructive"})}};if(i)return t.jsxs("div",{className:"max-w-4xl space-y-4","data-testid":"tab-ai-plus",children:[t.jsx(Bt,{className:"h-8 w-48"}),t.jsx(Bt,{className:"h-24"}),t.jsx(Bt,{className:"h-32"})]});const v=a?Math.min(100,Math.round(a.dailyUsed/a.aiPlusDailyLimit*100)):0;return t.jsxs("div",{className:"max-w-4xl space-y-4","data-testid":"tab-ai-plus",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"AI+ Features"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Manage AI-powered features like Visual Search & Natural Language for this device"})]}),t.jsx("div",{className:"rounded-lg border border-border p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Do,{
574className:"w-5 h-5 text-amber-500"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold",children:"AI+ Visual Search"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:a?.aiPlusEnabled?"Users can draw on paused video to find matching events using AI vision, and search using natural language.":"Enable to allow AI-powered visual search on recordings."})]})]}),r&&t.jsx(sr,{checked:a?.aiPlusEnabled??!1,onCheckedChange:p,"data-testid":"switch-ai-plus-enabled"})]})}),a?.aiPlusEnabled&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(QI,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold",children:"Daily Usage"})]}),t.jsxs(Ke,{variant:v>=90?"destructive":v>=70?"secondary":"outline",className:"text-xs","data-testid":"badge-ai-plus-usage",children:[a.dailyUsed," / ",a.aiPlusDailyLimit," requests"]})]}),t.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:t.jsx("div",{className:`h-2 rounded-full transition-all ${v>=90?"bg-destructive":v>=70?"bg-amber-500":"bg-primary"}`,style:{width:`${v}%`},"data-testid":"progress-ai-plus-usage"})}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.dailyRemaining," requests remaining today"]}),t.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Faces & people and basic object detection requests are unlimited and do not count toward this limit."})]}),s&&t.jsx("div",{className:"rounded-lg border border-border p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Daily Request Limit"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Maximum number of AI+ requests per day across all users on this device"})]}),l?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ke,{type:"number",value:d,onChange:b=>h(b.target.value),className:"w-24 h-8 text-sm",min:1,max:1e4,"data-testid":"input-ai-plus-daily-limit"}),t.jsx(L,{size:"sm",className:"h-8",onClick:g,"data-testid":"button-save-ai-plus-limit",children:t.jsx(Vl,{className:"w-3.5 h-3.5"})}),t.jsx(L,{size:"sm",variant:"ghost",className:"h-8",onClick:()=>c(!1),"data-testid":"button-cancel-ai-plus-limit",children:"Cancel"})]}):t.jsxs(L,{size:"sm",variant:"outline",className:"h-8 text-xs",onClick:()=>{h(String(a.aiPlusDailyLimit)),c(!0)},"data-testid":"button-edit-ai-plus-limit",children:[a.aiPlusDailyLimit,"/day"]})]})}),r&&o&&o.usage.length>0&&t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ba,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold",children:"Today's Usage by User"})]}),t.jsx("div",{className:"space-y-2",children:o.usage.map(b=>t.jsxs("div",{className:"flex items-center justify-between text-sm py-1.5 px-2 rounded bg-muted/30",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-medium truncate","data-testid":`text-ai-usage-user-${b.userId}`,children:b.userName}),t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:b.email})]}),t.jsxs(Ke,{variant:"outline",className:"shrink-0 text-xs","data-testid":`badge-ai-usage-count-${b.userId}`,children:[b.searchCount," requests"]})]},b.userId))})]})]})]})}function A9e(e){if(!e||e<0)return"0 B";const s=["B","KB","MB","GB","TB"];let r=0,n=e;for(;n>=1024&&r<s.length-1;)n/=1024,r++;return`${n.toFixed(n>=100||r===0?0:1)} ${s[r]}`}function M9e({edgeDeviceId:e,salesOrderId:s,isAdmin:r}){const{data:n,isLoading:a}=ze({queryKey:["/api/cloud-storage/settings",e],queryFn:()=>fetch(`/api/cloud-storage/settings/${e}`,{credentials:"include"}).then(g=>g.ok?g.json():null)}),i=!!n?.syncEnabled,{data:o}=ze({queryKey:["/api/cloud-storage/stats",e],queryFn:()=>fetch(`/api/cloud-storage/stats/${e}`,{credentials:"include"}).then(g=>g.ok?g.json():{totalSize:0,videoCount:0}),enabled:i,staleTime:3e4}),{data:l}=ze({queryKey:["/api/edge-quotes",s],queryFn:()=>fetch(`/api/edge-quotes/${s}`,{credentials:"include"}).then(g=>g.ok?g.json():null),enabled:!!s&&r,staleTime:6e4});if(a)return t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[t.jsx(Fe,{className:"h-4 w-4 animate-spin"}),"Loading subscription details…"]});const c=(()=>{const g=l?.storageType??n?.planStorageType;if(g){const v=String(g);return v==="cloud"?"Cloud":v==="hybrid"?"Hybrid (Local + Cloud)":v==="local"?"Local Only":v.charAt(0).toUpperCase()+v.slice(1)}return n?.syncEnabled?"Cloud":"Local Only"})(),d=(()=>{const g=l?.recordingMode??n?.planRecordingMode;return g==="motion"?"All Events (Motion)":g==="247"?"24/7 Continuous":n?.syncMode==="events"?"All Events (Motion)":n?.syncMode==="continuous"?"24/7 Continuous":"—"})(),h=l?.cloudRetentionDays??n?.planRetentionDays??n?.retentionDays,p=n?.lastEdgeSyncAt||n?.lastSyncAt;return t.jsxs("div",{className:"space-y-3","data-testid":"cloud-storage-info",children:[t.jsxs("div",{className:"rounded-lg border border-border p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(pn,{className:"w-4 h-4 text-primary"}),t.jsx("h3",{className:"text-sm font-semibold",children:"Subscription Plan"})]}),t.jsx(Ke,{variant:i?"default":"secondary",className:"text-xs","data-testid":"badge-sync-status",children:i?"Sync Active":"Sync Off"})]}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Storage Type"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-plan-type",children:c})]}),t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Retention"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-retention",children:h?`${h} days`:"—"})]}),t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Recording Mode"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-recording-mode",children:d})]}),r&&n?.storageClass&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Storage Class"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-storage-class",children:n.storageClass})]}),r&&l?.orderNumber&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Sales Order"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-sales-order",children:l.orderNumber})]}),p&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Last Sync"}),t.jsx("p",{className:"text-sm font-medium","data-testid":"text-last-sync",children:new Date(p).toLocaleStr
574ing()})]})]})]}),i&&t.jsxs("div",{className:"rounded-lg border border-border p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx(mf,{className:"w-4 h-4 text-primary"}),t.jsx("h3",{className:"text-sm font-semibold",children:"Cloud Usage"})]}),o?t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Fa,{className:"w-5 h-5 text-muted-foreground"}),t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Stored"}),t.jsx("p",{className:"text-base font-semibold","data-testid":"text-storage-used",children:A9e(o.totalSize||0)})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Vi,{className:"w-5 h-5 text-muted-foreground"}),t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Videos"}),t.jsx("p",{className:"text-base font-semibold","data-testid":"text-video-count",children:(o.videoCount||0).toLocaleString()})]})]})]}):t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(Fe,{className:"h-3 w-3 animate-spin"}),"Loading usage…"]})]})]})}function R9e(e){if(!e)return"";const s=new Date(e).getTime()-Date.now();if(s<=0)return"expired";const r=Math.round(s/6e4),n=Math.floor(r/60),a=r%60;return n>0?`${n}h ${a}m remaining`:`${a}m remaining`}function I9e({siteId:e,siteName:s}){const{toast:r}=Hs(),[n,a]=u.useState("4"),{data:i,isLoading:o}=ze({queryKey:["/api/sites",e,"privacy"],refetchInterval:6e4}),l=()=>Je.invalidateQueries({queryKey:["/api/sites",e,"privacy"]}),c=Et({mutationFn:y=>Ze("PUT",`/api/sites/${e}/privacy`,{enabled:y}),onSuccess:(y,w)=>{l(),r({title:w?"Privacy enabled":"Privacy disabled",description:w?"Administrators can no longer view video for this site.":"Administrators can view video for this site again."})},onError:y=>r({title:"Error",description:y?.message||"Failed to update privacy.",variant:"destructive"})}),d=Et({mutationFn:()=>Ze("POST",`/api/sites/${e}/privacy/temp-support`,{hours:Number(n)}),onSuccess:()=>{l(),r({title:"Temporary support granted",description:`Support can view video for ${n} hour(s).`})},onError:y=>r({title:"Error",description:y?.message||"Failed to grant temporary support.",variant:"destructive"})}),h=Et({mutationFn:()=>Ze("DELETE",`/api/sites/${e}/privacy/temp-support`),onSuccess:()=>{l(),r({title:"Temporary support canceled",description:"Video is private again for Admins and Super Admins."})},onError:y=>r({title:"Error",description:y?.message||"Failed to cancel temporary support.",variant:"destructive"})});if(o||!i)return t.jsxs("div",{className:"max-w-3xl space-y-4","data-testid":"tab-privacy",children:[t.jsx(Bt,{className:"h-8 w-48"}),t.jsx(Bt,{className:"h-40 w-full"})]});const p=i.canModify,g=i.canGrantTempSupport??i.canModify,v=i.enabled,b=!!i.tempSupportExpires;return t.jsxs("div",{className:"max-w-3xl space-y-4","data-testid":"tab-privacy",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-base font-semibold flex items-center gap-2",children:[t.jsx(ka,{className:"w-4 h-4"})," Privacy"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:p?`Privacy keeps your site's video for your eyes only and the users you allow. When it's on, administrators (the people who installed your cameras and/or 3rd party support) can't see any video for ${s} — that means live view, recordings, thumbnails, and downloads/exports are all hidden from them. Device settings and management still work as normal, so your site keeps running. You stay in control: turn privacy on or off anytime, and grant temporary support access when you need help.`:g?`The owner of ${s} controls whether administrators can view video. You can't change that setting, but you can grant administrators temporary support access when they need to help.`:`The owner of ${s} controls whether administrators can view video.`})]}),t.jsxs("div",{className:"rounded-lg border border-border p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("p",{className:"text-sm font-medium",children:"Hide video from administrators"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:v?"Video is private. Administrators cannot view live, recordings, thumbnails, or exports.":"Off — Administrators can view all video for this site."})]}),t.jsx(sr,{checked:v,disabled:!p||c.isPending,onCheckedChange:y=>c.mutate(y),"data-testid":"switch-privacy-enabled"})]}),t.jsx("div",{className:"mt-3 flex items-center gap-2",children:v?t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-500/10 text-amber-600 dar
574k:text-amber-400 px-2 py-0.5 text-[11px] font-medium","data-testid":"status-privacy",children:[t.jsx(ka,{className:"w-3 h-3"})," Video private"]}):t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 px-2 py-0.5 text-[11px] font-medium","data-testid":"status-privacy",children:[t.jsx(Xr,{className:"w-3 h-3"})," Video visible"]})})]}),v&&t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(vi,{className:"w-4 h-4 text-primary"}),t.jsx("p",{className:"text-sm font-medium",children:"Temporary Support Access"})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Grant administrators temporary access to video so they can help troubleshoot. Access is restored automatically when the time is up."}),b?t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-md bg-muted/50 p-3",children:[t.jsxs("div",{className:"text-sm",children:[t.jsx("span",{className:"font-medium text-emerald-600 dark:text-emerald-400",children:"Support access is active"}),t.jsx("span",{className:"text-muted-foreground ml-2","data-testid":"text-temp-remaining",children:R9e(i.tempSupportExpires)})]}),g&&t.jsx(L,{variant:"outline",size:"sm",onClick:()=>h.mutate(),disabled:h.isPending,"data-testid":"button-cancel-temp-support",children:h.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):"Cancel now"})]}):g?t.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-muted-foreground",children:"Duration"}),t.jsxs(Us,{value:n,onValueChange:a,children:[t.jsx($s,{className:"w-32","data-testid":"select-temp-hours",children:t.jsx(zs,{})}),t.jsx(Fs,{children:[1,2,4,6,8,12,24].map(y=>t.jsxs(rt,{value:String(y),children:[y," hour",y>1?"s":""]},y))})]})]}),t.jsx(L,{size:"sm",onClick:()=>d.mutate(),disabled:d.isPending,"data-testid":"button-grant-temp-support",children:d.isPending?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):"Grant access"})]}):t.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No temporary support access is currently active."})]})]})}function O9e({edgeDeviceId:e,siteId:s,companyId:r}){const{toast:n}=Hs(),{data:a=[],isLoading:i}=ze({queryKey:["/api/edge-devices",e,"user-permissions"]}),{data:o}=ze({queryKey:["/api/admin/users"]}),l=o?.users||[],{data:c}=ze({queryKey:["/api/sites",s,"cameras"]}),d=(c?.cameras||[]).filter(ce=>ce.enabled),h=8,[p,g]=u.useState(0),v=Math.max(1,Math.ceil(d.length/h)),b=d.slice(p*h,(p+1)*h),y=l.filter(ce=>{const Pe=ce.role||"user";return Pe==="superadmin"||Pe==="admin"?!1:r?Uje(ce,s,r):!0}),w=Et({mutationFn:ce=>Ze("PUT",`/api/edge-devices/${e}/user-permissions`,ce),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/edge-devices",e,"user-permissions"]}),n({title:"Saved",description:"User permissions updated."})},onError:ce=>{n({title:"Error",description:ce?.message||"Failed to save permissions.",variant:"destructive"})}}),j=ze({queryKey:["/api/edge-devices",e,"my-menus"],queryFn:()=>fetch(`/api/edge-devices/${e}/my-menus`).then(ce=>ce.json()),enabled:!!e}),x=new Set(j.data?.menus||[]),C=!!j.data,[k,S]=u.useState(null),[_,A]=u.useState(new Set),T=k&&l.find(ce=>ce.id===k)?.role||"user",[M,R]=u.useState(!1),[D,$]=u.useState(new Set),[O,q]=u.useState(new Set),[V,K]=u.useState(!1),[G,z]=u.useState(null),Z=ce=>C?new Set(ce.filter(Pe=>x.has(Pe))):new Set,ee=()=>{$(new Set),q(Z(U1)),z(null),R(!0)},Q=ce=>{$(Pe=>{const et=new Set(Pe);return et.has(ce)?et.delete(ce):et.add(ce),et})},Y=(ce,Pe)=>{Pe&&q(et=>{const $e=new Set(et);return $e.has(ce)?$e.delete(ce):$e.add(ce),$e})},oe=()=>$(new Set(y.map(ce=>ce.id))),he=()=>$(new Set),je=async()=>{if(!C){n({title:"Still loading",description:"Your menu permissions are still loading. Try again in a moment.",variant:"destructive"});return}if(D.size===0){n({title:"No users selected",description:"Pick at least one user to apply menus to.",variant:"destructive"});return}K(!0),z(null);const ce=Array.from(O),Pe=Array.from(D);let et=0,$e=[],bt=!1;try{const Be=await(await Ze("PUT",`/api/edge-devices/${e}/user-permissions/bulk`,{userIds:Pe,menuPermissions:ce})).json();et=Be.ok,$e=Be.results.filter(J=>!J.ok).map(J=>({userId:J.userId,message:J.message||"Failed"}))}catch(Ae){const Be=typeof Ae?.message=="string"?Ae.message:"",J=Be.indexOf("{");let ae=null;if(J>=0)try{ae=JSON.parse(Be.slice(J))}catch{}ae&&Array.isArray(ae.results)?(et=ae.ok??0,bt=!!ae.atomic,$e=ae.results.filter(we=>!we.ok).map(we=>({userId:we.userId,message:we.message||"Failed"}))):$e=Pe.map(we=>({userId:we,message:ae?.message||Be||"Failed"}))}z({ok:et,failed:$e}
574),K(!1),Je.invalidateQueries({queryKey:["/api/edge-devices",e,"user-permissions"]}),$e.length===0?(n({title:"Menus applied",description:`Updated ${et} user${et===1?"":"s"}.`}),R(!1)):n(bt?{title:`${$e.length} failed — nothing applied`,description:"No changes were saved. Fix the per-user errors and try again.",variant:"destructive"}:{title:`Applied to ${et}, ${$e.length} failed`,description:"See dialog for details.",variant:"destructive"})},pe=ce=>{const Pe=a.find(bt=>bt.userId===ce),et=l.find(bt=>bt.id===ce)?.role||"user";let $e;Pe?.menuPermissions?$e=Pe.menuPermissions:et==="owner"?$e=U1:$e=[],et==="owner"&&!$e.includes("privacy")&&($e=[...$e,"privacy"]),A(new Set($e)),S(ce)},le=(ce,Pe)=>{Pe&&A(et=>{const $e=new Set(et);return $e.has(ce)?$e.delete(ce):$e.add(ce),$e})},ue=()=>{if(!k)return;const ce=a.find(Pe=>Pe.userId===k);w.mutate({userId:k,restrictedCameras:ce?.restrictedCameras||[],audioRestricted:ce?.audioRestricted??!1,downloadRestricted:ce?.downloadRestricted??!1,menuPermissions:Array.from(_)},{onSuccess:()=>S(null)})},fe=Et({mutationFn:ce=>Ze("DELETE",`/api/edge-devices/${e}/user-permissions/${ce}`),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/edge-devices",e,"user-permissions"]}),n({title:"Removed",description:"User restrictions removed — full access restored."})},onError:()=>{n({title:"Error",description:"Failed to remove permissions.",variant:"destructive"})}}),H=ce=>a.find(Pe=>Pe.userId===ce),se=(ce,Pe)=>{const et=H(ce),$e=et?.restrictedCameras||[],Ae=$e.includes(Pe)?$e.filter(Be=>Be!==Pe):[...$e,Pe];w.mutate({userId:ce,restrictedCameras:Ae,audioRestricted:et?.audioRestricted??!1,downloadRestricted:et?.downloadRestricted??!1})},me=ce=>{const Pe=H(ce);w.mutate({userId:ce,restrictedCameras:Pe?.restrictedCameras||[],audioRestricted:!(Pe?.audioRestricted??!1),downloadRestricted:Pe?.downloadRestricted??!1})},ge=ce=>{const Pe=H(ce);w.mutate({userId:ce,restrictedCameras:Pe?.restrictedCameras||[],audioRestricted:Pe?.audioRestricted??!1,downloadRestricted:!(Pe?.downloadRestricted??!1)})},be=ce=>{fe.mutate(ce)};return i?t.jsxs("div",{className:"max-w-4xl space-y-4","data-testid":"tab-user-permissions",children:[t.jsx(Bt,{className:"h-8 w-48"}),t.jsx(Bt,{className:"h-64 w-full"})]}):t.jsxs("div",{className:"max-w-4xl space-y-4","data-testid":"tab-user-permissions",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"User Permissions"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Control per-user access to cameras, audio, and downloads on this device. Admins are exempt from restrictions."})]}),y.length>0&&t.jsxs(L,{variant:"outline",size:"sm",className:"h-8 gap-1.5 shrink-0",onClick:ee,"data-testid":"button-bulk-edit-menus",children:[t.jsx(xd,{className:"w-3.5 h-3.5"}),"Bulk Edit Menus"]})]}),y.length===0?t.jsx("div",{className:"rounded-lg border border-border p-6 text-center text-sm text-muted-foreground",children:"No owners or users found for this site's organization."}):t.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[v>1&&t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-muted/30 border-b","data-testid":"perm-cam-pagination",children:[t.jsxs(L,{variant:"ghost",size:"sm",className:"h-6 text-[10px] px-1.5 gap-1",onClick:()=>g(ce=>Math.max(0,ce-1)),disabled:p===0,"data-testid":"perm-cam-prev",children:[t.jsx(Kl,{className:"w-3 h-3"})," Prev"]}),t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Cameras ",p*h+1,"–",Math.min((p+1)*h,d.length)," of ",d.length]}),t.jsxs(L,{variant:"ghost",size:"sm",className:"h-6 text-[10px] px-1.5 gap-1",onClick:()=>g(ce=>Math.min(v-1,ce+1)),disabled:p>=v-1,"data-testid":"perm-cam-next",children:["Next ",t.jsx(hi,{className:"w-3 h-3"})]})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b bg-muted/50",children:[t.jsx("th",{className:"text-left py-2.5 px-3 font-medium sticky left-0 bg-muted/50 z-10 min-w-[160px]",children:"User"}),b.map(ce=>t.jsx("th",{className:"text-center py-2.5 px-1.5 font-medium min-w-[56px]",children:t.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[t.jsx(wo,{className:"w-3 h-3 text-muted-foreground"}),t.jsx("span",{className:"text-[10px] leading-tight",children:ce.displayName||ce.name})]})},ce.name)),t.jsx("th",{className:"text-center py-2.5 px-2 font-medium min-w-[56px]",children:t.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[t.jsx(XK,{className:"w-3 h-3 text-muted-foreground"}),t.jsx("span",{className:"text-[10px]",children:"Audio"})]})}),t.jsx("th",{className:"text-center py-2.5 px-2 font-medium min-w-[56px]",children:t.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[t.jsx(ya,{className:"w-3 h-3 text-muted-foreground"}),t.jsx("span",{className:"text-[10px]",children:"Export"})]})}),t.jsx("th",{className:"text-center py-2.5 px-2 font-medium min-w-[80px]",children:t.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[t.jsx(xd,{className:"w-3 h-3 text-muted-foreground"}),t.jsx("span",{className:"text-[10px]",children:"Menus"})]})}),t.jsx("th",{className:"text-center py-2.5 px-2 font-medium min-w-[64px]",children:"Actions"})]})}),t.jsx("tbody",{children:y.map(ce=>{const Pe=H(ce.id),et=Pe?.restrictedCameras||[],$e=et.length>0||Pe?.audioRestricted||Pe?.downloadRestricted,bt=ce.role||"user";return t.jsxs("tr",{className:"border-b last:border-b-0 hover:bg-muted/30 transition-colors",children:[t.jsx("td",{className:"py-2 px-3 sticky left-0 bg-background z-10",children:t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"font-medium text-xs truncate max-w-[140px]",title:`${ce.firstName||""} ${ce.lastName||""}`,children:ce.firstName||ce.lastName?`${ce.firstName||""} ${ce.lastName||""}`.trim():ce.email}),t.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[140px]",children:ce.email}),t.jsx(Ke,{variant:"outline",className:"mt-0.5 text-[9px] px-1 py-0 
574w-fit",children:bt})]})}),b.map(Ae=>{const Be=et.includes(Ae.name);return t.jsx("td",{className:"text-center py-2 px-1.5",children:t.jsx(On,{"data-testid":`perm-camera-${ce.id}-${Ae.name}`,checked:!Be,onCheckedChange:()=>se(ce.id,Ae.name),disabled:w.isPending})},Ae.name)}),t.jsx("td",{className:"text-center py-2 px-2",children:t.jsx(On,{"data-testid":`perm-audio-${ce.id}`,checked:!(Pe?.audioRestricted??!1),onCheckedChange:()=>me(ce.id),disabled:w.isPending})}),t.jsx("td",{className:"text-center py-2 px-2",children:t.jsx(On,{"data-testid":`perm-download-${ce.id}`,checked:!(Pe?.downloadRestricted??!1),onCheckedChange:()=>ge(ce.id),disabled:w.isPending})}),t.jsx("td",{className:"text-center py-2 px-2",children:(()=>{const J=(Pe?.menuPermissions??void 0??(bt==="owner"?U1:[])).length,ae=Gv.length;return t.jsxs(L,{variant:"outline",size:"sm",className:"h-6 text-[10px] px-2",onClick:()=>pe(ce.id),"data-testid":`perm-menus-${ce.id}`,children:[J,"/",ae]})})()}),t.jsx("td",{className:"text-center py-2 px-2",children:$e&&t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 text-[10px] px-1.5",onClick:()=>be(ce.id),disabled:fe.isPending,"data-testid":`perm-clear-${ce.id}`,children:"Reset"})})]},ce.id)})})]})})]}),t.jsx("div",{className:"rounded-lg border border-border p-3 bg-muted/30",children:t.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.jsx("strong",{children:"How it works:"})," Unchecked cameras are hidden from live view and recordings for that user. Unchecked audio mutes playback. Unchecked downloads restricts exports. ",t.jsx("strong",{children:"Menus"})," controls which Device Settings tabs an owner can see and use for this device. All boxes checked = full access (default). Only owners and users within this site's organization are shown — Administrators always have full access."]})}),t.jsx(Ys,{open:!!k,onOpenChange:ce=>{ce||S(null)},children:t.jsxs(Ws,{className:"max-w-md","data-testid":"dialog-edit-menus",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Device Settings Menus"}),t.jsx(cr,{children:"Pick which Device Settings tabs this owner can use for this device. You can only grant menus you yourself have access to."})]}),t.jsx("div",{className:"grid grid-cols-1 gap-2 py-2",children:Gv.map(ce=>{const Pe=ce==="privacy"&&T==="owner",et=C&&x.has(ce),$e=_.has(ce)||Pe,bt=!et||Pe,Ae=Pe?"cursor-default":et?"cursor-pointer hover-elevate":"opacity-60 cursor-not-allowed";return t.jsxs("label",{className:`flex items-center justify-between rounded-md border px-3 py-2 text-sm ${Ae}`,"data-testid":`menu-row-${ce}`,title:Pe?"Owners always have Privacy — it can't be removed.":et?void 0:"You don't have access to this menu","aria-disabled":bt,children:[t.jsx("span",{children:xV[ce]}),t.jsx(On,{checked:$e,disabled:bt,onCheckedChange:()=>le(ce,et&&!Pe),"data-testid":`menu-toggle-${ce}`})]},ce)})}),t.jsxs(In,{children:[t.jsx(L,{variant:"ghost",onClick:()=>S(null),"data-testid":"button-menu-cancel",children:"Cancel"}),t.jsx(L,{onClick:ue,disabled:w.isPending,"data-testid":"button-menu-save",children:w.isPending?"Saving...":"Save"})]})]})}),t.jsx(Ys,{open:M,onOpenChange:ce=>{V||R(ce)},children:t.jsxs(Ws,{className:"max-w-2xl","data-testid":"dialog-bulk-edit-menus",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Bulk Edit Device Settings Menus"}),t.jsx(cr,{children:"Pick the users and the exact menu set to apply. The chosen menus replace each selected user's current menu permissions for this device. You can only grant menus you yourself have access to."})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 py-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("h3",{className:"text-sm font-medium",children:["Users (",D.size,"/",y.length,")"]}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2",onClick:oe,disabled:V,"data-testid":"button-bulk-select-all",children:"All"}),t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2",onClick:he,disabled:V,"data-testid":"button-bulk-select-none",children:"None"})]})]}),t.jsx("div",{className:"rounded-md border max-h-72 overflow-y-auto",children:y.map(ce=>{const Pe=D.has(ce.id),et=ce.role||"user",$e=G?.failed.find(bt=>bt.userId===ce.id);return t.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 border-b last:border-b-0 cursor-pointer hover-elevate","data-testid":`bulk-user-row-${ce.id}`,children:[t.jsx(On,{checked:Pe,disabled:V,onCheckedChange:()=>Q(ce.id),"data-testid":`bulk-user-toggle-${ce.id}`}),t.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[t.jsx("span",{className:"text-xs font-medium truncate",children:ce.firstName||ce.lastName?`${ce.firstName||""} ${ce.lastName||""}`.trim():ce.email}),t.jsx("span",{className:"text-[10px] text-muted-foreground truncate",children:ce.email}),$e&&t.jsx("span",{className:"text-[10px] text-destructive mt-0.5","data-testid":`bulk-user-error-${ce.id}`,children:$e.message})]}),t.jsx(Ke,{variant:"outline",className:"text-[9px] px-1 py-0",children:et})]},ce.id)})})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("h3",{className:"text-sm font-medium",children:["Menus to apply (",O.size,"/",Gv.length,")"]}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2",onClick:()=>q(Z(Gv)),disabled:V||!C,"data-testid":"button-bulk-menus-all",children:"All"}),t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2",onClick:()=>q(new Set),disabled:V,"data-testid":"button-bulk-menus-none",children:"None"}),t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2",onClick:()=>q(Z(U1)),disabled:V||!C,"data-testid":"button-bulk-menus-defaults",children:"Defaults"})]})]}),t.jsx("div",{className:"rounded-md border max-h-72 overflow-y-auto",children:Gv.map(ce=>{const Pe=C&&x.has(ce),et=O.has(ce);return t.jsxs("label",{className:`flex items-center justify-between gap-2 px-3 py-2 border-b last:border-b-0 ${Pe?"cursor-pointer hover-elevate":"opacity-60 cursor-not-allowed"}`,"data-testid":`bulk-menu-row-${ce}`,title:Pe?void 0:"You don't have access to this menu","aria-disabled":!Pe,children:[t.jsx("span",{className:"text-xs",children:xV[ce]}),t.jsx(On,{checked:et,disabled:!Pe||V,onCheckedChange:()=>Y(ce,Pe),"data-testid":`bulk-menu-toggle-${ce}`})]},ce)})})]})]}),G&&G.failed.length>0&&t.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs","data-testid":"bulk-results-summary",children:["Applied to ",G.ok,", ",G.failed.length," failed. See per-user errors above."]}),t.jsxs(In,{children:[t.jsx(L,{variant:"ghost",onClick:()=>R(!1),disabled:V,"data-testid":"button-bulk-cancel",children:"Cancel"}),t.jsx(L,{onClick:je,disabled:V||D.size===0||!C,"data-testid":"button-bulk-apply",children:V?"Applying...":`Apply to ${D.size} user${D.size===1?"":"s"}`})]})]})})]})}function D9e({edgeDeviceId:e,isAdmin:s}){const{toast:r}=Hs(),[n,a]=u.useState(""),[i,o]=u.useState(null),[l,c]=u.useState(""),d=u.useRef(null),[h,p]=u.useState(null),[g,v]=u.useState(!1),b=ze({queryKey:["/api/edge-devices",e,"person-labels"],queryFn:()=>fetch(`/api/edge-devices/${e}/person-labels`).then(A=>A.json()),enabled:!!e}),y=b.data?.labels||[],w=Et({mutationFn:async A=>Ze("POST",`/api/edge-devices/${e}/person-labels`,{name:A}),onSuccess:()=>
574{a(""),Je.invalidateQueries({queryKey:["/api/edge-devices",e,"person-labels"]})},onError:async A=>{const T=A?.message||"Failed to create label";r({title:"Could not add label",description:T,variant:"destructive"})}}),j=Et({mutationFn:async({id:A,name:T})=>Ze("PATCH",`/api/edge-devices/${e}/person-labels/${A}`,{name:T}),onSuccess:()=>{o(null),c(""),Je.invalidateQueries({queryKey:["/api/edge-devices",e,"person-labels"]})},onError:A=>r({title:"Could not rename",description:A?.message||"Error",variant:"destructive"})}),x=Et({mutationFn:async({id:A,name:T,matchThreshold:M})=>Ze("PATCH",`/api/edge-devices/${e}/person-labels/${A}`,{name:T,matchThreshold:M}),onSuccess:()=>Je.invalidateQueries({queryKey:["/api/edge-devices",e,"person-labels"]}),onError:A=>r({title:"Could not update threshold",description:A?.message||"Error",variant:"destructive"})}),C=Et({mutationFn:async A=>Ze("DELETE",`/api/edge-devices/${e}/person-labels/${A}`,void 0),onSuccess:()=>Je.invalidateQueries({queryKey:["/api/edge-devices",e,"person-labels"]}),onError:A=>r({title:"Could not delete",description:A?.message||"Error",variant:"destructive"})}),k=Et({mutationFn:async({labelId:A,imageId:T})=>Ze("DELETE",`/api/edge-devices/${e}/person-labels/${A}/images/${T}`,void 0),onSuccess:()=>Je.invalidateQueries({queryKey:["/api/edge-devices",e,"person-labels"]}),onError:A=>r({title:"Could not remove photo",description:A?.message||"Error",variant:"destructive"})}),S=A=>{p(A),d.current?.click()},_=async A=>{const T=A.target.files?.[0];if(A.target.value="",!(!T||!h)){if(!T.type.startsWith("image/")){r({title:"Image required",description:"Please select an image file",variant:"destructive"});return}if(T.size>7*1024*1024){r({title:"Too large",description:"Reference photos must be under 7 MB",variant:"destructive"});return}v(!0);try{const R=(await new Promise((D,$)=>{const O=new FileReader;O.onload=()=>D(String(O.result||"")),O.onerror=()=>$(new Error("Could not read the file")),O.readAsDataURL(T)})).split(",")[1];if(!R)throw new Error("Could not read the file");await Ze("POST",`/api/edge-devices/${e}/person-labels/${h}/images`,{imageBase64:R,contentType:T.type||"image/jpeg"}),Je.invalidateQueries({queryKey:["/api/edge-devices",e,"person-labels"]})}catch(M){r({title:"Upload failed",description:M?.message||"Error",variant:"destructive"})}finally{v(!1),p(null)}}};return t.jsxs("div",{className:"max-w-4xl space-y-4","data-testid":"tab-faces",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"Faces & People"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Create named person labels with reference photos. AI Text Search will detect these names in your queries and use the reference photos to identify the same person in recordings."})]}),t.jsxs("div",{className:"flex gap-2.5 rounded-lg border border-amber-300/60 bg-amber-50/70 p-3 dark:border-amber-700/50 dark:bg-amber-950/30","data-testid":"notice-face-photo-tips",children:[t.jsx(cde,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400 mt-0.5"}),t.jsxs("div",{className:"text-xs text-amber-900 dark:text-amber-100 leading-relaxed",children:[t.jsx("p",{className:"font-semibold mb-1",children:"Photo quality drives recognition accuracy."}),t.jsxs("p",{className:"mb-1.5",children:["For best results, upload ",t.jsx("strong",{children:"4–6 reference photos"})," of the same person that show real-world variety. Recognition accuracy depends entirely on how well your references represent how the person actually appears on camera."]}),t.jsxs("ul",{className:"list-disc list-inside space-y-0.5 marker:text-amber-600 dark:marker:text-amber-400",children:[t.jsx("li",{children:"Sharp, well-lit photos — avoid motion blur or heavy shadows"}),t.jsx("li",{children:"Face clearly visible and roughly forward-facing (small angle variation is fine)"}),t.jsx("li",{children:"Cropped reasonably tight on the head — not full-body or distant shots"}),t.jsx("li",{children:"Mix of lighting conditions (bright daylight, indoor, dusk) and angles the cameras typically capture"}),t.jsx("li",{children:"Phone selfies and clean headshots usually beat stills pulled from camera footage"})]}),t.jsx("p",{className:"mt-1.5",children:"One or two references taken in a single setting will only match recordings shot in those same conditions — the more variety you provide, the more reliably the same person will be found across the day."})]})]}),t.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:_,"data-testid":"input-face-photo"}),s&&t.jsxs("div",{className:"border border-border rounded-lg p-3 bg-card",children:[t.jsx(re,{className:"text-xs",children:"Add a new person label"}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[t.jsx(ke,{value:n,onChange:A=>a(A.target.value),placeholder:"e.g. Alice, Bob, Driver Mike",maxLength:64,className:"h-9 text-sm","data-testid":"input-new-label-name",onKeyDown:A=>{A.key==="Enter"&&n.trim()&&w.mutate(n.trim())}}),t.jsx(L,{size:"sm",onClick:()=>w.mutate(n.trim()),disabled:!n.trim()||w.isPending,"data-testid":"button-add-label",children:w.isPending?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):t.jsxs(t.Fragment,{children:[t.jsx(Fo,{className:"w-4 h-4 mr-1"}),"Add"]})})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:"Names must be unique on this device. Up to 6 reference photos per person."})]}),b.isLoading?t.jsxs("div",{className:"space-y-2",children:[t.jsx(Bt,{className:"h-24 w-full"}),t.jsx(Bt,{className:"h-24 w-full"})]}):y.length===0?t.jsxs("div",{className:"text-center py-12 border border-dashed rounded-lg border-border",children:[t.jsx(Ba,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:"No person labels yet."}),s&&t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Add a label above to get started."})]}):t.jsx("div",{className:"space-y-3",children:y.map(A=>t.jsxs("div",{className:"border border-border rounded-lg p-3 bg-card","data-testid":`row-label-${A.id}`,children:[t.jsx("div",{className:"flex items-center justify-between gap-2 mb-2",children:i===A.id?t.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[t.jsx(ke,{value:l,onCh
574ange:T=>c(T.target.value),maxLength:64,className:"h-8 text-sm","data-testid":`input-edit-label-${A.id}`,autoFocus:!0}),t.jsx(L,{size:"sm",className:"h-8",onClick:()=>j.mutate({id:A.id,name:l.trim()}),disabled:!l.trim()||j.isPending,"data-testid":`button-save-label-${A.id}`,children:"Save"}),t.jsx(L,{size:"sm",variant:"ghost",className:"h-8",onClick:()=>{o(null),c("")},"data-testid":`button-cancel-label-${A.id}`,children:"Cancel"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ba,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"text-sm font-medium","data-testid":`text-label-name-${A.id}`,children:A.name}),t.jsxs(Ke,{variant:"secondary",className:"text-[10px]",children:[A.imageCount,"/6"]})]}),s&&t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(L,{size:"sm",variant:"ghost",className:"h-8 px-2",onClick:()=>{o(A.id),c(A.name)},"data-testid":`button-rename-label-${A.id}`,children:t.jsx(ga,{className:"w-3.5 h-3.5"})}),t.jsx(L,{size:"sm",variant:"ghost",className:"h-8 px-2 text-destructive hover:text-destructive",onClick:()=>{confirm(`Delete "${A.name}" and all its photos?`)&&C.mutate(A.id)},"data-testid":`button-delete-label-${A.id}`,children:t.jsx(sa,{className:"w-3.5 h-3.5"})})]})]})}),s&&t.jsxs("div",{className:"flex items-center gap-3 mb-2 text-xs",children:[t.jsxs("span",{className:"text-muted-foreground",children:["Enrolled: ",t.jsxs("span",{"data-testid":`text-enrolled-${A.id}`,children:[A.enrolledCount??0,"/",A.images.length]})]}),t.jsx("span",{className:"text-muted-foreground",children:"·"}),t.jsx(re,{className:"text-muted-foreground",title:"Cosine distance — lower = stricter",children:"Match distance"}),t.jsx(E9e,{value:A.matchThreshold??.6,onCommit:T=>{const M=A.matchThreshold??null,R=Math.round(T*100)/100;R!==M&&x.mutate({id:A.id,name:A.name,matchThreshold:R})},testId:`slider-threshold-${A.id}`}),t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"(0.30–0.75, default 0.60, lower = stricter)"})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[A.images.map(T=>{const M=!!T.enrolled,R=T.embeddingError;return t.jsxs("div",{className:"relative group","data-testid":`img-wrap-${T.id}`,children:[t.jsx("img",{src:T.thumbnailPath||T.objectPath,alt:A.name,className:"w-20 h-20 object-cover rounded border border-border","data-testid":`img-face-${T.id}`}),t.jsx("div",{className:`absolute -bottom-1 -left-1 text-[9px] px-1 rounded ${M?"bg-emerald-600 text-white":"bg-amber-500 text-black"}`,title:M?"Face embedded — usable for face recognition":R||"Not enrolled — face-rec sidecar may be unconfigured or no face was detected","data-testid":`status-embed-${T.id}`,children:M?"✓ enrolled":"✕ not enrolled"}),s&&t.jsx("button",{type:"button",className:"absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-0.5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>k.mutate({labelId:A.id,imageId:T.id}),"data-testid":`button-remove-image-${T.id}`,"aria-label":"Remove photo",children:t.jsx(sa,{className:"w-3 h-3"})})]},T.id)}),s&&A.images.length<6&&t.jsx("button",{type:"button",className:"w-20 h-20 rounded border border-dashed border-border flex flex-col items-center justify-center text-muted-foreground hover-elevate active-elevate-2 disabled:opacity-50",onClick:()=>S(A.id),disabled:g,"data-testid":`button-add-photo-${A.id}`,children:g&&h===A.id?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):t.jsxs(t.Fragment,{children:[t.jsx(Om,{className:"w-4 h-4"}),t.jsx("span",{className:"text-[10px] mt-1",children:"Add photo"})]})})]})]},A.id))})]})}function vV(e){const s=new Date(e).getTime();if(Number.isNaN(s))return"";const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<45)return"just now";const n=Math.round(r/60);if(n<60)return`${n} min ago`;const a=Math.round(n/60);if(a<24)return`${a} hr ago`;const i=Math.round(a/24);return`${i} day${i===1?"":"s"} ago`}function L9e(){const e=h_(),r=Ek().siteId||null,[n,a]=Ia(),i=sje(window.location.search,r||void 0),{user:o}=Gi(),{toast:l}=Hs(),c=Er(),{data:d}=ze({queryKey:["/api/companies"],enabled:!!o}),{data:h}=ze({queryKey:["/api/user/role"],enabled:!!o}),p=h?.role==="superadmin",g=h?.role==="admin"||h?.role==="superadmin",v=h?.role==="owner",b=!g,y=d?.find(P=>P.sites?.some(X=>X.id===r)),w=y?.sites?.find(P=>P.id===r),j=w?.edgeDevice?.id,x=!!w?.edgeDevice?.edgeSyncApiKey||!1,C=ze({queryKey:["/api/sites",r,"ai-plus","status"],queryFn:()=>fetch(`/api/sites/${r}/ai-plus/status`).then(P=>P.json()),enabled:!!r,staleTime:60*1e3}),k=C.data?.hasSubscription??!1,S=k&&(C.data?.aiPlusEnabled??!1),_=ze({queryKey:["/api/edge-devices",j,"my-menus"],queryFn:()=>fetch(`/api/edge-devices/${j}/my-menus`).then(P=>P.json()),enabled:!!j,staleTime:30*1e3}),A=new Set(_.data?.menus||[]),T=ze({queryKey:["/api/edge-devices",j],enabled:!!j,staleTime:30*1e3}),M=T.data?.hasSubscriptionPlan??!1,R=!!w&&w.isOnline===!1&&p&&T.data?.allowDiagnosticsIfOffline===!0,D=!M,O=!!ze({queryKey:["/api/cloud-storage/settings",j],queryFn:()=>fetch(`/api/cloud-storage/settings/${j}`,{credentials:"include"}).then(P=>P.ok?P.json():null),enabled:!!j,staleTime:3e4}).data?.syncEnabled,q=_.data?.reason==="no_device_access"||_.data?.reason==="device_not_found",[V,K]=u.useState(()=>{const P=new URLSearchParams(window.location.search).get("tab");return P==="diagnostics"?"diagnostics":P==="camera-configuration"?"streams":"discovery"});u.useEffect(()=>{const P=new URLSearchParams(window.location.search).get("tab");P==="camera-configuration"&&K("streams"),P==="diagnostics"&&K("diagnostics")},[n]);const[G,z]=u.useState(!1),[Z,ee]=u.useState(""),[Q,Y]=u.useState(!1),[oe,he]=u.useState(!1),[je,pe]=u.useState(""),[le,ue]=u.useState(""),[fe,H]=u.useState(!1),[se,me]=u.useState(!1),[ge,be]=u.useState(""),[ce,Pe]=u.useState(""),[et,$e]=u.useState(!1),[bt,Ae]=u.useState(new Set),Be=`truvios.probeCreds.${j}`,J=()=>{try{const P=sessionStorage.getItem(Be);if(!P)return{};const X=JSON.parse(P);return X&&typeof X=="object"?X:{}}catch{return{}}},ae=(P,X)=>{if(P)try{const xe=J();xe[P]=X,sessionStorage.setItem(Be,JSON.stringify(xe))}catch{}},we=P=>{if(!P)return;const X=J()[P];
574if(X&&typeof X.username=="string"&&typeof X.password=="string")return X},[Qe,ye]=u.useState(null),[te,Ue]=u.useState(!1),[We,St]=u.useState(""),It=900*1e3,ns="defaultCredCooldowns",dt=P=>`${P.ipAddress}:${P.port||80}`,Qt=()=>{try{const P=localStorage.getItem(ns);if(!P)return{};const X=JSON.parse(P);if(!X||typeof X!="object")return{};const xe=Date.now(),Ee={};for(const[_t,Me]of Object.entries(X))typeof Me=="number"&&Me>xe&&(Ee[_t]=Me);return Ee}catch{return{}}},[Re,pt]=u.useState(Qt),Ft=P=>{pt(P);try{localStorage.setItem(ns,JSON.stringify(P))}catch{}},Es=(P,X=It)=>{Ft({...Re,[dt(P)]:Date.now()+X})},Ge=P=>{const X=P instanceof Error?P.message:"";if(!X.startsWith("429:"))return null;try{const xe=JSON.parse(X.slice(X.indexOf(":")+1).trim());if(xe?.defaultCredCooldown&&typeof xe.cooldownRemainingMs=="number")return Math.max(1e3,xe.cooldownRemainingMs)}catch{}return null},ft=P=>{const X={...Re};delete X[dt(P)],Ft(X)},[He,zt]=u.useState(()=>Date.now());u.useEffect(()=>{if(!Object.values(Re).some(xe=>xe>Date.now()))return;const X=setInterval(()=>{zt(Date.now()),pt(xe=>{const Ee=Date.now(),_t=Object.entries(xe).filter(([,st])=>st>Ee);if(_t.length===Object.keys(xe).length)return xe;const Me=Object.fromEntries(_t);try{localStorage.setItem(ns,JSON.stringify(Me))}catch{}return Me})},1e3);return()=>clearInterval(X)},[Re]);const fs=P=>{const X=Re[dt(P)];return X?Math.max(0,X-He):0},Ce=P=>{const X=Math.ceil(P/1e3),xe=Math.floor(X/60),Ee=X%60;return xe>0?`${xe}:${String(Ee).padStart(2,"0")}`:`0:${String(Ee).padStart(2,"0")}`},[Dt,ne]=u.useState(""),[Oe,De]=u.useState(!1),[jt,Ct]=u.useState(!1),[Lt,xr]=u.useState(!1),[qe,Xt]=u.useState({}),[Ut,gt]=u.useState(!1),[es,br]=u.useState(!1),[fr,xn]=u.useState({}),[Br,Pi]=u.useState(!1),[Qn,ii]=u.useState(null),[ua,Ua]=u.useState(!1),[Ln,Ir]=u.useState(new Set),[Hr,lt]=u.useState(null),[Rt,At]=u.useState({}),[Ht,vr]=u.useState({displayName:"",enabled:!0,mainStreamUrl:"",subStreamUrl:"",motionThreshold:30,motionContourArea:20,detectEnabled:!0,useGo2rtc:!1}),mn={brand:"",model:"",ip:"",port:"554",user:"",pass:""},[hr,Sn]=u.useState(mn),[Sr,Os]=u.useState(!1),[ur,nr]=u.useState({}),[qr,So]=u.useState(null),[Xn,Jr]=u.useState(!1),[vn,Mn]=u.useState({}),[Dr,en]=u.useState({}),[Co,Oa]=u.useState(()=>Date.now()),[ku,ma]=u.useState(!1),[lo,Cn]=u.useState(!1),[Lr,Vr]=u.useState(null),[Nc,Ds]=u.useState(!1),[nl,co]=u.useState(!1),fn=Et({mutationFn:()=>Ze("DELETE",`/api/sites/${r}`),onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/companies"]}),Je.invalidateQueries({queryKey:["/api/subscriptions"]}),Je.invalidateQueries({queryKey:["/api/subscription-summary"]}),Je.invalidateQueries({queryKey:["/api/edge-devices"]}),Je.invalidateQueries({queryKey:["/api/cloud-storage/settings"]}),l({title:"Success",description:"Site deactivated successfully"}),a("/")},onError:()=>{l({title:"Error",description:"Failed to deactivate site",variant:"destructive"})}}),[bi,Sc]=u.useState(!1),[ra,za]=u.useState(""),[Xl,Ei]=u.useState(""),[na,Ur]=u.useState(!1),[Da,Xc]=u.useState(new Set),[oi,Zl]=u.useState(!1),al=u.useRef(null),[Zc,il]=u.useState(null),[Jl,Uo]=u.useState(!1),[Cc,Ti]=u.useState(""),[oa,ja]=u.useState([]),[Tr,zo]=u.useState([]),[ha,Jc]=u.useState([]),[ol,zn]=u.useState(!1),[ll,yn]=u.useState({done:0,total:0}),[cl,ko]=u.useState(!1),[dl,Cl]=u.useState([]),[Ho,Ha]=u.useState({}),[Ai,Bs]=u.useState(null),[ti,ec]=u.useState(!1),[uo,Na]=u.useState(!1),[La,kc]=u.useState(null),[_c,tn]=u.useState(!0),[qo,Hn]=u.useState(""),[mo,qn]=u.useState(""),[_o,tm]=u.useState(""),[Pd,wi]=u.useState(""),[tc,ul]=u.useState(!1),[Pc,_u]=u.useState([]),[Ec,Tc]=u.useState(!1),Ea=u.useRef(!1),Ac=u.useRef(null),[Ed,ed]=u.useState(""),[Ah,td]=u.useState(""),[Vo,nn]=u.useState(!1),[Um,Pu]=u.useState(!1),[sd,sc]=u.useState(!1),Wo=u.useRef(null),[Mh,Td]=u.useState(!1),[qa,Qs]=u.useState([]),[rc,Eu]=u.useState(!1),[Po,la]=u.useState(null),[Rh,ml]=u.useState(null),[rd,Mc]=u.useState(""),[Mi,nc]=u.useState(null),[kl,Ri]=u.useState(null),[ho,ac]=u.useState(null),[tr,_l]=u.useState([]),[nd,hl]=u.useState([]),[Rc,sm]=u.useState(!1),[Eo,pl]=u.useState(!1),[U,_e]=u.useState(!1),[qt,Zt]=u.useState(!1);u.useEffect(()=>{w?.edgeDevice&&Zt(w.edgeDevice.colorMatchingEnabled??!1)},[w?.edgeDevice?.colorMatchingEnabled]);const[Rs,ir]=u.useState("mse"),[Vn,Ns]=u.useState(2),[or,os]=u.useState(100),[nt,tt]=u.useState(!1),[$t,kr]=u.useState(!1),[Wn,zr]=u.useState(!1),$n=u.useRef(null),[Va,Yi]=u.useState(5),[Ii,To]=u.useState(5),[Qi,Ls]=u.useState(!1),[Or,Pl]=u.useState(!1),[Oi,ad]=u.useState(!0),[ji,Wa]=u.useState(60),[Ic,Tu]=u.useState(!1),[id,El]=u.useState("all"),[Di,Xi]=u.useState([]),[tu,bn]=u.useState(30),[Tl,od]=u.useState(20),[ld,Al]=u.useState(!1),[Ni,rm]=u.useState(!1),[Ko,Ad]=u.useState(!1),[Ml,qg]=u.useState(null),[zm,Au]=u.useState(W4),[I
574h,cd]=u.useState({}),[Oh,Zi]=u.useState(!1),[Hm,Mu]=u.useState(null),Oc=P=>Ni&&Ic&&(id==="all"||Di.includes(P)),nm=P=>!Ni||Oc(P),yp=u.useCallback(async()=>{if(j)try{const P=await fetch(`/api/edge-devices/${j}/pending-config`,{credentials:"include"});if(!P.ok)return;const X=await P.json();ma(!!X.hasPending),Ar(X.lastApplyError||null)}catch{}},[j]),Ru=async()=>{if(r)try{const P=await fetch(`/api/sites/${r}/record-options`,{credentials:"include"});if(!P.ok)return;const X=await P.json();Yi(typeof X.preCaptureSec=="number"?X.preCaptureSec:5),To(typeof X.postCaptureSec=="number"?X.postCaptureSec:5),Ls(!!X.preferLegacyCloudClip),Pl(!!X.cloudClipDirectStream),ad(X.subStreamRolloverEnabled!==!1),Wa(typeof X.subStreamRolloverIntervalMinutes=="number"?X.subStreamRolloverIntervalMinutes:60),Tu(X.globalMotionEnabled===!0),El(X.globalMotionScope==="selected"?"selected":"all"),Xi(Array.isArray(X.globalMotionCameraNames)?X.globalMotionCameraNames.filter(xe=>typeof xe=="string"):[]),bn(typeof X.globalMotionSensitivity=="number"?X.globalMotionSensitivity:30),od(typeof X.globalMotionThreshold=="number"?X.globalMotionThreshold:20),Au({...W4,...X.exportOverlays||{}}),cd({}),Al(!1),rm(!0)}catch{}},su=async()=>{if(r){Zi(!0),Mu(null);try{const P=await fetch(`/api/sites/${r}/record-options`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({exportOverlays:Ih})});if(!P.ok){const xe=await P.text();l({title:"Save failed",description:xe.substring(0,200),variant:"destructive"});return}const X=await P.json();X.exportOverlays&&Au({...W4,...X.exportOverlays}),cd({}),Mu(Date.now()),Je.invalidateQueries({queryKey:["/api/sites",r,"record-options"]}),l({title:"Saved",description:"Export overlay options are ready for future video downloads."})}catch(P){l({title:"Save failed",description:P?.message||"Could not save export options.",variant:"destructive"})}finally{Zi(!1)}}},po=async P=>{if(!r)return;const X=yt=>Math.max(0,Math.min(60,Math.round(Number.isFinite(yt)?yt:5))),xe=yt=>Math.max(1,Math.min(1440,Math.round(Number.isFinite(yt)?yt:60))),Ee=P?.preferLegacyCloudClip??!!Qi,_t=P?.cloudClipDirectStream??!!Or,Me=P?.subStreamRolloverEnabled??!!Oi,st=xe(P?.subStreamRolloverIntervalMinutes??ji),ot=P?.globalMotionEnabled??!!Ic,Nt=P?.globalMotionUpdate??ld,Gt={preCaptureSec:X(Va),postCaptureSec:X(Ii),preferLegacyCloudClip:Ee,cloudClipDirectStream:_t,subStreamRolloverEnabled:Me,subStreamRolloverIntervalMinutes:st,globalMotionEnabled:ot,updateGlobalMotion:Nt,globalMotionScope:id,globalMotionCameraNames:Di,globalMotionSensitivity:Math.max(1,Math.min(255,Math.round(tu||30))),globalMotionThreshold:Math.max(10,Math.min(50,Math.round(Tl||20)))};Ad(!0);try{const yt=await fetch(`/api/sites/${r}/record-options`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(Gt)});if(yt.ok){const hs=await yt.json();Yi(hs.preCaptureSec),To(hs.postCaptureSec),Ls(!!hs.preferLegacyCloudClip),Pl(!!hs.cloudClipDirectStream),typeof hs.subStreamRolloverEnabled=="boolean"&&ad(hs.subStreamRolloverEnabled),typeof hs.subStreamRolloverIntervalMinutes=="number"&&Wa(hs.subStreamRolloverIntervalMinutes),Tu(hs.globalMotionEnabled===!0),El(hs.globalMotionScope==="selected"?"selected":"all"),Xi(Array.isArray(hs.globalMotionCameraNames)?hs.globalMotionCameraNames:[]),typeof hs.globalMotionSensitivity=="number"&&bn(hs.globalMotionSensitivity),typeof hs.globalMotionThreshold=="number"&&od(hs.globalMotionThreshold),Al(!1),qg(Date.now()),Je.invalidateQueries({queryKey:["/api/sites",r,"record-options"]}),Md(),await yp(),P?.silent||l({title:"Saved",description:"Changes are pending. Use Apply Changes in YAML Config to push them to the device."})}else{const hs=await yt.text();l({title:"Save failed",description:hs.substring(0,200),variant:"destructive"})}}catch(yt){l({title:"Save failed",description:yt.message,variant:"destructive"})}finally{Ad(!1)}},[Dh,Rl]=u.useState(()=>Z0()),[Il,Go]=u.useState(!1),[fl,Ol]=u.useState(!1),[Af,gl]=u.useState(!1),[Dc,Lc]=u.useState(!1),[Iu,Ou]=u.useState(!1),[Ta,$c]=u.useState(!1),[fo,Zn]=u.useState(()=>typeof window<"u"?localStorage.getItem(`superadmin_showlocal_${r}`)==="true":!1),hn=P=>{Zn(P),r&&(P?localStorage.setItem(`superadmin_showlocal_${r}`,"true"):localStorage.removeItem(`superadmin_showlocal_${r}`))},[Ao,Sa]=u.useState(!1),[Aa,dd]=u.useState(180),[Dl,li]=u.useState("180"),[Fc,F]=u.useState(!1),[ve,Te]=u.useState(null),ht=u.useRef(null),kt=[{category:"People",objects:["person"]},{category:"Vehicles",objects:["car","motorcycle","bicycle","airplane","bus","train","truck","boat"]},{category:"Traffic & Street",objects:["traffic light","fire hydrant","stop sign","parking meter","bench"]},{category:"Animals",objects:["bird","cat","dog","horse","sheep","cow","elephant","bear","zebra","giraffe"]},{category:"Outdoor & Accessories",objects:["backpack","umbrella","handbag","tie","suitcase"]},{category:"Sports & Recreation",objects:["frisbee","skis","snowboard","sports ball","kite","baseball bat","baseball glove","skateboard","surfboard","tennis racket"]},{category:"Food & Drink",objects:["bottle","wine glass","cup","fork","knife","spoon","bowl","banana","apple","sandwich","orange","broccoli","carrot","hot dog","pizza","donut","cake"]},{category:"Indoor & Household Items",objects:["chair","couch","potted plant","bed","dining table","toilet","tv","laptop","mouse","remote","keyboard","cell phone","microwave","oven","toaster","sink","refrigerator","book","clock","vase","scissors","teddy bear","hair drier","toothbrush"]}],us=async()=>
574{if(j){sm(!0);try{const P=await fetch(`/api/edge-devices/${j}/ai-objects`,{credentials:"include"});if(!P.ok)throw new Error("Failed to load");const X=await P.json();_l(X.trackedObjects||[]),hl(X.trackedObjects||[]),_e(!0)}catch(P){l({title:"Error",description:P.message||"Failed to load AI object settings",variant:"destructive"})}finally{sm(!1)}}},ts=(P,X)=>{_l(xe=>X?xe.includes(P)?xe:[...xe,P]:xe.filter(Ee=>Ee!==P))},is=async()=>{if(j){pl(!0);try{const P=await Ze("PUT",`/api/edge-devices/${j}/ai-objects`,{trackedObjects:tr});if(!P.ok)throw new Error("Failed to save");const X=await P.json();hl(X.trackedObjects||tr),ma(!0),l({title:"Saved",description:"AI object detection settings saved as pending. Click Apply Changes to deploy."})}catch(P){l({title:"Error",description:P.message||"Failed to save AI settings",variant:"destructive"})}finally{pl(!1)}}},js=U&&JSON.stringify([...tr].sort())!==JSON.stringify([...nd].sort()),ms=async P=>{if(Zt(P),!!j)try{await Ze("PATCH",`/api/edge-devices/${j}/color-matching`,{enabled:P}),Je.invalidateQueries({queryKey:["/api/companies"]})}catch{Zt(!P),l({title:"Error",description:"Failed to save color matching setting",variant:"destructive"})}},[gs,Ar]=u.useState(null);u.useEffect(()=>{if(!j)return;let P=!1;const X=()=>{fetch(`/api/edge-devices/${j}/pending-config`,{credentials:"include"}).then(Ee=>Ee.json()).then(Ee=>{P||(ma(!!Ee.hasPending),Ar(Ee.lastApplyError||null))}).catch(()=>{})};X();const xe=setInterval(X,1e4);return()=>{P=!0,clearInterval(xe)}},[j]);const si=async()=>{if(r)try{const P=await fetch(`/api/sites/${r}/stream-options`,{credentials:"include",headers:V==="diagnostics"?{"X-Device-Settings-Context":"diagnostics"}:void 0});if(!P.ok)return;const X=await P.json(),xe={protocol:X.protocol??"mse",jpegFps:X.jpegFps??2,jpegQuality:X.jpegQuality??100,debugWebRtc:X.debugWebRtc??!1,forceSubStreamLive:X.forceSubStreamLive??!1};$n.current=xe,ir(xe.protocol),Ns(xe.jpegFps),os(xe.jpegQuality),tt(xe.debugWebRtc),kr(xe.forceSubStreamLive),zr(!0)}catch{}},Ka=async P=>{if(!(!r||!P))try{if(!(await fetch(`/api/sites/${r}/stream-options`,{method:"PUT",headers:{"Content-Type":"application/json",...V==="diagnostics"?{"X-Device-Settings-Context":"diagnostics"}:{}},credentials:"include",body:JSON.stringify(P)})).ok)return;
574$n.current=P,Je.invalidateQueries({queryKey:["/api/sites",r,"stream-options"]})}catch{}};u.useEffect(()=>{if(!Wn||!r)return;const P=$n.current,X={protocol:Rs,jpegFps:Vn,jpegQuality:or,debugWebRtc:nt,forceSubStreamLive:$t};if(P&&Object.keys(X).every(Ee=>P[Ee]===X[Ee]))return;const xe=setTimeout(()=>{Ka(X)},600);return()=>clearTimeout(xe)},[Rs,Vn,or,nt,$t,Wn,r]),u.useEffect(()=>{j&&(V==="network"&&dl.length===0&&!cl&&an(),V==="system-time"&&x&&!La&&!ti&&Ep(),V==="aidetection"&&!U&&!Rc&&us(),V==="yamlconfig"&&!sd&&!Vo&&tx(),(V==="stream-options"||V==="diagnostics")&&!Wn&&si(),!Ni&&r&&Ru(),(V==="cloud-storage"||V==="diagnostics")&&!Ta&&r&&(fetch(`/api/sites/${r}/cloud-preferences`,{credentials:"include",headers:V==="diagnostics"?{"X-Device-Settings-Context":"diagnostics"}:void 0}).then(P=>P.ok?P.json():null).then(P=>{P&&(Go(P.hideLocalRecordings??!1),Ol(P.hybridRetrievalEnabled??!1),gl(P.distinguishHybridSources??!1),Ou(P.hybridPreferencesHidden??!1),Lc(P.hideHybridRetrievalPreferences??!1)),$c(!0)}).catch(()=>$c(!0)),fetch(`/api/cloud-storage/settings/${j}`,{credentials:"include"}).then(P=>P.ok?P.json():null).then(P=>{if(!P)return;ht.current=P;const X=Number.isInteger(P.clipDurationSeconds)?Math.max(10,Math.min(300,P.clipDurationSeconds)):180;dd(X),li(String(X))}).catch(()=>{})))},[V,j,r,Ni]),u.useEffect(()=>{if(j)return()=>{fetch(`/api/edge-devices/${j}/discovered-cameras`,{method:"DELETE",credentials:"include"}).catch(()=>{}),Je.removeQueries({queryKey:["/api/edge-devices",j,"discovered-cameras"]})}},[j]);const{data:Wr=[],refetch:dn}=ze({queryKey:["/api/edge-devices",j,"discovered-cameras"],queryFn:async()=>{if(!j)return[];const P=await fetch(`/api/edge-devices/${j}/discovered-cameras`,{credentials:"include"});return P.ok?(await P.json()).map(xe=>({...xe,manufacturer:G1(xe.manufacturer),model:G1(xe.model),name:G1(xe.name),firmwareVersion:G1(xe.firmwareVersion)})):[]},enabled:!!j,refetchInterval:G||oe?5e3:!1}),Yo=V==="diagnostics",{data:Ji}=ze({queryKey:["/api/edge-devices",j,"ai-config-assist","status",Yo],queryFn:async()=>{const P=await fetch(`/api/edge-devices/${j}/ai-config-assist/status`,{credentials:"include",headers:Yo?{"X-Device-Settings-Context":"diagnostics"}:void 0});return P.ok?P.json():{enabled:!1,aiAvailable:!1}},enabled:!!j}),pi=!!Ji?.enabled&&!!Ji?.aiAvailable;u.useEffect(()=>{if(!(V!=="discovery"||!pi||!j||Lt)){try{if(NBe(localStorage))return}catch{}xr(!0),Ct(!0)}},[V,pi,j,Lt]);const{data:Pr,isLoading:am,refetch:Md}=ze({queryKey:["/api/sites",r,"cameras"],enabled:!!r&&(V==="streams"||V==="camera-names"||V==="discovery"||V==="camera-import-export"),staleTime:0}),{data:wn=[]}=ze({queryKey:["/api/edge-devices",j,"cameras-ptz"],enabled:!!j&&(V==="streams"||V==="camera-import-export"),staleTime:5e3}),Li=new Map(wn.map(P=>[P.channelName,P])),[fi,aa]=u.useState(null),{data:eo}=ze({queryKey:["/api/edge-devices",j,"camera-health"],enabled:!!j&&V==="streams",refetchInterval:V==="streams"?3e4:!1,staleTime:1e4}),Bc=new Map((eo?.cameras||[]).map(P=>[P.channelName,P])),Vg=new Map((eo?.detection||[]).map(P=>[P.cameraName,P])),Lh=Et({mutationFn:async P=>(await Ze("POST",`/api/edge-devices/${j}/cameras/${P}/ptz/test`,{})).json(),onMutate:P=>aa(P),onSettled:(P,X,xe)=>{aa(Ee=>Ee===xe?null:Ee),Je.invalidateQueries({queryKey:["/api/edge-devices",j,"cameras-ptz"]}),Je.invalidateQueries({queryKey:["/api/sites",r,"cameras",xe,"ptz-info"]})},onSuccess:(P,X)=>{P.enabled?l({title:`PTZ enabled on ${X}`,description:P.message}):l({variant:"destructive",title:`PTZ test failed on ${X}`,description:P.message})},onError:(P,X)=>{l({variant:"destructive",title:`PTZ test error on ${X}`,description:P?.message||"Could not run the PTZ connectivity test."})}}),[ru,Wg]=u.useState(null),Uc=Et({mutationFn:async({cameraName:P,enabled:X})=>(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${P}`,{enabled:X})).json(),onMutate:({cameraName:P})=>Wg(P),onSettled:(P,X,xe)=>{Wg(Ee=>Ee===xe.cameraName?null:Ee)},onSuccess:(P,X)=>{P?.success?(ma(!0),Je.setQueryData(["/api/sites",r,"cameras"],xe=>xe?.cameras?{...xe,cameras:xe.cameras.map(Ee=>Ee.name===X.cameraName?{...Ee,enabled:X.enabled}:Ee)}:xe),l({title:X.enabled?`${X.cameraName} enabled`:`${X.cameraName} disabled`,description:P.message||"Restart the Edge device to apply."})):l({variant:"destructive",title:"Could not update Camera State",description:P?.message||"Unknown error"})},onError:(P,X)=>{l({variant:"destructive",title:`Failed to toggle ${X.cameraName}`,description:P?.message||"Please try again."})}}),[yv,qm]=u.useState(null),Mf=Et({mutationFn:async({cameraName:P,recordEnabled:X})=>(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${P}`,{recordEnabled:X})).json(),onMutate:({cameraName:P})=>qm(P),onSettled:(P,X,xe)=>{qm(Ee=>Ee===xe.cameraName?null:Ee)},onSuccess:(P,X)=>{P?.success?(ma(!0),Je.setQueryData(["/api/sites",r,"cameras"],xe=>xe?.cameras?{...xe,cameras:xe.cameras.map(Ee=>{if(Ee.name!==X.cameraName)return Ee;const _t=Array.isArray(Ee.streams)?Ee.streams:[];if(_t.length===0)return Ee;let Me=_t.findIndex(ot=>Array.isArray(ot.roles)&&ot.roles.includes("record"));Me<0&&(Me=_t.findIndex(ot=>!Array.isArray(ot.roles)||!ot.roles.includes("detect"))),Me<0&&(Me=_t.length-1);const st=_t.map((ot,Nt)=>{if(Nt!==Me)return ot;const Gt=new Set(Array.isArray(ot.roles)?ot.roles:[]);return X.recordEnabled?Gt.add("record"):Gt.delete("record"),{...ot,roles:Array.from(Gt)}});return{...Ee,streams:st,record:{...Ee.record||{},enabled:X.recordEnabled}}})}:xe),l({title:X.recordEnabled?`Recording enabled on ${X.cameraName}`:`Recording disabled on ${X.cameraName}`,description:P.message||"Restart the Edge device to apply."})):l({variant:"destructive",title:"Could not update Record Video",description:P?.message||"Unknown error"})},onError:(P,X)=>{l({variant:"destructive",title:`Failed to toggle recording on ${X.cameraName}`,description:P?.message||"Please try again."})}}),[Kg,im]=u.useState(null),bp=Et({mutationFn:async({cameraName:P,prioritizeStorage:X})=>(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${P}`,{prioritizeStorage:X})).json(),onMutate:({cameraName:P})=>im(P),onSettled:(P,X,xe)=>{im(Ee=>Ee===xe.cameraName?null:Ee)},onSuccess:(P,X)=>{P?.success?(ma(!0),Je.setQueryData(["/api/edge-devices",j,"camera-health"],xe=>{const Ee=Array.isArray(xe?.cameras)?xe.cameras:[],_t=Ee.some(ot=>ot.channelName===X.cameraName),Me=P.recordingSource==="main"||P.recordingSource==="sub"?P.recordingSource:X.prioritizeStorage?"sub":"main",st=_t?Ee.map(ot=>ot.channelName===X.cameraName?{...ot,prioritizeStorage:X.prioritizeStorage,recordingSource:Me,lastFailureReason:null}:ot):[...Ee,{channelName:X.cameraName,mainStreamOk:null,subStreamOk:null,recordingSource:Me,prioritizeStorage:X.prioritizeStorage,lastFailureReason:null,lastCheckedAt:null}];return{...xe||{},cameras:st}}
574),Je.invalidateQueries({queryKey:["/api/edge-devices",j,"camera-health"]}),l({title:X.prioritizeStorage?`Adaptive Storage enabled on ${X.cameraName}`:`Adaptive Storage disabled on ${X.cameraName}`,description:P.message||"Apply changes to save to the Edge device."})):l({variant:"destructive",title:"Could not update Adaptive Storage",description:P?.message||"Unknown error"})},onError:(P,X)=>{l({variant:"destructive",title:`Failed to toggle Adaptive Storage on ${X.cameraName}`,description:P?.message||"Please try again."})}}),[Gg,Rf]=u.useState(null),Vm=Et({mutationFn:async({cameraName:P,streamShifting:X})=>(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${P}`,{streamShifting:X})).json(),onMutate:({cameraName:P})=>Rf(P),onSettled:(P,X,xe)=>{Rf(Ee=>Ee===xe.cameraName?null:Ee)},onSuccess:(P,X)=>{P?.success?(X.streamShifting||ma(!0),Je.setQueryData(["/api/edge-devices",j,"camera-health"],xe=>{const Ee=Array.isArray(xe?.cameras)?xe.cameras:[],Me=Ee.some(st=>st.channelName===X.cameraName)?Ee.map(st=>st.channelName===X.cameraName?{...st,streamShifting:X.streamShifting,...X.streamShifting?{}:{detectSource:"sub"}}:st):[...Ee,{channelName:X.cameraName,mainStreamOk:null,subStreamOk:null,recordingSource:"main",streamShifting:X.streamShifting,lastFailureReason:null,lastCheckedAt:null}];return{...xe||{},cameras:Me}}),l({title:X.streamShifting?`Stream Shifting enabled on ${X.cameraName}`:`Stream Shifting disabled on ${X.cameraName}`,description:X.streamShifting?"Detection may automatically shift to the main stream if the sub stream stops delivering video.":P.message||"Detection will use the sub stream. Apply changes to save to the Edge device."})):l({variant:"destructive",title:"Could not update Stream Shifting",description:P?.message||"Unknown error"})},onError:(P,X)=>{l({variant:"destructive",title:`Failed to toggle Stream Shifting on ${X.cameraName}`,description:P?.message||"Please try again."})}}),[bv,Wm]=u.useState(null),Du=Et({mutationFn:async({cameraName:P,audioEnabled:X})=>(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${P}`,{audioEnabled:X})).json(),onMutate:({cameraName:P})=>Wm(P),onSettled:(P,X,xe)=>{Wm(Ee=>Ee===xe.cameraName?null:Ee)},onSuccess:(P,X)=>{P?.success?(ma(!0),Je.setQueryData(["/api/sites",r,"cameras"],xe=>xe?.cameras?{...xe,cameras:xe.cameras.map(Ee=>{if(Ee.name!==X.cameraName)return Ee;const _t=Array.isArray(Ee.streams)?Ee.streams:[];if(_t.length===0)return Ee;let Me=_t.findIndex(ot=>Array.isArray(ot.roles)&&ot.roles.includes("record"));Me<0&&(Me=_t.findIndex(ot=>!Array.isArray(ot.roles)||!ot.roles.includes("detect"))),Me<0&&(Me=_t.length-1);const st=_t.map((ot,Nt)=>{if(Nt!==Me)return ot;const Gt=new Set(Array.isArray(ot.roles)?ot.roles:[]);return X.audioEnabled?Gt.add("audio"):Gt.delete("audio"),{...ot,roles:Array.from(Gt)}});return{...Ee,streams:st}})}:xe),l({title:X.audioEnabled?`Audio enabled on ${X.cameraName}`:`Audio disabled on ${X.cameraName}`,description:P.message||"Restart the Edge device to apply."})):l({variant:"destructive",title:"Could not update Record Audio",description:P?.message||"Unknown error"})},onError:(P,X)=>{l({variant:"destructive",title:`Failed to toggle audio on ${X.cameraName}`,description:P?.message||"Please try again."})}}),[Km,If]=u.useState(null),Yg=Et({mutationFn:async({cameraName:P,aiEventsEnabled:X})=>(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${P}`,{aiEventsEnabled:X})).json(),onMutate:({cameraName:P})=>If(P),onSettled:(P,X,xe)=>{If(Ee=>Ee===xe.cameraName?null:Ee)},onSuccess:(P,X)=>{P?.success?(ma(!0),Je.setQueryData(["/api/sites",r,"cameras"],xe=>xe?.cameras?{...xe,cameras:xe.cameras.map(Ee=>{if(Ee.name!==X.cameraName)return Ee;const _t=Array.isArray(Ee.streams)?Ee.streams:[];if(_t.length===0)return Ee;if(X.aiEventsEnabled){let st=_t.findIndex(Nt=>Array.isArray(Nt.roles)&&Nt.roles.includes("detect"));st<0&&(st=_t.findIndex(Nt=>/(_sub|\/sub)/i.test(Nt.path||""))),st<0&&(st=0);const ot=_t.map((Nt,Gt)=>{if(Gt!==st)return Nt;const yt=new Set(Array.isArray(Nt.roles)?Nt.roles:[]);return yt.add("detect"),{...Nt,roles:Array.from(yt)}});return{...Ee,streams:ot,detect:{...Ee.detect||{},enabled:!0}}}const Me=_t.map(st=>!Array.isArray(st.roles)||!st.roles.includes("detect")?st:{...st,roles:st.roles.filter(ot=>ot!=="detect")});return{...Ee,streams:Me,detect:{...Ee.detect||{},enabled:!1}}})}:xe),l({title:X.aiEventsEnabled?`AI events enabled on ${X.cameraName}`:`AI events disabled on ${X.cameraName}`,description:P.message||"Restart the Edge device to apply."})):l({variant:"destructive",title:"Could not update Record AI Events",description:P?.message||"Unknown error"})},onError:(P,X)=>{l({variant:"destructive",title:`Failed to toggle AI events on ${X.cameraName}`,description:P?.message||"Please try again."})}}),[Of,wp]=u.useState(null),Gm=Et({mutationFn:async({cameraName:P,useGo2rtc:X})=>(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${P}`,{useGo2rtc:X})).json(),onMutate:({cameraName:P})=>wp(P),onSettled:(P,X,xe)=>
574{wp(Ee=>Ee===xe.cameraName?null:Ee)},onSuccess:(P,X)=>{P?.success?(ma(!0),Je.setQueryData(["/api/sites",r,"cameras"],xe=>xe?.cameras?{...xe,cameras:xe.cameras.map(Ee=>Ee.name===X.cameraName?{...Ee,usesGo2rtc:X.useGo2rtc}:Ee)}:xe),l({title:X.useGo2rtc?`WebRTC enabled on ${X.cameraName}`:`WebRTC disabled on ${X.cameraName}`,description:P.message||"Restart the Edge device to apply."})):l({variant:"destructive",title:"Could not update Web Streaming",description:P?.message||"Unknown error"})},onError:(P,X)=>{l({variant:"destructive",title:`Failed to toggle Web Streaming on ${X.cameraName}`,description:P?.message||"Please try again."})}}),ic=Et({mutationFn:async P=>(await Ze("POST",`/api/edge-devices/${j}/cameras/${P}/ptz/disable`,{})).json(),onSuccess:(P,X)=>{Je.invalidateQueries({queryKey:["/api/edge-devices",j,"cameras-ptz"]}),Je.invalidateQueries({queryKey:["/api/sites",r,"cameras",X,"ptz-info"]}),l({title:`PTZ disabled on ${X}`})},onError:(P,X)=>{l({variant:"destructive",title:`Failed to disable PTZ on ${X}`,description:P?.message||"Please try again."})}}),om=P=>{const X=P.streams.find(yt=>yt.roles.includes("record")),xe=P.streams.find(yt=>yt.roles.includes("detect")),Ee=yt=>!!yt&&/^rtsp:\/\/(?:127\.0\.0\.1|localhost):/i.test(yt),_t=P.usesGo2rtc?P.go2rtcUrl||(Ee(X?.path)?"":X?.path||""):X?.path||"",Me=P.usesGo2rtc?P.go2rtcSubUrl||(Ee(xe?.path)?"":xe?.path||""):xe?.path||"";vr({displayName:P.displayName||P.name,enabled:P.enabled,mainStreamUrl:_t,subStreamUrl:Me,motionThreshold:P.motion?.threshold??30,motionContourArea:P.motion?.contour_area??20,detectEnabled:P.detect?.enabled!==!1,useGo2rtc:!!P.usesGo2rtc});const st=c9(_t),ot=P.quickConnectBrand||"",Nt=P.quickConnectModel||"",Gt=ot&&Nt?lm(ot,Nt):void 0;Sn({brand:Gt?ot:"",model:Gt?Nt:"",ip:st.ip,port:st.port||(Gt?String(Gt.port):"554"),user:st.user,pass:st.pass}),Os(!1),lt(P.name)},jp=async(P,X)=>{if(!j)return;const xe=X.trim();if(!xe){l({title:"Name required",description:"Display name cannot be empty.",variant:"destructive"});return}So(P);try{const _t=await(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${P}`,{displayName:xe})).json();_t.success?(l({title:"Name updated",description:`${P} → ${xe}`}),ma(!0),nr(Me=>{const st={...Me};return delete st[P],st}),Mn(Me=>{if(Me[P]===void 0)return Me;const st={...Me};return delete st[P],st}),Je.invalidateQueries({queryKey:["/api/sites",r,"cameras"]})):l({title:"Error",description:_t.message,variant:"destructive"})}catch(Ee){l({title:"Error",description:Ee.message||"Failed to update display name",variant:"destructive"})}finally{So(null)}},Qg=async()=>{if(!j)return;const P=(Pr?.cameras||[]).filter(X=>X.enabled).map(X=>X.name);if(P.length===0){l({title:"No cameras",description:"Add and enable cameras before suggesting names.",variant:"destructive"});return}Jr(!0);try{const xe=await(await Ze("POST",`/api/edge-devices/${j}/ai-config-assist/suggest-names`,{cameras:P.slice(0,16)})).json(),Ee=xe.suggestions||[];if(Ee.length===0){l({title:"No suggestions",description:"The AI could not suggest names from the current snapshots.",variant:"destructive"});return}nr(Me=>{const st={...Me};for(const ot of Ee)st[ot.camera]=ot.name;return st}),Mn(Object.fromEntries(Ee.map(Me=>[Me.camera,Me.name])));const _t=Array.isArray(xe.failed)&&xe.failed.length>0?` (${xe.failed.length} snapshot(s) unavailable)`:"";l({title:"AI suggested names",description:`Review and edit ${Ee.length} suggestion(s), then Save.${_t}`})}catch(X){l({title:"AI naming failed",description:X.message||"Could not suggest camera names.",variant:"destructive"})}finally{Jr(!1)}},nu=async()=>{if(!j)return;const P=Object.entries(vn).map(([Ee,_t])=>({camera:Ee,name:(ur[Ee]??_t).trim()})).filter(Ee=>Ee.name.length>0);if(P.length===0)return;Jr(!0);let X=0;const xe=[];try{for(const Ee of P)try{(await(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${Ee.camera}`,{displayName:Ee.name})).json()).success?X++:xe.push(Ee.camera)}catch{xe.push(Ee.camera)}X>0&&(ma(!0),nr(Ee=>{const _t={...Ee};for(const Me of P)xe.includes(Me.camera)||delete _t[Me.camera];return _t}),Mn(Ee=>{const _t={...Ee};for(const Me of P)xe.includes(Me.camera)||delete _t[Me.camera];return _t}
574),Je.invalidateQueries({queryKey:["/api/sites",r,"cameras"]})),xe.length===0?l({title:"Names saved",description:`${X} camera name(s) updated.`}):l({title:X>0?"Partially saved":"Error",description:`${X} saved, ${xe.length} failed (${xe.join(", ")}).`,variant:"destructive"})}finally{Jr(!1)}},gi=async P=>{if(!j)return;const X=(Ht.mainStreamUrl||"").trim(),xe=(Ht.subStreamUrl||"").trim();if(!X&&!xe){l({title:"Nothing to test",description:"Enter at least one RTSP URL.",variant:"destructive"});return}At(Ee=>({...Ee,[P]:{status:"running"}}));try{const Ee=await Ze("POST",`/api/edge-devices/${j}/test-stream`,{mainUrl:X||void 0,subUrl:xe||void 0}),{commandId:_t}=await Ee.json();if(!_t)throw new Error("Server did not return a command id");const Me=Date.now()+45e3;let st=null;for(;Date.now()<Me;){await new Promise(yt=>setTimeout(yt,800));const Nt=await fetch(`/api/edge-devices/${j}/commands/${_t}/status`,{credentials:"include"});if(!Nt.ok)continue;const Gt=await Nt.json();if(Gt.status==="completed"||Gt.status==="failed"){st=Gt;break}}if(!st){At(Nt=>({...Nt,[P]:{status:"error",message:"Timed out waiting for the edge device to respond."}}));return}if(st.status==="failed"){At(Nt=>({...Nt,[P]:{status:"error",message:st.result||"Stream test failed"}}));return}let ot=null;try{ot=JSON.parse(st.result||"{}")}catch{}if(!ot||!ot.main&&!ot.sub){At(Nt=>({...Nt,[P]:{status:"error",message:ot?.error||"Unexpected response from edge device"}}));return}At(Nt=>({...Nt,[P]:{status:"done",main:ot.main,sub:ot.sub}}))}catch(Ee){At(_t=>({..._t,[P]:{status:"error",message:Ee?.message||"Failed to start stream test"}}))}},Np=async P=>{if(j){Cn(!0);try{const xe=await(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${P}`,{enabled:Ht.enabled,mainStreamUrl:Ht.mainStreamUrl||void 0,subStreamUrl:Ht.subStreamUrl||void 0,motionThreshold:Ht.motionThreshold,motionContourArea:Ht.motionContourArea,detectEnabled:Ht.detectEnabled,useGo2rtc:Ht.useGo2rtc,quickConnectBrand:hr.brand||null,quickConnectModel:hr.model||null})).json();xe.success?(l({title:"Camera updated",description:xe.message}),ma(!0),lt(null),At(Ee=>{const{[P]:_t,...Me}=Ee;return Me}),Je.invalidateQueries({queryKey:["/api/sites",r,"cameras"]})):l({title:"Error",description:xe.message,variant:"destructive"})}catch(X){l({title:"Error",description:X.message||"Failed to update camera",variant:"destructive"})}finally{Cn(!1)}}},Xg=async P=>{if(j){Cn(!0);try{const xe=await(await Ze("DELETE",`/api/edge-devices/${j}/frigate-config/cameras/${P}`)).json();xe.success?(l({title:"Camera cleared",description:xe.message}),ma(!0),Vr(null),Je.invalidateQueries({queryKey:["/api/sites",r,"cameras"]})):l({title:"Error",description:xe.message,variant:"destructive"})}catch(X){l({title:"Error",description:X.message||"Failed to clear camera",variant:"destructive"})}finally{Cn(!1)}}},Lu=async()=>{if(!(!j||!ra||Da.size===0)){Zl(!0);try{const X=await(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/bulk-credentials`,{cameras:Array.from(Da),username:ra,password:Xl})).json();X.success?(l({title:"Credentials updated",description:X.message}),ma(!0),Sc(!1),za(""),Ei(""),Xc(new Set)):l({title:"Error",description:X.message,variant:"destructive"})}catch(P){l({title:"Error",description:P.message||"Failed to update credentials",variant:"destructive"})}finally{Zl(!1)}}},$u=JR,Sp=P=>`${P.series} | ${P.model}`,lm=(P,X)=>Dj.find(xe=>xe.brand===P&&Sp(xe)===X),Ym=(P,X)=>{if(!X)return 1;const xe=/^ch0*(\d+)$/i.exec(P);if(!xe)return 1;const Ee=parseInt(xe[1],10);return Number.isFinite(Ee)&&Ee>=1?Ee:1},Cp=(P,X,xe,Ee)=>{const _t=X.type==="NVR"||X.type==="DVR",Me=Ym(Ee,_t),st=Uze(Me,Bze(X)),ot=(xe.port||"").trim()||String(X.port);let Nt=P.replaceAll("[user]",encodeURIComponent(xe.user||"")).replaceAll("[pass]",encodeURIComponent(xe.pass||"")).replaceAll("[ip]",xe.ip||"").replaceAll("[ch]",st);return ot&&ot!==String(X.port)&&(Nt=Nt.replace(/^(rtsp:\/\/(?:[^@\/]*@)?)([^:\/?#]+)(?::\d+)?/i,`$1$2:${ot}`)),Nt},au=["Camera_Name","Camera_Or_NVR","IP_Address","RTSP_Port","User","Password","Motion_Sens","Motion_Threshold"],Rd=P=>{if(P.quickConnectBrand&&P.quickConnectModel){const X=lm(P.quickConnectBrand,P.quickConnectModel);if(X&&(X.type==="NVR"||X.type==="DVR"))return"NVR"}return"Camera"},Qm=P=>{const X=P.streams?.find(xe=>Array.isArray(xe.roles)&&xe.roles.includes("record"))||P.streams?.[0];return P.usesGo2rtc&&P.go2rtcUrl?P.go2rtcUrl:X?.path||""},cm=P=>{const X=P.streams?.find(xe=>Array.isArray(xe.roles)&&xe.roles.includes("detect"));return P.usesGo2rtc&&P.go2rtcSubUrl?P.go2rtcSubUrl:X?.path||""},iu=P=>{const X=Qm(P),xe=c9(X);return{Camera_Name:P.displayName||P.name,Camera_Or_NVR:Rd(P),IP_Address:xe.ip,RTSP_Port:xe.port||"554",User:xe.user,Password:xe.pass,Motion_Sens:String(P.motion?.contour_area??20),Motion_Threshold:String(P.motion?.threshold??30)}},oc=(P,X)=>{if(!P)return"";const Ee=/^rtsp:\/\/(?:[^@\/]*@)?[^\/?#]*(.*)$/i.exec(P)?.[1]||"",_t=X.user||X.pass?`${encodeURIComponent(X.user)}:${encodeURIComponent(X.pass)}@`:"",Me=X.port?`:${X.port}`:"";return`rtsp://${_t}${X.ip}${Me}${Ee}`},kp=P=>{const X=P.trim();return X?/^(\d{1,3}\.){3}\d{1,3}$/.test(X)?X.split(".").every(xe=>{const Ee=parseInt(xe,10);return Ee>=0&&Ee<=255}):/^(?=.{1,253}$)([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(X):!1},ud=(P,X,xe)=>{const Ee=new Blob([P],{type:xe}),_t=URL.createObjectURL(Ee),Me=document.createElement("a");Me.href=_t,Me.download=X,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),setTimeout(()=>URL.revokeObjectURL(_t),1e3)},Df=async P=>{const X=Pr?.cameras||[];if(X.length===0){l({title:"No cameras to export",variant:"destructive"});return}const xe=X.map(iu),Ee=w?.edgeDevice?.serialNumber||"cameras",_t=new Date,Me=`${_t.getFullYear()}${String(_t.getMonth()+1).padStart(2,"0")}${String(_t.getDate()).padStart(2,"0")}`,st=`cameras-${Ee}-${Me}`;if(P==="csv"){const Nt=(await fg(async()=>{const{default:Gt}=await import("./papaparse.min-CeqaA8Dl.js").then(yt=>yt.p);return{default:Gt}},[])).default.unparse({fields:[...au],data:xe.map(Gt=>au.map(yt=>Gt[yt]))});ud(Nt,`${st}.csv`,"text/csv;charset=utf-8")}else{const ot=await fg(()=>import("./xlsx-CNerDvZX.js"),[]),Nt=ot.utils.json_to_sheet(xe,{header:[...au]}),Gt=ot.utils.book_new();ot.utils.book_append_sheet(Gt,Nt,"Cameras");const yt=ot.write(Gt,{type:"array",bookType:"xlsx"});ud(yt,`${st}.xlsx`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")}l({title:"Export ready",description:`${xe.length} camera(s) exported as ${P.toUpperCase()}.`})},ci=async P=>{Ti(P.name);let X=[];try{const Nt=P.name.toLowerCase();if(Nt.endsWith(".xlsx")||Nt.endsWith(".xls")){const Gt=await fg(()=>import("./xlsx-CNerDvZX.js"),[]),yt=await P.arrayBuffer(),hs=Gt.read(yt,{type:"array"}),jn=hs.Sheets[hs.SheetNames[0]];X=Gt.utils.sheet_to_json(jn,{defval:""})}else{const Gt=(await fg(async()=>{const{default:jn}=await import("./papaparse.min-CeqaA8Dl.js").then(so=>so.p);return{default:jn}},[])).default,yt=await P.text();X=Gt.parse(yt,{header:!0,skipEmptyLines:!0}).data}}catch(Nt){l({title:"Could not parse file",description:Nt?.message||"Unsupported file format.",variant:"destructive"});return}if(X.length===0){l({title:"Empty file",description:"No data rows found.",variant:"destructive"});return}const xe=Object.keys(X[0]).map(Nt=>String(Nt).trim()),Ee=au.filter(Nt=>!xe.includes(Nt));if(Ee.length>0){l({title:"Missing columns",description:`Required: ${Ee.join(", ")}`,variant:"destructive"});return}const _t=Pr?.cameras||[],Me=[],st=[],ot=[];
574X.forEach((Nt,Gt)=>{const yt=Gt+2,hs=Fi=>String(Nt[Fi]??"").trim(),jn=hs("Camera_Name");if(!jn){ot.push({rowNumber:yt,cameraName:"(blank)",message:"Camera_Name is required"});return}const so=hs("IP_Address"),Zm=hs("RTSP_Port")||"554",go=hs("User"),xl=hs("Password"),lu=hs("Motion_Sens")||"20",dm=hs("Motion_Threshold")||"30";if(!kp(so)){ot.push({rowNumber:yt,cameraName:jn,message:`Invalid IP_Address / hostname "${so}"`});return}const Od=parseInt(Zm,10);if(!Number.isFinite(Od)||Od<1||Od>65535){ot.push({rowNumber:yt,cameraName:jn,message:`Invalid RTSP_Port "${Zm}"`});return}const Jm=parseInt(lu,10),eh=parseInt(dm,10);if(!Number.isFinite(Jm)||Jm<10||Jm>50){ot.push({rowNumber:yt,cameraName:jn,message:`Motion_Sens must be 10–50 (got "${lu}")`});return}if(!Number.isFinite(eh)||eh<1||eh>255){ot.push({rowNumber:yt,cameraName:jn,message:`Motion_Threshold must be 1–255 (got "${dm}")`});return}const vl=jn.toLowerCase(),xo=_t.find(Fi=>(Fi.displayName||Fi.name).toLowerCase()===vl)||_t.find(Fi=>Fi.name.toLowerCase()===vl);if(!xo){ot.push({rowNumber:yt,cameraName:jn,message:"No camera with this name exists. Import does not create new cameras."});return}const Tp=iu(xo),Fh={Camera_Name:jn,Camera_Or_NVR:Tp.Camera_Or_NVR,IP_Address:so,RTSP_Port:String(Od),User:go,Password:xl,Motion_Sens:String(Jm),Motion_Threshold:String(eh)},jv=["Camera_Name","IP_Address","RTSP_Port","User","Password","Motion_Sens","Motion_Threshold"].filter(Fi=>Tp[Fi]!==Fh[Fi]).map(Fi=>({field:Fi,from:Fi==="Password"?Tp[Fi]?"••••":"(empty)":Tp[Fi]||"(empty)",to:Fi==="Password"?Fh[Fi]?"••••":"(empty)":Fh[Fi]||"(empty)"})),rx={matchedChannel:xo.name,row:{rowNumber:yt,cameraName:jn,cameraOrNvr:hs("Camera_Or_NVR"),ipAddress:so,rtspPort:String(Od),user:go,pass:xl,motionSens:Jm,motionThreshold:eh},changes:jv,newMainStreamUrl:void 0,newSubStreamUrl:void 0},rw=["IP_Address","RTSP_Port","User","Password"];if(jv.some(Fi=>rw.includes(Fi.field))){const Fi=Qm(xo);if(!Fi){ot.push({rowNumber:yt,cameraName:jn,message:"Camera has no existing stream URL to update; edit in the form first."});return}rx.newMainStreamUrl=oc(Fi,{ip:so,port:String(Od),user:go,pass:xl});const Nv=cm(xo);Nv&&(rx.newSubStreamUrl=oc(Nv,{ip:so,port:String(Od),user:go,pass:xl}))}jv.length===0?st.push(rx):Me.push(rx)}),ja(Me),zo(st),Jc(ot),Uo(!0)},_p=async()=>{if(!j||oa.length===0)return;zn(!0),yn({done:0,total:oa.length});let P=0,X=0;for(const _t of oa){try{const Me={motionThreshold:_t.row.motionThreshold,motionContourArea:_t.row.motionSens};_t.changes.some(Nt=>Nt.field==="Camera_Name")&&(Me.displayName=_t.row.cameraName),_t.newMainStreamUrl&&(Me.mainStreamUrl=_t.newMainStreamUrl),_t.newSubStreamUrl&&(Me.subStreamUrl=_t.newSubStreamUrl),(await(await Ze("PUT",`/api/edge-devices/${j}/frigate-config/cameras/${_t.matchedChannel}`,Me)).json()).success?P++:X++}catch{X++}yn(Me=>({...Me,done:Me.done+1}))}let xe=!1;if(P>0){try{await Ze("POST",`/api/edge-devices/${j}/apply-config`),ma(!1),Ar(null),xe=!0}catch{ma(!0)}Je.invalidateQueries({queryKey:["/api/sites",r,"cameras"]})}zn(!1);const Ee=X===0&&(P===0||xe);Ee&&(Uo(!1),ja([]),zo([]),Jc([]),Ti("")),l({title:Ee?"Import complete":"Import finished with errors",description:`${P} applied, ${Tr.length} skipped, ${X+ha.length} errored.`,variant:Ee?"default":"destructive"}),Ee&&P>0&&(await Je.refetchQueries({queryKey:["/api/sites/restarting"]}),setTimeout(()=>a("/"),800))},Pp=async()=>{if(j){Ds(!0);try{const X=await(await Ze("POST",`/api/edge-devices/${j}/apply-config`)).json();X.success?(l({title:"Changes applied",description:"Configuration saved and Edge device is restarting. This may take a minute."}),ma(!1),Ar(null),await Je.refetchQueries({queryKey:["/api/sites/restarting"]}),setTimeout(()=>a("/"),800)):l({title:"Error",description:X.message||"Apply failed",variant:"destructive"})}catch(P){l({title:"Error",description:P.message||"Failed to apply changes",variant:"destructive"})}finally{Ds(!1)}}},Mo=async()=>{if(j)try{await Ze("DELETE",`/api/edge-devices/${j}/pending-config`),ma(!1),l({title:"Changes discarded",description:"Pending configuration changes have been discarded."})}catch(P){l({title:"Error",description:P.message||"Failed to discard changes",variant:"destructive"})}},ou=u.useRef(!0);u.useEffect(()=>(ou.current=!0,()=>{ou.current=!1}),[]);const Ll=async(P,X,xe)=>{for(let Me=0;Me<40;Me++){if(await new Promise(st=>setTimeout(st,3e3)),!ou.current)return;try{const st=await fetch(`/api/edge-devices/${j}/commands/${P}/status`,{credentials:"include"});if(!ou.current)return;if(st.status===404){xe("Command not found. The server may have restarted — please try again.");return}if(!st.ok)continue;const ot=await st.json();if(ot.status==="completed"){X(ot);return}else if(ot.status==="failed"){xe(ot.result||"Command failed on device");return}dn()}catch{}}ou.current&&xe("Timed out waiting for response from the edge device")},$h=async()=>
574{if(j){z(!0);try{const P=Z.split(/[\s,]+/).map(_t=>_t.trim()).filter(Boolean),Ee=(await(await Ze("POST",`/api/edge-devices/${j}/camera-scan`,{extraSubnets:P})).json()).commandId;l({title:"Scan initiated",description:"Scanning the network for cameras..."}),await Ll(Ee,()=>{dn(),z(!1),l({title:"Scan complete",description:"Network scan finished. Check results below."})},_t=>{dn(),z(!1),l({title:"Scan issue",description:_t,variant:"destructive"})})}catch(P){l({title:"Scan failed",description:P.message||"Could not start camera scan",variant:"destructive"}),z(!1)}}},ca=P=>{const X=P.trim().match(/^(\d{1,3}(?:\.\d{1,3}){3})(?::(\d{1,5}))?$/);if(!X||X[1].split(".").some(Ee=>parseInt(Ee,10)>255))return null;const xe=X[2]?parseInt(X[2],10):80;return xe<1||xe>65535?null:{ip:X[1],port:xe}},to=async()=>{if(!j)return;const P=Dt.trim(),X=P?ca(P):null;if(P&&!X){l({title:"Invalid address",description:"Enter an IP like 192.168.1.200 or IP:port like 192.168.1.200:8080",variant:"destructive"});return}if(!(bt.size===0&&!X)){if(!je){l({title:"RTSP username required",description:"Enter RTSP credentials to retrieve stream URLs",variant:"destructive"});return}if(se&&!ge.trim()){l({title:"ONVIF username required",description:"Enter the separate ONVIF username, or turn off separate ONVIF credentials",variant:"destructive"});return}he(!0);try{const xe=Wr.filter(st=>bt.has(st.id)).map(st=>({ip:st.ipAddress,port:st.port||80}));X&&!xe.some(st=>st.ip===X.ip&&st.port===X.port)&&xe.push(X);const Me=(await(await Ze("POST",`/api/edge-devices/${j}/camera-probe`,{targets:xe,username:je,password:le,...se?{onvifUsername:ge,onvifPassword:ce}:{}})).json()).commandId;l({title:"Probe initiated",description:`Probing ${xe.length} camera(s) for stream URLs...`}),await Ll(Me,async st=>{let ot,Nt;try{const[hs,jn]=await Promise.all([dn(),Md()]);ot=hs.data,Nt=jn.data}catch(hs){console.warn("Probe completed but failed to refetch lists:",hs)}he(!1),Ae(new Set),ne(""),l({title:"Probe complete",description:st?.result||"Camera probe finished."});const Gt=ot||Wr,yt=Gt.filter(hs=>hs.rtspMainStream);for(const hs of yt){if(!bt.has(hs.id))continue;const jn=(hs.manufacturer||"").trim().toLowerCase();jn&&ae(jn,{username:je,password:le})}yt.length>0&&Mt(null,Gt,Nt)},st=>{dn(),he(!1),l({title:"Probe failed",description:st,variant:"destructive"})})}catch(xe){l({title:"Probe failed",description:xe.message||"Could not start camera probe",variant:"destructive"}),he(!1)}}},$i=async()=>{if(j)try{await Ze("DELETE",`/api/edge-devices/${j}/discovered-cameras`),dn(),Ae(new Set),l({title:"Cleared",description:"All discovered cameras removed."})}catch{l({title:"Error",description:"Failed to clear cameras",variant:"destructive"})}},Lf=async P=>{try{await Ze("DELETE",`/api/discovered-cameras/${P}`),dn(),Ae(X=>{const xe=new Set(X);return xe.delete(P),xe})}catch{l({title:"Error",description:"Failed to remove camera",variant:"destructive"})}},I=(P,X,xe)=>{if(!P||!X)return P;try{const Ee=new URL(P);return Ee.username=X,Ee.password=xe,Ee.toString()}catch{const Ee=P.match(/^(rtsp:\/\/)(.*)$/);return Ee?`${Ee[1]}${encodeURIComponent(X)}:${encodeURIComponent(xe)}@${Ee[2]}`:P}},ie=P=>{const X=_t=>{if(!_t)return null;try{return new URL(_t).hostname||null}catch{const Me=_t.match(/^[a-z]+:\/\/(?:[^@/]+@)?([^/:?#]+)/i);return Me?Me[1]:null}},xe=_t=>!!_t&&_t!=="127.0.0.1"&&_t.toLowerCase()!=="localhost",Ee=X(P.go2rtcUrl);if(xe(Ee))return Ee;for(const _t of P.streams||[]){const Me=X(_t.path);if(xe(Me))return Me}return null},Le=P=>{const X=P.channels;return Array.isArray(X)?X.filter(xe=>xe&&typeof xe.mainStream=="string"&&xe.mainStream):[]},Ye=P=>{const X=[];for(const xe of P){const Ee=Le(xe);if(Ee.length>1)for(const _t of Ee)X.push({key:`${xe.id}::${_t.channel}`,cam:xe,channelNo:_t.channel,mainStream:_t.mainStream,subStream:_t.subStream||null});else Ee.length===1?X.push({key:xe.id,cam:xe,channelNo:null,mainStream:Ee[0].mainStream,subStream:Ee[0].subStream||null}):xe.rtspMainStream&&X.push({key:xe.id,cam:xe,channelNo:null,mainStream:xe.rtspMainStream,subStream:xe.rtspSubStream||null})}return X},Mt=(P,X,xe)=>{const Ee=(X||Wr).filter(ot=>ot.rtspMainStream);if(Ee.length===0){l({title:"No probed cameras",description:"Probe at least one camera first to retrieve its stream URLs.",variant:"destructive"});return}const _t=P?Ee.filter(ot=>ot.id===P):Ee,Me=Ye(_t),st={};for(const ot of Me){const Nt=ot.cam,Gt=[Nt.manufacturer,Nt.model,Nt.ipAddress.split(".").pop()].filter(
574Boolean).join(" ").trim()||`Camera ${Nt.ipAddress}`,yt=ot.channelNo!=null?`${Gt} Ch ${ot.channelNo}`:Gt;st[ot.key]={channelName:"",displayName:yt,useGo2rtc:!0}}if(xn(st),Ua(!1),Ir(new Set),ii(P||null),!je&&!le)for(const ot of _t){const Nt=(ot.manufacturer||"").trim().toLowerCase(),Gt=we(Nt);if(Gt){pe(Gt.username),ue(Gt.password);break}}br(!0)},_s=Wr.filter(P=>P.rtspMainStream).filter(P=>!Qn||P.id===Qn),ks=Ye(_s),Ts=ks.some(P=>!fr[P.key]?.channelName),ls=P=>{if(Ua(P),!P){xn(ot=>{const Nt={...ot};for(const Gt of Ln)Nt[Gt]&&(Nt[Gt]={...Nt[Gt],channelName:""});return Nt}),Ir(new Set);return}const X=(Pr?.cameras||[]).filter(ot=>/^ch\d{2,}$/.test(ot.name)).slice().sort((ot,Nt)=>parseInt(ot.name.slice(2),10)-parseInt(Nt.name.slice(2),10)),xe=Math.max(X.length,Pr?.maxCameras??8),Ee=new Set(X.map(ot=>parseInt(ot.name.slice(2),10))),_t=new Set(ks.map(ot=>fr[ot.key]?.channelName).filter(ot=>!!ot)),Me=new Set,st={...fr};for(const ot of ks){if(st[ot.key]?.channelName)continue;let Nt=X.find(Gt=>!ie(Gt)&&!_t.has(Gt.name))?.name||"";if(!Nt)for(let Gt=1;Gt<=xe;Gt++){const yt=`ch${String(Gt).padStart(2,"0")}`;if(!Ee.has(Gt)&&!_t.has(yt)){Nt=yt;break}}Nt&&(_t.add(Nt),Me.add(ot.key),st[ot.key]={...st[ot.key],channelName:Nt})}xn(st),Ir(Me)},ps=async()=>{if(!j)return;if(!je.trim()){l({title:"RTSP credentials required",description:"Enter the RTSP username and password needed by the camera before assigning it.",variant:"destructive"});return}const P=Wr.filter(st=>
574st.rtspMainStream),X=Qn?P.filter(st=>st.id===Qn):P,xe=Ye(X);if(xe.find(st=>!fr[st.key]?.channelName)){l({title:"Choose every channel slot",description:"Select a channel slot for every camera before saving.",variant:"destructive"});return}const _t=xe.map(st=>{const ot=fr[st.key],Nt=I(st.mainStream,je.trim(),le),Gt=st.subStream?I(st.subStream,je.trim(),le):null;return{unitKey:st.key,channelName:ot.channelName,mainStreamUrl:Nt,subStreamUrl:Gt,displayName:ot.displayName.trim()||void 0,useGo2rtc:ot.useGo2rtc}}),Me=new Set;for(const st of _t){if(Me.has(st.channelName)){l({title:"Duplicate channel",description:`Channel ${st.channelName} is assigned more than once.`,variant:"destructive"});return}Me.add(st.channelName)}Pi(!0);try{_t.sort((hs,jn)=>parseInt(hs.channelName.slice(2),10)-parseInt(jn.channelName.slice(2),10));const ot=await(await Ze("POST",`/api/edge-devices/${j}/frigate-config/assign-cameras`,{selectedUnitKeys:xe.map(hs=>hs.key),assignments:_t})).json(),Nt=ot?.results||[],Gt=Nt.length?Nt.filter(hs=>hs.ok).length:_t.length,yt=Nt.filter(hs=>!hs.ok);l({title:yt.length?`Assigned ${Gt} of ${_t.length}`:"Cameras assigned",description:yt.length?`${Gt} succeeded, ${yt.length} failed.`:ot?.message||`Assigned ${Gt} camera${Gt===1?"":"s"}.`,variant:yt.length&&Gt===0?"destructive":"default"});for(const hs of yt)l({title:`Failed: ${hs.channelName}`,description:hs.message||"Unknown error",variant:"destructive"});ma(!0),br(!1),dn();try{await Md()}catch(hs){console.warn("Assignment saved but failed to refetch streams:",hs)}}catch(st){let ot="Failed to assign cameras",Nt=[];try{const Gt=JSON.parse(st.message);ot=Gt.message||ot,Array.isArray(Gt.results)&&(Nt=Gt.results)}catch{ot=st.message||ot}l({title:"Assignment failed",description:ot,variant:"destructive"});for(const Gt of Nt.filter(yt=>!yt.ok))l({title:`Failed: ${Gt.channelName}`,description:Gt.message||"Unknown error",variant:"destructive"})}finally{Pi(!1)}},Kr=P=>{if(Ae(X=>{const xe=new Set(X);return xe.has(P)?xe.delete(P):xe.add(P),xe}),!bt.has(P)&&!je&&!le){const X=Wr.find(_t=>_t.id===P),xe=(X?.manufacturer||"").trim().toLowerCase(),Ee=xe?we(xe):void 0;Ee&&(pe(Ee.username),ue(Ee.password),l({title:"Credentials reused",description:`Filled in the credentials that worked for this ${X?.manufacturer} device.`}))}},Is=async P=>{if(!j)return;const X=fs(P);if(X>0){l({title:"Cooldown active",description:`Defaults were recently tried on this camera. Wait ${Ce(X)} before retrying to avoid a camera lockout.`,variant:"destructive"}),ye(null);return}const xe=p5({manufacturer:P.manufacturer,model:P.model,name:P.name},3);if(xe.length===0){l({title:"No known defaults",description:"No factory-default credentials are known for this device.",variant:"destructive"});return}Ue(!0);const Ee={ip:P.ipAddress,port:P.port||80},_t=crypto.randomUUID?.()||Math.random().toString(36).slice(2)+Date.now().toString(36);try{for(let Me=0;Me<xe.length;Me++){const st=xe[Me];St(`Trying default ${Me+1} of ${xe.length} (${st.username}/${st.password||"<blank>"})…`);try{const Nt=await(await Ze("POST",`/api/edge-devices/${j}/camera-probe`,{targets:[Ee],username:st.username,password:st.password,defaultCredRunId:_t})).json();if(await new Promise(yt=>{Ll(Nt.commandId,async()=>{const jn=((await dn()).data||[]).find(so=>so.id===P.id);yt(!!jn?.rtspMainStream)},()=>yt(!1))})){ft(P);const yt=(P.manufacturer||"").trim().toLowerCase();yt&&ae(yt,{username:st.username,password:st.password}),pe(st.username),ue(st.password),l({title:"Default credentials worked",description:`Connected with ${st.username}/${st.password||"<blank>"}. You can save these cameras now.`}),ye(null);return}}catch(ot){const Nt=Ge(ot);if(Nt!==null){Es(P,Nt),l({title:"Cooldown active",description:`Defaults were recently tried on this camera. Wait ${Ce(Nt)} before retrying to avoid a camera lockout.`,variant:"destructive"});return}}Me<xe.length-1&&await new Promise(ot=>setTimeout(ot,4e3))}Es(P),l({title:"Defaults didn't work",description:`None of the known factory defaults connected. Enter the camera's credentials manually. To avoid locking the camera out, retrying defaults is blocked for ${Math.round(It/6e4)} minutes.`,variant:"destructive"})}finally{Ue(!1),St(""),ye(null)}},kn=()=>{const P=Wr.filter(X=>!X.rtspMainStream).map(X=>X.id);P.every(X=>bt.has(X))?Ae(new Set):Ae(new Set(P))},an=async()=>
574{if(j){ko(!0);try{const X=await(await Ze("POST",`/api/edge-devices/${j}/network-scan`)).json();l({title:"Scanning network",description:"Retrieving network adapter information..."}),await Ll(X.commandId,xe=>{try{const Ee=JSON.parse(xe.result||"[]");Cl(Ee);const _t={};Ee.forEach(Me=>{_t[Me.name]={...Me}}),Ha(_t)}catch{Cl([])}ko(!1),l({title:"Scan complete",description:"Network adapters loaded."})},xe=>{ko(!1),l({title:"Scan failed",description:xe,variant:"destructive"})})}catch(P){l({title:"Scan failed",description:P.message||"Could not scan network",variant:"destructive"}),ko(!1)}}},ri=async P=>{if(!j)return;const X=Ho[P];if(X){if(!X.dhcp){const xe=/^(\d{1,3}\.){3}\d{1,3}$/;if(!xe.test(X.ipAddress)){l({title:"Invalid IP address",variant:"destructive"});return}if(!xe.test(X.subnet)){l({title:"Invalid subnet mask",variant:"destructive"});return}if(X.gateway&&!xe.test(X.gateway)){l({title:"Invalid gateway",variant:"destructive"});return}if(X.dns1&&!xe.test(X.dns1)){l({title:"Invalid DNS 1",variant:"destructive"});return}if(X.dns2&&!xe.test(X.dns2)){l({title:"Invalid DNS 2",variant:"destructive"});return}}Bs(P);try{const Ee=await(await Ze("POST",`/api/edge-devices/${j}
574/network-save`,{interfaceName:X.name,dhcp:X.dhcp,ipAddress:X.ipAddress,subnet:X.subnet,gateway:X.gateway,dns1:X.dns1,dns2:X.dns2})).json();l({title:"Saving network settings",description:`Applying changes to ${X.name}. The device may briefly disconnect.`}),Je.refetchQueries({queryKey:["/api/sites/restarting"]}),await Ll(Ee.commandId,()=>{Bs(null),l({title:"Network saved",description:`Settings applied to ${X.name}.`}),setTimeout(()=>an(),5e3)},_t=>{Bs(null),l({title:"Save failed",description:_t,variant:"destructive"})})}catch(xe){l({title:"Save failed",description:xe.message||"Could not save network settings",variant:"destructive"}),Bs(null)}}},Id=(P,X,xe)=>{Ha(Ee=>({...Ee,[P]:{...Ee[P],[X]:xe}}))},Zg=P=>{kc(P),tn(!!P.ntp),Hn(P.timezone||"");const X=/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2})/.exec(P.datetime||"");X&&(qn(X[1]),tm(X[2]))},Ep=async()=>{if(j){ec(!0);try{const X=await(await Ze("POST",`/api/edge-devices/${j}/system-time-scan`)).json();await Ll(X.commandId,xe=>{try{const Ee=JSON.parse(xe.result||"{}");Zg(Ee)}catch{kc(null)}ec(!1)},xe=>{ec(!1),l({title:"Couldn't read system time",description:xe,variant:"destructive"})})}catch(P){l({title:"Couldn't read system time",description:P.message||"Could not reach the edge device",variant:"destructive"}),ec(!1)}}},$f=async()=>{if(j){if(!qo){l({title:"Select a timezone",variant:"destructive"});return}if(!_c){if(!/^\d{4}-\d{2}-\d{2}$/.test(mo)){l({title:"Invalid date",description:"Use YYYY-MM-DD",variant:"destructive"});return}if(!/^\d{2}:\d{2}$/.test(_o)){l({title:"Invalid time",description:"Use HH:MM",variant:"destructive"});return}}Na(!0);try{const X=await(await Ze("POST",`/api/edge-devices/${j}/system-time-save`,{timezone:qo,ntp:_c,date:mo,time:_o})).json();l({title:"Updating system time",description:"Applying changes to the edge device..."}),await Ll(X.commandId,()=>{Na(!1),l({title:"System time updated",description:"Changes applied to the edge device."}),setTimeout(()=>Ep(),2e3)},xe=>{Na(!1),l({title:"Update failed",description:xe,variant:"destructive"})})}catch(P){l({title:"Update failed",description:P.message||"Could not update system time",variant:"destructive"}),Na(!1)}}},Ff=async(P=!1)=>{if(j){ul(!0);try{const xe=await(await Ze("POST",`/api/edge-devices/${j}/network-stats`)).json();P||l({title:"Measuring bandwidth",description:"Sampling network traffic..."}),await Ll(xe.commandId,Ee=>{try{const _t=JSON.parse(Ee.result||"[]");_u(_t)}catch{_u([])}ul(!1),P||(l({title:"Stats ready",description:"Network bandwidth data loaded."}),Tc(!0),Ea.current=!0),Ea.current&&(Ac.current=setTimeout(()=>{Ea.current&&Ff(!0)},3e4))},Ee=>{ul(!1),Tc(!1),Ea.current=!1,l({title:"Stats failed",description:Ee,variant:"destructive"})})}catch(X){l({title:"Stats failed",description:X.message||"Could not measure bandwidth",variant:"destructive"}),ul(!1),Tc(!1),Ea.current=!1}}},Bf=()=>{Tc(!1),Ea.current=!1,Ac.current&&(clearTimeout(Ac.current),Ac.current=null)};u.useEffect(()=>{V!=="netstats"&&Bf()},[V]),u.useEffect(()=>{if(V!=="camera-names")return;Oa(Date.now());const P=setInterval(()=>Oa(Date.now()),3e4);return()=>clearInterval(P)},[V]),u.useEffect(()=>()=>{Ea.current=!1,Ac.current&&clearTimeout(Ac.current)},[]);const Jg=async P=>{if(r){Sa(!0);try{const X=await fetch(`/api/sites/${r}/cloud-preferences`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json",...V==="diagnostics"?{"X-Device-Settings-Context":"diagnostics"}:{}},body:JSON.stringify(P)});if(!X.ok)throw new Error(await X.text());const xe=await X.json().catch(()=>null);xe&&(xe.hideLocalRecordings!==void 0&&Go(!!xe.hideLocalRecordings),xe.hybridRetrievalEnabled!==void 0&&Ol(!!xe.hybridRetrievalEnabled),xe.distinguishHybridSources!==void 0&&gl(!!xe.distinguishHybridSources),xe.hybridPreferencesHidden!==void 0&&Ou(!!xe.hybridPreferencesHidden),xe.hideHybridRetrievalPreferences!==void 0&&Lc(!!xe.hideHybridRetrievalPreferences)),l({title:"Saved",description:"Cloud storage preferences updated."})}catch(X){l({title:"Error",description:X.message,variant:"destructive"})}finally{Sa(!1)}}},wv=async()=>{if(!j)return;const P=Number(Dl);
574if(!Number.isInteger(P)||P<10||P>300){l({title:"Invalid clip duration",description:"Enter a whole number of seconds from 10 to 300.",variant:"destructive"});return}F(!0);try{const X=await fetch(`/api/cloud-storage/settings/${j}`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({clipDurationSeconds:P})});if(!X.ok)throw new Error(await X.text());const xe=await X.json();ht.current=xe,dd(P),li(String(P)),Te(Date.now()),Je.invalidateQueries({queryKey:["/api/cloud-storage/settings",j]}),l({title:"Saved",description:"Clip duration length updated."})}catch(X){l({title:"Save failed",description:X?.message||"Could not save clip duration.",variant:"destructive"})}finally{F(!1)}},ex=P=>P>=1e6?`${(P/1e6).toFixed(1)} MB/s`:P>=1e3?`${(P/1e3).toFixed(1)} KB/s`:`${P} B/s`,Xb=P=>{const X=P*8;return X>=1e9?`${(X/1e9).toFixed(1)} Gbps`:X>=1e6?`${(X/1e6).toFixed(1)} Mbps`:X>=1e3?`${(X/1e3).toFixed(1)} Kbps`:`${X} bps`},tx=async()=>{if(j){nn(!0);try{const P=await fetch(`/api/edge-devices/${j}/frigate-config/raw`,{credentials:"include"});if(!P.ok){const xe=await P.json().catch(()=>({message:"Failed to load config"}));throw new Error(xe.message)}const X=await P.json();ed(X.yaml),td(X.yaml),sc(!0),l({title:"Config loaded",description:"YAML configuration retrieved from Edge device."})}catch(P){l({title:"Failed to load config",description:P.message||"Unknown error",variant:"destructive"})}finally{nn(!1)}}},CN=async()=>{if(!j)return;const P=Ed.replace(/\r\n?/g,`
575`),X=P.split(`
576`);for(let xe=0;xe<X.length;xe++){const Ee=X[xe].indexOf("	");if(Ee!==-1){l({title:"Save failed: TAB character detected",description:`Line ${xe+1} col ${Ee+1} contains a tab. The ${c.productName} configuration parser does not accept tabs. This usually happens when copy-pasting from a browser or chat — replace the tab with a newline + spaces.`,variant:"destructive"});return}}Pu(!0);try{const Ee=await(await Ze("POST",`/api/edge-devices/${j}/frigate-config/raw`,{yaml:P})).json();if(!Ee.success)throw new Error(Ee.message||"Save failed");Ee.globalMotion&&(Tu(Ee.globalMotion.enabled===!0),El(Ee.globalMotion.scope==="selected"?"selected":"all"),Xi(Array.isArray(Ee.globalMotion.cameraNames)?Ee.globalMotion.cameraNames:[]),typeof Ee.globalMotion.sensitivity=="number"&&bn(Ee.globalMotion.sensitivity),typeof Ee.globalMotion.threshold=="number"&&od(Ee.globalMotion.threshold),Al(!1),(Ee.globalMotionStatus==="diverged"||Ee.globalMotionStatus==="no-targets")&&l({title:"Global Motion Settings turned off",description:"The YAML no longer uses one sensitivity and threshold across the selected cameras. Review the values in Record Options before enabling it again.",variant:"destructive"})),td(P),ed(P),ma(!0),Md(),l({title:"Config saved",description:"Changes saved as pending. Apply Changes to push to the Edge device."})}catch(xe){l({title:"Save failed",description:xe.message||"Unknown error",variant:"destructive"})}finally{Pu(!1)}},kN=()=>{const P=new Blob([Ed],{type:"text/yaml"}),X=URL.createObjectURL(P),xe=document.createElement("a");xe.href=X;const Ee=w?.edgeDevice?.serialNumber||"config";xe.download=`${Ee}-config.yml`,xe.click(),URL.revokeObjectURL(X)},_N=P=>{const X=P.target.files?.[0];if(!X)return;const xe=new FileReader;xe.onload=Ee=>{const _t=Ee.target?.result;ed(_t),l({title:"Config imported",description:`Loaded ${X.name}. Review and save to apply.`})},xe.readAsText(X),P.target.value=""},Zb=async()=>{if(j){Td(!0),Eu(!0),Qs([]);try{const P=await fetch(`/api/edge-devices/${j}/yaml-backups`,{credentials:"include"});if(!P.ok){const xe=await P.json().catch(()=>({message:"Failed to load backups"}));throw new Error(xe.message)}const X=await P.json();Qs(X.versions||[])}catch(P){l({title:"Failed to load backups",description:P.message||"Unknown error",variant:"destructive"}),Td(!1)}finally{Eu(!1)}}},Jb=async P=>{if(j){la(P);try{const X=await fetch(`/api/edge-devices/${j}/yaml-backups/${encodeURIComponent(P)}`,{credentials:"include"});if(!X.ok){const st=await X.json().catch(()=>({message:"Failed to fetch backup"}));throw new Error(st.message)}const Ee=(await X.json()).yaml;ed(Ee),sc(!0);const Me=await(await Ze("POST",`/api/edge-devices/${j}/frigate-config/raw`,{yaml:Ee})).json();if(!Me.success)throw new Error(Me.message||"Failed to queue restore");td(Ee),ma(!0),Td(!1),l({title:"Snapshot restored",description:"Review the config in the editor, then click Apply Changes to push it to the device."})}catch(X){l({title:"Restore failed",description:X.message||"Unknown error",variant:"destructive"})}finally{la(null)}}},ew=async P=>{if(j){nc(P);try{const X=await fetch(`/api/edge-devices/${j}/yaml-backups/${encodeURIComponent(P)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:rd})});if(!X.ok){const xe=await X.json().catch(()=>({message:"Failed to update label"}));throw new Error(xe.message)}Qs(xe=>xe.map(Ee=>Ee.key===P?{...Ee,label:rd.trim()}:Ee)),ml(null)}catch(X){l({title:"Failed to update label",description:X.message||"Unknown error",variant:"destructive"})}finally{nc(null)}}},PN=async P=>{if(j){Ri(P);try{const X=await fetch(`/api/edge-devices/${j}/yaml-backups/${encodeURIComponent(P)}`,{method:"DELETE",credentials:"include"});if(!X.ok){const xe=await X.json().catch(()=>({message:"Failed to delete snapshot"}));throw new Error(xe.message)}Qs(xe=>xe.filter(Ee=>Ee.key!==P))}catch(X){l({title:"Failed to delete snapshot",description:X.message||"Unknown error",variant:"destructive"})}finally{Ri(null)}}},tw=sd&&Ed!==Ah,EN=Wr.filter(P=>!P.rtspMainStream).length,sw=Wr.filter(P=>P.rtspMainStream).length,p2={discovery:Wh,"camera-names":ga,streams:Vi,"camera-import-export":eP,"stream-options":Cg,"record-options":cn,"system-time":cn,network:cg,netstats:vc,"cloud-storage":pn,aidetection:uw,"ai-plus":Do,faces:Ba,"device-alerts":mi,"smart-alerts":mi,"user-permissions":Ba,privacy:ka},f2=b?CBe(A,{showAiPlusTab:k,showFacesTab:S,showUserPermissions:v}).map(P=>({key:P.key,label:P.label,icon:p2[P.key]??Wh,dividerBefore:P.dividerBefore})):[{key:"discovery",label:"Camera Discovery",icon:Wh},{key:"camera-names",label:"Camera Names",icon:ga},{key:"streams",label:"Camera Configuration",icon:Vi},{key:"stream-options",label:"Live Streaming",icon:Cg},{key:"record-options",label:"Record Options",icon:cn},{key:"user-permissions",label:"User Permissions",icon:Ba,dividerBefore:!0},{key:"privacy",label:"Owner Privacy",icon:ka},{key:"system-time",label:"System Time",icon:cn,dividerBefore:!0},{key:"network",label:"Network Settings",icon:cg},{key:"netstats",label:"Network Stats",icon:vc},{key:"cloud-storage",label:"Cloud Storage",icon:pn},{key:"aidetection",label:"AI Object Detection",icon:uw,dividerBefore:!0},...k?[{key:"ai-plus",label:"AI+ Features",icon:Do}]:[],...S?[{key:"faces",label:"Faces & People",icon:Ba}]:[],{key:"device-alerts",label:"Device Alerts",icon:mi,dividerBefore:!0},{key:"smart-alerts",label:"Smart Alerts",icon:mi},{key:"camera-import-export",label:"Import / Export",icon:eP,dividerBefore:!0},...p?[{key:"yamlconfig",label:"YAML Config",icon:J2},{key:"diagnostics",label:"Diagnostics",icon:jy}]:[]],Xm=R?[{key:"diagnostics",label:"Diagnostics",icon:jy}]:f2,TN=Xm.map(P=>P.key).join("|");if(u.useEffect(()=>{Xm.length!==0&&(Xm.some(P=>P.key===V)||K(Xm[0].key))},[TN]),u.useEffect(()=>{D&&V==="smart-alerts"&&Xm.length>0&&K(Xm[0].key)},[D,V]),!w)return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>a(i),"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(xd,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold",children:"Device Settings"})]}),t.jsx(qd,{showDashboardLink:!0,dashboardHref:i})]})})}),t.jsx("main",{className:"max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:t.jsxs("div",{className:"text-center py-12",children:[t.jsx(xd,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4 opacity-40"}),t.jsx("p",{className:"text-muted-foreground",children:"Site not found or still loading..."}),t.jsx(L,{variant:"outline",className:"mt-4",onClick:()=>a(i),"data-testid":"button-go-home",children:"Return to Dashboard"})]})})]});if(w.isOnline===!1&&!R)return t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-6",children:t.jsxs("div",{className:"max-w-md text-center space-y-2",children:[t.jsx("h1",{className:"text-lg font-semibold",children:"Device is offline"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Device Settings are unavailable while this device is offline."})]})});if(q){const P=_.data?.message||"You no longer have access to this device — contact your administrator.";return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>a(i),"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(xd,{className:"w-5 h-5 text-primary"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-lg font-semibold truncate",children:"Device Settings"}),t.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[w.name," 
576(",w.serialNumber,")"]})]})]}),t.jsx(qd,{showDashboardLink:!0,dashboardHref:i})]})})}),t.jsx("main",{className:"max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:t.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-8 text-center","data-testid":"empty-state-device-access-lost",children:[t.jsx(ta,{className:"w-12 h-12 mx-auto text-amber-500 mb-4"}),t.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Access unavailable"}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6","data-testid":"text-device-access-lost-message",children:P}),t.jsx(L,{variant:"outline",onClick:()=>a(i),"data-testid":"button-go-home-access-lost",children:"Return to Dashboard"})]})})]})}return b&&_.data&&Xm.length===0?t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>a(i),"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(xd,{className:"w-5 h-5 text-primary"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-lg font-semibold truncate",children:"Device Settings"}),t.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[w.name," (",w.serialNumber,")"]})]})]}),t.jsx(qd,{showDashboardLink:!0,dashboardHref:i})]})})}),t.jsx("main",{className:"max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:t.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-8 text-center","data-testid":"empty-state-no-menus",children:[t.jsx(xd,{className:"w-12 h-12 mx-auto text-muted-foreground mb-4"}),t.jsx("h2",{className:"text-lg font-semibold mb-2",children:"No settings available"}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"You don't have access to any device settings yet — contact your administrator if you need access."}),t.jsx(L,{variant:"outline",onClick:()=>a(i),"data-testid":"button-go-home-no-menus",children:"Return to Dashboard"})]})})]}):fn.isPending?t.jsx("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center gap-6 px-4",children:t.jsxs("div",{className:"flex flex-col items-center gap-4 max-w-sm w-full text-center",children:[t.jsx("div",{className:"w-14 h-14 rounded-full bg-destructive/10 flex items-center justify-center",children:t.jsx(Fe,{className:"w-7 h-7 text-destructive animate-spin"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold",children:"Deactivating Device"}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Removing ",t.jsx("strong",{children:w?.name})," and cancelling any active subscriptions. Please wait..."]})]}),t.jsx("div",{className:"w-full bg-muted rounded-full h-1.5 overflow-hidden",children:t.jsx("div",{className:"h-full bg-destructive rounded-full animate-[progress_1.5s_ease-in-out_infinite]",style:{width:"40%",animationName:"indeterminate"}})}),t.jsx("style",{children:"@keyframes indeterminate { 0% { transform: translateX(-100%); width: 40%; } 50% { width: 60%; } 100% { transform: translateX(350%); width: 40%; } }"})]})}):t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"flex items-center justify-between gap-4 h-16",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>a(i),"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(xd,{className:"w-5 h-5 text-primary"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-lg font-semibold truncate","data-testid":"text-device-settings-title",children:"Device Settings"}),t.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[w.name," 
576(",w.serialNumber,")"]})]})]}),t.jsx(qd,{showDashboardLink:!0,dashboardHref:i})]})})}),t.jsxs("main",{className:"flex flex-col sm:flex-row flex-1 min-h-0 overflow-hidden",style:{height:"calc(100vh - 4rem)"},children:[t.jsxs("div",{className:"shrink-0 border-b sm:border-b-0 sm:border-r border-border bg-muted/30 overflow-x-auto sm:overflow-x-visible sm:overflow-y-auto sm:w-56 sm:p-3",children:[t.jsxs("div",{className:"flex sm:flex-col items-stretch h-auto gap-0.5 sm:gap-1 px-1.5 py-1.5 sm:p-0 justify-start sm:justify-start w-max sm:w-auto",children:[Xm.map((P,X)=>{const xe=P.icon,Ee=V===P.key,_t=P.key==="smart-alerts"&&D;return t.jsxs("div",{className:"contents",children:[P.dividerBefore&&t.jsx("div",{className:"hidden sm:block border-b border-border my-1.5"}),t.jsxs("button",{onClick:()=>{_t||K(P.key)},disabled:_t,title:_t?"Smart Alerts requires a subscription plan":void 0,className:`flex items-center gap-2 sm:gap-2.5 px-3 sm:px-3 py-2.5 sm:py-2 sm:rounded-md text-sm transition-colors text-left whitespace-nowrap flex-none sm:flex-none justify-center sm:justify-start border-b-2 sm:border-b-0 ${_t?"text-muted-foreground/40 opacity-60 cursor-not-allowed border-transparent":Ee?"bg-primary/10 text-primary font-medium border-primary sm:border-transparent":"text-muted-foreground hover:bg-muted hover:text-foreground border-transparent"}`,"data-testid":`nav-item-${P.key}`,children:[t.jsx(xe,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{className:"hidden sm:inline",children:P.label})]})]},P.key)}),g&&t.jsx("button",{onClick:()=>co(!0),disabled:fn.isPending,className:"sm:hidden flex items-center justify-center px-3 py-2.5 flex-none border-b-2 border-transparent text-destructive hover:bg-destructive/10 transition-colors","data-testid":"button-deactivate-device-mobile",children:t.jsx(sa,{className:"w-4 h-4 shrink-0"})})]}),g&&t.jsxs("div",{className:"hidden sm:block mt-auto pt-2",children:[t.jsx("div",{className:"border-t border-border my-1.5"}),t.jsxs("button",{onClick:()=>co(!0),disabled:fn.isPending,className:"flex items-center gap-2.5 px-3 py-2 sm:rounded-md text-sm transition-colors text-left w-full text-destructive hover:bg-destructive/10","data-testid":"button-deactivate-device",children:[t.jsx(sa,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{children:"Deactivate Device"})]})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:[ku&&t.jsxs("div",{className:`sticky top-0 z-20 max-w-4xl mb-4 flex flex-col gap-2 p-3 rounded-lg border shadow-md backdrop-blur ${gs?"border-red-500/40 bg-red-500/95 dark:bg-red-950/95":"border-amber-500/40 bg-amber-50/95 dark:bg-amber-950/95"}`,"data-testid":"banner-pending-restart",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2",children:[t.jsxs("div",{className:`flex items-center gap-2 text-sm ${gs?"text-red-700 dark:text-red-400":"text-amber-700 dark:text-amber-400"}`,children:[t.jsx(ta,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{children:gs?"Last apply failed. The Edge device did not accept the configuration.":"You have pending changes. Apply when you are finished."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[pi&&j&&t.jsx(pHe,{edgeDeviceId:j}),t.jsx(L,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:Mo,disabled:Nc,"data-testid":"button-discard-changes",children:"Discard"}),t.jsxs(L,{size:"sm",className:"h-7 text-xs",onClick:Pp,disabled:e||Nc,"data-testid":"button-apply-changes",children:[Nc?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(kg,{className:"w-3.5 h-3.5 mr-1"}),Nc?"Applying...":gs?"Retry Apply":"Apply Changes"]})]})]}),gs&&t.jsx("div",{className:"text-xs text-red-700 dark:text-red-300 bg-red-500/5 border border-red-500/20 rounded p-2 font-mono whitespace-pre-wrap break-words","data-testid":"text-apply-error",children:gs})]}),V==="discovery"&&t.jsxs("div",{className:"max-w-4xl space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(L,{size:"sm",onClick:$h,disabled:G||!j||!x,"data-testid":"button-scan-cameras",className:"h-7 sm:h-8 text-xs sm:text-sm",children:G?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),t.jsx("span",{className:"hidden sm:inline",children:"Scanning..."}),t.jsx("span",{className:"sm:hidden",children:"..."})]}):t.jsxs(t.Fragment,{children:[t.jsx(Wh,{className:"w-3.5 h-3.5 mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Scan Network"}),t.jsx("span",{className:"sm:hidden",children:"Scan"})]})}),Wr.length>0&&t.jsxs(L,{variant:"ghost",size:"sm",onClick:$i,"data-testid":"button-clear-cameras",className:"h-7 sm:h-8 text-xs sm:text-sm",children:[t.jsx(sa,{className:"w-3.5 h-3.5 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Clear"})]}),pi&&j&&x&&t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>De(!0),"data-testid":"button-ai-setup",className:"h-7 sm:h-8 text-xs sm:text-sm",children:[t.jsx(Do,{
576className:"w-3.5 h-3.5 mr-1 text-primary"}),t.jsx("span",{className:"hidden sm:inline",children:"AI Setup"}),t.jsx("span",{className:"sm:hidden",children:"AI"})]}),pi&&j&&Wr.length>0&&t.jsxs(L,{variant:"outline",size:"sm",onClick:async()=>{gt(!0);try{const X=await(await Ze("POST",`/api/edge-devices/${j}/ai-config-assist/classify-scan`,{})).json(),xe={};for(const Ee of X.classifications||[])xe[Ee.id]=Ee;Xt(xe)}catch(P){l({title:"AI classification failed",description:P.message||"Could not classify the scan results.",variant:"destructive"})}finally{gt(!1)}},disabled:Ut,"data-testid":"button-ai-classify",className:"h-7 sm:h-8 text-xs sm:text-sm",children:[Ut?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(Do,{className:"w-3.5 h-3.5 mr-1 text-primary"}),t.jsx("span",{className:"hidden sm:inline",children:"AI Classify"}),t.jsx("span",{className:"sm:hidden",children:"Classify"})]}),t.jsx(L,{variant:"ghost",size:"sm",onClick:()=>Y(P=>!P),"data-testid":"button-toggle-extra-subnets",className:"h-7 sm:h-8 text-xs sm:text-sm",children:Q?"Hide extra subnets":"Extra subnets"}),Q&&t.jsx(ke,{value:Z,onChange:P=>ee(P.target.value),placeholder:"Extra subnets (e.g. 192.168.250.0/24)",className:"h-7 sm:h-8 text-xs sm:text-sm max-w-xs","data-testid":"input-extra-scan-subnets",disabled:G})]}),Q&&t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Optional. Add comma-separated CIDRs (max /24 each) for camera networks reachable via routing/VPN where the edge device has no NIC on that subnet."}),Wr.length>0&&t.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"badge-camera-count",children:["Network Devices — ",Wr.length," found"]})]}),!j&&t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-no-edge-device",children:"No edge device linked to this site."}),j&&!x&&t.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"text-no-edge-sync",children:"Edge sync is not configured for this device. Configure it in Admin Control to enable camera scanning."}),j&&x&&Wr.length===0&&!G&&t.jsxs("div",{className:"text-center py-12 border border-dashed rounded-lg border-border","data-testid":"text-no-cameras",children:[t.jsx(Wh,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:"No cameras discovered yet"}),t.jsx("p",{className:"text-muted-foreground text-xs mt-1",children:`Click "Scan Network" to find cameras on this device's network`})]}),j&&x&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-3 space-y-1.5","data-testid":"section-manual-probe",children:[t.jsx(re,{className:"text-xs font-medium text-muted-foreground",children:"Add a device by address"}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"For NVRs or cameras the network scan did not find."}),t.jsx(ke,{placeholder:"e.g. 192.168.1.200 or 192.168.1.200:8080",value:Dt,onChange:P=>ne(P.target.value),className:"h-8 text-sm",autoComplete:"off",name:"manual-probe-ip","data-testid":"input-manual-probe-ip"})]}),(bt.size>0||Dt.trim().length>0)&&t.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-muted/50 p-3","data-testid":"section-probe-credentials",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Device credentials"}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Used to retrieve stream URLs for the selected camera or recorder."})]}),EN>0&&t.jsx(L,{variant:"ghost",size:"sm",className:"text-xs h-6 shrink-0",onClick:kn,"data-testid":"button-select-all",children:bt.size===EN?"Deselect All":"Select All"})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:"RTSP credentials"}),t.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[t.jsx(ke,{placeholder:"RTSP username",value:je,onChange:P=>pe(P.target.value),className:"h-8 text-sm",autoComplete:"off",name:"rtsp-probe-user","data-testid":"input-probe-username"}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{type:"text",name:"username",autoComplete:"username",tabIndex:-1,"aria-hidden":"true",style:{position:"absolute",opacity:0,height:0,width:0,pointerEvents:"none"}}),t.jsx("input",{type:"password",name:"password",autoComplete:"current-password",tabIndex:-1,"aria-hidden":"true",style:{position:"absolute",opacity:0,height:0,width:0,pointerEvents:"none"}}),t.jsx(ke,{type:fe?"text":"password",placeholder:"RTSP password",value:le,onChange:P=>ue(P.target.value),className:"h-8 text-sm pr-8",autoComplete:"new-password",name:"rtsp-probe-pass","data-testid":"input-probe-password"}),t.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>H(!fe),"aria-label":fe?"Hide RTSP password":"Show RTSP password",children:fe?t.jsx(Gp,{className:"w-3.5 h-3.5"}):t.jsx(Xr,{className:"w-3.5 h-3.5"})})]}),t.jsxs(L,{size:"sm",className:"h-8 shrink-0",onClick:to,disabled:oe||bt.size===0&&!Dt.trim()||!je||se&&!ge.trim(),"data-testid":"button-probe-cameras",children:[oe?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):"Probe",!oe&&bt.size+(Dt.trim()?1:0)>0&&` (${bt.size+(Dt.trim()?1:0)})`]})]})]}),t.jsxs("div",{className:"space-y-2 rounded-md border border-border/70 bg-background/50 p-2.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(On,{id:"use-separate-onvif-credentials",checked:se,onCheckedChange:P=>me(P===!0),"data-testid":"checkbox-separate-onvif-credentials"}),t.jsx(re,{htmlFor:"use-separate-onvif-credentials",className:"cursor-pointer text-xs font-normal",children:"Use separate ONVIF credentials"})]}),se&&t.jsxs("div",{className:"space-y-1.5","data-testid":"section-onvif-credentials",children:[t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Used for ONVIF discovery, channel enumeration, and PTZ. RTSP streams continue to use the credentials above."}),t.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[t.jsx(ke,{placeholder:"ONVIF username",value:ge,onChange:P=>be(P.target.value),className:"h-8 text-sm",autoComplete:"off",name:"onvif-probe-user","data-testid":"input-onvif-username"}),t.jsxs("div",{className:"relative",children:[t.jsx(ke,{type:et?"text":"password",placeholder:"ONVIF password",value:ce,onChange:P=>Pe(P.target.value),className:"h-8 text-sm pr-8",autoComplete:"new-password",name:"onvif-probe-pass","data-testid":"input-onvif-password"}),t.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>$e(!et),"aria-label":et?"Hide ONVIF password":"Show ONVIF password",children:et?t.jsx(Gp,{className:"w-3.5 h-3.5"}):t.jsx(Xr,{className:"w-3.5 h-3.5"})})]})]})]})]})]}),t.jsx("div",{className:"space-y-1.5",children:Wr.map(P=>t.jsxs("div",{className:`flex items-start sm:items-center gap-2 sm:gap-3 p-2.5 rounded-lg border text-sm transition-colors ${bt.has(P.id)?"border-primary/50 bg-primary/5":"border-border bg-background"}`,"data-testid":`card-discovered-camera-${P.id}`,children:[!P.rtspMainStream&&t.jsx("button",{type:"button",role:"checkbox","aria-checked":bt.has(P.id),onClick:()=>Kr(P.id),className:`shrink-0 h-5 w-5 mt-0.5 sm:mt-0 rounded-md border-2 flex items-center justify-center transition-all duration-150 ${bt.has(P.id)?"bg-primary border-primary text-primary-foreground":"border-muted-foreground
576/40 bg-background hover:border-primary/60"}`,"data-testid":`checkbox-camera-${P.id}`,children:bt.has(P.id)&&t.jsx(Hd,{className:"w-3.5 h-3.5 stroke-[3]"})}),P.rtspMainStream&&t.jsx(ar,{className:"w-4 h-4 text-emerald-500 shrink-0 mt-0.5 sm:mt-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:gap-2",children:[t.jsxs("span",{className:"font-mono text-xs","data-testid":`text-camera-ip-${P.id}`,children:[P.ipAddress,P.port&&P.port!==80?`:${P.port}`:""]}),P.manufacturer&&t.jsx(Ke,{variant:"outline",className:"text-[10px] h-4 no-default-active-elevate",children:P.manufacturer}),P.model&&t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:P.model})]}),P.rtspMainStream&&t.jsxs("div",{className:"mt-0.5 space-y-0.5",children:[t.jsxs("p",{className:"text-xs text-muted-foreground font-mono truncate","data-testid":`text-rtsp-${P.id}`,children:[t.jsx("span",{className:"text-emerald-500 font-sans mr-1",children:"Main:"}),P.rtspMainStream]}),P.rtspSubStream?t.jsxs("p",{className:"text-xs text-muted-foreground font-mono truncate","data-testid":`text-rtsp-sub-${P.id}`,children:[t.jsx("span",{className:"text-sky-500 font-sans mr-1",children:"Sub:"}),P.rtspSubStream]}):t.jsx("p",{className:"text-xs text-amber-500/70 italic",children:"No sub stream found"})]}),P.probeError&&t.jsxs("div",{className:"mt-0.5",children:[t.jsx("p",{className:"text-xs text-destructive break-words whitespace-normal",children:P.probeError}),pi&&j&&t.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[t.jsx(e5,{edgeDeviceId:j,context:"probe",errorText:P.probeError,camera:{ip:P.ipAddress,port:P.port,manufacturer:P.manufacturer,model:P.model},compact:!0}),/^(401|403|auth|unauthor|login|password|credential|access denied)/i.test(P.probeError)&&p5({manufacturer:P.manufacturer,model:P.model,name:P.name}).length>0&&(()=>{const X=fs(P);return t.jsxs(L,{variant:"ghost",size:"sm",className:"h-5 px-1.5 text-[10px]",onClick:()=>ye(P),disabled:te||X>0,"data-testid":`button-try-default-creds-${P.id}`,children:[t.jsx($w,{className:"w-3 h-3 mr-1 text-amber-500"}),X>0?`Defaults on cooldown (${Ce(X)})`:"Try default credentials"]})})()]})]}),qe[P.id]&&t.jsxs("div",{className:"mt-0.5 flex items-start gap-1.5 flex-wrap","data-testid":`ai-classification-${P.id}`,children:[t.jsx(Ke,{variant:qe[P.id].category==="nvr"?"default":qe[P.id].category==="camera"?"secondary":"outline",className:"text-[10px] px-1.5 py-0",children:qe[P.id].category==="nvr"?"NVR / Recorder":qe[P.id].category==="camera"?"Camera":"Not a camera"}),t.jsx("span",{className:"text-[10px] text-muted-foreground",children:qe[P.id].suggestion||qe[P.id].reason})]}),P.name&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:P.name})]}),t.jsxs("div",{className:"flex flex-col gap-1 shrink-0",children:[P.rtspMainStream&&t.jsx(L,{variant:"outline",size:"icon",className:"h-6 w-6",onClick:()=>Mt(P.id),title:"Assign to channel slot","data-testid":`button-add-frigate-${P.id}`,children:t.jsx(Fo,{className:"w-3 h-3"})}),t.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>Lf(P.id),"data-testid":`button-delete-camera-${P.id}`,children:t.jsx(sa,{className:"w-3 h-3"})})]})]},P.id))}),sw>0&&t.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[t.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"text-probed-count",children:[sw," camera(s) probed with stream URLs"]}),t.jsxs(L,{size:"sm",className:"h-7 text-xs",onClick:()=>Mt(),"data-testid":"button-assign-to-channels",children:[t.jsx(Fo,{className:"w-3 h-3 mr-1"}),"Assign to Channels…"]})]})]}),t.jsx(Ys,{open:es,onOpenChange:P=>{br(P),P||(xn({}),ii(null),Ua(!1),Ir(new Set))},children:t.jsxs(Ws,{className:"max-w-2xl max-h-[85vh] flex flex-col","data-testid":"dialog-assign-cameras",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Assign Cameras to Channels"}),t.jsx(cr,{children:"Pick a channel slot for each probed camera. Selected slots will overwrite any existing camera in that slot."})]}),t.jsxs("div",{className:"flex items-center justify-between gap-4 roun
576ded-lg border border-border bg-muted/40 p-3",children:[t.jsxs("div",{children:[t.jsx(re,{htmlFor:"auto-assign-camera-slots",className:"text-sm font-medium",children:"Auto-assign available slots"}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Off by default so you can choose the camera channel order."})]}),t.jsx(sr,{id:"auto-assign-camera-slots",checked:ua,onCheckedChange:ls,"data-testid":"switch-auto-assign-camera-slots"})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto -mx-6 px-6",children:t.jsxs("div",{className:"space-y-3 py-2",children:[t.jsxs("div",{className:"rounded-lg border border-border bg-muted/40 p-3 space-y-2","data-testid":"section-assignment-rtsp-credentials",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium",children:"RTSP credentials"}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Confirm the credentials that should be embedded in the assigned stream URLs. They may need to be re-entered after reopening this browser tab."})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[t.jsx(ke,{placeholder:"RTSP username",value:je,onChange:P=>pe(P.target.value),className:"h-8 text-sm",autoComplete:"off",name:"assignment-rtsp-user","data-testid":"input-assignment-rtsp-username"}),t.jsxs("div",{className:"relative",children:[t.jsx(ke,{type:fe?"text":"password",placeholder:"RTSP password",value:le,onChange:P=>ue(P.target.value),className:"h-8 text-sm pr-8",autoComplete:"new-password",name:"assignment-rtsp-pass","data-testid":"input-assignment-rtsp-password"}),t.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>H(!fe),"aria-label":fe?"Hide RTSP password":"Show RTSP password",children:fe?t.jsx(Gp,{className:"w-3.5 h-3.5"}):t.jsx(Xr,{className:"w-3.5 h-3.5"})})]})]})]}),(()=>{const P=Wr.filter(yt=>
576yt.rtspMainStream),X=Qn?P.filter(yt=>yt.id===Qn):P,xe=(Pr?.cameras||[]).filter(yt=>/^ch\d{2,}$/.test(yt.name)).slice().sort((yt,hs)=>parseInt(yt.name.slice(2),10)-parseInt(hs.name.slice(2),10)),Ee=Math.max(xe.length,Pr?.maxCameras??8),_t=new Set(xe.map(yt=>parseInt(yt.name.slice(2),10))),Me=xe.map(yt=>({name:yt.name,isNew:!1,cam:yt}));for(let yt=1;yt<=Ee;yt++)if(!_t.has(yt)){const hs=`ch${String(yt).padStart(2,"0")}`;Me.push({name:hs,isNew:!0,cam:null})}Me.sort((yt,hs)=>parseInt(yt.name.slice(2),10)-parseInt(hs.name.slice(2),10));const st=yt=>{if(yt.isNew||!yt.cam)return{label:"New slot",tone:"new"};const hs=ie(yt.cam);return hs?{label:`In use (${hs})`,tone:"inuse"}:{label:"Empty",tone:"available"}},ot=Ye(P),Nt=Ye(X),Gt=yt=>{const hs=new Set;for(const jn of ot){if(jn.key===yt)continue;const so=fr[jn.key]?.channelName;so&&hs.add(so)}return hs};return Nt.length===0?t.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No probed cameras yet."}):Nt.map(yt=>{const hs=yt.cam,jn=fr[yt.key]||{channelName:"",displayName:"",useGo2rtc:!0},so=Gt(yt.key),Zm=Qn===hs.id;return t.jsxs("div",{className:`p-3 rounded-lg border space-y-2 ${Zm?"border-primary bg-primary/5":"border-border"}`,"data-testid":`row-assign-${yt.key}`,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[t.jsxs("span",{className:"font-mono",children:[hs.ipAddress,hs.port&&hs.port!==80?`:${hs.port}`:""]}),yt.channelNo!=null&&t.jsxs(Ke,{className:"text-[10px] h-4 no-default-active-elevate","data-testid":`badge-nvr-channel-${yt.key}`,children:["NVR Ch ",yt.channelNo]}),hs.manufacturer&&t.jsx(Ke,{variant:"outline",className:"text-[10px] h-4 no-default-active-elevate",children:hs.manufacturer}),hs.model&&t.jsx("span",{className:"text-muted-foreground truncate",children:hs.model})]}),t.jsxs("div",{className:"space-y-1 text-[10px] font-mono leading-tight",children:[t.jsxs("div",{className:"flex items-start gap-2","data-testid":`text-main-stream-${yt.key}`,children:[t.jsx("span",{className:"shrink-0 text-muted-foreground uppercase",children:"Main"}),t.jsx("span",{className:"truncate text-foreground/80",title:yt.mainStream,children:yt.mainStream})]}),yt.subStream&&t.jsxs("div",{className:"flex items-start gap-2","data-testid":`text-sub-stream-${yt.key}`,children:[t.jsx("span",{className:"shrink-0 text-muted-foreground uppercase",children:"Sub"}),t.jsx("span",{className:"truncate text-foreground/80",title:yt.subStream,children:yt.subStream})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-2 items-end",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px]",children:"Display Name"}),t.jsx(ke,{value:jn.displayName,onChange:go=>xn(xl=>({...xl,[yt.key]:{...jn,displayName:go.target.value}})),className:"h-8 text-xs mt-1",placeholder:"e.g. Front Door","data-testid":`input-display-name-${yt.key}`})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px]",children:"Channel Slot"}),t.jsxs(Us,{value:jn.channelName||"__none__",onValueChange:go=>{Ir(xl=>{const lu=new Set(xl);return lu.delete(yt.key),lu}),xn(xl=>({...xl,[yt.key]:{...jn,channelName:go==="__none__"?"":go}}))},children:[t.jsx($s,{className:"h-8 text-xs mt-1","data-testid":`select-channel-${yt.key}`,children:t.jsx(zs,{placeholder:"Select a channel"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"__none__",children:"— Select a channel —"}),Me.map(go=>{const xl=st(go),lu=so.has(go.name),dm=xl.tone==="available"?"text-emerald-600 dark:text-emerald-400":xl.tone==="new"?"text-sky-600 dark:text-sky-400":"text-amber-600 dark:text-amber-400";return t.jsx(rt,{value:go.name,disabled:lu,"data-testid":`option-channel-${go.name}-${yt.key}`,children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-mono",children:go.isNew?`+ Add ${go.name}`:go.name}),t.jsx("span",{className:`text-[10px] ${dm}`,children:xl.label}),lu&&t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"— picked above"})]})},go.name)})]})]})]})]})]},yt.key)})})()]})}),t.jsxs(In,{className:"gap-2",children:[t.jsx(L,{variant:"ghost",onClick:()=>br(!1),disabled:Br,"data-testid":"button-cancel-assign",children:"Cancel"}),t.jsxs(L,{onClick:ps,disabled:Br||!je.trim()||ks.length===0||Ts,"data-testid":"button-submit-assign",children:[Br?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(Fo,{className:"w-3.5 h-3.5 mr-1"}),"Assign Selected"]})]})]})})]}),V==="camera-names"&&t.jsxs("div",{className:"max-w-4xl space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h4",{className:"font-medium text-sm",children:"Camera Names"}),Pr?.cameras&&t.jsxs(Ke,{variant:"secondary",className:"text-xs no-default-active-elevate","data-testid":"badge-camera-name-count",children:[Pr.cameras.length," camera",Pr.cameras.length!==1?"s":""]})]}),pi&&j&&Pr?.cameras&&Pr.cameras.length>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[Object.keys(vn).length>0&&t.jsxs(L,{size:"sm",variant:"secondary",className:"h-7 sm:h-8 text-xs sm:text-sm",onClick:nu,disabled:Xn,"data-testid":"button-accept-all-ai-names",children:[t.jsx(Hd,{className:"w-3.5 h-3.5 mr-1"}),"Accept all (",Object.keys(vn).length,")"]}),t.jsxs(L,{size:"sm",variant:"outline",className:"h-7 sm:h-8 text-xs sm:text-sm",onClick:Qg,disabled:Xn,"data-testid":"button-ai-suggest-names",children:[Xn?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}
576):t.jsx(Do,{className:"w-3.5 h-3.5 mr-1 text-primary"}),t.jsx("span",{className:"hidden sm:inline",children:"Suggest Names with AI"}),t.jsx("span",{className:"sm:hidden",children:"AI Names"})]})]})]}),!Pr?.cameras||Pr.cameras.length===0?t.jsxs("div",{className:"text-center py-12 border border-dashed border-border rounded-lg",children:[t.jsx(ga,{className:"w-10 h-10 mx-auto text-muted-foreground mb-3 opacity-40"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No cameras configured yet"}),t.jsx("p",{className:"text-muted-foreground text-xs mt-1",children:"Use Camera Discovery to find and add cameras, then come back here to give them friendly names"})]}):t.jsx("div",{className:"rounded-lg border border-border bg-background p-3 space-y-2","data-testid":"card-camera-names",children:t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5",children:Pr.cameras.map(P=>{const X=P.displayName||P.name,xe=ur[P.name]??X,Ee=xe!==X,_t=qr===P.name,Me=Dr[P.name]??"loading",st=r&&P.enabled?`/api/sites/${r}/cameras/${encodeURIComponent(P.name)}/thumbnail?t=${Co}&h=80`:null;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"w-20 h-12 shrink-0 rounded-md overflow-hidden border border-border bg-muted/40 flex items-center justify-center","data-testid":`thumb-camera-${P.name}`,children:st?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:st,alt:`${X} preview`,className:`w-full h-full object-cover ${Me==="ok"?"":"hidden"}`,onLoad:()=>en(ot=>ot[P.name]==="ok"?ot:{...ot,[P.name]:"ok"}),onError:()=>en(ot=>ot[P.name]==="error"?ot:{...ot,[P.name]:"error"}),"data-testid":`img-camera-thumb-${P.name}`}),Me!=="ok"&&t.jsx(Vi,{className:"w-4 h-4 text-muted-foreground/60"})]}):t.jsx(Vi,{className:"w-4 h-4 text-muted-foreground/40"})}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground w-12 shrink-0",children:P.name}),t.jsx(ke,{value:xe,onChange:ot=>nr(Nt=>({...Nt,[P.name]:ot.target.value})),onKeyDown:ot=>{ot.key==="Enter"&&Ee&&!_t&&jp(P.name,xe)},className:"h-7 text-xs flex-1","data-testid":`input-camera-name-${P.name}`}),t.jsx(L,{size:"icon",variant:"ghost",className:"h-7 w-7 shrink-0",disabled:!Ee||_t,onClick:()=>jp(P.name,xe),"data-testid":`button-save-camera-name-${P.name}`,children:_t?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):t.jsx(Vl,{className:"w-3.5 h-3.5"})})]}),vn[P.name]!==void 0&&vn[P.name]===xe&&Ee&&t.jsx("div",{className:"flex items-center gap-1 ml-[88px]",children:t.jsxs(Ke,{variant:"secondary",className:"text-[10px] h-4 no-default-active-elevate font-normal","data-testid":`badge-ai-suggested-${P.name}`,children:[t.jsx(Do,{className:"w-2.5 h-2.5 mr-0.5 text-primary"}),"AI suggested"]})}),(P.quickConnectBrand||P.quickConnectModel)&&t.jsx("div",{className:"flex items-center gap-1.5 ml-[88px]",children:t.jsx(Ke,{variant:"outline",className:"text-[10px] h-4 no-default-active-elevate font-normal text-muted-foreground","data-testid":`badge-hardware-name-${P.name}`,children:[P.quickConnectBrand,P.quickConnectModel].filter(Boolean).join(" · ")})})]},`name-${P.name}`)})})})]}),V==="streams"&&t.jsxs("div",{className:"max-w-4xl space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("h4",{className:"font-medium text-sm",children:"Configured Cameras"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Pr?.cameras&&t.jsxs(Ke,{variant:"secondary",className:"text-xs no-default-active-elevate","data-testid":"badge-stream-count",children:[Pr.cameras.length," camera",Pr.cameras.length!==1?"s":""]}),eo?.resolutionLicense&&t.jsxs(Ke,{variant:"outline",className:"text-xs no-default-active-elevate","data-testid":"badge-license-max-resolution",children:["Max: ",eo.resolutionLicense.label]}),eo?.resolutionLicense&&typeof eo.licensedResolutionOutOfComplianceCount=="number"&&t.jsxs(Ke,{className:eo.licensedResolutionOutOfComplianceCount>0?"text-xs no-default-active-elevate border-destructive/40 bg-destructive/15 text-destructive":"text-xs no-default-active-elevate border-emerald-500/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-400","data-testid":"badge-license-compliance-count",children:[eo.licensedResolutionOutOfComplianceCount," out of compliance"]})]})]}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs(L,{variant:bi?"secondary":"outline",size:"sm",className:"h-7 sm:h-8 text-xs sm:text-sm",onClick:()=>{Sc(!bi),bi||Xc(new Set)},"data-testid":"button-bulk-credentials",children:[t.jsx($w,{className:"w-3.5 h-3.5 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Update Credentials"})]})})]}),bi&&t.jsxs("div",{className:"p-4 rounded-lg border border-border bg-muted/30 space-y-3","data-testid":"panel-bulk-credentials",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Update RTSP credentials for multiple cameras at once. Changes are queued until you Apply Changes."}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Username"}),t.jsx(ke,{value:ra,onChange:P=>za(P.target.value),placeholder:"admin",className:"h-8 text-sm mt-1",autoComplete:"off",name:"rtsp-bulk-user","data-testid":"input-bulk-username"})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Password"}),t.jsxs("div",{className:"relative mt-1",children:[t.jsx("input",{type:"text",name:"username",autoComplete:"username",tabIndex:-1,"aria-hidden":"true",style:{position:"absolute",opacity:0,height:0,width:0,pointerEvents:"none"}}),t.jsx("input",{type:"password",name:"password",autoComplete:"current-password",tabIndex:-1,"aria-hidden":"true",style:{position:"absolute",opacity:0,height:0,width:0,pointerEvents:"none"}}),t.jsx(ke,{type:na?"text":"password",value:Xl,onChange:P=>Ei(P.target.value),placeholder:"password",className:"h-8 text-sm pr-8",autoComplete:"new-password",name:"rtsp-bulk-pass","data-testid":"input-bulk-password"}),t.jsx(L,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-8 w-8",onClick:()=>Ur(!na),"data-testid":"button-toggle-bulk-pw",children:na?t.jsx(Gp,{className:"w-3.5 h-3.5"}):t.jsx(Xr,{className:"w-3.5 h-3.5"})})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx(re,{className:"text-xs",children:"Select Cameras"}),t.jsx(L,{variant:"ghost",size:"sm",className:"h-6 text-[10px] px-2",onClick:()=>
576{if(Pr?.cameras){const P=Pr.cameras.filter(xe=>xe.streams.length>0).map(xe=>xe.name),X=P.every(xe=>Da.has(xe));Xc(X?new Set:new Set(P))}},"data-testid":"button-bulk-select-all",children:Pr?.cameras&&Pr.cameras.filter(P=>P.streams.length>0).every(P=>Da.has(P.name))?"Deselect All":"Select All"})]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-1.5",children:Pr?.cameras?.filter(P=>P.streams.length>0).map(P=>t.jsxs("label",{className:"flex items-center gap-1.5 p-1.5 rounded border border-border cursor-pointer hover:bg-muted/50 text-xs","data-testid":`label-bulk-camera-${P.name}`,children:[t.jsx(On,{checked:Da.has(P.name),onCheckedChange:X=>{Xc(xe=>{const Ee=new Set(xe);return X?Ee.add(P.name):Ee.delete(P.name),Ee})},"data-testid":`checkbox-bulk-camera-${P.name}`}),t.jsx("span",{className:"truncate",children:P.displayName})]},P.name))})]}),t.jsxs("div",{className:"flex items-center justify-between pt-1",children:[t.jsxs("span",{className:"text-xs text-muted-foreground",children:[Da.size," camera(s) selected"]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(L,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{Sc(!1),za(""),Ei(""),Xc(new Set)},"data-testid":"button-bulk-cancel",children:"Cancel"}),t.jsxs(L,{size:"sm",className:"h-7 text-xs",onClick:Lu,disabled:oi||!ra||Da.size===0,"data-testid":"button-bulk-apply",children:[oi?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx($w,{className:"w-3.5 h-3.5 mr-1"}),oi?"Updating...":"Update Credentials"]})]})]})]}),am&&t.jsx("div",{className:"space-y-2",children:[1,2,3].map(P=>t.jsx(Bt,{className:"h-16 rounded-lg"},P))}),!am&&(!Pr?.cameras||Pr.cameras.length===0)&&t.jsxs("div",{className:"text-center py-12 border border-dashed rounded-lg border-border","data-testid":"text-no-streams",children:[t.jsx(Vi,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:"No cameras configured on this Edge device"}),t.jsx("p",{className:"text-muted-foreground text-xs mt-1",children:"Use Camera Discovery to find and add cameras"})]}),Pr?.cameras&&Pr.cameras.length>0&&t.jsx("div",{className:"space-y-2",children:Pr.cameras.map(P=>{const X=Hr===P.name,xe=hr.brand&&hr.model?lm(hr.brand,hr.model):void 0,Ee=hr.brand?Dj.filter(Me=>Me.brand===hr.brand):[],_t=Me=>{Sn(Me);const st=Me.brand&&Me.model?lm(Me.brand,Me.model):void 0;st&&vr(ot=>({...ot,mainStreamUrl:Cp(st.rtspMain,st,Me,P.name),subStreamUrl:Cp(st.rtspSub,st,Me,P.name)}))};return t.jsxs("div",{className:`p-3 rounded-lg border ${X?"border-primary/40 bg-primary/5":"border-border bg-background"}`,"data-testid":`card-stream-${P.name}`,children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-1 mb-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(wo,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium truncate","data-testid":`text-stream-name-${P.name}`,children:P.displayName}),P.displayName!==P.name&&t.jsxs("span",{className:"text-xs font-mono text-muted-foreground shrink-0",children:["(",P.name,")"]})]}),t.jsx("div",{className:"flex items-center gap-1.5",children:!X&&t.jsxs(t.Fragment,{children:[t.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>om(P),"data-testid":`button-edit-camera-${P.name}`,children:t.jsx(xd,{className:"w-3 h-3"})}),t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(L,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive hover:text-destructive",onClick:()=>Vr(P.name),"data-testid":`button-clear-camera-${P.name}`,children:t.jsx(sa,{className:"w-3 h-3"})})}),t.jsx(Yt,{children:"Clear & disable camera"})]})]})})]}),(P.quickConnectBrand||P.quickConnectModel)&&t.jsx("div",{className:"flex items-center gap-1.5 -mt-0.5 mb-1.5 ml-5",children:t.jsx(Ke,{variant:"outline",className:"text-[10px] h-4 no-default-active-elevate font-normal text-muted-foreground","data-testid":`badge-hardware-${P.name}`,children:[P.quickConnectBrand,P.quickConnectModel].filter(Boolean).join(" · ")})}),(()=>{const Me=Bc.get(P.name);return!Me||Me.detectSource!=="main"?null:t.jsx("div",{className:"-mt-0.5 mb-1.5 ml-5","data-testid":`row-detect-main-${P.n
576ame}`,children:t.jsxs(Ke,{className:"text-[10px] h-4 no-default-active-elevate border-amber-500/40 bg-amber-500/15 text-amber-700 dark:text-amber-400","data-testid":`badge-detect-main-${P.name}`,children:[t.jsx(ta,{className:"w-2.5 h-2.5 mr-1"}),"Detection on main stream"]})})})(),(()=>{if(!P.enabled)return null;const Me=eo?.resolutionLicense,st=Bc.get(P.name),ot=st?.recordDisabledByResolution===!0;if(!Me&&!ot)return null;const Nt=Rt[P.name]?.status==="done"?Rt[P.name]:null,Gt=kBe(Nt?.main,Nt?.sub,Me?.maxPixels),yt=Gt.status??st?.resolutionStatus??"unknown",hs=(xo,Tp)=>{const Fh=Number(xo),sx=Number(Tp);return Number.isFinite(Fh)&&Fh>0&&Number.isFinite(sx)&&sx>0&&Fh*sx<=(Me?.maxPixels??0)},jn=!!Me&&hs(st?.mainWidth,st?.mainHeight)&&hs(st?.subWidth,st?.subHeight),so=!!st&&(Number(st.mainWidth)>0&&Number(st.mainHeight)>0||Number(st.subWidth)>0&&Number(st.subHeight)>0);if(yt==="compliant"||jn||yt==="unknown"&&so||ot&&yt!=="mismatch")return null;const Zm=Gt.record?.width??st?.mainWidth,go=Gt.record?.height??st?.mainHeight,xl=Gt.detect?.width??st?.subWidth,lu=Gt.detect?.height??st?.subHeight,dm=Zm&&go?`${Zm}×${go}`:null,Od=xl&&lu?`${xl}×${lu}`:null,Jm=!!(dm||Od),eh=Gt.status==="mismatch"?Gt.recommendedSource:st?.resolutionRecommendedSource,vl=Me?.label||"purchased resolution";return t.jsxs("div",{className:"-mt-0.5 mb-2 ml-0 sm:ml-5 rounded-md border border-amber-500/30 bg-amber-500/5 p-2.5 space-y-2","data-testid":`row-resolution-license-${P.name}`,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[yt==="mismatch"?t.jsxs(Ke,{className:"text-[10px] h-4 no-default-active-elevate border-destructive/40 bg-destructive/15 text-destructive","data-testid":`badge-resolution-mismatch-${P.name}`,children:[t.jsx(ta,{className:"w-2.5 h-2.5 mr-1"}),"Camera resolution exceeds licensed limit"]}):ot?t.jsxs(Ke,{className:"text-[10px] h-4 no-default-active-elevate border-destructive/40 bg-destructive/15 text-destructive","data-testid":`badge-resolution-paused-${P.name}`,children:[t.jsx(ta,{className:"w-2.5 h-2.5 mr-1"}),"Previous resolution pause needs review"]}):t.jsxs(Ke,{className:"text-[10px] h-4 no-default-active-elevate border-amber-500/40 bg-amber-500/15 text-amber-700 dark:text-amber-400","data-testid":`badge-resolution-unknown-${P.name}`,children:[t.jsx(ta,{className:"w-2.5 h-2.5 mr-1"}),Jm?"Recording source could not be verified":"Camera resolution could not be verified"]}),(dm||Od)&&t.jsxs("span",{className:"text-[10px] text-muted-foreground","data-testid":`text-resolution-measured-${P.name}`,children:["Measured: ",[dm&&`Main ${dm}`,Od&&`Sub ${Od}`].filter(Boolean).join(" · ")]})]}),t.jsx("p",{className:yt==="mismatch"||ot?"text-[11px] text-destructive":"text-[11px] text-amber-700 dark:text-amber-400","data-testid":`text-resolution-reason-${P.name}`,children:yt==="mismatch"?"Camera resolution exceeds the licensed limit. This camera’s measured resolution is higher than the resolution included with this device’s license. Recording and configuration remain unchanged.":ot?"This camera was paused by a retired resolution policy, but its current resolution could not be verified. Recording and configuration remain unchanged.":Jm?"The available stream dimensions were measured, but the current recording source could not be verified. Recording and configuration remain unchanged. The system will try again during the next scheduled check.":"Camera resolution could not be verified. Recording and configuration remain unchanged. The system will try again during the next scheduled check."}),yt==="mismatch"&&!ot&&t.jsx("p",{className:"text-[10px] text-muted-foreground",children:eh==="main"||eh==="sub"?`Recommended change: record from the measured ${eh} stream, which fits the ${vl} limit.`:`No healthy measured alternate stream currently fits the ${vl} limit. Recording remains unchanged.`})]})})(),(()=>{const Me=Bc.get(P.name);return!Me||Me.recordingSource!=="sub"||Me.prioritizeStorage?null:t.jsxs("div",{className:"-mt-0.5 mb-1.5 ml-5 space-y-1","data-testid":`row-sub-rollover-${P.name}`,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Ke,{className:"text-[10px] h-4 no-default-active-elevate border-amber-500/40 bg-amber-500/15 text-amber-700 dark:text-amber-400","data-testid":`badge-sub-rollover-${P.name}`,children:[t.jsx(ta,{className:"w-2.5 h-2.5 mr-1"}),"Sub-stream only available"]}),Me.lastCheckedAt&&t.jsxs("span",{className:"text-[10px] text-muted-foreground","data-testid":`text-sub-rollover-checked-${P.n
576ame}`,children:["Last checked: ",vV(Me.lastCheckedAt)]})]}),Me.lastFailureReason&&t.jsxs("p",{className:"text-[10px] text-amber-700 dark:text-amber-400","data-testid":`text-sub-rollover-reason-${P.name}`,children:["Main stream: ",Me.lastFailureReason]})]})})(),(()=>{const Me=Vg.get(P.name);return!P.enabled||!Me||Me.isOnline?null:t.jsxs("div",{className:"-mt-0.5 mb-1.5 ml-5 space-y-1","data-testid":`row-detection-health-${P.name}`,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Ke,{className:"text-[10px] h-4 no-default-active-elevate border-destructive/40 bg-destructive/15 text-destructive","data-testid":`badge-detection-health-${P.name}`,children:[t.jsx(ta,{className:"w-2.5 h-2.5 mr-1"}),"No video from detection stream"]}),Me.lastChecked&&t.jsxs("span",{className:"text-[10px] text-muted-foreground","data-testid":`text-detection-health-checked-${P.name}`,children:["Last checked: ",vV(Me.lastChecked)]})]}),t.jsx("p",{className:"text-[10px] text-destructive","data-testid":`text-detection-health-reason-${P.name}`,children:Me.statusMessage||"Detection stream isn't delivering video — check the sub stream settings on the camera/NVR."})]})})(),!X&&(()=>{const Me=ru===P.name;return t.jsxs("div",{className:"flex items-center justify-between gap-2 py-1.5 px-2 mb-1.5 ml-5 rounded-md bg-muted/30 border border-border","data-testid":`row-camera-state-${P.name}`,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs font-medium",children:"Camera State"}),t.jsx(Ke,{variant:P.enabled?"default":"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:P.enabled?"Enabled":"Disabled"}),Me&&t.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[t.jsx(Fe,{className:"w-3 h-3 animate-spin"}),"Updating…"]})]}),t.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:"Turns this camera on or off for recording, detection, and live view."})]}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:g?t.jsx(sr,{checked:!!P.enabled,disabled:Me,onCheckedChange:st=>Uc.mutate({cameraName:P.name,enabled:st}),"data-testid":`switch-camera-state-${P.name}`}):t.jsx(Ke,{variant:"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:P.enabled?"On":"Off"})})]})})(),!X&&P.enabled&&(()=>{const Me=yv===P.name,ot=(Array.isArray(P.streams)?P.streams:[]).some(yt=>Array.isArray(yt.roles)&&yt.roles.includes("record")),Nt=P.record?.enabled!==!1,Gt=ot&&Nt;return t.jsxs("div",{className:"flex items-center justify-between gap-2 py-1.5 px-2 mb-1.5 ml-5 rounded-md bg-muted/30 border border-border","data-testid":`row-record-video-${P.name}`,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs font-medium",children:"Record Video"}),t.jsx(Ke,{variant:Gt?"default":"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:Gt?"Enabled":"Disabled"}),Me&&t.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[t.jsx(Fe,{className:"w-3 h-3 animate-spin"}),"Updating…"]})]}),t.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:"Saves video footage for later playback."})]}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:g?t.jsx(sr,{checked:Gt,disabled:Me,onCheckedChange:yt=>Mf.mutate({cameraName:P.name,recordEnabled:yt}),"data-testid":`switch-record-video-${P.name}`}):t.jsx(Ke,{variant:"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:Gt?"On":"Off"})})]})})(),!X&&P.enabled&&(()=>{const Me=bv===P.name,ot=(Array.isArray(P.streams)?P.streams:[]).some(Nt=>Array.isArray(Nt.roles)&&Nt.roles.includes("audio"));return t.jsxs("div",{className:"flex items-center justify-between gap-2 py-1.5 px-2 mb-1.5 ml-5 rounded-md bg-muted/30 border border-border","data-testid":`row-record-audio-${P.name}`,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs font-medium",children:"Record Audio"}),t.jsx(Ke,{variant:ot?"default":"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:ot?"Enabled":"Disabled"}),Me&&t.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[t.jsx(Fe,{className:"w-3 h-3 animate-spin"}),"Updating…"]})]}),t.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:"Includes audio in recordings when the camera provides it."})]}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:g?t.jsx(sr,{checked:ot,disabled:Me,onCheckedChange:Nt=>Du.mutate({cameraName:P.name,audioEnabled:Nt}),"data-testid":`switch-record-audio-${P.name}`}):t.jsx(Ke,{variant:"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:ot?"On":"Off"})})]})})(),!X&&P.enabled&&(()=>{const Me=Km===P.name,ot=(Array.isArray(P.streams)?P.streams:[]).some(yt=>Array.isArray(yt.roles)&&yt.roles.includes("detect")),Nt=P.detect?.enabled!==!1,Gt=ot&&Nt;return t.jsxs("div",{className:"flex items-center justify-between gap-2 py-1.5 px-2 mb-1.5 ml-5 rounded-md bg-muted/30 border border-border","data-testid":`row-ai-events-${P.name}`,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs font-medium",children:"Record AI Events"}),t.jsx(Ke,{variant:Gt?"default":"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:Gt?"Enabled":"Disabled"}),Me&&t.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[t.jsx(Fe,{className:"w-3 h-3 animate-spin"}),"Updating…"]})]}),t.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:"Enables detection so activity can appear as searchable AI events."})]}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:g?t.jsx(sr,{checked:Gt,disabled:Me,onCheckedChange:yt=>Yg.mutate({cameraName:P.name,aiEventsEnabled:yt}),"data-testid":`switch-ai-events-${P.name}`}):t.jsx(Ke,{variant:"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:Gt?"On":"Off"})})]})})(),!X&&P.enabled&&(()=>{const Me=Of===P.name;return t.jsxs("div",{className:"flex items-center justify-between gap-2 py-1.5 px-2 mb-1.5 ml-5 rounded-md bg-muted/30 border border-border","data-testid":`row-web-streaming-${P.name}`,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs font-medium",children:"Web Streaming"}),P.usesGo2rtc?t.jsx(Ke,{variant:"outline",className:"text-[10px] h-4 no-default-active-elevate border-blue-500/50 text-blue-500",children:"Live Video Streaming"}):t.jsx(Ke,{variant:"outline",className:"text-[10px] h-4 no-default-active-elevate text-muted-foreground",children:"JPEG fallback"}),Me&&t.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[t.jsx(Fe,{className:"w-3 h-3 animate-spin"}),"Updating…"]})]}),t.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:"Streams live video in the browser instead of refreshed JPEG images."})]}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:g?t.jsx(sr,{checked:!!P.usesGo2rtc,disabled:Me,onCheckedChange:st=>Gm.mutate({cameraName:P.name,useGo2rtc:st}),"data-testid":`switch-web-streaming-${P.name}`}):t.jsx(Ke,{variant:"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:P.usesGo2rtc?"On":"Off"})})]})})(),!X&&P.enabled&&(()=>{const Me=Kg===P.name,st=Bc.get(P.name)?.prioritizeStorage===!0;return t.jsx("div",{className:"py-1.5 px-2 mb-1.5 ml-5 rounded-md bg-muted/30 border border-border","data-testid":`row-prioritize-storage-${P.name}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs font-medium",children:"Adaptive Storage"}),t.jsx(Ke,{variant:st?"default":"secondary",className:"text-[10px] h-4 no-default-active-elevate","data-testid":`badge-prioritize-storage-${P.name}`,children:st?"Enabled":"Disabled"}),Me&&t.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[t.jsx(Fe,{className:"w-3 h-3 animate-spin"}),"Updating…"]})]}),t.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:"Uses the sub-stream to reduce bandwidth and stay within the licensed resolution when the main stream exceeds it."})]}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:g?t.jsx(sr,{checked:st,disabled:Me,"aria-label":`Adaptive Storage for ${P.name}`,onCheckedChange:ot=>bp.mutate({cameraName:P.name,prioritizeStorage:ot}),"data-testid":`switch-prioritize-storage-${P.name}`}):t.jsx(Ke,{variant:"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:st?"On":"Off"})})]})})})(),!X&&P.enabled&&(()=>{const Me=Gg===P.name,st=Bc.get(P.name)?.streamShifting===!0;return t.jsx("div",{className:"py-1.5 px-2 mb-1.5 ml-5 rounded-md bg-muted/30 border border-border","data-testid":`row-stream-shifting-${P.name}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs font-medium",children:"Stream Shifting"}),t.jsx(Ke,{variant:st?"default":"secondary",className:"text-[10px] h-4 no-default-active-elevate","data-testid":`badge-stream-shifting-${P.name}`,children:st?"Enabled":"Disabled"}),Me&&t.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[t.jsx(Fe,{className:"w-3 h-3 animate-spin"}),"Updating…"]})]}),t.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:"Switches detection to the main stream if the sub-stream stops delivering video."})]}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:g?t.jsx(sr,{checked:st,disabled:Me,onCheckedChange:ot=>Vm.mutate({cameraName:P.name,streamShifting:ot}),"data-testid":`switch-stream-shifting-${P.name}`}):t.jsx(Ke,{variant:"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:st?"On":"Off"})})]})})})(),!X&&P.enabled&&(()=>{const Me=Li.get(P.name),st=!!Me?.ptzUserEnabled,ot=fi===P.name,Nt=Me?.ptzLastTestResult||null,Gt=Me?.ptzLastTestMessage||null,yt=Me?.ptzLastTestAt?new Date(Me.ptzLastTestAt).getTime():0,hs=yt>0&&Date.now()-yt<600*1e3,jn=!st&&hs&&Nt&&Nt!=="ok"?{auth_failed:"Auth failed",unreachable:"Unreachable",timeout:"Timed out",no_ptz_profile:"No PTZ",error:"Error"}[Nt]||"Failed":null;return t.jsxs("div",{className:"flex items-center justify-between gap-2 py-1.5 px-2 mb-1.5 ml-5 rounded-md bg-muted/30 border border-border","data-testid":`row-ptz-toggle-${P.name}`,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs font-medium",children:"PTZ Controls"}),t.jsx(Ke,{variant:st?"default":"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:st?"Enabled":"Disabled"}),ot?t.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[t.jsx(Fe,{className:"w-3 h-3 animate-spin"}),"Testing ONVIF…"]}):jn?t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx(Ke,{variant:"outline",className:"text-[10px] h-4 no-default-active-elevate border-destructive/50 text-destructive cursor-help",children:jn})}),Gt&&t.jsx(Yt,{className:"max-w-xs",children:Gt})]}):null]}),t.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:"Tests ONVIF and enables pan, tilt, and zoom controls for this camera."})]}),t.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:g?t.jsx(sr,{checked:st,disabled:ot||ic.isPending,onCheckedChange:so=>{so?Lh.mutate(P.name):ic.mutate(P.name)}
576,"data-testid":`switch-ptz-${P.name}`}):t.jsx(Ke,{variant:"secondary",className:"text-[10px] h-4 no-default-active-elevate",children:st?"On":"Off"})})]})})(),X?t.jsxs("div",{className:"space-y-3 mt-2",children:[t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 p-2.5 space-y-2",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("h5",{className:"text-xs font-semibold",children:"Quick Connect"}),t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Pick a model and fill in the IP and login — RTSP URLs are built for you."})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:"Manufacturer"}),t.jsxs(Us,{value:hr.brand,onValueChange:Me=>_t({...hr,brand:Me,model:""}),children:[t.jsx($s,{className:"h-7 text-xs mt-0.5","data-testid":`select-qc-brand-${P.name}`,children:t.jsx(zs,{placeholder:"Pick brand…"})}),t.jsx(Fs,{className:"max-h-72",children:$u.map(Me=>t.jsx(rt,{value:Me,"data-testid":`select-qc-brand-option-${Me}`,children:Me},Me))})]})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:"Model"}),t.jsxs(Us,{value:hr.model,onValueChange:Me=>{const st=lm(hr.brand,Me);_t({...hr,model:Me,port:st?String(st.port):hr.port})},disabled:!hr.brand,children:[t.jsx($s,{className:"h-7 text-xs mt-0.5","data-testid":`select-qc-model-${P.name}`,children:t.jsx(zs,{placeholder:hr.brand?"Pick model…":"Pick brand first"})}),t.jsx(Fs,{className:"max-h-72",children:Ee.map(Me=>{const st=Sp(Me);return t.jsxs(rt,{value:st,"data-testid":`select-qc-model-option-${Me.model}`,children:[Me.series," • ",Me.model]},st)})})]})]})]}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:"IP Address"}),t.jsx(ke,{value:hr.ip,onChange:Me=>_t({...hr,ip:Me.target.value}),placeholder:"192.168.1.10",className:"h-7 text-xs mt-0.5 font-mono","data-testid":`input-qc-ip-${P.name}`})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:"RTSP Port"}),t.jsx(ke,{value:hr.port,onChange:Me=>_t({...hr,port:Me.target.value.replace(/[^\d]/g,"")}),placeholder:xe?String(xe.port):"554",className:"h-7 text-xs mt-0.5 font-mono","data-testid":`input-qc-port-${P.name}`})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:"User"}),t.jsx(ke,{value:hr.user,onChange:Me=>_t({...hr,user:Me.target.value}),placeholder:"admin",className:"h-7 text-xs mt-0.5 font-mono",autoComplete:"off",name:`rtsp-qc-user-${P.name}`,"data-testid":`input-qc-user-${P.name}`})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:"Password"}),t.jsx(ke,{type:"password",value:hr.pass,onChange:Me=>_t({...hr,pass:Me.target.value}),placeholder:"••••••••",className:"h-7 text-xs mt-0.5 font-mono",autoComplete:"new-password",name:`rtsp-qc-pass-${P.name}`,"data-testid":`input-qc-pass-${P.name}`})]})]}),xe&&t.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Using ",t.jsxs("span",{className:"font-mono",children:[xe.brand," ",xe.model]}),xe.type==="NVR"||xe.type==="DVR"?` — channel ${Ym(P.name,!0)} of the recorder.`:" — single-camera URL."]})]}),t.jsxs("div",{className:`rounded-md border p-2.5 space-y-2 ${nm(P.name)?"border-muted bg-muted/40 opacity-70":"border-border bg-muted/20"}`,children:[t.jsx("h5",{className:"text-xs font-semibold",children:"Motion Detection"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:"Sensitivity (1-255)"}),t.jsx(ke,{type:"number",min:1,max:255,value:Ht.motionThreshold,onChange:Me=>vr(st=>({...st,motionThreshold:Math.min(255,Math.max(1,parseInt(Me.target.value)||1))})),disabled:nm(P.name),className:"h-7 text-xs mt-0.5","data-testid":`input-motion-threshold-${P.name}`})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:"Threshold (10-50)"}),t.jsx(ke,{type:"number",min:10,max:50,value:Ht.motionContourArea,onChange:Me=>vr(st=>({...st,motionContourArea:Math.min(50,Math.max(10,parseInt(Me.target.value)||10))})),disabled:nm(P.name),className:"h-7 text-xs mt-0.5","data-testid":`input-contour-area-${P.name}`})]})]}),Oc(P.name)&&t.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Controlled globally under Record Options."})]}),t.jsxs(m9,{open:Sr,onOpenChange:Os,children:[t.jsx(h9,{asChild:!0,children:t.jsxs(L,{variant:"ghost",size:"sm",className:"h-7 text-xs w-full justify-between px-2","data-testid":`button-toggle-advanced-${P.n
576ame}`,children:[t.jsx("span",{children:"Advanced — raw RTSP URLs"}),t.jsx(Xa,{className:`w-3.5 h-3.5 transition-transform ${Sr?"rotate-180":""}`})]})}),t.jsx(p9,{className:"pt-2",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:Ht.useGo2rtc?"Record Source (Primary Stream)":"Main Stream (Record)"}),t.jsx(ke,{value:Ht.mainStreamUrl,onChange:Me=>vr(st=>({...st,mainStreamUrl:Me.target.value})),placeholder:"rtsp://...",className:"h-7 text-xs font-mono mt-0.5","data-testid":`input-main-stream-${P.name}`}),(()=>{const Me=Bc.get(P.name);return!Me||Me.recordingSource!=="sub"||!Me.lastFailureReason?null:t.jsxs("div",{className:"mt-1 inline-flex items-start gap-1 rounded px-1.5 py-0.5 text-[10px] border border-amber-500/40 bg-amber-500/15 text-amber-700 dark:text-amber-400","data-testid":`chip-main-stream-error-${P.name}`,children:[t.jsx(ta,{className:"w-2.5 h-2.5 mt-px shrink-0"}),t.jsx("span",{children:Me.lastFailureReason})]})})()]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-[11px] text-muted-foreground",children:Ht.useGo2rtc?"Detect Source (Secondary Stream)":"Sub Stream (Detect)"}),t.jsx(ke,{value:Ht.subStreamUrl,onChange:Me=>vr(st=>({...st,subStreamUrl:Me.target.value})),placeholder:"rtsp://...",className:"h-7 text-xs font-mono mt-0.5","data-testid":`input-sub-stream-${P.name}`})]})]})})]}),(()=>{const Me=Rt[P.name];if(!Me)return null;const st=(ot,Nt)=>{if(!Nt)return null;if(Nt.ok){const Gt=Nt.width&&Nt.height?`${Nt.width}x${Nt.height}`:"",yt=Nt.fps?`@ ${Nt.fps} fps`:"",hs=[];return typeof Nt.framesReceived=="number"&&typeof Nt.durationSec=="number"&&hs.push(`${Nt.framesReceived} frames in ${Nt.durationSec}s`),typeof Nt.measuredFps=="number"&&hs.push(`${Nt.measuredFps} fps measured`),typeof Nt.bitrateKbps=="number"&&hs.push(Nt.bitrateKbps>=1e3?`${(Nt.bitrateKbps/1e3).toFixed(1)} Mbps`:`${Nt.bitrateKbps} kbps`),Nt.unstable?t.jsxs("div",{className:"text-[11px] text-amber-600 dark:text-amber-400","data-testid":`text-stream-test-${ot.toLowerCase()}-${P.name}`,children:[t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsx(ta,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",children:ot})," ",Nt.codec||"video"," ",Gt," ",yt,hs.length>0&&t.jsxs(t.Fragment,{children:[" · ",hs.join(" · ")]})]})]}),Nt.warning&&t.jsx("div",{className:"ml-5 text-[10px]","data-testid":`text-stream-warning-${ot.toLowerCase()}-${P.name}`,children:Nt.warning})]}):t.jsx("div",{className:"text-[11px] text-emerald-600 dark:text-emerald-400","data-testid":`text-stream-test-${ot.toLowerCase()}-${P.name}`,children:t.jsxs("div",{className:"flex items-start gap-2",children:[Nt.snapshot&&t.jsx("img",{src:Nt.snapshot,alt:`${ot} preview`,className:"w-20 h-12 rounded border border-border object-cover shrink-0","data-testid":`img-stream-test-snapshot-${ot.toLowerCase()}-${P.name}`}),t.jsxs("div",{className:"flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-start gap-1.5 min-w-0",children:[t.jsx(ar,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"font-medium",children:ot})," ",Nt.codec||"video"," ",Gt," ",yt,hs.length>0&&t.jsxs(t.Fragment,{children:[" · ",hs.join(" · ")]})]})]}),!Nt.snapshot&&Nt.snapshotError&&t.jsxs("div",{className:"ml-5 mt-0.5 text-[10px] text-muted-foreground font-mono break-all","data-testid":`text-stream-snapshot-error-${ot.toLowerCase()}-${P.name}`,children:["thumbnail unavailable: ",Nt.snapshotError]})]})]})})}return t.jsxs("div",{className:"text-[11px] text-destructive","data-testid":`text-stream-test-${ot.toLowerCase()}-${P.name}`,children:[t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsx(ta,{className:"w-3.5 h-3.5 mt-0.5 shrink-0"}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",children:ot})," ",Nt.error||"Failed"]})]}),Nt.details&&t.jsx("div",{className:"ml-5 text-[10px] text-muted-foreground font-mono break-all",children:Nt.details})]})};return t.jsxs("div",{className:"rounded-md bg-muted/30 border border-border px-2 py-1.5 space-y-1","data-testid":`panel-stream-test-${P.name}`,children:[Me.status==="running"&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}),t.jsx("span",{children:"Probing streams from the edge device…"})]}),Me.status==="error"&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-destructive flex-wrap",children:[t.jsx(ta,{className:"w-3.5 h-3.5"}),t.jsx("span",{children:Me.message||"Stream test failed"}),pi&&j&&t.jsx(e5,{edgeDeviceId:j,context:"test-stream",errorText:Me.message||"Stream test failed",compact:!0})]}),Me.status==="done"&&t.jsxs(t.Fragment,{children:[st("Record",Me.main),st("Detect",Me.sub),pi&&j&&(Me.main&&!Me.main.ok||Me.sub&&!Me.sub.ok)&&t.jsx(e5,{edgeDeviceId:j,context:"test-stream",errorText:[Me.main&&!Me.main.ok?`Record stream
576: ${Me.main.error||"failed"}${Me.main.details?` — ${Me.main.details}`:""}`:null,Me.sub&&!Me.sub.ok?`Detect stream: ${Me.sub.error||"failed"}${Me.sub.details?` — ${Me.sub.details}`:""}`:null].filter(Boolean).join(`
577`),compact:!0})]})]})})(),t.jsxs("div",{className:"flex justify-end gap-2",children:[(()=>{const Me=Rt[P.name]?.status==="running",st=!Ht.mainStreamUrl?.trim()&&!Ht.subStreamUrl?.trim(),ot=!w?.isOnline,Nt=Me||st||ot,Gt=ot?"Edge device is offline — cannot test streams":st?"Enter a Record or Detect URL to test":"",yt=t.jsxs(L,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>gi(P.name),disabled:Nt,"data-testid":`button-test-streams-${P.name}`,children:[Me?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(vc,{className:"w-3.5 h-3.5 mr-1"}),Me?"Testing…":"Test Streams"]});return Nt&&Gt?t.jsxs(Wt,{children:[t.jsx(Kt,{asChild:!0,children:t.jsx("span",{tabIndex:0,children:yt})}),t.jsx(Yt,{children:Gt})]}):yt})(),t.jsx(L,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{lt(null),At(Me=>{const{[P.name]:st,...ot}=Me;return ot})},"data-testid":`button-cancel-edit-${P.name}`,children:"Cancel"}),t.jsxs(L,{size:"sm",className:"h-7 text-xs",onClick:()=>Np(P.name),disabled:lo,"data-testid":`button-save-camera-${P.name}`,children:[lo?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(Hd,{className:"w-3.5 h-3.5 mr-1"}),lo?"Saving...":"Save"]})]})]}):t.jsx(t.Fragment,{children:P.streams.length>0?t.jsx("div",{className:"space-y-1 mt-1",children:(()=>{const Me=Gt=>{const yt=Gt.toLowerCase();return yt.includes("/streaming/channels/")||yt.includes("/isapi/")?"Hikvision":yt.includes("/cam/realmonitor")||yt.includes("/live")?"Dahua":yt.includes("/onvif")||yt.includes("/media/video")?"ONVIF":yt.includes("/videostream.cgi")||yt.includes("/ipcam/")?"Foscam":yt.includes("/axis-media/media.amp")||yt.includes("/axis-cgi/")?"Axis":yt.includes("/stw-cgi/")||yt.includes("/profile")?"Hanwha":yt.includes("/mediainput/")||yt.includes("/videoinput_")?"Bosch":yt.includes("/video1")||yt.includes("/mpeg4/")?"Vivotek":yt.includes("/h264preview_")||yt.includes("/snap.jpg")?"Reolink":yt.includes("/unicast")||yt.includes("/ch0_")?"Amcrest":"Generic"},st=P.usesGo2rtc?P.go2rtcUrl||"":P.streams[0]?.path||"",ot=st?Me(st):"Unknown",Nt=P.streams.map(Gt=>Gt.roles.join("/")).join(", ");return t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx(Ke,{variant:"outline",className:"text-[10px] h-5 no-default-active-elevate border-violet-500/40 text-violet-600 dark:text-violet-400","data-testid":`badge-manufacturer-${P.name}`,children:ot}),t.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[P.streams.length," stream",P.streams.length!==1?"s":""," (",Nt,")"]})]})})()}):t.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No stream inputs configured"})})]},P.name)})})]}),V==="camera-import-export"&&t.jsxs("div",{className:"max-w-4xl space-y-4",children:[t.jsxs("div",{className:"p-4 rounded-lg border border-border bg-muted/20 space-y-3","data-testid":"panel-camera-import-export",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("h4",{className:"font-medium text-sm flex items-center gap-2",children:[t.jsx(eP,{className:"w-4 h-4 text-muted-foreground"}),"Import / Export"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Import camera connection and motion settings via spreadsheet. Row count must match existing cameras — extra rows are flagged as errors."})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsxs(L,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>il("csv"),disabled:!Pr?.cameras||Pr.cameras.length===0,"data-testid":"button-camera-export-csv",children:[t.jsx(ya,{className:"w-3.5 h-3.5 mr-1"}),"Export CSV"]}),t.jsxs(L,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>il("xlsx"),disabled:!Pr?.cameras||Pr.cameras.length===0,"data-testid":"button-camera-export-xlsx",children:[t.jsx(ya,{className:"w-3.5 h-3.5 mr-1"}),"Export XLSX"]}),g&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:al,type:"file",accept:".csv,.xlsx,.xls,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel",className:"hidden",onChange:P=>{const X=P.target.files?.[0];X&&ci(X),P.target.value=""},"data-testid":"input-camera-import-file"}),t.jsxs(L,{size:"sm",className:"h-8 text-xs",onClick:()=>al.current?.click(),disabled:!Pr?.cameras||Pr.cameras.length===0,"data-testid":"button-camera-import",children:[t.jsx(Om,{className:"w-3.5 h-3.5 mr-1"}),"Import"]})]})]})]}),t.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Required columns: ",t.jsx("code",{className:"text-[10px]",children:"Camera_Name, Camera_Or_NVR, IP_Address, RTSP_Port, User, Password, Motion_Sens, Motion_Threshold"})]}),(!Pr?.cameras||Pr.cameras.length===0)&&t.jsxs("div",{className:"text-xs text-muted-foreground italic",children:["No cameras configured yet. Add cameras in ",t.jsx("span",{className:"font-medium",children:"Camera Configuration"})," first."]})]}),Zc&&t.jsx(zd,{open:!!Zc,onOpenChange:P=>{P||il(null)},children:t.jsxs(bd,{children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:"Export contains plaintext passwords"}),t.jsxs(Sd,{children:["The exported ",Zc?.toUpperCase()," file will include the real RTSP password for every camera. Store it securely and delete when no longer needed."]})]}),t.jsxs(jd,{children:[t.jsx(Gc,{"data-testid":"button-cancel-camera-export",children:"Cancel"}),t.jsxs(Cd,{onClick:()=>{const P=Zc;il(null),Df(P)},"data-testid":"button-confirm-camera-export",children:[t.jsx(ya,{className:"w-3.5 h-3.5 mr-1"}),"Download"]})]})]})}),Jl&&t.jsx(Ys,{open:Jl,onOpenChange:P=>{!P&&!ol&&Uo(!1)},children:t.jsxs(Ws,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Review Camera Import"}),t.jsxs(cr,{children:[Cc," — ",oa.length," to update, ",Tr.length," unchanged, ",ha.length," error(s)."]})]}),t.jsxs("div",{className:"overflow-y-auto pr-2 -mr-2 space-y-4 text-xs",children:[ha.length>0&&t.jsxs("div",{"data-testid":"section-import-errors",children:[t.jsxs("div",{className:"font-medium text-destructive mb-1.5",children:["Errors (",ha.length,") — these rows will be skipped"]}),t.jsx("div",{className:"space-y-1",children:ha.map((P,X)=>t.jsxs("div",{className:"flex items-start gap-2 p-2 rounded border border-destructive/30 bg-destructive/5","data-testid":`row-import-error-${X}`,children:[t.jsx(ta,{className:"w-3.5 h-3.5 text-destructive shrink-0 mt-0.5"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{children:[t.jsxs("span",{className:"font-mono",children:["Row ",P.rowNumber]})," — ",t.jsx("span",{className:"font-medium",children:P.cameraName})]}),t.jsx("div",{className:"text-muted-foreground",children:P.message})]})]},X))})]}),oa.length>0&&t.jsxs("div",{"data-testid":"section-import-updates",children:[t.jsxs("div",{className:"font-medium mb-1.5",children:["Will be updated (",oa.length,")"]}),t.jsx("div",{className:"space-y-2",children:oa.map(P=>t.jsxs("div",{className:"p-2 rounded border border-border bg-muted/30","data-testid":`row-import-update-${P.matchedChannel}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[t.jsx("span",{className:"font-medium",children:P.row.cameraName}),t.jsx("span",{className:"text-muted-foreground font-mono text-[10px]",children:P.matchedChannel})]}),t.jsx("div",{className:"space-y-0.5",children:P.changes.map((X,xe)=>t.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 items-baseline",children:[t.jsx("span",{className:"text-muted-foreground",children:X.field}),t.jsxs("span",{className:"truncate",children:[t.jsx("span",{className:"line-through text-muted-foreground",children:X.from}),t.jsx("span",{className:"mx-1",children:"→"}),t.jsx("span",{className:"font-medium",children:X.to})]})]},xe))})]},P.matchedChannel))})]}),Tr.length>0&&t.jsxs("div",{"data-testid":"section-import-unchanged",children:[t.jsxs("div",{className:"font-medium text-muted-foreground mb-1.5",children:["Unch
577anged (",Tr.length,")"]}),t.jsx("div",{className:"text-muted-foreground",children:Tr.map(P=>P.row.cameraName).join(", ")})]}),oa.length===0&&ha.length===0&&t.jsx("div",{className:"text-center text-muted-foreground py-4",children:"Nothing to apply."})]}),t.jsxs(In,{className:"border-t pt-3 flex-col sm:flex-row gap-2",children:[ol&&t.jsxs("span",{className:"text-xs text-muted-foreground mr-auto flex items-center gap-1.5",children:[t.jsx(Fe,{className:"w-3 h-3 animate-spin"}),"Applying ",ll.done,"/",ll.total,"…"]}),t.jsx(L,{variant:"outline",size:"sm",onClick:()=>Uo(!1),disabled:ol,"data-testid":"button-cancel-import",children:"Cancel"}),t.jsxs(L,{size:"sm",onClick:_p,disabled:ol||oa.length===0,"data-testid":"button-apply-import",children:[ol?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(Hd,{className:"w-3.5 h-3.5 mr-1"}),"Apply ",oa.length," change",oa.length!==1?"s":""]})]})]})})]}),V==="streams"&&t.jsx(t.Fragment,{children:Lr&&t.jsx(zd,{open:!!Lr,onOpenChange:P=>{P||Vr(null)},children:t.jsxs(bd,{children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:"Clear Camera"}),t.jsxs(Sd,{children:['This will reset camera "',Lr,'" to default settings and disable it. The camera slot will remain in the configuration and can be reassigned later.']})]}),t.jsxs(jd,{children:[t.jsx(Gc,{"data-testid":"button-cancel-delete-camera",children:"Cancel"}),t.jsxs(Cd,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>Lr&&Xg(Lr),disabled:lo,"data-testid":"button-confirm-delete-camera",children:[lo?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):null,"Clear & Disable"]})]})]})})}),V==="stream-options"&&t.jsxs("div",{className:"max-w-lg space-y-8 py-2",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold mb-1",children:"Stream Options"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Live view parameters — applies globally for this device and affects all users."})]}),Wn?t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"p-4 rounded-lg border border-border bg-card space-y-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Stream Protocol"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Choose how cameras deliver live video. Only one protocol is active at a time."})]}),t.jsx("div",{className:"grid grid-cols-2 gap-2",children:["auto","webrtc","mse","jpeg"].map(P=>t.jsxs("button",{"data-testid":`btn-protocol-${P}`,onClick:()=>ir(P),className:["flex flex-col items-center gap-1 p-3 rounded-lg border text-center transition-colors",Rs===P?"border-primary bg-primary/10 text-primary":"border-border bg-background text-muted-foreground hover:bg-muted"].join(" "),children:[t.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:P==="auto"?"Auto":P==="webrtc"?"WebRTC":P==="mse"?"MSE":"JPEG"}),t.jsxs("span",{className:"text-[10px] leading-tight",children:[P==="auto"&&"WebRTC → MSE → JPEG fallback",P==="webrtc"&&"Ultra low-latency, direct stream",P==="mse"&&"Reliable, proxied streaming",P==="jpeg"&&"Snapshot fallback, all devices"]})]},P))})]}),t.jsxs("div",{className:"p-4 rounded-lg border border-border bg-card space-y-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Low Bandwidth JPEG"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"JPEG snapshot rate for cameras not using RTC. Higher values show more frequent frames but increase bandwidth usage."})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(km,{min:1,max:3,step:1,value:[Vn],onValueChange:([P])=>Ns(P),className:"flex-1","data-testid":"slider-jpeg-fps"}),t.jsxs("span",{className:"text-sm font-semibold w-14 text-right tabular-nums",children:[Vn," fps"]})]}),t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground px-1",children:[t.jsx("span",{children:"1 fps (low bandwidth)"}),t.jsx("span",{children:"3 fps (smoother)"})]})]})]}),t.jsxs("div",{className:"p-4 rounded-lg border border-border bg-card space-y-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"JPEG Image Quality"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Quality level for JPEG snapshots sent from the camera. Lower values reduce bandwidth; higher values produce sharper images."})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsx(km,{min:40,max:100,step:5,value:[or],onValueChange:([P])=>os(P),className:"flex-1","data-testid":"slider-jpeg-quality"}),t.jsxs("span",{className:"text-sm font-semibold w-14 text-right tabular-nums",children:[or,"%"]})]}),t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground px-1",children:[t.jsx("span",{children:"40% (low bandwidth)"}),t.jsx("span",{children:"100% (full quality)"})]})]})]}),t.jsx("div",{className:"p-4 rounded-lg border border-border bg-card",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Turn off main stream for live viewing"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"When on, live viewing always uses the lower-bandwidth sub stream, even if the quality is set to Auto or Main. Recordings and playback are not affected."})]}),t.jsx(sr,{checked:$t,onCheckedChange:kr,"data-testid":"switch-force-sub-stream-live"})]})})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"h-12 bg-muted rounded-lg animate-pulse"}),t.jsx("div",{className:"h-20 bg-muted rounded-lg animate-pulse"})]})]}),V==="record-options"&&t.jsxs("div",{className:"max-w-lg space-y-6 py-2",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold mb-1",children:"Record Options"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Extra seconds added to the start and end of each event recording. Applies to local clips, cloud-synced clips, and the device's own event clips so playback windows match everywhere."})]}),Ni?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 rounded-lg border border-border bg-card space-y-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Pre-Event Seconds"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"How many seconds of footage to include before the event starts. Range 0–60. Default 15."})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ke,{type:"number",min:0,max:60,step:1,value:Va,onChange:P=>Yi(Math.max(0,Math.min(60,parseInt(P.target.value||"0",10)||0))),className:"w-24","data-testid":"input-record-pre"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"seconds"})]})]}),t.jsxs("div",{className:"p-4 rounded-lg border border-border bg-card space-y-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Post-Event Seconds"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"How many seconds of footage to include after the event ends. Range 0–60. Default 15."})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ke,{type:"number",min:0,max:60,step:1,value:
577Ii,onChange:P=>To(Math.max(0,Math.min(60,parseInt(P.target.value||"0",10)||0))),className:"w-24","data-testid":"input-record-post"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"seconds"})]})]}),t.jsxs("div",{className:"p-4 rounded-lg border border-border bg-card space-y-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Global Motion Settings"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Use one sensitivity and threshold for every camera, or for a selected group of cameras."})]}),t.jsx(sr,{checked:Ic,disabled:Ko||!Pr?.cameras?.length,onCheckedChange:P=>{if(P&&id==="selected"&&Di.length===0){l({title:"Choose cameras first",description:"Select at least one camera before enabling Global Motion Settings.",variant:"destructive"});return}Tu(P),Al(!0),po({globalMotionEnabled:P,globalMotionUpdate:!0})},"data-testid":"switch-global-motion-settings"})]}),Pr?.cameras?.length?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Sensitivity (1–255)"}),t.jsx(ke,{type:"number",min:1,max:255,value:tu,onChange:P=>{bn(Math.max(1,Math.min(255,parseInt(P.target.value||"1",10)||1))),Al(!0)},disabled:Ko,className:"mt-1","data-testid":"input-global-motion-sensitivity"})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Threshold (10–50)"}),t.jsx(ke,{type:"number",min:10,max:50,value:Tl,onChange:P=>{od(Math.max(10,Math.min(50,parseInt(P.target.value||"10",10)||10))),Al(!0)},disabled:Ko,className:"mt-1","data-testid":"input-global-motion-threshold"})]})]}),t.jsxs("div",{children:[t.jsx(re,{className:"text-xs",children:"Apply to"}),t.jsxs(Us,{value:id,onValueChange:P=>{El(P),Al(!0)},disabled:Ko,children:[t.jsx($s,{className:"mt-1","data-testid":"select-global-motion-scope",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All cameras"}),t.jsx(rt,{value:"selected",children:"Selected cameras"})]})]})]}),id==="selected"&&t.jsxs("div",{className:"rounded-md border border-border px-3 py-2 space-y-2 max-h-44 overflow-y-auto",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose the cameras controlled by these values."}),Pr.cameras.map(P=>{const X=Di.includes(P.name);return t.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[t.jsx(On,{checked:X,disabled:Ko,onCheckedChange:xe=>{Xi(Ee=>xe?Array.from(new Set([...Ee,P.name])):Ee.filter(_t=>_t!==P.name)),Al(!0)},"data-testid":`checkbox-global-motion-camera-${P.name}`}),t.jsx("span",{children:P.displayName||P.name}),P.displayName&&t.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:P.name})]},P.name)})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:Ic?"Camera-level motion controls are locked for the cameras selected above. Save changes, then use Apply Changes in YAML Config.":"Set the values and scope, then turn this on to apply them and queue an Edge device restart."})]}):t.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a camera in Camera Configuration before enabling global motion settings."})]}),t.jsxs("div",{className:"p-4 rounded-lg border border-border bg-card space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Sub-Stream Rollover"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"If a camera's main stream stops responding but its sub stream still works, automatically keep recording from the sub stream until the main stream comes back. On by default."})]}),t.jsx(sr,{checked:Oi,onCheckedChange:P=>{ad(P),po({subStreamRolloverEnabled:P,silent:!0})},"data-testid":"switch-sub-stream-rollover"})]}),Oi&&t.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm",children:"Re-check interval"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"How often to re-test each camera's streams. Range 1–1440 minutes. Default 15."})]}),t.jsx(ke,{type:"number",min:1,max:1440,step:1,value:ji,onChange:P=>
577Wa(Math.max(1,Math.min(1440,parseInt(P.target.value||"60",10)||60))),className:"w-24","data-testid":"input-sub-stream-rollover-interval"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"minutes"})]})]}),t.jsx(TBe,{options:zm,timezone:w?.edgeDevice?.timezone,saving:Oh,saved:!!Hm,onChange:P=>{const X=Object.fromEntries(Object.keys(P).filter(xe=>P[xe]!==zm[xe]).map(xe=>[xe,P[xe]]));Au(P),cd(xe=>({...xe,...X})),Mu(null)},onSave:su}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(L,{onClick:()=>po(),disabled:Ko,"data-testid":"button-save-record-options",children:[Ko?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):null,Ko?"Saving...":"Save"]}),Ml&&!Ko&&t.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"text-record-options-saved",children:"Saved. Use Apply Changes in YAML Config to push to the device."})]})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"h-20 bg-muted rounded-lg animate-pulse"}),t.jsx("div",{className:"h-20 bg-muted rounded-lg animate-pulse"})]})]}),V==="system-time"&&t.jsxs("div",{className:"max-w-2xl space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(L,{size:"sm",onClick:Ep,disabled:ti||!j||!x,"data-testid":"button-refresh-system-time",className:"h-7 sm:h-8 text-xs sm:text-sm",children:[ti?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(cn,{className:"w-3.5 h-3.5 mr-1"}),ti?"Reading...":"Refresh"]}),!x&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Edge sync must be configured to manage system time."})]}),ti&&!La&&t.jsxs("div",{className:"p-4 border border-border rounded-lg space-y-3",children:[t.jsx(Bt,{className:"h-5 w-48"}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Bt,{className:"h-9"}),t.jsx(Bt,{className:"h-9"})]})]}),La&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-4 border border-border rounded-lg space-y-2","data-testid":"system-time-current",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(cn,{className:"w-4 h-4 text-primary"}),t.jsx("h3",{className:"font-medium text-sm",children:"Current Device Time"})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1 text-sm",children:[t.jsxs("div",{className:"flex justify-between sm:block",children:[t.jsx("span",{className:"text-muted-foreground text-xs mr-2",children:"Date & Time"}),t.jsx("span",{className:"font-mono","data-testid":"text-current-datetime",children:La.datetime||"—"})]}),t.jsxs("div",{className:"flex justify-between sm:block",children:[t.jsx("span",{className:"text-muted-foreground text-xs mr-2",children:"Timezone"}),t.jsxs("span",{className:"font-mono","data-testid":"text-current-timezone",children:[La.timezone||"—",La.utcOffset?` (${La.utcOffset})`:""]})]}),t.jsxs("div",{className:"flex justify-between sm:block",children:[t.jsx("span",{className:"text-muted-foreground text-xs mr-2",children:"Automatic Sync"}),t.jsx("span",{"data-testid":"text-current-ntp",children:t.jsx(Ke,{variant:La.ntp?"secondary":"outline",className:"text-xs",children:La.ntp?"On (NTP)":"Off (manual)"})})]})]})]}),t.jsxs("div",{className:"p-4 border border-border rounded-lg space-y-4",children:[t.jsx("h3",{className:"font-medium text-sm",children:"Change Settings"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{checked:_c,onCheckedChange:tn,"data-testid":"switch-system-time-ntp"}),t.jsx(re,{className:"text-sm",children:"Sync time automatically (NTP)"})]}),t.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"When automatic sync is on, the date and time are kept in step with internet time servers and can't be set manually."}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Timezone"}),t.jsx(ke,{value:Pd,onChange:P=>wi(P.target.value),placeholder:"Search timezones (e.g. New_York)",className:"h-9 text-sm","data-testid":"input-timezone-filter"}),t.jsxs(Us,{value:qo,onValueChange:Hn,children:[t.jsx($s,{className:"h-9 text-sm","data-testid":"select-timezone",children:t.jsx(zs,{placeholder:"Select a timezone"})}),t.jsxs(Fs,{className:"max-h-72",children:[gV.filter(P=>P.toLowerCase().includes(Pd.trim().toLowerCase())).map(P=>t.jsx(rt,{value:P,"data-testid":`timezone-option-${P}`,children:P},P)),qo&&!gV.includes(qo)&&t.jsx(rt,{value:qo,children:qo})]})]})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Date"}),t.jsx(ke,{type:"date",value:mo,onChange:P=>qn(P.target.value),disabled:_c,className:"h-9 text-sm font-mono","data-testid":"input-system-date"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Time"}),t.jsx(ke,{type:"time",value:_o,onChange:P=>tm(P.target.value),disabled:_c,className:"h-9 text-sm font-mono","data-testid":"input-system-time"})]})]}),t.jsx("div",{className:"flex justify-end pt-2 border-t border-border",children:t.jsxs(L,{size:"sm",onClick:$f,disabled:uo||ti,"data-testid":"button-save-system-time",className:"h-8 text-xs",children:[uo?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(Vl,{className:"w-3.5 h-3.5 mr-1"}
577),uo?"Saving...":"Save Changes"]})})]})]}),!ti&&!La&&t.jsxs("div",{className:"text-center py-12 border border-dashed rounded-lg border-border",children:[t.jsx(cn,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:'Click "Refresh" to read the current date, time, and timezone from the Edge device.'})]})]}),V==="network"&&t.jsxs("div",{className:"max-w-4xl space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(L,{size:"sm",onClick:an,disabled:cl||!j||!x,"data-testid":"button-scan-network",className:"h-7 sm:h-8 text-xs sm:text-sm",children:[cl?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(Wh,{className:"w-3.5 h-3.5 mr-1"}),cl?"Scanning...":"Scan Adapters"]}),!x&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Edge sync must be configured to scan network adapters."})]}),cl&&dl.length===0&&t.jsx("div",{className:"space-y-3",children:[1,2].map(P=>t.jsxs("div",{className:"p-4 border border-border rounded-lg space-y-3",children:[t.jsx(Bt,{className:"h-5 w-32"}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsx(Bt,{className:"h-9"}),t.jsx(Bt,{className:"h-9"}),t.jsx(Bt,{className:"h-9"}),t.jsx(Bt,{className:"h-9"})]})]},P))}),dl.length>0&&t.jsx("div",{className:"space-y-4",children:dl.map(P=>{const X=Ho[P.name]||P,xe=X.dhcp!==P.dhcp||X.ipAddress!==P.ipAddress||X.subnet!==P.subnet||X.gateway!==P.gateway||X.dns1!==P.dns1||X.dns2!==P.dns2;return t.jsxs("div",{className:"p-4 border border-border rounded-lg space-y-4","data-testid":`network-interface-${P.name}`,children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(cg,{className:"w-4 h-4 text-primary"}),t.jsx("h3",{className:"font-medium text-sm",children:P.name}),P.mac&&t.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:P.mac})]}),t.jsx(Ke,{variant:P.dhcp?"secondary":"outline",className:"text-xs",children:P.dhcp?"DHCP":"Static"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(sr,{checked:X.dhcp,onCheckedChange:Ee=>Id(P.name,"dhcp",Ee),"data-testid":`switch-dhcp-${P.name}`}),t.jsx(re,{className:"text-sm",children:"DHCP (automatic)"})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"IP Address"}),t.jsx(ke,{value:X.ipAddress,onChange:Ee=>Id(P.name,"ipAddress",Ee.target.value),disabled:X.dhcp,placeholder:"192.168.1.100",className:"h-9 text-sm font-mono","data-testid":`input-ip-${P.name}`})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Subnet Mask"}),t.jsx(ke,{value:X.subnet,onChange:Ee=>Id(P.name,"subnet",Ee.target.value),disabled:X.dhcp,placeholder:"255.255.255.0",className:"h-9 text-sm font-mono","data-testid":`input-subnet-${P.name}`})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"Default Gateway"}),t.jsx(ke,{value:X.gateway,onChange:Ee=>Id(P.name,"gateway",Ee.target.value),disabled:X.dhcp,placeholder:"192.168.1.1",className:"h-9 text-sm font-mono","data-testid":`input-gateway-${P.name}`})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"DNS 1"}),t.jsx(ke,{value:X.dns1,onChange:Ee=>Id(P.name,"dns1",Ee.target.value),disabled:X.dhcp,placeholder:"8.8.8.8",className:"h-9 text-sm font-mono","data-testid":`input-dns1-${P.name}`})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{className:"text-xs text-muted-foreground",children:"DNS 2"}),t.jsx(ke,{value:X.dns2,onChange:Ee=>Id(P.name,"dns2",Ee.target.value),disabled:X.dhcp,placeholder:"8.8.4.4",className:"h-9 text-sm font-mono","data-testid":`input-dns2-${P.name}`})]})]}),xe&&t.jsx("div",{className:"flex justify-end pt-2 border-t border-border",children:t.jsxs(L,{size:"sm",onClick:()=>ri(P.name),disabled:Ai!==null,"data-testid":`button-save-network-${P.name}`,className:"h-8 text-xs",children:[Ai===P.name?t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}):t.jsx(Vl,{className:"w-3.5 h-3.5 mr-1"}),Ai===P.name?"Saving...":"Save Changes"]})})]},P.name)}
577)}),!cl&&dl.length===0&&t.jsxs("div",{className:"text-center py-12 border border-dashed rounded-lg border-border",children:[t.jsx(cg,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:'Click "Scan Adapters" to retrieve network interface information from the Edge device.'})]})]}),V==="netstats"&&t.jsxs("div",{className:"max-w-4xl space-y-4","data-testid":"tab-netstats",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"Network Stats"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Real-time bandwidth usage per network interface"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[Ec&&t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Live"]}),Ec?t.jsxs(L,{size:"sm",variant:"outline",onClick:Bf,className:"h-8 text-xs","data-testid":"button-stop-bandwidth",children:[t.jsx(kg,{className:"w-3.5 h-3.5 mr-1"}),"Stop"]}):t.jsx(L,{size:"sm",variant:"outline",onClick:()=>Ff(!1),disabled:tc||!j||!x,className:"h-8 text-xs","data-testid":"button-measure-bandwidth",children:tc?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),"Measuring..."]}):t.jsxs(t.Fragment,{children:[t.jsx(vc,{className:"w-3.5 h-3.5 mr-1"}),"Measure Bandwidth"]})})]})]}),tc&&t.jsx("div",{className:"space-y-3",children:[1,2].map(P=>t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[t.jsx(Bt,{className:"h-5 w-32"}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsx(Bt,{className:"h-16"}),t.jsx(Bt,{className:"h-16"})]})]},P))}),!tc&&Pc.length>0&&t.jsx("div",{className:"space-y-3",children:Pc.map(P=>t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3","data-testid":`card-netstats-${P.name}`,children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(cg,{className:"w-4 h-4 text-primary"}),t.jsx("span",{className:"font-medium text-sm",children:P.name})]}),t.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[P.speed&&P.speed!=="unknown"&&t.jsxs("span",{children:["Link: ",P.speed]}),t.jsx("span",{className:"font-mono",children:P.mac})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx(wK,{className:"w-3.5 h-3.5 text-emerald-500"}),"Download (RX)"]}),t.jsx("p",{className:"text-lg font-semibold","data-testid":`text-rx-rate-${P.name}`,children:ex(P.rxBps)}),t.jsx("p",{className:"text-xs text-muted-foreground",children:Xb(P.rxBps)})]}),t.jsxs("div",{className:"rounded-md bg-muted/50 p-3 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx(jK,{className:"w-3.5 h-3.5 text-blue-500"}),"Upload (TX)"]}),t.jsx("p",{className:"text-lg font-semibold","data-testid":`text-tx-rate-${P.name}`,children:ex(P.txBps)}),t.jsx("p",{className:"text-xs text-muted-foreground",children:Xb(P.txBps)})]})]}),t.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground pt-1 border-t border-border",children:[t.jsxs("span",{children:["Total received: ",P.rxTotal]}),t.jsxs("span",{children:["Total sent: ",P.txTotal]})]})]},P.name))}),!tc&&Pc.length===0&&t.jsxs("div",{className:"text-center py-12 border border-dashed rounded-lg border-border",children:[t.jsx(vc,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:'Click "Measure Bandwidth" to sample network traffic on the Edge device.'})]})]}),V==="cloud-storage"&&t.jsxs("div",{className:"max-w-2xl space-y-4","data-testid":"tab-cloud-storage",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"Cloud Storage"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Subscription plan, usage and recording display preferences"})]}),j&&t.jsx(M9e,{edgeDeviceId:j,salesOrderId:w?.edgeDevice?.salesOrderId??null,isAdmin:g}),Ta?t.jsx("div",{className:"rounded-lg border border-border p-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"Hide Local Recordings"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"When enabled, the Local recordings tab is hidden for this site. Users will only see cloud recordings."})]}),t.jsx(sr,{"data-testid":"switch-hide-local-recordings",checked:Il,disabled:Ao,onCheckedChange:P=>{Go(P),Jg({hideLocalRecordings:P})}})]})}):t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4",children:[t.jsx(Fe,{className:"h-4 w-4 animate-spin"}),"Loading preferences…"]}),Ta&&t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[t.jsxs("div",{children:[t.jsx(re,{htmlFor:"clip-duration-length",className:"text-sm font-medium",children:"Clip Duration Length"}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Set how much continuous footage is combined into each cloud clip (10–300 seconds).",Aa>=60?` Currently ${Math.floor(Aa/60)} minute${Math.floor(Aa/60)===1?"":"s"}${Aa%60?` ${Aa%60} seconds`:""}.`:` Currently ${Aa} seconds.`]})]}),t.jsxs("div",{className:"flex items-end gap-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"clip-duration-length",className:"text-xs text-muted-foreground",children:"Seconds"}),t.jsx(ke,{id:"clip-duration-length","data-testid":"input-clip-duration-length",type:"number",min:10,max:300,step:1,value:Dl,disabled:Fc,onChange:P=>li(P.target.value),className:"w-32"})]}),t.jsxs(L,{type:"button",size:"sm",onClick:wv,disabled:Fc,"data-testid":"button-save-clip-duration",children:[Fc?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-2"}
577),Fc?"Saving…":"Save"]}),ve&&!Fc&&t.jsxs("span",{className:"text-xs text-emerald-600 flex items-center gap-1",children:[t.jsx(Hd,{className:"w-3 h-3"})," Saved"]})]})]}),Ta&&(p||!Iu)&&t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-medium",children:"Hybrid Retrieval"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"When enabled, the recordings timeline merges cloud and local footage into one continuous timeline. Cloud footage is preferred; local footage automatically fills recent footage that hasn't finished uploading yet."}),!O&&t.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500 mt-1","data-testid":"text-hybrid-requires-cloud",children:"Requires an active cloud storage subscription."})]}),t.jsx(sr,{"data-testid":"switch-hybrid-retrieval",checked:fl,disabled:Ao||!O,onCheckedChange:P=>{Ol(P),Jg({hybridRetrievalEnabled:P})}})]}),fl&&t.jsxs("div",{className:"pl-4 border-l-2 border-border flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-medium",children:"Distinguish Recording Sources on Timeline"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Sub-option of Hybrid Retrieval. When enabled, the timeline visually marks which footage came from the cloud versus the local device, with a legend so you can tell them apart at a glance."})]}),t.jsx(sr,{"data-testid":"switch-distinguish-hybrid-sources",checked:Af,disabled:Ao||!O,onCheckedChange:P=>{gl(P),Jg({distinguishHybridSources:P})}})]})]}),t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-medium",children:"Use Legacy Cloud Playback"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"When enabled, cloud event playback skips the new segment-stitch and edge-assembly paths and serves the original cloud clip directly. Turn this on for sites where segment archival is incomplete (e.g. some cameras have no segments) so playback works reliably on every camera."})]}),t.jsx(sr,{checked:Qi,disabled:Ko||!Ni,onCheckedChange:P=>{Ls(P);const X=P?!!Or:!1;P||Pl(!1),po({preferLegacyCloudClip:P,cloudClipDirectStream:X,silent:!0})},"data-testid":"switch-record-legacy-playback"})]}),t.jsxs("div",{className:`pl-4 border-l-2 border-border flex items-start justify-between gap-4 ${Qi?"":"opacity-50"}`,children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"text-sm font-medium",children:"Direct Google Cloud Streaming"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Sub-option of Legacy Cloud Playback. Sends the browser straight to Google Cloud Storage instead of routing bytes through this server. Cloud event downloads play at your full internet speed with no first-hit delay. Works on all browsers including iOS Safari (uses native Range requests against the signed GCS URL)."})]}),t.jsx(sr,{checked:Or,disabled:!Qi||Ko||!Ni,onCheckedChange:P=>{Pl(P),po({cloudClipDirectStream:P,silent:!0})},"data-testid":"switch-record-direct-stream"})]})]})]}),V==="user-permissions"&&j&&t.jsx(O9e,{edgeDeviceId:j,siteId:r,companyId:y?.id}),V==="privacy"&&r&&t.jsx(I9e,{siteId:r,siteName:w?.name||"this site"}),V==="aidetection"&&t.jsxs("div",{className:"max-w-4xl space-y-4","data-testid":"tab-aidetection",children:[t.jsx("div",{className:"rounded-lg border border-border p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Xr,{className:"w-5 h-5 text-primary"}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Color Matching"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"When enabled, a color filter appears in Recordings to search events by dominant color."})]})]}),t.jsx(sr,{checked:qt,onCheckedChange:ms,"data-testid":"switch-color-matching"})]})}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"AI Object Detection"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Configure which objects the AI detects across all cameras"})]}),t.jsx("div",{className:"flex items-center gap-2",children:U?t.jsx(L,{size:"sm",variant:"default",onClick:is,disabled:Eo||!js,className:"h-8 text-xs","data-testid":"button-save-ai-objects",children:Eo?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),"Saving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(Vl,{className:"w-3.5 h-3.5 mr-1"}),"Save"]})}):t.jsx(L,{size:"sm",variant:"outline",onClick:us,disabled:Rc||!j||!x,className:"h-8 text-xs","data-testid":"button-load-ai-objects",children:Rc?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),"Loading..."]}):t.jsxs(t.Fragment,{children:[t.jsx(uw,{className:"w-3.5 h-3.5 mr-1"}),"Load Settings"]})})})]}),Rc&&t.jsx("div",{className:"space-y-3",children:[1,2,3].map(P=>t.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[t.jsx(Bt,{className:"h-5 w-40"}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[1,2,3].map(X=>t.jsx(Bt,{className:"h-10"},X))})]},P))}),U&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground bg-muted/50 rounded-lg p-3",children:[t.jsx(uw,{className:"w-4 h-4 flex-shrink-0"}),t.jsxs("span",{children:[tr.length," object",tr.length!==1?"s":"",' currently being tracked. Toggle objects on/off, then click "Save" to queue changes.']})]}),t.jsx("div",{className:"space-y-4",children:kt.map(P=>t.jsx(m9,{defaultOpen:P.objects.some(X=>tr.includes(X)),children:t.jsxs("div",{className:"rounded-lg border border-border overflow-hidden",children:[t.jsxs(h9,{className:"flex items-center justify-between w-full p-3 hover:bg-muted/50 transition-colors","data-testid":`collapsible-${P.category}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium text-sm",children:P.category}),t.jsxs(Ke,{variant:"secondary",className:"text-xs",children:[P.objects.filter(X=>tr.includes(X)).length,"/",P.objects.length]})]}),t.jsx(Xa,{className:"w-4 h-4 text-muted-foreground transition-transform"})]}),t.jsx(p9,{children:t.jsx("div",{className:"border-t border-border p-3",children:t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:P.objects.map(X=>{const xe=tr.includes(X);return t.jsxs("div",{className:"flex items-center justify-between rounded-md px-3 py-2 hover:bg-muted/50 transition-colors","data-testid":`ai-object-${X.replace(/\s+/g,"-")}`,children:[t.jsx(re,{htmlFor:`ai-toggle-${X}`,className:"text-sm cursor-pointer capitalize",children:X}),t.jsx(sr,{id:`ai-toggle-${X}`,checked:xe,onCheckedChange:Ee=>ts(X,!!Ee),"data-testid":`switch-ai-${X.replace(/\s+/g,"-")}`})]},X)})})})})]})},P.category))})]}),!U&&!Rc&&t.jsxs("div",{className:"text-center py-12 border border-dashed rounded-lg border-border",children:[t.jsx(uw,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:'Click "Load Settings" to view and configure AI object detection.'})]})]}),V==="ai-plus"&&j&&t.jsx(T9e,{edgeDeviceId:j,isSuperAdmin:p,isAdmin:g}),V==="faces"&&j&&t.jsx(D9e,{edgeDeviceId:j,isAdmin:g||v}),V==="device-alerts"&&j&&t.jsx(eHe,{edgeDeviceId:j}),V==="smart-alerts"&&j&&!D&&t.jsx(Yze,{edgeDeviceId:j,cameraNames:Array.from(new Set((Pr?.cameras||[]).map(P=>
577P.name).filter(Boolean)))}),V==="yamlconfig"&&p&&t.jsxs("div",{className:"max-w-5xl space-y-4","data-testid":"tab-yamlconfig",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"YAML Config"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Advanced Edge device configuration editor (DB Admin only)"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[sd?t.jsxs(t.Fragment,{children:[t.jsx(L,{size:"sm",variant:"outline",onClick:tx,disabled:Vo,className:"h-8 text-xs",title:"Reload config","data-testid":"button-reload-yaml",children:Vo?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):t.jsx(tl,{className:"w-3.5 h-3.5"})}),t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>Wo.current?.click(),className:"h-8 text-xs",title:"Import YAML file","data-testid":"button-import-yaml",children:[t.jsx(Om,{className:"w-3.5 h-3.5 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Import"})]}),t.jsxs(L,{size:"sm",variant:"outline",onClick:kN,className:"h-8 text-xs",title:"Export YAML file","data-testid":"button-export-yaml",children:[t.jsx(ya,{className:"w-3.5 h-3.5 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Export"})]}),t.jsxs(L,{size:"sm",variant:"outline",onClick:Zb,disabled:!j,className:"h-8 text-xs",title:"Restore snapshot","data-testid":"button-restore-yaml",children:[t.jsx(e0,{className:"w-3.5 h-3.5 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Restore"})]}),tw&&t.jsx(L,{size:"sm",onClick:CN,disabled:Um,className:"h-8 text-xs","data-testid":"button-save-yaml",children:Um?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),t.jsx("span",{className:"hidden sm:inline",children:"Saving…"})]}):t.jsxs(t.Fragment,{children:[t.jsx(Vl,{className:"w-3.5 h-3.5 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Save"})]})})]}):t.jsxs(t.Fragment,{children:[t.jsx(L,{size:"sm",variant:"outline",onClick:tx,disabled:Vo||!j,className:"h-8 text-xs","data-testid":"button-load-yaml",children:Vo?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),t.jsx("span",{className:"hidden sm:inline",children:"Loading…"})]}):t.jsxs(t.Fragment,{children:[t.jsx(J2,{className:"w-3.5 h-3.5 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Load Config"})]})}),t.jsxs(L,{size:"sm",variant:"outline",onClick:Zb,disabled:!j,className:"h-8 text-xs",title:"Restore snapshot","data-testid":"button-restore-yaml",children:[t.jsx(e0,{className:"w-3.5 h-3.5 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Restore"})]})]}),t.jsx("input",{ref:Wo,type:"file",accept:".yml,.yaml,.txt",onChange:_N,className:"hidden"})]})]}),tw&&t.jsxs("div",{className:"flex items-center gap-2 p-2.5 rounded-lg border border-amber-500/40 bg-amber-500/10 text-sm text-amber-700 dark:text-amber-400",children:[t.jsx(ta,{className:"w-4 h-4 shrink-0"}),t.jsx("span",{children:"Config has been modified. Save to queue changes, then Apply Changes to push to the Edge device."})]}),!sd&&!Vo&&t.jsxs("div",{className:"text-center py-12 border border-dashed rounded-lg border-border",children:[t.jsx(J2,{className:"w-8 h-8 mx-auto text-muted-foreground mb-2"}),t.jsx("p",{className:"text-muted-foreground text-sm",children:'Click "Load Config" to retrieve the full YAML configuration from the Edge device.'})]}),Vo&&!sd&&t.jsx("div",{className:"space-y-2",children:t.jsx(Bt,{className:"h-[500px] w-full"})}),sd&&t.jsx(zze,{value:Ed,onChange:ed}),t.jsx(Ys,{open:Mh,onOpenChange:Td,children:t.jsxs(Ws,{className:"max-w-lg","data-testid":"dialog-yaml-restore",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:"Restore Config Snapshot"}),t.jsxs(cr,{children:["Select a previously saved configuration to load into the editor. Review the YAML and click Apply Changes to push it to the device.",!sd&&" If the device is currently offline, the restored config will be queued and pushed on the next Apply Changes."]})]}),rc?t.jsx("div",{className:"space-y-2 py-2",children:[0,1,2].map(P=>t.jsx(Bt,{className:"h-14 w-full"},P))}):qa.length===0?t.jsxs("div",{className:"text-center py-10 text-muted-foreground",children:[t.jsx(e0,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),t.jsx("p",{className:"text-sm",children:"No saved snapshots found."}),t.jsx("p",{className:"text-xs mt-1",children:"Snapshots are saved automatically each time you Apply Changes."})]}):t.jsx("div",{className:"divide-y max-h-[22rem] overflow-y-auto -mx-1 px-1",children:qa.map(P=>{const X=new Date(P.uploadedAt),xe=Po===P.key,Ee=Rh===P.key,_t=Mi===P.key,Me=kl===P.key,st=!!Po||!!kl||!!Mi;return t.jsxs("div",{className:"py-3 space-y-1.5","data-testid":`yaml-restore-row-${P.key}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium leading-tight",children:X.toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"})}),t.jsx("p",{className:"text-xs text-muted-foreground",children:X.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(L,{size:"icon",variant:"ghost",className:"h-7 w-7",t
577itle:"Edit label",disabled:st,onClick:()=>{ml(P.key),Mc(P.label||"")},"data-testid":`button-label-snapshot-${P.key}`,children:t.jsx(ga,{className:"w-3.5 h-3.5"})}),t.jsx(L,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive hover:text-destructive",title:"Delete snapshot",disabled:st,onClick:()=>ac(P.key),"data-testid":`button-delete-snapshot-${P.key}`,children:Me?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):t.jsx(sa,{className:"w-3.5 h-3.5"})}),t.jsx(L,{size:"sm",variant:"outline",onClick:()=>Jb(P.key),disabled:st,className:"h-7 text-xs px-2","data-testid":`button-restore-version-${P.key}`,children:xe?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-3.5 h-3.5 mr-1 animate-spin"}),"Loading…"]}):"Load"})]})]}),Ee?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{autoFocus:!0,type:"text",value:rd,onChange:ot=>Mc(ot.target.value),onKeyDown:ot=>{ot.key==="Enter"&&ew(P.key),ot.key==="Escape"&&ml(null)},placeholder:"Add a label…",maxLength:200,className:"flex-1 h-7 rounded-md border border-input bg-background px-2 text-xs focus:outline-none focus:ring-1 focus:ring-ring","data-testid":`input-snapshot-label-${P.key}`}),t.jsx(L,{size:"sm",variant:"default",className:"h-7 text-xs px-2",disabled:_t,onClick:()=>ew(P.key),"data-testid":`button-save-label-${P.key}`,children:_t?t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}):"Save"}),t.jsx(L,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",disabled:_t,onClick:()=>ml(null),"data-testid":`button-cancel-label-${P.key}`,children:"Cancel"})]}):P.label?t.jsx("p",{className:"text-xs text-muted-foreground italic truncate","data-testid":`snapshot-label-${P.key}`,children:P.label}):null]},P.key)})})]})}),t.jsx(zd,{open:!!ho,onOpenChange:P=>{P||ac(null)},children:t.jsxs(bd,{"data-testid":"dialog-delete-snapshot-confirm",children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:"Delete this snapshot?"}),t.jsx(Sd,{children:ho?(()=>{const P=qa.find(xe=>xe.key===ho),X=P?new Date(P.uploadedAt):null;return X?t.jsxs(t.Fragment,{children:["This will permanently delete the snapshot from ",t.jsx("strong",{children:X.toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"})})," at ",X.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}),". This action cannot be undone."]}):"This will permanently delete the snapshot. This action cannot be undone."})():null})]}),t.jsxs(jd,{children:[t.jsx(Gc,{"data-testid":"button-cancel-delete-snapshot",children:"Cancel"}),t.jsx(Cd,{"data-testid":"button-confirm-delete-snapshot",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{ho&&(PN(ho),ac(null))},children:"Delete"})]})]})})]}),V==="diagnostics"&&p&&t.jsxs("div",{className:"max-w-lg space-y-6","data-testid":"tab-diagnostics",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-base font-semibold",children:"Diagnostics"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Superadmin testing and diagnostic options for this device."})]}),t.jsxs("div",{className:"space-y-3",children:[j&&t.jsx(uoe,{edgeDeviceId:j}),t.jsxs("div",{className:"flex items-start justify-between gap-6 p-4 rounded-lg border border-border bg-card",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium",children:"Debug Live Stream"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"When enabled, shows a live status badge on each camera stream indicating the current transport (WebRTC, MSE, or JPEG). Useful for diagnosing streaming issues."})]}),t.jsx(sr,{checked:nt,onCheckedChange:tt,"data-testid":"switch-debug-live-stream"})]}),t.jsxs("div",{className:"flex items-start justify-between gap-6 p-4 rounded-lg border border-border bg-card",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium",children:"Debug Event & Playback"}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["When enabled, a floating panel appears on the Recordings pages logging: (1) every local + cloud event list fetch (URL, status, count, timing), (2) every HLS error during local clip playback (type, details, fatal), (3) HLS→MP4 fallback events, and (4) every cloud and local clip ","<video>"," error with full MediaError detail. Useful for diagnosing why events or clips fail to load or play. Setting persists in your browser only."]})]}),t.jsx(sr,{checked:Dh,onCheckedChange:P=>{Rl(P),hCe(P)},"data-testid":"switch-debug-event-retrieval"})]}),t.jsxs("div",{className:"flex items-start justify-between gap-6 p-4 rounded-lg border border-border bg-card",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium",children:"Use AI Configuration Assistance"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"When enabled, users entering Camera Discovery are offered an AI-guided setup wizard that scans the network, probes cameras with their credentials, and proposes channel assignments for review. Nothing is ever applied without user confirmation, and AI setup calls do not count toward any AI daily limits. When disabled, the feature is completely absent."})]}),t.jsx(sr,{checked:!!Ji?.enabled,onCheckedChange:async P=>{try{const X=await fetch(`/api/edge-devices/${j}/ai-config-assist/toggle`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json","X-Device-Settings-Context":"diagnostics"},body:JSON.stringify({enabled:P})});if(!X.ok)throw new Error((await X.json().catch(()=>null))?.error||"Failed to update setting");
577Je.invalidateQueries({queryKey:["/api/edge-devices",j,"ai-config-assist","status"]})}catch(X){l({title:"Failed to update setting",description:X.message,variant:"destructive"})}},"data-testid":"switch-ai-config-assist"})]}),t.jsxs("div",{className:"flex items-start justify-between gap-6 p-4 rounded-lg border border-border bg-card",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium",children:"Hide Hybrid Retrieval Preferences"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:'When enabled, the "Hybrid Retrieval" and "Distinguish Recording Sources" toggles are completely hidden from Owners, Admins, and Users on the Cloud Storage tab (and cannot be changed by them). Only superadmins can see or change them. This does not change how the timeline behaves — it only controls who can manage the setting.'})]}),t.jsx(sr,{checked:Dc,disabled:Ao||!Ta,onCheckedChange:P=>{Lc(P),Jg({hideHybridRetrievalPreferences:P})},"data-testid":"switch-hide-hybrid-preferences"})]}),Il&&p&&t.jsxs("div",{className:"flex items-start justify-between gap-6 p-4 rounded-lg border border-border bg-card",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium",children:"Show Local Recordings if hidden"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Local Recordings are hidden for this site. Enable this to restore access to the Local recordings tab for your superadmin session only. Other users are not affected."})]}),t.jsx(sr,{checked:fo,onCheckedChange:hn,"data-testid":"switch-show-local-override"})]})]})]})]})]}),t.jsx(zd,{open:jt,onOpenChange:Ct,children:t.jsxs(bd,{"data-testid":"dialog-ai-assist-prompt",children:[t.jsxs(wd,{children:[t.jsxs(Nd,{className:"flex items-center gap-2",children:[t.jsx(Do,{className:"w-4 h-4 text-primary"}),"AI Camera Setup"]}),t.jsxs(Sd,{children:["Do you want to use AI to automatically set up your camera streams? The assistant will ask a few questions, scan your network, and propose channel assignments for your review — nothing is applied without your confirmation."," ","Choose No thanks to stop these prompts for all sites. You can still start AI Setup manually."]})]}),t.jsxs(jd,{children:[t.jsx(Gc,{"data-testid":"button-ai-prompt-decline",onClick:()=>{try{Iae(localStorage)}catch{}Ct(!1)},children:"No thanks"}),t.jsx(Cd,{"data-testid":"button-ai-prompt-accept",onClick:()=>{Ct(!1),De(!0)},children:"Use AI Setup"})]})]})}),t.jsx(zd,{open:!!Qe,onOpenChange:P=>{!P&&!te&&ye(null)},children:t.jsxs(bd,{"data-testid":"dialog-default-creds",children:[t.jsxs(wd,{children:[t.jsxs(Nd,{className:"flex items-center gap-2",children:[t.jsx($w,{className:"w-4 h-4 text-amber-500"}),"Try factory-default credentials?"]}),t.jsx(Sd,{asChild:!0,children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("p",{children:["This will try known factory-default usernames and passwords for",Qe?.manufacturer?` ${Qe.manufacturer}`:" this"," devices, one at a time."]}),t.jsx("p",{className:"text-amber-600 dark:text-amber-400 text-xs",children:"Warning: repeated failed logins can temporarily lock a camera's account. Attempts are paced with a pause between each to reduce that risk, but only proceed if you understand the camera may briefly lock out. Most modern cameras require a password set at install and will not accept defaults."}),Qe&&t.jsxs("div",{className:"text-xs text-muted-foreground",children:["Will try: ",p5({manufacturer:Qe.manufacturer,model:Qe.model,name:Qe.name}).map(P=>`${P.username}/${P.password||"<blank>"}`).join(", ")]}),te&&We&&t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[t.jsx(Fe,{className:"w-3.5 h-3.5 animate-spin"}),We]})]})})]}),t.jsxs(jd,{children:[t.jsx(Gc,{disabled:te,"data-testid":"button-default-creds-cancel",children:"Cancel"}),t.jsx(Cd,{disabled:te||!!Qe&&fs(Qe)>0,onClick:P=>{P.preventDefault(),Qe&&Is(Qe)},"data-testid":"button-default-creds-confirm",children:te?"Trying…":Qe&&fs(Qe)>0?`Wait ${Ce(fs(Qe))}`:"Try defaults"})]})]})}),pi&&j&&t.jsx(hHe,{open:Oe,onOpenChange:De,edgeDeviceId:j,onAssigned:()=>
577{dn(),Md(),Je.invalidateQueries({queryKey:["/api/sites",r,"cameras"]})}}),t.jsx(zd,{open:nl,onOpenChange:co,children:t.jsxs(bd,{children:[t.jsxs(wd,{children:[t.jsx(Nd,{children:"Deactivate Device"}),t.jsxs(Sd,{children:["Are you sure you want to deactivate ",t.jsx("strong",{children:w?.name}),"? This will permanently remove the site and any active subscription will be cancelled."]})]}),t.jsxs(jd,{children:[t.jsx(Gc,{"data-testid":"button-cancel-deactivate-device",children:"Cancel"}),t.jsx(Cd,{onClick:()=>{fn.mutate(),co(!1)},disabled:fn.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90","data-testid":"button-confirm-deactivate-device",children:fn.isPending?"Deactivating...":"Deactivate"})]})]})})]})}function $9e(){const[,e]=NW("/edge-terminal/:edgeDeviceId"),[s,r]=u.useState();return u.useEffect(()=>{const n=o=>{if(o.origin!==window.location.origin||o.source!==window.opener)return;const l=o.data;l?.type!=="edge-terminal-handoff"||l.edgeDeviceId!==e?.edgeDeviceId||typeof l.handoff!="string"||r(l.handoff)};window.addEventListener("message",n);const a=()=>window.opener?.postMessage({type:"edge-terminal-ready"},window.location.origin);a();const i=window.setInterval(a,500);return()=>{window.clearInterval(i),window.removeEventListener("message",n)}},[e?.edgeDeviceId]),e?.edgeDeviceId?t.jsx("main",{className:"min-h-screen p-4 sm:p-6 bg-background",children:t.jsxs("div",{className:"mx-auto w-full",children:[t.jsx("h1",{className:"text-xl font-semibold mb-4",children:"Remote Linux Terminal"}),s?t.jsx(uoe,{edgeDeviceId:e.edgeDeviceId,handoff:s,expanded:!0}):t.jsx("p",{className:"text-sm text-muted-foreground",children:"Connecting to the active terminal session…"})]})}):t.jsx("p",{className:"p-6 text-destructive",children:"Terminal device is missing."})}function yV(){const e=Er(),{t:s,tLines:r,tParts:n}=rn(Ate);return u.useEffect(()=>{window.scrollTo(0,0)},[]),t.jsxs("div",{className:"min-h-screen bg-[#06060f] text-white",children:[t.jsx(pa,{}),t.jsxs("main",{className:"max-w-3xl mx-auto px-4 sm:px-8 pt-28 pb-12",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-bold text-white mb-2",children:s("title")}),t.jsx("p",{className:"text-sm text-white/40 mb-8",children:s("lastUpdated")}),t.jsx("p",{className:"text-white/70 leading-relaxed mb-10",children:s("intro")}),t.jsxs("div",{className:"space-y-8",children:[t.jsx(pd,{number:"1",title:s("s1.title"),children:t.jsx("p",{children:s("s1.body")})}),t.jsx(pd,{number:"2",title:s("s2.title"),children:t.jsx("p",{children:s("s2.body")})}),t.jsx(pd,{number:"3",title:s("s3.title"),children:t.jsx("ul",{children:n("s3.items").map(([a="",i=""],o)=>t.jsxs("li",{children:[t.jsx("strong",{children:a}),i&&t.jsxs(t.Fragment,{children:[" ",i]})]},o))})}),t.jsx(pd,{number:"4",title:s("s4.title"),children:t.jsx("ul",{children:n("s4.items").map(([a="",i=""],o)=>t.jsxs("li",{children:[t.jsx("strong",{children:a}),i&&t.jsxs(t.Fragment,{children:[" ",i]})]},o))})}),t.jsxs(pd,{number:"5",title:s("s5.title"),children:[t.jsx("p",{className:"mb-3",children:s("s5.intro")}),t.jsx("ul",{children:r("s5.items").map((a,i)=>t.jsx("li",{children:a},i))})]}),t.jsx(pd,{number:"6",title:s("s6.title"),children:t.jsx("ul",{children:n("s6.items").map(([a="",i=""],o)=>t.jsxs("li",{children:[t.jsx("strong",{children:a}),i&&t.jsxs(t.Fragment,{children:[" ",i]})]},o))})}),t.jsx(pd,{number:"7",title:s("s7.title"),children:t.jsx("ul",{children:n("s7.items").map(([a="",i=""],o)=>t.jsxs("li",{children:[t.jsx("strong",{children:a}),i&&t.jsxs(t.Fragment,{children:[" ",i]})]},o))})}),t.jsx(pd,{number:"8",title:s("s8.title"),children:t.jsx("ul",{children:r("s8.items").map((a,i)=>t.jsx("li",{children:a},i))})}),t.jsx(pd,{number:"9",title:s("s9.title"),children:t.jsx("ul",{children:n("s9.items").map(([a="",i=""],o)=>t.jsxs("li",{children:[t.jsx("strong",{children:a}),i&&t.jsxs(t.Fragment,{children:[" ",i]})]},o))})}),t.jsx(pd,{number:"10",title:s("s10.title"),children:t.jsxs("p",{children:[s("s10.bodyPre")," ",e.brandName.toUpperCase()," ",s("s10.bodyPost")]})}),t.jsx(pd,{number:"11",title:s("s11.title"),children:t.jsx("p",{children:s("s11.body")})}),t.jsx(pd,{number:"12",title:s("s12.title"),children:t.jsx("ul",{children:n("s12.items").map(([a="",i=""],o)=>t.jsxs("li",{children:[t.jsx("strong",{children:a}),i&&t.jsxs(t.Fragment,{children:[" ",i]})]},o))})}),t.jsx(pd,{number:"13",title:s("s13.title"),children:t.jsx("p",{children:s("s13.body")})}),t.jsx(pd,{number:"14",title:s("s14.title"),children:t.jsx("p",{children:s("s14.body")})}),t.jsx(pd,{number:"15",title:s("s15.title"),children:t.jsx("p",{children:s("s15.body")})}),t.jsxs(pd,{number:"16",title:s("s16.title"),children:[t.jsx("p",{className:"mb-3",children:s("s16.intro")}),t.jsxs("ul",{children:[t.jsxs("li",{children:[t.jsx("strong",{children:s("s16.emailLabel")})," ",t.jsx("a",{href:`mailto:${e.infoEmail}`,className:"text-[var(--brand)] hover:text-blue-400 transition-colors",children:e.infoEmail})]}),t.jsxs("li",{children:[t.jsx("strong",{children:s("s16.phoneLabel")})," ",e.phone]}
577),t.jsxs("li",{children:[t.jsx("strong",{children:s("s16.addressLabel")})," ",e.addressLine1,", ",e.addressLine2]})]})]})]})]}),t.jsx(_a,{})]})}function pd({number:e,title:s,children:r}){return t.jsxs("section",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-baseline gap-2",children:[t.jsxs("span",{className:"text-[var(--brand)] font-bold text-sm shrink-0",children:[e,"."]}),s]}),t.jsx("div",{className:"text-white/70 leading-relaxed space-y-2 pl-5 [&_p]:leading-relaxed [&_ul]:space-y-2 [&_ul]:list-none [&_ul]:pl-0 [&_li]:flex [&_li]:gap-2 [&_li]:before:content-['–'] [&_li]:before:text-[var(--brand)] [&_li]:before:shrink-0 [&_strong]:text-white/90 [&_strong]:font-medium",children:r})]})}function bV(){const e=Er(),{t:s,tLines:r,tParts:n}=rn(Tte);return u.useEffect(()=>{window.scrollTo(0,0)},[]),t.jsxs("div",{className:"min-h-screen bg-[#06060f] text-white",children:[t.jsx(pa,{}),t.jsxs("main",{className:"max-w-3xl mx-auto px-4 sm:px-8 pt-28 pb-12",children:[t.jsx("h1",{className:"text-3xl sm:text-4xl font-bold text-white mb-2",children:s("title")}),t.jsx("p",{className:"text-sm text-white/40 mb-8",children:s("lastUpdated")}),t.jsx("p",{className:"text-white/70 leading-relaxed mb-10",children:s("intro")}),t.jsxs("div",{className:"space-y-8",children:[t.jsxs(xm,{number:"1",title:s("s1.title"),children:[t.jsx("p",{className:"mb-3",children:s("s1.intro")}),t.jsx("ul",{children:n("s1.items").map(([a="",i=""],o)=>t.jsxs("li",{children:[t.jsx("strong",{children:a}),i&&t.jsxs(t.Fragment,{children:[" ",i]})]},o))})]}),t.jsxs(xm,{number:"2",title:s("s2.title"),children:[t.jsx("p",{className:"mb-3",children:s("s2.intro")}),t.jsx("ul",{children:r("s2.items").map((a,i)=>t.jsx("li",{children:a},i))})]}),t.jsxs(xm,{number:"3",title:s("s3.title"),children:[t.jsx("p",{className:"mb-3",children:s("s3.intro")}),t.jsx("ul",{children:n("s3.items").map(([a="",i=""],o)=>t.jsxs("li",{children:[t.jsx("strong",{children:a}),i&&t.jsxs(t.Fragment,{children:[" ",i]})]},o))})]}),t.jsxs(xm,{number:"4",title:s("s4.title"),children:[t.jsx("p",{className:"mb-3",children:s("s4.intro")}),t.jsx("ul",{children:n("s4.items").map(([a="",i=""],o)=>t.jsxs("li",{children:[t.jsx("strong",{children:a}),i&&t.jsxs(t.Fragment,{children:[" ",i]})]},o))})]}),t.jsx(xm,{number:"5",title:s("s5.title"),children:t.jsx("p",{children:s("s5.body")})}),t.jsx(xm,{number:"6",title:s("s6.title"),children:t.jsx("p",{children:s("s6.body")})}),t.jsx(xm,{number:"7",title:s("s7.title"),children:t.jsx("p",{children:s("s7.body")})}),t.jsx(xm,{number:"8",title:s("s8.title"),children:t.jsx("p",{children:s("s8.body")})}),t.jsxs(xm,{number:"9",title:s("s9.title"),children:[t.jsx("p",{className:"mb-3",children:s("s9.intro")}),t.jsx("ul",{children:n("s9.items").map(([a="",i=""],o)=>t.jsxs("li",{children:[t.jsx("strong",{children:a}),i&&t.jsxs(t.Fragment,{children:[" ",i]})]},o))}),t.jsxs("p",{className:"mt-3",children:[s("s9.outroPre")," ",t.jsx("a",{href:`mailto:${e.infoEmail}`,className:"text-[var(--brand)] hover:text-blue-400 transition-colors",children:e.infoEmail}),"."]})]}),t.jsx(xm,{number:"10",title:s("s10.title"),children:t.jsx("p",{children:s("s10.body")})}),t.jsx(xm,{number:"11",title:s("s11.title"),children:t.jsx("p",{children:s("s11.body")})}),t.jsxs(xm,{number:"12",title:s("s12.title"),children:[t.jsx("p",{className:"mb-3",children:s("s12.intro")}),t.jsxs("ul",{children:[t.jsxs("li",{children:[t.jsx("strong",{children:s("s12.emailLabel")})," ",t.jsx("a",{href:`mailto:${e.infoEmail}`,className:"text-[var(--brand)] hover:text-blue-400 transition-colors",children:e.infoEmail})]}),t.jsxs("li",{children:[t.jsx("strong",{children:s("s12.phoneLabel")})," ",e.phone]}),t.jsxs("li",{children:[t.jsx("strong",{children:s("s12.addressLabel")})," ",e.addressLine1,", ",e.addressLine2]})]})]})]})]}),t.jsx(_a,{})]})}function xm({number:e,title:s,children:r}){return t.jsxs("section",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-baseline gap-2",children:[t.jsxs("span",{className:"text-[var(--brand)] font-bold text-sm shrink-0",children:[e,"."]}),s]}),t.jsx("div",{className:"text-white/70 leading-relaxed space-y-2 pl-5 [&_p]:leading-relaxed [&_ul]:space-y-2 [&_ul]:list-none [&_ul]:pl-0 [&_li]:flex [&_li]:gap-2 [&_li]:before:content-['–'] [&_li]:before:text-[var(--brand)] [&_li]:before:shrink-0 [&_strong]:text-white/90 [&_strong]:font-medium",children:r})]})}function F9e(){const[,e]=Ia(),{toast:s}=Hs(),r=Er(),{t:n}=rn(ite),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(!1),[g,v]=u.useState(!1),[b,y]=u.useState(!1),[w,j]=u.useState(!1),[x,C]=u.useState(null);u.useEffect(()=>{const _=new URLSearchParams(window.location.search).get("token");_&&i(_)},[]);async function k(S){if(S.preventDefault(),o.length<8){s({title:"Password too short",description:"Password must be at least 8 characters.",variant:"destructive"});return}if(o!==c){s({title:"Passwords don't match",description:"Please make sure both passwords are the same.",variant:"destructive"});return}y(!0);try{const _=await fetch("/api/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,password:o})});if(!_.ok){const A=await _.json().catch(()=>({}));
577C(A.message||n("error.invalidLink"));return}C(null),j(!0)}catch{s({title:"Connection error",description:"Could not reach the server. Please try again.",variant:"destructive"})}finally{y(!1)}}return t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:t.jsxs("div",{className:"w-full max-w-sm bg-card border border-border rounded-2xl shadow-xl p-8 space-y-6",children:[t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("img",{src:r.appEmblemUrl||Tm,alt:r.brandName,className:"w-14 h-14 object-contain mx-auto"}),w?t.jsxs(t.Fragment,{children:[t.jsx(ar,{className:"w-10 h-10 text-green-500 mx-auto"}),t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:n("done.heading")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:n("done.body")})]}):t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:n("form.heading")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:n(a?"form.subheadingHasToken":"form.subheadingNoToken")})]})]}),!w&&x&&t.jsxs("div",{className:"rounded-lg border border-destructive/40 bg-destructive/10 p-4 space-y-3","data-testid":"reset-error-box",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(ta,{className:"w-4 h-4 text-destructive mt-0.5 shrink-0"}),t.jsx("p",{className:"text-sm text-destructive","data-testid":"text-reset-error",children:x})]}),t.jsx(L,{className:"w-full",variant:"destructive",onClick:()=>e("/?forgot=1"),"data-testid":"button-request-new-link",children:n("error.requestNewLink")})]}),w?t.jsx(L,{className:"w-full",onClick:()=>e("/"),"data-testid":"button-go-to-signin",children:n("done.signInButton")}):a?t.jsxs("form",{onSubmit:k,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:"new-password",children:n("form.newPasswordLabel")}),t.jsxs("div",{className:"relative",children:[t.jsx(ke,{id:"new-password",type:h?"text":"password",placeholder:n("form.newPasswordPlaceholder"),value:o,onChange:S=>l(S.target.value),required:!0,className:"pr-10","data-testid":"input-new-password"}),t.jsx("button",{type:"button",onClick:()=>p(!h),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:h?t.jsx(Gp,{className:"w-4 h-4"}):t.jsx(Xr,{className:"w-4 h-4"})})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{htmlFor:"confirm-password",children:n("form.confirmPasswordLabel")}),t.jsxs("div",{className:"relative",children:[t.jsx(ke,{id:"confirm-password",type:g?"text":"password",placeholder:n("form.confirmPasswordPlaceholder"),value:c,onChange:S=>d(S.target.value),required:!0,className:"pr-10","data-testid":"input-confirm-password"}),t.jsx("button",{type:"button",onClick:()=>v(!g),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:g?t.jsx(Gp,{className:"w-4 h-4"}):t.jsx(Xr,{className:"w-4 h-4"})})]})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:b,"data-testid":"button-reset-password",children:b?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):n("form.submitButton")})]}):t.jsxs("div",{className:"space-y-2",children:[t.jsx(L,{className:"w-full",onClick:()=>e("/?forgot=1"),"data-testid":"button-request-new-link-missing",children:n("missing.requestNewLink")}),t.jsx(L,{className:"w-full",variant:"outline",onClick:()=>e("/"),"data-testid":"button-go-home",children:n("missing.goHome")})]})]})})}const B9e=[xi,yg,cn,ql],U9e=[Xr,pn,mi,vi,Ba,xi];function wV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(hte),_=S("challenges.icons",B9e),A=S("features.icons",U9e);async function T(R){R.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const M=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:M.map((R,D)=>t.jsxs("span",{children:[D>0&&t.jsx("br",{className:"hidden sm:block"}),D>0&&" ",R]},D))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("hero.secondaryButton")})]})]})}),j.showTestimonials!=="false"&&t.jsxs("section",{className:"py-10 border-y border-border/40",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-6",children:x("trustedBy.heading")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-x-12 gap-y-3 px-4",children:C("trustedBy.names").map(R=>
577t.jsx("span",{className:"text-foreground/50 font-semibold text-sm tracking-widest uppercase whitespace-nowrap",children:R},R))})]}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("challenges.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("challenges.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("challenges.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("challenges.items").map(([R="",D=""],$)=>{const O=_($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-destructive/10 flex items-center justify-center shrink-0",children:t.jsx(O,{className:"w-5 h-5 text-destructive"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},R)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("features.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("features.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("features.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6",children:k("features.items").map(([R="",D=""],$)=>{const O=A($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 space-y-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:t.jsx(O,{className:"w-5 h-5 text-primary"})}),t.jsx("p",{className:"font-semibold text-foreground",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]},R)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([R="",D=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-primary",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground",children:D})]},D))})})}),j.showTestimonials!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-3xl mx-auto",children:t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-8 space-y-5",children:[t.jsx("div",{className:"text-3xl text-primary/60 font-serif leading-none",children:'"'}),t.jsxs("p",{className:"text-lg text-muted-foreground leading-relaxed italic",children:['"',x("testimonial.quote"),'"']}),t.jsxs("div",{className:"border-t border-border/40 pt-5",children:[t.jsx("p",{className:"font-semibold text-foreground",children:x("testimonial.name")}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[x("testimonial.role")," · ",x("testimonial.company")]})]})]})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(R=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:R})]},R))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:R=>i(R.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:R=>l(R.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:R=>d(R.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:R=>p(R.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const z9e=[lO,Pn,ql,ka],H9e=[yc,Xr,pn,mi,Ba,vi];function jV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(fte),_=S("challenges.icons",z9e),A=S("features.icons",H9e);async function T(R){R.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const M=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:M.map((R,D)=>t.jsxs("span",{children:[D>0&&t.jsx("br",{className:"hidden sm:block"}),D>0&&" ",R]},D))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("hero.secondaryButton")})]})]})}),j.showTestimonials!=="false"&&t.jsxs("section",{className:"py-10 border-y border-border/40",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-6",children:x("trustedBy.heading")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-x-12 gap-y-3 px-4",children:C("trustedBy.names").map(R=>
577t.jsx("span",{className:"text-foreground/50 font-semibold text-sm tracking-widest uppercase whitespace-nowrap",children:R},R))})]}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("challenges.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("challenges.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("challenges.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("challenges.items").map(([R="",D=""],$)=>{const O=_($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-destructive/10 flex items-center justify-center shrink-0",children:t.jsx(O,{className:"w-5 h-5 text-destructive"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},R)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("features.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("features.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("features.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6",children:k("features.items").map(([R="",D=""],$)=>{const O=A($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 space-y-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:t.jsx(O,{className:"w-5 h-5 text-primary"})}),t.jsx("p",{className:"font-semibold text-foreground",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]},R)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([R="",D=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-primary",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground",children:D})]},D))})})}),j.showTestimonials!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-3xl mx-auto",children:t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-8 space-y-5",children:[t.jsx("div",{className:"text-3xl text-primary/60 font-serif leading-none",children:'"'}),t.jsxs("p",{className:"text-lg text-muted-foreground leading-relaxed italic",children:['"',x("testimonial.quote"),'"']}),t.jsxs("div",{className:"border-t border-border/40 pt-5",children:[t.jsx("p",{className:"font-semibold text-foreground",children:x("testimonial.name")}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[x("testimonial.role")," · ",x("testimonial.company")]})]})]})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(R=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:R})]},R))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:R=>i(R.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:R=>l(R.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:R=>d(R.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:R=>p(R.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const q9e=[Pn,cn,ka,Xr],V9e=[yc,Xr,pn,mi,Ba,vi];function NV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(pte),_=S("challenges.icons",q9e),A=S("features.icons",V9e);async function T(R){R.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const M=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:M.map((R,D)=>t.jsxs("span",{children:[D>0&&t.jsx("br",{className:"hidden sm:block"}),D>0&&" ",R]},D))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("hero.secondaryButton")})]})]})}),j.showTestimonials!=="false"&&t.jsxs("section",{className:"py-10 border-y border-border/40",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-6",children:x("trustedBy.heading")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-x-12 gap-y-3 px-4",children:C("trustedBy.names").map(R=>
577t.jsx("span",{className:"text-foreground/50 font-semibold text-sm tracking-widest uppercase whitespace-nowrap",children:R},R))})]}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("challenges.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("challenges.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("challenges.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("challenges.items").map(([R="",D=""],$)=>{const O=_($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-destructive/10 flex items-center justify-center shrink-0",children:t.jsx(O,{className:"w-5 h-5 text-destructive"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},R)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("features.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("features.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("features.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6",children:k("features.items").map(([R="",D=""],$)=>{const O=A($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 space-y-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:t.jsx(O,{className:"w-5 h-5 text-primary"})}),t.jsx("p",{className:"font-semibold text-foreground",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]},R)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([R="",D=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-primary",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground",children:D})]},D))})})}),j.showTestimonials!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-3xl mx-auto",children:t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-8 space-y-5",children:[t.jsx("div",{className:"text-3xl text-primary/60 font-serif leading-none",children:'"'}),t.jsxs("p",{className:"text-lg text-muted-foreground leading-relaxed italic",children:['"',x("testimonial.quote"),'"']}),t.jsxs("div",{className:"border-t border-border/40 pt-5",children:[t.jsx("p",{className:"font-semibold text-foreground",children:x("testimonial.name")}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[x("testimonial.role")," · ",x("testimonial.company")]})]})]})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(R=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:R})]},R))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:R=>i(R.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:R=>l(R.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:R=>d(R.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:R=>p(R.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const W9e=[ka,Pn,cn,Xr],K9e=[yc,Xr,pn,mi,Ba,vi];function SV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(mte),_=S("challenges.icons",W9e),A=S("features.icons",K9e);async function T(R){R.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const M=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:M.map((R,D)=>t.jsxs("span",{children:[D>0&&t.jsx("br",{className:"hidden sm:block"}),D>0&&" ",R]},D))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("hero.secondaryButton")})]})]})}),j.showTestimonials!=="false"&&t.jsxs("section",{className:"py-10 border-y border-border/40",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-6",children:x("trustedBy.heading")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-x-12 gap-y-3 px-4",children:C("trustedBy.names").map(R=>
577t.jsx("span",{className:"text-foreground/50 font-semibold text-sm tracking-widest uppercase whitespace-nowrap",children:R},R))})]}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("challenges.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("challenges.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("challenges.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("challenges.items").map(([R="",D=""],$)=>{const O=_($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-destructive/10 flex items-center justify-center shrink-0",children:t.jsx(O,{className:"w-5 h-5 text-destructive"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},R)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("features.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("features.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("features.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6",children:k("features.items").map(([R="",D=""],$)=>{const O=A($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 space-y-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:t.jsx(O,{className:"w-5 h-5 text-primary"})}),t.jsx("p",{className:"font-semibold text-foreground",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]},R)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([R="",D=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-primary",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground",children:D})]},D))})})}),j.showTestimonials!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-3xl mx-auto",children:t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-8 space-y-5",children:[t.jsx("div",{className:"text-3xl text-primary/60 font-serif leading-none",children:'"'}),t.jsxs("p",{className:"text-lg text-muted-foreground leading-relaxed italic",children:['"',x("testimonial.quote"),'"']}),t.jsxs("div",{className:"border-t border-border/40 pt-5",children:[t.jsx("p",{className:"font-semibold text-foreground",children:x("testimonial.name")}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[x("testimonial.role")," · ",x("testimonial.company")]})]})]})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(R=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:R})]},R))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:R=>i(R.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:R=>l(R.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:R=>d(R.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:R=>p(R.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const G9e=[Pn,ql,ka,Ba],Y9e=[yc,Xr,pn,mi,Ba,vi];function CV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(dte),_=S("challenges.icons",G9e),A=S("features.icons",Y9e);async function T(R){R.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const M=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:M.map((R,D)=>t.jsxs("span",{children:[D>0&&t.jsx("br",{className:"hidden sm:block"}),D>0&&" ",R]},D))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("hero.secondaryButton")})]})]})}),j.showTestimonials!=="false"&&t.jsxs("section",{className:"py-10 border-y border-border/40",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-6",children:x("trustedBy.heading")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-x-12 gap-y-3 px-4",children:C("trustedBy.names").map(R=>
577t.jsx("span",{className:"text-foreground/50 font-semibold text-sm tracking-widest uppercase whitespace-nowrap",children:R},R))})]}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("challenges.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("challenges.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("challenges.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("challenges.items").map(([R="",D=""],$)=>{const O=_($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-destructive/10 flex items-center justify-center shrink-0",children:t.jsx(O,{className:"w-5 h-5 text-destructive"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},R)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("features.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("features.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("features.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6",children:k("features.items").map(([R="",D=""],$)=>{const O=A($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 space-y-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:t.jsx(O,{className:"w-5 h-5 text-primary"})}),t.jsx("p",{className:"font-semibold text-foreground",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]},R)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([R="",D=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-primary",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground",children:D})]},D))})})}),j.showTestimonials!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-3xl mx-auto",children:t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-8 space-y-5",children:[t.jsx("div",{className:"text-3xl text-primary/60 font-serif leading-none",children:'"'}),t.jsxs("p",{className:"text-lg text-muted-foreground leading-relaxed italic",children:['"',x("testimonial.quote"),'"']}),t.jsxs("div",{className:"border-t border-border/40 pt-5",children:[t.jsx("p",{className:"font-semibold text-foreground",children:x("testimonial.name")}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[x("testimonial.role")," · ",x("testimonial.company")]})]})]})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(R=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:R})]},R))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:R=>i(R.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:R=>l(R.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:R=>d(R.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:R=>p(R.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const Q9e=[ka,Pn,cn,Xr],X9e=[yc,Xr,pn,mi,Ba,vi];function kV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(ute),_=S("challenges.icons",Q9e),A=S("features.icons",X9e);async function T(R){R.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const M=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:M.map((R,D)=>t.jsxs("span",{children:[D>0&&t.jsx("br",{className:"hidden sm:block"}),D>0&&" ",R]},D))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("hero.secondaryButton")})]})]})}),j.showTestimonials!=="false"&&t.jsxs("section",{className:"py-10 border-y border-border/40",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-6",children:x("trustedBy.heading")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-x-12 gap-y-3 px-4",children:C("trustedBy.names").map(R=>
577t.jsx("span",{className:"text-foreground/50 font-semibold text-sm tracking-widest uppercase whitespace-nowrap",children:R},R))})]}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("challenges.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("challenges.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("challenges.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("challenges.items").map(([R="",D=""],$)=>{const O=_($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-destructive/10 flex items-center justify-center shrink-0",children:t.jsx(O,{className:"w-5 h-5 text-destructive"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},R)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("features.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("features.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("features.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6",children:k("features.items").map(([R="",D=""],$)=>{const O=A($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 space-y-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:t.jsx(O,{className:"w-5 h-5 text-primary"})}),t.jsx("p",{className:"font-semibold text-foreground",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]},R)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([R="",D=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-primary",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground",children:D})]},D))})})}),j.showTestimonials!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-3xl mx-auto",children:t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-8 space-y-5",children:[t.jsx("div",{className:"text-3xl text-primary/60 font-serif leading-none",children:'"'}),t.jsxs("p",{className:"text-lg text-muted-foreground leading-relaxed italic",children:['"',x("testimonial.quote"),'"']}),t.jsxs("div",{className:"border-t border-border/40 pt-5",children:[t.jsx("p",{className:"font-semibold text-foreground",children:x("testimonial.name")}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[x("testimonial.role")," · ",x("testimonial.company")]})]})]})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(R=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:R})]},R))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:R=>i(R.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:R=>l(R.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:R=>d(R.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:R=>p(R.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const Z9e=[ql,lO,ka,Ba],J9e=[yc,Xr,pn,mi,Ba,vi];function _V(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(cte),_=S("challenges.icons",Z9e),A=S("features.icons",J9e);async function T(R){R.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const M=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:M.map((R,D)=>t.jsxs("span",{children:[D>0&&t.jsx("br",{className:"hidden sm:block"}),D>0&&" ",R]},D))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("hero.secondaryButton")})]})]})}),j.showTestimonials!=="false"&&t.jsxs("section",{className:"py-10 border-y border-border/40",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-6",children:x("trustedBy.heading")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-x-12 gap-y-3 px-4",children:C("trustedBy.names").map(R=>
577t.jsx("span",{className:"text-foreground/50 font-semibold text-sm tracking-widest uppercase whitespace-nowrap",children:R},R))})]}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("challenges.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("challenges.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("challenges.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("challenges.items").map(([R="",D=""],$)=>{const O=_($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-destructive/10 flex items-center justify-center shrink-0",children:t.jsx(O,{className:"w-5 h-5 text-destructive"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},R)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("features.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("features.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("features.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6",children:k("features.items").map(([R="",D=""],$)=>{const O=A($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 space-y-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:t.jsx(O,{className:"w-5 h-5 text-primary"})}),t.jsx("p",{className:"font-semibold text-foreground",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]},R)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([R="",D=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-primary",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground",children:D})]},D))})})}),j.showTestimonials!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-3xl mx-auto",children:t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-8 space-y-5",children:[t.jsx("div",{className:"text-3xl text-primary/60 font-serif leading-none",children:'"'}),t.jsxs("p",{className:"text-lg text-muted-foreground leading-relaxed italic",children:['"',x("testimonial.quote"),'"']}),t.jsxs("div",{className:"border-t border-border/40 pt-5",children:[t.jsx("p",{className:"font-semibold text-foreground",children:x("testimonial.name")}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[x("testimonial.role")," · ",x("testimonial.company")]})]})]})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(R=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:R})]},R))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:R=>i(R.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:R=>l(R.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:R=>d(R.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:R=>p(R.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const eVe=[xu,ka,Pn,Xr],tVe=[yc,Xr,pn,mi,Ba,vi];function PV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(lte),_=S("challenges.icons",eVe),A=S("features.icons",tVe);async function T(R){R.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const M=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:M.map((R,D)=>t.jsxs("span",{children:[D>0&&t.jsx("br",{className:"hidden sm:block"}),D>0&&" ",R]},D))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("hero.secondaryButton")})]})]})}),j.showTestimonials!=="false"&&t.jsxs("section",{className:"py-10 border-y border-border/40",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-blue-500 mb-6",children:x("trustedBy.heading")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-x-12 gap-y-3 px-4",children:C("trustedBy.names").map(R=>
577t.jsx("span",{className:"text-foreground/50 font-semibold text-sm tracking-widest uppercase whitespace-nowrap",children:R},R))})]}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("challenges.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("challenges.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("challenges.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("challenges.items").map(([R="",D=""],$)=>{const O=_($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-destructive/10 flex items-center justify-center shrink-0",children:t.jsx(O,{className:"w-5 h-5 text-destructive"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},R)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("features.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("features.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("features.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-6",children:k("features.items").map(([R="",D=""],$)=>{const O=A($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 space-y-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:t.jsx(O,{className:"w-5 h-5 text-primary"})}),t.jsx("p",{className:"font-semibold text-foreground",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]},R)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([R="",D=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-primary",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground",children:D})]},D))})})}),j.showTestimonials!=="false"&&t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-3xl mx-auto",children:t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-8 space-y-5",children:[t.jsx("div",{className:"text-3xl text-primary/60 font-serif leading-none",children:'"'}),t.jsxs("p",{className:"text-lg text-muted-foreground leading-relaxed italic",children:['"',x("testimonial.quote"),'"']}),t.jsxs("div",{className:"border-t border-border/40 pt-5",children:[t.jsx("p",{className:"font-semibold text-foreground",children:x("testimonial.name")}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[x("testimonial.role")," · ",x("testimonial.company")]})]})]})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(R=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:R})]},R))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:R=>i(R.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:R=>l(R.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:R=>d(R.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:R=>p(R.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const sVe=[Ba,ka,zK,Pn];function EV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(Ste),_=S("useCases.icons",sVe);async function A(M){M.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const T=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-destructive/10 text-destructive",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:T.map((M,R)=>t.jsxs("span",{children:[R>0&&t.jsx("br",{className:"hidden sm:block"}),R>0&&" ",M]},R))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),"data-testid":"button-get-started",children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),"data-testid":"button-talk-sales",children:x("hero.secondaryButton")})]})]})}),j.imgWeaponHeroShow!=="false"&&t.jsx("section",{className:"py-4 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"w-full rounded-2xl overflow-hidden border border-border/40",children:t.jsx("img",{src:j.imgWeaponHero||QY,alt:"AI weapon detection identifying a person with a firearm",className:"w-full object-cover","data-testid":"img-weapon-detection-hero"})})})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-destructive",children:x("howItWorks.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("howItWorks.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("howItWorks.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("howItWorks.items").map(([M="",R="",D=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-5",children:[t.jsx("div",{className:"text-3xl font-bold text-destructive/20 leading-none shrink-0 pt-1",children:M}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-2",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-destructive",children:x("useCases.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("useCases.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("useCases.items").map(([M="",R=""],D)=>{const $=_(D);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-destructive/10 flex items-center justify-center shrink-0",children:t.jsx($,{className:"w-5 h-5 text-destructive"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:R})]})]},M)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([M="",R=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-destructive",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground",children:R})]},R))})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-destructive",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(M=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:M})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:A,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:M=>i(M.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:M=>l(M.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:M=>d(M.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:M=>p(M.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const rVe="/assets/image_1779675298833-BdFNZkex.png",nVe=[ka,GK,uc,xi];function TV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(vte),_=S("useCases.icons",nVe);async function A(T){T.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-purple-500/10 text-purple-600 dark:text-purple-400",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:C("hero.heading").map((T,M)=>t.jsxs("span",{children:[M>0&&t.jsx("br",{className:"hidden sm:block"}),M>0&&" ",T]},M))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),"data-testid":"button-get-started",children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),"data-testid":"button-talk-sales",children:x("hero.secondaryButton")})]})]})}),j.imgFacesHeroShow!=="false"&&t.jsx("section",{className:"py-4 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"w-full rounded-2xl overflow-hidden border border-border/40",children:t.jsx("img",{src:j.imgFacesHero||ZY,alt:x("heroImage.alt"),className:"w-full object-cover","data-testid":"img-faces-people-hero"})})})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-8 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-purple-500",children:x("howItWorks.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("howItWorks.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("howItWorks.subheading")})]}),j.imgFacesSearchShow!=="false"&&t.jsx("div",{className:"w-full rounded-2xl overflow-hidden border border-border/40 mb-14",children:t.jsx("img",{src:j.imgFacesSearch||rVe,alt:x("searchImage.alt"),className:"w-full object-cover","data-testid":"img-faces-search-results"})}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("howItWorks.items").map(([T="",M="",R=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-5",children:[t.jsx("div",{className:"text-3xl font-bold text-purple-500/20 leading-none shrink-0 pt-1",children:T}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-2",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:R})]})]},T))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-purple-500",children:x("useCases.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("useCases.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("useCases.items").map(([T="",M=""],R)=>{const D=_(R);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center shrink-0",children:t.jsx(D,{className:"w-5 h-5 text-purple-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:T}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:M})]})]},T)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([T="",M=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-purple-500",children:T}),t.jsx("p",{className:"text-sm text-muted-foreground",children:M})]},M))})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-purple-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(T=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:T})]},T))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:A,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:T=>i(T.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:T=>l(T.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:T=>d(T.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:T=>p(T.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const aVe=[vi,xu,xi,Xr];function AV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),{t:j,tLines:x,tParts:C,tIcons:k}=rn(yte),S=k("useCases.icons",aVe);async function _(A){A.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:j("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:x("hero.heading").map((A,T)=>t.jsxs("span",{children:[T>0&&t.jsx("br",{className:"hidden sm:block"}),T>0&&" ",A]},T))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:j("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),"data-testid":"button-get-started",children:j("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),"data-testid":"button-talk-sales",children:j("hero.secondaryButton")})]})]})}),t.jsx("section",{className:"py-12 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-primary mb-8",children:j("examples.heading")}),t.jsx("div",{className:"space-y-3",children:C("examples.items").map(([A="",T=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl px-5 py-4 flex flex-col sm:flex-row sm:items-center gap-3",children:[t.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[t.jsx(qx,{className:"w-4 h-4 text-primary shrink-0 mt-0.5"}),t.jsxs("span",{className:"text-sm font-medium text-foreground italic",children:['"',A,'"']})]}),t.jsxs("div",{className:"flex items-center gap-2 sm:shrink-0",children:[t.jsx(Nb,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:T})]})]},A))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-primary",children:j("howItWorks.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:j("howItWorks.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:C("howItWorks.items").map(([A="",T="",M=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-5",children:[t.jsx("div",{className:"text-3xl font-bold text-primary/20 leading-none shrink-0 pt-1",children:A}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-2",children:T}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:M})]})]},A))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-primary",children:j("useCases.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:j("useCases.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:C("useCases.items").map(([A="",T=""],M)=>{const R=S(M);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:t.jsx(R,{className:"w-5 h-5 text-primary"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:A}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:T})]})]},A)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:C("stats.items").map(([A="",T=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-primary",children:A}),t.jsx("p",{className:"text-sm text-muted-foreground",children:T})]},T))})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-primary",children:j("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:j("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:x("included.items").map(A=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:A})]},A))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:j("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:j("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:j("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:j("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:j("contact.title")}),t.jsx(cr,{children:j("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:j("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:j("contact.sentBody")})]}):t.jsxs("form",{onSubmit:_,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:A=>i(A.target.value),required:!0,placeholder:j("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:A=>l(A.target.value),required:!0,placeholder:j("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:A=>d(A.target.value),placeholder:j("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:A=>p(A.target.value),placeholder:j("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),j("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),j("contact.sendButton")]})})]})]})})]})}const iVe=[Ba,Rk,sO,Xr,Xr],MV=["bg-blue-500/10 text-blue-500","bg-amber-500/10 text-amber-500","bg-green-500/10 text-green-500","bg-purple-500/10 text-purple-500","bg-rose-500/10 text-rose-500"],oVe=[Rk,sO,Ba,xi];function RV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs();Er();const{t:j,tLines:x,tParts:C,tIcons:k}=rn(bte),S=k("detectable.icons",iVe),_=k("useCases.icons",oVe);async function A(M){M.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const T=x("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400",children:j("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:T.map((M,R)=>t.jsxs("span",{children:[R>0&&t.jsx("br",{className:"hidden sm:block"}),R>0&&" ",M]},R))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:j("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),"data-testid":"button-get-started",children:j("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),"data-testid":"button-talk-sales",children:j("hero.secondaryButton")})]})]})}),t.jsx("section",{className:"py-12 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500 mb-8",children:j("detectable.eyebrow")}),t.jsx("div",{className:"flex flex-wrap justify-center gap-4",children:x("detectable.items").map((M,R)=>{const D=S(R),$=MV[R%MV.length];return t.jsxs("div",{className:`flex items-center gap-2 px-5 py-3 rounded-full border border-border/50 bg-card ${$}`,children:[t.jsx(D,{className:"w-4 h-4"}),t.jsx("span",{className:"text-sm font-medium text-foreground",children:M})]},M)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:j("howItWorks.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:j("howItWorks.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:j("howItWorks.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:C("howItWorks.items").map(([M="",R="",D=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-5",children:[t.jsx("div",{className:"text-3xl font-bold text-blue-500/20 leading-none shrink-0 pt-1",children:M}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-2",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:j("useCases.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:j("useCases.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:C("useCases.items").map(([M="",R=""],D)=>{const $=_(D);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/10 flex items-center justify-center shrink-0",children:t.jsx($,{className:"w-5 h-5 text-blue-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:R})]})]},M)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:C("stats.items").map(([M="",R=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-blue-500",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground",children:R})]},R))})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:j("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:j("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:x("included.items").map(M=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:M})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:j("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:j("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:j("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:j("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:j("contact.title")}),t.jsx(cr,{children:j("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:j("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:j("contact.sentBody")})]}):t.jsxs("form",{onSubmit:A,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:M=>i(M.target.value),required:!0,placeholder:j("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:M=>l(M.target.value),required:!0,placeholder:j("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:M=>d(M.target.value),placeholder:j("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:M=>p(M.target.value),placeholder:j("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),j("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),j("contact.sendButton")]})})]})]})})]})}const lVe="/assets/image_1779684982566-hJOW-4sb.png",cVe=[Ba,xi,vi,xu];function IV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(Nte),_=S("useCases.icons",cVe);async function A(M){M.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const T=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:T.map((M,R)=>t.jsxs("span",{children:[R>0&&t.jsx("br",{className:"hidden sm:block"}),R>0&&" ",M]},R))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),"data-testid":"button-get-started",children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),"data-testid":"button-talk-sales",children:x("hero.secondaryButton")})]})]})}),t.jsx("section",{className:"py-4 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto grid md:grid-cols-2 gap-6",children:[j.imgVisualSearchShow!=="false"&&t.jsx("div",{className:"rounded-2xl border border-border/40 bg-card overflow-hidden shadow-sm",children:t.jsx("img",{src:j.imgVisualSearch||XY,alt:`${j.productName} visual search interface`,className:"w-full h-auto block","data-testid":"img-visual-search"})}),j.imgVisualMatchShow!=="false"&&t.jsx("div",{className:"rounded-2xl border border-border/40 bg-card overflow-hidden shadow-sm",children:t.jsx("img",{src:j.imgVisualMatch||lVe,alt:"
577Visual comparison match results",className:"w-full h-auto block","data-testid":"img-visual-match"})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-amber-500",children:x("howItWorks.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("howItWorks.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("howItWorks.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("howItWorks.items").map(([M="",R="",D=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-5",children:[t.jsx("div",{className:"text-3xl font-bold text-amber-500/20 leading-none shrink-0 pt-1",children:M}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-2",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-amber-500",children:x("useCases.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("useCases.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("useCases.items").map(([M="",R=""],D)=>{const $=_(D);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-amber-500/10 flex items-center justify-center shrink-0",children:t.jsx($,{className:"w-5 h-5 text-amber-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:R})]})]},M)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([M="",R=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-amber-500",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground",children:R})]},R))})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-amber-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(M=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx("span",{className:"text-sm text-foreground/80",children:M})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:A,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:M=>i(M.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:M=>l(M.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:M=>d(M.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:M=>p(M.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const dVe=[qK,Fa,xi,oh],uVe=[ka,vi,TK];function Y1(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(gte),_=S("useCases.icons",dVe),A=S("security.icons",uVe);async function T(M){M.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-sm font-medium bg-blue-500/10 text-blue-600 dar
577k:text-blue-400",children:[t.jsx(GY,{className:"w-4 h-4"}),x("hero.badge")]}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:C("hero.heading").map((M,R)=>t.jsxs("span",{children:[R>0&&t.jsx("br",{className:"hidden sm:block"}),R>0&&" ",M]},R))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),"data-testid":"button-get-started",children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),"data-testid":"button-talk-sales",children:x("hero.secondaryButton")})]})]})}),j.imgCloudHeroShow!=="false"&&t.jsx("section",{className:"py-4 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-3xl mx-auto flex justify-center",children:t.jsx("div",{className:"w-64 sm:w-72 lg:w-80",children:t.jsx("img",{src:j.imgCloudHero||YY,alt:x("heroImage.alt"),className:"w-full rounded-3xl shadow-2xl border border-white/10","data-testid":"img-cloud-storage"})})})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("howItWorks.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("howItWorks.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("howItWorks.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("howItWorks.items").map(([M="",R="",D=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-5","data-testid":`card-step-${M}`,children:[t.jsx("div",{className:"text-3xl font-bold text-blue-500/20 leading-none shrink-0 pt-1",children:M}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-2",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("useCases.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("useCases.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("useCases.items").map(([M="",R=""],D)=>{const $=_(D);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4","data-testid":`card-usecase-${M}`,children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/10 flex items-center justify-center shrink-0",children:t.jsx($,{className:"w-5 h-5 text-blue-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:R})]})]},M)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([M="",R=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-blue-500","data-testid":`stat-value-${R}`,children:M}),t.jsx("p",{className:"text-sm text-muted-foreground",children:R})]},R))})})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-12 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("security.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("security.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-3 gap-6",children:k("security.items").map(([M="",R=""],D)=>{const $=A(D);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6","data-testid":`card-security-${M}`,children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/10 flex items-center justify-center mb-4",children:t.jsx($,{className:"w-5 h-5 text-blue-500"})}),t.jsx("p",{className:"font-semibold text-foreground mb-2",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:R})]},M)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(M=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:M})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"w-14 h-14 rounded-2xl bg-blue-500/10 flex items-center justify-center",children:t.jsx(pn,{className:"w-7 h-7 text-blue-500"})})}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:M=>i(M.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:M=>l(M.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:M=>d(M.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:M=>p(M.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const mVe=[wo,jb,vi,ro],hVe=[Pn,tl,vc];function Q1(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(xte),_=S("useCases.icons",mVe),A=S("alertTypes.icons",hVe);async function T(M){M.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-sm font-medium bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",children:[t.jsx(mi,{className:"w-4 h-4"}),x("hero.badge")]}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:C("hero.heading").map((M,R)=>t.jsxs("span",{children:[R>0&&t.jsx("br",{className:"hidden sm:block"}),R>0&&" ",M]},R))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),"data-testid":"button-get-started",children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),"data-testid":"button-talk-sales",children:x("hero.secondaryButton")})]})]})}),j.imgNotifHeroShow!=="false"&&t.jsx("section",{className:"py-4 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-3xl mx-auto flex justify-center",children:t.jsx("div",{className:"w-64 sm:w-72 lg:w-80",children:t.jsx("img",{src:j.imgNotifHero||Q5,alt:x("heroImage.alt"),className:"w-full rounded-3xl shadow-2xl border border-white/10","data-testid":"img-notifications"})})})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-emerald-500",children:x("howItWorks.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("howItWorks.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("howItWorks.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("howItWorks.items").map(([M="",R="",D=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-5","data-testid":`card-step-${M}`,children:[t.jsx("div",{className:"text-3xl font-bold text-emerald-500/20 leading-none shrink-0 pt-1",children:M}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-2",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-emerald-500",children:x("useCases.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("useCases.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("useCases.items").map(([M="",R=""],D)=>{const $=_(D);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4","data-testid":`card-usecase-${M}`,children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-500/10 flex items-center justify-center shrink-0",children:t.jsx($,{className:"w-5 h-5 text-emerald-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:R})]})]},M)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([M="",R=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-4xl font-bold text-emerald-500","data-testid":`stat-value-${R}`,children:M}),t.jsx("p",{className:"text-sm text-muted-foreground",children:R})]},R))})})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-12 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-emerald-500",children:x("alertTypes.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("alertTypes.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-3 gap-6",children:k("alertTypes.items").map(([M="",R=""],D)=>{const $=A(D);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6","data-testid":`card-alert-${M}`,children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-500/10 flex items-center justify-center mb-4",children:t.jsx($,{className:"w-5 h-5 text-emerald-500"})}),t.jsx("p",{className:"font-semibold text-foreground mb-2",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:R})]},M)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-emerald-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(M=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:M})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"w-14 h-14 rounded-2xl bg-emerald-500/10 flex items-center justify-center",children:t.jsx(qi,{className:"w-7 h-7 text-emerald-500"})})}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:M=>i(M.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:M=>l(M.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:M=>d(M.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:M=>p(M.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}const pVe=[_y,WK,bK,EK,eO,Xr],fVe=[ql,pf,aO,Vj];function X1(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs();Er();const{t:j,tLines:x,tParts:C,tIcons:k}=rn(wte),S=k("capabilities.icons",pVe),_=k("useCases.icons",fVe);async function A(M){M.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const T=x("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-sm font-medium bg-purple-500/10 text-purple-600 dark:text-purple-400",children:[t.jsx(_y,{className:"w-4 h-4"}),j("hero.badge")]}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:T.map((M,R)=>t.jsxs("span",{children:[R>0&&t.jsx("br",{className:"hidden sm:block"}),R>0&&" ",M]},R))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:j("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),"data-testid":"button-get-started",children:j("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),"data-testid":"button-talk-sales",children:j("hero.secondaryButton")})]})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-purple-500",children:j("howItWorks.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:j("howItWorks.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:j("howItWorks.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:C("howItWorks.items").map(([M="",R="",D=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-5","data-testid":`card-step-${M}`,children:[t.jsx("div",{className:"text-3xl font-bold text-purple-500/20 leading-none shrink-0 pt-1",children:M}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-2",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-purple-500",children:j("capabilities.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:j("capabilities.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-3 gap-6",children:C("capabilities.items").map(([M="",R=""],D)=>{const $=S(D);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6","data-testid":`card-capability-${M}`,children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center mb-4",children:t.jsx($,{className:"w-5 h-5 text-purple-500"})}),t.jsx("p",{className:"font-semibold text-foreground mb-2",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:R})]},M)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-purple-500",children:j("useCases.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:j("useCases.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:C("useCases.items").map(([M="",R=""],D)=>{const $=_(D);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4","data-testid":`card-usecase-${M}`,children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center shrink-0",children:t.jsx($,{className:"w-5 h-5 text-purple-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:M}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:R})]})]},M)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-purple-500",children:j("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:j("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:x("included.items").map(M=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:M})]},M))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"w-14 h-14 rounded-2xl bg-purple-500/10 flex items-center justify-center",children:t.jsx(_y,{className:"w-7 h-7 text-purple-500"})})}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:j("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:j("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:j("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:j("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:j("contact.title")}),t.jsx(cr,{children:j("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:j("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:j("contact.sentBody")})]}):t.jsxs("form",{onSubmit:A,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:M=>i(M.target.value),required:!0,placeholder:j("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:M=>l(M.target.value),required:!0,placeholder:j("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:M=>d(M.target.value),placeholder:j("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:j("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:M=>p(M.target.value),placeholder:j("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),j("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),j("contact.sendButton")]})})]})]})})]})}const gVe="/assets/image_1779685405273-ClD8CDYc.png",xVe="/assets/1779390084813_1779685414298-DHhn2b44.jpg",vVe="/assets/1779390084884_1779685414299-ClIwX7m5.jpg",yVe=[Xr,Ba,Nb,qj],OV=["bg-blue-500/10 text-blue-500","bg-purple-500/10 text-purple-500","bg-amber-500/10 text-amber-500","bg-green-500/10 text-green-500"],bVe=[Pn,xi,vi,cn];function DV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k,tIcons:S}=rn(jte),_=S("ruleTypes.icons",yVe),A=S("useCases.icons",bVe);async function T(R){R.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:h})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}const M=C("hero.heading");return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400",children:x("hero.badge")}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:M.map((R,D)=>t.jsxs("span",{children:[D>0&&t.jsx("br",{className:"hidden sm:block"}),D>0&&" ",R]},D))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),"data-testid":"button-get-started",children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),"data-testid":"button-talk-sales",children:x("hero.secondaryButton")})]})]})}),t.jsx("section",{className:"py-4 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto 
577space-y-6",children:[j.imgAlertsInboxShow!=="false"&&t.jsx("div",{className:"rounded-2xl border border-border/40 bg-card overflow-hidden shadow-sm",children:t.jsx("img",{src:j.imgAlertsInbox||gVe,alt:"Smart Alerts inbox showing review queue with object detection results",className:"w-full h-auto block","data-testid":"img-alerts-inbox"})}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6 max-w-3xl mx-auto",children:[j.imgAlertsMobileShow!=="false"&&t.jsx("div",{className:"rounded-2xl border border-border/40 bg-card overflow-hidden shadow-sm flex items-center justify-center p-4",children:t.jsx("img",{src:j.imgAlertsMobile||xVe,alt:"Smart Alerts on mobile with known person matches",className:"max-h-[520px] w-auto object-contain","data-testid":"img-alerts-mobile"})}),j.imgAlertsRuleShow!=="false"&&t.jsx("div",{className:"rounded-2xl border border-border/40 bg-card overflow-hidden shadow-sm flex items-center justify-center p-4",children:t.jsx("img",{src:j.imgAlertsRule||vVe,alt:"New Smart Alert rule configuration",className:"max-h-[520px] w-auto object-contain","data-testid":"img-alert-rule"})})]})]})}),t.jsx("section",{className:"py-12 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-5xl mx-auto",children:[t.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-amber-500 mb-8",children:x("ruleTypes.eyebrow")}),t.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-4",children:k("ruleTypes.items").map(([R="",D=""],$)=>{const O=_($),q=OV[$%OV.length];return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-5 space-y-3",children:[t.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center ${q}`,children:t.jsx(O,{className:"w-4 h-4"})}),t.jsx("p",{className:"font-semibold text-foreground text-sm",children:R}),t.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:D})]},R)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-amber-500",children:x("howItWorks.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("howItWorks.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("howItWorks.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("howItWorks.items").map(([R="",D="",$=""])=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-5",children:[t.jsx("div",{className:"text-3xl font-bold text-amber-500/20 leading-none shrink-0 pt-1",children:R}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-2",children:D}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:$})]})]},R))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-amber-500",children:x("useCases.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("useCases.heading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("useCases.items").map(([R="",D=""],$)=>{const O=A($);return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-amber-500/10 flex items-center justify-center shrink-0",children:t.jsx(O,{className:"w-5 h-5 text-amber-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:D})]})]},R)})})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsx("div",{className:"grid sm:grid-cols-3 gap-8 text-center",children:k("stats.items").map(([R="",D=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-3xl font-bold text-amber-500",children:R}),t.jsx("p",{className:"text-sm text-muted-foreground",children:D})]},D))})})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-4xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-10 space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-amber-500",children:x("included.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("included.heading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:C("included.items").map(R=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-primary shrink-0"}
577),t.jsx("span",{className:"text-sm text-foreground/80",children:R})]},R))})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>s(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:T,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:R=>i(R.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:R=>l(R.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:R=>d(R.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:R=>p(R.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}function xx({label:e,children:s}){return t.jsxs("div",{className:"space-y-4",children:[e&&t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:e}),s]})}function vx({children:e}){return t.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground leading-snug",children:e})}function zp({children:e}){return t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:e})}function Gn({children:e}){return t.jsx("p",{className:"text-base text-muted-foreground leading-relaxed",children:e})}function f5({children:e}){return t.jsx("div",{className:"bg-primary/5 border border-primary/20 rounded-xl px-6 py-5",children:t.jsx("p",{className:"text-base text-foreground/80 leading-relaxed",children:e})})}const LV=["bg-destructive/20 text-destructive","bg-yellow-500/20 text-yellow-600 dark:text-yellow-400","bg-primary/20 text-primary"];function $V(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(!1),[g,v]=u.useState(!1),{toast:b}=Hs(),{t:y,tLines:w,tParts:j}=rn(Pte);async function x(C){C.preventDefault(),p(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,message:c})})).ok?v(!0):b({title:"Failed to send",description:"Please try again.",variant:"destructive"})}catch{b({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{p(!1)}}return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-16 px-4 sm:px-6 lg:px-8 border-b border-border/40",children:t.jsxs("div",{className:"max-w-4xl mx-auto 
577space-y-6",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:y("hero.badge")}),t.jsx("span",{className:"text-sm text-muted-foreground",children:y("hero.byline")})]}),t.jsx("h1",{className:"text-4xl sm:text-5xl font-bold text-foreground leading-tight",children:w("hero.heading").map((C,k)=>t.jsxs("span",{children:[k>0&&t.jsx("br",{className:"hidden sm:block"}),k>0?` ${C}`:C]},k))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl leading-relaxed",children:y("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap gap-3 pt-2",children:[t.jsx(L,{asChild:!0,size:"lg",children:t.jsxs("a",{href:"/Truvios-White-Paper-From-Storage-to-Intelligence.pdf",download:"Truvios-White-Paper-From-Storage-to-Intelligence.pdf",children:[t.jsx(ya,{className:"w-4 h-4 mr-2"})," ",y("hero.downloadButton")]})}),t.jsxs(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:[y("hero.demoButton")," ",t.jsx(N0,{className:"w-4 h-4 ml-2"})]})]})]})}),t.jsxs("article",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16 space-y-16",children:[t.jsxs(xx,{label:y("intro.label"),children:[t.jsx(vx,{children:y("intro.heading")}),t.jsx(Gn,{children:y("intro.p1")}),t.jsx(Gn,{children:y("intro.p2")}),t.jsx(Gn,{children:y("intro.p3")}),t.jsx("ul",{className:"space-y-2 pl-5 list-disc text-muted-foreground text-base leading-relaxed",children:w("intro.list").map(C=>t.jsx("li",{children:C},C))}),t.jsx(Gn,{children:y("intro.p4")}),t.jsx(f5,{children:y("intro.callout")}),t.jsx(Gn,{children:y("intro.p5")}),t.jsx(Gn,{children:y("intro.p6")})]}),t.jsxs(xx,{label:y("landscape.label"),children:[t.jsx(vx,{children:y("landscape.heading")}),t.jsx(Gn,{children:y("landscape.p1")}),t.jsx("div",{className:"overflow-x-auto -mx-4 sm:mx-0",children:t.jsxs("table",{className:"w-full text-sm border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border",children:[t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70 w-1/4",children:y("landscape.tableFeature")}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70",children:y("landscape.tableNvr")}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70",children:y("landscape.tableCloud")}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-primary",children:y("landscape.tableHybrid")})]})}),t.jsx("tbody",{children:j("landscape.comparisonRows").map(([C="",k="",S="",_=""],A)=>t.jsxs("tr",{className:A%2===0?"bg-muted/20":"",children:[t.jsx("td",{className:"px-4 py-3 font-medium text-foreground/80",children:C}),t.jsx("td",{className:"px-4 py-3 text-muted-foreground",children:k}),t.jsx("td",{className:"px-4 py-3 text-muted-foreground",children:S}),t.jsx("td",{className:"px-4 py-3 text-primary font-medium",children:_})]},C))})]})}),t.jsx(zp,{children:y("landscape.nvrHeading")}),t.jsx(Gn,{children:y("landscape.nvrIntro")}),t.jsx("div",{className:"space-y-4 pl-4 border-l-2 border-border",children:j("landscape.nvrItems").map(([C="",k=""])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"font-semibold text-foreground",children:C}),t.jsx(Gn,{children:k})]},C))}),t.jsx(zp,{children:y("landscape.cloudHeading")}),t.jsx(Gn,{children:y("landscape.cloudIntro")}),t.jsx(Gn,{children:y("landscape.cloudRisk")}),t.jsx("div",{className:"space-y-4 pl-4 border-l-2 border-border",children:j("landscape.cloudItems").map(([C="",k=""])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"font-semibold text-foreground",children:C}),t.jsx(Gn,{children:k})]},C))})]}),t.jsxs(xx,{label:y("hybrid.label"),children:[t.jsx(vx,{children:y("hybrid.heading")}),t.jsxs("div",{className:"bg-muted/30 border border-border/50 rounded-2xl p-6 sm:p-8",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500 mb-6 text-center",children:y("hybrid.diagramTitle")}),t.jsx("div",{className:"grid sm:grid-cols-3 gap-6",children:j("hybrid.diagramColumns").map(([C="",...k])=>t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"font-semibold text-foreground text-sm",children:C}),t.jsx("ul",{className:"space-y-1.5",children:k.map(S=>t.jsxs("li",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary shrink-0"}),S]},S))})]},C))})]}),t.jsx(Gn,{children:y("hybrid.p1")}),t.jsx(Gn,{children:y("hybrid.p2")}),t.jsx(Gn,{children:y("hybrid.p3")}),t.jsx(Gn,{children:y("hybrid.p4")}),t.jsx(Gn,{children:y("hybrid.p5")}),t.jsx(f5,{children:y("hybrid.callout")})]}),t.jsxs(xx,{label:y("approach.label"),children:[t.jsx(vx,{children:y("approach.heading")}),t.jsx(Gn,{children:y("approach.p1")}),t.jsxs("div",{className:"bg-muted/30 border border-border/50 rounded-2xl p-6 sm:p-8 space-y-4",children:[t.jsx("p",{className:"font-semibold text-foreground",children:y("approach.tiersTitle")}),t.jsx("div",{className:"space-y-3",children:j("approach.tiers").map(([C="",k="",S=""],_)=>{const A=LV[_%LV.length];return t.jsxs("div",{className:"flex items-center justify-between gap-4 bg-background/60 border border-border/40 rounded-lg px-4 py-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-foreground text-sm",children:C}),t.jsx("p",{className:"text-xs text-muted-foreground",children:k})]}),t.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-semibold shrink-0 ${A}`,children:S})]},C)})})]}),t.jsx(zp,{children:y("approach.storageHeading")}),t.jsx(Gn,{children:y("approach.storageP1")}),t.jsx(Gn,{children:y("approach.storageP2")}),t.jsx(Gn,{children:y("approach.storageP3")}),t.jsx(Gn,{children:y("approach.storageP4")}),t.jsx(zp,{children:y("approach.usableHeading")}),t.jsx(Gn,{children:y("approach.usableP1")}),t.jsx(Gn,{children:y("approach.usableP2")}),t.jsx(zp,{children:y("approach.runningHeading")}),t.jsx("div",{className:"bg-muted/30 border border-border/50 rounded-2xl p-6 sm:p-8",children:t.jsx("div",{className:"grid sm:grid-cols-4 gap-6",children:j("approach.runningCards").map(([C="",k=""])=>t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"font-semibold text-foreground text-sm",children:C}),t.jsx("p",{className:"text-sm text-muted-foreground",children:k})]},C))})}),t.jsx(Gn,{children:y("approach.runningP1")}),t.jsx(Gn,{children:y("approach.runningP2")})]}),t.jsxs(xx,{label:y("useCases.label"),children:[t.jsx(vx,{children:y("useCases.heading")}),t.jsx(Gn,{children:y("useCases.intro")}),t.jsx("div",{className:"space-y-8",children:j("useCases.items").map(([C="",...k],S)=>t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 space-y-3",children:[t.jsx(zp,{children:C}),k.map((_,A)=>t.jsx(Gn,{children:_},A))]},S))})]}),t.jsxs(xx,{label:y("partners.label"),children:[t.jsx(vx,{children:y("partners.heading")}),t.jsx(Gn,{children:y("partners.intro")}),t.jsx("div",{className:"overflow-x-auto -mx-4 sm:mx-0",children:t.jsxs("table",{className:"w-full text-sm border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border",children:[t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground
577/70 w-1/5",children:y("partners.tableArea")}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70",children:y("partners.tableSystem")}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-primary",children:y("partners.tablePartner")})]})}),t.jsx("tbody",{children:j("partners.rows").map(([C="",k="",S=""],_)=>t.jsxs("tr",{className:_%2===0?"bg-muted/20":"",children:[t.jsx("td",{className:"px-4 py-3 font-medium text-foreground/80 align-top",children:C}),t.jsx("td",{className:"px-4 py-3 text-muted-foreground align-top",children:k}),t.jsx("td",{className:"px-4 py-3 text-primary/90 align-top",children:S})]},C))})]})}),t.jsx(zp,{children:y("partners.swapHeading")}),t.jsx(Gn,{children:y("partners.swapP1")}),t.jsx(Gn,{children:y("partners.swapP2")}),t.jsx(Gn,{children:y("partners.swapP3")}),t.jsx(zp,{children:y("partners.costHeading")}),t.jsx(Gn,{children:y("partners.costP1")}),t.jsx(Gn,{children:y("partners.costP2")}),t.jsx(zp,{children:y("partners.recurringHeading")}),t.jsx(Gn,{children:y("partners.recurringP1")}),t.jsx(Gn,{children:y("partners.recurringP2")})]}),t.jsxs(xx,{label:y("conclusion.label"),children:[t.jsx(vx,{children:y("conclusion.heading")}),t.jsx(Gn,{children:y("conclusion.p1")}),t.jsx(Gn,{children:y("conclusion.p2")}),t.jsx(Gn,{children:y("conclusion.p3")}),t.jsx(f5,{children:y("conclusion.callout")})]}),t.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-2xl p-8 sm:p-10 text-center space-y-5",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-blue-500",children:y("download.eyebrow")}),t.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground",children:y("download.heading")}),t.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:y("download.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{asChild:!0,size:"lg",children:t.jsxs("a",{href:"/Truvios-White-Paper-From-Storage-to-Intelligence.pdf",download:"Truvios-White-Paper-From-Storage-to-Intelligence.pdf",children:[t.jsx(ya,{className:"w-4 h-4 mr-2"})," ",y("download.downloadButton")]})}),t.jsxs(L,{size:"lg",variant:"outline",onClick:()=>n(!0),children:[y("download.demoButton")," ",t.jsx(N0,{className:"w-4 h-4 ml-2"})]})]})]})]}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:y("contact.title")}),t.jsx(cr,{children:y("contact.description")})]}),g?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:y("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:y("contact.sentBody")})]}):t.jsxs("form",{onSubmit:x,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:y("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:C=>i(C.target.value),required:!0,placeholder:y("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:y("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:C=>l(C.target.value),required:!0,placeholder:y("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:y("contact.messageLabel")}),t.jsx(Nn,{value:c,onChange:C=>d(C.target.value),placeholder:y("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:h,children:h?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),y("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),y("contact.sendButton")]})})]})]})})]})}const wVe=["All Types","IP Camera","Bullet","Dome","Turret","PTZ Camera","NVR","DVR","Fisheye"];function FV({value:e}){const[s,r]=u.useState(!1),{toast:n}=Hs();function a(){navigator.clipboard.writeText(e),r(!0),n({title:"Copied to clipboard"}),setTimeout(()=>r(!1),2e3)}return t.jsx("button",{onClick:a,className:"ml-1.5 text-muted-foreground hover:text-foreground transition-colors shrink-0",title:"Copy URL",children:s?t.jsx(Hd,{className:"w-3.5 h-3.5 text-primary"}):t.jsx(I5,{className:"w-3.5 h-3.5"})})}function BV(){const[e,s]=u.useState(""),[r,n]=u.useState("All Brands"),[a,i]=u.useState("All Types"),[o,l]=u.useState(!1),[c,d]=u.useState("brand"),[h,p]=u.useState("asc"),[g,v]=u.useState(!1),{t:b}=rn(_te),y=u.useMemo(()=>{const x=e.toLowerCase();return Dj.filter(C=>!(r!=="All Brands"&&C.brand!==r||a!=="All Types"&&C.type!==a||o&&!C.onvif||x&&!`${C.brand} ${C.series} ${C.model} ${C.type} ${C.rtspMain} ${C.notes??""}`.toLowerCase().includes(x))).sort((C,k)=>{const S=C[c].toLowerCase(),_=k[c].toLowerCase();return h==="asc"?S.localeCompare(_):_.localeCompare(S)})},[e,r,a,o,c,h]);function w(x){c===x?p(C=>C==="asc"?"desc":"asc"):(d(x),p("asc"))}function j({field:x}){return c!==x?t.jsx(Xa,{className:"w-3.5 h-3.5 opacity-30"}):h==="asc"?t.jsx(Ig,{className:"w-3.5 h-3.5 text-primary"}):t.jsx(Xa,{className:"w-3.5 h-3.5 text-primary"})}return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1")}),t.jsx("section",{className:"pt-32 pb-12 px-4 sm:px-6 lg:px-8 border-b border-border/40",children:t.jsxs("div",{className:"max-w-5xl mx-auto 
577space-y-4",children:[t.jsx("div",{className:"flex flex-wrap items-center gap-3",children:t.jsx("span",{className:"inline-block px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary",children:b("hero.badge")})}),t.jsx("h1",{className:"text-4xl sm:text-5xl font-bold text-foreground leading-tight",children:b("hero.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-3xl leading-relaxed",children:b("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap gap-4 text-sm text-muted-foreground pt-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-primary"}),Dj.length," ",b("hero.statDevicesSuffix")]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-2 h-2 rounded-full bg-primary"}),JR.length," ",b("hero.statBrandsSuffix")]})]})]})}),t.jsxs("div",{className:"sticky top-16 z-30 bg-background/95 backdrop-blur-md border-b border-border/40",children:[t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-3 flex flex-wrap gap-3 items-center",children:[t.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-sm",children:[t.jsx(yc,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t.jsx(ke,{placeholder:b("toolbar.searchPlaceholder"),value:e,onChange:x=>s(x.target.value),className:"pl-9 h-9 text-sm","data-testid":"input-device-search"})]}),t.jsxs(L,{size:"sm",variant:"outline",onClick:()=>v(x=>!x),className:"h-9 gap-2",children:[t.jsx(oO,{className:"w-3.5 h-3.5"})," ",b("toolbar.filtersButton"),(r!=="All Brands"||a!=="All Types"||o)&&t.jsx("span",{className:"ml-1 w-2 h-2 rounded-full bg-primary"})]}),t.jsxs("span",{className:"text-sm text-muted-foreground ml-auto hidden sm:block",children:[y.length," ",y.length!==1?b("toolbar.resultPlural"):b("toolbar.resultSingular")]})]}),g&&t.jsx("div",{className:"border-t border-border/40 bg-background/95",children:t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-3 flex flex-wrap gap-3 items-center",children:[t.jsxs("select",{value:r,onChange:x=>n(x.target.value),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground","data-testid":"select-brand-filter",children:[t.jsx("option",{value:"All Brands",children:b("toolbar.allBrands")}),JR.map(x=>t.jsx("option",{value:x,children:x},x))]}),t.jsx("select",{value:a,onChange:x=>i(x.target.value),className:"h-9 rounded-md border border-input bg-background px-3 text-sm text-foreground","data-testid":"select-type-filter",children:wVe.map(x=>t.jsx("option",{value:x,children:x},x))}),t.jsxs("label",{className:"flex items-center gap-2 text-sm text-foreground cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:o,onChange:x=>l(x.target.checked),className:"rounded","data-testid":"checkbox-onvif-only"}),b("toolbar.onvifOnly")]}),(r!=="All Brands"||a!=="All Types"||o||e)&&t.jsx("button",{onClick:()=>{n("All Brands"),i("All Types"),l(!1),s("")},className:"text-sm text-primary hover:underline",children:b("toolbar.clearFilters")})]})})]}),t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[y.length===0?t.jsx("div",{className:"text-center py-20 text-muted-foreground",children:b("table.empty")}):t.jsx("div",{className:"overflow-x-auto rounded-xl border border-border/50",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70 whitespace-nowrap",children:t.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground transition-colors",onClick:()=>w("brand"),children:[b("table.brand")," ",t.jsx(j,{field:"brand"})]})}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70 whitespace-nowrap",children:b("table.series")}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70 whitespace-nowrap",children:t.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground transition-colors",onClick:()=>w("model"),children:[b("table.model")," ",t.jsx(j,{field:"model"})]})}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground
577/70 whitespace-nowrap",children:t.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground transition-colors",onClick:()=>w("type"),children:[b("table.type")," ",t.jsx(j,{field:"type"})]})}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70",children:b("table.onvif")}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70 min-w-[280px]",children:b("table.rtspMain")}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70 min-w-[280px]",children:b("table.rtspSub")}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70",children:b("table.port")}),t.jsx("th",{className:"text-left px-4 py-3 font-semibold text-foreground/70",children:b("table.notes")})]})}),t.jsx("tbody",{children:y.map((x,C)=>t.jsxs("tr",{className:`border-t border-border/40 ${C%2===0?"":"bg-muted/10"} hover:bg-muted/20 transition-colors`,children:[t.jsx("td",{className:"px-4 py-3 font-semibold text-foreground whitespace-nowrap",children:x.brand}),t.jsx("td",{className:"px-4 py-3 text-muted-foreground whitespace-nowrap",children:x.series}),t.jsx("td",{className:"px-4 py-3 text-foreground/90 font-mono text-xs whitespace-nowrap",children:x.model}),t.jsx("td",{className:"px-4 py-3",children:t.jsx(Ke,{variant:"outline",className:"text-xs whitespace-nowrap",children:x.type})}),t.jsx("td",{className:"px-4 py-3",children:x.onvif?t.jsx("span",{className:"text-xs font-semibold text-primary",children:b("table.onvifYes")}):t.jsx("span",{className:"text-xs text-muted-foreground/60",children:b("table.onvifNo")})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-start gap-1",children:[t.jsx("code",{className:"text-xs font-mono text-foreground/80 break-all leading-relaxed",children:x.rtspMain}),t.jsx(FV,{value:x.rtspMain})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-start gap-1",children:[t.jsx("code",{className:"text-xs font-mono text-foreground/80 break-all leading-relaxed",children:x.rtspSub}),t.jsx(FV,{value:x.rtspSub})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-muted-foreground whitespace-nowrap",children:x.port}),t.jsx("td",{className:"px-4 py-3 text-xs text-muted-foreground max-w-[200px]",children:x.notes})]},C))})]})}),t.jsxs("p",{className:"mt-6 text-xs text-muted-foreground",children:[b("footnote.replacePrefix"),t.jsx("code",{className:"font-mono bg-muted px-1 rounded",children:"[user]"}),", ",t.jsx("code",{className:"font-mono bg-muted px-1 rounded",children:"[pass]"}),", ",t.jsx("code",{className:"font-mono bg-muted px-1 rounded",children:"[ip]"}),", and ",t.jsx("code",{className:"font-mono bg-muted px-1 rounded",children:"[ch]"}),b("footnote.replaceSuffix")]})]}),t.jsx(_a,{})]})}const jVe="/assets/image_1780346203811-CdvmjjGg.png",UV=[rO,Yc,qi,xd],zV=[Wx,pn,S0,uc];function HV(){const[e,s]=u.useState(!1),[r,n]=u.useState(!1),[a,i]=u.useState(""),[o,l]=u.useState(""),[c,d]=u.useState(""),[h,p]=u.useState(""),[g,v]=u.useState(!1),[b,y]=u.useState(!1),{toast:w}=Hs(),j=Er(),{t:x,tLines:C,tParts:k}=rn(kte);async function S(_){_.preventDefault(),v(!0);try{(await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,email:o,phone:c,message:`[OEM Branding Inquiry]
578
579${h}`})})).ok?y(!0):w({title:"Failed to send",description:"Please try again or call us.",variant:"destructive"})}catch{w({title:"Network error",description:"Please try again.",variant:"destructive"})}finally{v(!1)}}return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1"),onContact:()=>n(!0)}),t.jsx("section",{className:"pt-32 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-6",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-sm font-medium bg-amber-500/10 text-amber-600 dark:text-amber-400",children:[t.jsx(xi,{className:"w-4 h-4"}),x("hero.badge")]}),t.jsx("h1",{className:"text-4xl sm:text-5xl lg:text-6xl font-bold text-foreground leading-tight",children:C("hero.heading").map((_,A)=>t.jsxs("span",{children:[A>0&&t.jsx("br",{className:"hidden sm:block"}),A===0?`${_} `:_]},A))}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-3xl mx-auto leading-relaxed",children:x("hero.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4 pt-2",children:[t.jsx(L,{size:"lg",onClick:()=>n(!0),"data-testid":"button-request-oem",children:x("hero.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>s(!0),"data-testid":"button-become-reseller",children:x("hero.secondaryButton")})]})]})}),t.jsx("section",{className:"py-16 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:t.jsxs("div",{className:"bg-card border border-border/50 rounded-2xl p-8 sm:p-10",children:[t.jsxs("div",{className:"text-center mb-8 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-amber-500",children:x("package.eyebrow")}),t.jsx("h2",{className:"text-3xl font-bold text-foreground",children:x("package.heading")}),t.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto",children:x("package.subheading")})]}),t.jsx("div",{className:"grid sm:grid-cols-2 gap-3 max-w-3xl mx-auto",children:C("package.items").map(_=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(ar,{className:"w-4 h-4 text-amber-500 shrink-0 mt-0.5"}
579),t.jsx("span",{className:"text-sm text-foreground/85",children:_})]},_))})]})})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-amber-500",children:x("branding.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("branding.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("branding.subheading")})]}),j.imgOemHeroShow!=="false"&&t.jsx("div",{className:"mb-14 max-w-4xl mx-auto",children:t.jsx("div",{className:"rounded-2xl border border-border/50 overflow-hidden bg-card shadow-sm",children:t.jsx("img",{src:j.imgOemHero||jVe,alt:"OEM branding controls",className:"w-full h-auto","data-testid":"img-oem-hero"})})}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("branding.items").map(([_="",A=""],T)=>{const M=UV[T%UV.length];return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4","data-testid":`card-branding-${_}`,children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-amber-500/10 flex items-center justify-center shrink-0",children:t.jsx(M,{className:"w-5 h-5 text-amber-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:_}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:A})]})]},_)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8 bg-muted/30",children:t.jsxs("div",{className:"max-w-6xl mx-auto",children:[t.jsxs("div",{className:"text-center mb-14 space-y-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-amber-500",children:x("hosting.eyebrow")}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("hosting.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:x("hosting.subheading")})]}),t.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:k("hosting.items").map(([_="",A=""],T)=>{const M=zV[T%zV.length];return t.jsxs("div",{className:"bg-card border border-border/50 rounded-xl p-6 flex gap-4","data-testid":`card-hosting-${_}`,children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-amber-500/10 flex items-center justify-center shrink-0",children:t.jsx(M,{className:"w-5 h-5 text-amber-500"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-foreground mb-1",children:_}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:A})]})]},_)})})]})}),t.jsx("section",{className:"py-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6",children:[t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"w-14 h-14 rounded-2xl bg-amber-500/10 flex items-center justify-center",children:t.jsx(xi,{className:"w-7 h-7 text-amber-500"})})}),t.jsx("h2",{className:"text-3xl sm:text-4xl font-bold text-foreground",children:x("cta.heading")}),t.jsx("p",{className:"text-lg text-muted-foreground",children:x("cta.subheading")}),t.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[t.jsx(L,{size:"lg",onClick:()=>n(!0),children:x("cta.primaryButton")}),t.jsx(L,{size:"lg",variant:"outline",onClick:()=>s(!0),children:x("cta.secondaryButton")})]})]})}),t.jsx(_a,{}),e&&t.jsx(sl,{onClose:()=>s(!1)}),t.jsx(Ys,{open:r,onOpenChange:n,children:t.jsxs(Ws,{className:"sm:max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:x("contact.title")}),t.jsx(cr,{children:x("contact.description")})]}),b?t.jsxs("div",{className:"py-6 text-center space-y-3",children:[t.jsx(ar,{className:"w-10 h-10 text-primary mx-auto"}),t.jsx("p",{className:"font-semibold text-foreground",children:x("contact.sentTitle")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:x("contact.sentBody")})]}):t.jsxs("form",{onSubmit:S,className:"space-y-4 pt-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.nameLabel")}),t.jsx(ke,{value:a,onChange:_=>i(_.target.value),required:!0,placeholder:x("contact.namePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.emailLabel")}),t.jsx(ke,{type:"email",value:o,onChange:_=>l(_.target.value),required:!0,placeholder:x("contact.emailPlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.phoneLabel")}),t.jsx(ke,{value:c,onChange:_=>d(_.target.value),placeholder:x("contact.phonePlaceholder")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{children:x("contact.messageLabel")}),t.jsx(Nn,{value:h,onChange:_=>p(_.target.value),placeholder:x("contact.messagePlaceholder"),rows:3})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:g,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),x("contact.sendingButton")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ja,{className:"w-4 h-4 mr-2"}),x("contact.sendButton")]})})]})]})})]})}function qV(){const e=Er(),{t:s}=rn(Ete),r=e.events??[];return t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{}),t.jsxs("main",{children:[t.jsx("section",{className:"pt-32 pb-16 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-5",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-1.5 text-sm font-medium text-primary",children:[t.jsx(nS,{className:"h-4 w-4"}),s("hero.badge")]}),t.jsx("h1",{className:"text-4xl font-bold tracking-tight sm:text-5xl",children:s("hero.heading")}),t.jsx("p",{className:"mx-auto max-w-2xl text-lg leading-relaxed text-muted-foreground",children:s("hero.subheading")})]})}),t.jsx("section",{className:"px-4 pb-24 sm:px-6 lg:px-8",children:t.jsx("div",{className:"mx-auto max-w-6xl",children:r.length===0?t.jsxs("div",{className:"rounded-2xl border border-dashed border-border bg-card/50 px-6 py-16 text-center",children:[t.jsx(nS,{className:"mx-auto mb-4 h-10 w-10 text-primary/70"}),t.jsx("h2",{className:"text-2xl font-semibold",children:s("empty.heading")}),t.jsx("p",{className:"mx-auto mt-2 max-w-md text-muted-foreground",children:s("empty.description")})]}):t.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3","data-testid":"events-grid",children:r.map(n=>t.jsxs("article",{className:"flex h-full flex-col overflow-hidden rounded-2xl border border-border/60 bg-card shadow-sm transition-shadow hover:shadow-lg","data-testid":`event-card-${n.id}`,children:[n.imageUrl?t.jsx("img",{src:n.imageUrl,alt:`Event in ${n.location} on ${n.eventDate}`,className:"aspect-[16/9] w-full object-cover"}):t.jsx("div",{className:"flex aspect-[16/9] w-full items-center justify-center bg-primary/10 text-primary",children:t.jsx(nS,{className:"h-10 w-10"})}),t.jsxs("div",{className:"flex flex-1 flex-col gap-4 p-6",children:[t.jsx("h2",{className:"text-xl font-semibold leading-tight",children:n.eventDate}),t.jsx("div",{className:"space-y-2 text-sm text-muted-foreground",children:t.jsxs("p",{className:"flex items-start gap-2",children:[t.jsx(ql,{className:"mt-0.5 h-4 w-4 shrink-0 text-primary"}),t.jsx("span",{children:n.location})]})}),t.jsx("p",{className:"whitespace-pre-line text-sm leading-relaxed text-foreground
579/80",children:n.description}),n.websiteUrl&&n.websiteTitle?t.jsxs("a",{href:n.websiteUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-auto inline-flex items-center gap-2 text-sm font-medium text-primary hover:underline",children:[n.websiteTitle,t.jsx(op,{className:"h-3.5 w-3.5","aria-hidden":"true"}),t.jsx("span",{className:"sr-only",children:s("card.websiteLinkLabel")})]}):null]})]},n.id))})})})]}),t.jsx(_a,{})]})}const uL="data-managed-head";function Lw(e,s){let r=document.head.querySelector(e);r||(r=document.createElement(e.startsWith("link")?"link":"meta"),r.setAttribute(uL,"1"),document.head.appendChild(r)),Object.entries(s).forEach(([n,a])=>r.setAttribute(n,a))}function VV(){document.head.querySelectorAll(`[${uL}]`).forEach(e=>e.remove())}function moe(e){u.useEffect(()=>{const s=document.title;return document.documentElement.setAttribute("data-page-head","1"),e.title&&(document.title=e.title),VV(),e.description&&Lw('meta[name="description"]',{name:"description",content:e.description}),e.keywords&&Lw('meta[name="keywords"]',{name:"keywords",content:e.keywords}),e.canonical&&Lw('link[rel="canonical"]',{rel:"canonical",href:e.canonical}),e.og&&Object.entries(e.og).forEach(([r,n])=>{n&&Lw(`meta[property="og:${r}"]`,{property:`og:${r}`,content:n})}),e.twitter&&Object.entries(e.twitter).forEach(([r,n])=>{n&&Lw(`meta[name="twitter:${r}"]`,{name:`twitter:${r}`,content:n})}),e.jsonLd&&e.jsonLd.length&&e.jsonLd.forEach((r,n)=>{const a=document.createElement("script");a.type="application/ld+json",a.setAttribute(uL,"1"),a.setAttribute("data-ld-idx",String(n)),a.text=JSON.stringify(r).replace(/</g,"\\u003c"),document.head.appendChild(a)}),()=>{document.documentElement.removeAttribute("data-page-head"),document.title=s,VV()}},[JSON.stringify(e)])}const WV={"Industry News":"bg-blue-500/10 text-blue-400 border-blue-500/20","AI & Analytics":"bg-purple-500/10 text-purple-400 border-purple-500/20","Security Trends":"bg-orange-500/10 text-orange-400 border-orange-500/20","Product Updates":"bg-green-500/10 text-green-400 border-green-500/20","Case Studies":"bg-cyan-500/10 text-cyan-400 border-cyan-500/20"};function NVe(e){return e?new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):""}function KV(){const[,e]=Ia(),s=Er(),{t:r}=rn(nte),{data:n=[],isLoading:a}=ze({queryKey:["/api/blog"]}),i=typeof window<"u"?window.location.origin:"",o=s.appEmblemUrl||`${i}/truvios-emblem.png`,l=`${i}/blog`,c=`${s.productName} Blog — AI Video Surveillance & NVR Management Insights`,d=`Industry news, AI analytics, and security trends on edge video surveillance and NVR management from ${s.productName}.`;return moe({title:c,description:d,canonical:l,og:{type:"website",title:c,description:d,url:l,image:o},twitter:{card:"summary_large_image",title:c,description:d,image:o},jsonLd:[{"@context":"https://schema.org","@type":"Blog",name:`${s.productName} Blog`,url:l,description:d,publisher:{"@type":"Organization",name:s.productName,logo:{"@type":"ImageObject",url:o}},blogPost:n.slice(0,25).map(h=>({"@type":"BlogPosting",headline:h.title,description:h.metaDescription||h.excerpt,url:`${i}/blog/${h.slug}`,datePublished:h.publishedAt?new Date(h.publishedAt).toISOString():void 0,image:h.heroImageUrl?[h.heroImageUrl.startsWith("http")?h.heroImageUrl:i+h.heroImageUrl]:void 0}))},{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:i+"/"},{"@type":"ListItem",position:2,name:"Blog",item:l}]}]}),t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1")}),t.jsx("section",{className:"pt-32 pb-16 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-4",children:[t.jsxs("span",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-sm font-medium bg-primary/10 text-primary border border-primary/20",children:[t.jsx(t0,{className:"w-3.5 h-3.5"}),r("hero.badge")]}),t.jsx("h1",{className:"text-4xl sm:text-5xl font-bold text-foreground",children:r("hero.heading")}),t.jsx("p",{className:"text-xl text-muted-foreground max-w-2xl mx-auto",children:r("hero.subheading")}),t.jsx("div",{className:"pt-2",children:t.jsxs("a",{href:"/blog/rss.xml",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-primary transition-colors","data-testid":"link-rss",children:[t.jsx(t0,{className:"w-3 h-3"})," ",r("hero.rssLink")]})})]})}),t.jsx("section",{className:"pb-24 px-4 sm:px-6 lg:px-8",children:t.jsx("div",{className:"max-w-5xl mx-auto",children:a?t.jsx("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:Array.from({length:6}).map((h,p)=>t.jsxs("div",{className:"space-y-3 p-6 rounded-xl border border-border/50 bg-card",children:[t.jsx(Bt,{className:"h-4 w-20"}),t.jsx(Bt,{className:"h-6 w-full"}),t.jsx(Bt,{className:"h-6 w-4/5"}),t.jsx(Bt,{className:"h-16 w-full"}),t.jsx(Bt,{className:"h-4 w-24"})]},p))}):n.length===0?t.jsxs("div",{className:"text-center py-24 space-y-3",children:[t.jsx(t0,{className:"w-12 h-12 mx-auto text-muted-foreground
579/30"}),t.jsx("p",{className:"text-lg text-muted-foreground",children:r("empty.message")})]}):t.jsx("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:n.map(h=>t.jsxs("article",{className:"group flex flex-col rounded-xl border border-border/50 bg-card hover:border-primary/30 hover:bg-card/80 transition-all cursor-pointer overflow-hidden",onClick:()=>e(`/blog/${h.slug}`),"data-testid":`card-blog-${h.id}`,children:[h.heroImageUrl&&t.jsx("div",{className:"aspect-video w-full overflow-hidden bg-muted",children:t.jsx("img",{src:h.heroImageUrl,alt:h.heroImageAlt||h.title,loading:"lazy",referrerPolicy:"no-referrer",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",onError:p=>{p.currentTarget.parentElement.style.display="none"}})}),t.jsxs("div",{className:"flex flex-col p-6 flex-1",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("span",{className:`text-xs font-medium px-2.5 py-0.5 rounded-full border ${WV[h.category]||WV["Industry News"]}`,children:h.category}),t.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(ro,{className:"w-3 h-3"}),NVe(h.publishedAt)]})]}),t.jsx("h2",{className:"text-base font-semibold text-foreground leading-snug mb-2 group-hover:text-primary transition-colors line-clamp-3",children:h.title}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed flex-1 line-clamp-3",children:h.excerpt}),t.jsxs("div",{className:"flex items-center gap-1 mt-4 text-sm font-medium text-primary",children:[r("card.readMore")," ",t.jsx(N0,{className:"w-3.5 h-3.5 group-hover:translate-x-0.5 transition-transform"})]})]})]},h.id))})})}),t.jsx(_a,{})]})}const Z1={"Industry News":"bg-blue-500/10 text-blue-400 border-blue-500/20","AI & Analytics":"bg-purple-500/10 text-purple-400 border-purple-500/20","Security Trends":"bg-orange-500/10 text-orange-400 border-orange-500/20","Product Updates":"bg-green-500/10 text-green-400 border-green-500/20","Case Studies":"bg-cyan-500/10 text-cyan-400 border-cyan-500/20"};function SVe(e){return e?new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):""}function GV(){const{slug:e}=Ek(),[,s]=Ia(),r=Er(),{t:n}=rn(ate),{data:a,isLoading:i,isError:o}=ze({queryKey:["/api/blog",e],queryFn:async()=>{const w=await fetch(`/api/blog/${e}`);if(!w.ok)throw new Error("Not found");return w.json()}}),{data:l=[]}=ze({queryKey:["/api/blog"]}),c=a?l.filter(w=>w.id!==a.id).sort((w,j)=>{const x=C=>C.category===a.category?-1:0;return x(w)-x(j)}).slice(0,3):[],d=typeof window<"u"?window.location.origin:"",h=a?`${d}/blog/${a.slug}`:d,p=r.appEmblemUrl||`${d}/truvios-emblem.png`,g=a?.heroImageUrl?a.heroImageUrl.startsWith("http")?a.heroImageUrl:d+a.heroImageUrl:p,v=a?a.seoTitle||`${a.title} | ${r.productName}`:`${r.productName} Blog`,b=a?a.metaDescription||a.excerpt:"",y=a?.keywords?.join(", ")||"";return moe({title:v,description:b,canonical:h,keywords:y,og:{type:"article",title:v,description:b,url:h,image:g},twitter:{card:"summary_large_image",title:v,description:b,image:g},jsonLd:a?[{"@context":"https://schema.org","@type":"Article",headline:a.title,de
579scription:b,image:g?[g]:void 0,datePublished:a.publishedAt?new Date(a.publishedAt).toISOString():void 0,dateModified:a.updatedAt?new Date(a.updatedAt).toISOString():void 0,author:{"@type":"Organization",name:r.productName},publisher:{"@type":"Organization",name:r.productName,logo:{"@type":"ImageObject",url:p}},mainEntityOfPage:{"@type":"WebPage","@id":h},articleSection:a.category,keywords:y||void 0},{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Home",item:d+"/"},{"@type":"ListItem",position:2,name:"Blog",item:d+"/blog"},{"@type":"ListItem",position:3,name:a.title,item:h}]},...a.faqJson&&a.faqJson.length?[{"@context":"https://schema.org","@type":"FAQPage",mainEntity:a.faqJson.map(w=>({"@type":"Question",name:w.q,acceptedAnswer:{"@type":"Answer",text:w.a}}))}]:[]]:[]}),t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1")}),t.jsx("article",{className:"pt-32 pb-24 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-3xl mx-auto",children:[t.jsxs("nav",{className:"mb-4 text-xs text-muted-foreground flex items-center gap-1.5 flex-wrap","aria-label":"Breadcrumb",children:[t.jsx(Rx,{href:"/",className:"hover:text-foreground",children:n("breadcrumb.home")}),t.jsx(hi,{className:"w-3 h-3"}),t.jsx(Rx,{href:"/blog",className:"hover:text-foreground",children:n("breadcrumb.blog")}),a&&t.jsxs(t.Fragment,{children:[t.jsx(hi,{className:"w-3 h-3"}),t.jsx("span",{className:"text-foreground line-clamp-1",children:a.title})]})]}),t.jsxs(L,{variant:"ghost",size:"sm",className:"mb-8 -ml-1 text-muted-foreground hover:text-foreground",onClick:()=>s("/blog"),"data-testid":"button-back-to-blog",children:[t.jsx(Wi,{className:"w-4 h-4 mr-1"})," ",n("backButton")]}),i?t.jsxs("div",{className:"space-y-4",children:[t.jsx(Bt,{className:"h-5 w-24"}),t.jsx(Bt,{className:"h-10 w-full"}),t.jsx(Bt,{className:"h-10 w-3/4"}),t.jsx(Bt,{className:"h-4 w-32"}),t.jsx("div",{className:"space-y-3 pt-6",children:Array.from({length:8}).map((w,j)=>t.jsx(Bt,{className:"h-4 w-full"},j))})]}):o||!a?t.jsxs("div",{className:"text-center py-24 space-y-4",children:[t.jsx("p",{className:"text-lg text-muted-foreground",children:n("notFound.message")}),t.jsx(L,{onClick:()=>s("/blog"),children:n("notFound.button")})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("span",{className:`text-xs font-medium px-2.5 py-0.5 rounded-full border ${Z1[a.category]||Z1["Industry News"]}`,children:a.category}),t.jsxs("span",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[t.jsx(ro,{className:"w-3.5 h-3.5"}),SVe(a.publishedAt)]})]}),t.jsx("h1",{className:"text-3xl sm:text-4xl font-bold text-foreground leading-tight mb-4",children:a.title}),a.heroImageUrl&&t.jsx("div",{className:"aspect-video w-full overflow-hidden rounded-xl border border-border/50 bg-muted mb-6",children:t.jsx("img",{src:a.heroImageUrl,alt:a.heroImageAlt||a.title,referrerPolicy:"no-referrer",className:"w-full h-full object-cover",onError:w=>{w.currentTarget.parentElement.style.display="none"}})}),t.jsx("p",{className:"text-lg text-muted-foreground leading-relaxed mb-8 border-l-4 border-primary/30 pl-4",children:a.excerpt}),t.jsx("div",{className:`prose prose-invert prose-sm sm:prose max-w-none
580                  prose-headings:text-foreground prose-headings:font-semibold
581                  prose-p:text-muted-foreground prose-p:leading-relaxed
582                  prose-li:text-muted-foreground
583                  prose-h2:text-2xl prose-h2:mt-8 prose-h2:mb-3
584                  prose-h3:text-lg prose-h3:mt-6 prose-h3:mb-2
585                  prose-a:text-primary prose-a:no-underline hover:prose-a:underline
586                  prose-strong:text-foreground
587                  prose-ul:my-3 prose-li:my-0.5`,dangerouslySetInnerHTML:{__html:a.content}}),a.faqJson&&a.faqJson.length>0&&t.jsxs("section",{className:"mt-12 pt-8 border-t border-border/50","data-testid":"section-faq",children:[t.jsx("h2",{className:"text-2xl font-semibold text-foreground mb-6",children:n("faq.heading")}),t.jsx("div",{className:"space-y-5",children:a.faqJson.map((w,j)=>t.jsxs("div",{className:"space-y-1.5","data-testid":`faq-item-${j}`,children:[t.jsx("h3",{className:"text-base font-semibold text-foreground",children:w.q}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:w.a})]},j))})]}),a.sourceUrl&&t.jsxs("div",{className:"mt-10 pt-6 border-t border-border/50",children:[t.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:n("source.label")}),t.jsxs("a",{href:a.sourceUrl,target:"_blank",rel:"noopener noreferrer nofollow",className:"inline-flex items-center gap-1.5 text-sm text-primary hover:underline","data-testid":"link-source",children:[a.sourceTitle||a.sourceUrl,t.jsx(op,{className:"w-3 h-3"})]})]}),c.length>0&&t.jsxs("section",{className:"mt-16 pt-10 border-t border-border/50","data-testid":"section-related",children:[t.jsx("h2",{className:"text-xl font-semibold text-foreground mb-6",children:n("related.heading")}),t.jsx("div",{className:"grid gap-4 sm:grid-cols-3",children:c.map(w=>t.jsxs(Rx,{href:`/blog/${w.slug}`,className:"group block rounded-lg border border-border/50 bg-card hover:border-primary/30 hover:bg-card/80 transition-all overflow-hidden","data-testid":`link-related-${w.id}`,children:[w.heroImageUrl&&t.jsx("div",{className:"aspect-video w-full overflow-hidden bg-muted",children:t.jsx("img",{src:w.heroImageUrl,alt:w.heroImageAlt||w.title,loading:"lazy",referrerPolicy:"no-referrer",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",onError:j=>{j.currentTarget.parentElement.style.display="none"}})}),t.jsxs("div",{className:"p-3",children:[t.jsx("span",{className:`inline-block text-[10px] font-medium px-2 py-0.5 rounded-full border mb-1.5 ${Z1[w.category]||Z1["Industry News"]}
587`,children:w.category}),t.jsx("h3",{className:"text-sm font-semibold text-foreground line-clamp-2 group-hover:text-primary transition-colors",children:w.title})]})]},w.id))})]})]})]})}),t.jsx(_a,{})]})}const YV=[{chapterIds:["login","menu","dashboard-overview","dashboard-main","dashboard-search"],nums:[1,2,3,4,5]},{chapterIds:["events","events-basics","player","mass-export"],nums:[6,7,8,9]},{chapterIds:["live","live-functions","custom-layouts","streaming"],nums:[10,11,12,13]},{chapterIds:["pulse","pulse-basics","device-management","ip-camera-functions"],nums:[14,15,16,17]},{chapterIds:["companies","manage-companies","dealer-info"],nums:[18,19,20]},{chapterIds:["user-roles","change-login","change-password","manage-users"],nums:[21,22,23,24]},{chapterIds:["device-config","device-name","cloud-storage","backup-frequency","alert-notifications","network-storage","device-info","advanced-settings","activation-status"],nums:[25,26,27,28,29,30,31,32,33]},{chapterIds:["local-settings","preferences","database-servers","stored-credentials"],nums:[34,35,36,37]},{chapterIds:["error-codes"],nums:[38]},{chapterIds:["remote-reboot","teamviewer"],nums:[39,40]}],CVe=["search.png","play.png","pause.png","loop2.png","nextevent2.png","mode.png","decrease.png","increase.png","snap.png","download.png"],kVe=["refresh.png","pref.png","active-on.png","deactive.png","update.png"];function _Ve(e,s){const r=[],n=/\*\*(.+?)\*\*|`(.+?)`/g;let a=0,i,o=0;for(;(i=n.exec(e))!==null;)i.index>a&&r.push(e.slice(a,i.index)),i[1]!==void 0?r.push(t.jsx("strong",{children:i[1]},`${s}-b${o}`)):r.push(t.jsx("code",{className:"text-xs bg-muted px-1 rounded",children:i[2]},`${s}-c${o}`)),a=n.lastIndex,o++;return a<e.length&&r.push(e.slice(a)),r}function vt({children:e}){return t.jsx(t.Fragment,{children:_Ve(e,"r")})}function qs({src:e,alt:s}){return t.jsx("img",{src:`/blu-docs/images/${e}`,alt:s??e,className:"my-4 rounded-lg border border-border/50 max-w-full shadow-sm",loading:"lazy"})}function zu({children:e}){const{t:s}=rn(oN);return t.jsxs("div",{className:"my-4 rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-sm text-foreground/90",children:[t.jsx("span",{className:"font-semibold text-primary",children:s("box.importantLabel")}),e]})}function PVe({children:e}){const{t:s}=rn(oN);return t.jsxs("div",{className:"my-4 rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-foreground/90",children:[t.jsx("span",{className:"font-semibold text-amber-500",children:s("box.warningLabel")}),e]})}function QV({children:e}){const{t:s}=rn(oN);return t.jsxs("div",{className:"my-4 rounded-lg border border-blue-500/30 bg-blue-500/5 px-4 py-3 text-sm text-foreground/90",children:[t.jsx("span",{className:"font-semibold text-blue-400",children:s("box.noticeLabel")}),e]})}function Fn({id:e,num:s,title:r,children:n}){return t.jsxs("section",{id:e,className:"scroll-mt-24 py-10 border-b border-border/30 last:border-0",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[t.jsx("span",{className:"shrink-0 w-8 h-8 rounded-full bg-primary/15 text-primary text-sm font-bold flex items-center justify-center mt-0.5",children:s}),t.jsx("h2",{className:"text-xl font-bold text-foreground leading-tight",children:r})]}),t.jsx("div",{className:"prose-sm leading-relaxed text-foreground/85 space-y-3 ml-11",children:n})]})}function XV(){const e=Er(),{t:s,tLines:r,tParts:n}=rn(oN),a=r("sections.labels"),i=r("chapters.titles"),o=w=>i[w-1]??"",l=YV.map((w,j)=>({label:a[j]??"",chapters:w.chapterIds.map((x,C)=>({id:x,num:w.nums[C],title:o(w.nums[C])}))})),[c,d]=u.useState("login"),[h,p]=u.useState(Object.fromEntries(YV.map((w,j)=>[a[j]??"",!0]))),[g,v]=u.useState(!1);u.useEffect(()=>{const w=new IntersectionObserver(j=>{j.forEach(x=>{x.isIntersecting&&d(x.target.id)})},{rootMargin:"-80px 0px -70% 0px"});return l.flatMap(j=>j.chapters).forEach(j=>{const x=document.getElementById(j.id);x&&w.observe(x)}),()=>w.disconnect()},[]);function b(w){document.getElementById(w)?.scrollIntoView({behavior:"smooth",block:"start"}),v(!1)}function y(w){p(j=>({...j,[w]:!j[w]}))}return l.flatMap(w=>w.chapters.map(j=>({...j,section:w.label}))),t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1")}),t.jsx("div",{className:"lg:hidden fixed bottom-4 right-4 z-50",children:t.jsx("button",{onClick:()=>v(w=>!w),className:"w-12 h-12 rounded-full bg-primary text-primary-foreground shadow-lg flex items-center justify-center",children:g?t.jsx(va,{className:"w-5 h-5"}):t.jsx(FK,{className:"w-5 h-5"})})}),g&&t.jsxs("div",{className:"lg:hidden fixed inset-0 z-40 bg-background/95 backdrop-blur-md pt-20 pb-6 px-4 overflow-y-auto",children:[t.jsx("h3",{className:"font-bold text-sm uppercase tracking-wider text-muted-foreground mb-4",children:s("toc.title")}),l.map(w=>t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground
587/70 mb-1 mt-3",children:w.label}),w.chapters.map(j=>t.jsxs("button",{onClick:()=>b(j.id),className:`w-full text-left text-sm px-2 py-1.5 rounded-md transition-colors ${c===j.id?"bg-primary/10 text-primary font-medium":"text-foreground/70 hover:text-foreground hover:bg-muted/50"}`,children:[t.jsxs("span",{className:"text-muted-foreground/50 mr-2",children:[String(j.num).padStart(2,"0"),"."]}),j.title]},j.id))]},w.label))]}),t.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-24 pb-16 flex gap-8",children:[t.jsx("aside",{className:"hidden lg:block w-64 shrink-0",children:t.jsxs("div",{className:"sticky top-20 max-h-[calc(100vh-6rem)] overflow-y-auto rounded-xl border border-border/50 bg-muted/10 p-4",children:[t.jsxs("div",{className:"mb-3",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:s("sidebar.manualLabel")}),t.jsx("p",{className:"text-[11px] text-muted-foreground/60 mt-0.5",children:s("sidebar.manualSubtitle")})]}),l.map(w=>t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{onClick:()=>y(w.label),className:"w-full flex items-center justify-between text-left py-1.5 px-2 rounded-md text-xs font-semibold uppercase tracking-wider text-muted-foreground/70 hover:text-foreground hover:bg-muted/50 transition-colors",children:[w.label,h[w.label]?t.jsx(Xa,{className:"w-3 h-3"}):t.jsx(hi,{className:"w-3 h-3"})]}),h[w.label]&&w.chapters.map(j=>t.jsxs("button",{onClick:()=>b(j.id),className:`w-full text-left text-xs px-3 py-1 rounded-md transition-colors ${c===j.id?"bg-primary/10 text-primary font-medium":"text-foreground/60 hover:text-foreground hover:bg-muted/50"}`,children:[t.jsxs("span",{className:"text-muted-foreground/40 mr-1",children:[String(j.num).padStart(2,"0"),"."]}),j.title]},j.id))]},w.label))]})}),t.jsxs("main",{className:"flex-1 min-w-0 max-w-3xl",children:[t.jsxs("div",{className:"mb-10 pb-8 border-b border-border/40",children:[t.jsx("span",{className:"inline-block px-3 py-1 rounded-full text-xs font-medium bg-primary/10 text-primary mb-3",children:s("hero.badge")}),t.jsx("h1",{className:"text-3xl sm:text-4xl font-bold text-foreground leading-tight mb-3",children:s("hero.heading")}),t.jsx("p",{className:"text-muted-foreground leading-relaxed",children:s("hero.subheading")}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[s("hero.helpPrefix")," ",t.jsx("a",{href:`mailto:${e.supportEmail}`,className:"text-primary hover:underline",children:e.supportEmail})]})]}),t.jsxs(Fn,{id:"login",num:1,title:o(1),children:[t.jsx(qs,{src:"login_1.png",alt:"Login screen"}),t.jsx("p",{children:t.jsx(vt,{children:s("s1.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s1.p2")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s1.p3")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s1.p4")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s1.p5")})}),t.jsx(zu,{children:t.jsx(vt,{children:s("s1.box1")})})]}),t.jsxs(Fn,{id:"menu",num:2,title:o(2),children:[t.jsx(qs,{src:"menu_1.png",alt:"Main navigational menu"}),t.jsx("p",{children:t.jsx(vt,{children:s("s2.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s2.p2")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s2.p3")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s2.p4")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s2.p5")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s2.p6")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s2.p7")})})]}),t.jsxs(Fn,{id:"dashboard-overview",num:3,title:o(3),children:[t.jsx(qs,{src:"dashboard_1.png",alt:"Dashboard overview"}),t.jsx("p",{children:t.jsx(vt,{children:s("s3.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s3.p2")})}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s3.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))}),t.jsx("p",{children:t.jsx(vt,{children:s("s3.p3")})}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s3.list2").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))})]}),t.jsxs(Fn,{id:"dashboard-main",num:4,title:o(4),children:[t.jsx(qs,{src:"dashboard_2.png",alt:"Dashboard main section"}),t.jsx("p",{children:t.jsx(vt,{children:s("s4.p1")})}),t.jsx(qs,{src:"dashboard_8.png",alt:"Dashboard pop-up menu"}),t.jsx("p",{children:t.jsx(vt,{children:s("s4.p2")})}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:"/blu-docs/images/dashboard_3.png",alt:"Online",className:"h-8"}),t.jsx("span",{children:t.jsx(vt,{children:s("s4.row1")})})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:"/blu-docs/images/dashboard_4.png",alt:"Online not backing up",className:"h-8"}),t.jsx("span",{children:t.jsx(vt,{children:s("s4.row2")})})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:"/blu-docs/images/dashboard_5.png",alt:"Offline",className:"h-8"}),t.jsx("span",{children:t.jsx(vt,{children:s("s4.row3")})})]})]}),t.jsx("p",{className:"mt-3",children:t.jsx(vt,{children:s("s4.p3")})}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s4.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))}),t.jsx("p",{children:t.jsx(vt,{children:s("s4.p4")})}),t.jsx(qs,{src:"dashboard_6.png",alt:"Bridge bar"}),t.jsx("p",{children:t.jsx(vt,{children:s("s4.p5")})})]}),t.jsxs(Fn,{id:"dashboard-search",num:5,title:o(5),children:[t.jsx(qs,{src:"dashboard_9.png",alt:"Dashboard search"}),t.jsx("p",{children:t.jsx(vt,{children:s("s5.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s5.p2")})}),t.jsx(qs,{src:"dashboard_10.png",alt:"Dashboard scrolling"}),t.jsx("p",{children:t.jsx(vt,{children:s("s5.p3")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s5.p4")})}),t.jsx(qs,{src:"dashboard_11.png",alt:"Quick sorting"}),t.jsx("p",{children:t.jsx(vt,{children:s("s5.p5")})})]}),t.jsxs(Fn,{id:"events",num:6,title:o(6),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s6.p1")})}),t.jsx(qs,{src:"dbicon.png",alt:"Bridge icon"}),t.jsx("p",{children:t.jsx(vt,{children:s("s6.p2")})}),t.jsx(qs,{src:"dashboard_8.PNG",alt:"Select event retrieval"}),t.jsx("p",{children:t.jsx(vt,{children:s("s6.p3")})}),t.jsx(qs,{src:"rp.png",alt:"Event search"}),t.jsx("p",{children:t.jsx(vt,{children:s("s6.p4")}
587)}),t.jsx(qs,{src:"rp2.png",alt:"Select event"}),t.jsx(zu,{children:t.jsx(vt,{children:s("s6.box1")})})]}),t.jsxs(Fn,{id:"events-basics",num:7,title:o(7),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s7.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s7.p2")})}),t.jsx(qs,{src:"events_2.png",alt:"Calendar controls"}),t.jsx("p",{children:t.jsx(vt,{children:s("s7.p3")})}),t.jsx(qs,{src:"events_3.PNG",alt:"Year navigation"}),t.jsx("p",{children:t.jsx(vt,{children:s("s7.p4")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s7.p5")})}),t.jsx(qs,{src:"events_4.png",alt:"Camera events"}),t.jsx(qs,{src:"events_6.png",alt:"Event list"}),t.jsx("p",{children:t.jsx(vt,{children:s("s7.p6")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s7.p7")})}),t.jsx(qs,{src:"events_7.png",alt:"Rename camera"}),t.jsx(zu,{children:t.jsx(vt,{children:s("s7.box1")})})]}),t.jsxs(Fn,{id:"player",num:8,title:o(8),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s8.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s8.p2")})}),t.jsx(qs,{src:"events_8.png",alt:"Event player"}),t.jsx("div",{className:"space-y-2",children:n("player.functions").map(([w="",j=""],x)=>{const C=CVe[x];return t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("img",{src:`/blu-docs/images/${C}`,alt:w,className:"h-6 w-auto mt-0.5 shrink-0"}),t.jsxs("span",{children:[t.jsxs("strong",{children:[w,":"]})," ",j]})]},C)})})]}),t.jsxs(Fn,{id:"mass-export",num:9,title:o(9),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s9.p1")})}),t.jsx(qs,{src:"events_13.png",alt:"Export events search"}),t.jsx("p",{children:t.jsx(vt,{children:s("s9.p2")})}),t.jsx(qs,{src:"events_14.png",alt:"Export options"}),t.jsx("ul",{className:"list-disc pl-5 space-y-2",children:r("s9.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))})]}),t.jsxs(Fn,{id:"live",num:10,title:o(10),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s10.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s10.p2")})}),t.jsx(qs,{src:"live_1.png",alt:"Live view launch"}),t.jsx("p",{children:t.jsx(vt,{children:s("s10.p3")})}),t.jsx(qs,{src:"dashboard_8.PNG",alt:"Select live view"}),t.jsx(zu,{children:t.jsx(vt,{children:s("s10.box1")})})]}),t.jsxs(Fn,{id:"live-functions",num:11,title:o(11),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s11.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s11.p2")})}),t.jsx(qs,{src:"live_2.png",alt:"Quick view layout"}),t.jsx("p",{children:t.jsx(vt,{children:s("s11.p3")})}),t.jsx(qs,{src:"live_3.png",alt:"Full live view layout"}),t.jsx("p",{children:t.jsx(vt,{children:s("s11.p4")})}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:"/blu-docs/images/cam-white.png",alt:"White camera",className:"h-6"}),t.jsx("span",{children:t.jsx(vt,{children:s("s11.row1")})})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:"/blu-docs/images/cam-blue.png",alt:"Blue camera",className:"h-6"}),t.jsx("span",{children:t.jsx(vt,{children:s("s11.row2")})})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:"/blu-docs/images/cam-grey.png",alt:"Grey camera",className:"h-6"}),t.jsx("span",{children:t.jsx(vt,{children:s("s11.row3")})})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("img",{src:"/blu-docs/images/loop2-b.png",alt:"Loop groups",className:"h-6"}),t.jsx("span",{children:t.jsx(vt,{children:s("s11.row4")})})]})]}),t.jsx("p",{children:t.jsx(vt,{children:s("s11.p5")})}),t.jsx(qs,{src:"live_4.PNG",alt:"Camera stream hover icons"})]}),t.jsxs(Fn,{id:"custom-layouts",num:12,title:o(12),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s12.p1")})}),t.jsx(qs,{src:"live_8.png",alt:"Layout manager"}),t.jsx("p",{children:t.jsx(vt,{children:s("s12.p2")})}),t.jsxs("ol",{className:"list-decimal pl-5 space-y-2",children:[t.jsx("li",{children:t.jsx(vt,{children:s("s12.li1")})}),t.jsx("li",{children:t.jsx(vt,{children:s("s12.li2")})}),t.jsx(qs,{src:"live_10.png",alt:"Create new layout"}),t.jsx("li",{children:t.jsx(vt,{children:s("s12.li3")})}),t.jsx(qs,{src:"live_11.png",alt:"Choose cameras"}),t.jsx("li",{children:t.jsx(vt,{children:s("s12.li4")})}),t.jsx(qs,{src:"live_12.png",alt:"Layout name"}),t.jsx("li",{children:t.jsx(vt,{children:s("s12.li5")})}),t.jsx(qs,{src:"live_13.png",alt:"Load at start"}),t.jsx("li",{children:t.jsx(vt,{children:s("s12.li6")})}),t.jsx(qs,{src:"live_14.png",alt:"Save layout"})]}),t.jsx("p",{children:t.jsx(vt,{children:s("s12.p3")})}),t.jsxs("ol",{className:"list-decimal pl-5 space-y-2",children:[t.jsx("li",{children:t.jsx(vt,{children:s("s12.li7")})}),t.jsx(qs,{src:"live_15.png",alt:"Select layout to delete"}),t.jsx("li",{children:t.jsx(vt,{children:s("s12.li8")})})]}),t.jsx(zu,{children:t.jsx(vt,{children:s("s12.box1")})})]}),t.jsxs(Fn,{id:"streaming",num:13,title:o(13),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s13.p1")})}),t.jsx(qs,{src:"live_16.png",alt:"Stream settings"}),t.jsx("p",{children:t.jsx(vt,{children:s("s13.p2")})}),t.jsx(qs,{src:"live_17.png",alt:"Streaming priority"}),t.jsx("ul",{className:"list-disc pl-5 space-y-2",children:r("s13.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))}),t.jsx("p",{children:t.jsx(vt,{children:s("s13.p3")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s13.p4")})}
587),t.jsx("p",{children:t.jsx(vt,{children:s("s13.p5")})})]}),t.jsxs(Fn,{id:"pulse",num:14,title:o(14),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s14.p1")})}),t.jsx(qs,{src:"pulse_2.png",alt:"Pulse monitoring"}),t.jsx("p",{children:t.jsx(vt,{children:s("s14.p2")})}),t.jsxs("ol",{className:"list-decimal pl-5 space-y-2",children:[t.jsx("li",{children:t.jsx(vt,{children:s("s14.li1")})}),t.jsx(qs,{src:"pulse.png",alt:"Launch from menu"}),t.jsx("li",{children:t.jsx(vt,{children:s("s14.li2")})}),t.jsx(qs,{src:"dbicon.png",alt:"Bridge icon"})]}),t.jsx(zu,{children:t.jsx(vt,{children:s("s14.box1")})})]}),t.jsxs(Fn,{id:"pulse-basics",num:15,title:o(15),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s15.p1")})}),t.jsx("div",{className:"space-y-2",children:n("pulse.topMenuIcons").map(([w="",j=""],x)=>{const C=kVe[x];return t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("img",{src:`/blu-docs/images/${C}`,alt:w,className:"h-6 w-auto mt-0.5 shrink-0"}),t.jsxs("span",{children:[t.jsxs("strong",{children:[w,":"]})," ",j]})]},C)})}),t.jsx(qs,{src:"pulse_3.png",alt:"Pulse list"}),t.jsx("p",{children:t.jsx(vt,{children:s("s15.p2")})}),t.jsx(qs,{src:"pulse_4.png",alt:"Pulse preferences"}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s15.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))})]}),t.jsxs(Fn,{id:"device-management",num:16,title:o(16),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s16.p1")})}),t.jsx(qs,{src:"pulse_5.png",alt:"Device pop-up"}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s16.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))}),t.jsx("p",{children:t.jsx(vt,{children:s("s16.p2")})}),t.jsx(qs,{src:"pulse_6.png",alt:"Add/edit device"}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s16.list2").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))})]}),t.jsxs(Fn,{id:"ip-camera-functions",num:17,title:o(17),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s17.p1")})}),t.jsx(qs,{src:"pulse_8.png",alt:"IP camera functions menu"}),t.jsx("p",{children:t.jsx(vt,{children:s("s17.p2")})}),t.jsx(qs,{src:"pulse_9.png",alt:"Export CSV"}),t.jsx("p",{children:t.jsx(vt,{children:s("s17.p3")})}),t.jsx(qs,{src:"pulse_10.png",alt:"Batch import"}),t.jsx("p",{children:t.jsx(vt,{children:s("s17.p4")})}),t.jsx(qs,{src:"pulse_11.png",alt:"CSV import"}),t.jsx("p",{children:t.jsx(vt,{children:s("s17.p5")})}),t.jsxs("div",{className:"flex items-start gap-3 mt-2",children:[t.jsx("img",{src:"/blu-docs/images/update.png",alt:"Update",className:"h-6 shrink-0 mt-0.5"}),t.jsx("span",{children:t.jsx(vt,{children:s("s17.row1")})})]})]}),t.jsxs(Fn,{id:"companies",num:18,title:o(18),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s18.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s18.p2")})}),t.jsx(qs,{src:"companies_1.png",alt:"Companies management"}),t.jsx("p",{children:t.jsx(vt,{children:s("s18.p3")})}),t.jsx(qs,{src:"companies_2.png",alt:"Assign company to user"}),t.jsx("p",{children:t.jsx(vt,{children:s("s18.p4")})}),t.jsx(qs,{src:"companies_3.png",alt:"Assign company to device"}),t.jsx(zu,{children:t.jsx(vt,{children:s("s18.box1")})})]}),t.jsxs(Fn,{id:"manage-companies",num:19,title:o(19),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s19.p1")})}),t.jsx(qs,{src:"companies_4.png",alt:"Manage companies"}),t.jsx("p",{children:t.jsx(vt,{children:s("s19.p2")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s19.p3")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s19.p4")})})]}),t.jsxs(Fn,{id:"dealer-info",num:20,title:o(20),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s20.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s20.p2")})})]}),t.jsxs(Fn,{id:"user-roles",num:21,title:o(21),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s21.p1")})}),t.jsx(qs,{src:"users.png",alt:"User roles"}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("p",{children:t.jsx(vt,{children:s("s21.p2")})}),t.jsx(PVe,{children:t.jsx(vt,{children:s("s21.box1")})})]}),t.jsxs("div",{children:[t.jsx("p",{children:t.jsx(vt,{children:s("s21.p3")})}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s21.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))})]}),t.jsx("div",{children:t.jsx("p",{children:t.jsx(vt,{children:s("s21.p4")})})}),t.jsx("div",{children:t.jsx("p",{children:t.jsx(vt,{children:s("s21.p5")})})})]})]}),t.jsxs(Fn,{id:"change-login",num:22,title:o(22),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s22.p1")})}),t.jsx(qs,{src:"users_4.png",alt:"Change login"}),t.jsx("p",{children:t.jsx(vt,{children:s("s22.p2")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s22.p3")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s22.p4")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s22.p5")})}),t.jsx(qs,{src:"users_7.png",alt:"2FA login"}),t.jsx(qs,{src:"users_5.png",alt:"Enter 2FA code"})]}),t.jsxs(Fn,{id:"change-password",num:23,title:o(23),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s23.p1")})}),t.jsx(qs,{src:"users_8.png",alt:"Change password"}),t.jsx("p",{children:t.jsx(vt,{children:s("s23.p2")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s23.p3")})}),t.jsx(qs,{src:"users_9.png",alt:"Forgot password"}),t.jsx(qs,{src:"users_10.png",alt:"Reset password"}),t.jsx(zu,{children:t.jsx(vt,{children:s("s23.box1")})})]}),t.jsxs(Fn,{id:"manage-users",num:24,title:o(24),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s24.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s24.p2")})}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s24.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))}),t.jsx(qs,{src:"users_11.png",alt:"New user instructions email"}),t.jsx("p",{children:t.jsx(vt,{children:s("s24.p3")})}),t.jsx(qs,{src:"users_13.png",alt:"Edit user dropdown"}),t.jsx("p",{children:t.jsx(vt,{children:s("s24.p4")})})]}),t.jsxs(Fn,{id:"device-config",num:25,title:o(25),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s25.p1")})}),t.jsx(qs,{src:"dbicon.png",alt:"Bridge icon"}),t.jsx(qs,{src:"dashboard_8.PNG",alt:"Select device config"}),t.jsx("p",{children:t.jsx(vt,{children:s("s25.p2")})}),t.jsx(qs,{src:"devices.png",alt:"Device configuration menu"}),t.jsx(zu,{children:t.jsx(vt,{children:s("s25.box1")})})]}),t.jsxs(Fn,{id:"device-name",num:26,title:o(26),children:[t.jsx(qs,{src:"devices_2.png",alt:"Device name and company"}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s26.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))}),t.jsx("p",{children:t.jsx(vt,{children:s("s26.p1")})})]}),t.jsxs(Fn,{id:"cloud-storage",num:27,title:o(27),children:[t.jsx(qs,{src:"devices_3.png",alt:"Cloud storage settings"}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s27.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))}),t.jsx(QV,{children:t.jsx(vt,{children:s("s27.box1")})})]}),t.jsxs(Fn,{id:"backup-frequency",num:28,title:o(28),children:[t.jsx(qs,{src:"devices_4.png",alt:"Backup frequency"}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s28.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))}),t.jsx(QV,{children:t.jsx(vt,{children:s("s28.box1")})})]}),t.jsxs(Fn,{id:"alert-notifications",num:29,title:o(29),children:[t.jsx(qs,{src:"devices_5.png",alt:"Alert notifications"}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s29.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))})]}),t.jsxs(Fn,{id:"network-storage",num:30,title:o(30),children:[t.jsx(qs,{src:"devices_6.png",alt:"Network and storage"}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s30.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))})]}),t.jsxs(Fn,{id:"device-info",num:31,title:o(31),children:[t.jsx(qs,{src:"devices_7.png",alt:"Device info"}),t.jsx("p",{children:t.jsx(vt,{children:s("s31.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s31.p2")})})]}),t.jsxs(Fn,{id:"advanced-settings",num:32,title:o(32),children:[t.jsx(qs,{src:"devices_8.png",alt:"Advanced settings"}),t.jsx("p",{children:t.jsx(vt,{children:s("s32.p1")})})]}),t.jsxs(Fn,{id:"activation-status",num:33,title:o(33),children:[t.jsx(qs,{src:"devices_9.png",alt:"Activation status"}),t.jsx("ul",{className:"list-disc pl-5 space-y-2",children:r("s33.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))})]}),t.jsxs(Fn,{id:"local-settings",num:34,title:o(34),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s34.p1")})}),t.jsx(qs,{src:"local_1.png",alt:"Local settings menu"}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s34.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))}),t.jsx(zu,{children:t.jsx(vt,{children:s("s34.box1")})})]}),t.jsxs(Fn,{id:"preferences",num:35,title:o(35),children:[t.jsx(qs,{src:"local_2.png",alt:"Preferences"}),t.jsx("p",{children:t.jsx(vt,{children:s("s35.p1")})}),t.jsx("ul",{className:"list-disc pl-5 space-y-1",children:r("s35.list1").map((w,j)=>t.jsx("li",{children:t.jsx(vt,{children:w})},j))})]}),t.jsxs(Fn,{id:"database-servers",num:36,title:o(36),children:[t.jsx(qs,{src:"local_3.png",alt:"Database servers"}),t.jsx("p",{children:t.jsx(vt,{children:s("s36.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s36.p2")})})]}),t.jsxs(Fn,{id:"stored-credentials",num:37,title:o(37),children:[t.jsx(qs,{src:"local_4.png",alt:"Stored credentials"}),t.jsx("p",{children:t.jsx(vt,{children:s("s37.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s37.p2")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s37.p3")})}),t.jsx(zu,{children:t.jsx(vt,{children:s("s37.box1")})})]}),t.jsxs(Fn,{id:"error-codes",num:38,title:o(38),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s38.p1")})}),t.jsx(qs,{src:"error.png",alt:"Error display"}),t.jsx("div",{className:"space-y-3",children:n("errorCodes.items").map(([w="",j="",...x])=>t.jsxs("div",{className:"rounded-lg border border-border/40 bg-muted/10 p-4",children:[t.jsx("p",{className:"font-bold text-primary mb-1",children:w}
587),t.jsxs("p",{className:"text-sm mb-2 italic text-foreground/80",children:['"',j,'"']}),t.jsx("ul",{className:"list-disc pl-4 space-y-0.5",children:x.map((C,k)=>t.jsx("li",{className:"text-sm text-foreground/75",children:C},k))})]},w))})]}),t.jsxs(Fn,{id:"remote-reboot",num:39,title:o(39),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s39.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s39.p2")})}),t.jsx(qs,{src:"TS_1.PNG",alt:"Remote reboot menu"}),t.jsx(zu,{children:t.jsx(vt,{children:s("s39.box1")})})]}),t.jsxs(Fn,{id:"teamviewer",num:40,title:o(40),children:[t.jsx("p",{children:t.jsx(vt,{children:s("s40.p1")})}),t.jsx("p",{children:t.jsx(vt,{children:s("s40.p2")})}),t.jsx(qs,{src:"TS_1.PNG",alt:"TeamViewer connect menu"}),t.jsx(zu,{children:t.jsx(vt,{children:s("s40.box1")})})]}),t.jsxs("div",{className:"pt-8 border-t border-border/30 text-center text-xs text-muted-foreground",children:["Event Management Portal User Manual — v1.50 series  ·  Support: ",t.jsx("a",{href:`mailto:${e.helpEmail}`,className:"text-primary hover:underline",children:e.helpEmail})]})]})]}),t.jsx(_a,{})]})}const EVe="/assets/apple_1_1776448653559-DIzEMgEX.PNG",TVe="/assets/apple_2_1776448653559-Cpya-E7h.PNG",AVe="/assets/apple_3_1776448653558-BUVHJbiW.PNG",MVe="/assets/android_1_1776448653558-B5USLZmi.webp",RVe="/assets/android_2_1776448653559-DtOC9wOB.webp",IVe="/assets/android_3_1776448653559-BsPqZypB.webp";function ZV(e){const s=[],r=/\*\*(.+?)\*\*|`(.+?)`/g;let n=0,a,i=0;for(;(a=r.exec(e))!==null;)a.index>n&&s.push(e.slice(n,a.index)),a[1]!==void 0?s.push(t.jsx("strong",{children:a[1]},`b${i}`)):s.push(t.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded",children:a[2]},`c${i}`)),n=r.lastIndex,i++;return n<e.length&&s.push(e.slice(n)),s}function OVe({step:e,testIdPrefix:s}){return t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[1fr_auto] gap-6 md:gap-10 items-center","data-testid":`${s}-step-${e.num}`,children:[t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("span",{className:"shrink-0 w-10 h-10 rounded-full bg-primary/15 text-primary text-base font-bold flex items-center justify-center",children:e.num}),t.jsx("p",{className:"text-base sm:text-lg text-foreground/85 leading-relaxed",children:e.text})]}),t.jsx("div",{className:"rounded-[2rem] border border-border/60 bg-muted/30 p-2 shadow-sm justify-self-center md:justify-self-end",children:t.jsx("img",{src:e.img,alt:e.alt,className:"rounded-[1.5rem] w-full max-w-[360px] sm:max-w-[420px] h-auto block",loading:"lazy"})})]})}function JV({title:e,icon:s,steps:r,testIdPrefix:n}){return t.jsxs("section",{className:"rounded-2xl border border-border/60 bg-muted/10 p-6 sm:p-8","data-testid":`${n}-guide`,children:[t.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center",children:t.jsx(s,{className:"w-5 h-5 text-primary"})}),t.jsx("h2",{className:"text-xl sm:text-2xl font-bold text-foreground",children:e})]}),t.jsx("div",{className:"space-y-10 md:space-y-12",children:r.filter(a=>a.show!=="false").map(a=>t.jsx(OVe,{step:a,testIdPrefix:n},a.num))})]})}function eW(){const e=Er(),{t:s,tLines:r}=rn(Cte),n=r("apple.steps"),a=r("android.steps"),i=[{img:e.imgInstallApple1||EVe,show:e.imgInstallApple1Show},{img:e.imgInstallApple2||TVe,show:e.imgInstallApple2Show},{img:e.imgInstallApple3||AVe,show:e.imgInstallApple3Show}],o=[{img:e.imgInstallAndroid1||MVe,show:e.imgInstallAndroid1Show},{img:e.imgInstallAndroid2||RVe,show:e.imgInstallAndroid2Show},{img:e.imgInstallAndroid3||IVe,show:e.imgInstallAndroid3Show}],l=[s("apple.step1Alt"),s("apple.step2Alt"),s("apple.step3Alt")],c=[s("android.step1Alt"),s("android.step2Alt"),s("android.step3Alt")],d=n.map((p,g)=>({num:g+1,text:t.jsx(t.Fragment,{children:ZV(p)}),img:i[g].img,show:i[g].show,alt:l[g]})),h=a.map((p,g)=>({num:g+1,text:t.jsx(t.Fragment,{children:ZV(p)}),img:o[g].img,show:o[g].show,alt:c[g]}));return u.useEffect(()=>{const p=document.title;document.title=`Edge App Install — ${e.brandName}`;const g=`Install the ${e.productName}
587 web app on your iPhone, iPad, or Android phone in three quick steps.`;let v=document.querySelector('meta[name="description"]');const b=!!v,y=v?.getAttribute("content")??null;return v||(v=document.createElement("meta"),v.setAttribute("name","description"),document.head.appendChild(v)),v.setAttribute("content",g),()=>{document.title=p,v&&(b?v.setAttribute("content",y??""):v.parentNode?.removeChild(v))}},[e.brandName,e.productName]),t.jsxs("div",{className:"min-h-screen bg-background text-foreground flex flex-col",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1")}),t.jsx("main",{className:"flex-1",children:t.jsxs("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 pt-24 pb-16",children:[t.jsxs("div",{className:"mb-10 pb-8 border-b border-border/40",children:[t.jsx("span",{className:"inline-block px-3 py-1 rounded-full text-xs font-medium bg-primary/10 text-primary mb-3",children:s("hero.badge")}),t.jsx("h1",{className:"text-3xl sm:text-4xl font-bold text-foreground leading-tight mb-3","data-testid":"text-page-title",children:s("hero.heading")}),t.jsx("p",{className:"text-muted-foreground leading-relaxed max-w-3xl",children:s("hero.subheading")}),t.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[s("hero.helpPrefix")," ",t.jsx("a",{href:`mailto:${e.supportEmail}`,className:"text-primary hover:underline",children:e.supportEmail}),"."]})]}),t.jsxs("div",{className:"space-y-10",children:[t.jsx(JV,{title:s("apple.title"),icon:Ice,steps:d,testIdPrefix:"apple"}),t.jsx(JV,{title:s("android.title"),icon:Yc,steps:h,testIdPrefix:"android"})]}),t.jsx("div",{className:"mt-10 rounded-xl border border-primary/20 bg-primary/5 px-5 py-4 text-sm text-foreground/85",children:t.jsxs("p",{children:[t.jsx("span",{className:"font-semibold text-primary",children:s("tip.label")})," ",s("tip.body")]})})]})}),t.jsx(_a,{})]})}const DVe=".jpg,.jpeg,.png,.gif,.webp,.bmp,.tiff,.heic,.heif,.mp4,.mov,.avi,.mkv,.webm,.m4v",LVe=".csv,.xlsx,.xls,.pdf,.doc,.docx,.txt";function $Ve(e){const s=e.split(".").pop()?.toLowerCase()||"";return/^(mp4|mov|avi|mkv|webm|m4v|ts)$/.test(s)?t.jsx(Vi,{className:"w-4 h-4 text-blue-400 shrink-0"}):/^(jpg|jpeg|png|gif|webp|bmp|tiff|heic|heif)$/.test(s)?t.jsx(Ok,{className:"w-4 h-4 text-green-400 shrink-0"}):t.jsx(xu,{className:"w-4 h-4 text-muted-foreground shrink-0"})}function FVe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function tW({mediaFiles:e,mediaRef:s,onAdd:r,onRemove:n}){const{t:i}=rn(w_);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs(re,{children:[i("media.label")," ",t.jsx("span",{className:"text-muted-foreground text-xs font-normal",children:i("media.optional").replace("{max}",String(5))})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:i("media.hint")}),t.jsx("input",{ref:s,type:"file",accept:DVe+","+LVe,multiple:!0,className:"hidden",onChange:o=>r(o.target.files),"data-testid":"input-media-files"}),e.length>0&&t.jsx("div",{className:"space-y-1.5",children:e.map((o,l)=>t.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-muted/20 px-3 py-2",children:[$Ve(o.name),t.jsx("span",{className:"text-sm font-medium text-foreground flex-1 truncate",children:o.name}),t.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:FVe(o.size)}),t.jsx("button",{type:"button",onClick:()=>n(l),className:"text-muted-foreground hover:text-foreground shrink-0","data-testid":`button-remove-media-${l}`,children:t.jsx(va,{className:"w-4 h-4"})})]},l))}),e.length<5&&t.jsxs("button",{type:"button",onClick:()=>s.current?.click(),className:"w-full flex flex-col items-center gap-2 rounded-lg border border-dashed border-border bg-muted/10 hover:border-primary/50 hover:bg-muted/20 transition-colors px-4 py-5 text-muted-foreground","data-testid":"button-add-media-files",children:[t.jsx(Om,{className:"w-5 h-5"}),t.jsx("span",{className:"text-sm",children:e.length===0?i("media.emptyPrompt"):i("media.morePrompt")}),t.jsx("span",{className:"text-xs",children:i("media.formats").replace("{remaining}",String(5-e.length))})]}),t.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1 mt-1",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),i("encryptionNotice")]})]})}const BVe=["footage_request","activation","support"],UVe=[t.jsx(ZI,{className:"w-5 h-5"}),t.jsx(Nb,{className:"w-5 h-5"}),t.jsx(IK,{className:"w-5 h-5"})];function zVe({values:e,onChange:s,errors:r,lockedEmail:n}){const{t:a}=rn(w_);return t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"name",children:[a("contact.nameLabel")," ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"name","data-testid":"input-name",value:e.name,onChange:i=>s({name:i.target.value}),placeholder:a("contact.namePlaceholder"),className:r.name?"border-destructive":""}),r.name&&t.jsx("p",{className:"text-xs text-destructive",children:r.name})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"business",children:[a("contact.businessLabel")," ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"business","data-testid":"input-business",value:e.business,onChange:i=>s({business:i.target.value}),placeholder:a("contact.businessPlaceholder"),className:r.business?"border-destructive":""}),r.business&&t.jsx("p",{className:"text-xs text-destructive",children:r.business})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"phone",children:[a("contact.phoneLabel")," ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"phone","data-testid":"input-phone",value:e.phone,onChange:i=>s({phone:i.target.value}),placeholder:a("contact.phonePlaceholder"),type:"tel",className:r.phone?"border-destructive":""}
587),r.phone&&t.jsx("p",{className:"text-xs text-destructive",children:r.phone})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"email",children:[a("contact.emailLabel")," ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"email","data-testid":"input-email",value:e.email,onChange:n?void 0:i=>s({email:i.target.value}),readOnly:n,placeholder:a("contact.emailPlaceholder"),type:"email",className:`${r.email?"border-destructive":""} ${n?"bg-muted/40 cursor-default":""}`}),n&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[a("contact.fromAccount")," ",t.jsx("button",{type:"button",className:"underline hover:text-foreground",onClick:()=>s({email:""}),children:a("contact.changeLink")})]}),r.email&&t.jsx("p",{className:"text-xs text-destructive",children:r.email})]})]})}function sW(){const{toast:e}=Hs(),{user:s}=Gi(),r=Er(),{t:n,tParts:a}=rn(w_),{data:i}=ze({queryKey:["/api/user/business-info"],enabled:!!s}),o=u.useRef(null),l=u.useRef(null),[c,d]=u.useState("footage_request"),[h,p]=u.useState(!1),[g,v]=u.useState(null),[b,y]=u.useState({name:"",business:"",phone:"",email:""});u.useEffect(()=>{s&&y(pe=>({...pe,name:pe.name||[s.firstName,s.lastName].filter(Boolean).join(" "),email:pe.email||s.email||""}))},[s]),u.useEffect(()=>{i&&y(pe=>({...pe,business:pe.business||i.businessName||"",phone:pe.phone||i.phone||""}))},[i]);const[w,j]=u.useState(""),[x,C]=u.useState(""),[k,S]=u.useState(""),[_,A]=u.useState(""),[T,M]=u.useState(""),[R,D]=u.useState(""),[$,O]=u.useState(""),[q,V]=u.useState(null),[K,G]=u.useState([]),[z,Z]=u.useState(""),[ee,Q]=u.useState({});function Y(pe){if(!pe)return;const le=5,ue=Array.from(pe);G(fe=>[...fe,...ue].slice(0,le)),l.current&&(l.current.value="")}function oe(pe){G(le=>le.filter((ue,fe)=>fe!==pe))}function he(){const pe={};return b.name.trim()||(pe.name=n("validation.nameRequired")),b.business.trim()||(pe.business=n("validation.businessRequired")),b.phone.trim()||(pe.phone=n("validation.phoneRequired")),b.email.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b.email)||(pe.email=n("validation.emailInvalid")):pe.email=n("validation.emailRequired"),
587c==="footage_request"&&(w||(pe.footageDateFrom=n("validation.footageStartRequired")),x||(pe.footageDateTo=n("validation.footageEndRequired"))),Q(pe),Object.keys(pe).length===0}async function je(pe){if(pe.preventDefault(),!!he()){p(!0);try{const le=new FormData;le.append("ticketType",c),le.append("name",b.name),le.append("business",b.business),le.append("phone",b.phone),le.append("email",b.email),c==="footage_request"&&(le.append("footageDateFrom",w),le.append("footageDateTo",x),k&&le.append("footageTimeFrom",k),_&&le.append("footageTimeTo",_),T&&le.append("description",T),K.forEach(H=>le.append("attachments",H))),c==="activation"&&(R&&le.append("soOrderNumber",R),$&&le.append("edgeSerialNumber",$),q&&le.append("attachment",q)),c==="support"&&(le.append("description",z),K.forEach(H=>le.append("attachments",H)));const ue=await fetch("/api/support/tickets",{method:"POST",body:le});if(!ue.ok){const H=await ue.json().catch(()=>({message:"Submission failed"}));throw new Error(H.message)}const fe=await ue.json();v(fe)}catch(le){e({title:"Submission failed",description:le.message||"Please try again.",variant:"destructive"})}finally{p(!1)}}}return g?t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1")}),t.jsxs("div",{className:"max-w-2xl mx-auto px-4 pt-32 pb-16 text-center",children:[t.jsx("div",{className:"w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mx-auto mb-6",children:t.jsx(Ny,{className:"w-8 h-8 text-green-500"})}),t.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:n("success.heading")}),t.jsx("p",{className:"text-muted-foreground mb-2",children:n("success.refLabel")}),t.jsxs("p",{className:"text-3xl font-mono font-bold text-primary mb-6",children:["#",g.ticketRef]}),t.jsxs("p",{className:"text-muted-foreground text-sm mb-8",children:[n("success.confirmationPrefix")," ",t.jsx("strong",{children:b.email}),n("success.confirmationSuffix")]}),t.jsxs("div",{className:"flex gap-3 justify-center",children:[t.jsx(L,{onClick:()=>{v(null),y({name:"",business:"",phone:"",email:""}),j(""),C(""),S(""),A(""),M(""),D(""),O(""),V(null),Z(""),Q({})},variant:"outline",children:n("success.submitAnother")}),t.jsx(L,{onClick:()=>window.location.assign("/"),children:n("success.goHome")})]})]}),t.jsx(_a,{})]}):t.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[t.jsx(pa,{onSignIn:()=>window.location.assign("/?signin=1")}),t.jsxs("div",{className:"max-w-2xl mx-auto px-4 sm:px-6 pt-24 pb-16",children:[t.jsxs("div",{className:"mb-8",children:[t.jsx("div",{className:"flex items-center gap-2 mb-3",children:t.jsx("span",{className:"inline-block px-3 py-1 rounded-full text-xs font-medium bg-primary/10 text-primary",children:n("hero.badge")})}),t.jsx("h1",{className:"text-3xl sm:text-4xl font-bold text-foreground mb-2",children:n("hero.heading")}),t.jsx("p",{className:"text-muted-foreground",children:n("hero.subheading")})]}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 mb-8",children:a("types.items").map(([pe="",le=""],ue)=>{const fe=BVe[ue],H=UVe[ue];return t.jsxs("button",{type:"button","data-testid":`ticket-type-${fe}`,onClick:()=>{d(fe),Q({})},className:`relative rounded-xl border p-4 text-left transition-all ${c===fe?"border-primary bg-primary/5 shadow-sm":"border-border bg-muted/10 hover:border-primary/40 hover:bg-muted/30"}`,children:[t.jsx("div",{className:`mb-2 ${c===fe?"text-primary":"text-muted-foreground"}`,children:H}),t.jsx("div",{className:"font-semibold text-sm text-foreground mb-1",children:pe}),t.jsx("div",{className:"text-xs text-muted-foreground leading-snug",children:le}),c===fe&&t.jsx("div",{className:"absolute top-3 right-3 w-2 h-2 rounded-full bg-primary"})]},fe)})}),t.jsxs("form",{onSubmit:je,className:"space-y-8",children:[t.jsxs("div",{className:"rounded-xl border border-border/60 bg-muted/5 p-6",children:[t.jsxs("h2",{className:"font-semibold text-foreground mb-4 flex items-center gap-2",children:[t.jsx("span",{className:"w-6 h-6 rounded-full bg-primary/15 text-primary text-xs font-bold flex items-center justify-center",children:"1"}),n("contactSection.heading")]}),t.jsx(zVe,{values:b,onChange:pe=>y(le=>({...le,...pe})),errors:ee,lockedEmail:!!(s&&s.email&&b.email===s.email)})]}),t.jsxs("div",{className:"rounded-xl border border-border/60 bg-muted/5 p-6",children:[t.jsxs("h2",{className:"font-semibold text-foreground mb-4 flex items-center gap-2",children:[t.jsx("span",{className:"w-6 h-6 rounded-full bg-primary/15 text-primary text-xs font-bold flex items-center justify-center",children:"2"}),c==="footage_request"&&n("footageDetails.heading"),c==="activation"&&n("activationDetail
587s.heading"),c==="support"&&n("problemDescription.heading")]}),c==="footage_request"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"footageDateFrom",children:[n("footage.startDateLabel")," ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"footageDateFrom","data-testid":"input-footage-date-from",type:"date",value:w,onChange:pe=>j(pe.target.value),className:ee.footageDateFrom?"border-destructive":""}),ee.footageDateFrom&&t.jsx("p",{className:"text-xs text-destructive",children:ee.footageDateFrom})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"footageDateTo",children:[n("footage.endDateLabel")," ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"footageDateTo","data-testid":"input-footage-date-to",type:"date",value:x,onChange:pe=>C(pe.target.value),className:ee.footageDateTo?"border-destructive":""}),ee.footageDateTo&&t.jsx("p",{className:"text-xs text-destructive",children:ee.footageDateTo})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"footageTimeFrom",children:n("footage.startTimeLabel")}),t.jsx(ke,{id:"footageTimeFrom","data-testid":"input-footage-time-from",type:"time",value:k,onChange:pe=>S(pe.target.value)})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"footageTimeTo",children:n("footage.endTimeLabel")}),t.jsx(ke,{id:"footageTimeTo","data-testid":"input-footage-time-to",type:"time",value:_,onChange:pe=>A(pe.target.value)})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"footageDescription",children:n("footage.additionalLabel")}),t.jsx(Nn,{id:"footageDescription","data-testid":"textarea-footage-description",value:T,onChange:pe=>M(pe.target.value),placeholder:n("footage.additionalPlaceholder"),rows:4})]}),t.jsx(tW,{mediaFiles:K,mediaRef:l,onAdd:Y,onRemove:oe})]}),c==="activation"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"soOrderNumber",children:n("activation.soLabel")}),t.jsx(ke,{id:"soOrderNumber","data-testid":"input-so-order-number",value:R,onChange:pe=>D(pe.target.value),placeholder:n("activation.soPlaceholder")})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"edgeSerialNumber",children:n("activation.edgeLabel")}),t.jsx(ke,{id:"edgeSerialNumber","data-testid":"input-edge-serial-number",value:$,onChange:pe=>O(pe.target.value),placeholder:n("activation.edgePlaceholder")})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:n("activation.eitherHint")}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:n("activation.credentialsLabel")}),t.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:n("activation.credentialsHint")}),t.jsx("input",{ref:o,type:"file",accept:".csv,.xlsx,.xls,.pdf,.doc,.docx,.txt",className:"hidden",onChange:pe=>V(pe.target.files?.[0]??null),"data-testid":"input-attachment"}),q?t.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-muted/20 px-4 py-3",children:[t.jsx(Om,{className:"w-4 h-4 text-primary shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-foreground flex-1 truncate",children:q.name}),t.jsx("button",{type:"button",onClick:()=>{V(null),o.current&&(o.current.value="")},className:"text-muted-foreground hover:text-foreground","data-testid":"button-remove-attachment",children:t.jsx(va,{className:"w-4 h-4"})})]}):t.jsxs("button",{type:"button",onClick:()=>o.current?.click(),className:"w-full flex flex-col items-center gap-2 rounded-lg border border-dashed border-border bg-muted/10 hover:border-primary/50 hover:bg-muted/20 transition-colors px-4 py-6 text-muted-foreground","data-testid":"button-upload-attachment",children:[t.jsx(Om,{className:"w-6 h-6"}),t.jsx("span",{className:"text-sm",children:n("activation.uploadPrompt")}),t.jsx("span",{className:"text-xs",children:n("activation.uploadFormats")})]}),t.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1 mt-1",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),n("encryptionNotice")]})]})]}),c==="support"&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"supportDescription",children:[n("support.descriptionLabel")," ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(Nn,{id:"supportDescription","data-testid":"textarea-support-description",value:z,onChange:pe=>Z(pe.target.value),placeholder:n("support.descriptionPlaceholder"),rows:6,className:ee.supp
587ortDescription?"border-destructive":""}),ee.supportDescription&&t.jsx("p",{className:"text-xs text-destructive",children:ee.supportDescription})]}),t.jsx(tW,{mediaFiles:K,mediaRef:l,onAdd:Y,onRemove:oe})]})]}),t.jsx(L,{type:"submit",className:"w-full",disabled:h,"data-testid":"button-submit-ticket",size:"lg",children:h?t.jsxs(t.Fragment,{children:[t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}),n("submit.sending")]}):t.jsxs(t.Fragment,{children:[t.jsx(k0,{className:"w-4 h-4 mr-2"}),n("submit.button")]})}),t.jsxs("p",{className:"text-center text-xs text-muted-foreground",children:[n("footer.note")," ",t.jsx("a",{href:`tel:${r.phoneHref}`,className:"text-primary hover:underline",children:r.phone}),"."]})]})]}),t.jsx(_a,{})]})}const HVe="https://truvios.app/CloudCMS/Pro-Hybrid-1/cms/proactive-cctv1.com/Vault-CMS-Installer.exe",qVe="https://truvios.app/CloudCMS/Pro-Hybrid-1/cms/proactive-cctv1.com/Vault-CMS-Installer_(non-admin).exe",J1={version:"v1.60",date:"05/15/2025",changes:[{type:"feature",text:"AI Search for object, text, and license plate detection"},{type:"feature",text:"Updated GUI interface design"},{type:"feature",text:"Better performance during event retrieval and live view"},{type:"feature",text:"Improved security updates"},{type:"feature",text:"Purple mode"},{type:"feature",text:"Minor various bug fixes"}]},VVe=[{version:"v1.57",date:"01/02/2024",changes:["Beta version release."]},{version:"v1.56",date:"01/04/2024",changes:["Feature: Added digital signature certificate to avoid false malware alerts.","Notice: Version 1.56 only updated Proactive Portal.exe — other .exe files remain on v1.54."]},{version:"v1.55",date:"02/26/2023",changes:["Bug Fix: Disables DPI awareness from v1.54, which caused scaling issues on laptops.","Notice: Version 1.55 only updated Proactive Portal.exe — other .exe files remain on v1.54."]},{version:"v1.54",date:"02/21/2023",changes:["Feature: Added preference to never let host choose mode or theme.","Bug Fix: Fixes OEM customization bug when downloading data."]},{version:"v1.53",date:"01/03/2023",changes:["Feature: OEM customization feature added."]}],rW=[Vx,uc,jb,fde,Vx];function WVe(){const[e,s]=u.useState(!1),{t:r}=rn(b_);return t.jsxs("div",{className:"mt-6 border border-border rounded-lg overflow-hidden",children:[t.jsxs("button",{onClick:()=>s(n=>!n),className:"w-full flex items-center justify-between px-5 py-3.5 bg-muted/30 hover:bg-muted/50 transition-colors text-sm font-semibold text-foreground","data-testid":"button-version-history-toggle",children:[t.jsx("span",{children:r("download.versionHistory")}),e?t.jsx(Ig,{className:"w-4 h-4 text-muted-foreground"}):t.jsx(Xa,{className:"w-4 h-4 text-muted-foreground"})]}),e&&t.jsx("div",{className:"divide-y divide-border",children:VVe.map(n=>t.jsxs("div",{className:"px-5 py-4",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[t.jsx("span",{className:"text-sm font-semibold text-foreground",children:n.version}),t.jsx("span",{className:"text-xs text-muted-foreground",children:n.date})]}),t.jsx("ul",{className:"space-y-1",children:n.changes.map((a,i)=>t.jsxs("li",{className:"text-sm text-muted-foreground flex items-start gap-2",children:[t.jsx("span",{className:"mt-1 w-1.5 h-1.5 rounded-full bg-primary/60 shrink-0"}),a]},i))})]},n.version))})]})}function nW({title:e,subtitle:s,description:r,note:n,href:a,testId:i}){const{t:o}=rn(b_);return t.jsxs("div",{className:"rounded-xl border border-border bg-card shadow-sm flex flex-col",children:[t.jsxs("div",{className:"p-6 flex-1",children:[t.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-lg font-semibold text-foreground",children:e}),t.jsx("p",{className:"text-sm text-primary font-medium mt-0.5",children:s})]}),t.jsx("div",{className:"shrink-0 w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:t.jsx(ya,{className:"w-5 h-5 text-primary"})})]}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed mb-3",children:r}),t.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-amber-500/10 border border-amber-500/20 px-3 py-2.5",children:[t.jsx(Pn,{className:"w-4 h-4 text-amber-500 shrink-0 mt-0.5"}),t.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-400 leading-snug",children:n})]})]}),t.jsx("div",{className:"px-6 pb-6",children:t.jsxs("a",{href:a,className:"flex items-center justify-center gap-2 w-full rounded-lg bg-primary text-primary-foreground px-4 py-2.5 text-sm font-semibold hover:bg-primary/90 transition-colors","data-testid":i,children:[t.jsx(ya,{className:"w-4 h-4"}),o("download.button")]})}),t.jsx(WVe,{})]})}function aW(){const{t:e,tParts:s}=rn(b_);return t.jsxs("div",{className:"min-h-screen flex flex-col bg-background",children:[t.jsx(pa,{}),t.jsx("section",{className:"pt-24 pb-10 px-4 border-b border-border bg-muted/20",children:t.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-primary/10 px-4 py-1.5 mb-4",children:[t.jsx(ya,{className:"w-4 h-4 text-primary"}),t.jsx("span",{className:"text-sm font-medium text-primary",children:e("hero.badge")})]}),t.jsx("h1",{className:"text-3xl sm:text-4xl font-bold text-foreground mb-3",children:e("hero.heading")}),t.jsx("p",{className:"text-muted-foreground text-base max-w-xl mx-auto",children:e("hero.subheading")}),t.jsxs("div",{className:"mt-4 inline-flex items-center gap-2 rounded-full bg-green-500/10 border border-green-500/20 px-4 py-1.5",children:[t.jsx(Ny,{className:"w-4 h-4 text-green-500"}),t.jsxs("span",{className:"text-sm font-medium text-green-700 dark:text-green-400",children:[e("hero.latestLabel")," ",J1.version," — ",J1.date]})]})]})}),t.jsx("main",{className:"flex-1 px-4 py-12",children:t.jsxs("div",{className:"max-w-4xl mx-auto 
587space-y-12",children:[t.jsxs("section",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-foreground mb-4",children:[e("whatsNew.heading")," ",J1.version]}),t.jsx("div",{className:"rounded-xl border border-border bg-card p-5 grid sm:grid-cols-2 gap-3",children:J1.changes.map((r,n)=>t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsx("span",{className:`mt-0.5 shrink-0 w-5 h-5 rounded-full flex items-center justify-center text-xs font-bold ${r.type==="feature"?"bg-primary/10 text-primary":"bg-orange-500/10 text-orange-500"}`,children:r.type==="feature"?"✦":"✗"}),t.jsx("span",{className:"text-sm text-muted-foreground leading-snug",children:r.text})]},n))})]}),t.jsxs("section",{children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground mb-4",children:e("chooseVersion.heading")}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-6 items-start",children:[t.jsx(nW,{title:e("admin.title"),subtitle:e("admin.subtitle"),description:e("admin.description"),note:e("admin.note"),href:HVe,testId:"link-download-admin"}),t.jsx(nW,{title:e("user.title"),subtitle:e("user.subtitle"),description:e("user.description"),note:e("user.note"),href:qVe,testId:"link-download-user"})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground mb-4",children:e("systemReq.heading")}),t.jsx("div",{className:"rounded-xl border border-border bg-card divide-y divide-border overflow-hidden",children:s("systemReq.items").map(([r="",n=""],a)=>{const i=rW[a%rW.length];return t.jsxs("div",{className:"flex items-start gap-4 px-5 py-4",children:[t.jsx("div",{className:"shrink-0 w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center mt-0.5",children:t.jsx(i,{className:"w-4 h-4 text-primary"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground/70 mb-0.5",children:r}),t.jsx("p",{className:"text-sm text-foreground",children:n})]})]},r)})})]})]})}),t.jsx(_a,{})]})}function iW(){const[,e]=Ia(),{toast:s}=Hs(),{t:r}=rn(rte),[n,a]=u.useState(""),[i,o]=u.useState(""),[l,c]=u.useState(!1),d=async h=>{if(h.preventDefault(),!n.trim()||!i.trim()){s({title:"Missing fields",description:"Please enter both a name and email address.",variant:"destructive"});return}c(!0);try{const p=await fetch("/api/refer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n.trim(),email:i.trim()})});if(!p.ok){const g=await p.json().catch(()=>({error:"Failed to send"}));throw new Error(g.error||"Failed to send referral email")}s({title:"Referral sent!",description:`A marketing email has been sent to ${i.trim()}.`}),a(""),o("")}catch(p){s({title:"Send Failed",description:p instanceof Error?p.message:"Failed to send referral email",variant:"destructive"})}finally{c(!1)}};return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx(pa,{onSignIn:()=>e("/?signin=1"),onContact:()=>e("/home?contact=1")}),t.jsx("div",{className:"pt-24 pb-20 px-4 sm:px-6 lg:px-8",children:t.jsxs("div",{className:"max-w-lg mx-auto",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-primary/10 mb-4",children:t.jsx(ny,{className:"w-8 h-8 text-primary"})}),t.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2","data-testid":"text-refer-title",children:r("hero.heading")}),t.jsx("p",{className:"text-muted-foreground max-w-md mx-auto",children:r("hero.subheading")})]}),t.jsx(ut,{className:"border-border",children:t.jsx(mt,{className:"p-6",children:t.jsxs("form",{onSubmit:d,className:"space-y-5",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"referName",className:"text-sm",children:r("form.nameLabel")}),t.jsx(ke,{id:"referName",placeholder:r("form.namePlaceholder"),value:n,onChange:h=>a(h.target.value),required:!0,"data-testid":"input-refer-name"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"referEmail",className:"text-sm",children:r("form.emailLabel")}),t.jsx(ke,{id:"referEmail",type:"email",placeholder:r("form.emailPlaceholder"),value:i,onChange:h=>o(h.target.value),required:!0,"data-testid":"input-refer-email"})]}),t.jsxs(L,{type:"submit",className:"w-full",disabled:l,"data-testid":"button-refer-submit",children:[l?t.jsx(Fe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(Ja,{className:"w-4 h-4 mr-2"}),r(l?"form.sendingButton":"form.submitButton")]})]})})}),t.jsx("div",{className:"text-center mt-6",children:t.jsxs(L,{variant:"ghost",size:"sm",onClick:()=>e("/home"),"data-testid":"button-refer-back",children:[t.jsx(Wi,{className:"w-3.5 h-3.5 mr-1.5"}),r("backButton")]})})]})})]})}const oW=[{code:"AL",name:"Alabama"},{code:"AK",name:"Alaska"},{code:"AZ",name:"Arizona"},{code:"AR",name:"Arkansas"},{code:"CA",name:"California"},{code:"CO",name:"Colorado"},{code:"CT",name:"Connecticut"},{code:"DE",name:"Delaware"},{code:"DC",name:"District of Columbia"},{code:"FL",name:"Florida"},{code:"GA",name:"Georgia"},{code:"HI",name:"Hawaii"},{code:"ID",name:"Idaho"},{code:"IL",name:"Illinois"},{code:"IN",name:"Indiana"},{code:"IA",name:"Iowa"},{code:"KS",name:"Kansas"},{code:"KY",name:"Kentucky"},{code:"LA",name:"Louisiana"},{code:"ME",name:"Maine"},{code:"MD",name:"Maryland"},{code:"MA",name:"Massachusetts"},{code:"MI",name:"Michigan"},{code:"MN",name:"Minnesota"},{code:"MS",name:"Mississippi"},{code:"MO",name:"Missouri"},{code:"MT",name:"Montana"},{code:"NE",name:"Nebraska"},{code:"NV",name:"Nevada"},{code:"NH",name:"New Hampshire"},{code:"NJ",name:"New Jersey"},{code:"NM",name:"New Mexico"},{code:"NY",name:"New York"},{code:"NC",name:"North Carolina"},{code:"ND",name:"North Dakota"},{code:"OH",name:"Ohio"},{code:"OK",name:"Oklahoma"},{code:"OR",name:"Oregon"},{code:"PA",name:"Pennsylvania"},{code:"RI",name:"Rhode Island"},{code:"SC",name:"South Carolina"},{code:"SD",name:"South Dakota"},{code:"TN",name:"Tennessee"},{code:"TX",name:"Texas"},{code:"UT",name:"Utah"},{code:"VT",name:"Vermont"},{code:"VA",name:"Virginia"},{code:"WA",name:"Washington"},{code:"WV",name:"West Virginia"},{code:"WI",name:"Wisconsin"},{code:"WY",name:"Wyoming"}].sort((e,s)=>zi(e.name,s.name)),lW={projectName:"",businessName:"",customerName:"",customerEmail:"",cameraCount:8,storageType:"cloud",resolutionTier:"standard",recordingMode:"motion",cloudRetention:30,localRetentionDays:30,remoteMonitoring:!1,smartAlerts:!1,smartAlertsCameraCount:8,discountPercent:0,discountScope:"both",promoCode:"",promoPercent:0,promoScope:"",billingFrequency:"monthly",msrpEnabled:!1,msrpHardwareMarkupPercent:50,msrpSubscriptionMarkupPercent:100,currency:"USD",shipCountry:"US",shipPostalCode:"",shipService:"03",shipBusinessName:"",shipAttnName:"",shipAddress1:"",shipAddress2:"",shipCity:"",shipState:"",shippingAmountOverride:null,shippingOverrideReason:"",savedShippingUsd:null,savedShippingKey:null,
587savedFxRate:null,savedFxCurrency:null,isLegacyRecord:!1};function cW(e,s,r,n){const a=e.storageType==="cloud"||e.storageType==="hybrid",i=e.storageType==="local"||e.storageType==="hybrid";return{projectName:e.projectName||"Untitled Project",businessName:e.businessName||void 0,customerName:e.customerName||void 0,customerEmail:e.customerEmail||void 0,cameraCount:e.cameraCount,storageType:e.storageType,resolutionTier:a||i?e.resolutionTier:void 0,recordingMode:a||e.storageType==="local"?e.recordingMode:void 0,cloudRetention:a?e.cloudRetention:void 0,localRetentionDays:i?e.localRetentionDays:void 0,remoteMonitoring:e.storageType==="local"?e.remoteMonitoring:!1,smartAlerts:e.smartAlerts,smartAlertsCameraCount:e.smartAlerts?e.smartAlertsCameraCount:void 0,discountPercent:e.discountPercent>0?e.discountPercent:void 0,discountScope:e.discountPercent>0?e.discountScope:"none",promoCode:e.promoCode&&e.promoPercent>0?e.promoCode:void 0,promoDiscountPercent:e.promoCode&&e.promoPercent>0?e.promoPercent:void 0,promoScope:e.promoCode&&e.promoPercent>0&&e.promoScope?e.promoScope:void 0,billingFrequency:e.billingFrequency,distributorHardwareMarkupPercent:n?.hardwarePercent??0,distributorSubscriptionMarkupPercent:n?.subscriptionPercent??0,msrpEnabled:e.msrpEnabled,msrpHardwareMarkupPercent:e.msrpEnabled?e.msrpHardwareMarkupPercent:void 0,msrpSubscriptionMarkupPercent:e.msrpEnabled?e.msrpSubscriptionMarkupPercent:void 0,currency:e.currency,shipCountry:e.shipCountry||void 0,shipPostalCode:e.shipPostalCode||void 0,shipService:e.shipService,shipBusinessName:e.shipBusinessName||void 0,shipAttnName:e.shipAttnName||void 0,shipAddress1:e.shipAddress1||void 0,shipAddress2:e.shipAddress2||void 0,shipCity:e.shipCity||void 0,shipState:e.shipState||void 0,shippingAmount:typeof s=="number"?s:void 0,shippingAmountOverride:typeof e.shippingAmountOverride=="number"?e.shippingAmountOverride:void 0,shippingOverrideReason:e.shippingOverrideReason||void 0,quoteForResellerId:r||void 0}}function dW(){const[,e]=Ia(),{user:s}=Gi();Er();const{t:r}=rn(y_);return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx(pa,{}),t.jsx("main",{className:"pt-24 pb-16 px-4 max-w-2xl mx-auto",children:t.jsxs(ut,{children:[t.jsxs(xs,{className:"text-center",children:[t.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-muted flex items-center justify-center mb-2",children:t.jsx(ka,{className:"w-6 h-6 text-primary"})}),t.jsx(ys,{"data-testid":"text-quote-gate-title",children:r("gate.title")}),t.jsx(Xs,{children:r("gate.description")})]}),t.jsxs(mt,{className:"flex flex-col gap-3 items-center",children:[s?t.jsx("p",{className:"text-sm text-muted-foreground text-center",children:r("gate.noPermission")}):t.jsx(L,{onClick:()=>e("/?signin=1"),"data-testid":"button-quote-signin",children:r("gate.signInButton")}),t.jsxs(L,{variant:"ghost",onClick:()=>e("/home"),"data-testid":"button-quote-back-home",children:[t.jsx(Wi,{className:"w-4 h-4 mr-1"})," ",r("gate.backHomeButton")]})]})]})})]})}function KVe(){if(typeof window>"u")return null;try{const s=new URLSearchParams(window.location.search).get("revise");return s&&s.trim()?s.trim():null}catch{return null}}function eS(){const[,e]=Ia(),{user:s}=Gi(),{toast:r}=Hs(),n=Er(),{t:a,tLines:i,tParts:o}=rn(y_),l=Zee(o("step2.resolutionOptions")),[c]=u.useState(()=>KVe()),d=!!c,[h,p]=u.useState(null),{data:g,isLoading:v,error:b}=ze({queryKey:["/api/edge-pricing"],enabled:!!s,retry:!1}),{data:y}=ze({queryKey:["/api/user/role"],enabled:!!s,retry:!1}),w=y?.role==="superadmin",j=y?.role==="admin",x=w||j,{data:C}=ze({queryKey:["/api/admin/resellers"],enabled:!!s&&w,retry:!1}),{data:k}=ze({queryKey:["/api/distributors"],enabled:!!s&&w,retry:!1}),[S,_]=u.useState(null),A=w?S:s?.id??null,{data:T}=ze({queryKey:["/api/admin/resellers",A,"effective-markup"],queryFn:async()=>{const ne=await fetch(`/api/admin/resellers/${A}/effective-markup`,{credentials:"include",cache:"no-store"});if(!ne.ok)throw new Error("Failed to load markup");return ne.json()},enabled:!!A,retry:!1}),{data:M}=ze({queryKey:["/api/user/business-info"],enabled:!!s,retry:!1}),[R,D]=u.useState(1),[$,O]=u.useState(lW),[q,V]=u.useState(!1),{data:K}=ze({queryKey:["/api/edge-quotes",c],enabled:!!c&&!!s,retry:!1});u.useEffect(()=>{if(!K||q)return;const ne=K,De=(Array.isArray(ne.lineItems)?ne.lineItems:[]).find(Ct=>Ct.kind==="promo"),jt=De?/Hardware/i.test(De.label)?"hardware":/Subscription/i.test(De.label)?"subscription":"both":"";O({projectName:ne.projectName??"",businessName:ne.businessName??"",customerName:ne.customerName??"",customerEmail:ne.customerEmail??"",cameraCount:ne.cameraCount??8,storageType:ne.storageType??"cloud",resolutionTier:ne.resolutionTier==="2mp"?"eco":ne.resolutionTier??"standard",recordingMode:ne.recordingMode??"motion",cloudRetention:ne.cloudRetentionDays??30,localRetentionDays:ne.localRetentionDays??30,remoteMonitoring:!!ne.remoteMonitoring,smartAlerts:!!ne.smartAlerts,smartAlertsCameraCount:ne.smartAlertsCameraCount??ne.cameraCount??8,discountPercent:ne.discountPercent??0,discountScope:ne.discountScope&&ne.discountScope!=="none"?ne.discountScope:"both",promoCode:ne.promoCode??"",promoPercent:ne.promoDiscountPercent??0,promoScope:jt,billingFrequency:ne.billingFrequency??"monthly",msrpEnabled:!!ne.msrpEnabled,msrpHardwareMarkupPercent:ne.msrpHardwareMarkupPercent??50,msrpSubscriptionMarkupPercent:ne.msrpSubscriptionMarkupPercent??100,currency:ne.currency??"USD",shipCountry:ne.shipCountry??"",shipPostalCode:ne.shipPostalCode??"",shipService:ne.shipService??"03",shipBusinessName:ne.shipBusinessName??"",shipAttnName:ne.shipAttnName??"",shipAddress1:ne.shipAddress1??"",shipAddress2:ne.shipAddress2??"",shipCity:ne.shipCity??"",shipState:ne.shipState??"",shippingAmountOverride:typeof ne.shippingAmountOverride=="number"?ne.shippingAmountOverride:null,shippingOverrideReason:ne.shippingOverrideReason??"",savedShippingUsd:typeof ne.shippingAmount=="number"?ne.shippingAmount:null,savedShippingKey:`${ne.shipCountry??""}|${ne.shipPostalCode??""}|${ne.shipService??"03"}|${ne.cameraCount}|${ne.storageType}`,savedFxRate:typeof ne.fxRate=="number"?ne.fxRate:null,savedFxCurrency:ne.currency?ne.currency:null,isLegacyRecord:!ne.shipCountry&&!ne.shipPostalCode}),V(!0)},[K,q]),u.useEffect(()=>{!s||!y||x||O(ne=>{const Oe={...ne},De=`${s.firstName??""} ${s.lastName??""}`.trim();return!ne.shipPostalCode&&M?.zip&&(Oe.shipPostalCode=M.zip),(!ne.shipCountry||ne.shipCountry==="US")&&M?.country&&(Oe.shipCountry=M.country),!ne.shipBusinessName&&M?.businessName&&(Oe.shipBusinessName=M.businessName),!ne.shipAttnName&&De&&(Oe.shipAttnName=De),!ne.shipAddress1&&M?.address&&(Oe.shipAddress1=M.address),!ne.shipCity&&M?.city&&(Oe.shipCity=M.city),!ne.shipState&&M?.state&&(Oe.shipState=M.state),Oe})},[s,y,w,M]);const G=g?.pricing??ete,z=MSe($.cameraCount,$.storageType,$.resolutionTier),{data:Z}=ze({queryKey:["/api/fx-rates"],enabled:!!s,staleTime:3600*1e3}),ee=$.currency==="USD"?1:$.savedFxRate!=null&&$.savedFxCurrency===$.currency?$.savedFxRate:Z?.rates?.[$.currency]??NSe[$.currency]??1,Q=ne=>kx(ne,$.currency,ee),Y=u.useRef(null),oe=u.useRef(null);u.useEffect(()=>{if(!w||d||S||!C||C.length===0)return;const ne=($.customerEmail||"").trim().toLowerCase();if(!ne||oe.current===ne)return;const Oe=C.find(De=>(De.user?.email??De.email??"").trim().toLowerCase()===ne);
587Oe&&(oe.current=ne,Y.current=null,_(Oe.userId))},[w,d,S,$.customerEmail,C]);const he=($.cameraCount??0)>0,[je,pe]=u.useState($.shipCountry),[le,ue]=u.useState($.shipPostalCode);u.useEffect(()=>{const ne=setTimeout(()=>{pe($.shipCountry),ue($.shipPostalCode)},350);return()=>clearTimeout(ne)},[$.shipCountry,$.shipPostalCode]);const fe=!!s&&he&&(je||"").length===2&&(le||"").trim().length>=3&&$.shippingAmountOverride===null,{data:H,isFetching:se}=ze({queryKey:["/api/shipping/quote",je,le,$.shipService,$.shipState],enabled:fe,staleTime:300*1e3,retry:!1,queryFn:async()=>(await Ze("POST","/api/shipping/quote",{country:$.shipCountry,postalCode:$.shipPostalCode,service:$.shipService,stateProvince:$.shipState})).json()}),me=`${$.shipCountry}|${$.shipPostalCode}|${$.shipService}|${$.cameraCount}|${$.storageType}`,ge=H&&!("error"in H)&&typeof H.amount=="number"?H.amount:null,ce=!!$.savedShippingKey&&$.savedShippingKey===me&&$.savedShippingUsd!=null?$.savedShippingUsd:ge,Pe=u.useMemo(()=>d?{hardwarePercent:K?.distributorHardwareMarkupPercent??0,subscriptionPercent:K?.distributorSubscriptionMarkupPercent??0}:T&&T.source!=="none"?{hardwarePercent:T.hardwarePercent??0,subscriptionPercent:T.subscriptionPercent??0}:{hardwarePercent:0,subscriptionPercent:0},[d,K,T]),et=u.useMemo(()=>{if(!$.cameraCount||$.cameraCount<1)return null;try{return LF(cW($,ce,null,Pe),G,{productName:n.productName})}catch{return null}},[$,G,ce,Pe,n.productName]),$e=async()=>{const ne=cW($,ce,w?S:null,Pe),Oe=c??h;if(Oe){const Ct=LF(ne,G,{productName:n.productName}),Lt={projectName:ne.projectName,businessName:ne.businessName??null,customerName:ne.customerName??null,customerEmail:ne.customerEmail??null,cameraCount:ne.cameraCount,storageType:ne.storageType,resolutionTier:ne.resolutionTier??null,recordingMode:ne.recordingMode??null,cloudRetentionDays:ne.cloudRetention??null,localRetentionDays:ne.localRetentionDays??null,remoteMonitoring:!!ne.remoteMonitoring,discountPercent:ne.discountPercent??0,discountScope:ne.discountScope??"none",promoCode:ne.promoCode??null,promoDiscountPercent:ne.promoDiscountPercent??null,billingFrequency:ne.billingFrequency??"monthly",msrpEnabled:!!ne.msrpEnabled,msrpHardwareMarkupPercent:ne.msrpEnabled?ne.msrpHardwareMarkupPercent??50:50,msrpSubscriptionMarkupPercent:ne.msrpEnabled?ne.msrpSubscriptionMarkupPercent??100:100,currency:ne.currency??"USD",shipCountry:ne.shipCountry??null,shipPostalCode:ne.shipPostalCode??null,shipService:ne.shipService??null,shippingAmount:typeof ne.shippingAmount=="number"?ne.shippingAmount:null,shippingAmountOverride:typeof ne.shippingAmountOverride=="number"?ne.shippingAmountOverride:null,shippingOverrideReason:ne.shippingOverrideReason??null,lineItems:Ct.lineItems,oneTimeTotal:Ct.oneTimeTotal,monthlyTotal:Ct.monthlyTotal};return(await Ze("PATCH",`/api/sales-orders/${Oe}`,Lt)).json()}const jt=await(await Ze("POST","/api/edge-quotes",ne)).json();return jt?.id&&p(jt.id),jt},bt=Et({mutationFn:$e,onSuccess:()=>{if(Je.invalidateQueries({queryKey:["/api/edge-quotes"]}),Je.invalidateQueries({queryKey:["/api/sales-orders"]}),d){r({title:"Order updated",description:"The revised quote has been saved."}),e("/admin?tab=sales-orders");return}r({title:"Quote saved",description:"It's now in Sales Orders under Admin Control."}),_(null),Y.current=null,oe.current=null,p(null),O({...lW}),D(1)},onError:ne=>r({title:"Failed to save quote",description:ne.message,variant:"destructive"})}),[Ae,Be]=u.useState(!1),J=async()=>{if(!et||Ae)return;const ne=window.open("","_blank");Be(!0);try{const Oe=await $e();Je.invalidateQueries({queryKey:["/api/edge-quotes"]}),Je.invalidateQueries({queryKey:["/api/sales-orders"]});const De=`/api/sales-orders/${Oe.id}/pdf`;ne?ne.location.href=De:window.location.href=De,r({title:d?"Quote updated":"Quote saved",description:"Opening PDF…"})}catch(Oe){ne&&ne.close(),r({title:"Failed to generate PDF",description:Oe?.message||String(Oe),variant:"destructive"})}finally{Be(!1)}},[ae,we]=u.useState({open:!1,orderId:null}),[Qe,ye]=u.useState(""),[te,Ue]=u.useState(!1),[We,St]=u.useState(!1),[It,ns]=u.useState(""),[dt,Qt]=u.useState(!1),Re=async()=>
587{if(!(!et||dt)){Qt(!0);try{const ne=await $e();Je.invalidateQueries({queryKey:["/api/edge-quotes"]}),Je.invalidateQueries({queryKey:["/api/sales-orders"]}),ye($.customerEmail||ne.customerEmail||""),ns(""),we({open:!0,orderId:ne.id})}catch(ne){r({title:"Failed to save quote",description:ne?.message||String(ne),variant:"destructive"})}finally{Qt(!1)}}},pt=Et({mutationFn:async()=>{if(!ae.orderId)throw new Error("No order to email");return(await Ze("POST",`/api/sales-orders/${ae.orderId}/email`,{to:Qe,message:It})).json()},onSuccess:()=>{Je.invalidateQueries({queryKey:["/api/sales-orders"]}),we({open:!1,orderId:null}),ns(""),r({title:"Quote emailed",description:`Sent to ${Qe}`})},onError:ne=>r({title:"Failed to send email",description:ne.message,variant:"destructive"})}),Ft=Et({mutationFn:async ne=>(await Ze("POST","/api/promo-codes/validate",{code:ne})).json(),onSuccess:ne=>{ne.ok?(O(Oe=>({...Oe,promoPercent:ne.percent,promoScope:ne.scope})),r({title:"Promo applied",description:`${ne.percent}% off (${ne.scope})`})):(O(Oe=>({...Oe,promoPercent:0,promoScope:""})),r({title:ne.reason==="expired"?"Promo expired":"Promo not found",description:"That code can't be applied.",variant:"destructive"}))},onError:ne=>r({title:"Failed to validate promo",description:ne.message,variant:"destructive"})});if(!s)return t.jsx(dW,{});if(v)return t.jsxs("div",{className:"min-h-screen bg-background pt-24 px-4 max-w-3xl mx-auto space-y-3",children:[t.jsx(Bt,{className:"h-10 w-48"}),t.jsx(Bt,{className:"h-32 w-full"}),t.jsx(Bt,{className:"h-64 w-full"})]});if(b)return t.jsx(dW,{});const Ge=!!et?.lineItems?.some(ne=>ne.kind==="hardware"||ne.kind==="local_storage")||($.cameraCount??0)>0,ft=$.isLegacyRecord&&!$.shipCountry&&!$.shipPostalCode,He=PSe($.shipCountry),zt=kSe($.shipCountry),fs=!Ge||ft||($.shipCountry||"").length===2&&($.shipPostalCode||"").trim().length>=3&&($.shipBusinessName||"").trim().length>0&&($.shipAttnName||"").trim().length>0&&($.shipAddress1||"").trim().length>0&&($.shipCity||"").trim().length>0&&(!He.required||($.shipState||"").trim().length>0),Ce=$.projectName.trim().length>0,Dt=!1;return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"sticky top-0 z-40 backdrop-blur-md bg-background/80 border-b border-border",children:t.jsx("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 py-3 flex items-center justify-between gap-3",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>e("/"),"data-testid":"button-quote-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsx(no,{className:"w-5 h-5 text-primary"}),t.jsxs("h1",{className:"text-lg font-semibold","data-testid":"text-quote-page-title",children:[n.productName," — ",a(d?"header.reviseTitle":"header.newTitle"),d&&K?.orderNumber?t.jsx("span",{className:"ml-2 text-sm text-muted-foreground font-normal",children:K.orderNumber}):null]})]})})}),t.jsxs("main",{className:"max-w-6xl mx-auto px-4 sm:px-6 py-6 grid lg:grid-cols-3 gap-6",children:[t.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[t.jsx("div",{className:"flex items-center gap-2 text-sm",children:[1,2,3].map(ne=>{const Oe=ne,De=Oe===1||Oe===2&&Ce||Oe===3&&Ce;return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>De&&D(Oe),disabled:!De,className:`flex items-center gap-2 rounded-md px-1 py-0.5 ${De?"cursor-pointer hover-elevate active-elevate-2":"cursor-not-allowed opacity-70"}`,"data-testid":`step-button-${ne}`,children:[t.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center text-xs font-semibold ${R>=Oe?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,"data-testid":`step-indicator-${ne}`,children:R>Oe?t.jsx(Hd,{className:"w-3.5 h-3.5"}):ne}),t.jsx("span",{className:R===Oe?"font-medium":"text-muted-foreground",children:i("steps.labels")[ne-1]??""})]}),ne<3&&t.jsx("div",{className:"w-6 h-px bg-border mx-1"})]},ne)})}),R===1&&t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{children:a("step1.title")}),t.jsx(Xs,{children:a("step1.descriptionEditable")})]}),t.jsxs(mt,{className:"space-y-4",children:[t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"project-name",children:[a("step1.locationNameLabel")," ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"project-name",value:$.projectName,onChange:ne=>O(Oe=>({...Oe,projectName:ne.target.value})),placeholder:a("step1.locationNamePlaceholder"),"data-testid":"input-project-name"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"business-name",children:[a("step1.businessNameLabel")," ",Dt]}),t.jsx(ke,{id:"business-name",value:$.businessName,onChange:ne=>O(Oe=>({...Oe,businessName:ne.target.value})),placeholder:a("step1.businessNamePlaceholder"),readOnly:Dt,disabled:Dt,"data-testid":"input-business-name"})]})]}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"customer-name",children:[a("step1.customerNameLabel")," ",Dt]}),t.jsx(ke,{id:"customer-name",value:$.customerName,onChange:ne=>O(Oe=>({...Oe,customerName:ne.target.value})),placeholder:a("step1.customerNamePlaceholder"),readOnly:Dt,disabled:Dt,"data-testid":"input-customer-name"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"customer-email",children:[a("step1.customerEmailLabel")," ",Dt]}),t.jsx(ke,{id:"customer-email",type:"email",value:$.customerEmail,onChange:ne=>O(Oe=>({...Oe,customerEmail:ne.target.value})),placeholder:a("step1.customerEmailPlaceholder"),readOnly:Dt,disabled:Dt,"data-testid":"input-customer-email"})]})]}),w&&!d&&C&&C.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"quote-customer-select",children:a("step1.existingCustomerLabel")}),t.jsxs(Us,{value:S??void 0,onValueChange:ne=>{const Oe=C.find(jt=>jt.userId===ne);if(!Oe)return;const De=`${Oe.user?.firstName??""} ${Oe.user?.lastName??""}`.trim()||(Oe.contactName??"");Y.current=null,oe.current=(Oe.user?.email??Oe.email??"").trim().toLowerCase()||null,_(Oe.userId),O(jt=>({...jt,shipBusinessName:Oe.businessName??jt.shipBusinessName,shipAttnName:De||jt.shipAttnName,shipAddress1:Oe.address??jt.shipAddress1,shipCity:Oe.city??jt.shipCity,shipState:Oe.state??jt.shipState,shipPostalCode:Oe.zip??jt.shipPostalCode,businessName:Oe.businessName??jt.businessName,customerName:De||jt.customerName,customerEmail:Oe.user?.email??Oe.email??jt.customerEmail}))},children:[t.jsx($s,{id:"quote-customer-select","data-testid":"select-quote-customer",children:t.jsx(zs,{placeholder:a("step1.existingCustomerPlaceholder")})}),t.jsx(Fs,{children:[...C].sort((ne,Oe)=>zi(ne.businessName||ne.contactName||ne.user?.email||ne.userId,Oe.businessName||Oe.contactName||Oe.user?.email||Oe.userId)
587).map(ne=>t.jsx(rt,{value:ne.userId,children:ne.businessName||ne.contactName||ne.user?.email||ne.userId},ne.userId))})]}),S&&T&&T.source!=="none"&&t.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"text-step1-markup-applied",children:T.source==="override"?a("step1.perCustomerMarkupApplied"):`${a("step1.distributorMarkupApplied")}${T.distributorName?` (${T.distributorName})`:""}`}),S&&T&&T.source==="none"&&t.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"text-step1-no-markup",children:a("step1.noMarkupConfigured")})]}),t.jsxs("div",{className:"space-y-1.5 max-w-xs",children:[t.jsx(re,{htmlFor:"currency-select",children:a("step1.currencyLabel")}),t.jsxs(Us,{value:$.currency,onValueChange:ne=>O(Oe=>({...Oe,currency:ne})),children:[t.jsx($s,{id:"currency-select","data-testid":"select-currency",children:t.jsx(zs,{})}),t.jsx(Fs,{children:wSe.map(ne=>t.jsx(rt,{value:ne,"data-testid":`option-currency-${ne}`,children:ne},ne))})]}),$.currency!=="USD"&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:["FX 1 USD ≈ ",ee.toFixed(4)," ",$.currency,Z?.asOf?` (as of ${new Date(Z.asOf).toLocaleDateString()})`:""]})]}),t.jsx("div",{className:"flex justify-end pt-2",children:t.jsxs(L,{onClick:()=>D(2),disabled:!Ce,"data-testid":"button-step-next-1",children:[a("step1.nextButton")," ",t.jsx(N0,{className:"w-4 h-4 ml-1"})]})})]})]}),R===2&&t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{children:a("step2.title")}),t.jsx(Xs,{children:a("step2.description")})]}),t.jsxs(mt,{className:"space-y-5",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(re,{htmlFor:"camera-count-s2",className:"whitespace-nowrap text-sm",children:a("step2.cameraCountLabel")}),t.jsx(ke,{id:"camera-count-s2",type:"number",min:1,value:$.cameraCount,onChange:ne=>O(Oe=>{const De=Math.max(1,parseInt(ne.target.value||"0",10)||0);return{...Oe,cameraCount:De,smartAlertsCameraCount:Math.min(Oe.smartAlertsCameraCount,De)}}),className:"w-28","data-testid":"input-camera-count-s2"})]}),t.jsxs("div",{className:"space-y-2 pt-1 border-t",children:[t.jsx(re,{className:"pt-3 block",children:a("step2.retentionTypeLabel")}),t.jsxs(b0,{value:$.storageType,onValueChange:ne=>O(Oe=>({...Oe,storageType:ne,remoteMonitoring:ne==="local"?Oe.remoteMonitoring:!1})),className:"grid sm:grid-cols-3 gap-3",children:[t.jsxs(re,{className:"border rounded-lg p-3 cursor-pointer flex items-start gap-3 hover-elevate active-elevate-2 [&:has([data-state=checked])]:border-primary [&:has([data-state=checked])]:bg-primary/5","data-testid":"radio-storage-cloud",children:[t.jsx(Gh,{value:"cloud"}),t.jsxs("div",{children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsx(pn,{className:"w-4 h-4"})," ",o("step2.storageOptions")[0]?.[0]??""]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o("step2.storageOptions")[0]?.[1]??""})]})]}),t.jsxs(re,{className:"border rounded-lg p-3 cursor-pointer flex items-start gap-3 hover-elevate active-elevate-2 [&:has([data-state=checked])]:border-primary [&:has([data-state=checked])]:bg-primary/5","data-testid":"radio-storage-local",children:[t.jsx(Gh,{value:"local"}),t.jsxs("div",{children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsx(Wx,{className:"w-4 h-4"})," ",o("step2.storageOptions")[1]?.[0]??""]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o("step2.storageOptions")[1]?.[1]??""})]})]}),t.jsxs(re,{className:"border rounded-lg p-3 cursor-pointer flex items-start gap-3 hover-elevate active-elevate-2 [&:has([data-state=checked])]:border-primary [&:has([data-state=checked])]:bg-primary/5","data-testid":"radio-storage-hybrid",children:[t.jsx(Gh,{value:"hybrid"}),t.jsxs("div",{children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsx(Wx,{className:"w-4 h-4"}),t.jsx(pn,{className:"w-4 h-4"})," ",o("step2.storageOptions")[2]?.[0]??""]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o("step2.storageOptions")[2]?.[1]??""})]})]})]})]}),$.storageType==="local"&&t.jsx(ut,{className:"border-primary/40 bg-primary/5",children:t.jsx(mt,{className:"pt-4 space-y-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-sm",children:a("step2.remoteMonitoringTitle")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:a("step2.remoteMonitoringDescription").replace("{rate}",Q(G.plusPlanRate))})]}),t.jsx(sr,{checked:$.remoteMonitoring,onCheckedChange:ne=>O(Oe=>({...Oe,remoteMonitoring:ne})),"data-testid":"switch-remote-monitoring"})]})})}),t.jsx(ut,{className:"border-primary/40 bg-primary/5",children:t.jsxs(mt,{className:"pt-4 space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-sm",children:a("step2.smartAlertsTitle")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:a("step2.smartAlertsDescription").replace("{rate}",Q(G.smartAlertsRate??9.99))})]}),t.jsx(sr,{checked:$.smartAlerts,onCheckedChange:ne=>O(Oe=>({...Oe,smartAlerts:ne,smartAlertsCameraCount:ne?Oe.cameraCount:Oe.smartAlertsCameraCount})),"data-testid":"switch-smart-alerts"})]}),$.smartAlerts&&t.jsxs("div",{className:"flex items-center gap-3 pt-1 border-t border-border",children:[t.jsx(re,{htmlFor:"smart-alerts-cam-count",className:"whitespace-nowrap text-sm text-muted-foreground",children:a("step2.smartAlertsCamerasLabel")}),t.jsx(ke,{id:"smart-alerts-cam-count",type:"number",min:1,max:$.cameraCount,value:$.smartAlertsCameraCount,onChange:ne=>O(Oe=>({...Oe,smartAlertsCameraCount:Math.max(1,Math.min(Oe.cameraCount,parseInt(ne.target.value||"1",10)||1))})),className:"w-24","data-testid":"input-smart-alerts-camera-count"}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[a("step2.smartAlertsOfPrefix")," ",$.cameraCount]})]})]})}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:a("step2.resolutionTierLabel")}),t.jsx(b0,{value:$.resolutionTier,onValueChange:ne=>O(Oe=>({...Oe,resolutionTier:ne}
587)),className:"grid sm:grid-cols-2 lg:grid-cols-5 gap-3",children:v_.map(({tier:ne},Oe)=>t.jsxs(re,{className:"border rounded-lg p-3 cursor-pointer flex items-center gap-3 hover-elevate active-elevate-2 [&:has([data-state=checked])]:border-primary [&:has([data-state=checked])]:bg-primary/5","data-testid":`radio-resolution-${ne}`,children:[t.jsx(Gh,{value:ne}),t.jsx("div",{children:t.jsx("div",{className:"font-medium text-sm",children:l[Oe][0]})})]},ne))}),t.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300 mt-2","data-testid":"text-resolution-fallback-notice",children:a("step2.resolutionFallbackNotice")})]}),z!==null&&t.jsxs("div",{className:"relative overflow-hidden rounded-xl border-2 border-primary/60 bg-gradient-to-br from-primary/15 via-primary/8 to-background p-5 shadow-md","data-testid":"upload-bandwidth-recommendation",children:[t.jsx("div",{className:"absolute inset-y-0 left-0 w-1.5 bg-primary","aria-hidden":"true"}),t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"rounded-full bg-primary p-2.5 text-primary-foreground shadow-sm",children:t.jsx(vc,{className:"h-5 w-5","aria-hidden":"true"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-semibold text-sm text-foreground",children:a("step2.uploadBandwidthTitle")}),t.jsxs("div",{className:"mt-1 flex items-baseline gap-2",children:[t.jsx("span",{className:"text-3xl font-bold tracking-tight text-primary","data-testid":"upload-bandwidth-total",children:z}),t.jsx("span",{className:"text-base font-semibold text-foreground",children:a("step2.uploadBandwidthUnit")})]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:a("step2.uploadBandwidthDescription").replace("{total}",String(z)).replace("{rate}",String(kM[$.resolutionTier])).replace("{cameraCount}",String($.cameraCount))})]})]})]}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:a("step2.recordingModeLabel")}),t.jsxs(Us,{value:$.recordingMode,onValueChange:ne=>O(Oe=>({...Oe,recordingMode:ne})),children:[t.jsx($s,{"data-testid":"select-recording-mode",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"motion",children:a("step2.recordingModeMotion")}),t.jsx(rt,{value:"247",children:a("step2.recordingMode247")})]})]}),$.storageType==="local"&&t.jsx("p",{className:"text-xs text-muted-foreground",children:a("step2.recordingModeLocalNote")})]}),($.storageType==="cloud"||$.storageType==="hybrid")&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:a("step2.cloudRetentionLabel")}),t.jsxs(Us,{value:String($.cloudRetention),onValueChange:ne=>O(Oe=>({...Oe,cloudRetention:Number(ne)})),children:[t.jsx($s,{"data-testid":"select-cloud-retention",children:t.jsx(zs,{})}),t.jsx(Fs,{children:Jee.map(ne=>t.jsx(rt,{value:String(ne.value),children:ne.label},ne.value))})]})]})]}),($.storageType==="local"||$.storageType==="hybrid")&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"local-retention",children:a("step2.localRetentionLabel")}),t.jsx(ke,{id:"local-retention",type:"number",min:1,max:3650,value:$.localRetentionDays,onChange:ne=>O(Oe=>({...Oe,localRetentionDays:Math.max(1,Math.min(3650,parseInt(ne.target.value||"30",10)||30))})),"data-testid":"input-local-retention"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:$.storageType==="hybrid"?a("step2.localRetentionHybridNote"):a("step2.localRetentionNote")})]}),t.jsxs("div",{className:"flex justify-between pt-2",children:[t.jsxs(L,{variant:"ghost",onClick:()=>D(1),"data-testid":"button-step-back-2",children:[t.jsx(Wi,{className:"w-4 h-4 mr-1"})," ",a("step2.backButton")]}),t.jsxs(L,{onClick:()=>D(3),"data-testid":"button-step-next-2",children:[a("step2.nextButton")," ",t.jsx(N0,{className:"w-4 h-4 ml-1"})]})]})]})]}),R===3&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs(ut,{children:[t.jsx(xs,{role:"button",tabIndex:0,onClick:()=>Ue(ne=>!ne),onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),Ue(Oe=>!Oe))},className:"cursor-pointer select-none hover-elevate active-elevate-2 roun
587ded-t-md","data-testid":"header-discounts-toggle",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(Ode,{className:"w-4 h-4 text-primary"})," ",a("step3.discountsTitle")]}),t.jsx(Xs,{children:a("step3.discountsDescription")})]}),te?t.jsx(Xa,{className:"w-5 h-5 text-muted-foreground shrink-0 mt-1"}):t.jsx(hi,{className:"w-5 h-5 text-muted-foreground shrink-0 mt-1"})]})}),te&&t.jsxs(mt,{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"promo-code",children:a("step3.promoCodeLabel")}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ke,{id:"promo-code",value:$.promoCode,onChange:ne=>O(Oe=>({...Oe,promoCode:ne.target.value.toUpperCase(),promoPercent:0,promoScope:""})),placeholder:a("step3.promoCodePlaceholder"),"data-testid":"input-promo-code"}),t.jsx(L,{onClick:()=>Ft.mutate($.promoCode.trim()),disabled:!$.promoCode.trim()||Ft.isPending,"data-testid":"button-promo-apply",children:Ft.isPending?t.jsx(Fe,{className:"w-4 h-4 animate-spin"}):a("step3.promoApplyButton")})]}),$.promoPercent>0&&$.promoScope&&t.jsxs(Ke,{className:"bg-primary/15 text-primary border-primary/30 mt-1","data-testid":"badge-promo-applied",children:[$.promoPercent,"% off — ",$.promoScope]})]}),T&&T.source!=="none"&&!j&&t.jsxs("div",{className:"space-y-1 pt-3 border-t border-border rounded-md","data-testid":"section-distributor-markup",children:[t.jsx(re,{className:"text-sm font-medium",children:a("step3.distributorMarkupLabel")}),t.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"text-distributor-markup-source",children:[T.source==="override"?a("step3.perCustomerMarkupAuto"):`${a("step3.distributorMarkupAuto")}${T.distributorName?` (${T.distributorName})`:""}`,` — hardware +${T.hardwarePercent}%, subscription +${T.subscriptionPercent}%`]})]}),t.jsxs("div",{className:"space-y-3 pt-3 border-t border-border","data-testid":"section-msrp",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsx(re,{htmlFor:"msrp-toggle",className:"text-sm font-medium",children:a("step3.msrpLabel")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:a("step3.msrpDescription")})]}),t.jsx(sr,{id:"msrp-toggle",checked:$.msrpEnabled,onCheckedChange:ne=>O(Oe=>({...Oe,msrpEnabled:!!ne})),"data-testid":"switch-msrp-enabled"})]}),$.msrpEnabled&&t.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"msrp-hw-markup",children:a("step3.msrpHardwareLabel")}),t.jsx(ke,{id:"msrp-hw-markup",type:"number",min:0,max:500,value:$.msrpHardwareMarkupPercent,onChange:ne=>O(Oe=>({...Oe,msrpHardwareMarkupPercent:Math.max(0,Math.min(500,parseFloat(ne.target.value||"0")||0))})),"data-testid":"input-msrp-hardware-markup"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"msrp-sub-markup",children:a("step3.msrpSubscriptionLabel")}),t.jsx(ke,{id:"msrp-sub-markup",type:"number",min:0,max:500,value:$.msrpSubscriptionMarkupPercent,onChange:ne=>O(Oe=>({...Oe,msrpSubscriptionMarkupPercent:Math.max(0,Math.min(500,parseFloat(ne.target.value||"0")||0))})),"data-testid":"input-msrp-subscription-markup"})]})]})]}),w&&t.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 pt-2 border-t border-border",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"discount-percent",children:a("step3.discountPercentLabel")}),t.jsx(ke,{id:"discount-percent",type:"number",min:0,max:100,value:$.discountPercent,onChange:ne=>O(Oe=>({...Oe,discountPercent:Math.max(0,Math.min(100,parseFloat(ne.target.value||"0")||0))})),"data-testid":"input-discount-percent"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{children:a("step3.discountScopeLabel")}),t.jsxs(Us,{value:$.discountScope,onValueChange:ne=>O(Oe=>({...Oe,discountScope:ne})),children:[t.jsx($s,{"data-testid":"select-discount-scope",children:t.jsx(zs,{})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"hardware",children:a("step3.scopeHardware")}),t.jsx(rt,{value:"subscription",children:a("step3.scopeSubscription")}),t.jsx(rt,{value:"both",children:a("step3.scopeBoth")})]})]})]})]})]})]}
587),w&&Ge&&t.jsxs(ut,{"data-testid":"card-shipping-override",children:[t.jsx(xs,{role:"button",tabIndex:0,onClick:()=>St(ne=>!ne),onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&(ne.preventDefault(),St(Oe=>!Oe))},className:"cursor-pointer select-none hover-elevate active-elevate-2 rounded-t-md","data-testid":"header-shipping-override-toggle",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{children:[t.jsx(ys,{children:a("shipOverride.title")}),t.jsxs(Xs,{children:["Manually set the shipping amount in ",$.currency," (overrides UPS rate and free-shipping rule).",$.currency!=="USD"&&t.jsxs("span",{className:"block text-xs mt-1",children:["Stored internally in USD using current FX rate (",ee.toFixed(4)," ",$.currency,"/USD)."]})]})]}),We?t.jsx(Xa,{className:"w-5 h-5 text-muted-foreground shrink-0 mt-1"}):t.jsx(hi,{className:"w-5 h-5 text-muted-foreground shrink-0 mt-1"})]})}),We&&t.jsx(mt,{className:"space-y-3",children:t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"ship-override-amount",children:[a("shipOverride.amountLabel")," (",$.currency,")"]}),t.jsx(ke,{id:"ship-override-amount",type:"number",min:0,step:"0.01",value:$.shippingAmountOverride===null?"":String(($.shippingAmountOverride*ee).toFixed(2)),onChange:ne=>{const Oe=ne.target.value.trim(),De=Oe===""?null:Math.max(0,parseFloat(Oe)||0),jt=De===null?null:ee>0?De/ee:De;O(Ct=>({...Ct,shippingAmountOverride:jt}))},placeholder:a("shipOverride.amountPlaceholder"),"data-testid":"input-shipping-override-amount"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"ship-override-reason",children:a("shipOverride.reasonLabel")}),t.jsx(ke,{id:"ship-override-reason",value:$.shippingOverrideReason,onChange:ne=>O(Oe=>({...Oe,shippingOverrideReason:ne.target.value})),placeholder:a("shipOverride.reasonPlaceholder"),"data-testid":"input-shipping-override-reason"})]})]})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{children:a("shipping.title")}),t.jsx(Xs,{children:a("shipping.description")})]}),t.jsxs(mt,{className:"space-y-4",children:[Ge&&!ft&&t.jsxs("div",{className:"rounded-md border border-border p-4 space-y-3","data-testid":"section-review-shipping-address",children:[t.jsxs("div",{className:"space-y-0.5",children:[t.jsx("div",{className:"font-medium text-sm",children:a("shipping.addressTitle")}),t.jsx("p",{className:"text-xs text-muted-foreground",children:a(x?"shipping.addressDescriptionEditable":"shipping.addressDescriptionLocked")})]}),w&&C&&C.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"ship-reseller-select",children:a("shipping.loadFromCustomerLabel")}),t.jsxs(Us,{value:S??"",onValueChange:ne=>{const Oe=C.find(jt=>jt.userId===ne);if(!Oe)return;const De=`${Oe.user?.firstName??""} ${Oe.user?.lastName??""}`.trim()||(Oe.contactName??"");Y.current=null,oe.current=(Oe.user?.email??Oe.email??"").trim().toLowerCase()||null,_(Oe.userId),O(jt=>({...jt,shipBusinessName:Oe.businessName??jt.shipBusinessName,shipAttnName:De||jt.shipAttnName,shipAddress1:Oe.address??jt.shipAddress1,shipCity:Oe.city??jt.shipCity,shipState:Oe.state??jt.shipState,shipPostalCode:Oe.zip??jt.shipPostalCode,businessName:Oe.businessName??jt.businessName,customerName:De||jt.customerName,customerEmail:Oe.user?.email??Oe.email??jt.customerEmail}))},children:[t.jsx($s,{id:"ship-reseller-select","data-testid":"select-ship-reseller",children:t.jsx(zs,{placeholder:a("shipping.loadFromCustomerPlaceholder")})}),t.jsx(Fs,{children:[...C].filter(ne=>ne.businessName).sort((ne,Oe)=>zi(ne.businessName,Oe.businessName)).map(ne=>t.jsxs(rt,{value:ne.userId,"data-testid":`option-ship-reseller-${ne.userId}`,children:[ne.businessName,ne.user?.email?` — ${ne.user.email}`:""]},ne.userId))})]})]}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"ship-business-name",children:[a("shipping.businessNameLabel")," ",x&&t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"ship-business-name",value:$.shipBusinessName,onChange:ne=>O(Oe=>({...Oe,shipBusinessName:ne.target.value})),placeholder:a("shipping.businessNamePlaceholder"),disabled:!x,"data-testid":"input-ship-business-name"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"ship-attn-name",children:[a("shipping.attnNameLabel")," ",x&&t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"ship-attn-name",value:$.shipAttnName,onChange:ne=>O(Oe=>({...Oe,shipAttnName:ne.target.value})),placeholder:a("shipping.attnNamePlaceholder"),disabled:!x,"data-testid":"input-ship-attn-name"})]})]}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"ship-address1",children:[a("shipping.address1Label")," ",x&&t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"ship-address1",value:$.shipAddress1,onChange:ne=>O(Oe=>({...Oe,shipAddress1:ne.target.value})),placeholder:a("shipping.address1Placeholder"),disabled:!x,"data-testid":"input-ship-address1"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"ship-address2",children:a("shipping.address2Label")}),t.jsx(ke,{id:"ship-address2",value:$.shipAddress2,onChange:ne=>O(Oe=>({...Oe,shipAddress2:ne.target.value})),placeholder:a("shipping.address2Placeholder"),disabled:!x,"data-testid":"input-ship-address2"})]})]}),t.jsxs("div",{className:"grid sm:grid-cols-3 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"ship-city",children:[a("shipping.cityLabel")," ",x&&t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx(ke,{id:"ship-city",value:$.shipCity,onChange:ne=>O(Oe=>({...Oe,shipCity:ne.target.value})),placeholder:a("shipping.cityPlaceholder"),disabled:!x,"data-testid":"input-ship-city"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"ship-state",children:[He.label,He.required?"":a("shipping.stateOptionalSuffix"),x&&He.required&&t.jsx("span",{className:"text-destructive",children:" *"})]}),$.shipCountry==="US"?t.jsxs(Us,{value:oW.some(ne=>ne.code===$.shipState)?$.shipState:"",onValueChange:ne=>O(Oe=>({...Oe,shipState:ne})),disabled:!x,children:[t.jsx($s,{id:"ship-state","data-testid":"select-ship-state",children:t.jsx(zs,{placeholder:a("shipping.statePlaceholderUs")})}),t.jsx(Fs,{children:oW.map(ne=>t.jsx(rt,{value:ne.code,"data-testid":`option-ship-state-${ne.code}`,children:ne.name},ne.code))})]}):t.jsx(ke,{id:"ship-state",value:$.shipState,onChange:ne=>{const Oe=ne.target.value.slice(0,64);O(De=>({...De,shipState:He.uppercase?Oe.toUpperCase():Oe}))},placeholder:He.placeholder,disabled:!x,"data-testid":"input-ship-state"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"ship-postal",children:zt.label}),t.jsx(ke,{id:"ship-postal",value:$.shipPostalCode,onChange:ne=>O(Oe=>({...Oe,shipPostalCode:ne.target.value})),placeholder:zt.placeholder,disabled:!x,"data-testid":"input-ship-postal"})]})]}),t.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"ship-country",children:a("shipping.countryLabel")}),t.jsxs(Us,{value:RF.some(ne=>ne.code===$.shipCountry)?$.shipCountry:"US",onValueChange:ne=>O(Oe=>({...Oe,shipCountry:ne})),disabled:!x,children:[t.jsx($s,{id:"ship-country","data-testid":"select-ship-country",children:t.jsx(zs,{})}),t.jsx(Fs,{children:RF.map(ne=>t.jsxs(rt,{value:ne.code,"data-testid":`option-ship-country-${ne.code}`,children:[ne.code," — ",ne.label]},ne.code))})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"ship-service",children:a("shipping.serviceLabel")}),t.jsxs(Us,{value:$.shipService,onValueChange:ne=>O(Oe=>({...Oe,shipService:ne})),children:[t.jsx($s,{id:"ship-service","data-testid":"select-ship-service",children:t.jsx(zs,{})}),t.jsx(Fs,{children:tte.map(ne=>t.jsx(rt,{value:ne.value,"data-testid":`option-ship-service-${ne.value}`,children:ne.label},ne.value))})]})]})]}),!fs&&t.jsx("p",{className:"text-xs text-destructive","data-testid":"text-shipping-required",children:a("shipping.requiredError")})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(re,{children:a("billing.frequencyLabel")}),t.jsx(b0,{value:$.billingFrequency,onValueChange:ne=>O(Oe=>({...Oe,billingFrequency:ne})),className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[{value:"monthly",label:o("billing.frequencyOptions")[0]?.[0]??"",note:o("billing.frequencyOptions")[0]?.[1]??""},{value:"quarterly",label:o("billing.frequencyOptions")[1]?.[0]??"",note:o("billing.frequencyOptions")[1]?.[1]??""},{value:"annually",label:o("billing.frequencyOptions")[2]?.[0]??"",note:o("billing.frequencyOptions")[2]?.[1]??""}].map(ne=>t.jsxs(re,{htmlFor:`bf-${ne.value}`,className:`flex items-start gap-2 rounded-md border p-3 cursor-pointer hover-elevate active-elevate-2 ${$.billingFrequency===ne.value?"border-primary":"border-border"}`,"data-testid":`radio-billing-${ne.value}`,children:[t.jsx(Gh,{id:`bf-${ne.value}`,value:ne.value}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"text-sm font-medium",children:ne.label}),ne.note&&t.jsx("div",{className:"text-xs text-muted-foreground",children:ne.n
587ote})]})]},ne.value))})]})]})]}),t.jsxs(ut,{"data-testid":"card-billing-final-pricing",children:[t.jsxs(xs,{children:[t.jsx(ys,{children:a("finalPricing.title")}),t.jsx(Xs,{children:a("finalPricing.description")})]}),t.jsxs(mt,{className:"space-y-4",children:[t.jsx(uW,{result:et,billingFrequency:$.billingFrequency,showGrandTotal:!0,fmt:Q,currency:$.currency,fxRate:ee,fxAsOf:Z?.asOf,shipFetching:se,shipError:H&&"error"in H&&H.error?{error:H.error,message:H.message}:null}),t.jsxs("div",{className:"flex flex-wrap justify-between gap-2 pt-2",children:[t.jsxs(L,{variant:"ghost",onClick:()=>D(2),"data-testid":"button-step-back-3",children:[t.jsx(Wi,{className:"w-4 h-4 mr-1"})," ",a("finalPricing.backButton")]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs(L,{variant:"outline",onClick:J,disabled:Ae||bt.isPending||dt||!et,"data-testid":"button-view-pdf",children:[Ae?t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}):t.jsx(XI,{className:"w-4 h-4 mr-1"}),a("finalPricing.viewPdfButton")]}),t.jsxs(L,{variant:"outline",onClick:Re,disabled:dt||bt.isPending||Ae||!et,"data-testid":"button-email-quote",children:[dt?t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}):t.jsx(qi,{className:"w-4 h-4 mr-1"}),a("finalPricing.emailQuoteButton")]}),t.jsxs(L,{onClick:()=>bt.mutate(),disabled:bt.isPending||Ae||dt||!et,"data-testid":"button-save-quote",children:[bt.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}):t.jsx(Vl,{className:"w-4 h-4 mr-1"}),a(d?"finalPricing.updateButton":"finalPricing.saveButton")]})]})]})]})]})]})]}),t.jsx("aside",{className:"lg:sticky lg:top-20 self-start lg:mt-11",children:t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{className:"text-base","data-testid":"text-live-quote-title",children:a("liveQuote.title")}),t.jsx(Xs,{children:a("liveQuote.description")}),(()=>{if(!w)return null;const ne=d?K?.markupSource:void 0,Oe=d?K?.markupDistributorId:void 0;let De=null;if(d){const jt=K?.distributorHardwareMarkupPercent??0,Ct=K?.distributorSubscriptionMarkupPercent??0;if((jt>0||Ct>0)&&ne&&ne!=="manual"){let Lt;if(ne==="override")Lt="per-customer override";else{const xr=k?.find(qe=>qe.id===Oe)?.name;Lt=xr?`from ${xr}`:"from distributor"}De=`Distributor markup: ${jt}% HW / ${Ct}% Sub (${Lt})`}}else if(T&&T.source!=="none"){const jt=T.source==="override"?"per-customer override":T.distributorName?`from ${T.distributorName}`:"from distributor";De=`Distributor markup: ${T.hardwarePercent}% HW / ${T.subscriptionPercent}% Sub (${jt})`}return!De&&!$.msrpEnabled?null:t.jsxs("div",{className:"pt-1 space-y-0.5",children:[De&&t.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"text-live-distributor-caption",children:De}),$.msrpEnabled&&t.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"text-live-markup-caption",children:["MSRP markup: ",$.msrpHardwareMarkupPercent,"% HW / ",$.msrpSubscriptionMarkupPercent,"% Sub"]})]})})()]}),t.jsx(mt,{children:t.jsx(uW,{result:et,compact:!0,hideSubscriptions:R===1,fmt:Q,currency:$.currency,fxRate:ee,fxAsOf:Z?.asOf,shipFetching:se,shipError:H&&"error"in H&&H.error?{error:H.error,message:H.message}:null})})]})})]}),t.jsx(Ys,{open:ae.open,onOpenChange:ne=>{ne||we({open:!1,orderId:null})},children:t.jsxs(Ws,{className:"max-w-md",children:[t.jsxs(Zs,{children:[t.jsx(Ks,{children:a("email.title")}),t.jsx(cr,{children:a("email.description")})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"email-to",children:a("email.recipientLabel")}),t.jsx(ke,{id:"email-to",type:"email",value:Qe,onChange:ne=>ye(ne.target.value),placeholder:a("email.recipientPlaceholder"),"data-testid":"input-email-to"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(re,{htmlFor:"email-message",children:a("email.messageLabel")}),t.jsx(Nn,{id:"email-message",value:It,onChange:ne=>ns(ne.target.value),placeholder:a("email.messagePlaceholder"),rows:4,"data-testid":"textarea-email-message"})]})]}),t.jsxs(In,{children:[t.jsx(L,{variant:"outline",onClick:()=>we({open:!1,orderId:null}),"data-testid":"button-email-cancel",children:a("email.cancelButton")}),t.jsxs(L,{onClick:()=>pt.mutate(),disabled:pt.isPending||!Qe.trim(),"data-testid":"button-email-send",children:[pt.isPending?t.jsx(Fe,{className:"w-4 h-4 mr-1 animate-spin"}):t.jsx(qi,{className:"w-4 h-4 mr-1"}),a("email.sendButton")]})]})]})})]})}function uW({result:e,compact:s,hideSubscriptions:r,billingFrequency:n,showGrandTotal:a,fmt:i,currency:o,fxRate:l,fxAsOf:c,shipFetching:d,shipError:h}){const p=Er(),{t:g}=rn(y_),v=i;if(!e)return t.jsx("p",{className:"text-sm text-muted-foreground",children:g("review.emptyPrompt")});if(e.lineItems.length===0)return t.jsx("p",{className:"text-sm text-muted-foreground",children:g("review.noLineItems")});const b=e.lineItems,y=b.filter(D=>D.kind==="local_storage").reduce((D,$)=>D+$.qty,0),w=y>196,j=b.filter(D=>D.kind==="hardware"||D.kind==="local_storage"),x=b.filter(D=>D.kind==="cloud"||D.kind==="plus"||D.kind==="smart_alerts"),C=b.filter(D=>D.kind==="shipping"),k=b.filter(D=>D.kind==="discount"||D.kind==="promo"),S=n==="annually"?12:n==="quarterly"?3:1,_=n==="annually"?"year":n==="quarterly"?"quarter":"mo",A=` / ${_}`,T=j.reduce((D,$)=>D+$.subtotal,0),M=x.reduce((D,$)=>D+$.subtotal,0)*S,R=(D,$,O)=>{const q=D.recurring?D.subtotal*S:D.subtotal,V=D.recurring&&S>1?D.unitPrice*S:D.unitPrice,K=D.recurring&&S>1&&D.unit==="cam/mo"?`cam/${_}`:D.unit;return t.jsxs("div",{className:"py-2 flex items-start justify-between gap-3","data-testid":`line-item-${D.kind}-${$}`,children:[t.jsxs("div",{className:"min-w-0 flex items-start gap-2",children:[D.kind==="cloud"&&t.jsx(pn,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),D.kind==="plus"&&t.jsx(vc,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),D.kind==="smart_alerts"&&t.jsx(mi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),D.kind==="shipping"&&t.jsx(Dfe,{className:"h-4 w-4 mt-0.5 shrink-0",style:{color:"#642f00"}}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:`text-sm ${s?"":"font-medium"} truncate`,children:D.label}),D.kind!=="shipping"&&D.kind!=="discount"&&D.kind!=="promo"&&D.kind!=="local_storage"&&t.jsxs("div",{className:"text-xs text-muted-foreground",children:[D.qty," × ",v(V)," / ",K]})]})]}),t.jsx("div",{className:"text-right text-sm whitespace-nowrap",children:D.kind==="shipping"&&q===0&&/Free|Manual override/i.test(D.label)?t.jsx(Ke,{variant:"outline",className:"text-primary border-primary/40","data-testid":"badge-shipping-free",children:g("review.shippingFreeBadge")}):t.jsxs("div",{className:q<0?"font-medium text-primary":"font-medium",children:[q<0?"−":"",v(Math.abs(q)),D.recurring?O:""]})})]},`${D.kind}-${$}`)};return t.jsxs("div",{className:"space-y-4",children:[w&&t.jsxs("div",{className:"rounded-md border border-amber-500/40 bg-amber-50 dark:bg-amber-950/30 p-3 text-xs space-y-1","data-testid":"banner-enterprise-tier",children:[t.jsxs("div",{className:"font-semibold text-amber-900 dark:text-amber-200",children:[g("review.enterpriseTierTitle")," (",y.toFixed(1)," TB)"]}),t.jsxs("p",{className:"text-amber-900/80 dark:text-amber-200/80",children:[g("review.enterpriseTierBody"),t.jsx("a",{href:`mailto:${p.salesEmail}`,className:"underline font-medium",children:p.salesEmail}),g("review.enterpriseTierBodyAfter")]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-1",children:g("review.sectionHardware")}),j.length>0&&(()=>{const D=j.map(K=>K.label||"").join(" "),$=/4U Rackmount/i.test(D),O=!$&&/2U Rackmount/i.test(D),q=$?p.imgChassis4u||"/edge-chassis/4u.png":O?p.imgChassis2u||"/edge-chassis/2u.png":p.imgChassisNuc||"/edge-chassis/nuc.png",V=$?`${p.productName} 4U Rackmount`:O?`${p.productName} 2U Rackmount`:`${p.productName} Intel NUC`;return t.jsx("div",{className:"flex justify-start py-2",children:t.jsx("img",{src:q,alt:V,className:"max-h-20 object-contain",onError:K=>{K.currentTarget.src="/edge-chassis/nuc.png"},"data-testid":"img-chassis"})})})(),t.jsx("div",{className:"divide-y divide-border",children:j.length===0?t.jsx("p",{className:"text-xs text-muted-foreground py-2",children:g("review.noHardwareLineItems")}):j.map((D,$)=>R(D,$,""))}),j.length>0&&t.jsxs("div",{className:"flex justify-between text-xs pt-1.5 border-t border-border mt-1",children:[t.jsx("span",{className:"text-muted-foreground",children:g("review.subtotal")}),t.jsx("span",{className:"font-medium","data-testid":"text-subtotal-hardware",children:v(T)})]})]}),!r&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-1",children:g("review.sectionSubscriptions")}),t.jsx("div",{className:"divide-y divide-border",children:x.length===0?t.jsx("p",{className:"text-xs text-muted-foreground py-2",children:g("review.noSubscriptionLineItems")}):x.map((D,$)=>R(D,$,A))}),x.length>0&&t.jsxs("div",{className:"flex justify-between text-xs pt-1.5 border-t border-border mt-1",children:[t.jsx("span",{className:"text-muted-foreground",children:g("review.subtotal")}),t.jsxs("span",{className:"font-medium","data-testid":"text-subtotal-subscription",children:[v(M),A]})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-1",children:g("review.sectionShipping")}),t.jsx("div",{className:"divide-y divide-border",children:C.map((D,$)=>R(D,$,""))}),d&&t.jsx("p",{className:"text-xs text-muted-foreground pt-1","data-testid":"text-shipping-loading",children:g("review.shippingLoading")}),h&&t.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300 pt-1","data-testid":"text-shipping-error",children:h.error==="ups_not_configured"?g("review.shippingUpsUnconfigured"):h.message?`Shipping rate unavailable: ${h.message}`:`Shipping rate unavailable (${h.error}). Shown as estimate pending.`})]}),k.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-1",children:g("review.sectionAdjustments")}),t.jsx("div",{className:"divide-y divide-border",children:k.map((D,$)=>R(D,$,A))})]}),t.jsxs("div",{className:"border-t-2 border-border pt-3 space-y-1 text-sm",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-muted-foreground",children:g("review.oneTimeTotal")}),t.jsx("span",{className:"font-semibold","data-testid":"text-total-onetime",children:v(e.oneTimeTotal)})]}),!r&&t.jsxs("div",{className:"flex justify-between",children:[t.jsxs("span",{className:"text-muted-foreground",children:[g("review.recurringPrefix")," ",g(_==="mo"?"review.recurringMonthly":_==="quarter"?"review.recurringQuarterly":"review.recurringAnnually")]}),t.jsxs("span",{className:"font-semibold","data-testid":"text-total-monthly",children:[v(e.monthlyTotal*S),A]})]}),o!=="USD"&&t.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"text-fx-footer",children:["All amounts shown in ",o," at 1 USD ≈ ",l.toFixed(4)," ",o,c?` (as of ${new Date(c).toLocaleDateString()})`:"","."]}),a&&(()=>{const D=_==="mo"?"month":_,$=e.monthlyTotal*S,O=e.oneTimeTotal+$;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex justify-between pt-2 border-t border-border mt-2 text-base",children:[t.jsx("span",{className:"font-semibold",children:g("review.grandTotalLabel")}),t.jsx("span",{className:"font-bold text-primary","data-testid":"text-grand-total",children:v(O)})]}),t.jsxs("p",{className:"text-xs text-muted-foreground","data-testid":"text-grand-total-note",children:["Hardware ",v(e.oneTimeTotal)," + first ",D,"'s subscription ",v($),".",n==="annually"&&g("review.annualDiscountNote")]})]})})()]})]})}const mW={live_view:"Live view",playback:"Playback",ai_search:"AI search",device_change:"Device change",other:"Other"};function g5(e){if(!e)return"—";const s=new Date(e);
587return Number.isNaN(s.getTime())?e:s.toLocaleString()}function GVe(e){switch(e.toLowerCase()){case"active":return"bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-300";case"idle":return"bg-amber-100 text-amber-800 dark:bg-amber-950 dark:text-amber-300";default:return"bg-muted text-muted-foreground"}}function YVe({selected:e}){const[s,r]=u.useState("all"),[n,a]=u.useState("all"),i=ze({queryKey:["/api/audit/live"],queryFn:async()=>{const h=await fetch("/api/audit/live",{credentials:"include"});if(!h.ok)throw new Error(`Unable to load live sessions (${h.status})`);return h.json()},enabled:e,refetchInterval:e?5e3:!1,retry:1}),o=i.data?.sessions||[],l=u.useMemo(()=>{const h=new Map;return o.forEach(p=>h.set(p.userId,p)),Array.from(h.values())},[o]),c=u.useMemo(()=>Array.from(new Set(o.map(h=>h.category).filter(h=>!!h))).sort(),[o]),d=o.filter(h=>(s==="all"||h.userId===s)&&(n==="all"||h.category===n));return t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2 text-base",children:[t.jsx(vc,{className:"h-4 w-4 text-primary"})," Live Monitoring"]}),t.jsx(Xs,{children:"Current user activity, refreshed every five seconds while this tab is open."})]}),t.jsxs(mt,{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"live-user-filter",className:"text-xs",children:"User"}),t.jsxs(Us,{value:s,onValueChange:r,children:[t.jsx($s,{id:"live-user-filter","data-testid":"select-live-user",children:t.jsx(zs,{placeholder:"All users"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All users"}),l.map(h=>t.jsx(rt,{value:h.userId,children:h.name||h.email||h.userId},h.userId))]})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(re,{htmlFor:"live-category-filter",className:"text-xs",children:"Activity category"}),t.jsxs(Us,{value:n,onValueChange:a,children:[t.jsx($s,{id:"live-category-filter","data-testid":"select-live-category",children:t.jsx(zs,{placeholder:"All categories"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All categories"}),c.map(h=>t.jsx(rt,{value:h,children:mW[h]||h},h))]})]})]})]}),i.isLoading?t.jsxs("div",{className:"space-y-3","aria-label":"Loading live sessions",children:[t.jsx(Bt,{className:"h-10 w-full"}),t.jsx(Bt,{className:"h-12 w-full"})]}):i.isError?t.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-md border border-destructive/30 p-6 text-center",role:"alert",children:[t.jsx(ta,{className:"h-5 w-5 text-destructive"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:i.error?.message||"Live monitoring could not be loaded."}),t.jsxs(L,{variant:"outline",size:"sm",onClick:()=>i.refetch(),disabled:i.isFetching,children:[t.jsx(tl,{className:`mr-2 h-4 w-4 ${i.isFetching?"animate-spin":""}`})," Try again"]})]}):i.data?.enabled===!1?t.jsx("p",{className:"rounded-md border p-8 text-center text-sm text-muted-foreground",children:"Live monitoring is currently disabled by policy."}):t.jsx("div",{className:"overflow-x-auto rounded-md border",children:t.jsxs(Fy,{className:"min-w-[780px]",children:[t.jsx(By,{children:t.jsxs(hu,{children:[t.jsx(fa,{children:"User"}),t.jsx(fa,{children:"Status"}),t.jsx(fa,{children:"Role"}),t.jsx(fa,{children:"Site"}),t.jsx(fa,{children:"Camera"}),t.jsx(fa,{children:"Activity"})]})}),t.jsx(Uy,{children:d.length===0?t.jsx(hu,{children:t.jsx(ia,{colSpan:6,className:"h-24 text-center text-muted-foreground",children:o.length?"No sessions match these filters.":"There are no live sessions right now."})}):d.map(h=>t.jsxs(hu,{children:[t.jsxs(ia,{className:"max-w-48",children:[t.jsx("div",{className:"truncate font-medium",children:h.name||"Unknown user"}),h.email&&t.jsx("div",{className:"truncate text-xs text-muted-foreground",children:h.email})]}),t.jsxs(ia,{children:[t.jsx(Ke,{className:GVe(h.status),children:h.status||"Unknown"}),t.jsxs("div",{className:"mt-1 whitespace-nowrap text-xs text-muted-foreground",title:g5(h.lastSeen),children:["Last seen ",g5(h.lastSeen)]})]}),t.jsx(ia,{className:"capitalize",children:h.role||"—"}),t.jsx(ia,{className:"max-w-44 break-words",children:h.siteName||"—"}),t.jsx(ia,{className:"max-w-36 break-words",children:h.camera||"—"}),t.jsx(ia,{className:"min-w-48 max-w-80",children:h.category?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"font-medium",children:mW[h.category]||h.category}),h.summary&&t.jsx("div",{className:"break-words text-sm text-muted-foreground",children:h.summary}),h.searchTerm&&t.jsxs("div",{className:"break-words text-sm text-muted-foreground",children:["Search: ",h.searchTerm]}),t.jsx("div",{className:"text-xs text-muted-foreground",children:g5(h.activityAt)})]}):t.jsx("span",{className:"text-muted-foreground",children:"—"})})]}
587,h.id))})]})})]})]})}const hW=new Set(["local_storage","cloud_storage"]);function tS(){return new Date().toISOString().slice(0,10)}function x5(e){const s=new Date;return s.setDate(s.getDate()-e),s.toISOString().slice(0,10)}function v5(e){if(!e)return"0 B";const s=["B","KB","MB","GB","TB","PB"],r=Math.min(Math.floor(Math.log(e)/Math.log(1024)),s.length-1);return`${(e/Math.pow(1024,r)).toFixed(r===0?0:1)} ${s[r]}`}function QVe(e){if(!e||e<=0)return"—";const s=Math.round(e/1e3);if(s<60)return`${s}s`;const r=Math.floor(s/60),n=s%60;return r<60?`${r}m ${n}s`:`${Math.floor(r/60)}h ${r%60}m`}const XVe={login:"Login",logout:"Logout",live_view:"Live View",playback:"Playback",export:"Export",device_setting_change:"Setting Change",user_create:"User Created",view_as_start:"View As (Start)",view_as_stop:"View As (Stop)"};function ZVe(){const[,e]=Ia(),{data:s}=ze({queryKey:["/api/user/role"]}),{data:r,isPending:n}=ze({queryKey:["/api/audit/live/policy"],queryFn:async()=>{const Y=await fetch("/api/audit/live/policy",{credentials:"include"});if(!Y.ok)throw new Error(`Live monitoring policy unavailable (${Y.status})`);return Y.json()},retry:!1,refetchInterval:5e3});u.useEffect(()=>{s?.auditingDisabled&&e("/")},[s?.auditingDisabled,e]);const[a,i]=u.useState("live_monitoring"),[o,l]=u.useState(x5(7)),[c,d]=u.useState(tS()),[h,p]=u.useState([]),[g,v]=u.useState("all"),{data:b,isLoading:y,isError:w,error:j,refetch:x,isFetching:C}=ze({queryKey:["/api/audit/meta"],retry:2}),k=/^403:/.test(j?.message??""),S=b?.categories||[],_=r?.enabled===!0,A=a==="live_monitoring"&&!_?S[0]?.key||"login_logout":a,T=S.find(Y=>Y.key===A),M=hW.has(A),R=u.useMemo(()=>{const Y=new URLSearchParams;return o&&Y.set("start",new Date(o+"T00:00:00").toISOString()),c&&Y.set("end",new Date(c+"T23:59:59.999").toISOString()),h.length&&Y.set("siteIds",h.join(",")),g&&g!=="all"&&Y.set("actorUserId",g),Y},[o,c,h,g]),D=(T?.eventTypes||[]).join(","),$=u.useMemo(()=>{const Y=new URLSearchParams(R);return D&&Y.set("types",D),Y.toString()},[R,D]),{data:O,isLoading:q}=ze({queryKey:[`/api/audit/events?${$}`],enabled:!!b&&!M&&A!=="live_monitoring"&&!(a==="live_monitoring"&&n)}),V=A==="local_storage"?"local":"cloud",K=u.useMemo(()=>{const Y=new URLSearchParams(R);return Y.set("kind",V),Y.toString()},[R,V]),{data:G,isLoading:z}=ze({queryKey:[`/api/audit/storage?${K}`],enabled:!!b&&M}),Z=u.useMemo(()=>{if(!O)return[];const Y=new Map;for(const oe of O){const he=(oe.createdAt||"").slice(0,10);he&&Y.set(he,(Y.get(he)||0)+1)}return Array.from(Y.entries()).sort((oe,he)=>oe[0].localeCompare(he[0])).map(([oe,he])=>({date:oe,count:he}))},[O]),ee=Y=>{p(oe=>oe.includes(Y)?oe.filter(he=>he!==Y):[...oe,Y])},Q=()=>{const Y=new URLSearchParams(R);D&&Y.set("types",D),window.open(`/api/audit/events.csv?${Y.toString()}`,"_blank")};return y?t.jsxs("div",{className:"min-h-screen bg-background p-6",children:[t.jsx(Bt,{className:"h-10 w-64 mb-6"}),t.jsx(Bt,{className:"h-96 w-full"})]}):!b&&w&&k?t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-6",children:t.jsxs(ut,{className:"max-w-md",children:[t.jsxs(xs,{children:[t.jsx(ys,{children:"Access Denied"}),t.jsx(Xs,{children:"You don't have permission to view the audit reporting section."})]}),t.jsx(mt,{children:t.jsxs(L,{onClick:()=>e("/"),"data-testid":"button-back-home",children:[t.jsx(Wi,{className:"w-4 h-4 mr-2"})," Back to Dashboard"]})})]})}):b?t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"border-b sticky top-0 z-10 bg-background/95 backdrop-blur",children:t.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-6 py-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(L,{variant:"ghost",size:"icon",onClick:()=>e("/"),"data-testid":"button-back",children:t.jsx(Wi,{className:"w-5 h-5"})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(xu,{className:"w-5 h-5 text-primary"}),t.jsx("h1",{className:"text-lg font-semibold","data-testid":"text-page-title",children:"Audit"})]})]}),t.jsx(qd,{})]})}
587),t.jsxs("div",{className:"p-4 sm:p-6 max-w-7xl mx-auto space-y-4",children:[A!=="live_monitoring"&&t.jsx(ut,{children:t.jsxs(mt,{className:"pt-6 space-y-4",children:[t.jsx("div",{className:"flex flex-wrap gap-2",children:(()=>{const Y=[{label:"Last 7 Days",days:7},{label:"Last 14 Days",days:14},{label:"Last 30 Days",days:30}],oe=je=>o===x5(je)&&c===tS(),he=!Y.some(je=>oe(je.days));return t.jsxs(t.Fragment,{children:[Y.map(je=>t.jsx(L,{type:"button",size:"sm",variant:oe(je.days)?"default":"outline",onClick:()=>{l(x5(je.days)),d(tS())},"data-testid":`button-range-${je.days}`,children:je.label},je.days)),t.jsx(L,{type:"button",size:"sm",variant:he?"default":"outline",onClick:()=>{const je=document.getElementById("start-date");je?.focus(),je?.showPicker?.()},"data-testid":"button-range-custom",children:"Custom Range"})]})})()}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:flex lg:flex-wrap lg:items-end gap-4",children:[t.jsxs("div",{className:"space-y-1 w-full lg:w-auto",children:[t.jsx(re,{htmlFor:"start-date",className:"text-xs",children:"Start date"}),t.jsx(ke,{id:"start-date",type:"date",value:o,max:c,onChange:Y=>l(Y.target.value),className:"w-full min-w-0 box-border appearance-none lg:w-40","data-testid":"input-start-date"})]}),t.jsxs("div",{className:"space-y-1 w-full lg:w-auto",children:[t.jsx(re,{htmlFor:"end-date",className:"text-xs",children:"End date"}),t.jsx(ke,{id:"end-date",type:"date",value:c,min:o,max:tS(),onChange:Y=>d(Y.target.value),className:"w-full min-w-0 box-border appearance-none lg:w-40","data-testid":"input-end-date"})]}),t.jsxs("div",{className:"flex flex-col gap-1 w-full lg:w-auto",children:[t.jsx(re,{className:"text-xs",children:"Sites"}),t.jsxs(vd,{children:[t.jsx(yd,{asChild:!0,children:t.jsxs(L,{variant:"outline",className:"w-full lg:w-48 justify-between font-normal px-3","data-testid":"button-site-filter",children:[t.jsx("span",{children:h.length===0?"All sites":`${h.length} selected`}),t.jsx(qj,{className:"w-4 h-4 ml-2 shrink-0 opacity-50"})]})}),t.jsx(Kc,{className:"w-64 p-2 max-h-72 overflow-y-auto",children:b.sites.length===0?t.jsx("p",{className:"text-sm text-muted-foreground p-2",children:"No sites available"}):t.jsx("div",{className:"space-y-1",children:b.sites.map(Y=>t.jsxs("label",{className:"flex items-center gap-2 px-2 py-1.5 rounded hover-elevate cursor-pointer text-sm","data-testid":`option-site-${Y.id}`,children:[t.jsx(On,{checked:h.includes(Y.id),onCheckedChange:()=>ee(Y.id)}),t.jsx("span",{className:"truncate",children:Y.name})]},Y.id))})})]})]}),b.users.length>0&&!M&&t.jsxs("div",{className:"space-y-1 w-full lg:w-auto",children:[t.jsx(re,{className:"text-xs",children:"User"}),t.jsxs(Us,{value:g,onValueChange:v,children:[t.jsx($s,{className:"w-full lg:w-52","data-testid":"select-user",children:t.jsx(zs,{placeholder:"All users"})}),t.jsxs(Fs,{children:[t.jsx(rt,{value:"all",children:"All users"}),b.users.map(Y=>t.jsxs(rt,{value:Y.id,children:[Y.name," (",Y.role,")"]},Y.id))]})]})]}),!M&&t.jsx("div",{className:"w-full sm:col-span-2 lg:w-auto lg:ml-auto",children:t.jsxs(L,{onClick:Q,variant:"outline",className:"w-full lg:w-auto","data-testid":"button-export-csv",children:[t.jsx(ya,{className:"w-4 h-4 mr-2"})," Export CSV"]})})]})]})}),t.jsxs(_h,{value:A,onValueChange:i,children:[t.jsxs(Dm,{className:"grid grid-cols-2 sm:flex sm:flex-wrap h-auto w-full gap-1",children:[_&&t.jsx(_n,{value:"live_monitoring",className:"w-full sm:w-auto","data-testid":"tab-live-monitoring",children:"Live Monitoring"}),S.map(Y=>t.jsx(_n,{value:Y.key,className:"w-full sm:w-auto","data-testid":`tab-${Y.key}`,children:Y.label},Y.key))]}),_&&t.jsx(ea,{value:"live_monitoring",className:"space-y-4",children:t.jsx(YVe,{selected:A==="live_monitoring"})}),S.map(Y=>t.jsx(ea,{value:Y.key,className:"space-y-4",children:hW.has(Y.key)?t.jsx(JVe,{loading:z,series:Y.key===A?G:void 0,label:Y.label}):t.jsx(eWe,{loading:q,events:Y.key===A?O:void 0,chartData:Y.key===A?Z:[],label:Y.label})},Y.key))]})]})]}):t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-6",children:t.jsxs(ut,{className:"max-w-md",children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"flex items-center gap-2",children:[t.jsx(ta,{className:"w-5 h-5 text-destructive"}),"Couldn't load audit data"]}),t.jsx(Xs,{children:"Something went wrong while loading the audit reporting section. This is usually temporary — please try again."})]}),t.jsxs(mt,{className:"flex flex-col sm:flex-row gap-2",children:[t.jsxs(L,{onClick:()=>x(),disabled:C,"data-testid":"button-retry-audit",children:[t.jsx(tl,{className:`w-4 h-4 mr-2 ${C?"animate-spin":""}`}),C?"Retrying…":"Try again"]}),t.jsxs(L,{variant:"outline",onClick:()=>e("/"),"data-testid":"button-back-home",children:[t.jsx(Wi,{className:"w-4 h-4 mr-2"})," Back to Dashboard"]})]})]})})}function JVe({loading:e,series:s,label:r}){const n=(s||[]).reduce((a,i)=>
587a+i.bytes,0);return t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"text-base",children:[r," Usage Over Time"]}),t.jsx(Xs,{children:r==="Local Storage"?"On-device recording storage by day (sum of on-disk recording sizes).":"Cloud recording storage by day (sum of uploaded recording sizes)."})]}),t.jsx(mt,{children:e?t.jsx(Bt,{className:"h-72 w-full"}):!s||s.length===0?t.jsx("p",{className:"text-sm text-muted-foreground py-12 text-center","data-testid":"text-no-storage-data",children:"No storage data for the selected range."}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"flex gap-6 mb-4",children:t.jsxs("div",{children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Total in range"}),t.jsx("p",{className:"text-2xl font-semibold","data-testid":"text-storage-headline",children:v5(n)})]})}),t.jsx(nD,{width:"100%",height:300,children:t.jsxs(NFe,{data:s,children:[t.jsx(BD,{strokeDasharray:"3 3",className:"stroke-muted"}),t.jsx(Vb,{dataKey:"date",tick:{fontSize:12}}),t.jsx(Wb,{tickFormatter:a=>v5(Number(a)),tick:{fontSize:12},width:70}),t.jsx(uh,{cursor:!1,formatter:a=>v5(Number(a))}),t.jsx(Hg,{type:"monotone",dataKey:"bytes",stroke:"hsl(var(--primary))",fill:"hsl(var(--primary))",fillOpacity:.2})]})})]})})]})}function eWe({loading:e,events:s,chartData:r,label:n}){return t.jsxs(t.Fragment,{children:[t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsxs(ys,{className:"text-base",children:[n," Activity"]}),t.jsx(Xs,{children:"Event count per day in the selected range."})]}),t.jsx(mt,{children:e?t.jsx(Bt,{className:"h-64 w-full"}):r.length===0?t.jsx("p",{className:"text-sm text-muted-foreground py-12 text-center","data-testid":"text-no-chart-data",children:"No activity for the selected range."}):t.jsx(nD,{width:"100%",height:260,children:t.jsxs(wFe,{data:r,children:[t.jsx(BD,{strokeDasharray:"3 3",className:"stroke-muted"}),t.jsx(Vb,{dataKey:"date",tick:{fontSize:12}}),t.jsx(Wb,{allowDecimals:!1,tick:{fontSize:12},width:40}),t.jsx(uh,{cursor:!1}),t.jsx(xv,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0]})]})})})]}),t.jsxs(ut,{children:[t.jsxs(xs,{children:[t.jsx(ys,{className:"text-base",children:"Events"}),t.jsx(Xs,{children:s?`${s.length} event${s.length===1?"":"s"}`:""})]}),t.jsx(mt,{children:e?t.jsx(Bt,{className:"h-64 w-full"}):!s||s.length===0?t.jsx("p",{className:"text-sm text-muted-foreground py-12 text-center","data-testid":"text-no-events",children:"No events for the selected range."}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs(Fy,{children:[t.jsx(By,{children:t.jsxs(hu,{children:[t.jsx(fa,{children:"Time"}),t.jsx(fa,{children:"Type"}),t.jsx(fa,{children:"User"}),t.jsx(fa,{children:"Role"}),t.jsx(fa,{children:"IP"}),t.jsx(fa,{title:"For live views, shows whether the viewer was on the same local network as the camera (LAN) or remote (WAN), inferred from the network. Other events show duration.",children:"Duration / Connection"}),t.jsx(fa,{children:"Details"})]})}),t.jsx(Uy,{children:s.map(a=>t.jsxs(hu,{"data-testid":`row-event-${a.id}`,children:[t.jsx(ia,{className:"whitespace-nowrap text-xs",children:new Date(a.createdAt).toLocaleString()}),t.jsx(ia,{children:t.jsx(Ke,{variant:"secondary",children:XVe[a.eventType]||a.eventType})}),t.jsx(ia,{className:"text-sm",children:a.actorName||a.actorEmail||"—"}),t.jsx(ia,{className:"text-sm",children:a.actorRole||"—"}),t.jsx(ia,{className:"text-xs",children:a.ipAddress||"—"}),t.jsx(ia,{className:"text-xs",children:a.eventType==="live_view"&&(a.details?.connection==="lan"||a.details?.connection==="wan")?t.jsx(Ke,{variant:a.details.connection==="lan"?"default":"secondary","data-testid":`badge-connection-${a.id}`,children:a.details.connection==="lan"?"LAN":"WAN"}):QVe(a.durationMs)}),t.jsx(ia,{className:"text-sm max-w-xs truncate",children:a.summary||"—"})]},a.id))})]})})})]})]})}function tWe(e){if(!e)return"0 B";const s=["B","KB","MB","GB","TB"];let r=0,n=e;for(;n>=1024&&r<s.length-1;)n/=1024,r++;return`${n.toFixed(n>=10||r===0?0:1)} ${s[r]}`}function pW(){const{token:e}=Ek(),{t:s}=rn(Mte),[r,n]=u.useState(""),[a,i]=u.useState(!1),[o,l]=u.useState(null),c=ze({queryKey:["/api/shared-exports",e],queryFn:async()=>{const h=await fetch(`/api/shared-exports/${e}`);if(!h.ok){const p=await h.json().catch(()=>({}));throw new Error(p.error||s("error.unavailable"))}return h.json()},retry:!1}),d=async()=>
587{l(null),i(!0);try{const h=await fetch(`/api/shared-exports/${e}/verify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:r.trim()})}),p=await h.json().catch(()=>({}));if(!h.ok){l(p.error||s("error.verificationFailed"));return}window.location.href=`/api/shared-exports/${e}/download?ticket=${encodeURIComponent(p.ticket)}`}catch{l(s("error.generic"))}finally{i(!1)}};return t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:t.jsxs(ut,{className:"w-full max-w-md",children:[t.jsx(xs,{children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(AK,{className:"w-5 h-5 text-primary"}),t.jsx(ys,{className:"text-lg",children:s("title")})]})}),t.jsxs(mt,{className:"space-y-5",children:[c.isLoading&&t.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:t.jsx(Fe,{className:"w-5 h-5 animate-spin"})}),c.isError&&t.jsxs("div",{className:"flex items-start gap-2 text-sm text-destructive","data-testid":"text-share-error",children:[t.jsx(ta,{className:"w-4 h-4 mt-0.5 shrink-0"}),t.jsx("span",{children:c.error?.message||s("error.unavailable")})]}),c.data&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"rounded-md border p-3 text-sm space-y-1",children:[t.jsx("div",{className:"font-medium break-all","data-testid":"text-file-name",children:c.data.fileName}),t.jsxs("div",{className:"text-muted-foreground text-xs",children:[c.data.itemCount," ",c.data.itemCount===1?s("clip.singular"):s("clip.plural")," ·"," ",tWe(c.data.totalBytes)]}),c.data.expiresAt&&t.jsxs("div",{className:"text-muted-foreground text-xs",children:[s("availableUntilPrefix")," ",new Date(c.data.expiresAt).toLocaleDateString()]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs(re,{htmlFor:"access-code",className:"text-xs flex items-center gap-1",children:[t.jsx(vi,{className:"w-3.5 h-3.5"})," ",s("accessCodeLabel")]}),t.jsx(ke,{id:"access-code",value:r,onChange:h=>{n(h.target.value.toUpperCase()),l(null)},onKeyDown:h=>{h.key==="Enter"&&r.trim()&&!a&&d()},placeholder:s("accessCodePlaceholder"),className:"font-mono tracking-widest",autoComplete:"off","data-testid":"input-access-code"}),o&&t.jsx("p",{className:"text-xs text-destructive","data-testid":"text-code-error",children:o})]}),t.jsxs(L,{className:"w-full",onClick:d,disabled:!r.trim()||a,"data-testid":"button-shared-download",children:[a?t.jsx(Fe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(ya,{className:"w-4 h-4 mr-2"}),s("downloadButton")]})]})]})]})})}function sWe(){const{t:e}=rn(ote);return t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:t.jsxs("div",{className:"text-center space-y-6 max-w-md",children:[t.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto",children:t.jsx(Vi,{className:"w-8 h-8 text-muted-foreground"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"text-4xl font-bold text-foreground",children:e("code")}),t.jsx("h2",{className:"text-xl font-semibold text-foreground",children:e("heading")}),t.jsx("p",{className:"text-muted-foreground",children:e("body")})]}),t.jsx("a",{href:"/",children:t.jsxs(L,{"data-testid":"button-go-home",children:[t.jsx(Ik,{className:"w-4 h-4 mr-2"}),e("homeButton")]})})]})})}const y5="truvios_push_prompt_dismissed";async function rWe(){if(!("serviceWorker"in navigator)||!("PushManager"in window))return{error:"Push notifications are not supported in this browser."};try{const e=await navigator.serviceWorker.ready;return await Notification.requestPermission()!=="granted"?{error:"Notification permission was denied. You can enable it in your browser settings."}:await v3(e)}catch(e){return{error:e?.message||"Enrollment failed."}}}function nWe(){if(typeof window>"u"||!window.matchMedia("(max-width: 767px)").matches)return"hidden";const e=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,s=window.navigator?.standalone===!0||window.matchMedia?.("(display-mode: standalone)")?.matches;
587return e&&!s?"ios-install":e&&s||"serviceWorker"in navigator&&"PushManager"in window?"enroll":"hidden"}function aWe(){const{user:e}=Gi(),s=Er(),r=Su(),[n,a]=u.useState(!1),[i,o]=u.useState("hidden"),[l,c]=u.useState(!1),[d,h]=u.useState(!1),[p,g]=u.useState(null),v=ze({queryKey:["/api/push/subscriptions"],enabled:!!e,staleTime:1e3*60*5});u.useEffect(()=>{e&&xje().then(w=>{w&&r.invalidateQueries({queryKey:["/api/push/subscriptions"]})})},[e,r]),u.useEffect(()=>{if(!e||v.isLoading||localStorage.getItem(y5)||v.data&&v.data.length>0)return;const w=nWe();if(w==="hidden")return;const j=setTimeout(()=>{o(w),a(!0)},1500);return()=>clearTimeout(j)},[e,v.isLoading,v.data]);function b(){l&&localStorage.setItem(y5,"1"),a(!1)}async function y(){h(!0),g(null);const w=await rWe();h(!1),"error"in w?g(w.error):(r.invalidateQueries({queryKey:["/api/push/subscriptions"]}),l&&localStorage.setItem(y5,"1"),a(!1))}return n?i==="ios-install"?t.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 p-4 md:hidden","data-testid":"mobile-push-prompt",children:t.jsxs("div",{className:"bg-background border rounded-2xl shadow-2xl p-5 space-y-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:t.jsx(mi,{className:"w-5 h-5 text-primary"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-sm","data-testid":"text-push-prompt-title",children:"Get Push Notifications on iPhone"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Safari requires the app to be installed first."})]})]}),t.jsx("button",{onClick:b,className:"text-muted-foreground hover:text-foreground flex-shrink-0 mt-0.5","data-testid":"button-push-prompt-close","aria-label":"Dismiss",children:t.jsx(va,{className:"w-4 h-4"})})]}),t.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground pl-1",children:[t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(Sde,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-primary"}),t.jsxs("span",{children:["Tap the ",t.jsx("strong",{className:"text-foreground",children:"Share"})," button at the bottom of Safari"]})]}),t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(Tde,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-primary"}),t.jsxs("span",{children:["Choose ",t.jsx("strong",{className:"text-foreground",children:"Add to Home Screen"})]})]}),t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(mi,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-primary"}),t.jsxs("span",{children:["Open ",s.brandName," from your Home Screen and sign in — push enrollment will appear automatically"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(On,{id:"push-dont-show",checked:l,onCheckedChange:w=>c(!!w),"data-testid":"checkbox-push-dont-show"}),t.jsx(re,{htmlFor:"push-dont-show",className:"text-xs text-muted-foreground cursor-pointer",children:"Don't show this again"})]}),t.jsx(L,{size:"sm",variant:"outline",onClick:b,className:"w-full","data-testid":"button-push-prompt-dismiss",children:"Got It"})]})}):t.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 p-4 md:hidden","data-testid":"mobile-push-prompt",children:t.jsxs("div",{className:"bg-background border rounded-2xl shadow-2xl p-5 space-y-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0",children:t.jsx(mi,{className:"w-5 h-5 text-primary"})}),t.jsxs("div",{children:[t.jsx("p",{className:"font-semibold text-sm","data-testid":"text-push-prompt-title",children:"Enable Push Notifications"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Get instant alerts for device outages, camera issues, and security events on this device."})]})]}),t.jsx("button",{onClick:b,className:"text-muted-foreground hover:text-foreground flex-shrink-0 mt-0.5","data-testid":"button-push-prompt-close","aria-label":"Dismiss",children:t.jsx(va,{className:"w-4 h-4"})})]}),p&&t.jsx("p",{className:"text-xs text-destructive","data-testid":"text-push-prompt-error",children:p}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(On,{id:"push-dont-show",checked:l,onCheckedChange:w=>c(!!w),"data-testid":"checkbox-push-dont-show"}),t.jsx(re,{htmlFor:"push-dont-show",className:"text-xs text-muted-foreground cursor-pointer",children:"Don't show this again"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(L,{size:"sm",variant:"outline",onClick:b,className:"flex-1","data-testid":"button-push-prompt-not-now",children:"Not Now"}),t.jsx(L,{size:"sm",onClick:y,disabled:d,className:"flex-1","data-testid":"button-push-prompt-enable",children:d?"Enabling…":"Enable"})]})]})}):null}const iWe=["/account","/preferences","/settings","/admin","/device-notifications","/recordings","/cloud-rec
587ordings","/local-recordings","/live/","/multi-live-view","/multi-recordings","/video-export","/device-settings/","/audit"];function oWe(){const{user:e,isLoading:s}=Gi(),[r]=Ia();return u.useEffect(()=>{if(s)return;const n=r==="/"||iWe.some(o=>r.startsWith(o)),a=!!e&&n;window.__tawkHide=a;const i=window.Tawk_API;i&&(a?i.hideWidget?.():i.showWidget?.())},[e,s,r]),null}function lWe(){const[e]=Ia();return u.useEffect(()=>{window.scrollTo(0,0)},[e]),null}function cWe(){const{user:e}=Gi();return u.useEffect(()=>{if(e)return Vwe()},[e?.id]),null}function dWe(){const{user:e}=Gi(),s=Er(),{data:r}=ze({queryKey:["/api/user/settings"],enabled:!!e}),n=s.showDemetriMode!=="false"&&!!r?.demetriMode;return u.useEffect(()=>{n?document.documentElement.classList.add("demetri-mode"):document.documentElement.classList.remove("demetri-mode")},[n]),null}function uWe(){const{user:e}=Gi(),{setTheme:s}=YG(),{data:r}=ze({queryKey:["/api/user/settings"],enabled:!!e});return u.useEffect(()=>{const n=r?.theme;(n==="light"||n==="dark"||n==="darker")&&s(n)},[r?.theme]),null}function mWe(){const{user:e,isLoading:s}=Gi();return s?t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:t.jsxs("div",{className:"space-y-4 text-center",children:[t.jsx(Bt,{className:"h-12 w-12 rounded-full mx-auto"}),t.jsx(Bt,{className:"h-4 w-32"})]})}):e?t.jsxs(o$,{children:[t.jsx(ds,{path:"/",component:nje}),t.jsx(ds,{path:"/account",component:wje}),t.jsx(ds,{path:"/preferences",component:yF}),t.jsx(ds,{path:"/settings",component:yF}),t.jsx(ds,{path:"/admin",component:rCe}),t.jsx(ds,{path:"/audit",component:ZVe}),t.jsx(ds,{path:"/device-notifications",component:DFe}),t.jsx(ds,{path:"/recordings",component:H4}),t.jsx(ds,{path:"/cloud-recordings",component:H4}),t.jsx(ds,{path:"/local-recordings",component:H4}),t.jsx(ds,{path:"/live/:siteId/:cameraName",component:FFe}),t.jsx(ds,{path:"/multi-live-view",component:dBe}),t.jsx(ds,{path:"/multi-recordings",component:gBe}),t.jsx(ds,{path:"/video-export",component:wBe}),t.jsx(ds,{path:"/device-settings/:siteId",component:L9e}),t.jsx(ds,{path:"/edge-terminal/:edgeDeviceId",component:$9e}),t.jsx(ds,{path:"/resources/white-paper",component:$V}),t.jsx(ds,{path:"/resources/supported-devices",component:BV}),t.jsx(ds,{path:"/resources/oem-branding",component:HV}),t.jsx(ds,{path:"/resources/events",component:qV}),t.jsx(ds,{path:"/blog/:slug",component:GV}),t.jsx(ds,{path:"/blog",component:KV}),t.jsx(ds,{path:"/support/edge-app-install",component:eW}),t.jsx(ds,{path:"/support/blu-documentation",component:XV}),t.jsx(ds,{path:"/support/submit-ticket",component:sW}),t.jsx(ds,{path:"/support/downloads",component:aW}),t.jsx(ds,{path:"/refer",component:iW}),t.jsx(ds,{path:"/edge-quote",component:eS}),t.jsx(ds,{path:"/edge",component:eS}),t.jsx(ds,{path:"/solutions/hospitality",component:wV}),t.jsx(ds,{path:"/solutions/retail",component:jV}),t.jsx(ds,{path:"/solutions/restaurants",component:NV}),t.jsx(ds,{path:"/solutions/healthcare",component:SV}),t.jsx(ds,{path:"/solutions/education",component:CV}),t.jsx(ds,{path:"/solutions/government",component:kV}),t.jsx(ds,{path:"/solutions/commercial-real-estate",component:_V}),t.jsx(ds,{path:"/solutions/cannabis",component:PV}),t.jsx(ds,{path:"/solutions/features/weapon-detection",component:EV}),t.jsx(ds,{path:"/solutions/features/faces-people",component:TV}),t.jsx(ds,{path:"/solutions/features/natural-text-search",component:AV}),t.jsx(ds,{path:"/solutions/features/object-detection",component:RV}),t.jsx(ds,{path:"/solutions/features/visual-comparisons",component:IV}),t.jsx(ds,{path:"/solutions/features/smart-ai-alerts",component:DV}),t.jsx(ds,{path:"/cloud-video-surveillance",component:Y1}),t.jsx(ds,{path:"/solutions/features/cloud-video-surveillance",component:Y1}),t.jsx(ds,{path:"/device-notifications",component:Q1}),t.jsx(ds,{path:"/solutions/features/device-notifications",component:Q1}),t.jsx(ds,{path:"/ptz-fisheye",component:X1}),t.jsx(ds,{path:"/solutions/features/ptz-fisheye",component:X1}),t.jsx(ds,{path:"/blu",component:v6}),t.jsx(ds,{path:"/home",component:f6}),t.jsx(ds,{path:"/get-started",component:x6}),t.jsx(ds,{path:"/terms-conditions",component:yV}),t.jsx(ds,{path:"/privacy-policy",component:bV}),t.jsx(ds,{path:"/d/:token",component:pW}),t.jsx(ds,{component:sWe})]}):t.jsxs(o$,{children:[t.jsx(ds,{path:"/blu",component:v6}),t.jsx(ds,{path:"/solutions/hospitality",component:wV}),t.jsx(ds,{path:"/solutions/retail",component:jV}),t.jsx(ds,{path:"/solutions/restaurants",component:NV}),t.jsx(ds,{path:"/solutions/healthcare",component:SV}
587),t.jsx(ds,{path:"/solutions/education",component:CV}),t.jsx(ds,{path:"/solutions/government",component:kV}),t.jsx(ds,{path:"/solutions/commercial-real-estate",component:_V}),t.jsx(ds,{path:"/solutions/cannabis",component:PV}),t.jsx(ds,{path:"/solutions/features/weapon-detection",component:EV}),t.jsx(ds,{path:"/solutions/features/faces-people",component:TV}),t.jsx(ds,{path:"/solutions/features/natural-text-search",component:AV}),t.jsx(ds,{path:"/solutions/features/object-detection",component:RV}),t.jsx(ds,{path:"/solutions/features/visual-comparisons",component:IV}),t.jsx(ds,{path:"/solutions/features/smart-ai-alerts",component:DV}),t.jsx(ds,{path:"/cloud-video-surveillance",component:Y1}),t.jsx(ds,{path:"/solutions/features/cloud-video-surveillance",component:Y1}),t.jsx(ds,{path:"/device-notifications",component:Q1}),t.jsx(ds,{path:"/solutions/features/device-notifications",component:Q1}),t.jsx(ds,{path:"/ptz-fisheye",component:X1}),t.jsx(ds,{path:"/solutions/features/ptz-fisheye",component:X1}),t.jsx(ds,{path:"/resources/white-paper",component:$V}),t.jsx(ds,{path:"/resources/supported-devices",component:BV}),t.jsx(ds,{path:"/resources/oem-branding",component:HV}),t.jsx(ds,{path:"/resources/events",component:qV}),t.jsx(ds,{path:"/blog/:slug",component:GV}),t.jsx(ds,{path:"/blog",component:KV}),t.jsx(ds,{path:"/support/edge-app-install",component:eW}),t.jsx(ds,{path:"/support/blu-documentation",component:XV}),t.jsx(ds,{path:"/support/submit-ticket",component:sW}),t.jsx(ds,{path:"/support/downloads",component:aW}),t.jsx(ds,{path:"/refer",component:iW}),t.jsx(ds,{path:"/edge-quote",component:eS}),t.jsx(ds,{path:"/edge",component:eS}),t.jsx(ds,{path:"/terms-conditions",component:yV}),t.jsx(ds,{path:"/privacy-policy",component:bV}),t.jsx(ds,{path:"/reset-password",component:F9e}),t.jsx(ds,{path:"/get-started",component:x6}),t.jsx(ds,{path:"/d/:token",component:pW}),t.jsx(ds,{component:f6})]})}function hWe(){return t.jsx(Dle,{client:Je,children:t.jsx(Bme,{defaultTheme:"dark",children:t.jsx(epe,{children:t.jsxs(KG,{delayDuration:300,children:[t.jsx(lWe,{}),t.jsx(cWe,{}),t.jsx(dWe,{}),t.jsx(uWe,{}),t.jsx(oWe,{}),t.jsx(tpe,{}),t.jsx(spe,{}),t.jsx(mWe,{}),t.jsx(aWe,{}),t.jsx(wue,{})]})})})})}Voe.createRoot(document.getElementById("root")).render(t.jsx(hWe,{}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js",{scope:"/"}).catch(e=>console.warn("[sw] registration failed:",e))});export{ei as g};

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.