var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ee(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function te(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var P=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},F={map:ee,forEach:function(e,t,n){ee(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ee(e,function(){t++}),t},toArray:function(e){return ee(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=F,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:te}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,P)}catch(e){P(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}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(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.7`})),h=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function ee(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?ee(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return ee(e(t))}catch{}}return null}var te=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},re=[],ie=-1;function ae(e){return{current:e}}function oe(e){0>ie||(e.current=re[ie],re[ie]=null,ie--)}function se(e,t){ie++,re[ie]=e.current,e.current=t}var ce=ae(null),le=ae(null),ue=ae(null),de=ae(null);function fe(e,t){switch(se(ue,t),se(le,e),se(ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Gd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Gd(t),e=Kd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}oe(ce),se(ce,e)}function pe(){oe(ce),oe(le),oe(ue)}function me(e){e.memoizedState!==null&&se(de,e);var t=ce.current,n=Kd(t,e.type);t!==n&&(se(le,e),se(ce,n))}function he(e){le.current===e&&(oe(ce),oe(le)),de.current===e&&(oe(de),np._currentValue=ne)}var ge,_e;function ve(e){if(ge===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||``,_e=-1<e.stack.indexOf(`
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
`+ge+e+_e}var ye=!1;function be(e,t){if(!e||ye)return``;ye=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
`),l=s.split(`
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ye=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ve(n):``}function xe(e,t){switch(e.tag){case 26:case 27:case 5:return ve(e.type);case 16:return ve(`Lazy`);case 13:return e.child!==t&&t!==null?ve(`Suspense Fallback`):ve(`Suspense`);case 19:return ve(`SuspenseList`);case 0:case 15:return be(e.type,!1);case 11:return be(e.type.render,!1);case 1:return be(e.type,!0);case 31:return ve(`Activity`);default:return``}}function Se(e){try{var t=``,n=null;do t+=xe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
Error generating stack: `+e.message+`
`+e.stack}}var Ce=Object.prototype.hasOwnProperty,we=t.unstable_scheduleCallback,Te=t.unstable_cancelCallback,Ee=t.unstable_shouldYield,De=t.unstable_requestPaint,Oe=t.unstable_now,ke=t.unstable_getCurrentPriorityLevel,Ae=t.unstable_ImmediatePriority,je=t.unstable_UserBlockingPriority,Me=t.unstable_NormalPriority,Ne=t.unstable_LowPriority,Pe=t.unstable_IdlePriority,Fe=t.log,Ie=t.unstable_setDisableYieldValue,Le=null,Re=null;function ze(e){if(typeof Fe==`function`&&Ie(e),Re&&typeof Re.setStrictMode==`function`)try{Re.setStrictMode(Le,e)}catch{}}var Be=Math.clz32?Math.clz32:Ue,Ve=Math.log,He=Math.LN2;function Ue(e){return e>>>=0,e===0?32:31-(Ve(e)/He|0)|0}var We=256,Ge=262144,Ke=4194304;function qe(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Je(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=qe(n))):i=qe(o):i=qe(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=qe(n))):i=qe(o)):i=qe(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Ye(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Xe(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ze(){var e=Ke;return Ke<<=1,!(Ke&62914560)&&(Ke=4194304),e}function Qe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function $e(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function et(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Be(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&tt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function tt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Be(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function nt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Be(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function rt(e,t){var n=t&-t;return n=n&42?1:it(n),(n&(e.suspendedLanes|t))===0?n:0}function it(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function at(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function ot(){var e=F.p;return e===0?(e=window.event,e===void 0?32:_p(e.type)):e}function st(e,t){var n=F.p;try{return F.p=e,t()}finally{F.p=n}}var ct=Math.random().toString(36).slice(2),lt=`__reactFiber$`+ct,ut=`__reactProps$`+ct,dt=`__reactContainer$`+ct,ft=`__reactEvents$`+ct,pt=`__reactListeners$`+ct,mt=`__reactHandles$`+ct,ht=`__reactResources$`+ct,gt=`__reactMarker$`+ct;function _t(e){delete e[lt],delete e[ut],delete e[ft],delete e[pt],delete e[mt]}function vt(e){var t=e[lt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[dt]||n[lt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=hf(e);e!==null;){if(n=e[lt])return n;e=hf(e)}return t}e=n,n=e.parentNode}return null}function yt(e){if(e=e[lt]||e[dt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function bt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function xt(e){var t=e[ht];return t||=e[ht]={hoistableStyles:new Map,hoistableScripts:new Map},t}function St(e){e[gt]=!0}var Ct=new Set,wt={};function Tt(e,t){Et(e,t),Et(e+`Capture`,t)}function Et(e,t){for(wt[e]=t,e=0;e<t.length;e++)Ct.add(t[e])}var Dt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Ot={},kt={};function At(e){return Ce.call(kt,e)?!0:Ce.call(Ot,e)?!1:Dt.test(e)?kt[e]=!0:(Ot[e]=!0,!1)}function jt(e,t,n){if(At(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Mt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Nt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Pt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Ft(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function It(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Lt(e){if(!e._valueTracker){var t=Ft(e)?`checked`:`value`;e._valueTracker=It(e,t,``+e[t])}}function Rt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Ft(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function I(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var zt=/[\n"\\]/g;function Bt(e){return e.replace(zt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Vt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Pt(t)):e.value!==``+Pt(t)&&(e.value=``+Pt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Ut(e,o,Pt(n)):Ut(e,o,Pt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Pt(s):e.removeAttribute(`name`)}function Ht(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Lt(e);return}n=n==null?``:``+Pt(n),t=t==null?n:``+Pt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Lt(e)}function Ut(e,t,n){t===`number`&&I(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Wt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Pt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Gt(e,t,n){if(t!=null&&(t=``+Pt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Pt(n)}function Kt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(te(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Pt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Lt(e)}function qt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Jt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Yt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Jt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Xt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Yt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Yt(e,o,t[o])}function Zt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Qt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),$t=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function en(e){return $t.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function tn(){}var nn=null;function rn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var an=null,on=null;function sn(e){var t=yt(e);if(t&&(e=t.stateNode)){var n=e[ut]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Vt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Bt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[ut]||null;if(!a)throw Error(i(90));Vt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Rt(r)}break a;case`textarea`:Gt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Wt(e,!!n.multiple,t,!1)}}}var cn=!1;function ln(e,t,n){if(cn)return e(t,n);cn=!0;try{return e(t)}finally{if(cn=!1,(an!==null||on!==null)&&(Su(),an&&(t=an,e=on,on=an=null,sn(t),e)))for(t=0;t<e.length;t++)sn(e[t])}}function un(e,t){var n=e.stateNode;if(n===null)return null;var r=n[ut]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var dn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),fn=!1;if(dn)try{var pn={};Object.defineProperty(pn,"passive",{get:function(){fn=!0}}),window.addEventListener(`test`,pn,pn),window.removeEventListener(`test`,pn,pn)}catch{fn=!1}var mn=null,hn=null,gn=null;function _n(){if(gn)return gn;var e,t=hn,n=t.length,r,i=`value`in mn?mn.value:mn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return gn=i.slice(e,1<r?1-r:void 0)}function vn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function yn(){return!0}function bn(){return!1}function xn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?yn:bn,this.isPropagationStopped=bn,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=yn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=yn)},persist:function(){},isPersistent:yn}),t}var Sn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Cn=xn(Sn),wn=m({},Sn,{view:0,detail:0}),Tn=xn(wn),En,Dn,On,kn=m({},wn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Bn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==On&&(On&&e.type===`mousemove`?(En=e.screenX-On.screenX,Dn=e.screenY-On.screenY):Dn=En=0,On=e),En)},movementY:function(e){return`movementY`in e?e.movementY:Dn}}),An=xn(kn),jn=xn(m({},kn,{dataTransfer:0})),Mn=xn(m({},wn,{relatedTarget:0})),Nn=xn(m({},Sn,{animationName:0,elapsedTime:0,pseudoElement:0})),Pn=xn(m({},Sn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Fn=xn(m({},Sn,{data:0})),In={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Ln={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`},Rn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function zn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Rn[e])?!!t[e]:!1}function Bn(){return zn}var Vn=xn(m({},wn,{key:function(e){if(e.key){var t=In[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=vn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Ln[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Bn,charCode:function(e){return e.type===`keypress`?vn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?vn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Hn=xn(m({},kn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Un=xn(m({},wn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Bn})),Wn=xn(m({},Sn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Gn=xn(m({},kn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Kn=xn(m({},Sn,{newState:0,oldState:0})),qn=[9,13,27,32],Jn=dn&&`CompositionEvent`in window,Yn=null;dn&&`documentMode`in document&&(Yn=document.documentMode);var Xn=dn&&`TextEvent`in window&&!Yn,Zn=dn&&(!Jn||Yn&&8<Yn&&11>=Yn),Qn=` `,$n=!1;function er(e,t){switch(e){case`keyup`:return qn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function tr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var nr=!1;function rr(e,t){switch(e){case`compositionend`:return tr(t);case`keypress`:return t.which===32?($n=!0,Qn):null;case`textInput`:return e=t.data,e===Qn&&$n?null:e;default:return null}}function ir(e,t){if(nr)return e===`compositionend`||!Jn&&er(e,t)?(e=_n(),gn=hn=mn=null,nr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Zn&&t.locale!==`ko`?null:t.data;default:return null}}var ar={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function or(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!ar[e.type]:t===`textarea`}function sr(e,t,n,r){an?on?on.push(r):on=[r]:an=r,t=kd(t,`onChange`),0<t.length&&(n=new Cn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var cr=null,lr=null;function ur(e){xd(e,0)}function dr(e){if(Rt(bt(e)))return e}function fr(e,t){if(e===`change`)return t}var pr=!1;if(dn){var mr;if(dn){var hr=`oninput`in document;if(!hr){var gr=document.createElement(`div`);gr.setAttribute(`oninput`,`return;`),hr=typeof gr.oninput==`function`}mr=hr}else mr=!1;pr=mr&&(!document.documentMode||9<document.documentMode)}function _r(){cr&&(cr.detachEvent(`onpropertychange`,vr),lr=cr=null)}function vr(e){if(e.propertyName===`value`&&dr(lr)){var t=[];sr(t,lr,e,rn(e)),ln(ur,t)}}function yr(e,t,n){e===`focusin`?(_r(),cr=t,lr=n,cr.attachEvent(`onpropertychange`,vr)):e===`focusout`&&_r()}function br(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return dr(lr)}function xr(e,t){if(e===`click`)return dr(t)}function Sr(e,t){if(e===`input`||e===`change`)return dr(t)}function Cr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var wr=typeof Object.is==`function`?Object.is:Cr;function Tr(e,t){if(wr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Ce.call(t,i)||!wr(e[i],t[i]))return!1}return!0}function Er(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Dr(e,t){var n=Er(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Er(n)}}function Or(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Or(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function kr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=I(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=I(e.document)}return t}function Ar(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var jr=dn&&`documentMode`in document&&11>=document.documentMode,Mr=null,Nr=null,Pr=null,Fr=!1;function Ir(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Fr||Mr==null||Mr!==I(r)||(r=Mr,`selectionStart`in r&&Ar(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Pr&&Tr(Pr,r)||(Pr=r,r=kd(Nr,`onSelect`),0<r.length&&(t=new Cn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Mr)))}function Lr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Rr={animationend:Lr(`Animation`,`AnimationEnd`),animationiteration:Lr(`Animation`,`AnimationIteration`),animationstart:Lr(`Animation`,`AnimationStart`),transitionrun:Lr(`Transition`,`TransitionRun`),transitionstart:Lr(`Transition`,`TransitionStart`),transitioncancel:Lr(`Transition`,`TransitionCancel`),transitionend:Lr(`Transition`,`TransitionEnd`)},zr={},Br={};dn&&(Br=document.createElement(`div`).style,`AnimationEvent`in window||(delete Rr.animationend.animation,delete Rr.animationiteration.animation,delete Rr.animationstart.animation),`TransitionEvent`in window||delete Rr.transitionend.transition);function Vr(e){if(zr[e])return zr[e];if(!Rr[e])return e;var t=Rr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Br)return zr[e]=t[n];return e}var Hr=Vr(`animationend`),Ur=Vr(`animationiteration`),Wr=Vr(`animationstart`),Gr=Vr(`transitionrun`),Kr=Vr(`transitionstart`),qr=Vr(`transitioncancel`),Jr=Vr(`transitionend`),Yr=new Map,Xr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Xr.push(`scrollEnd`);function Zr(e,t){Yr.set(e,t),Tt(t,[e])}var Qr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},$r=[],ei=0,ti=0;function ni(){for(var e=ei,t=ti=ei=0;t<e;){var n=$r[t];$r[t++]=null;var r=$r[t];$r[t++]=null;var i=$r[t];$r[t++]=null;var a=$r[t];if($r[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&oi(n,i,a)}}function ri(e,t,n,r){$r[ei++]=e,$r[ei++]=t,$r[ei++]=n,$r[ei++]=r,ti|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function ii(e,t,n,r){return ri(e,t,n,r),L(e)}function ai(e,t){return ri(e,null,null,t),L(e)}function oi(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Be(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function L(e){if(50<pu)throw pu=0,mu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var si={};function ci(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function li(e,t,n,r){return new ci(e,t,n,r)}function ui(e){return e=e.prototype,!(!e||!e.isReactComponent)}function di(e,t){var n=e.alternate;return n===null?(n=li(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function fi(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function pi(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)ui(e)&&(s=1);else if(typeof e==`string`)s=qf(e,n,ce.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=li(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return mi(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=li(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=li(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=li(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=li(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function mi(e,t,n,r){return e=li(7,e,r,t),e.lanes=n,e}function hi(e,t,n){return e=li(6,e,null,t),e.lanes=n,e}function gi(e){var t=li(18,null,null,0);return t.stateNode=e,t}function _i(e,t,n){return t=li(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var vi=new WeakMap;function yi(e,t){if(typeof e==`object`&&e){var n=vi.get(e);return n===void 0?(t={value:e,source:t,stack:Se(t)},vi.set(e,t),t):n}return{value:e,source:t,stack:Se(t)}}var bi=[],xi=0,Si=null,R=0,z=[],Ci=0,wi=null,Ti=1,Ei=``;function Di(e,t){bi[xi++]=R,bi[xi++]=Si,Si=e,R=t}function Oi(e,t,n){z[Ci++]=Ti,z[Ci++]=Ei,z[Ci++]=wi,wi=e;var r=Ti;e=Ei;var i=32-Be(r)-1;r&=~(1<<i),n+=1;var a=32-Be(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Ti=1<<32-Be(t)+i|n<<i|r,Ei=a+e}else Ti=1<<a|n<<i|r,Ei=e}function ki(e){e.return!==null&&(Di(e,1),Oi(e,1,0))}function Ai(e){for(;e===Si;)Si=bi[--xi],bi[xi]=null,R=bi[--xi],bi[xi]=null;for(;e===wi;)wi=z[--Ci],z[Ci]=null,Ei=z[--Ci],z[Ci]=null,Ti=z[--Ci],z[Ci]=null}function ji(e,t){z[Ci++]=Ti,z[Ci++]=Ei,z[Ci++]=wi,Ti=t.id,Ei=t.overflow,wi=e}var Mi=null,Ni=null,Pi=!1,Fi=null,Ii=!1,Li=Error(i(519));function Ri(e){throw Wi(yi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Li}function zi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[lt]=e,t[ut]=r,n){case`dialog`:Sd(`cancel`,t),Sd(`close`,t);break;case`iframe`:case`object`:case`embed`:Sd(`load`,t);break;case`video`:case`audio`:for(n=0;n<yd.length;n++)Sd(yd[n],t);break;case`source`:Sd(`error`,t);break;case`img`:case`image`:case`link`:Sd(`error`,t),Sd(`load`,t);break;case`details`:Sd(`toggle`,t);break;case`input`:Sd(`invalid`,t),Ht(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Sd(`invalid`,t);break;case`textarea`:Sd(`invalid`,t),Kt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Fd(t.textContent,n)?(r.popover!=null&&(Sd(`beforetoggle`,t),Sd(`toggle`,t)),r.onScroll!=null&&Sd(`scroll`,t),r.onScrollEnd!=null&&Sd(`scrollend`,t),r.onClick!=null&&(t.onclick=tn),t=!0):t=!1,t||Ri(e,!0)}function Bi(e){for(Mi=e.return;Mi;)switch(Mi.tag){case 5:case 31:case 13:Ii=!1;return;case 27:case 3:Ii=!0;return;default:Mi=Mi.return}}function Vi(e){if(e!==Mi)return!1;if(!Pi)return Bi(e),Pi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||qd(e.type,e.memoizedProps)),n=!n),n&&Ni&&Ri(e),Bi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ni=mf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ni=mf(e)}else t===27?(t=Ni,tf(e.type)?(e=pf,pf=null,Ni=e):Ni=t):Ni=Mi?ff(e.stateNode.nextSibling):null;return!0}function Hi(){Ni=Mi=null,Pi=!1}function Ui(){var e=Fi;return e!==null&&(eu===null?eu=e:eu.push.apply(eu,e),Fi=null),e}function Wi(e){Fi===null?Fi=[e]:Fi.push(e)}var Gi=ae(null),Ki=null,qi=null;function Ji(e,t,n){se(Gi,t._currentValue),t._currentValue=n}function Yi(e){e._currentValue=Gi.current,oe(Gi)}function Xi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Zi(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Xi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Xi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Qi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;wr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===de.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[np]:e.push(np))}a=a.return}e!==null&&Zi(t,e,n,r),t.flags|=262144}function $i(e){for(e=e.firstContext;e!==null;){if(!wr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function ea(e){Ki=e,qi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ta(e){return ra(Ki,e)}function na(e,t){return Ki===null&&ea(e),ra(e,t)}function ra(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},qi===null){if(e===null)throw Error(i(308));qi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else qi=qi.next=t;return n}var ia=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},aa=t.unstable_scheduleCallback,oa=t.unstable_NormalPriority,sa={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ca(){return{controller:new ia,data:new Map,refCount:0}}function la(e){e.refCount--,e.refCount===0&&aa(oa,function(){e.controller.abort()})}var ua=null,da=0,fa=0,pa=null;function ma(e,t){if(ua===null){var n=ua=[];da=0,fa=pd(),pa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return da++,t.then(ha,ha),t}function ha(){if(--da===0&&ua!==null){pa!==null&&(pa.status=`fulfilled`);var e=ua;ua=null,fa=0,pa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ga(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var _a=P.S;P.S=function(e,t){ru=Oe(),typeof t==`object`&&t&&typeof t.then==`function`&&ma(e,t),_a!==null&&_a(e,t)};var va=ae(null);function ya(){var e=va.current;return e===null?zl.pooledCache:e}function ba(e,t){t===null?se(va,va.current):se(va,t.pool)}function xa(){var e=ya();return e===null?null:{parent:sa._currentValue,pool:e}}var Sa=Error(i(460)),Ca=Error(i(474)),wa=Error(i(542)),Ta={then:function(){}};function Ea(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Da(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(tn,tn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ja(e),e;default:if(typeof t.status==`string`)t.then(tn,tn);else{if(e=zl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ja(e),e}throw ka=t,Sa}}function Oa(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ka=e,Sa):e}}var ka=null;function Aa(){if(ka===null)throw Error(i(459));var e=ka;return ka=null,e}function ja(e){if(e===Sa||e===wa)throw Error(i(483))}var Ma=null,Na=0;function Pa(e){var t=Na;return Na+=1,Ma===null&&(Ma=[]),Da(Ma,e,t)}function Fa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ia(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function La(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=di(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=hi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&Oa(i)===t.type)?(t=a(t,n.props),Fa(t,n),t.return=e,t):(t=pi(n.type,n.key,n.props,null,e.mode,r),Fa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=_i(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=mi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=hi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=pi(t.type,t.key,t.props,null,e.mode,n),Fa(n,t),n.return=e,n;case v:return t=_i(t,e.mode,n),t.return=e,t;case O:return t=Oa(t),f(e,t,n)}if(te(t)||M(t))return t=mi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Pa(t),n);if(t.$$typeof===C)return f(e,na(e,t),n);Ia(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=Oa(n),p(e,t,n,r)}if(te(n)||M(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Pa(n),r);if(n.$$typeof===C)return p(e,t,na(e,n),r);Ia(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=Oa(r),m(e,t,n,r,i)}if(te(r)||M(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Pa(r),i);if(r.$$typeof===C)return m(e,t,n,na(t,r),i);Ia(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Pi&&Di(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Pi&&Di(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Pi&&Di(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Pi&&Di(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Pi&&Di(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Pi&&Di(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&Oa(l)===r.type){n(e,r.sibling),c=a(r,o.props),Fa(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=mi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=pi(o.type,o.key,o.props,null,e.mode,c),Fa(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=_i(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=Oa(o),b(e,r,o,c)}if(te(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Pa(o),c);if(o.$$typeof===C)return b(e,r,na(e,o),c);Ia(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=hi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Na=0;var i=b(e,t,n,r);return Ma=null,i}catch(t){if(t===Sa||t===wa)throw t;var a=li(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ra=La(!0),B=La(!1),za=!1;function Ba(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Va(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ha(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ua(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Rl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=L(e),oi(e,null,n),t}return ri(e,r,t,n),L(e)}function Wa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,nt(e,n)}}function Ga(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ka=!1;function qa(){if(Ka){var e=pa;if(e!==null)throw e}}function Ja(e,t,n,r){Ka=!1;var i=e.updateQueue;za=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Bl&f)===f:(r&f)===f){f!==0&&f===fa&&(Ka=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:za=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Jl|=o,e.lanes=o,e.memoizedState=d}}function Ya(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Xa(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ya(n[e],t)}var Za=ae(null),Qa=ae(0);function $a(e,t){e=Kl,se(Qa,e),se(Za,t),Kl=e|t.baseLanes}function eo(){se(Qa,Kl),se(Za,Za.current)}function to(){Kl=Qa.current,oe(Za),oe(Qa)}var no=ae(null),ro=null;function io(e){var t=e.alternate;se(co,co.current&1),se(no,e),ro===null&&(t===null||Za.current!==null||t.memoizedState!==null)&&(ro=e)}function ao(e){se(co,co.current),se(no,e),ro===null&&(ro=e)}function V(e){e.tag===22?(se(co,co.current),se(no,e),ro===null&&(ro=e)):oo(e)}function oo(){se(co,co.current),se(no,no.current)}function so(e){oe(no),ro===e&&(ro=null),oe(co)}var co=ae(0);function lo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||lf(n)||uf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var uo=0,fo=null,po=null,mo=null,ho=!1,go=!1,_o=!1,vo=0,yo=0,bo=null,xo=0;function So(){throw Error(i(321))}function Co(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!wr(e[n],t[n]))return!1;return!0}function wo(e,t,n,r,i,a){return uo=a,fo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,P.H=e===null||e.memoizedState===null?Vs:Hs,_o=!1,a=n(r,i),_o=!1,go&&(a=Eo(t,n,r,i)),To(e),a}function To(e){P.H=Bs;var t=po!==null&&po.next!==null;if(uo=0,mo=po=fo=null,ho=!1,yo=0,bo=null,t)throw Error(i(300));e===null||rc||(e=e.dependencies,e!==null&&$i(e)&&(rc=!0))}function Eo(e,t,n,r){fo=e;var a=0;do{if(go&&(bo=null),yo=0,go=!1,25<=a)throw Error(i(301));if(a+=1,mo=po=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}P.H=Us,o=t(n,r)}while(go);return o}function Do(){var e=P.H,t=e.useState()[0];return t=typeof t.then==`function`?Po(t):t,e=e.useState()[0],(po===null?null:po.memoizedState)!==e&&(fo.flags|=1024),t}function Oo(){var e=vo!==0;return vo=0,e}function ko(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Ao(e){if(ho){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}ho=!1}uo=0,mo=po=fo=null,go=!1,yo=vo=0,bo=null}function jo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mo===null?fo.memoizedState=mo=e:mo=mo.next=e,mo}function Mo(){if(po===null){var e=fo.alternate;e=e===null?null:e.memoizedState}else e=po.next;var t=mo===null?fo.memoizedState:mo.next;if(t!==null)mo=t,po=e;else{if(e===null)throw fo.alternate===null?Error(i(467)):Error(i(310));po=e,e={memoizedState:po.memoizedState,baseState:po.baseState,baseQueue:po.baseQueue,queue:po.queue,next:null},mo===null?fo.memoizedState=mo=e:mo=mo.next=e}return mo}function No(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Po(e){var t=yo;return yo+=1,bo===null&&(bo=[]),e=Da(bo,e,t),t=fo,(mo===null?t.memoizedState:mo.next)===null&&(t=t.alternate,P.H=t===null||t.memoizedState===null?Vs:Hs),e}function Fo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Po(e);if(e.$$typeof===C)return ta(e)}throw Error(i(438,String(e)))}function Io(e){var t=null,n=fo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=fo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=No(),fo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=A;return t.index++,n}function Lo(e,t){return typeof t==`function`?t(e):t}function Ro(e){return zo(Mo(),po,e)}function zo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(uo&f)===f:(Bl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===fa&&(d=!0);else if((uo&p)===p){u=u.next,p===fa&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,fo.lanes|=p,Jl|=p;f=u.action,_o&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,fo.lanes|=f,Jl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!wr(o,e.memoizedState)&&(rc=!0,d&&(n=pa,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Bo(e){var t=Mo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);wr(o,t.memoizedState)||(rc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Vo(e,t,n){var r=fo,a=Mo(),o=Pi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!wr((po||a).memoizedState,n);if(s&&(a.memoizedState=n,rc=!0),a=a.queue,fs(Wo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||mo!==null&&mo.memoizedState.tag&1){if(r.flags|=2048,ss(9,{destroy:void 0},Uo.bind(null,r,a,n,t),null),zl===null)throw Error(i(349));o||uo&127||Ho(r,t,n)}return n}function Ho(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=fo.updateQueue,t===null?(t=No(),fo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Uo(e,t,n,r){t.value=n,t.getSnapshot=r,Go(t)&&Ko(e)}function Wo(e,t,n){return n(function(){Go(t)&&Ko(e)})}function Go(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!wr(e,n)}catch{return!0}}function Ko(e){var t=ai(e,2);t!==null&&_u(t,e,2)}function qo(e){var t=jo();if(typeof e==`function`){var n=e;if(e=n(),_o){ze(!0);try{n()}finally{ze(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:e},t}function Jo(e,t,n,r){return e.baseState=n,zo(e,po,typeof r==`function`?r:Lo)}function Yo(e,t,n,r,a){if(Ls(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};P.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Xo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Xo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=P.T,o={};P.T=o;try{var s=n(i,r),c=P.S;c!==null&&c(o,s),Zo(e,t,s)}catch(n){$o(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),P.T=a}}else try{a=n(i,r),Zo(e,t,a)}catch(n){$o(e,t,n)}}function Zo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Qo(e,t,n)},function(n){return $o(e,t,n)}):Qo(e,t,n)}function Qo(e,t,n){t.status=`fulfilled`,t.value=n,es(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Xo(e,n)))}function $o(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,es(t),t=t.next;while(t!==r)}e.action=null}function es(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function ts(e,t){return t}function ns(e,t){if(Pi){var n=zl.formState;if(n!==null){a:{var r=fo;if(Pi){if(Ni){b:{for(var i=Ni,a=Ii;i.nodeType!==8;){if(!a){i=null;break b}if(i=ff(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Ni=ff(i.nextSibling),r=i.data===`F!`;break a}}Ri(r)}r=!1}r&&(t=n[0])}}return n=jo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ts,lastRenderedState:t},n.queue=r,n=Ps.bind(null,fo,r),r.dispatch=n,r=qo(!1),a=Is.bind(null,fo,!1,r.queue),r=jo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Yo.bind(null,fo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function rs(e){return is(Mo(),po,e)}function is(e,t,n){if(t=zo(e,t,ts)[0],e=Ro(Lo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Po(t)}catch(e){throw e===Sa?wa:e}else r=t;t=Mo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(fo.flags|=2048,ss(9,{destroy:void 0},as.bind(null,i,n),null)),[r,a,e]}function as(e,t){e.action=t}function os(e){var t=Mo(),n=po;if(n!==null)return is(t,n,e);Mo(),t=t.memoizedState,n=Mo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function ss(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=fo.updateQueue,t===null&&(t=No(),fo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function cs(){return Mo().memoizedState}function ls(e,t,n,r){var i=jo();fo.flags|=e,i.memoizedState=ss(1|t,{destroy:void 0},n,r===void 0?null:r)}function us(e,t,n,r){var i=Mo();r=r===void 0?null:r;var a=i.memoizedState.inst;po!==null&&r!==null&&Co(r,po.memoizedState.deps)?i.memoizedState=ss(t,a,n,r):(fo.flags|=e,i.memoizedState=ss(1|t,a,n,r))}function ds(e,t){ls(8390656,8,e,t)}function fs(e,t){us(2048,8,e,t)}function ps(e){fo.flags|=4;var t=fo.updateQueue;if(t===null)t=No(),fo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ms(e){var t=Mo().memoizedState;return ps({ref:t,nextImpl:e}),function(){if(Rl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function hs(e,t){return us(4,2,e,t)}function gs(e,t){return us(4,4,e,t)}function _s(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function vs(e,t,n){n=n==null?null:n.concat([e]),us(4,4,_s.bind(null,t,e),n)}function ys(){}function bs(e,t){var n=Mo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Co(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function xs(e,t){var n=Mo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Co(t,r[1]))return r[0];if(r=e(),_o){ze(!0);try{e()}finally{ze(!1)}}return n.memoizedState=[r,t],r}function Ss(e,t,n){return n===void 0||uo&1073741824&&!(Bl&261930)?e.memoizedState=t:(e.memoizedState=n,e=gu(),fo.lanes|=e,Jl|=e,n)}function Cs(e,t,n,r){return wr(n,t)?n:Za.current===null?!(uo&42)||uo&1073741824&&!(Bl&261930)?(rc=!0,e.memoizedState=n):(e=gu(),fo.lanes|=e,Jl|=e,t):(e=Ss(e,n,r),wr(e,t)||(rc=!0),e)}function ws(e,t,n,r,i){var a=F.p;F.p=a!==0&&8>a?a:8;var o=P.T,s={};P.T=s,Is(e,!1,t,n);try{var c=i(),l=P.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Fs(e,t,ga(c,r),hu(e)):Fs(e,t,r,hu(e))}catch(n){Fs(e,t,{then:function(){},status:`rejected`,reason:n},hu())}finally{F.p=a,o!==null&&s.types!==null&&(o.types=s.types),P.T=o}}function Ts(){}function Es(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Ds(e).queue;ws(e,a,t,ne,n===null?Ts:function(){return Os(e),n(r)})}function Ds(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ne,baseState:ne,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:ne},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Os(e){var t=Ds(e);t.next===null&&(t=e.alternate.memoizedState),Fs(e,t.next.queue,{},hu())}function ks(){return ta(np)}function As(){return Mo().memoizedState}function js(){return Mo().memoizedState}function Ms(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=hu();e=Ha(n);var r=Ua(t,e,n);r!==null&&(_u(r,t,n),Wa(r,t,n)),t={cache:ca()},e.payload=t;return}t=t.return}}function Ns(e,t,n){var r=hu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ls(e)?Rs(t,n):(n=ii(e,t,n,r),n!==null&&(_u(n,e,r),zs(n,t,r)))}function Ps(e,t,n){Fs(e,t,n,hu())}function Fs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ls(e))Rs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,wr(s,o))return ri(e,t,i,0),zl===null&&ni(),!1}catch{}if(n=ii(e,t,i,r),n!==null)return _u(n,e,r),zs(n,t,r),!0}return!1}function Is(e,t,n,r){if(r={lane:2,revertLane:pd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ls(e)){if(t)throw Error(i(479))}else t=ii(e,n,r,2),t!==null&&_u(t,e,2)}function Ls(e){var t=e.alternate;return e===fo||t!==null&&t===fo}function Rs(e,t){go=ho=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,nt(e,n)}}var Bs={readContext:ta,use:Fo,useCallback:So,useContext:So,useEffect:So,useImperativeHandle:So,useLayoutEffect:So,useInsertionEffect:So,useMemo:So,useReducer:So,useRef:So,useState:So,useDebugValue:So,useDeferredValue:So,useTransition:So,useSyncExternalStore:So,useId:So,useHostTransitionStatus:So,useFormState:So,useActionState:So,useOptimistic:So,useMemoCache:So,useCacheRefresh:So};Bs.useEffectEvent=So;var Vs={readContext:ta,use:Fo,useCallback:function(e,t){return jo().memoizedState=[e,t===void 0?null:t],e},useContext:ta,useEffect:ds,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),ls(4194308,4,_s.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ls(4194308,4,e,t)},useInsertionEffect:function(e,t){ls(4,2,e,t)},useMemo:function(e,t){var n=jo();t=t===void 0?null:t;var r=e();if(_o){ze(!0);try{e()}finally{ze(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=jo();if(n!==void 0){var i=n(t);if(_o){ze(!0);try{n(t)}finally{ze(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ns.bind(null,fo,e),[r.memoizedState,e]},useRef:function(e){var t=jo();return e={current:e},t.memoizedState=e},useState:function(e){e=qo(e);var t=e.queue,n=Ps.bind(null,fo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ys,useDeferredValue:function(e,t){return Ss(jo(),e,t)},useTransition:function(){var e=qo(!1);return e=ws.bind(null,fo,e.queue,!0,!1),jo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=fo,a=jo();if(Pi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),zl===null)throw Error(i(349));Bl&127||Ho(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ds(Wo.bind(null,r,o,e),[e]),r.flags|=2048,ss(9,{destroy:void 0},Uo.bind(null,r,o,n,t),null),n},useId:function(){var e=jo(),t=zl.identifierPrefix;if(Pi){var n=Ei,r=Ti;n=(r&~(1<<32-Be(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=vo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=xo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ks,useFormState:ns,useActionState:ns,useOptimistic:function(e){var t=jo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Is.bind(null,fo,!0,n),n.dispatch=t,[e,t]},useMemoCache:Io,useCacheRefresh:function(){return jo().memoizedState=Ms.bind(null,fo)},useEffectEvent:function(e){var t=jo(),n={impl:e};return t.memoizedState=n,function(){if(Rl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Hs={readContext:ta,use:Fo,useCallback:bs,useContext:ta,useEffect:fs,useImperativeHandle:vs,useInsertionEffect:hs,useLayoutEffect:gs,useMemo:xs,useReducer:Ro,useRef:cs,useState:function(){return Ro(Lo)},useDebugValue:ys,useDeferredValue:function(e,t){return Cs(Mo(),po.memoizedState,e,t)},useTransition:function(){var e=Ro(Lo)[0],t=Mo().memoizedState;return[typeof e==`boolean`?e:Po(e),t]},useSyncExternalStore:Vo,useId:As,useHostTransitionStatus:ks,useFormState:rs,useActionState:rs,useOptimistic:function(e,t){return Jo(Mo(),po,e,t)},useMemoCache:Io,useCacheRefresh:js};Hs.useEffectEvent=ms;var Us={readContext:ta,use:Fo,useCallback:bs,useContext:ta,useEffect:fs,useImperativeHandle:vs,useInsertionEffect:hs,useLayoutEffect:gs,useMemo:xs,useReducer:Bo,useRef:cs,useState:function(){return Bo(Lo)},useDebugValue:ys,useDeferredValue:function(e,t){var n=Mo();return po===null?Ss(n,e,t):Cs(n,po.memoizedState,e,t)},useTransition:function(){var e=Bo(Lo)[0],t=Mo().memoizedState;return[typeof e==`boolean`?e:Po(e),t]},useSyncExternalStore:Vo,useId:As,useHostTransitionStatus:ks,useFormState:os,useActionState:os,useOptimistic:function(e,t){var n=Mo();return po===null?(n.baseState=e,[e,n.queue.dispatch]):Jo(n,po,e,t)},useMemoCache:Io,useCacheRefresh:js};Us.useEffectEvent=ms;function Ws(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Gs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=hu(),i=Ha(r);i.payload=t,n!=null&&(i.callback=n),t=Ua(e,i,r),t!==null&&(_u(t,e,r),Wa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=hu(),i=Ha(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ua(e,i,r),t!==null&&(_u(t,e,r),Wa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=hu(),r=Ha(n);r.tag=2,t!=null&&(r.callback=t),t=Ua(e,r,n),t!==null&&(_u(t,e,n),Wa(t,e,n))}};function Ks(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Tr(n,r)||!Tr(i,a):!0}function qs(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Gs.enqueueReplaceState(t,t.state,null)}function H(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Js(e){Qr(e)}function Ys(e){console.error(e)}function Xs(e){Qr(e)}function Zs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function U(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Qs(e,t,n){return n=Ha(n),n.tag=3,n.payload={element:null},n.callback=function(){Zs(e,t)},n}function $s(e){return e=Ha(e),e.tag=3,e}function ec(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){U(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){U(t,n,r),typeof i!=`function`&&(ou===null?ou=new Set([this]):ou.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function tc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Qi(t,n,a,!0),n=no.current,n!==null){switch(n.tag){case 31:case 13:return ro===null?ku():n.alternate===null&&ql===0&&(ql=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Ta?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),qu(e,r,a)),!1;case 22:return n.flags|=65536,r===Ta?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),qu(e,r,a)),!1}throw Error(i(435,n.tag))}return qu(e,r,a),ku(),!1}if(Pi)return t=no.current,t===null?(r!==Li&&(t=Error(i(423),{cause:r}),Wi(yi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=yi(r,n),a=Qs(e.stateNode,r,a),Ga(e,a),ql!==4&&(ql=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Li&&(e=Error(i(422),{cause:r}),Wi(yi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=yi(o,n),$l===null?$l=[o]:$l.push(o),ql!==4&&(ql=2),t===null)return!0;r=yi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Qs(n.stateNode,r,e),Ga(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(ou===null||!ou.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=$s(a),ec(a,e,n,r),Ga(n,a),!1}n=n.return}while(n!==null);return!1}var nc=Error(i(461)),rc=!1;function W(e,t,n,r){t.child=e===null?B(t,null,n,r):Ra(t,e.child,n,r)}function ic(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return ea(t),r=wo(e,t,n,o,a,i),s=Oo(),e!==null&&!rc?(ko(e,t,i),Ec(e,t,i)):(Pi&&s&&ki(t),t.flags|=1,W(e,t,r,i),t.child)}function ac(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ui(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,oc(e,t,a,r,i)):(e=pi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Dc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Tr:n,n(o,r)&&e.ref===t.ref)return Ec(e,t,i)}return t.flags|=1,e=di(a,r),e.ref=t.ref,e.return=t,t.child=e}function oc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Tr(a,r)&&e.ref===t.ref)if(rc=!1,t.pendingProps=r=a,Dc(e,i))e.flags&131072&&(rc=!0);else return t.lanes=e.lanes,Ec(e,t,i)}return G(e,t,n,r,i)}function sc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return lc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ba(t,a===null?null:a.cachePool),a===null?eo():$a(t,a),V(t);else return r=t.lanes=536870912,lc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ba(t,null),eo(),oo(t)):(ba(t,a.cachePool),$a(t,a),oo(t),t.memoizedState=null);return W(e,t,i,n),t.child}function cc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function lc(e,t,n,r,i){var a=ya();return a=a===null?null:{parent:sa._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ba(t,null),eo(),V(t),e!==null&&Qi(e,t,r,!0),t.childLanes=i,null}function uc(e,t){return t=Sc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function dc(e,t,n){return Ra(t,e.child,null,n),e=uc(t,t.pendingProps),e.flags|=2,so(t),t.memoizedState=null,e}function fc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Pi){if(r.mode===`hidden`)return e=uc(t,r),t.lanes=536870912,cc(null,e);if(ao(t),(e=Ni)?(e=cf(e,Ii),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:wi===null?null:{id:Ti,overflow:Ei},retryLane:536870912,hydrationErrors:null},n=gi(e),n.return=t,t.child=n,Mi=t,Ni=null)):e=null,e===null)throw Ri(t);return t.lanes=536870912,null}return uc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(ao(t),a)if(t.flags&256)t.flags&=-257,t=dc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(rc||Qi(e,t,n,!1),a=(n&e.childLanes)!==0,rc||a){if(r=zl,r!==null&&(s=rt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,ai(e,s),_u(r,e,s),nc;ku(),t=dc(e,t,n)}else e=o.treeContext,Ni=ff(s.nextSibling),Mi=t,Pi=!0,Fi=null,Ii=!1,e!==null&&ji(t,e),t=uc(t,r),t.flags|=4096;return t}return e=di(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function pc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function G(e,t,n,r,i){return ea(t),n=wo(e,t,n,r,void 0,i),r=Oo(),e!==null&&!rc?(ko(e,t,i),Ec(e,t,i)):(Pi&&r&&ki(t),t.flags|=1,W(e,t,n,i),t.child)}function mc(e,t,n,r,i,a){return ea(t),t.updateQueue=null,n=Eo(t,r,n,i),To(e),r=Oo(),e!==null&&!rc?(ko(e,t,a),Ec(e,t,a)):(Pi&&r&&ki(t),t.flags|=1,W(e,t,n,a),t.child)}function hc(e,t,n,r,i){if(ea(t),t.stateNode===null){var a=si,o=n.contextType;typeof o==`object`&&o&&(a=ta(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Gs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ba(t),o=n.contextType,a.context=typeof o==`object`&&o?ta(o):si,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ws(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Gs.enqueueReplaceState(a,a.state,null),Ja(t,r,a,i),qa(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=H(n,s);a.props=c;var l=a.context,u=n.contextType;o=si,typeof u==`object`&&u&&(o=ta(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&qs(t,a,r,o),za=!1;var f=t.memoizedState;a.state=f,Ja(t,r,a,i),qa(),l=t.memoizedState,s||f!==l||za?(typeof d==`function`&&(Ws(t,n,d,r),l=t.memoizedState),(c=za||Ks(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Va(e,t),o=t.memoizedProps,u=H(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=si,typeof l==`object`&&l&&(c=ta(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&qs(t,a,r,c),za=!1,f=t.memoizedState,a.state=f,Ja(t,r,a,i),qa();var p=t.memoizedState;o!==d||f!==p||za||e!==null&&e.dependencies!==null&&$i(e.dependencies)?(typeof s==`function`&&(Ws(t,n,s,r),p=t.memoizedState),(u=za||Ks(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&$i(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,pc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ra(t,e.child,null,i),t.child=Ra(t,null,n,i)):W(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Ec(e,t,i),e}function gc(e,t,n,r){return Hi(),t.flags|=256,W(e,t,n,r),t.child}var _c={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function vc(e){return{baseLanes:e,cachePool:xa()}}function yc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Zl),e}function bc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(co.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Pi){if(a?io(t):oo(t),(e=Ni)?(e=cf(e,Ii),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:wi===null?null:{id:Ti,overflow:Ei},retryLane:536870912,hydrationErrors:null},n=gi(e),n.return=t,t.child=n,Mi=t,Ni=null)):e=null,e===null)throw Ri(t);return uf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(oo(t),a=t.mode,c=Sc({mode:`hidden`,children:c},a),r=mi(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=vc(n),r.childLanes=yc(e,s,n),t.memoizedState=_c,cc(null,r)):(io(t),xc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(io(t),t.flags&=-257,t=Cc(e,t,n)):t.memoizedState===null?(oo(t),c=r.fallback,a=t.mode,r=Sc({mode:`visible`,children:r.children},a),c=mi(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ra(t,e.child,null,n),r=t.child,r.memoizedState=vc(n),r.childLanes=yc(e,s,n),t.memoizedState=_c,t=cc(null,r)):(oo(t),t.child=e.child,t.flags|=128,t=null);else if(io(t),uf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Wi({value:r,source:null,stack:null}),t=Cc(e,t,n)}else if(rc||Qi(e,t,n,!1),s=(n&e.childLanes)!==0,rc||s){if(s=zl,s!==null&&(r=rt(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,ai(e,r),_u(s,e,r),nc;lf(c)||ku(),t=Cc(e,t,n)}else lf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ni=ff(c.nextSibling),Mi=t,Pi=!0,Fi=null,Ii=!1,e!==null&&ji(t,e),t=xc(t,r.children),t.flags|=4096);return t}return a?(oo(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=di(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=mi(c,a,n,null),c.flags|=2):c=di(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,cc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=vc(n):(a=c.cachePool,a===null?a=xa():(l=sa._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=yc(e,s,n),t.memoizedState=_c,cc(e.child,r)):(io(t),n=e.child,e=n.sibling,n=di(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function xc(e,t){return t=Sc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Sc(e,t){return e=li(22,e,null,t),e.lanes=0,e}function Cc(e,t,n){return Ra(t,e.child,null,n),e=xc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function wc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Xi(e.return,t,n)}function Tc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function K(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=co.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,se(co,o),W(e,t,r,n),r=Pi?R:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wc(e,n,t);else if(e.tag===19)wc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&lo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Tc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&lo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Tc(t,!0,n,null,a,r);break;case`together`:Tc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Ec(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Jl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Qi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=di(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=di(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Dc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&$i(e))):!0}function Oc(e,t,n){switch(t.tag){case 3:fe(t,t.stateNode.containerInfo),Ji(t,sa,e.memoizedState.cache),Hi();break;case 27:case 5:me(t);break;case 4:fe(t,t.stateNode.containerInfo);break;case 10:Ji(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,ao(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(io(t),e=Ec(e,t,n),e===null?null:e.sibling):bc(e,t,n):(io(t),t.flags|=128,null);io(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Qi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return K(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),se(co,co.current),r)break;return null;case 22:return t.lanes=0,sc(e,t,n,t.pendingProps);case 24:Ji(t,sa,e.memoizedState.cache)}return Ec(e,t,n)}function kc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)rc=!0;else{if(!Dc(e,n)&&!(t.flags&128))return rc=!1,Oc(e,t,n);rc=!!(e.flags&131072)}else rc=!1,Pi&&t.flags&1048576&&Oi(t,R,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Oa(t.elementType),t.type=e,typeof e==`function`)ui(e)?(r=H(e,r),t.tag=1,t=hc(null,t,e,r,n)):(t.tag=0,t=G(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=ic(null,t,e,r,n);break a}else if(a===D){t.tag=14,t=ac(null,t,e,r,n);break a}}throw t=ee(e)||e,Error(i(306,t,``))}}return t;case 0:return G(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=H(r,t.pendingProps),hc(e,t,r,a,n);case 3:a:{if(fe(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Va(e,t),Ja(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ji(t,sa,r),r!==o.cache&&Zi(t,[sa],n,!0),qa(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=gc(e,t,r,n);break a}else if(r!==a){a=yi(Error(i(424)),t),Wi(a),t=gc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Ni=ff(e.firstChild),Mi=t,Pi=!0,Fi=null,Ii=!0,n=B(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Hi(),r===a){t=Ec(e,t,n);break a}W(e,t,r,n)}t=t.child}return t;case 26:return pc(e,t),e===null?(n=Nf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Pi||(n=t.type,e=t.pendingProps,r=Wd(ue.current).createElement(n),r[lt]=t,r[ut]=e,Rd(r,n,e),St(r),t.stateNode=r):t.memoizedState=Nf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return me(t),e===null&&Pi&&(r=t.stateNode=gf(t.type,t.pendingProps,ue.current),Mi=t,Ii=!0,a=Ni,tf(t.type)?(pf=a,Ni=ff(r.firstChild)):Ni=a),W(e,t,t.pendingProps.children,n),pc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Pi&&((a=r=Ni)&&(r=of(r,t.type,t.pendingProps,Ii),r===null?a=!1:(t.stateNode=r,Mi=t,Ni=ff(r.firstChild),Ii=!1,a=!0)),a||Ri(t)),me(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,qd(a,o)?r=null:s!==null&&qd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=wo(e,t,Do,null,null,n),np._currentValue=a),pc(e,t),W(e,t,r,n),t.child;case 6:return e===null&&Pi&&((e=n=Ni)&&(n=sf(n,t.pendingProps,Ii),n===null?e=!1:(t.stateNode=n,Mi=t,Ni=null,e=!0)),e||Ri(t)),null;case 13:return bc(e,t,n);case 4:return fe(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ra(t,null,r,n):W(e,t,r,n),t.child;case 11:return ic(e,t,t.type,t.pendingProps,n);case 7:return W(e,t,t.pendingProps,n),t.child;case 8:return W(e,t,t.pendingProps.children,n),t.child;case 12:return W(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ji(t,t.type,r.value),W(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,ea(t),a=ta(a),r=r(a),t.flags|=1,W(e,t,r,n),t.child;case 14:return ac(e,t,t.type,t.pendingProps,n);case 15:return oc(e,t,t.type,t.pendingProps,n);case 19:return K(e,t,n);case 31:return fc(e,t,n);case 22:return sc(e,t,n,t.pendingProps);case 24:return ea(t),r=ta(sa),e===null?(a=ya(),a===null&&(a=zl,o=ca(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Ba(t),Ji(t,sa,a)):((e.lanes&n)!==0&&(Va(e,t),Ja(t,null,null,n),qa()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ji(t,sa,r),r!==a.cache&&Zi(t,[sa],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ji(t,sa,r))),W(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Ac(e){e.flags|=4}function jc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Eu())e.flags|=8192;else throw ka=Ta,Ca}else e.flags&=-16777217}function Mc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Jf(t))if(Eu())e.flags|=8192;else throw ka=Ta,Ca}function Nc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ze(),e.lanes|=t,Ql|=t)}function Pc(e,t){if(!Pi)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Fc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Ic(e,t,n){var r=t.pendingProps;switch(Ai(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Fc(t),null;case 1:return Fc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Yi(sa),pe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Vi(t)?Ac(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ui())),Fc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Ac(t),o===null?(Fc(t),jc(t,a,null,r,n)):(Fc(t),Mc(t,o))):o?o===e.memoizedState?(Fc(t),t.flags&=-16777217):(Ac(t),Fc(t),Mc(t,o)):(e=e.memoizedProps,e!==r&&Ac(t),Fc(t),jc(t,a,e,r,n)),null;case 27:if(he(t),n=ue.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Ac(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Fc(t),null}e=ce.current,Vi(t)?zi(t,e):(e=gf(a,r,n),t.stateNode=e,Ac(t))}return Fc(t),null;case 5:if(he(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Ac(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Fc(t),null}if(o=ce.current,Vi(t))zi(t,o);else{var s=Wd(ue.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[lt]=t,o[ut]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Rd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Ac(t)}}return Fc(t),jc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Ac(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ue.current,Vi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Mi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[lt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Fd(e.nodeValue,n)),e||Ri(t,!0)}else e=Wd(e).createTextNode(r),e[lt]=t,t.stateNode=e}return Fc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Vi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[lt]=t}else Hi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Fc(t),e=!1}else n=Ui(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(so(t),t):(so(t),null);if(t.flags&128)throw Error(i(558))}return Fc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Vi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[lt]=t}else Hi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Fc(t),a=!1}else a=Ui(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(so(t),t):(so(t),null)}return so(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Nc(t,t.updateQueue),Fc(t),null);case 4:return pe(),e===null&&Td(t.stateNode.containerInfo),Fc(t),null;case 10:return Yi(t.type),Fc(t),null;case 19:if(oe(co),r=t.memoizedState,r===null)return Fc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Pc(r,!1);else{if(ql!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=lo(e),o!==null){for(t.flags|=128,Pc(r,!1),e=o.updateQueue,t.updateQueue=e,Nc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)fi(n,e),n=n.sibling;return se(co,co.current&1|2),Pi&&Di(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Oe()>iu&&(t.flags|=128,a=!0,Pc(r,!1),t.lanes=4194304)}else{if(!a)if(e=lo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Nc(t,e),Pc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Pi)return Fc(t),null}else 2*Oe()-r.renderingStartTime>iu&&n!==536870912&&(t.flags|=128,a=!0,Pc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Fc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Oe(),e.sibling=null,n=co.current,se(co,a?n&1|2:n&1),Pi&&Di(t,r.treeForkCount),e);case 22:case 23:return so(t),to(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Fc(t),t.subtreeFlags&6&&(t.flags|=8192)):Fc(t),n=t.updateQueue,n!==null&&Nc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&oe(va),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Yi(sa),Fc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Lc(e,t){switch(Ai(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Yi(sa),pe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return he(t),null;case 31:if(t.memoizedState!==null){if(so(t),t.alternate===null)throw Error(i(340));Hi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(so(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Hi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return oe(co),null;case 4:return pe(),null;case 10:return Yi(t.type),null;case 22:case 23:return so(t),to(),e!==null&&oe(va),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Yi(sa),null;case 25:return null;default:return null}}function Rc(e,t){switch(Ai(t),t.tag){case 3:Yi(sa),pe();break;case 26:case 27:case 5:he(t);break;case 4:pe();break;case 31:t.memoizedState!==null&&so(t);break;case 13:so(t);break;case 19:oe(co);break;case 10:Yi(t.type);break;case 22:case 23:so(t),to(),e!==null&&oe(va);break;case 24:Yi(sa)}}function zc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Ku(t,t.return,e)}}function Bc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Ku(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Ku(t,t.return,e)}}function Vc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Xa(t,n)}catch(t){Ku(e,e.return,t)}}}function Hc(e,t,n){n.props=H(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Ku(e,t,n)}}function Uc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Ku(e,t,n)}}function Wc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Ku(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Ku(e,t,n)}else n.current=null}function Gc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Ku(e,e.return,t)}}function Kc(e,t,n){try{var r=e.stateNode;zd(r,e.type,n,t),r[ut]=t}catch(t){Ku(e,e.return,t)}}function qc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&tf(e.type)||e.tag===4}function Jc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||qc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&tf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Yc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=tn));else if(r!==4&&(r===27&&tf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Yc(e,t,n),e=e.sibling;e!==null;)Yc(e,t,n),e=e.sibling}function Xc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&tf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Xc(e,t,n),e=e.sibling;e!==null;)Xc(e,t,n),e=e.sibling}function Zc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Rd(t,r,n),t[lt]=e,t[ut]=n}catch(t){Ku(e,e.return,t)}}var Qc=!1,$c=!1,el=!1,tl=typeof WeakSet==`function`?WeakSet:Set,nl=null;function rl(e,t){if(e=e.containerInfo,Hd=up,e=kr(e),Ar(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Ud={focusedElem:e,selectionRange:n},up=!1,nl=t;nl!==null;)if(t=nl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,nl=e;else for(;nl!==null;){switch(t=nl,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=H(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Ku(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)af(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:af(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,nl=e;break}nl=t.return}}function il(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:yl(e,n),r&4&&zc(5,n);break;case 1:if(yl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Ku(n,n.return,e)}else{var i=H(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Ku(n,n.return,e)}}r&64&&Vc(n),r&512&&Uc(n,n.return);break;case 3:if(yl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Xa(e,t)}catch(e){Ku(n,n.return,e)}}break;case 27:t===null&&r&4&&Zc(n);case 26:case 5:yl(e,n),t===null&&r&4&&Gc(n),r&512&&Uc(n,n.return);break;case 12:yl(e,n);break;case 31:yl(e,n),r&4&&ul(e,n);break;case 13:yl(e,n),r&4&&dl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Xu.bind(null,n),df(e,n))));break;case 22:if(r=n.memoizedState!==null||Qc,!r){t=t!==null&&t.memoizedState!==null||$c,i=Qc;var a=$c;Qc=r,($c=t)&&!a?xl(e,n,(n.subtreeFlags&8772)!=0):yl(e,n),Qc=i,$c=a}break;case 30:break;default:yl(e,n)}}function al(e){var t=e.alternate;t!==null&&(e.alternate=null,al(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&_t(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var ol=null,sl=!1;function cl(e,t,n){for(n=n.child;n!==null;)ll(e,t,n),n=n.sibling}function ll(e,t,n){if(Re&&typeof Re.onCommitFiberUnmount==`function`)try{Re.onCommitFiberUnmount(Le,n)}catch{}switch(n.tag){case 26:$c||Wc(n,t),cl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:$c||Wc(n,t);var r=ol,i=sl;tf(n.type)&&(ol=n.stateNode,sl=!1),cl(e,t,n),_f(n.stateNode),ol=r,sl=i;break;case 5:$c||Wc(n,t);case 6:if(r=ol,i=sl,ol=null,cl(e,t,n),ol=r,sl=i,ol!==null)if(sl)try{(ol.nodeType===9?ol.body:ol.nodeName===`HTML`?ol.ownerDocument.body:ol).removeChild(n.stateNode)}catch(e){Ku(n,t,e)}else try{ol.removeChild(n.stateNode)}catch(e){Ku(n,t,e)}break;case 18:ol!==null&&(sl?(e=ol,nf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Ip(e)):nf(ol,n.stateNode));break;case 4:r=ol,i=sl,ol=n.stateNode.containerInfo,sl=!0,cl(e,t,n),ol=r,sl=i;break;case 0:case 11:case 14:case 15:Bc(2,n,t),$c||Bc(4,n,t),cl(e,t,n);break;case 1:$c||(Wc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Hc(n,t,r)),cl(e,t,n);break;case 21:cl(e,t,n);break;case 22:$c=(r=$c)||n.memoizedState!==null,cl(e,t,n),$c=r;break;default:cl(e,t,n)}}function ul(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ip(e)}catch(e){Ku(t,t.return,e)}}}function dl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ip(e)}catch(e){Ku(t,t.return,e)}}function fl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new tl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new tl),t;default:throw Error(i(435,e.tag))}}function pl(e,t){var n=fl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Zu.bind(null,e,t);t.then(r,r)}})}function ml(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(tf(c.type)){ol=c.stateNode,sl=!1;break a}break;case 5:ol=c.stateNode,sl=!1;break a;case 3:case 4:ol=c.stateNode.containerInfo,sl=!0;break a}c=c.return}if(ol===null)throw Error(i(160));ll(o,s,a),ol=null,sl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)gl(t,e),t=t.sibling}var hl=null;function gl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ml(t,e),_l(e),r&4&&(Bc(3,e,e.return),zc(3,e),Bc(5,e,e.return));break;case 1:ml(t,e),_l(e),r&512&&($c||n===null||Wc(n,n.return)),r&64&&Qc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=hl;if(ml(t,e),_l(e),r&512&&($c||n===null||Wc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[gt]||o[lt]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Rd(o,r,n),o[lt]=e,St(o),r=o;break a;case`link`:var s=Gf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Rd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Gf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Rd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[lt]=e,St(o),r=o}e.stateNode=r}else Kf(a,e.type,e.stateNode);else e.stateNode=Bf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Kc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Kf(a,e.type,e.stateNode):Bf(a,r,e.memoizedProps))}break;case 27:ml(t,e),_l(e),r&512&&($c||n===null||Wc(n,n.return)),n!==null&&r&4&&Kc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(ml(t,e),_l(e),r&512&&($c||n===null||Wc(n,n.return)),e.flags&32){a=e.stateNode;try{qt(a,``)}catch(t){Ku(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Kc(e,a,n===null?a:n.memoizedProps)),r&1024&&(el=!0);break;case 6:if(ml(t,e),_l(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Ku(e,e.return,t)}}break;case 3:if(Wf=null,a=hl,hl=bf(t.containerInfo),ml(t,e),hl=a,_l(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Ip(t.containerInfo)}catch(t){Ku(e,e.return,t)}el&&(el=!1,vl(e));break;case 4:r=hl,hl=bf(e.stateNode.containerInfo),ml(t,e),_l(e),hl=r;break;case 12:ml(t,e),_l(e);break;case 31:ml(t,e),_l(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,pl(e,r)));break;case 13:ml(t,e),_l(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(nu=Oe()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,pl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Qc,d=$c;if(Qc=u||a,$c=d||l,ml(t,e),$c=d,Qc=u,_l(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||Qc||$c||bl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Ku(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Ku(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?rf(m,!0):rf(l.stateNode,!1)}catch(e){Ku(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,pl(e,n))));break;case 19:ml(t,e),_l(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,pl(e,r)));break;case 30:break;case 21:break;default:ml(t,e),_l(e)}}function _l(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(qc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Xc(e,Jc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(qt(o,``),n.flags&=-33),Xc(e,Jc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Yc(e,Jc(e),s);break;default:throw Error(i(161))}}catch(t){Ku(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function vl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;vl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function yl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)il(e,t.alternate,t),t=t.sibling}function bl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Bc(4,t,t.return),bl(t);break;case 1:Wc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Hc(t,t.return,n),bl(t);break;case 27:_f(t.stateNode);case 26:case 5:Wc(t,t.return),bl(t);break;case 22:t.memoizedState===null&&bl(t);break;case 30:bl(t);break;default:bl(t)}e=e.sibling}}function xl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:xl(i,a,n),zc(4,a);break;case 1:if(xl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Ku(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ya(c[i],s)}catch(e){Ku(r,r.return,e)}}n&&o&64&&Vc(a),Uc(a,a.return);break;case 27:Zc(a);case 26:case 5:xl(i,a,n),n&&r===null&&o&4&&Gc(a),Uc(a,a.return);break;case 12:xl(i,a,n);break;case 31:xl(i,a,n),n&&o&4&&ul(i,a);break;case 13:xl(i,a,n),n&&o&4&&dl(i,a);break;case 22:a.memoizedState===null&&xl(i,a,n),Uc(a,a.return);break;case 30:break;default:xl(i,a,n)}t=t.sibling}}function Sl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&la(n))}function Cl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&la(e))}function wl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Tl(e,t,n,r),t=t.sibling}function Tl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:wl(e,t,n,r),i&2048&&zc(9,t);break;case 1:wl(e,t,n,r);break;case 3:wl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&la(e)));break;case 12:if(i&2048){wl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Ku(t,t.return,e)}}else wl(e,t,n,r);break;case 31:wl(e,t,n,r);break;case 13:wl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?wl(e,t,n,r):(a._visibility|=2,El(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?wl(e,t,n,r):Dl(e,t),i&2048&&Sl(o,t);break;case 24:wl(e,t,n,r),i&2048&&Cl(t.alternate,t);break;default:wl(e,t,n,r)}}function El(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:El(a,o,s,c,i),zc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,El(a,o,s,c,i)):u._visibility&2?El(a,o,s,c,i):Dl(a,o),i&&l&2048&&Sl(o.alternate,o);break;case 24:El(a,o,s,c,i),i&&l&2048&&Cl(o.alternate,o);break;default:El(a,o,s,c,i)}t=t.sibling}}function Dl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Dl(n,r),i&2048&&Sl(r.alternate,r);break;case 24:Dl(n,r),i&2048&&Cl(r.alternate,r);break;default:Dl(n,r)}t=t.sibling}}var Ol=8192;function kl(e,t,n){if(e.subtreeFlags&Ol)for(e=e.child;e!==null;)Al(e,t,n),e=e.sibling}function Al(e,t,n){switch(e.tag){case 26:kl(e,t,n),e.flags&Ol&&e.memoizedState!==null&&Yf(n,hl,e.memoizedState,e.memoizedProps);break;case 5:kl(e,t,n);break;case 3:case 4:var r=hl;hl=bf(e.stateNode.containerInfo),kl(e,t,n),hl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Ol,Ol=16777216,kl(e,t,n),Ol=r):kl(e,t,n));break;default:kl(e,t,n)}}function jl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Ml(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];nl=r,Fl(r,e)}jl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Nl(e),e=e.sibling}function Nl(e){switch(e.tag){case 0:case 11:case 15:Ml(e),e.flags&2048&&Bc(9,e,e.return);break;case 3:Ml(e);break;case 12:Ml(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Pl(e)):Ml(e);break;default:Ml(e)}}function Pl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];nl=r,Fl(r,e)}jl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Bc(8,t,t.return),Pl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Pl(t));break;default:Pl(t)}e=e.sibling}}function Fl(e,t){for(;nl!==null;){var n=nl;switch(n.tag){case 0:case 11:case 15:Bc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:la(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,nl=r;else a:for(n=e;nl!==null;){r=nl;var i=r.sibling,a=r.return;if(al(r),r===n){nl=null;break a}if(i!==null){i.return=a,nl=i;break a}nl=a}}}var Il={getCacheForType:function(e){var t=ta(sa),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ta(sa).controller.signal}},Ll=typeof WeakMap==`function`?WeakMap:Map,Rl=0,zl=null,q=null,Bl=0,Vl=0,Hl=null,Ul=!1,Wl=!1,Gl=!1,Kl=0,ql=0,Jl=0,Yl=0,Xl=0,Zl=0,Ql=0,$l=null,eu=null,tu=!1,nu=0,ru=0,iu=1/0,au=null,ou=null,J=0,su=null,cu=null,lu=0,uu=0,du=null,fu=null,pu=0,mu=null;function hu(){return Rl&2&&Bl!==0?Bl&-Bl:P.T===null?ot():pd()}function gu(){if(Zl===0)if(!(Bl&536870912)||Pi){var e=Ge;Ge<<=1,!(Ge&3932160)&&(Ge=262144),Zl=e}else Zl=536870912;return e=no.current,e!==null&&(e.flags|=32),Zl}function _u(e,t,n){(e===zl&&(Vl===2||Vl===9)||e.cancelPendingCommit!==null)&&(wu(e,0),xu(e,Bl,Zl,!1)),$e(e,n),(!(Rl&2)||e!==zl)&&(e===zl&&(!(Rl&2)&&(Yl|=n),ql===4&&xu(e,Bl,Zl,!1)),ad(e))}function vu(e,t,n){if(Rl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Ye(e,t),a=r?Mu(e,t):Au(e,t,!0),o=r;do{if(a===0){Wl&&!r&&xu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!bu(n)){a=Au(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=$l;var l=c.current.memoizedState.isDehydrated;if(l&&(wu(c,s).flags|=256),s=Au(c,s,!1),s!==2){if(Gl&&!l){c.errorRecoveryDisabledLanes|=o,Yl|=o,a=4;break a}o=eu,eu=a,o!==null&&(eu===null?eu=o:eu.push.apply(eu,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){wu(e,0),xu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:xu(r,t,Zl,!Ul);break a;case 2:eu=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=nu+300-Oe(),10<a)){if(xu(r,t,Zl,!Ul),Je(r,0,!0)!==0)break a;lu=t,r.timeoutHandle=Xd(yu.bind(null,r,n,eu,au,tu,t,Zl,Yl,Ql,Ul,o,`Throttled`,-0,0),a);break a}yu(r,n,eu,au,tu,t,Zl,Yl,Ql,Ul,o,null,-0,0)}}break}while(1);ad(e)}function yu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:tn},Al(t,a,d);var m=(a&62914560)===a?nu-Oe():(a&4194048)===a?ru-Oe():0;if(m=Zf(d,m),m!==null){lu=a,e.cancelPendingCommit=m(zu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),xu(e,a,o,!l);return}}zu(e,t,a,n,r,i,o,s,c)}function bu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!wr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function xu(e,t,n,r){t&=~Xl,t&=~Yl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Be(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&tt(e,n,t)}function Su(){return Rl&6?!0:(od(0,!1),!1)}function Cu(){if(q!==null){if(Vl===0)var e=q.return;else e=q,qi=Ki=null,Ao(e),Ma=null,Na=0,e=q;for(;e!==null;)Rc(e.alternate,e),e=e.return;q=null}}function wu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Zd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),lu=0,Cu(),zl=e,q=n=di(e.current,null),Bl=t,Vl=0,Hl=null,Ul=!1,Wl=Ye(e,t),Gl=!1,Ql=Zl=Xl=Yl=Jl=ql=0,eu=$l=null,tu=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Be(r),a=1<<i;t|=e[i],r&=~a}return Kl=t,ni(),n}function Tu(e,t){fo=null,P.H=Bs,t===Sa||t===wa?(t=Aa(),Vl=3):t===Ca?(t=Aa(),Vl=4):Vl=t===nc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Hl=t,q===null&&(ql=1,Zs(e,yi(t,e.current)))}function Eu(){var e=no.current;return e===null?!0:(Bl&4194048)===Bl?ro===null:(Bl&62914560)===Bl||Bl&536870912?e===ro:!1}function Du(){var e=P.H;return P.H=Bs,e===null?Bs:e}function Ou(){var e=P.A;return P.A=Il,e}function ku(){ql=4,Ul||(Bl&4194048)!==Bl&&no.current!==null||(Wl=!0),!(Jl&134217727)&&!(Yl&134217727)||zl===null||xu(zl,Bl,Zl,!1)}function Au(e,t,n){var r=Rl;Rl|=2;var i=Du(),a=Ou();(zl!==e||Bl!==t)&&(au=null,wu(e,t)),t=!1;var o=ql;a:do try{if(Vl!==0&&q!==null){var s=q,c=Hl;switch(Vl){case 8:Cu(),o=6;break a;case 3:case 2:case 9:case 6:no.current===null&&(t=!0);var l=Vl;if(Vl=0,Hl=null,Iu(e,s,c,l),n&&Wl){o=0;break a}break;default:l=Vl,Vl=0,Hl=null,Iu(e,s,c,l)}}ju(),o=ql;break}catch(t){Tu(e,t)}while(1);return t&&e.shellSuspendCounter++,qi=Ki=null,Rl=r,P.H=i,P.A=a,q===null&&(zl=null,Bl=0,ni()),o}function ju(){for(;q!==null;)Pu(q)}function Mu(e,t){var n=Rl;Rl|=2;var r=Du(),a=Ou();zl!==e||Bl!==t?(au=null,iu=Oe()+500,wu(e,t)):Wl=Ye(e,t);a:do try{if(Vl!==0&&q!==null){t=q;var o=Hl;b:switch(Vl){case 1:Vl=0,Hl=null,Iu(e,t,o,1);break;case 2:case 9:if(Ea(o)){Vl=0,Hl=null,Fu(t);break}t=function(){Vl!==2&&Vl!==9||zl!==e||(Vl=7),ad(e)},o.then(t,t);break a;case 3:Vl=7;break a;case 4:Vl=5;break a;case 7:Ea(o)?(Vl=0,Hl=null,Fu(t)):(Vl=0,Hl=null,Iu(e,t,o,7));break;case 5:var s=null;switch(q.tag){case 26:s=q.memoizedState;case 5:case 27:var c=q;if(s?Jf(s):c.stateNode.complete){Vl=0,Hl=null;var l=c.sibling;if(l!==null)q=l;else{var u=c.return;u===null?q=null:(q=u,Lu(u))}break b}}Vl=0,Hl=null,Iu(e,t,o,5);break;case 6:Vl=0,Hl=null,Iu(e,t,o,6);break;case 8:Cu(),ql=6;break a;default:throw Error(i(462))}}Nu();break}catch(t){Tu(e,t)}while(1);return qi=Ki=null,P.H=r,P.A=a,Rl=n,q===null?(zl=null,Bl=0,ni(),ql):0}function Nu(){for(;q!==null&&!Ee();)Pu(q)}function Pu(e){var t=kc(e.alternate,e,Kl);e.memoizedProps=e.pendingProps,t===null?Lu(e):q=t}function Fu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=mc(n,t,t.pendingProps,t.type,void 0,Bl);break;case 11:t=mc(n,t,t.pendingProps,t.type.render,t.ref,Bl);break;case 5:Ao(t);default:Rc(n,t),t=q=fi(t,Kl),t=kc(n,t,Kl)}e.memoizedProps=e.pendingProps,t===null?Lu(e):q=t}function Iu(e,t,n,r){qi=Ki=null,Ao(t),Ma=null,Na=0;var i=t.return;try{if(tc(e,i,t,n,Bl)){ql=1,Zs(e,yi(n,e.current)),q=null;return}}catch(t){if(i!==null)throw q=i,t;ql=1,Zs(e,yi(n,e.current)),q=null;return}t.flags&32768?(Pi||r===1?e=!0:Wl||Bl&536870912?e=!1:(Ul=e=!0,(r===2||r===9||r===3||r===6)&&(r=no.current,r!==null&&r.tag===13&&(r.flags|=16384))),Ru(t,e)):Lu(t)}function Lu(e){var t=e;do{if(t.flags&32768){Ru(t,Ul);return}e=t.return;var n=Ic(t.alternate,t,Kl);if(n!==null){q=n;return}if(t=t.sibling,t!==null){q=t;return}q=t=e}while(t!==null);ql===0&&(ql=5)}function Ru(e,t){do{var n=Lc(e.alternate,e);if(n!==null){n.flags&=32767,q=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){q=e;return}q=e=n}while(e!==null);ql=6,q=null}function zu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Uu();while(J!==0);if(Rl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=ti,et(e,n,o,s,c,l),e===zl&&(q=zl=null,Bl=0),cu=t,su=e,lu=n,uu=o,du=a,fu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Qu(Me,function(){return Wu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=P.T,P.T=null,a=F.p,F.p=2,s=Rl,Rl|=4;try{rl(e,t,n)}finally{Rl=s,F.p=a,P.T=r}}J=1,Bu(),Vu(),Y()}}function Bu(){if(J===1){J=0;var e=su,t=cu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=Rl;Rl|=4;try{gl(t,e);var a=Ud,o=kr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Or(s.ownerDocument.documentElement,s)){if(c!==null&&Ar(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Dr(s,h),v=Dr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}up=!!Hd,Ud=Hd=null}finally{Rl=i,F.p=r,P.T=n}}e.current=t,J=2}}function Vu(){if(J===2){J=0;var e=su,t=cu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=Rl;Rl|=4;try{il(e,t.alternate,t)}finally{Rl=i,F.p=r,P.T=n}}J=3}}function Y(){if(J===4||J===3){J=0,De();var e=su,t=cu,n=lu,r=fu;t.subtreeFlags&10256||t.flags&10256?J=5:(J=0,cu=su=null,Hu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(ou=null),at(n),t=t.stateNode,Re&&typeof Re.onCommitFiberRoot==`function`)try{Re.onCommitFiberRoot(Le,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=P.T,i=F.p,F.p=2,P.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{P.T=t,F.p=i}}lu&3&&Uu(),ad(e),i=e.pendingLanes,n&261930&&i&42?e===mu?pu++:(pu=0,mu=e):pu=0,od(0,!1)}}function Hu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,la(t)))}function Uu(){return Bu(),Vu(),Y(),Wu()}function Wu(){if(J!==5)return!1;var e=su,t=uu;uu=0;var n=at(lu),r=P.T,a=F.p;try{F.p=32>n?32:n,P.T=null,n=du,du=null;var o=su,s=lu;if(J=0,cu=su=null,lu=0,Rl&6)throw Error(i(331));var c=Rl;if(Rl|=4,Nl(o.current),Tl(o,o.current,s,n),Rl=c,od(0,!1),Re&&typeof Re.onPostCommitFiberRoot==`function`)try{Re.onPostCommitFiberRoot(Le,o)}catch{}return!0}finally{F.p=a,P.T=r,Hu(e,t)}}function Gu(e,t,n){t=yi(n,t),t=Qs(e.stateNode,t,2),e=Ua(e,t,2),e!==null&&($e(e,2),ad(e))}function Ku(e,t,n){if(e.tag===3)Gu(e,e,n);else for(;t!==null;){if(t.tag===3){Gu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(ou===null||!ou.has(r))){e=yi(n,e),n=$s(2),r=Ua(t,n,2),r!==null&&(ec(n,r,t,e),$e(r,2),ad(r));break}}t=t.return}}function qu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ll;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Gl=!0,i.add(n),e=Ju.bind(null,e,t,n),t.then(e,e))}function Ju(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,zl===e&&(Bl&n)===n&&(ql===4||ql===3&&(Bl&62914560)===Bl&&300>Oe()-nu?!(Rl&2)&&wu(e,0):Xl|=n,Ql===Bl&&(Ql=0)),ad(e)}function Yu(e,t){t===0&&(t=Ze()),e=ai(e,t),e!==null&&($e(e,t),ad(e))}function Xu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Yu(e,n)}function Zu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Yu(e,n)}function Qu(e,t){return we(e,t)}var $u=null,ed=null,td=!1,nd=!1,rd=!1,id=0;function ad(e){e!==ed&&e.next===null&&(ed===null?$u=ed=e:ed=ed.next=e),nd=!0,td||(td=!0,fd())}function od(e,t){if(!rd&&nd){rd=!0;do for(var n=!1,r=$u;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Be(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,dd(r,a))}else a=Bl,a=Je(r,r===zl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Ye(r,a)||(n=!0,dd(r,a));r=r.next}while(n);rd=!1}}function sd(){cd()}function cd(){nd=td=!1;var e=0;id!==0&&Yd()&&(e=id);for(var t=Oe(),n=null,r=$u;r!==null;){var i=r.next,a=ld(r,t);a===0?(r.next=null,n===null?$u=i:n.next=i,i===null&&(ed=n)):(n=r,(e!==0||a&3)&&(nd=!0)),r=i}J!==0&&J!==5||od(e,!1),id!==0&&(id=0)}function ld(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Be(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Xe(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=zl,n=Bl,n=Je(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Vl===2||Vl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Te(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Ye(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Te(r),at(n)){case 2:case 8:n=je;break;case 32:n=Me;break;case 268435456:n=Pe;break;default:n=Me}return r=ud.bind(null,e),n=we(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Te(r),e.callbackPriority=2,e.callbackNode=null,2}function ud(e,t){if(J!==0&&J!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Uu()&&e.callbackNode!==n)return null;var r=Bl;return r=Je(e,e===zl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(vu(e,r,t),ld(e,Oe()),e.callbackNode!=null&&e.callbackNode===n?ud.bind(null,e):null)}function dd(e,t){if(Uu())return null;vu(e,t,!0)}function fd(){$d(function(){Rl&6?we(Ae,sd):cd()})}function pd(){if(id===0){var e=fa;e===0&&(e=We,We<<=1,!(We&261888)&&(We=256)),id=e}return id}function md(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:en(``+e)}function hd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function gd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=md((i[ut]||null).action),o=r.submitter;o&&(t=(t=o[ut]||null)?md(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Cn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(id!==0){var e=o?hd(i,o):new FormData(i);Es(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?hd(i,o):new FormData(i),Es(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var _d=0;_d<Xr.length;_d++){var vd=Xr[_d];Zr(vd.toLowerCase(),`on`+(vd[0].toUpperCase()+vd.slice(1)))}Zr(Hr,`onAnimationEnd`),Zr(Ur,`onAnimationIteration`),Zr(Wr,`onAnimationStart`),Zr(`dblclick`,`onDoubleClick`),Zr(`focusin`,`onFocus`),Zr(`focusout`,`onBlur`),Zr(Gr,`onTransitionRun`),Zr(Kr,`onTransitionStart`),Zr(qr,`onTransitionCancel`),Zr(Jr,`onTransitionEnd`),Et(`onMouseEnter`,[`mouseout`,`mouseover`]),Et(`onMouseLeave`,[`mouseout`,`mouseover`]),Et(`onPointerEnter`,[`pointerout`,`pointerover`]),Et(`onPointerLeave`,[`pointerout`,`pointerover`]),Tt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Tt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Tt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Tt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Tt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Tt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var yd=`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(` `),bd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(yd));function xd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Qr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Qr(e)}i.currentTarget=null,a=c}}}}function Sd(e,t){var n=t[ft];n===void 0&&(n=t[ft]=new Set);var r=e+`__bubble`;n.has(r)||(Ed(t,e,2,!1),n.add(r))}function Cd(e,t,n){var r=0;t&&(r|=4),Ed(n,e,r,t)}var wd=`_reactListening`+Math.random().toString(36).slice(2);function Td(e){if(!e[wd]){e[wd]=!0,Ct.forEach(function(t){t!==`selectionchange`&&(bd.has(t)||Cd(t,!1,e),Cd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[wd]||(t[wd]=!0,Cd(`selectionchange`,!1,t))}}function Ed(e,t,n,r){switch(_p(t)){case 2:var i=dp;break;case 8:i=fp;break;default:i=pp}n=i.bind(null,t,n,e),i=void 0,!fn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Dd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=vt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}ln(function(){var r=a,i=rn(n),s=[];a:{var c=Yr.get(e);if(c!==void 0){var l=Cn,u=e;switch(e){case`keypress`:if(vn(n)===0)break a;case`keydown`:case`keyup`:l=Vn;break;case`focusin`:u=`focus`,l=Mn;break;case`focusout`:u=`blur`,l=Mn;break;case`beforeblur`:case`afterblur`:l=Mn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=An;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=jn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Un;break;case Hr:case Ur:case Wr:l=Nn;break;case Jr:l=Wn;break;case`scroll`:case`scrollend`:l=Tn;break;case`wheel`:l=Gn;break;case`copy`:case`cut`:case`paste`:l=Pn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Hn;break;case`toggle`:case`beforetoggle`:l=Kn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=un(m,p),g!=null&&d.push(Od(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==nn&&(u=n.relatedTarget||n.fromElement)&&(vt(u)||u[dt]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?vt(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=An,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Hn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:bt(l),h=u==null?c:bt(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,vt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Ad,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&jd(s,c,l,d,!1),u!==null&&f!==null&&jd(s,f,u,d,!0)}}a:{if(c=r?bt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=fr;else if(or(c))if(pr)v=Sr;else{v=br;var y=yr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Zt(r.elementType)&&(v=fr):v=xr;if(v&&=v(e,r)){sr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Ut(c,`number`,c.value)}switch(y=r?bt(r):window,e){case`focusin`:(or(y)||y.contentEditable===`true`)&&(Mr=y,Nr=r,Pr=null);break;case`focusout`:Pr=Nr=Mr=null;break;case`mousedown`:Fr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Fr=!1,Ir(s,n,i);break;case`selectionchange`:if(jr)break;case`keydown`:case`keyup`:Ir(s,n,i)}var b;if(Jn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else nr?er(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Zn&&n.locale!==`ko`&&(nr||x!==`onCompositionStart`?x===`onCompositionEnd`&&nr&&(b=_n()):(mn=i,hn=`value`in mn?mn.value:mn.textContent,nr=!0)),y=kd(r,x),0<y.length&&(x=new Fn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=tr(n),b!==null&&(x.data=b)))),(b=Xn?rr(e,n):ir(e,n))&&(x=kd(r,`onBeforeInput`),0<x.length&&(y=new Fn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),gd(s,e,r,n,i)}xd(s,t)})}function Od(e,t,n){return{instance:e,listener:t,currentTarget:n}}function kd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=un(e,n),i!=null&&r.unshift(Od(e,i,a)),i=un(e,t),i!=null&&r.push(Od(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ad(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function jd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=un(n,a),l!=null&&o.unshift(Od(n,l,c))):i||(l=un(n,a),l!=null&&o.push(Od(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Md=/\r\n?/g,Nd=/\u0000|\uFFFD/g;function Pd(e){return(typeof e==`string`?e:``+e).replace(Md,`
`).replace(Nd,``)}function Fd(e,t){return t=Pd(t),Pd(e)===t}function Id(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||qt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&qt(e,``+r);break;case`className`:Mt(e,`class`,r);break;case`tabIndex`:Mt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Mt(e,n,r);break;case`style`:Xt(e,r,o);break;case`data`:if(t!==`object`){Mt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=en(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Id(e,t,`name`,a.name,a,null),Id(e,t,`formEncType`,a.formEncType,a,null),Id(e,t,`formMethod`,a.formMethod,a,null),Id(e,t,`formTarget`,a.formTarget,a,null)):(Id(e,t,`encType`,a.encType,a,null),Id(e,t,`method`,a.method,a,null),Id(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=en(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=tn);break;case`onScroll`:r!=null&&Sd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Sd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=en(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Sd(`beforetoggle`,e),Sd(`toggle`,e),jt(e,`popover`,r);break;case`xlinkActuate`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Nt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Nt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Nt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:jt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Qt.get(n)||n,jt(e,n,r))}}function Ld(e,t,n,r,a,o){switch(n){case`style`:Xt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?qt(e,r):(typeof r==`number`||typeof r==`bigint`)&&qt(e,``+r);break;case`onScroll`:r!=null&&Sd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Sd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=tn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!wt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[ut]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):jt(e,n,r)}}}function Rd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Sd(`error`,e),Sd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Id(e,t,o,s,n,null)}}a&&Id(e,t,`srcSet`,n.srcSet,n,null),r&&Id(e,t,`src`,n.src,n,null);return;case`input`:Sd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Id(e,t,r,d,n,null)}}Ht(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Sd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Id(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Wt(e,!!r,n,!0):Wt(e,!!r,t,!1);return;case`textarea`:for(s in Sd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Id(e,t,s,c,n,null)}Kt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Id(e,t,l,r,n,null)}return;case`dialog`:Sd(`beforetoggle`,e),Sd(`toggle`,e),Sd(`cancel`,e),Sd(`close`,e);break;case`iframe`:case`object`:Sd(`load`,e);break;case`video`:case`audio`:for(r=0;r<yd.length;r++)Sd(yd[r],e);break;case`image`:Sd(`error`,e),Sd(`load`,e);break;case`details`:Sd(`toggle`,e);break;case`embed`:case`source`:case`link`:Sd(`error`,e),Sd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Id(e,t,u,r,n,null)}return;default:if(Zt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Ld(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Id(e,t,c,r,n,null))}function zd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Id(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Id(e,t,p,m,r,f)}}Vt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Id(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Id(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Wt(e,!!n,n?[]:``,!1):Wt(e,!!n,t,!0)):Wt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Id(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Id(e,t,s,a,r,o)}Gt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Id(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Id(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Id(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Id(e,t,u,p,r,m)}return;default:if(Zt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Ld(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Ld(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Id(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Id(e,t,f,p,r,m)}function Bd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Vd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Bd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Bd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Hd=null,Ud=null;function Wd(e){return e.nodeType===9?e:e.ownerDocument}function Gd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Kd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function qd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Jd=null;function Yd(){var e=window.event;return e&&e.type===`popstate`?e===Jd?!1:(Jd=e,!0):(Jd=null,!1)}var Xd=typeof setTimeout==`function`?setTimeout:void 0,Zd=typeof clearTimeout==`function`?clearTimeout:void 0,Qd=typeof Promise==`function`?Promise:void 0,$d=typeof queueMicrotask==`function`?queueMicrotask:Qd===void 0?Xd:function(e){return Qd.resolve(null).then(e).catch(ef)};function ef(e){setTimeout(function(){throw e})}function tf(e){return e===`head`}function nf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Ip(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_f(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_f(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[gt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_f(e.ownerDocument.body);n=i}while(n);Ip(t)}function rf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function af(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:af(n),_t(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function of(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[gt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=ff(e.nextSibling),e===null)break}return null}function sf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=ff(e.nextSibling),e===null))return null;return e}function cf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=ff(e.nextSibling),e===null))return null;return e}function lf(e){return e.data===`$?`||e.data===`$~`}function uf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function df(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function ff(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var pf=null;function mf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return ff(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function hf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function gf(e,t,n){switch(t=Wd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function _f(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);_t(e)}var vf=new Map,yf=new Set;function bf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var xf=F.d;F.d={f:Sf,r:Cf,D:Ef,C:Df,L:Of,m:kf,X:jf,S:Af,M:Mf};function Sf(){var e=xf.f(),t=Su();return e||t}function Cf(e){var t=yt(e);t!==null&&t.tag===5&&t.type===`form`?Os(t):xf.r(e)}var wf=typeof document>`u`?null:document;function Tf(e,t,n){var r=wf;if(r&&typeof t==`string`&&t){var i=Bt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),yf.has(i)||(yf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Rd(t,`link`,e),St(t),r.head.appendChild(t)))}}function Ef(e){xf.D(e),Tf(`dns-prefetch`,e,null)}function Df(e,t){xf.C(e,t),Tf(`preconnect`,e,t)}function Of(e,t,n){xf.L(e,t,n);var r=wf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Bt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Bt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Bt(n.imageSizes)+`"]`)):i+=`[href="`+Bt(e)+`"]`;var a=i;switch(t){case`style`:a=Pf(e);break;case`script`:a=Rf(e)}vf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Ff(a))||t===`script`&&r.querySelector(zf(a))||(t=r.createElement(`link`),Rd(t,`link`,e),St(t),r.head.appendChild(t)))}}function kf(e,t){xf.m(e,t);var n=wf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Bt(r)+`"][href="`+Bt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rf(e)}if(!vf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),vf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zf(a)))return}r=n.createElement(`link`),Rd(r,`link`,e),St(r),n.head.appendChild(r)}}}function Af(e,t,n){xf.S(e,t,n);var r=wf;if(r&&e){var i=xt(r).hoistableStyles,a=Pf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Ff(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vf.get(a))&&Hf(e,n);var c=o=r.createElement(`link`);St(c),Rd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jf(e,t){xf.X(e,t);var n=wf;if(n&&e){var r=xt(n).hoistableScripts,i=Rf(e),a=r.get(i);a||(a=n.querySelector(zf(i)),a||(e=m({src:e,async:!0},t),(t=vf.get(i))&&Uf(e,t),a=n.createElement(`script`),St(a),Rd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mf(e,t){xf.M(e,t);var n=wf;if(n&&e){var r=xt(n).hoistableScripts,i=Rf(e),a=r.get(i);a||(a=n.querySelector(zf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=vf.get(i))&&Uf(e,t),a=n.createElement(`script`),St(a),Rd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nf(e,t,n,r){var a=(a=ue.current)?bf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Pf(n.href),n=xt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pf(n.href);var o=xt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Ff(e)))&&!o._p&&(s.instance=o,s.state.loading=5),vf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vf.set(e,n),o||Lf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Rf(n),n=xt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pf(e){return`href="`+Bt(e)+`"`}function Ff(e){return`link[rel="stylesheet"][`+e+`]`}function If(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Lf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Rd(t,`link`,n),St(t),e.head.appendChild(t))}function Rf(e){return`[src="`+Bt(e)+`"]`}function zf(e){return`script[async]`+e}function Bf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Bt(n.href)+`"]`);if(r)return t.instance=r,St(r),r;var a=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),St(r),Rd(r,`style`,a),Vf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pf(n.href);var o=e.querySelector(Ff(a));if(o)return t.state.loading|=4,t.instance=o,St(o),o;r=If(n),(a=vf.get(a))&&Hf(r,a),o=(e.ownerDocument||e).createElement(`link`),St(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Rd(o,`link`,r),t.state.loading|=4,Vf(o,n.precedence,e),t.instance=o;case`script`:return o=Rf(n.src),(a=e.querySelector(zf(o)))?(t.instance=a,St(a),a):(r=n,(a=vf.get(o))&&(r=m({},n),Uf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),St(a),Rd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vf(r,n.precedence,e));return t.instance}function Vf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Hf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Uf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wf=null;function Gf(e,t,n){if(Wf===null){var r=new Map,i=Wf=new Map;i.set(n,r)}else i=Wf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[gt]||a[lt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Kf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Yf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pf(r.href),a=t.querySelector(Ff(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Qf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,St(a);return}a=t.ownerDocument||t,r=If(r),(i=vf.get(i))&&Hf(r,i),a=a.createElement(`link`),St(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Rd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Qf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Xf=0;function Zf(e,t){return e.stylesheets&&e.count===0&&ep(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ep(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Xf===0&&(Xf=62500*Vd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ep(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Xf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Qf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ep(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var $f=null;function ep(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,$f=new Map,t.forEach(tp,e),$f=null,Qf.call(e))}function tp(e,t){if(!(t.state.loading&4)){var n=$f.get(e);if(n)var r=n.get(null);else{n=new Map,$f.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Qf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var np={$$typeof:C,Provider:null,Consumer:null,_currentValue:ne,_currentValue2:ne,_threadCount:0};function rp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Qe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qe(0),this.hiddenUpdates=Qe(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ip(e,t,n,r,i,a,o,s,c,l,u,d){return e=new rp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=li(3,null,null,t),e.current=a,a.stateNode=e,t=ca(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ba(a),e}function ap(e){return e?(e=si,e):si}function op(e,t,n,r,i,a){i=ap(i),r.context===null?r.context=i:r.pendingContext=i,r=Ha(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ua(e,r,t),n!==null&&(_u(n,e,t),Wa(n,e,t))}function sp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function X(e,t){sp(e,t),(e=e.alternate)&&sp(e,t)}function cp(e){if(e.tag===13||e.tag===31){var t=ai(e,67108864);t!==null&&_u(t,e,67108864),X(e,67108864)}}function lp(e){if(e.tag===13||e.tag===31){var t=hu();t=it(t);var n=ai(e,t);n!==null&&_u(n,e,t),X(e,t)}}var up=!0;function dp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=2,pp(e,t,n,r)}finally{F.p=a,P.T=i}}function fp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=8,pp(e,t,n,r)}finally{F.p=a,P.T=i}}function pp(e,t,n,r){if(up){var i=mp(r);if(i===null)Dd(e,t,r,hp,n),Ep(e,r);else if(Op(i,e,t,n,r))r.stopPropagation();else if(Ep(e,r),t&4&&-1<Tp.indexOf(e)){for(;i!==null;){var a=yt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=qe(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Be(o);s.entanglements[1]|=c,o&=~c}ad(a),!(Rl&6)&&(iu=Oe()+500,od(0,!1))}}break;case 31:case 13:s=ai(a,2),s!==null&&_u(s,a,2),Su(),X(a,2)}if(a=mp(r),a===null&&Dd(e,t,r,hp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Dd(e,t,r,null,n)}}function mp(e){return e=rn(e),gp(e)}var hp=null;function gp(e){if(hp=null,e=vt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return hp=e,null}function _p(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ke()){case Ae:return 2;case je:return 8;case Me:case Ne:return 32;case Pe:return 268435456;default:return 32}default:return 32}}var vp=!1,yp=null,bp=null,xp=null,Sp=new Map,Cp=new Map,wp=[],Tp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Ep(e,t){switch(e){case`focusin`:case`focusout`:yp=null;break;case`dragenter`:case`dragleave`:bp=null;break;case`mouseover`:case`mouseout`:xp=null;break;case`pointerover`:case`pointerout`:Sp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Cp.delete(t.pointerId)}}function Dp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=yt(t),t!==null&&cp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Op(e,t,n,r,i){switch(t){case`focusin`:return yp=Dp(yp,e,t,n,r,i),!0;case`dragenter`:return bp=Dp(bp,e,t,n,r,i),!0;case`mouseover`:return xp=Dp(xp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Sp.set(a,Dp(Sp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Cp.set(a,Dp(Cp.get(a)||null,e,t,n,r,i)),!0}return!1}function kp(e){var t=vt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,st(e.priority,function(){lp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,st(e.priority,function(){lp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ap(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=mp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);nn=r,n.target.dispatchEvent(r),nn=null}else return t=yt(n),t!==null&&cp(t),e.blockedOn=n,!1;t.shift()}return!0}function jp(e,t,n){Ap(e)&&n.delete(t)}function Mp(){vp=!1,yp!==null&&Ap(yp)&&(yp=null),bp!==null&&Ap(bp)&&(bp=null),xp!==null&&Ap(xp)&&(xp=null),Sp.forEach(jp),Cp.forEach(jp)}function Np(e,n){e.blockedOn===n&&(e.blockedOn=null,vp||(vp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Mp)))}var Pp=null;function Fp(e){Pp!==e&&(Pp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Pp===e&&(Pp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(gp(r||n)===null)continue;break}var a=yt(n);a!==null&&(e.splice(t,3),t-=3,Es(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Ip(e){function t(t){return Np(t,e)}yp!==null&&Np(yp,e),bp!==null&&Np(bp,e),xp!==null&&Np(xp,e),Sp.forEach(t),Cp.forEach(t);for(var n=0;n<wp.length;n++){var r=wp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<wp.length&&(n=wp[0],n.blockedOn===null);)kp(n),n.blockedOn===null&&wp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[ut]||null;if(typeof a==`function`)o||Fp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[ut]||null)s=o.formAction;else if(gp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Fp(n)}}}function Lp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Rp(e){this._internalRoot=e}zp.prototype.render=Rp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;op(n,hu(),e,t,null,null)},zp.prototype.unmount=Rp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;op(e.current,2,null,e,null,null),Su(),t[dt]=null}};function zp(e){this._internalRoot=e}zp.prototype.unstable_scheduleHydration=function(e){if(e){var t=ot();e={blockedOn:null,target:e,priority:t};for(var n=0;n<wp.length&&t!==0&&t<wp[n].priority;n++);wp.splice(n,0,e),n===0&&kp(e)}};var Bp=n.version;if(Bp!==`19.2.7`)throw Error(i(527,Bp,`19.2.7`));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var Vp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Hp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hp.isDisabled&&Hp.supportsFiber)try{Le=Hp.inject(Vp),Re=Hp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Js,s=Ys,c=Xs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ip(e,1,!1,null,null,n,r,null,o,s,c,Lp),e[dt]=t.current,Td(e),new Rp(t)}})),_=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=`modulepreload`,y=function(e){return`/dist/`+e},b={},x=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,new URL(`../../../src/node/plugins/importAnalysisBuild.ts`,import.meta.url)).href}r=o(t.map(t=>{if(t=y(t,n),t=s(t),t in b)return;b[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:v,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},S=l(d(),1),C=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,w=/^[\\/]{2}/;function T(e,t){return t+e.replace(/\\/g,`/`)}var E=`popstate`;function D(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function O(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return N(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:ee(t)}return P(t,n,null,e)}function k(e,t){if(e===!1||e==null)throw Error(t)}function A(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function j(){return Math.random().toString(36).substring(2,10)}function M(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function N(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?te(t):t,state:n,key:t&&t.key||r||j(),mask:i}}function ee({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function te(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function P(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=D(e)?e:N(h.location,e,t);n&&n(r,e),l=u()+1;let d=M(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=D(e)?e:N(h.location,e,t);n&&n(r,e),l=u();let i=M(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return F(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(E,d),c=e,()=>{i.removeEventListener(E,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function F(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),k(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:ee(t);return i=i.replace(/ $/,`%20`),!n&&w.test(i)&&(i=r+i),new URL(i,r)}function ne(e,t,n=`/`){return re(e,t,n,!1)}function re(e,t,n,r,i){let a=Ce((typeof t==`string`?te(t):t).pathname||`/`,n);if(a==null)return null;let o=i??ae(e),s=null,c=Se(a);for(let e=0;s==null&&e<o.length;++e)s=ve(o[e],c,r);return s}function ie(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function ae(e){let t=oe(e);return ce(t),t}function oe(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;k(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=je([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(k(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),oe(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:ge(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=xe(e.relativePath,e.caseSensitive,t===u.length-1);return{...e,matcher:n,compiledParams:r}})})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of se(e.path))a(e,t,!0,n)}),t}function se(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=se(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function ce(e){e.sort((e,t)=>e.score===t.score?_e(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var le=/^:[\w-]+$/,ue=3,de=2,fe=1,pe=10,me=-2,he=e=>e===`*`;function ge(e,t){let n=e.split(`/`),r=n.length;return n.some(he)&&(r+=me),t&&(r+=de),n.filter(e=>!he(e)).reduce((e,t)=>e+(le.test(t)?ue:t===``?fe:pe),r)}function _e(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function ve(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u={path:s.relativePath,caseSensitive:s.caseSensitive,end:c},d=s.matcher&&s.compiledParams?be(u,l,s.matcher,s.compiledParams):ye(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=ye({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:je([a,d.pathname]),pathnameBase:Ne(je([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=je([a,d.pathnameBase]))}return o}function ye(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=xe(e.path,e.caseSensitive,e.end);return be(e,t,n,r)}function be(e,t,n,r){let i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function xe(e,t=!1,n=!0){A(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function Se(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return A(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Ce(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function we(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?te(e):e,a;return n?(n=Ae(n),a=n.startsWith(`/`)?Te(n.substring(1),`/`):Te(n,t)):a=t,{pathname:a,search:Pe(r),hash:Fe(i)}}function Te(e,t){let n=Me(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Ee(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function De(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Oe(e){let t=De(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function ke(e,t,n,r=!1){let i;typeof e==`string`?i=te(e):(i={...e},k(!i.pathname||!i.pathname.includes(`?`),Ee(`?`,`pathname`,`search`,i)),k(!i.pathname||!i.pathname.includes(`#`),Ee(`#`,`pathname`,`hash`,i)),k(!i.search||!i.search.includes(`#`),Ee(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=we(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Ae=e=>e.replace(/[\\/]{2,}/g,`/`),je=e=>Ae(e.join(`/`)),Me=e=>e.replace(/\/+$/,``),Ne=e=>Me(e).replace(/^\/*/,`/`),Pe=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Fe=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Ie=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Le(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Re(e){return je(e.map(e=>e.route.path).filter(Boolean))||`/`}var ze=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Be(e,t){let n=e;if(typeof n!=`string`||!C.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(ze)try{let e=new URL(window.location.href),r=w.test(n)?new URL(T(n,e.protocol)):new URL(n),a=Ce(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{A(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Ve=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Ve);var He=[`GET`,...Ve];new Set(He);var Ue=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function We(e){try{return Ue.includes(new URL(e).protocol)}catch{return!1}}var Ge=S.createContext(null);Ge.displayName=`DataRouter`;var Ke=S.createContext(null);Ke.displayName=`DataRouterState`;var qe=S.createContext(!1);function Je(){return S.useContext(qe)}var Ye=S.createContext({isTransitioning:!1});Ye.displayName=`ViewTransition`;var Xe=S.createContext(new Map);Xe.displayName=`Fetchers`;var Ze=S.createContext(null);Ze.displayName=`Await`;var Qe=S.createContext(null);Qe.displayName=`Navigation`;var $e=S.createContext(null);$e.displayName=`Location`;var et=S.createContext({outlet:null,matches:[],isDataRoute:!1});et.displayName=`Route`;var tt=S.createContext(null);tt.displayName=`RouteError`;var nt=`REACT_ROUTER_ERROR`,rt=`REDIRECT`,it=`ROUTE_ERROR_RESPONSE`;function at(e){if(e.startsWith(`${nt}:${rt}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function ot(e){if(e.startsWith(`${nt}:${it}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Ie(t.status,t.statusText,t.data)}catch{}}function st(e,{relative:t}={}){k(ct(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=S.useContext(Qe),{hash:i,pathname:a,search:o}=ht(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:je([n,a])),r.createHref({pathname:s,search:o,hash:i})}function ct(){return S.useContext($e)!=null}function lt(){return k(ct(),`useLocation() may be used only in the context of a <Router> component.`),S.useContext($e).location}var ut=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function dt(e){S.useContext(Qe).static||S.useLayoutEffect(e)}function ft(){let{isDataRoute:e}=S.useContext(et);return e?Pt():pt()}function pt(){k(ct(),`useNavigate() may be used only in the context of a <Router> component.`);let e=S.useContext(Ge),{basename:t,navigator:n}=S.useContext(Qe),{matches:r}=S.useContext(et),{pathname:i}=lt(),a=JSON.stringify(Oe(r)),o=S.useRef(!1);return dt(()=>{o.current=!0}),S.useCallback((r,s={})=>{if(A(o.current,ut),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=ke(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:je([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}S.createContext(null);function mt(){let{matches:e}=S.useContext(et);return e[e.length-1]?.params??{}}function ht(e,{relative:t}={}){let{matches:n}=S.useContext(et),{pathname:r}=lt(),i=JSON.stringify(Oe(n));return S.useMemo(()=>ke(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function gt(e,t){return _t(e,t)}function _t(e,t,n){k(ct(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=S.useContext(Qe),{matches:i}=S.useContext(et),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;It(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=lt(),d;if(t){let e=typeof t==`string`?te(t):t;k(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):ne(e,{pathname:p});A(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),A(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=wt(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:je([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:je([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?S.createElement($e.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function vt(){let e=Nt(),t=Le(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=S.createElement(S.Fragment,null,S.createElement(`p`,null,`💿 Hey developer 👋`),S.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,S.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,S.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),S.createElement(S.Fragment,null,S.createElement(`h2`,null,`Unexpected Application Error!`),S.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?S.createElement(`pre`,{style:i},n):null,o)}var yt=S.createElement(vt,null),bt=class extends S.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=ot(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:S.createElement(et.Provider,{value:this.props.routeContext},S.createElement(tt.Provider,{value:e,children:this.props.component}));return this.context?S.createElement(St,{error:e},t):t}};bt.contextType=qe;var xt=new WeakMap;function St({children:e,error:t}){let{basename:n}=S.useContext(Qe);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=at(t.digest);if(e){let r=xt.get(t);if(r)throw r;let i=Be(e.location,n),a=i.absoluteURL||i.to;if(We(a))throw Error(`Invalid redirect location`);if(ze&&!xt.get(t))if(i.isExternal||e.reloadDocument)window.location.href=a;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw xt.set(t,n),n}return S.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${a}`})}}return e}function Ct({routeContext:e,match:t,children:n}){let r=S.useContext(Ge);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),S.createElement(et.Provider,{value:e},n)}function wt(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);k(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:Re(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||yt,o&&(s<0&&c===0?(It(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?S.createElement(n.route.Component,null):n.route.element?n.route.element:e,S.createElement(Ct,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?S.createElement(bt,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function Tt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Et(e){let t=S.useContext(Ge);return k(t,Tt(e)),t}function Dt(e){let t=S.useContext(Ke);return k(t,Tt(e)),t}function Ot(e){let t=S.useContext(et);return k(t,Tt(e)),t}function kt(e){let t=Ot(e),n=t.matches[t.matches.length-1];return k(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function At(){return kt(`useRouteId`)}function jt(){let e=Dt(`useNavigation`);return S.useMemo(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function Mt(){let{matches:e,loaderData:t}=Dt(`useMatches`);return S.useMemo(()=>e.map(e=>ie(e,t)),[e,t])}function Nt(){let e=S.useContext(tt),t=Dt(`useRouteError`),n=kt(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Pt(){let{router:e}=Et(`useNavigate`),t=kt(`useNavigate`),n=S.useRef(!1);return dt(()=>{n.current=!0}),S.useCallback(async(r,i={})=>{A(n.current,ut),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Ft={};function It(e,t,n){!t&&!Ft[e]&&(Ft[e]=!0,A(!1,n))}S.memo(Lt);function Lt({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return _t(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function Rt({to:e,replace:t,state:n,relative:r}){k(ct(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=S.useContext(Qe);A(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=S.useContext(et),{pathname:o}=lt(),s=ft(),c=ke(e,Oe(a),o,r===`path`),l=JSON.stringify(c);return S.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function I(e){k(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function zt({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:o}){k(!ct(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=S.useMemo(()=>({basename:s,navigator:i,static:a,useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=te(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,mask:m}=n,h=S.useMemo(()=>{let e=Ce(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return A(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:S.createElement(Qe.Provider,{value:c},S.createElement($e.Provider,{children:t,value:h}))}function Bt({children:e,location:t}){return gt(Vt(e),t)}S.Component;function Vt(e,t=[]){let n=[];return S.Children.forEach(e,(e,r)=>{if(!S.isValidElement(e))return;let i=[...t,r];if(e.type===S.Fragment){n.push.apply(n,Vt(e.props.children,i));return}k(e.type===I,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),k(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Vt(e.props.children,i)),n.push(a)}),n}var Ht=`get`,Ut=`application/x-www-form-urlencoded`;function Wt(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Gt(e){return Wt(e)&&e.tagName.toLowerCase()===`button`}function Kt(e){return Wt(e)&&e.tagName.toLowerCase()===`form`}function qt(e){return Wt(e)&&e.tagName.toLowerCase()===`input`}function Jt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Yt(e,t){return e.button===0&&(!t||t===`_self`)&&!Jt(e)}function Xt(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Zt(e,t){let n=Xt(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Qt=null;function $t(){if(Qt===null)try{new FormData(document.createElement(`form`),0),Qt=!1}catch{Qt=!0}return Qt}var en=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function tn(e){return e!=null&&!en.has(e)?(A(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ut}"`),null):e}function nn(e,t){let n,r,i,a,o;if(Kt(e)){let o=e.getAttribute(`action`);r=o?Ce(o,t):null,n=e.getAttribute(`method`)||Ht,i=tn(e.getAttribute(`enctype`))||Ut,a=new FormData(e)}else if(Gt(e)||qt(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?Ce(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||Ht,i=tn(e.getAttribute(`formenctype`))||tn(o.getAttribute(`enctype`))||Ut,a=new FormData(o,e),!$t()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(Wt(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=Ht,r=null,i=Ut,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var rn={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},an=/[&><\u2028\u2029]/g;function on(e){return e.replace(an,e=>rn[e])}function sn(e,t){if(e===!1||e==null)throw Error(t)}function cn(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&Ce(i.pathname,t)===`/`?i.pathname=`${Me(t)}/_root.${r}`:i.pathname=`${Me(i.pathname)}.${r}`,i}async function ln(e,t){if(e.id in t)return t[e.id];try{let n=await x(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function un(e){return e!=null&&typeof e.page==`string`}function dn(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function fn(e,t,n){return _n((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await ln(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(dn).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function pn(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function mn(e,t,{includeHydrateFallback:n}={}){return hn(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function hn(e){return[...new Set(e)]}function gn(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function _n(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!un(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(gn(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function vn(){let e=S.useContext(Ge);return sn(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function yn(){let e=S.useContext(Ke);return sn(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var bn=S.createContext(void 0);bn.displayName=`FrameworkContext`;function xn(){let e=S.useContext(bn);return sn(e,`You must render this element inside a <HydratedRouter> element`),e}function Sn(e,t){let n=S.useContext(bn),[r,i]=S.useState(!1),[a,o]=S.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=S.useRef(null);S.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),S.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:Cn(s,p),onBlur:Cn(c,m),onMouseEnter:Cn(l,p),onMouseLeave:Cn(u,m),onTouchStart:Cn(d,p)}]:[a,f,{}]:[!1,f,{}]}function Cn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function wn({page:e,...t}){let n=Je(),{nonce:r}=xn(),{router:i}=vn(),a=S.useMemo(()=>ne(i.routes,e,i.basename),[i.routes,e,i.basename]);return a?(t.nonce==null&&r&&(t={...t,nonce:r}),n?S.createElement(En,{page:e,matches:a,...t}):S.createElement(Dn,{page:e,matches:a,...t})):null}function Tn(e){let{manifest:t,routeModules:n}=xn(),[r,i]=S.useState([]);return S.useEffect(()=>{let r=!1;return fn(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function En({page:e,matches:t,...n}){let r=lt(),{future:i}=xn(),{basename:a}=vn(),o=S.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=cn(e,a,i.v8_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.v8_trailingSlashAwareDataRequests,e,r,t]);return S.createElement(S.Fragment,null,o.map(e=>S.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function Dn({page:e,matches:t,...n}){let r=lt(),{future:i,manifest:a,routeModules:o}=xn(),{basename:s}=vn(),{loaderData:c,matches:l}=yn(),u=S.useMemo(()=>pn(e,t,l,a,r,`data`),[e,t,l,a,r]),d=S.useMemo(()=>pn(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=S.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=cn(e,s,i.v8_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.v8_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=S.useMemo(()=>mn(d,a),[d,a]),m=Tn(d);return S.createElement(S.Fragment,null,f.map(e=>S.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>S.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>S.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function On(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}S.Component;var kn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{kn&&(window.__reactRouterVersion=`7.18.0`)}catch{}function An({basename:e,children:t,useTransitions:n,window:r}){let i=S.useRef();i.current??=O({window:r,v5Compat:!0});let a=i.current,[o,s]=S.useState({action:a.action,location:a.location}),c=S.useCallback(e=>{n===!1?s(e):S.startTransition(()=>s(e))},[n]);return S.useLayoutEffect(()=>a.listen(c),[a,c]),S.createElement(zt,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,useTransitions:n})}function jn({basename:e,children:t,history:n,useTransitions:r}){let[i,a]=S.useState({action:n.action,location:n.location}),o=S.useCallback(e=>{r===!1?a(e):S.startTransition(()=>a(e))},[r]);return S.useLayoutEffect(()=>n.listen(o),[n,o]),S.createElement(zt,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}jn.displayName=`unstable_HistoryRouter`;var Mn=S.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,useTransitions:_}=S.useContext(Qe),v=typeof l==`string`&&C.test(l),y=Be(l,h);l=y.to;let b=st(l,{relative:r}),x=lt(),w=null;if(o){let e=ke(o,[],x.mask?x.mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:je([h,e.pathname])),w=g.createHref(e)}let[T,E,D]=Sn(n,p),O=zn(l,{replace:a,mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,defaultShouldRevalidate:f,useTransitions:_});function k(t){e&&e(t),t.defaultPrevented||O(t)}let A=!(y.isExternal||i),j=S.createElement(`a`,{...p,...D,href:(A?w:void 0)||y.absoluteURL||b,onClick:A?k:e,ref:On(m,E),target:c,"data-discover":!v&&t===`render`?`true`:void 0});return T&&!v?S.createElement(S.Fragment,null,j,S.createElement(wn,{page:b})):j});Mn.displayName=`Link`;var Nn=S.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=ht(a,{relative:c.relative}),d=lt(),f=S.useContext(Ke),{navigator:p,basename:m}=S.useContext(Qe),h=f!=null&&Xn(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=Ce(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,x=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),C={isActive:b,isPending:x,isTransitioning:h},w=b?e:void 0,T;T=typeof n==`function`?n(C):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let E=typeof i==`function`?i(C):i;return S.createElement(Mn,{...c,"aria-current":w,className:T,ref:l,style:E,to:a,viewTransition:o},typeof s==`function`?s(C):s)});Nn.displayName=`NavLink`;var Pn=S.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=Ht,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m)=>{let{useTransitions:h}=S.useContext(Qe),g=Un(),_=Wn(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&C.test(s);return S.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f});h&&n!==!1?S.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});Pn.displayName=`Form`;function Fn({getKey:e,storageKey:t,...n}){let r=S.useContext(bn),{basename:i}=S.useContext(Qe),a=lt(),o=Mt();Jn({getKey:e,storageKey:t});let s=S.useMemo(()=>{if(!r||!e)return null;let t=qn(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return n.nonce==null&&r?.nonce&&(n.nonce=r.nonce),S.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${on(JSON.stringify(t||Gn))}, ${on(JSON.stringify(s))})`}})}Fn.displayName=`ScrollRestoration`;function In(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ln(e){let t=S.useContext(Ge);return k(t,In(e)),t}function Rn(e){let t=S.useContext(Ke);return k(t,In(e)),t}function zn(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=ft(),d=lt(),f=ht(e,{relative:o});return S.useCallback(p=>{if(Yt(p,t)){p.preventDefault();let t=n===void 0?ee(d)===ee(f):n,m=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?S.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function Bn(e){A(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=S.useRef(Xt(e)),n=S.useRef(!1),r=lt(),i=S.useMemo(()=>Zt(r.search,n.current?null:t.current),[r.search]),a=ft();return[i,S.useCallback((e,t)=>{let r=Xt(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var Vn=0,Hn=()=>`__${String(++Vn)}__`;function Un(){let{router:e}=Ln(`useSubmit`),{basename:t}=S.useContext(Qe),n=At(),r=e.fetch,i=e.navigate;return S.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=nn(e,t);a.navigate===!1?await r(a.fetcherKey||Hn(),n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function Wn(e,{relative:t}={}){let{basename:n}=S.useContext(Qe),r=S.useContext(et);k(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...ht(e||`.`,{relative:t})},o=lt();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:je([n,a.pathname])),ee(a)}var Gn=`react-router-scroll-positions`,Kn={};function qn(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:Ce(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Jn({getKey:e,storageKey:t}={}){let{router:n}=Ln(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=Rn(`useScrollRestoration`),{basename:a}=S.useContext(Qe),o=lt(),s=Mt(),c=jt();S.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),Yn(S.useCallback(()=>{if(c.state===`idle`){let t=qn(o,s,a,e);Kn[t]=window.scrollY}try{sessionStorage.setItem(t||Gn,JSON.stringify(Kn))}catch(e){A(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(S.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Gn);e&&(Kn=JSON.parse(e))}catch{}},[t]),S.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(Kn,()=>window.scrollY,e?(t,n)=>qn(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),S.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{A(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function Yn(e,t){let{capture:n}=t||{};S.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function Xn(e,{relative:t}={}){let n=S.useContext(Ye);k(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Ln(`useViewTransitionState`),i=ht(e,{relative:t});if(!n.isTransitioning)return!1;let a=Ce(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Ce(n.nextLocation.pathname,r)||n.nextLocation.pathname;return ye(i.pathname,o)!=null||ye(i.pathname,a)!=null}var Zn={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Qn=new class{#e=Zn;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function $n(e){setTimeout(e,0)}var er=typeof window>`u`||`Deno`in globalThis;function tr(){}function nr(e,t){return typeof e==`function`?e(t):e}function rr(e){return typeof e==`number`&&e>=0&&e!==1/0}function ir(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ar(e,t){return typeof e==`function`?e(t):e}function or(e,t){return typeof e==`function`?e(t):e}function sr(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==lr(o,t.options))return!1}else if(!dr(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function cr(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ur(t.options.mutationKey)!==ur(a))return!1}else if(!dr(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function lr(e,t){return(t?.queryKeyHashFn||ur)(e)}function ur(e){return JSON.stringify(e,(e,t)=>gr(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function dr(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>dr(e[n],t[n])):!1}var fr=Object.prototype.hasOwnProperty;function pr(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=hr(e)&&hr(t);if(!r&&!(gr(e)&&gr(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:fr.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=pr(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function mr(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function hr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function gr(e){if(!_r(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!_r(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function _r(e){return Object.prototype.toString.call(e)===`[object Object]`}function vr(e){return new Promise(t=>{Qn.setTimeout(t,e)})}function yr(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:pr(e,t)}function br(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function xr(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Sr=Symbol();function Cr(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Sr?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function wr(e,t){return typeof e==`function`?e(...t):!!e}function Tr(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Er=(()=>{let e=()=>er;return{isServer(){return e()},setIsServer(t){e=t}}})(),Dr=$n;function Or(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Dr,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var kr=Or(),Ar=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rr(this.gcTime)&&(this.#e=Qn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Er.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Qn.clearTimeout(this.#e),this.#e=void 0)}},jr=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(){}},Mr=new class extends jr{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Nr=new class extends jr{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Pr(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}function Fr(e){return Math.min(1e3*2**e,3e4)}function Ir(e){return(e??`online`)===`online`?Nr.isOnline():!0}var Lr=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Rr(e){let t=!1,n=0,r,i=Pr(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new Lr(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Mr.isFocused()&&(e.networkMode===`always`||Nr.isOnline())&&e.canRun(),u=()=>Ir(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Er.isServer()?0:3),o=e.retryDelay??Fr,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),vr(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var zr=class extends Ar{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Br(),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.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Rr({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,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{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),kr.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Br(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Vr=class extends jr{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),mr(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ur(t.mutationKey)!==ur(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Br();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){kr.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function Hr(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Tr(e,()=>t.signal,()=>n=!0)},u=Cr(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?xr:br;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Wr:Ur,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Ur(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Ur(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Wr(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Gr=class extends Ar{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Jr(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Jr(this.options);e.data!==void 0&&(this.setState(qr(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=yr(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(tr).catch(tr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>or(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Sr||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>ar(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!ir(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.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(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Cr(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Hr(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=Rr({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Lr&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Lr){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Kr(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...qr(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),kr.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Kr(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ir(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function qr(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Jr(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Yr=class extends jr{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??lr(r,t),a=this.get(i);return a||(a=new Gr({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){kr.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>sr(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>sr(e,t)):t}notify(e){kr.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){kr.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){kr.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Xr=class extends jr{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new zr({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Zr(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Zr(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Zr(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Zr(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){kr.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>cr(t,e))}findAll(e={}){return this.getAll().filter(t=>cr(e,t))}notify(e){kr.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return kr.batch(()=>Promise.all(e.map(e=>e.continue().catch(tr))))}};function Zr(e){return e.options.scope?.id}var Qr=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Yr,this.#t=e.mutationCache||new Xr,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Mr.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Nr.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ar(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=nr(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return kr.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;kr.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return kr.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=kr.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(tr).catch(tr)}invalidateQueries(e,t={}){return kr.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=kr.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(tr)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(tr)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(ar(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(tr).catch(tr)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(tr).catch(tr)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Nr.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ur(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{dr(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ur(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{dr(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=lr(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Sr&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},$r=class extends jr{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Pr(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),ti(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ni(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ni(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=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 or(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!mr(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&ri(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||or(this.options.enabled,this.#t)!==or(t.enabled,this.#t)||ar(this.options.staleTime,this.#t)!==ar(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||or(this.options.enabled,this.#t)!==or(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ai(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(tr)),t}#g(){this.#b();let e=ar(this.options.staleTime,this.#t);if(Er.isServer()||this.#r.isStale||!rr(e))return;let t=ir(this.#r.dataUpdatedAt,e)+1;this.#d=Qn.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(Er.isServer()||or(this.options.enabled,this.#t)===!1||!rr(this.#p)||this.#p===0)&&(this.#f=Qn.setInterval(()=>{(this.options.refetchIntervalInBackground||Mr.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Qn.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Qn.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&ti(e,t),o=i&&ri(e,n,t,r);(a||o)&&(l={...l,...Kr(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=yr(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=yr(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:ii(e,t),refetch:this.refetch,promise:this.#o,isEnabled:or(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=Pr())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!mr(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){kr.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function ei(e,t){return or(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&or(t.retryOnMount,e)===!1)}function ti(e,t){return ei(e,t)||e.state.data!==void 0&&ni(e,t,t.refetchOnMount)}function ni(e,t,n){if(or(t.enabled,e)!==!1&&ar(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&ii(e,t)}return!1}function ri(e,t,n,r){return(e!==t||or(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&ii(e,n)}function ii(e,t){return or(t.enabled,e)!==!1&&e.isStaleByTime(ar(t.staleTime,e))}function ai(e,t){return!mr(e.getCurrentResult(),t)}var oi=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),L=o(((e,t)=>{t.exports=oi()}))(),si=S.createContext(void 0),ci=e=>{let t=S.useContext(si);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},li=({client:e,children:t})=>(S.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,L.jsx)(si.Provider,{value:e,children:t}));function ui(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var di=S.createContext(ui()),fi=()=>S.useContext(di),pi=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?wr(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},mi=e=>{S.useEffect(()=>{e.clearReset()},[e])},hi=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||wr(n,[e.error,r])),gi=S.createContext(!1),_i=()=>S.useContext(gi);gi.Provider;var vi=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},yi=(e,t)=>e.isLoading&&e.isFetching&&!t,bi=(e,t)=>e?.suspense&&t.isPending,xi=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Si(e,t,n){let r=_i(),i=fi(),a=ci(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,vi(o),pi(o,i,s),mi(i);let l=!a.getQueryCache().get(o.queryHash),[u]=S.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(S.useSyncExternalStore(S.useCallback(e=>{let t=f?u.subscribe(kr.batchCalls(e)):tr;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),S.useEffect(()=>{u.setOptions(o)},[o,u]),bi(o,d))throw xi(o,u,i);if(hi({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!Er.isServer()&&yi(d,r)&&(l?xi(o,u,i):s?.promise)?.catch(tr).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function R(e,t){return Si(e,$r,t)}function z(e,t){let n=ci(t),[r]=S.useState(()=>new Vr(n,e));S.useEffect(()=>{r.setOptions(e)},[r,e]);let i=S.useSyncExternalStore(S.useCallback(e=>r.subscribe(kr.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=S.useCallback((e,t)=>{r.mutate(e,t).catch(tr)},[r]);if(i.error&&wr(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Ci(e,t){return function(){return e.apply(t,arguments)}}var{toString:wi}=Object.prototype,{getPrototypeOf:Ti}=Object,{iterator:Ei,toStringTag:Di}=Symbol,Oi=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ki=(e,t)=>{let n=e,r=[];for(;n!=null&&n!==Object.prototype;){if(r.indexOf(n)!==-1)return!1;if(r.push(n),Oi(n,t))return!0;n=Ti(n)}return!1},Ai=(e,t)=>e!=null&&ki(e,t)?e[t]:void 0,ji=(e=>t=>{let n=wi.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Mi=e=>(e=e.toLowerCase(),t=>ji(t)===e),Ni=e=>t=>typeof t===e,{isArray:Pi}=Array,Fi=Ni(`undefined`);function Ii(e){return e!==null&&!Fi(e)&&e.constructor!==null&&!Fi(e.constructor)&&Bi(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Li=Mi(`ArrayBuffer`);function Ri(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Li(e.buffer),t}var zi=Ni(`string`),Bi=Ni(`function`),Vi=Ni(`number`),Hi=e=>typeof e==`object`&&!!e,Ui=e=>e===!0||e===!1,Wi=e=>{if(!Hi(e))return!1;let t=Ti(e);return(t===null||t===Object.prototype||Ti(t)===null)&&!ki(e,Di)&&!ki(e,Ei)},Gi=e=>{if(!Hi(e)||Ii(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ki=Mi(`Date`),qi=Mi(`File`),Ji=e=>!!(e&&e.uri!==void 0),Yi=e=>e&&e.getParts!==void 0,Xi=Mi(`Blob`),Zi=Mi(`FileList`),Qi=e=>Hi(e)&&Bi(e.pipe);function $i(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}}var ea=$i(),ta=ea.FormData===void 0?void 0:ea.FormData,na=e=>{if(!e)return!1;if(ta&&e instanceof ta)return!0;let t=Ti(e);if(!t||t===Object.prototype||!Bi(e.append))return!1;let n=ji(e);return n===`formdata`||n===`object`&&Bi(e.toString)&&e.toString()===`[object FormData]`},ra=Mi(`URLSearchParams`),[ia,aa,oa,sa]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(Mi),ca=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function la(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),Pi(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(Ii(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length,o;for(r=0;r<a;r++)o=i[r],t.call(null,e[o],o,e)}}function ua(e,t){if(Ii(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,i;for(;r-->0;)if(i=n[r],t===i.toLowerCase())return i;return null}var da=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,fa=e=>!Fi(e)&&e!==da;function pa(...e){let{caseless:t,skipUndefined:n}=fa(this)&&this||{},r={},i=(e,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=t&&typeof i==`string`&&ua(r,i)||i,o=Oi(r,a)?r[a]:void 0;Wi(o)&&Wi(e)?r[a]=pa(o,e):Wi(e)?r[a]=pa({},e):Pi(e)?r[a]=e.slice():(!n||!Fi(e))&&(r[a]=e)};for(let t=0,n=e.length;t<n;t++){let n=e[t];if(!n||Ii(n)||(la(n,i),typeof n!=`object`||Pi(n)))continue;let r=Object.getOwnPropertySymbols(n);for(let e=0;e<r.length;e++){let t=r[e];Ta.call(n,t)&&i(n[t],t)}}return r}var ma=(e,t,n,{allOwnKeys:r}={})=>(la(t,(t,r)=>{n&&Bi(t)?Object.defineProperty(e,r,{__proto__:null,value:Ci(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{__proto__:null,value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),ha=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ga=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},_a=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-->0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&Ti(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},va=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},ya=e=>{if(!e)return null;if(Pi(e))return e;let t=e.length;if(!Vi(t))return null;let n=Array(t);for(;t-->0;)n[t]=e[t];return n},ba=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&Ti(Uint8Array)),xa=(e,t)=>{let n=(e&&e[Ei]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},Sa=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Ca=Mi(`HTMLFormElement`),wa=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),{propertyIsEnumerable:Ta}=Object.prototype,Ea=Mi(`RegExp`),Da=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};la(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},Oa=e=>{Da(e,(t,n)=>{if(Bi(e)&&[`arguments`,`caller`,`callee`].includes(n))return!1;let r=e[n];if(Bi(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},ka=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return Pi(e)?r(e):r(String(e).split(t)),n},Aa=()=>{},ja=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Ma(e){return!!(e&&Bi(e.append)&&e[Di]===`FormData`&&e[Ei])}var Na=e=>{let t=new WeakSet,n=e=>{if(Hi(e)){if(t.has(e))return;if(Ii(e))return e;if(!(`toJSON`in e)){t.add(e);let r=Pi(e)?[]:{};return la(e,(e,t)=>{let i=n(e);!Fi(i)&&(r[t]=i)}),t.delete(e),r}}return e};return n(e)},Pa=Mi(`AsyncFunction`),Fa=e=>e&&(Hi(e)||Bi(e))&&Bi(e.then)&&Bi(e.catch),Ia=((e,t)=>e?setImmediate:t?((e,t)=>(da.addEventListener(`message`,({source:n,data:r})=>{n===da&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),da.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,Bi(da.postMessage)),La=typeof queueMicrotask<`u`?queueMicrotask.bind(da):typeof process<`u`&&process.nextTick||Ia,Ra=e=>e!=null&&Bi(e[Ei]),B={isArray:Pi,isArrayBuffer:Li,isBuffer:Ii,isFormData:na,isArrayBufferView:Ri,isString:zi,isNumber:Vi,isBoolean:Ui,isObject:Hi,isPlainObject:Wi,isEmptyObject:Gi,isReadableStream:ia,isRequest:aa,isResponse:oa,isHeaders:sa,isUndefined:Fi,isDate:Ki,isFile:qi,isReactNativeBlob:Ji,isReactNative:Yi,isBlob:Xi,isRegExp:Ea,isFunction:Bi,isStream:Qi,isURLSearchParams:ra,isTypedArray:ba,isFileList:Zi,forEach:la,merge:pa,extend:ma,trim:ca,stripBOM:ha,inherits:ga,toFlatObject:_a,kindOf:ji,kindOfTest:Mi,endsWith:va,toArray:ya,forEachEntry:xa,matchAll:Sa,isHTMLForm:Ca,hasOwnProperty:Oi,hasOwnProp:Oi,hasOwnInPrototypeChain:ki,getSafeProp:Ai,reduceDescriptors:Da,freezeMethods:Oa,toObjectSet:ka,toCamelCase:wa,noop:Aa,toFiniteNumber:ja,findKey:ua,global:da,isContextDefined:fa,isSpecCompliantForm:Ma,toJSONObject:Na,isAsyncFn:Pa,isThenable:Fa,setImmediate:Ia,asap:La,isIterable:Ra,isSafeIterable:e=>e!=null&&ki(e,Ei)&&Ra(e)},za=B.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),Ba=e=>{let t={},n,r,i;return e&&e.split(`
`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&za[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t};function Va(e){let t=0,n=e.length;for(;t<n;){let n=e.charCodeAt(t);if(n!==9&&n!==32)break;t+=1}for(;n>t;){let t=e.charCodeAt(n-1);if(t!==9&&t!==32)break;--n}return t===0&&n===e.length?e:e.slice(t,n)}var Ha=RegExp(`[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+`,`g`),Ua=RegExp(`[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+`,`g`);function Wa(e,t){return B.isArray(e)?e.map(e=>Wa(e,t)):Va(String(e).replace(t,``))}var Ga=e=>Wa(e,Ha),Ka=e=>Wa(e,Ua);function qa(e){let t=Object.create(null);return B.forEach(e.toJSON(),(e,n)=>{t[n]=Ka(e)}),t}var Ja=Symbol(`internals`);function Ya(e){return e&&String(e).trim().toLowerCase()}function Xa(e){return e===!1||e==null?e:B.isArray(e)?e.map(Xa):Ga(String(e))}function Za(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var Qa=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function $a(e,t,n,r,i){if(B.isFunction(r))return r.call(this,t,n);if(i&&(t=n),B.isString(t)){if(B.isString(r))return t.indexOf(r)!==-1;if(B.isRegExp(r))return r.test(t)}}function eo(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function to(e,t){let n=B.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var no=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=Ya(t);if(!i)return;let a=B.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=Xa(e))}let a=(e,t)=>B.forEach(e,(e,n)=>i(e,n,t));if(B.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(B.isString(e)&&(e=e.trim())&&!Qa(e))a(Ba(e),t);else if(B.isObject(e)&&B.isSafeIterable(e)){let n=Object.create(null),r,i;for(let t of e){if(!B.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);i=t[0],B.hasOwnProp(n,i)?(r=n[i],n[i]=B.isArray(r)?[...r,t[1]]:[r,t[1]]):n[i]=t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=Ya(e),e){let n=B.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return Za(e);if(B.isFunction(t))return t.call(this,e,n);if(B.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=Ya(e),e){let n=B.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||$a(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=Ya(e),e){let i=B.findKey(n,e);i&&(!t||$a(n,n[i],i,t))&&(delete n[i],r=!0)}}return B.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||$a(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return B.forEach(this,(r,i)=>{let a=B.findKey(n,i);if(a){t[a]=Xa(r),delete t[i];return}let o=e?eo(i):String(i).trim();o!==i&&delete t[i],t[o]=Xa(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return B.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&B.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(`
`)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[Ja]=this[Ja]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=Ya(e);t[r]||(to(n,e),t[r]=!0)}return B.isArray(e)?e.forEach(r):r(e),this}};no.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),B.reduceDescriptors(no.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),B.freezeMethods(no);var ro=`[REDACTED ****]`;function io(e){if(B.hasOwnProp(e,`toJSON`))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(B.hasOwnProp(t,`toJSON`))return!0;t=Object.getPrototypeOf(t)}return!1}function ao(e,t){let n=new Set(t.map(e=>String(e).toLowerCase())),r=[],i=e=>{if(typeof e!=`object`||!e||B.isBuffer(e))return e;if(r.indexOf(e)!==-1)return;e instanceof no&&(e=e.toJSON()),r.push(e);let t;if(B.isArray(e))t=[],e.forEach((e,n)=>{let r=i(e);B.isUndefined(r)||(t[n]=r)});else{if(!B.isPlainObject(e)&&io(e))return r.pop(),e;t=Object.create(null);for(let[r,a]of Object.entries(e)){let e=n.has(r.toLowerCase())?ro:i(a);B.isUndefined(e)||(t[r]=e)}}return r.pop(),t};return i(e)}var V=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return Object.defineProperty(s,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,"message",{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){let e=this.config,t=e&&B.hasOwnProp(e,`redact`)?e.redact:void 0,n=B.isArray(t)&&t.length>0?ao(e,t):B.toJSONObject(e);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:n,code:this.code,status:this.status}}};V.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,V.ERR_BAD_OPTION=`ERR_BAD_OPTION`,V.ECONNABORTED=`ECONNABORTED`,V.ETIMEDOUT=`ETIMEDOUT`,V.ECONNREFUSED=`ECONNREFUSED`,V.ERR_NETWORK=`ERR_NETWORK`,V.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,V.ERR_DEPRECATED=`ERR_DEPRECATED`,V.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,V.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,V.ERR_CANCELED=`ERR_CANCELED`,V.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,V.ERR_INVALID_URL=`ERR_INVALID_URL`,V.ERR_FORM_DATA_DEPTH_EXCEEDED=`ERR_FORM_DATA_DEPTH_EXCEEDED`;function oo(e){return B.isPlainObject(e)||B.isArray(e)}function so(e){return B.endsWith(e,`[]`)?e.slice(0,-2):e}function co(e,t,n){return e?e.concat(t).map(function(e,t){return e=so(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function lo(e){return B.isArray(e)&&!e.some(oo)}var uo=B.toFlatObject(B,{},null,function(e){return/^is[A-Z]/.test(e)});function fo(e,t,n){if(!B.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=B.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!B.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||m,a=n.dots,o=n.indexes,s=n.Blob||typeof Blob<`u`&&Blob,c=n.maxDepth===void 0?100:n.maxDepth,l=s&&B.isSpecCompliantForm(t),u=[];if(!B.isFunction(i))throw TypeError(`visitor must be a function`);function d(e){if(e===null)return``;if(B.isDate(e))return e.toISOString();if(B.isBoolean(e))return e.toString();if(!l&&B.isBlob(e))throw new V(`Blob is not supported. Use a Buffer instead.`);if(B.isArrayBuffer(e)||B.isTypedArray(e)){if(l&&typeof s==`function`)return new s([e]);if(typeof Buffer<`u`)return Buffer.from(e);throw new V(`Blob is not supported. Use a Buffer instead.`,V.ERR_NOT_SUPPORT)}return e}function f(e){if(e>c)throw new V(`Object is too deeply nested (`+e+` levels). Max depth: `+c,V.ERR_FORM_DATA_DEPTH_EXCEEDED)}function p(e,t){if(c===1/0)return JSON.stringify(e);let n=[];return JSON.stringify(e,function(e,r){if(!B.isObject(r))return r;for(;n.length&&n[n.length-1]!==this;)n.pop();return n.push(r),f(t+n.length-1),r})}function m(e,n,i){let s=e;if(B.isReactNative(t)&&B.isReactNativeBlob(e))return t.append(co(i,n,a),d(e)),!1;if(e&&!i&&typeof e==`object`){if(B.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=p(e,1);else if(B.isArray(e)&&lo(e)||(B.isFileList(e)||B.endsWith(n,`[]`))&&(s=B.toArray(e)))return n=so(n),s.forEach(function(e,r){!(B.isUndefined(e)||e===null)&&t.append(o===!0?co([n],r,a):o===null?n:n+`[]`,d(e))}),!1}return oo(e)?!0:(t.append(co(i,n,a),d(e)),!1)}let h=Object.assign(uo,{defaultVisitor:m,convertValue:d,isVisitable:oo});function g(e,n,r=0){if(!B.isUndefined(e)){if(f(r),u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),B.forEach(e,function(e,a){(!(B.isUndefined(e)||e===null)&&i.call(t,e,B.isString(a)?a.trim():a,n,h))===!0&&g(e,n?n.concat(a):[a],r+1)}),u.pop()}}if(!B.isObject(e))throw TypeError(`data must be an object`);return g(e),t}function po(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(e){return t[e]})}function mo(e,t){this._pairs=[],e&&fo(e,this,t)}var ho=mo.prototype;ho.append=function(e,t){this._pairs.push([e,t])},ho.toString=function(e){let t=e?t=>e.call(this,t,po):po;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function go(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function _o(e,t,n){if(!t)return e;e||=``;let r=B.isFunction(n)?{serialize:n}:n,i=B.getSafeProp(r,`encode`)||go,a=B.getSafeProp(r,`serialize`),o;if(o=a?a(t,r):B.isURLSearchParams(t)?t.toString():new mo(t,r).toString(i),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var vo=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){B.forEach(this.handlers,function(t){t!==null&&e(t)})}},yo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},bo={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:mo,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},xo=s({hasBrowserEnv:()=>So,hasStandardBrowserEnv:()=>wo,hasStandardBrowserWebWorkerEnv:()=>To,navigator:()=>Co,origin:()=>Eo}),So=typeof window<`u`&&typeof document<`u`,Co=typeof navigator==`object`&&navigator||void 0,wo=So&&(!Co||[`ReactNative`,`NativeScript`,`NS`].indexOf(Co.product)<0),To=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,Eo=So&&window.location.href||`http://localhost`,Do={...xo,...bo};function Oo(e,t){return fo(e,new Do.classes.URLSearchParams,{visitor:function(e,t,n,r){return Do.isNode&&B.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}var ko=100;function Ao(e){if(e>ko)throw new V(`FormData field is too deeply nested (`+e+` levels). Max depth: `+ko,V.ERR_FORM_DATA_DEPTH_EXCEEDED)}function jo(e){let t=[],n=/\w+|\[(\w*)]/g,r;for(;(r=n.exec(e))!==null;)Ao(t.length),t.push(r[0]===`[]`?``:r[1]||r[0]);return t}function Mo(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r<i;r++)a=n[r],t[a]=e[a];return t}function No(e){function t(e,n,r,i){Ao(i);let a=e[i++];if(a===`__proto__`)return!0;let o=Number.isFinite(+a),s=i>=e.length;return a=!a&&B.isArray(r)?r.length:a,s?(B.hasOwnProp(r,a)?r[a]=B.isArray(r[a])?r[a].concat(n):[r[a],n]:r[a]=n,!o):((!B.hasOwnProp(r,a)||!B.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&B.isArray(r[a])&&(r[a]=Mo(r[a])),!o)}if(B.isFormData(e)&&B.isFunction(e.entries)){let n={};return B.forEachEntry(e,(e,r)=>{t(jo(e),r,n,0)}),n}return null}var Po=(e,t)=>e!=null&&B.hasOwnProp(e,t)?e[t]:void 0;function Fo(e,t,n){if(B.isString(e))try{return(t||JSON.parse)(e),B.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var Io={transitional:yo,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=B.isObject(e);if(i&&B.isHTMLForm(e)&&(e=new FormData(e)),B.isFormData(e))return r?JSON.stringify(No(e)):e;if(B.isArrayBuffer(e)||B.isBuffer(e)||B.isStream(e)||B.isFile(e)||B.isBlob(e)||B.isReadableStream(e))return e;if(B.isArrayBufferView(e))return e.buffer;if(B.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){let t=Po(this,`formSerializer`);if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return Oo(e,t).toString();if((a=B.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let n=Po(this,`env`),r=n&&n.FormData;return fo(a?{"files[]":e}:e,r&&new r,t)}}return i||r?(t.setContentType(`application/json`,!1),Fo(e)):e}],transformResponse:[function(e){let t=Po(this,`transitional`)||Io.transitional,n=t&&t.forcedJSONParsing,r=Po(this,`responseType`),i=r===`json`;if(B.isResponse(e)||B.isReadableStream(e))return e;if(e&&B.isString(e)&&(n&&!r||i)){let n=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,Po(this,`parseReviver`))}catch(e){if(n)throw e.name===`SyntaxError`?V.from(e,V.ERR_BAD_RESPONSE,this,null,Po(this,`response`)):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:Do.classes.FormData,Blob:Do.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};B.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`],e=>{Io.headers[e]={}});function Lo(e,t){let n=this||Io,r=t||n,i=no.from(r.headers),a=r.data;return B.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function Ro(e){return!!(e&&e.__CANCEL__)}var zo=class extends V{constructor(e,t,n){super(e??`canceled`,V.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function Bo(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new V(`Request failed with status code `+n.status,n.status>=400&&n.status<500?V.ERR_BAD_REQUEST:V.ERR_BAD_RESPONSE,n.config,n.request,n))}function Vo(e){let t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||``}function Ho(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o<t)return;let f=l&&c-l;return f?Math.round(d*1e3/f):void 0}}function Uo(e,t){let n=0,r=1e3/t,i,a,o=(t,r=Date.now())=>{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var Wo=(e,t,n=3)=>{let r=0,i=Ho(50,250);return Uo(n=>{if(!n||typeof n.loaded!=`number`)return;let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=o==null?a:Math.min(a,o),c=Math.max(0,s-r),l=i(c);r=Math.max(r,s),e({loaded:s,total:o,progress:o?s/o:void 0,bytes:c,rate:l||void 0,estimated:l&&o?(o-s)/l:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},Go=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ko=e=>(...t)=>B.asap(()=>e(...t)),qo=Do.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,Do.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(Do.origin),Do.navigator&&/(msie|trident)/i.test(Do.navigator.userAgent)):()=>!0,Jo=Do.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];B.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),B.isString(r)&&s.push(`path=${r}`),B.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),B.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.split(`;`);for(let n=0;n<t.length;n++){let r=t[n].replace(/^\s+/,``),i=r.indexOf(`=`);if(i!==-1&&r.slice(0,i)===e)try{return decodeURIComponent(r.slice(i+1))}catch{return r.slice(i+1)}}return null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function Yo(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function Xo(e,t){return t?e.replace(/\/?\/$/,``)+`/`+t.replace(/^\/+/,``):e}var Zo=/^https?:(?!\/\/)/i,Qo=/[\t\n\r]/g;function $o(e){let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t)}function es(e){return $o(e).replace(Qo,``)}function ts(e,t){if(typeof e==`string`&&Zo.test(es(e)))throw new V(`Invalid URL: missing "//" after protocol`,V.ERR_INVALID_URL,t)}function ns(e,t,n,r){ts(t,r);let i=!Yo(t);return e&&(i||n===!1)?(ts(e,r),Xo(e,t)):t}var rs=e=>e instanceof no?{...e}:e;function is(e,t){e||={},t||={};let n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(e,t,n,r){return B.isPlainObject(e)&&B.isPlainObject(t)?B.merge.call({caseless:r},e,t):B.isPlainObject(t)?B.merge({},t):B.isArray(t)?t.slice():t}function i(e,t,n,i){if(!B.isUndefined(t))return r(e,t,n,i);if(!B.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!B.isUndefined(t))return r(void 0,t)}function o(e,t){if(!B.isUndefined(t))return r(void 0,t);if(!B.isUndefined(e))return r(void 0,e)}function s(n){let r=B.hasOwnProp(t,`transitional`)?t.transitional:void 0;if(!B.isUndefined(r))if(B.isPlainObject(r)){if(B.hasOwnProp(r,n))return r[n]}else return;let i=B.hasOwnProp(e,`transitional`)?e.transitional:void 0;if(B.isPlainObject(i)&&B.hasOwnProp(i,n))return i[n]}function c(n,i,a){if(B.hasOwnProp(t,a))return r(n,i);if(B.hasOwnProp(e,a))return r(void 0,n)}let l={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,allowedSocketPaths:o,responseEncoding:o,validateStatus:c,headers:(e,t,n)=>i(rs(e),rs(t),n,!0)};return B.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=B.hasOwnProp(l,r)?l[r]:i,o=a(B.hasOwnProp(e,r)?e[r]:void 0,B.hasOwnProp(t,r)?t[r]:void 0,r);B.isUndefined(o)&&a!==c||(n[r]=o)}),B.hasOwnProp(t,`validateStatus`)&&B.isUndefined(t.validateStatus)&&s(`validateStatusUndefinedResolves`)===!1&&(B.hasOwnProp(e,`validateStatus`)?n.validateStatus=r(void 0,e.validateStatus):delete n.validateStatus),n}var as=[`content-type`,`content-length`];function os(e,t,n){if(n!==`content-only`){e.set(t);return}Object.entries(t||{}).forEach(([t,n])=>{as.includes(t.toLowerCase())&&e.set(t,n)})}var ss=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16)));function cs(e){let t=is({},e),n=e=>B.hasOwnProp(t,e)?t[e]:void 0,r=n(`data`),i=n(`withXSRFToken`),a=n(`xsrfHeaderName`),o=n(`xsrfCookieName`),s=n(`headers`),c=n(`auth`),l=n(`baseURL`),u=n(`allowAbsoluteUrls`),d=n(`url`);if(t.headers=s=no.from(s),t.url=_o(ns(l,d,u,t),n(`params`),n(`paramsSerializer`)),c){let t=B.getSafeProp(c,`username`)||``,n=B.getSafeProp(c,`password`)||``;try{s.set(`Authorization`,`Basic `+btoa(t+`:`+(n?ss(n):``)))}catch(t){throw V.from(t,V.ERR_BAD_OPTION_VALUE,e)}}if(B.isFormData(r)&&(Do.hasStandardBrowserEnv||Do.hasStandardBrowserWebWorkerEnv||B.isReactNative(r)?s.setContentType(void 0):B.isFunction(r.getHeaders)&&os(s,r.getHeaders(),n(`formDataHeaderPolicy`))),Do.hasStandardBrowserEnv&&(B.isFunction(i)&&(i=i(t)),i===!0||i==null&&qo(t.url))){let e=a&&o&&Jo.read(o);e&&s.set(a,e)}return t}var ls=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=cs(e),i=r.data,a=no.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=no.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());Bo(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.startsWith(`file:`))||setTimeout(g)},h.onabort=function(){h&&=(n(new V(`Request aborted`,V.ECONNABORTED,e,h)),m(),null)},h.onerror=function(t){let r=new V(t&&t.message?t.message:`Network Error`,V.ERR_NETWORK,e,h);r.event=t||null,n(r),m(),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||yo;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new V(t,i.clarifyTimeoutError?V.ETIMEDOUT:V.ECONNABORTED,e,h)),m(),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&B.forEach(qa(a),function(e,t){h.setRequestHeader(t,e)}),B.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=Wo(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=Wo(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new zo(null,e,h):t),h.abort(),m(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=Vo(r.url);if(_&&!Do.protocols.includes(_)){n(new V(`Unsupported protocol `+_+`:`,V.ERR_BAD_REQUEST,e)),m();return}h.send(i||null)})},us=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;let n=new AbortController,r=!1,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof V?t:new zo(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new V(`timeout of ${t}ms exceeded`,V.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i,{once:!0}));let{signal:s}=n;return s.unsubscribe=()=>B.asap(o),s},ds=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},fs=async function*(e,t){for await(let n of ps(e))yield*ds(n,t)},ps=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},ms=(e,t,n,r)=>{let i=fs(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},hs=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,gs=(e,t,n)=>t+2<n&&hs(e.charCodeAt(t+1))&&hs(e.charCodeAt(t+2));function _s(e){if(!e||typeof e!=`string`||!e.startsWith(`data:`))return 0;let t=e.indexOf(`,`);if(t<0)return 0;let n=e.slice(5,t),r=e.slice(t+1);if(/;base64/i.test(n)){let e=r.length,t=r.length;for(let n=0;n<t;n++)if(r.charCodeAt(n)===37&&n+2<t){let t=r.charCodeAt(n+1),i=r.charCodeAt(n+2);hs(t)&&hs(i)&&(e-=2,n+=2)}let n=0,i=t-1,a=e=>e>=2&&r.charCodeAt(e-2)===37&&r.charCodeAt(e-1)===51&&(r.charCodeAt(e)===68||r.charCodeAt(e)===100);i>=0&&(r.charCodeAt(i)===61?(n++,i--):a(i)&&(n++,i-=3)),n===1&&i>=0&&(r.charCodeAt(i)===61||a(i))&&n++;let o=Math.floor(e/4)*3-(n||0);return o>0?o:0}let i=0;for(let e=0,t=r.length;e<t;e++){let n=r.charCodeAt(e);if(n===37&&gs(r,e,t))i+=1,e+=2;else if(n<128)i+=1;else if(n<2048)i+=2;else if(n>=55296&&n<=56319&&e+1<t){let t=r.charCodeAt(e+1);t>=56320&&t<=57343?(i+=4,e++):i+=3}else i+=3}return i}var vs=`1.18.1`,ys=64*1024,{isFunction:bs}=B,xs=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))),Ss=e=>{if(!B.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},Cs=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ws=e=>{let t=e.indexOf(`://`),n=e;return t!==-1&&(n=n.slice(t+3)),n.includes(`@`)||n.includes(`:`)},Ts=e=>{let t=B.global!==void 0&&B.global!==null?B.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=B.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);let{fetch:i,Request:a,Response:o}=e,s=i?bs(i):typeof fetch==`function`,c=bs(a),l=bs(o);if(!s)return!1;let u=s&&bs(n),d=s&&(typeof r==`function`?(e=>t=>e.encode(t))(new r):async e=>new Uint8Array(await new a(e).arrayBuffer())),f=c&&u&&Cs(()=>{let e=!1,t=new a(Do.origin,{body:new n,method:`POST`,get duplex(){return e=!0,`half`}}),r=t.headers.has(`Content-Type`);return t.body!=null&&t.body.cancel(),e&&!r}),p=l&&u&&Cs(()=>B.isReadableStream(new o(``).body)),m={stream:p&&(e=>e.body)};s&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!m[e]&&(m[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new V(`Response type '${e}' is not supported`,V.ERR_NOT_SUPPORT,n)})});let h=async e=>{if(e==null)return 0;if(B.isBlob(e))return e.size;if(B.isSpecCompliantForm(e))return(await new a(Do.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(B.isArrayBufferView(e)||B.isArrayBuffer(e))return e.byteLength;if(B.isURLSearchParams(e)&&(e+=``),B.isString(e))return(await d(e)).byteLength},g=async(e,t)=>B.toFiniteNumber(e.getContentLength())??h(t);return async e=>{let{url:t,method:n,data:s,signal:l,cancelToken:d,timeout:_,onDownloadProgress:v,onUploadProgress:y,responseType:b,headers:x,withCredentials:S=`same-origin`,fetchOptions:C,maxContentLength:w,maxBodyLength:T}=cs(e),E=B.isNumber(w)&&w>-1,D=B.isNumber(T)&&T>-1,O=t=>B.hasOwnProp(e,t)?e[t]:void 0,k=i||fetch;b=b?(b+``).toLowerCase():`text`;let A=us([l,d&&d.toAbortSignal()],_),j=null,M=A&&A.unsubscribe&&(()=>{A.unsubscribe()}),N,ee=null,te=()=>new V(`Request body larger than maxBodyLength limit`,V.ERR_BAD_REQUEST,e,j);try{let i,l=O(`auth`);if(l&&(i={username:B.getSafeProp(l,`username`)||``,password:B.getSafeProp(l,`password`)||``}),ws(t)){let e=new URL(t,Do.origin);!i&&(e.username||e.password)&&(i={username:Ss(e.username),password:Ss(e.password)}),(e.username||e.password)&&(e.username=``,e.password=``,t=e.href)}if(i&&(x.delete(`authorization`),x.set(`Authorization`,`Basic `+btoa(xs((i.username||``)+`:`+(i.password||``))))),E&&typeof t==`string`&&t.startsWith(`data:`)&&_s(t)>w)throw new V(`maxContentLength size of `+w+` exceeded`,V.ERR_BAD_RESPONSE,e,j);if(D&&n!==`get`&&n!==`head`){let e=await h(s);if(typeof e==`number`&&isFinite(e)&&(N=e,e>T))throw te()}let d=D&&(B.isReadableStream(s)||B.isStream(s)),_=(e,t,n)=>ms(e,ys,e=>{if(D&&e>T)throw ee=te();t&&t(e)},n);if(f&&n!==`get`&&n!==`head`&&(y||d)){if(N??=await g(x,s),N!==0||d){let e=new a(t,{method:`POST`,body:s,duplex:`half`}),n;if(B.isFormData(s)&&(n=e.headers.get(`content-type`))&&x.setContentType(n),e.body){let[t,n]=y&&Go(N,Wo(Ko(y)))||[];s=_(e.body,t,n)}}}else if(d&&!c&&u&&n!==`get`&&n!==`head`)s=_(s);else if(d&&c&&!f&&n!==`get`&&n!==`head`)throw new V(`Stream request bodies are not supported by the current fetch implementation`,V.ERR_NOT_SUPPORT,e,j);B.isString(S)||(S=S?`include`:`omit`);let P=c&&`credentials`in a.prototype;if(B.isFormData(s)){let e=x.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&x.delete(`content-type`)}x.set(`User-Agent`,`axios/`+vs,!1);let F={...C,signal:A,method:n.toUpperCase(),headers:qa(x.normalize()),body:s,duplex:`half`,credentials:P?S:void 0};j=c&&new a(t,F);let ne=await(c?k(j,C):k(t,F)),re=no.from(ne.headers);if(E){let t=B.toFiniteNumber(re.getContentLength());if(t!=null&&t>w)throw new V(`maxContentLength size of `+w+` exceeded`,V.ERR_BAD_RESPONSE,e,j)}let ie=p&&(b===`stream`||b===`response`);if(p&&ne.body&&(v||E||ie&&M)){let t={};[`status`,`statusText`,`headers`].forEach(e=>{t[e]=ne[e]});let n=B.toFiniteNumber(re.getContentLength()),[r,i]=v&&Go(n,Wo(Ko(v),!0))||[],a=0;ne=new o(ms(ne.body,ys,t=>{if(E&&(a=t,a>w))throw new V(`maxContentLength size of `+w+` exceeded`,V.ERR_BAD_RESPONSE,e,j);r&&r(t)},()=>{i&&i(),M&&M()}),t)}b||=`text`;let ae=await m[B.findKey(m,b)||`text`](ne,e);if(E&&!p&&!ie){let t;if(ae!=null&&(typeof ae.byteLength==`number`?t=ae.byteLength:typeof ae.size==`number`?t=ae.size:typeof ae==`string`&&(t=typeof r==`function`?new r().encode(ae).byteLength:ae.length)),typeof t==`number`&&t>w)throw new V(`maxContentLength size of `+w+` exceeded`,V.ERR_BAD_RESPONSE,e,j)}return!ie&&M&&M(),await new Promise((t,n)=>{Bo(t,n,{data:ae,headers:no.from(ne.headers),status:ne.status,statusText:ne.statusText,config:e,request:j})})}catch(t){if(M&&M(),A&&A.aborted&&A.reason instanceof V){let n=A.reason;throw n.config=e,j&&(n.request=j),t!==n&&Object.defineProperty(n,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),n}if(ee)throw j&&!ee.request&&(ee.request=j),ee;if(t instanceof V)throw j&&!t.request&&(t.request=j),t;if(t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)){let n=new V(`Network Error`,V.ERR_NETWORK,e,j,t&&t.response);throw Object.defineProperty(n,"cause",{__proto__:null,value:t.cause||t,writable:!0,enumerable:!1,configurable:!0}),n}throw V.from(t,t&&t.code,e,j,t&&t.response)}}},Es=new Map,Ds=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=Es;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:Ts(t)),l=c;return c};Ds();var Os={http:null,xhr:ls,fetch:{get:Ds}};B.forEach(Os,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});var ks=e=>`- ${e}`,As=e=>B.isFunction(e)||e===null||e===!1;function js(e,t){e=B.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o<n;o++){r=e[o];let n;if(i=r,!As(r)&&(i=Os[(n=String(r)).toLowerCase()],i===void 0))throw new V(`Unknown adapter '${n}'`);if(i&&(B.isFunction(i)||(i=i.get(t))))break;a[n||`#`+o]=i}if(!i){let e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new V(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since :
`+e.map(ks).join(`
`):` `+ks(e[0]):`as no adapter specified`),V.ERR_NOT_SUPPORT)}return i}var Ms={getAdapter:js,adapters:Os};function Ns(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new zo(null,e)}function Ps(e){return Ns(e),e.headers=no.from(e.headers),e.data=Lo.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),Ms.getAdapter(e.adapter||Io.adapter,e)(e).then(function(t){Ns(e),e.response=t;try{t.data=Lo.call(e,e.transformResponse,t)}finally{delete e.response}return t.headers=no.from(t.headers),t},function(t){if(!Ro(t)&&(Ns(e),t&&t.response)){e.response=t.response;try{t.response.data=Lo.call(e,e.transformResponse,t.response)}finally{delete e.response}t.response.headers=no.from(t.response.headers)}return Promise.reject(t)})}var Fs={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{Fs[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});var Is={};Fs.transitional=function(e,t,n){function r(e,t){return`[Axios v`+vs+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new V(r(i,` has been removed`+(t?` in `+t:``)),V.ERR_DEPRECATED);return t&&!Is[i]&&(Is[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),e?e(n,i,a):!0}},Fs.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Ls(e,t,n){if(typeof e!=`object`||!e)throw new V(`options must be an object`,V.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-->0;){let a=r[i],o=Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new V(`option `+a+` must be `+n,V.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new V(`Unknown option `+a,V.ERR_BAD_OPTION)}}var Rs={assertOptions:Ls,validators:Fs},zs=Rs.validators,Bs=class{constructor(e){this.defaults=e||{},this.interceptors={request:new vo,response:new vo}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=(()=>{if(!t.stack)return``;let e=t.stack.indexOf(`
`);return e===-1?``:t.stack.slice(e+1)})();try{if(!e.stack)e.stack=n;else if(n){let t=n.indexOf(`
`),r=t===-1?-1:n.indexOf(`
`,t+1),i=r===-1?``:n.slice(r+1);String(e.stack).endsWith(i)||(e.stack+=`
`+n)}}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=is(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&Rs.assertOptions(n,{silentJSONParsing:zs.transitional(zs.boolean),forcedJSONParsing:zs.transitional(zs.boolean),clarifyTimeoutError:zs.transitional(zs.boolean),legacyInterceptorReqResOrdering:zs.transitional(zs.boolean),advertiseZstdAcceptEncoding:zs.transitional(zs.boolean),validateStatusUndefinedResolves:zs.transitional(zs.boolean)},!1),r!=null&&(B.isFunction(r)?t.paramsSerializer={serialize:r}:Rs.assertOptions(r,{encode:zs.function,serialize:zs.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),Rs.assertOptions(t,{baseUrl:zs.spelling(`baseURL`),withXsrfToken:zs.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&B.merge(i.common,i[t.method]);i&&B.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`,`common`],e=>{delete i[e]}),t.headers=no.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||yo;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[Ps.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=Ps.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=is(this.defaults,e),_o(ns(e.baseURL,e.url,e.allowAbsoluteUrls,e),e.params,e.paramsSerializer)}};B.forEach([`delete`,`get`,`head`,`options`],function(e){Bs.prototype[e]=function(t,n){return this.request(is(n||{},{method:e,url:t,data:n&&B.hasOwnProp(n,`data`)?n.data:void 0}))}}),B.forEach([`post`,`put`,`patch`,`query`],function(e){function t(t){return function(n,r,i){return this.request(is(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}Bs.prototype[e]=t(),e!==`query`&&(Bs.prototype[e+`Form`]=t(!0))});var Vs=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-->0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new zo(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function Hs(e){return function(t){return e.apply(null,t)}}function Us(e){return B.isObject(e)&&e.isAxiosError===!0}var Ws={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ws).forEach(([e,t])=>{Ws[t]=e});function Gs(e){let t=new Bs(e),n=Ci(Bs.prototype.request,t);return B.extend(n,Bs.prototype,t,{allOwnKeys:!0}),B.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return Gs(is(e,t))},n}var Ks=Gs(Io);Ks.Axios=Bs,Ks.CanceledError=zo,Ks.CancelToken=Vs,Ks.isCancel=Ro,Ks.VERSION=vs,Ks.toFormData=fo,Ks.AxiosError=V,Ks.Cancel=Ks.CanceledError,Ks.all=function(e){return Promise.all(e)},Ks.spread=Hs,Ks.isAxiosError=Us,Ks.mergeConfig=is,Ks.AxiosHeaders=no,Ks.formToJSON=e=>No(B.isHTMLForm(e)?new FormData(e):e),Ks.getAdapter=Ms.getAdapter,Ks.HttpStatusCode=Ws,Ks.default=Ks;var qs=l(_(),1),H=Ks.create({baseURL:``,withCredentials:!0,timeout:12e4,headers:{"Content-Type":`application/json`}}),Js=null,Ys=null;async function Xs(){return Ys||=Ks.get(`/api/csrf-token`,{withCredentials:!0}).then(e=>(Js=e.data.token,Js)).catch(()=>null).finally(()=>{Ys=null}),Ys}var Zs=[`post`,`put`,`delete`,`patch`];H.interceptors.request.use(async e=>{let t=(e.method||`get`).toLowerCase();return Zs.includes(t)&&(Js||await Xs(),Js&&(e.headers[`X-CSRF-Token`]=Js)),e}),H.interceptors.response.use(e=>e,async e=>{if(e.response?.status===403&&typeof e.response?.data?.error==`string`&&e.response.data.error.toLowerCase().includes(`csrf`)&&!e.config?._csrfRetried){Js=null;let t=await Xs();if(t)return e.config._csrfRetried=!0,e.config.headers[`X-CSRF-Token`]=t,H.request(e.config)}if(e.response?.status===401){let t=e.config?.url||``;if(!t.includes(`/auth/`)&&!t.includes(`/coaching/`)&&window.location.pathname!==`/auth/login`&&window.location.pathname!==`/auth/signup`){try{await fetch(`/api/auth/logout`,{method:`POST`,credentials:`include`})}catch{}window.location.replace(`/auth/login`)}}return Promise.reject(e)});var U=H,Qs={getCurrentUser:async()=>{try{let{data:e}=await H.get(`/api/auth/user`);return e.user}catch{return null}},login:async(e,t)=>{let{data:n}=await H.post(`/api/auth/login`,{email:e,password:t});return n},signup:async e=>{let{data:t}=await H.post(`/api/auth/signup`,e);return t},logout:async()=>{await H.post(`/api/auth/logout`)},updateProfile:async e=>{let{data:t}=await H.put(`/api/auth/user`,{full_name:e});return{id:t.user.id,email:t.user.email,full_name:t.user.full_name,role:t.user.role}},forgotPassword:async e=>{let{data:t}=await H.post(`/api/auth/forgot-password`,{email:e});return t},resetPassword:async(e,t)=>{let{data:n}=await H.post(`/api/auth/reset-password`,{token:e,password:t});return n},changePassword:async(e,t)=>{let{data:n}=await H.post(`/api/auth/change`,{currentPassword:e,newPassword:t});return n}},$s={owner:5,admin:4,manager:3,rep:2,viewer:1},ec={create_org:$s.owner,manage_team:$s.manager,view_analytics:$s.manager,edit_integrations:$s.admin,view_reports:$s.viewer,edit_settings:$s.admin};function tc(e,t){return e?($s[e]??0)>=t:!1}var nc=(0,S.createContext)(void 0);function rc({children:e}){let t=ci(),n=R({queryKey:[`auth-user`],queryFn:Qs.getCurrentUser,staleTime:300*1e3,retry:!1}),r=n.data??null,i=n.isLoading,a=(0,S.useCallback)(async(e,n)=>{await Qs.login(e,n),await t.invalidateQueries({queryKey:[`auth-user`]})},[t]),o=(0,S.useCallback)(async()=>{await Qs.logout(),t.setQueryData([`auth-user`],null)},[t]),s=(0,S.useCallback)(async e=>{await Qs.signup(e),await t.invalidateQueries({queryKey:[`auth-user`]})},[t]),c=(0,S.useCallback)(async e=>{await Qs.updateProfile(e),await t.invalidateQueries({queryKey:[`auth-user`]})},[t]),l=(0,S.useCallback)(async(e,t)=>await Qs.changePassword(e,t),[]),u=(0,S.useCallback)(e=>r?.role===e,[r]),d=(0,S.useCallback)((...e)=>!!r?.role&&e.includes(r.role),[r]),f=(0,S.useCallback)(()=>r?.companyRole,[r]),p=(0,S.useCallback)(()=>$s[r?.companyRole]??0,[r]),m=(0,S.useCallback)(e=>{let t=ec[e];return tc(r?.companyRole,t)},[r]),h=(0,S.useCallback)(e=>{let t=$s[e];return tc(r?.companyRole,t)},[r]),g=(0,S.useMemo)(()=>({user:r,isAuthenticated:!!r,isLoading:i,login:a,logout:o,signup:s,updateProfile:c,changePassword:l,isRole:u,hasRole:d,companyRole:f(),roleLevel:p(),hasCompanyPermission:m,hasRoleAtLeast:h}),[r,i,a,o,s,c,l,u,d,f,p,m,h]);return(0,L.jsx)(nc.Provider,{value:g,children:e})}function W(){let e=(0,S.useContext)(nc);if(e===void 0)throw Error(`useAuth must be used within an AuthProvider`);return e}var ic=class extends S.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught:`,e,t)}render(){return this.state.hasError?this.props.fallback||(0,L.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50`,children:(0,L.jsxs)(`div`,{className:`text-center p-8`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 mb-4`,children:`Something went wrong`}),(0,L.jsx)(`p`,{className:`text-gray-600 mb-4`,children:this.state.error?.message||`An unexpected error occurred`}),(0,L.jsx)(`button`,{onClick:()=>window.location.reload(),className:`px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700`,children:`Reload Page`})]})}):this.props.children}},ac=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),oc=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),sc=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),cc=e=>{let t=sc(e);return t.charAt(0).toUpperCase()+t.slice(1)},lc={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`},uc=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},dc=(0,S.createContext)({}),fc=()=>(0,S.useContext)(dc),pc=(0,S.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=fc()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,S.createElement)(`svg`,{ref:c,...lc,width:t??l??lc.width,height:t??l??lc.height,stroke:e??f,strokeWidth:m,className:ac(`lucide`,p,i),...!a&&!uc(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,S.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),G=(e,t)=>{let n=(0,S.forwardRef)(({className:n,...r},i)=>(0,S.createElement)(pc,{ref:i,iconNode:t,className:ac(`lucide-${oc(cc(e))}`,`lucide-${e}`,n),...r}));return n.displayName=cc(e),n},mc=G(`chart-column`,[[`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`}]]),hc=G(`chart-line`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`m19 9-5 5-4-4-3 3`,key:`2osh9i`}]]),gc=G(`chart-no-axes-column`,[[`path`,{d:`M5 21v-6`,key:`1hz6c0`}],[`path`,{d:`M12 21V3`,key:`1lcnhd`}],[`path`,{d:`M19 21V9`,key:`unv183`}]]),_c=G(`chart-pie`,[[`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`,key:`pzmjnu`}],[`path`,{d:`M21.21 15.89A10 10 0 1 1 8 2.83`,key:`k2fpak`}]]),vc=G(`circle-alert`,[[`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`}]]),yc=G(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),bc=G(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),xc=G(`circle-question-mark`,[[`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`}]]),Sc=G(`circle-x`,[[`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`}]]),Cc=G(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),wc=G(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),Tc=G(`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:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),K=G(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),Ec=G(`lock-open`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),Dc=G(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),Oc=G(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`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`}]]),kc=G(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),Ac=G(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),jc=G(`triangle-alert`,[[`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`}]]),Mc=G(`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`}]]),Nc=G(`arrow-down-right`,[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]),Pc=G(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Fc=G(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Ic=G(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),Lc=G(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Rc=G(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),zc=G(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Bc=G(`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`}]]),Vc=G(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Hc=G(`banknote`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M6 12h.01M18 12h.01`,key:`113zkx`}]]),Uc=G(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Wc=G(`book-open`,[[`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`}]]),Gc=G(`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`}]]),Kc=G(`building-2`,[[`path`,{d:`M10 12h4`,key:`a56b0p`}],[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M14 21v-3a2 2 0 0 0-4 0v3`,key:`1rgiei`}],[`path`,{d:`M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2`,key:`secmi2`}],[`path`,{d:`M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16`,key:`16ra0t`}]]),qc=G(`calculator`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,key:`1nb95v`}],[`line`,{x1:`8`,x2:`16`,y1:`6`,y2:`6`,key:`x4nwl0`}],[`line`,{x1:`16`,x2:`16`,y1:`14`,y2:`18`,key:`wjye3r`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}]]),Jc=G(`calendar-days`,[[`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`}]]),Yc=G(`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`}]]),Xc=G(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Zc=G(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Qc=G(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),$c=G(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),el=G(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),tl=G(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),nl=G(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),rl=G(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),il=G(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),al=G(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),ol=G(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`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`}]]),sl=G(`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`}]]),cl=G(`credit-card`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),ll=G(`crown`,[[`path`,{d:`M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z`,key:`1vdc57`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),ul=G(`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`}]]),dl=G(`dollar-sign`,[[`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`}]]),fl=G(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),pl=G(`external-link`,[[`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`}]]),ml=G(`eye-off`,[[`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`}]]),hl=G(`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`}]]),gl=G(`factory`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M16 16h.01`,key:`1f9h7w`}],[`path`,{d:`M3 19a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a.5.5 0 0 0-.769-.422l-4.462 2.844A.5.5 0 0 1 15 10.5v-2a.5.5 0 0 0-.769-.422L9.77 10.922A.5.5 0 0 1 9 10.5V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z`,key:`1iv0i2`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),_l=G(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),vl=G(`folder-open`,[[`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`}]]),yl=G(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),bl=G(`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`}]]),xl=G(`handshake`,[[`path`,{d:`m11 17 2 2a1 1 0 1 0 3-3`,key:`efffak`}],[`path`,{d:`m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4`,key:`9pr0kb`}],[`path`,{d:`m21 3 1 11h-2`,key:`1tisrp`}],[`path`,{d:`M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3`,key:`1uvwmv`}],[`path`,{d:`M3 4h8`,key:`1ep09j`}]]),Sl=G(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),Cl=G(`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`}]]),wl=G(`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`}]]),Tl=G(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),El=G(`key-round`,[[`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`}]]),Dl=G(`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`}]]),Ol=G(`landmark`,[[`path`,{d:`M10 18v-7`,key:`wt116b`}],[`path`,{d:`M11.119 2.205a2 2 0 0 1 1.762 0l7.84 3.846A.5.5 0 0 1 20.5 7h-17a.5.5 0 0 1-.22-.949z`,key:`yxxwt6`}],[`path`,{d:`M14 18v-7`,key:`vav6t3`}],[`path`,{d:`M18 18v-7`,key:`aexdmj`}],[`path`,{d:`M3 22h18`,key:`8prr45`}],[`path`,{d:`M6 18v-7`,key:`1ivflk`}]]),kl=G(`layout-dashboard`,[[`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`}]]),Al=G(`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`}]]),jl=G(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),Ml=G(`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`}]]),Nl=G(`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`}]]),Pl=G(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),Fl=G(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),Il=G(`map-pin`,[[`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`}]]),Ll=G(`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`}]]),Rl=G(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),zl=G(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),q=G(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Bl=G(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),Vl=G(`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`}]]),Hl=G(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),Ul=G(`mouse-pointer`,[[`path`,{d:`M12.586 12.586 19 19`,key:`ea5xo7`}],[`path`,{d:`M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z`,key:`277e5u`}]]),Wl=G(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`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:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Gl=G(`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`}]]),Kl=G(`percent`,[[`line`,{x1:`19`,x2:`5`,y1:`5`,y2:`19`,key:`1x9vlm`}],[`circle`,{cx:`6.5`,cy:`6.5`,r:`2.5`,key:`4mh3h7`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`2.5`,key:`1mdrzq`}]]),ql=G(`phone-call`,[[`path`,{d:`M13 2a9 9 0 0 1 9 9`,key:`1itnx2`}],[`path`,{d:`M13 6a5 5 0 0 1 5 5`,key:`11nki7`}],[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),Jl=G(`phone-incoming`,[[`path`,{d:`M16 2v6h6`,key:`1mfrl5`}],[`path`,{d:`m22 2-6 6`,key:`6f0sa0`}],[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),Yl=G(`phone-missed`,[[`path`,{d:`m16 2 6 6`,key:`1gw87d`}],[`path`,{d:`m22 2-6 6`,key:`6f0sa0`}],[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),Xl=G(`phone-outgoing`,[[`path`,{d:`m16 8 6-6`,key:`oawc05`}],[`path`,{d:`M22 8V2h-6`,key:`oqy2zc`}],[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),Zl=G(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),Ql=G(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),$l=G(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),eu=G(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),tu=G(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),nu=G(`refresh-cw`,[[`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`}]]),ru=G(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),iu=G(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`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-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),au=G(`rotate-ccw`,[[`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`}]]),ou=G(`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`}]]),J=G(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),su=G(`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`}]]),cu=G(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),lu=G(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),uu=G(`shield-alert`,[[`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:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),du=G(`shield-check`,[[`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`}]]),fu=G(`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`}]]),pu=G(`shopping-cart`,[[`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`}]]),mu=G(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),hu=G(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),gu=G(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),_u=G(`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`}]]),vu=G(`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`}]]),yu=G(`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`}]]),bu=G(`toggle-left`,[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]),xu=G(`toggle-right`,[[`circle`,{cx:`15`,cy:`12`,r:`3`,key:`1afu0r`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]),Su=G(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Cu=G(`trending-down`,[[`path`,{d:`M16 17h6v-6`,key:`t6n2it`}],[`path`,{d:`m22 17-8.5-8.5-5 5L2 7`,key:`x473p`}]]),wu=G(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),Tu=G(`trophy`,[[`path`,{d:`M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978`,key:`1n3hpd`}],[`path`,{d:`M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978`,key:`rfe1zi`}],[`path`,{d:`M18 9h1.5a1 1 0 0 0 0-5H18`,key:`7xy6bh`}],[`path`,{d:`M4 22h16`,key:`57wxv0`}],[`path`,{d:`M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z`,key:`1mhfuq`}],[`path`,{d:`M6 9H4.5a1 1 0 0 1 0-5H6`,key:`tex48p`}]]),Eu=G(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),Du=G(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),Ou=G(`user-check`,[[`path`,{d:`m16 11 2 2 4-4`,key:`9rsbq5`}],[`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`}]]),ku=G(`user-cog`,[[`path`,{d:`M10 15H6a4 4 0 0 0-4 4v2`,key:`1nfge6`}],[`path`,{d:`m14.305 16.53.923-.382`,key:`1itpsq`}],[`path`,{d:`m15.228 13.852-.923-.383`,key:`eplpkm`}],[`path`,{d:`m16.852 12.228-.383-.923`,key:`13v3q0`}],[`path`,{d:`m16.852 17.772-.383.924`,key:`1i8mnm`}],[`path`,{d:`m19.148 12.228.383-.923`,key:`1q8j1v`}],[`path`,{d:`m19.53 18.696-.382-.924`,key:`vk1qj3`}],[`path`,{d:`m20.772 13.852.924-.383`,key:`n880s0`}],[`path`,{d:`m20.772 16.148.924.383`,key:`1g6xey`}],[`circle`,{cx:`18`,cy:`15`,r:`3`,key:`gjjjvw`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Au=G(`user-minus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),ju=G(`user-plus`,[[`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`}]]),Mu=G(`user-x`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`17`,x2:`22`,y1:`8`,y2:`13`,key:`3nzzx3`}],[`line`,{x1:`22`,x2:`17`,y1:`8`,y2:`13`,key:`1swrse`}]]),Nu=G(`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`}]]),Pu=G(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Fu=G(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Iu=G(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Lu=G(`zap-off`,[[`path`,{d:`M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317`,key:`193nxd`}],[`path`,{d:`M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773`,key:`27a7lr`}],[`path`,{d:`M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643`,key:`1e0qe9`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ru=G(`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`}]]),zu={bg:`#0a0f1a`,green:`#00A846`,blue:`#00AECB`,lime:`#C6F24E`,cardBg:`rgba(255,255,255,0.04)`},Bu={single:{title:`Command Center for owner-operators`,steps:[{title:`Everything in one view`,desc:`Your CRM, ad spend, and books in a single dashboard. No tab-switching between HubSpot, Google Ads, and QuickBooks — see what matters this week at a glance.`,icon:mc,highlight:`Unified Dashboard`},{title:`Revenue that actually makes sense`,desc:`Forecasting built for small teams. See your likely, best, and conservative revenue bands over the next 6 months — no data science degree required.`,icon:wu,highlight:`Revenue Forecasting`},{title:`Know which ads are paying`,desc:`Track your Google and Facebook ad spend against actual conversions. See which campaigns bring real leads and which ones burn cash, updated in real time.`,icon:Ru,highlight:`Ad Performance Tracking`},{title:`Integrations that just work`,desc:`Connect HubSpot, QuickBooks, Google Ads, Facebook Ads, Slack, and more in minutes. No API knowledge needed — paste your credentials and you're live.`,icon:Pu,highlight:`10+ Integrations`}],cta:`Start your free trial`},multi:{title:`Command Center for multi-location operators`,steps:[{title:`Compare markets at a glance`,desc:`Side-by-side market comparison with close rate, CAC, margin, and pipeline value. Instantly spot which location is thriving and which needs coaching.`,icon:bl,highlight:`Multi-Market Analytics`},{title:`Smart coaching that finds problems first`,desc:`Automated health scores for every market and rep. Get severity alerts before a problem becomes a quarterly miss. Dismiss, track, and act — all from one dashboard.`,icon:yu,highlight:`Smart Coaching`},{title:`Scale with confidence`,desc:`ROAS, LTV:CAC, and budget recommendations across all locations. Know exactly where to shift spend for maximum revenue lift, not gut feeling.`,icon:wu,highlight:`Scale Optimization`},{title:`Root cause, not just symptoms`,desc:`Revenue waterfall and drill-down trees show you why a market is underperforming — bad close rate, high CAC, or low volume — so you fix the real problem.`,icon:Ru,highlight:`Strategic Intelligence`}],cta:`See it in action`},enterprise:{title:`Command Center for portfolios & enterprises`,steps:[{title:`Roll up every operating company`,desc:`Single KPI taxonomy across all portfolio companies. Compare performance, benchmark against peers, and identify value creation opportunities at scale.`,icon:mc,highlight:`Portfolio Roll-up`},{title:`Cascading goals that actually cascade`,desc:`Set org-level targets that automatically break down to department, team, and rep level. Watch progress roll up in real time — no manual spreadsheet tracking.`,icon:yu,highlight:`Cascading Goals`},{title:`White-label and SSO built in`,desc:`Custom branding, colors, logo, and domain per company. SSO/SAML for enterprise security. Give each brand its own portal while maintaining full oversight.`,icon:fu,highlight:`Enterprise Features`},{title:`Custom connectors for your stack`,desc:`Beyond our 10+ built-in integrations, the generic REST API connector lets you pull from any system your portfolio companies use. ServiceTitan, Salesforce, custom ERPs — all wired.`,icon:cu,highlight:`Custom Connectors`}],cta:`Book a demo`}};function Vu({audience:e,onClose:t}){let[n,r]=(0,S.useState)(0),i=Bu[e],a=(0,S.useCallback)(()=>{i&&n<i.steps.length-1&&r(e=>e+1)},[n,i]),o=(0,S.useCallback)(()=>{n>0&&r(e=>e-1)},[n]);if((0,S.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,S.useEffect)(()=>(document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=``}),[]),!i)return null;let s=i.steps[n],c=s.icon;return(0,L.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4`,role:`dialog`,"aria-modal":`true`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/80 backdrop-blur-sm`,onClick:t}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-2xl rounded-3xl border border-white/10 overflow-hidden`,style:{background:zu.bg},children:[(0,L.jsx)(`button`,{onClick:t,className:`absolute top-4 right-4 z-10 p-2 rounded-full text-white/50 hover:text-white hover:bg-white/10 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center`,"aria-label":`Close`,children:(0,L.jsx)(Iu,{size:20})}),(0,L.jsxs)(`div`,{className:`px-8 pt-8 pb-4`,children:[(0,L.jsxs)(`p`,{className:`text-xs font-semibold uppercase tracking-wider mb-2`,style:{color:zu.blue},children:[`Walkthrough · Step `,n+1,` of `,i.steps.length]}),(0,L.jsx)(`h2`,{className:`text-2xl md:text-3xl font-black text-white`,children:i.title})]}),(0,L.jsx)(`div`,{className:`px-8 mb-6`,children:(0,L.jsx)(`div`,{className:`h-1 rounded-full bg-white/10 overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full transition-all duration-300`,style:{background:`linear-gradient(90deg, ${zu.green}, ${zu.blue})`,width:`${(n+1)/i.steps.length*100}%`}})})}),(0,L.jsx)(`div`,{className:`px-8 pb-6`,children:(0,L.jsxs)(`div`,{className:`flex gap-5`,children:[(0,L.jsx)(`div`,{className:`flex-shrink-0 w-14 h-14 rounded-2xl flex items-center justify-center`,style:{background:`rgba(0,168,70,0.15)`},children:(0,L.jsx)(c,{size:24,style:{color:zu.green}})}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsx)(`div`,{className:`flex items-center gap-2 mb-1`,children:(0,L.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-full`,style:{background:`rgba(0,174,203,0.15)`,color:zu.blue},children:s.highlight})}),(0,L.jsx)(`h3`,{className:`text-lg font-bold text-white mb-2`,children:s.title}),(0,L.jsx)(`p`,{className:`text-sm text-white/60 leading-relaxed`,children:s.desc})]})]})}),(0,L.jsx)(`div`,{className:`px-8 pb-4 flex items-center justify-center gap-2`,children:i.steps.map((e,t)=>(0,L.jsx)(`button`,{onClick:()=>r(t),className:`w-2 h-2 rounded-full transition-all ${t===n?`bg-white`:`bg-white/20 hover:bg-white/40`}`,"aria-label":`Go to step ${t+1}`},t))}),(0,L.jsxs)(`div`,{className:`px-8 pb-8 flex items-center justify-between`,children:[(0,L.jsxs)(`button`,{onClick:o,disabled:n===0,className:`flex items-center gap-2 text-sm text-white/50 hover:text-white transition-colors disabled:opacity-30 disabled:cursor-not-allowed min-h-[44px] px-3 py-2 rounded-lg`,children:[(0,L.jsx)(Fc,{size:16}),`Back`]}),n<i.steps.length-1?(0,L.jsxs)(`button`,{onClick:a,className:`flex items-center gap-2 text-sm font-semibold min-h-[44px] px-5 py-2.5 rounded-xl transition-colors`,style:{background:zu.green,color:`white`},children:[`Next`,(0,L.jsx)(Lc,{size:16})]}):(0,L.jsxs)(`button`,{onClick:t,className:`flex items-center gap-2 text-sm font-semibold min-h-[44px] px-5 py-2.5 rounded-xl transition-colors`,style:{background:zu.blue,color:`white`},children:[i.cta,(0,L.jsx)(Lc,{size:16})]})]})]})]})}var Y={bg:`#0a0f1a`,bgAlt:`#050a14`,green:`#00A846`,blue:`#00AECB`,lime:`#C6F24E`,red:`#ff4d4d`,cardBg:`rgba(255,255,255,0.04)`,cardBorder:`rgba(255,255,255,0.1)`};function Hu(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(!0);(0,S.useEffect)(()=>{fetch(`/api/coaching/insights`).then(e=>e.json()).then(e=>{e?.insights?.[0]&&t(e.insights[0]),r(!1)}).catch(()=>r(!1))},[]);let i=e||{title:`Coach the Phoenix market on follow-up speed`,narrative:`Recover an estimated $84K this quarter`};return(0,L.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded-xl border p-3`,style:{borderColor:`${Y.lime}30`,background:`${Y.lime}0d`},children:[(0,L.jsx)(`span`,{style:{color:Y.lime},children:`✦`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider mb-0.5`,style:{color:Y.lime},children:`Next move`}),(0,L.jsx)(`div`,{className:`text-xs text-white/70 leading-snug`,children:n?(0,L.jsx)(`span`,{className:`animate-pulse`,children:`Loading insights…`}):(0,L.jsxs)(L.Fragment,{children:[i.title,`. `,i.narrative]})})]})]})}var Uu=e=>({...e});Y.cardBg,`${Y.cardBorder}`;var Wu=(e,t)=>({display:`inline-flex`,alignItems:`center`,gap:`0.5rem`,padding:`0.375rem 1rem`,borderRadius:`9999px`,fontSize:`0.75rem`,fontWeight:600,color:e,background:t,border:`1px solid ${e}`,marginBottom:`1.5rem`});function Gu(){let[e,t]=(0,S.useState)(!1),n=[{label:`Why`,href:`#why`},{label:`Mission`,href:`#manifesto`},{label:`Stories`,href:`#stories`},{label:`Pricing`,href:`#pricing`},{label:`Docs`,href:`#docs`}],r=e=>{t(!1);let n=document.querySelector(e);n&&n.scrollIntoView({behavior:`smooth`})};return(0,L.jsxs)(`header`,{className:`z-50 pt-3 px-4`,children:[(0,L.jsxs)(`nav`,{className:`max-w-6xl mx-auto rounded-full border border-white/10 backdrop-blur-xl pl-5 pr-2.5 h-14 flex items-center justify-between shadow-xl shadow-black/30`,style:{background:`rgba(10,16,28,0.7)`},children:[(0,L.jsxs)(Mn,{to:`/`,className:`flex items-center gap-2.5`,children:[(0,L.jsx)(`div`,{className:`w-7 h-7 rounded-lg flex items-center justify-center font-black text-[11px]`,style:{background:Y.green},children:`CC`}),(0,L.jsx)(`span`,{className:`font-bold tracking-tight`,children:`Command Center`})]}),(0,L.jsx)(`div`,{className:`hidden md:flex items-center gap-7 text-sm text-white/60`,children:n.map(e=>(0,L.jsx)(`button`,{onClick:()=>r(e.href),className:`hover:text-white transition-colors`,children:e.label},e.href))}),(0,L.jsxs)(`div`,{className:`hidden md:flex items-center gap-1 sm:gap-2`,children:[(0,L.jsx)(Mn,{to:`/auth/login`,className:`text-sm text-white/70 hover:text-white transition-colors px-3 py-2 min-h-[44px] flex items-center`,children:`Log in`}),(0,L.jsx)(Mn,{to:`/auth/signup`,className:`px-5 py-2.5 rounded-full text-sm font-semibold transition-all hover:opacity-90 min-h-[44px]`,style:{background:Y.green},children:`Start free trial`})]}),(0,L.jsx)(`button`,{className:`md:hidden p-2 text-white/60 hover:text-white min-w-[44px] min-h-[44px] flex items-center justify-center rounded-lg hover:bg-white/5`,onClick:()=>t(!e),children:e?(0,L.jsx)(Iu,{size:20}):(0,L.jsx)(Rl,{size:20})})]}),e&&(0,L.jsxs)(`div`,{className:`md:hidden mt-2 mx-4 rounded-2xl border border-white/10 backdrop-blur-xl p-4 space-y-3`,style:{background:`rgba(10,16,28,0.95)`},children:[n.map(e=>(0,L.jsx)(`button`,{onClick:()=>r(e.href),className:`block w-full text-left text-sm text-white/60 hover:text-white py-2.5 min-h-[44px]`,children:e.label},e.href)),(0,L.jsx)(`hr`,{className:`border-white/10`}),(0,L.jsx)(Mn,{to:`/auth/login`,className:`block text-sm text-white/70 hover:text-white py-2`,onClick:()=>t(!1),children:`Log in`}),(0,L.jsx)(Mn,{to:`/auth/signup`,className:`block text-center px-4 py-2.5 rounded-full text-sm font-semibold min-h-[44px]`,style:{background:Y.green},onClick:()=>t(!1),children:`Start free trial`})]})]})}function Ku(){return(0,L.jsxs)(`section`,{className:`relative overflow-hidden pt-16 pb-24 px-6 hero-section`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 opacity-25`,style:{background:`radial-gradient(ellipse at 15% 10%, #00AECB 0%, transparent 55%), radial-gradient(ellipse at 95% 85%, #00A846 0%, transparent 50%)`}}),(0,L.jsxs)(`div`,{className:`relative max-w-6xl mx-auto grid lg:grid-cols-2 gap-12 items-center`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{style:Wu(Y.lime,`${Y.lime}12`),children:[(0,L.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-current`,style:{animation:`pulse 2s infinite`}}),`Signal Over Noise · True North for the Trades`]}),(0,L.jsxs)(`h1`,{className:`text-3xl sm:text-4xl md:text-5xl lg:text-6xl font-black leading-[1.04] tracking-tight mb-6`,children:[`Stop hunting`,(0,L.jsx)(`br`,{}),`for the number.`,(0,L.jsx)(`br`,{}),(0,L.jsx)(`span`,{style:{color:Y.lime},children:`Command it.`})]}),(0,L.jsx)(`p`,{className:`text-lg text-white/70 max-w-xl mb-8 leading-relaxed`,children:`Command Center unifies every tool a home improvement company runs, forecasts the quarter, cascades goals to every rep, and tells your leaders exactly what to fix next. One clear path from chaos to sovereignty.`}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-8`,children:[(0,L.jsxs)(Mn,{to:`/auth/signup`,className:`group px-8 py-3.5 rounded-full text-base font-bold shadow-lg flex items-center gap-2 hover:opacity-90 transition-opacity min-h-[44px]`,style:{background:Y.green},children:[`Start 7-day free trial`,(0,L.jsx)(el,{size:16,className:`transition-transform group-hover:translate-x-0.5`})]}),(0,L.jsx)(`a`,{href:`#demo`,className:`px-8 py-3.5 rounded-full text-base font-semibold border border-white/15 hover:border-white/35 transition-colors min-h-[44px]`,children:`Book a demo`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3.5 text-sm text-white/50`,children:[(0,L.jsx)(`div`,{className:`flex -space-x-2`,children:[`MH`,`PN`,`DO`].map(e=>(0,L.jsx)(`div`,{className:`w-8 h-8 rounded-full flex items-center justify-center text-[10px] font-bold border-2 border-[#0a0f1a]`,style:{background:`linear-gradient(135deg, ${Y.blue}, ${Y.green})`,color:`#001018`},children:e},e))}),(0,L.jsxs)(`span`,{children:[`Trusted by operators running`,` `,(0,L.jsx)(`span`,{className:`text-white/80 font-semibold`,children:`9-figure`}),` portfolios`]})]})]}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`div`,{className:`absolute -inset-6 rounded-[2.5rem] opacity-25 blur-3xl`,style:{background:`radial-gradient(circle at 70% 25%, #C6F24E, transparent 70%)`}}),(0,L.jsxs)(`div`,{className:`relative rounded-3xl border border-white/10 p-5 sm:p-6 shadow-2xl shadow-black/50 backdrop-blur-xl`,style:{background:`linear-gradient(160deg, rgba(0,48,87,0.55), rgba(10,16,28,0.9))`},children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`span`,{className:`relative flex h-2 w-2`,children:[(0,L.jsx)(`span`,{className:`absolute inline-flex h-full w-full rounded-full opacity-75`,style:{background:Y.lime,animation:`ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite`}}),(0,L.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2`,style:{background:Y.lime}})]}),(0,L.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-widest text-white/70`,children:`Live forecast`})]}),(0,L.jsx)(`span`,{className:`text-[11px] font-semibold text-white/40`,children:`JUN 2026`})]}),(0,L.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wider text-white/40 mb-1`,children:`Projected landing`}),(0,L.jsxs)(`div`,{className:`flex items-end gap-3 mb-6`,children:[(0,L.jsx)(`div`,{className:`text-4xl font-black tracking-tight`,children:`$2.41M`}),(0,L.jsx)(`div`,{className:`mb-1.5 inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-bold`,style:{background:`${Y.lime}22`,color:Y.lime},children:`On pace · 103%`})]}),(0,L.jsx)(`div`,{className:`flex items-end gap-1.5 h-20 mb-6`,children:[42,55,48,63,70,66,82,78,91].map((e,t)=>(0,L.jsx)(`div`,{className:`flex-1 rounded-t-md`,style:{height:`${e}%`,background:t>=7?Y.lime:`${Y.blue}80`}},t))}),(0,L.jsx)(`div`,{className:`grid grid-cols-3 gap-2 mb-5`,children:[{label:`Close rate`,value:`34%`},{label:`CAC`,value:`$410`},{label:`Pipeline`,value:`$5.1M`}].map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-white/10 p-2.5`,style:{background:`rgba(255,255,255,0.03)`},children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-white/40`,children:e.label}),(0,L.jsx)(`div`,{className:`text-sm font-bold`,children:e.value})]},e.label))}),(0,L.jsx)(Hu,{})]})]})]}),(0,L.jsx)(`p`,{className:`relative text-center text-xs text-white/55 mt-16`,children:`No credit card required · Up and running in a day`})]})}function qu(){return(0,L.jsx)(`section`,{className:`py-8 border-y border-white/10`,style:{background:`rgba(255,255,255,0.03)`},children:(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6`,children:[(0,L.jsx)(`p`,{className:`text-center text-xs font-semibold uppercase tracking-widest text-white/60 mb-5`,children:`Connects with your existing tools`}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-4`,children:[[`ServiceTitan`,`JobNimbus`,`HubSpot`,`Google Ads`,`Facebook Ads`,`Angi`,`HomeAdvisor`,`QuickBooks`,`Slack`].map(e=>(0,L.jsx)(`span`,{className:`px-4 py-2 rounded-lg text-sm font-medium border border-white/10 text-white/60`,style:{background:`rgba(255,255,255,0.05)`},children:e},e)),(0,L.jsx)(`span`,{className:`px-4 py-2 text-sm text-white/60 font-medium`,children:`+ any REST API`})]})]})})}function Ju(){return(0,L.jsxs)(`section`,{id:`manifesto`,className:`relative overflow-hidden py-12 md:py-24 px-6`,style:Uu(),children:[(0,L.jsx)(`div`,{className:`absolute inset-0`,style:{background:`linear-gradient(160deg, #003057cc 0%, #0a0f1a 50%, #020810 100%)`}}),(0,L.jsx)(`div`,{className:`absolute inset-0 opacity-10`,style:{background:`radial-gradient(ellipse at 50% 0%, #00AECB 0%, transparent 70%)`}}),(0,L.jsxs)(`div`,{className:`relative max-w-3xl mx-auto`,children:[(0,L.jsx)(`div`,{style:Wu(Y.blue,`transparent`),children:`Our Mission`}),(0,L.jsxs)(`div`,{className:`space-y-6 text-lg md:text-xl leading-relaxed font-medium`,children:[(0,L.jsx)(`p`,{style:{color:`rgba(255,255,255,0.90)`},children:`We see you grinding before sunrise. Chasing close rates. Managing crews across three markets. Wondering if this month's number will land, all while fielding calls, running a P&L on a whiteboard, and fighting a dozen disconnected tools just to find the truth.`}),(0,L.jsx)(`p`,{style:{color:`rgba(255,255,255,0.75)`},children:`You didn't build this company to spend your days hunting for a number. You built it to build something. A legacy. A team. A livelihood for the people who show up for you every day.`}),(0,L.jsx)(`p`,{style:{color:`rgba(255,255,255,0.75)`},children:`The chaos in your stack isn't just annoying. It's the thing standing between you and your greatness. Every hour lost to reconciling spreadsheets is an hour not spent on strategy, on coaching, on growth.`}),(0,L.jsx)(`p`,{className:`text-base md:text-lg`,style:{color:`rgba(255,255,255,0.60)`},children:`Inspired by Bitcoin's Lightning ethos of proof of work and signal over noise, we built Command Center to give you the clarity to steer. Not another dashboard that shows you what happened. A command center that tells you what to do next.`}),(0,L.jsx)(`div`,{className:`pt-4 border-t border-white/10`,children:(0,L.jsx)(`p`,{className:`text-xl md:text-2xl font-black`,style:{color:Y.green},children:`You deserve sovereignty. Let's build it together.`})})]})]})]})}function Yu(){let e=[{icon:ol,title:`Strategic Intelligence`,desc:`An FP&A waterfall and drillable root-cause tree reconcile every dollar of variance down to the driver.`},{icon:wu,title:`Forecasting & Run-Rate`,desc:`Live run-rate vs. required pace, with a projected landing curve. Know if you'll hit the number weeks early.`},{icon:yu,title:`Cascading Goals`,desc:`Targets that auto-calculate from the org goal down to each frontline rep: org → department → team → rep.`},{icon:iu,title:`Scale Optimization`,desc:`ROAS and LTV:CAC ranked by product × channel × market, with recommended budget moves.`},{icon:Pu,title:`Smart Coaching`,desc:`A recommendation engine that surfaces coaching and scorecards from live performance and routes them.`},{icon:$l,title:`Connect Everything`,desc:`Pre-built connectors for ServiceTitan, HubSpot, Google Ads, QuickBooks, Angi, or push via REST.`}];return(0,L.jsx)(`section`,{className:`py-12 md:py-24 px-6`,style:Uu(),children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`text-center mb-16`,children:[(0,L.jsx)(`h2`,{className:`text-3xl md:text-4xl font-black mb-4`,children:`From dashboards to decisions`}),(0,L.jsx)(`p`,{className:`text-white/60 text-lg max-w-2xl mx-auto`,children:`Most tools show you what happened. Command Center forecasts what's next, sets the goals to get there, and routes the follow-ups.`})]}),(0,L.jsx)(`div`,{className:`grid md:grid-cols-2 lg:grid-cols-3 gap-6`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`p-6 rounded-2xl border border-white/10 hover:border-white/20 transition-colors`,style:{background:Y.cardBg},children:[(0,L.jsx)(`div`,{className:`mb-4`,style:{color:Y.blue},children:(0,L.jsx)(e.icon,{size:32,strokeWidth:1.5})}),(0,L.jsx)(`h3`,{className:`font-bold text-base mb-2`,children:e.title}),(0,L.jsx)(`p`,{className:`text-sm text-white/60 leading-relaxed`,children:e.desc})]},e.title))})]})})}function Xu({onSeeHow:e}){return(0,L.jsx)(`section`,{className:`py-12 md:py-24 px-6`,style:Uu({background:`rgba(255,255,255,0.02)`}),children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`text-center mb-12`,children:[(0,L.jsx)(`h2`,{className:`text-3xl md:text-4xl font-black mb-4`,children:`Built for how you operate`}),(0,L.jsx)(`p`,{className:`text-white/60 text-lg`,children:`From a single crew to a PE-backed platform.`})]}),(0,L.jsx)(`div`,{className:`grid md:grid-cols-3 gap-6`,children:[{type:`single`,label:`For owner-operators`,title:`Single-location contractor`,desc:`You're wearing every hat. Command Center pulls your CRM, ads and books together so you can see what's working this week, without a data team.`},{type:`multi`,label:`For regional operators`,title:`Multi-location / regional`,desc:`Stop normalizing spreadsheets across branches. Rank markets by close rate, CAC and margin, and see exactly which location to coach next.`},{type:`enterprise`,label:`For platforms & portfolios`,title:`Enterprise & PE-backed`,desc:`Roll up every operating company, enforce a single KPI taxonomy, and give each brand its own portal, with SSO, custom connectors and an SLA.`}].map(t=>(0,L.jsxs)(`div`,{className:`h-full p-6 rounded-2xl border border-white/10 hover:border-white/30 transition-colors cursor-pointer`,style:{background:Y.cardBg},onClick:()=>e(t.type),children:[(0,L.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider mb-2`,style:{color:Y.blue},children:t.label}),(0,L.jsx)(`h3`,{className:`font-bold text-lg mb-2`,children:t.title}),(0,L.jsx)(`p`,{className:`text-sm text-white/60 leading-relaxed mb-4`,children:t.desc}),(0,L.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-1`,style:{color:Y.green},children:[`See how `,(0,L.jsx)(Lc,{size:14})]})]},t.title))})]})})}function Zu(){return(0,L.jsx)(`section`,{className:`py-12 md:py-24 px-6`,children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`text-center mb-12`,children:[(0,L.jsx)(`h2`,{className:`text-3xl md:text-4xl font-black mb-4`,children:`Built for your trade`}),(0,L.jsx)(`p`,{className:`text-white/60 text-lg`,children:`Industry-specific KPIs, benchmarks and playbooks out of the box.`})]}),(0,L.jsx)(`div`,{className:`grid md:grid-cols-3 gap-6`,children:[{slug:`home-services`,label:`Home Service`,title:`HVAC, plumbing & electrical`,desc:`Booked-call rate, average ticket and tech utilization tied to one live landing forecast.`},{slug:`roofing`,label:`Roofing`,title:`Residential & storm restoration`,desc:`Margin per square, backlog burn-down and storm-cycle re-forecasting within 48 hours.`},{slug:`remodeling`,label:`Remodeling`,title:`Kitchen, bath & design-build`,desc:`Catch project slippage in week 2 and capture every billable change order.`}].map(e=>(0,L.jsxs)(Mn,{to:`/industries/${e.slug}`,className:`block h-full p-6 rounded-2xl border border-white/10 hover:border-white/30 transition-colors`,style:{background:Y.cardBg},children:[(0,L.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider mb-2`,style:{color:Y.blue},children:e.label}),(0,L.jsx)(`h3`,{className:`font-bold text-lg mb-2`,children:e.title}),(0,L.jsx)(`p`,{className:`text-sm text-white/60 leading-relaxed mb-4`,children:e.desc}),(0,L.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-1`,style:{color:Y.green},children:[`See how `,(0,L.jsx)(Lc,{size:14})]})]},e.slug))})]})})}function Qu(){let e=[{icon:ll,title:`Sovereignty`,desc:`Know what to do, how to do it, and how to grow. A frictionless path across your whole organization so you own every strategic decision, not your tool stack.`},{icon:Wc,title:`Faith & Stewardship`,desc:`Conviction in the journey, proof of work over noise. We steward your data, your team, and your trust, steering every decision toward true north.`},{icon:Al,title:`Truth & Clarity`,desc:`Signal over noise. We cut through the chaos and give you data you can actually see and act on, so you never confuse a tool problem for a people problem again.`},{icon:Ol,title:`Legacy`,desc:`You're not just building a quarter. You're building a team, a livelihood, a standard for the trades. We build for the long arc: the legacy you're working to leave.`}];return(0,L.jsxs)(`section`,{id:`why`,className:`relative overflow-hidden py-12 md:py-24 px-6`,style:Uu(),children:[(0,L.jsx)(`div`,{className:`absolute inset-0 opacity-[0.12]`,style:{background:`radial-gradient(ellipse at 80% 0%, #00AECB 0%, transparent 55%), radial-gradient(ellipse at 10% 100%, #00A846 0%, transparent 55%)`}}),(0,L.jsxs)(`div`,{className:`relative max-w-5xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`text-center max-w-3xl mx-auto mb-16`,children:[(0,L.jsx)(`div`,{style:Wu(Y.blue,`transparent`),children:`Our Why`}),(0,L.jsxs)(`h2`,{className:`text-3xl md:text-5xl font-black leading-tight mb-6 mt-6`,children:[`Built for your `,(0,L.jsx)(`span`,{style:{color:Y.green},children:`sovereignty`}),`.`]}),(0,L.jsx)(`p`,{className:`text-lg text-white/70 leading-relaxed`,children:`Every company, whether a single crew or a national platform, is on its own hero's journey, fighting toward something bigger. Sovereignty means knowing what to do, how to do it, and how to grow: a seamless, frictionless path across your whole organization. Not your tool stack making the calls. You.`})]}),(0,L.jsx)(`div`,{className:`grid sm:grid-cols-2 lg:grid-cols-4 gap-5 mb-16`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`p-7 rounded-2xl border border-white/10 hover:border-white/25 transition-colors`,style:{background:Y.cardBg},children:[(0,L.jsx)(`div`,{className:`text-3xl mb-4`,style:{color:Y.blue},children:(0,L.jsx)(e.icon,{size:28,strokeWidth:1.5})}),(0,L.jsx)(`h3`,{className:`font-bold text-base mb-2`,style:{color:Y.blue},children:e.title}),(0,L.jsx)(`p`,{className:`text-sm text-white/60 leading-relaxed`,children:e.desc})]},e.title))}),(0,L.jsxs)(`div`,{className:`rounded-2xl border border-white/10 overflow-hidden`,style:{background:`rgba(255,255,255,0.03)`},children:[(0,L.jsxs)(`div`,{className:`px-8 py-7 border-b border-white/10`,children:[(0,L.jsx)(`h3`,{className:`text-xl md:text-2xl font-black mb-2`,children:`Sovereignty isn't just for the CEO.`}),(0,L.jsx)(`p`,{className:`text-white/60 text-sm leading-relaxed max-w-2xl`,children:`When one company runs with clarity and conviction, the effects ripple outward, through teams, partners, customers, communities, and the entire industry. This is the legacy we're building together.`})]}),(0,L.jsx)(`div`,{className:`divide-y divide-white/5`,children:[{label:`Owners & operators`,desc:`Full strategic clarity. Know the number, own the decision, build the legacy you set out to build.`},{label:`Your team`,desc:`Everyone knows what 'good' looks like. Goals cascade to every rep. No one's guessing. Accountability becomes a gift, not a threat.`},{label:`Partners & trade allies`,desc:`Clear performance data builds trust. Referrals and co-marketing decisions are made on signal, not gut.`},{label:`Your customers`,desc:`A well-run shop delivers better installations, faster follow-up, and a homeowner experience worth a five-star review.`},{label:`Your community`,desc:`Every thriving contractor means local jobs, stronger livelihoods, and real economic growth in the neighborhoods you serve.`},{label:`The industry`,desc:`When great operators run tight, it raises the bar for the entire trades. Sovereignty at scale changes what the industry looks like.`}].map(e=>(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start gap-2 sm:gap-6 px-8 py-5`,children:[(0,L.jsx)(`div`,{className:`shrink-0 sm:w-44 text-xs font-bold uppercase tracking-wider pt-0.5`,style:{color:Y.green},children:e.label}),(0,L.jsx)(`p`,{className:`text-sm text-white/65 leading-relaxed`,children:e.desc})]},e.label))})]}),(0,L.jsx)(`p`,{className:`text-center text-sm font-semibold uppercase tracking-widest text-white/55 mt-12`,children:`Sovereignty · Faith & Stewardship · Truth & Clarity · Legacy · steering the path to true north`})]})]})}function $u(){let e=[{icon:mc,text:`Numbers live in five tabs and a whiteboard`},{icon:Ru,text:`You find out you missed the month after it's over`},{icon:ol,text:`Can't tell a market problem from a rep problem`},{icon:wu,text:`Monthly review takes two days of prep`},{icon:$l,text:`Every acquisition has different systems`},{icon:yu,text:`Goals don't cascade past the GM`}],t=[{icon:ol,text:`One source of truth across every tool and market`},{icon:wu,text:`Live run-rate flags a gap six weeks before month-end`},{icon:yu,text:`Root-cause tree tells your GMs exactly what to fix`},{icon:Ru,text:`Monthly review collapses from two days to two hours`},{icon:$l,text:`Every acquisition connects to one standard scorecard`},{icon:Bc,text:`Cascading goals reach every rep, auto-calculated`}],n=({icon:e,text:t,color:n})=>(0,L.jsxs)(`li`,{className:`flex items-start gap-3 px-6 py-4`,children:[(0,L.jsx)(`span`,{className:`text-lg shrink-0 mt-0.5`,style:{color:n},children:(0,L.jsx)(e,{size:20,strokeWidth:2})}),(0,L.jsx)(`span`,{className:`text-sm leading-relaxed`,style:{color:`rgba(255,255,255,0.70)`},children:t})]});return(0,L.jsx)(`section`,{className:`py-12 md:py-24 px-6`,style:Uu({background:`rgba(255,255,255,0.02)`}),children:(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`text-center mb-14`,children:[(0,L.jsx)(`div`,{style:Wu(Y.green,`transparent`),children:`The Journey`}),(0,L.jsx)(`h2`,{className:`text-3xl md:text-4xl font-black mb-4 mt-6`,children:`From noise to sovereignty.`}),(0,L.jsx)(`p`,{className:`text-white/60 text-lg max-w-2xl mx-auto`,children:`Every operator we work with starts in the same place. Here's the transformation.`})]}),(0,L.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-6 items-start`,children:[(0,L.jsxs)(`div`,{className:`rounded-2xl border overflow-hidden`,style:{borderColor:`rgba(255,77,77,0.25)`,background:`rgba(255,77,77,0.04)`},children:[(0,L.jsxs)(`div`,{className:`px-6 py-4 flex items-center gap-3 border-b`,style:{borderColor:`rgba(255,77,77,0.15)`,background:`rgba(255,77,77,0.08)`},children:[(0,L.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full`,style:{background:Y.red}}),(0,L.jsx)(`span`,{className:`font-black text-sm uppercase tracking-wider`,style:{color:Y.red},children:`The noise`})]}),(0,L.jsx)(`ul`,{className:`divide-y divide-[rgba(255,77,77,0.08)]`,children:e.map((e,t)=>(0,L.jsx)(n,{icon:e.icon,text:e.text,color:Y.red},t))})]}),(0,L.jsxs)(`div`,{className:`rounded-2xl border overflow-hidden`,style:{borderColor:`${Y.green}40`,background:`${Y.green}08`},children:[(0,L.jsxs)(`div`,{className:`px-6 py-4 flex items-center gap-3 border-b`,style:{borderColor:`${Y.green}25`,background:`${Y.green}12`},children:[(0,L.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full`,style:{background:Y.green}}),(0,L.jsx)(`span`,{className:`font-black text-sm uppercase tracking-wider`,style:{color:Y.green},children:`Sovereignty`}),(0,L.jsx)(`span`,{className:`ml-auto text-xs font-semibold px-2 py-0.5 rounded-full`,style:{background:`${Y.green}20`,color:Y.green},children:`Your destination`})]}),(0,L.jsx)(`ul`,{className:`divide-y divide-[#00A84610]`,children:t.map((e,t)=>(0,L.jsx)(n,{icon:e.icon,text:e.text,color:Y.green},t))})]})]}),(0,L.jsxs)(`div`,{className:`hidden md:flex items-center justify-center mt-8 gap-4`,children:[(0,L.jsx)(`div`,{className:`h-px flex-1`,style:{background:`linear-gradient(to right, rgba(255,77,77,0.3), ${Y.green}60)`}}),(0,L.jsx)(`div`,{className:`px-5 py-2.5 rounded-full text-xs font-bold border shrink-0`,style:{borderColor:`${Y.green}40`,color:Y.green,background:`${Y.green}10`},children:`Command Center is the bridge →`}),(0,L.jsx)(`div`,{className:`h-px flex-1`,style:{background:`linear-gradient(to right, ${Y.green}60, rgba(0,168,70,0.1))`}})]}),(0,L.jsx)(`div`,{className:`mt-10 text-center`,children:(0,L.jsx)(Mn,{to:`/auth/signup`,className:`px-8 py-3.5 rounded-xl text-base font-bold shadow-lg hover:opacity-90 transition-opacity inline-block`,style:{background:Y.green},children:`Start your 7-day free trial`})})]})})}function ed(){return(0,L.jsx)(`section`,{id:`stories`,className:`py-12 md:py-24 px-6`,style:{background:`rgba(255,255,255,0.02)`},children:(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`text-center mb-14`,children:[(0,L.jsx)(`p`,{className:`text-center text-xs font-semibold uppercase tracking-widest text-white/40 mb-8`,children:`Trusted by operators across the country`}),(0,L.jsx)(`h2`,{className:`text-3xl md:text-4xl font-black mb-4`,children:`Customer Stories`}),(0,L.jsx)(`p`,{className:`text-white/60 text-lg max-w-2xl mx-auto`,children:`Real numbers from operators who made the switch.`})]}),(0,L.jsx)(`div`,{className:`grid md:grid-cols-3 gap-6`,children:[{badge:`$480K gap closed`,quote:`Command Center forecasts our landing number in real time. We caught a $480K revenue gap six weeks early and closed it.`,name:`Marcus Hale`,role:`VP of Operations, Summit Exteriors`,initials:`MH`},{badge:`+23% booked-job rate`,quote:`The cascading goals changed how our crews think. Every rep sees their own target tied to the company number. Booked-job rate is up 23% since rollout and nobody's guessing what 'good' looks like anymore.`,name:`Priya Nair`,role:`Director of Sales, Evergreen Home Services`,initials:`PN`},{badge:`2 days → 2 hours`,quote:`As a PE-backed platform across nine markets, we needed one source of truth. The root-cause tree tells our GMs exactly which driver to fix. We cut our monthly review from two days to two hours.`,name:`David Okonkwo`,role:`CFO, Atlas Home Brands`,initials:`DO`}].map(e=>(0,L.jsxs)(`figure`,{className:`flex flex-col h-full p-7 rounded-2xl border border-white/10 hover:border-white/25 transition-colors`,style:{background:Y.cardBg},children:[(0,L.jsx)(`div`,{className:`inline-flex self-start items-center px-3 py-1 rounded-full text-xs font-bold mb-5`,style:{background:`${Y.green}1f`,color:Y.green},children:e.badge}),(0,L.jsxs)(`blockquote`,{className:`text-sm text-white/75 leading-relaxed flex-1 mb-6`,children:[`“`,e.quote,`”`]}),(0,L.jsx)(`figcaption`,{className:`pt-5 border-t border-white/10`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center text-xs font-bold shrink-0`,style:{background:`linear-gradient(135deg, ${Y.blue}, ${Y.green})`,color:`#001018`},children:e.initials}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-sm font-semibold`,children:e.name}),(0,L.jsx)(`div`,{className:`text-xs text-white/50`,children:e.role})]})]})})]},e.name))})]})})}function td(){let e=[{id:`launch`,name:`Launch`,price:`$299`,period:`/mo`,desc:`Get your command center stood up and connected.`,summary:`1 market · 5 seats`,summary2:`3 integrations · 5 GB`,features:[`1 market`,`Up to 5 seats`,`3 integrations`,`Strategic Intelligence dashboards`,`5 GB data storage`,`Email support`],cta:`Start 7-day trial`,ctaBg:`rgba(255,255,255,0.1)`,ctaColor:`#fff`,nameColor:Y.blue,popular:!1},{id:`growth`,name:`Growth`,price:`$899`,period:`/mo`,desc:`Forecast the quarter and cascade the number to every rep.`,summary:`5 markets · 25 seats`,summary2:`10 integrations · 50 GB`,features:[`Up to 5 markets`,`Up to 25 seats`,`10 integrations`,`Forecasting & cascading goals`,`Field Companion mobile app`,`50 GB data storage`],cta:`Start 7-day trial`,ctaBg:Y.green,ctaColor:`#000`,nameColor:Y.green,popular:!0},{id:`command`,name:`Command`,price:`$2,499`,period:`/mo`,desc:`Let the platform tell each leader exactly what to fix next.`,summary:`25 markets · 100 seats`,summary2:`50 integrations · 250 GB`,features:[`Up to 25 markets`,`Up to 100 seats`,`50 integrations`,`AI Intervention engine`,`Custom connectors`,`250 GB data storage`],cta:`Start 7-day trial`,ctaBg:`rgba(255,255,255,0.1)`,ctaColor:`#fff`,nameColor:Y.blue,popular:!1},{id:`enterprise`,name:`Enterprise`,price:`Custom`,period:``,desc:`Unlimited scale, white-label, SSO and an SLA.`,summary:`Unlimited markets · Unlimited seats`,summary2:`Unlimited integrations · Unlimited GB`,features:[`Unlimited markets, seats & integrations`,`White-label branding`,`SSO / SAML`,`Unlimited data storage`,`Custom connectors`,`Dedicated CSM & SLA`],cta:`Contact sales`,ctaBg:`rgba(255,255,255,0.1)`,ctaColor:`#fff`,nameColor:Y.blue,popular:!1}];return(0,L.jsx)(`section`,{id:`pricing`,className:`py-12 md:py-24 px-6`,style:Uu({background:`rgba(255,255,255,0.02)`}),children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`text-center mb-16`,children:[(0,L.jsx)(`h2`,{className:`text-3xl md:text-4xl font-black mb-4`,children:`Pricing that scales with you`}),(0,L.jsx)(`p`,{className:`text-white/60 text-lg`,children:`Start with a 7-day free trial on Launch. Upgrade as you add markets, seats and integrations.`})]}),(0,L.jsx)(`div`,{className:`grid md:grid-cols-2 lg:grid-cols-4 gap-5`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`relative p-6 rounded-2xl border flex flex-col`,style:{borderColor:e.popular?Y.green:Y.cardBorder,background:e.popular?`${Y.green}12`:Y.cardBg},children:[e.popular&&(0,L.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 px-3 py-1 rounded-full text-xs font-bold`,style:{background:Y.green,color:`#000`},children:`Most Popular`}),(0,L.jsx)(`h3`,{className:`font-black text-lg mb-1`,style:{color:e.nameColor},children:e.name}),(0,L.jsxs)(`div`,{className:`mb-1`,children:[(0,L.jsx)(`span`,{className:`text-2xl font-bold`,children:e.price}),e.period&&(0,L.jsx)(`span`,{className:`text-sm text-white/40`,children:e.period})]}),(0,L.jsx)(`p`,{className:`text-xs text-white/50 mb-4 min-h-[2.5rem]`,children:e.desc}),(0,L.jsxs)(`div`,{className:`text-[11px] text-white/40 mb-4 space-y-0.5`,children:[(0,L.jsx)(`div`,{children:e.summary}),(0,L.jsx)(`div`,{children:e.summary2})]}),(0,L.jsx)(`ul`,{className:`space-y-2 flex-1 mb-6`,children:e.features.map(e=>(0,L.jsxs)(`li`,{className:`flex items-start gap-2 text-xs`,children:[(0,L.jsx)(`span`,{style:{color:Y.green},children:`✓`}),(0,L.jsx)(`span`,{className:`text-white/70`,children:e})]},e))}),(0,L.jsx)(Mn,{to:`/auth/signup${e.id===`enterprise`?``:`?plan=${e.id}`}`,className:`w-full py-2.5 rounded-lg text-sm font-semibold text-center transition-all hover:opacity-90 block min-h-[44px]`,style:{background:e.ctaBg,color:e.ctaColor},children:e.cta})]},e.name))})]})})}function nd(){let[e,t]=(0,S.useState)(!1),[n,r]=(0,S.useState)(!1),[i,a]=(0,S.useState)(``),[o,s]=(0,S.useState)({name:``,email:``,company:``,phone:``,message:``}),c=async e=>{e.preventDefault(),a(``),t(!0);try{let e=await fetch(`/api/leads/demo-request`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Submission failed`)}r(!0)}catch(e){a(e.message||`Something went wrong`)}finally{t(!1)}},l=e=>t=>s(n=>({...n,[e]:t.target.value}));return(0,L.jsx)(`section`,{id:`demo`,className:`py-12 md:py-24 px-6`,children:(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto grid md:grid-cols-2 gap-10 items-stretch`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col justify-center`,children:[(0,L.jsxs)(`div`,{style:Wu(Y.lime,`${Y.lime}12`),children:[(0,L.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-current`,style:{animation:`pulse 2s infinite`}}),`Booking walkthroughs now`]}),(0,L.jsx)(`h2`,{className:`text-3xl md:text-4xl font-black mb-4`,children:`See it on your data`}),(0,L.jsx)(`p`,{className:`text-white/70 text-lg leading-relaxed mb-6`,children:`Book a 30-minute walkthrough. We'll connect your tools and show you the forecast, the gap, and the plan to close it, live on your numbers.`}),(0,L.jsx)(`ul`,{className:`space-y-2.5 text-sm text-white/65 mb-7`,children:[`Personalized to your markets`,`No prep required`,`Bring your toughest question`].map(e=>(0,L.jsxs)(`li`,{className:`flex items-center gap-2.5`,children:[(0,L.jsx)(`span`,{className:`flex items-center justify-center w-5 h-5 rounded-full text-[10px] font-black shrink-0`,style:{background:`${Y.lime}22`,color:Y.lime},children:`✓`}),e]},e))}),(0,L.jsxs)(`figure`,{className:`rounded-2xl border border-white/10 p-5`,style:{background:`rgba(255,255,255,0.03)`},children:[(0,L.jsx)(`blockquote`,{className:`text-sm text-white/75 leading-relaxed mb-3`,children:`“We caught a $480K revenue gap six weeks early and closed it. The walkthrough paid for the year in one call.”`}),(0,L.jsxs)(`figcaption`,{className:`flex items-center gap-2.5`,children:[(0,L.jsx)(`div`,{className:`w-8 h-8 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0`,style:{background:`linear-gradient(135deg, ${Y.blue}, ${Y.green})`,color:`#001018`},children:`MH`}),(0,L.jsx)(`div`,{className:`text-xs text-white/55`,children:`Marcus Hale, VP Operations, Summit Exteriors`})]})]})]}),(0,L.jsx)(`div`,{className:`rounded-2xl border border-white/10 p-6 md:p-7`,style:{background:`rgba(255,255,255,0.04)`},children:n?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-center`,children:[(0,L.jsx)(`div`,{className:`w-16 h-16 rounded-full flex items-center justify-center mb-4`,style:{background:`${Y.green}22`},children:(0,L.jsx)(Xc,{size:32,style:{color:Y.green}})}),(0,L.jsx)(`h3`,{className:`font-black text-xl mb-2`,children:`Request submitted!`}),(0,L.jsx)(`p`,{className:`text-sm text-white/60`,children:`A specialist will reach out within one business day.`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`h3`,{className:`font-black text-lg mb-1`,children:`Request your walkthrough`}),(0,L.jsx)(`p`,{className:`text-sm text-white/50 mb-5`,children:`A specialist reaches out within one business day.`}),i&&(0,L.jsx)(`div`,{className:`mb-3 p-3 rounded-lg text-sm text-red-400 bg-red-500/10 border border-red-500/20`,children:i}),(0,L.jsxs)(`form`,{className:`flex flex-col gap-3 text-left`,onSubmit:c,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,L.jsx)(`input`,{required:!0,className:`w-full rounded-lg border border-white/10 bg-white/5 px-3 py-3 text-sm text-white outline-none focus:border-white/30 placeholder:text-white/25`,placeholder:`Full name`,value:o.name,onChange:l(`name`)}),(0,L.jsx)(`input`,{type:`email`,required:!0,className:`w-full rounded-lg border border-white/10 bg-white/5 px-3 py-3 text-sm text-white outline-none focus:border-white/30 placeholder:text-white/25`,placeholder:`Work email`,value:o.email,onChange:l(`email`)}),(0,L.jsx)(`input`,{className:`w-full rounded-lg border border-white/10 bg-white/5 px-3 py-3 text-sm text-white outline-none focus:border-white/30 placeholder:text-white/25`,placeholder:`Company`,value:o.company,onChange:l(`company`)}),(0,L.jsx)(`input`,{className:`w-full rounded-lg border border-white/10 bg-white/5 px-3 py-3 text-sm text-white outline-none focus:border-white/30 placeholder:text-white/25`,placeholder:`Phone (optional)`,value:o.phone,onChange:l(`phone`)})]}),(0,L.jsx)(`textarea`,{className:`w-full rounded-lg border border-white/10 bg-white/5 px-3 py-3 text-sm text-white outline-none focus:border-white/30 placeholder:text-white/25 resize-none`,rows:3,placeholder:`What would you like to see? (optional)`,value:o.message,onChange:l(`message`)}),(0,L.jsx)(`button`,{type:`submit`,disabled:e,className:`w-full py-3 rounded-xl font-bold text-sm transition-all hover:opacity-90 disabled:opacity-50`,style:{background:Y.green},children:e?`Sending…`:`Request a demo`})]})]})})]})})}function rd(){return(0,L.jsx)(`section`,{className:`py-12 md:py-24 px-6`,style:Uu({background:`rgba(255,255,255,0.02)`}),children:(0,L.jsxs)(`div`,{className:`max-w-3xl mx-auto text-center p-8 md:p-12 rounded-3xl border border-white/10`,style:{background:`linear-gradient(135deg, #00305780, #00AECB20)`},children:[(0,L.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest mb-4`,style:{color:Y.blue},children:`Signal Over Noise · True North for the Trades`}),(0,L.jsx)(`h2`,{className:`text-3xl md:text-4xl font-black mb-4`,children:`Ready to command your number?`}),(0,L.jsx)(`p`,{className:`text-white/70 text-lg mb-8`,children:`Start free today. No card, no implementation project. Sovereignty starts here.`}),(0,L.jsx)(Mn,{to:`/auth/signup`,className:`px-10 py-4 rounded-xl text-base font-bold hover:opacity-90 transition-opacity inline-block`,style:{background:Y.green},children:`Start 7-day free trial`})]})})}function id(){return(0,L.jsx)(`footer`,{className:`border-t border-white/10 py-8 px-6`,children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto flex flex-wrap items-center justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`w-6 h-6 rounded-md flex items-center justify-center font-black text-[10px]`,style:{background:Y.green},children:`CC`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-sm font-semibold`,children:`Command Center`}),(0,L.jsx)(`span`,{className:`hidden sm:inline text-xs text-white/55 ml-2`,children:`· Signal Over Noise · True North for the Trades`})]})]}),(0,L.jsxs)(`div`,{className:`flex gap-6 text-sm text-white/60`,children:[(0,L.jsx)(`a`,{href:`#pricing`,className:`hover:text-white/70 transition-colors py-2 inline-block`,children:`Pricing`}),(0,L.jsx)(`a`,{href:`#why`,className:`hover:text-white/70 transition-colors py-2 inline-block`,children:`Docs`}),(0,L.jsx)(Mn,{to:`/auth/signup`,className:`hover:text-white/70 transition-colors py-2 inline-block`,children:`Start free`}),(0,L.jsx)(Mn,{to:`/auth/login`,className:`hover:text-white/70 transition-colors py-2 inline-block`,children:`Log in`})]}),(0,L.jsx)(`p`,{className:`text-xs text-white/55`,children:`© 2026 Command Center. All rights reserved.`})]})})}function ad(){let[e,t]=(0,S.useState)(null);return(0,L.jsxs)(`div`,{className:`min-h-screen text-white`,style:{background:Y.bg},children:[(0,L.jsx)(`style`,{children:`
html { scroll-behavior: smooth; }
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
`}),(0,L.jsx)(Gu,{}),(0,L.jsx)(Ku,{}),(0,L.jsx)(qu,{}),(0,L.jsx)(Ju,{}),(0,L.jsx)(Yu,{}),(0,L.jsx)(Xu,{onSeeHow:t}),(0,L.jsx)(Zu,{}),(0,L.jsx)(Qu,{}),(0,L.jsx)($u,{}),(0,L.jsx)(ed,{}),(0,L.jsx)(td,{}),(0,L.jsx)(nd,{}),(0,L.jsx)(rd,{}),(0,L.jsx)(id,{}),e&&(0,L.jsx)(Vu,{audience:e,onClose:()=>t(null)})]})}var od=(0,S.createContext)(null),sd=()=>(0,S.useContext)(od);function cd(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=cd(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function ld(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=cd(e))&&(r&&(r+=` `),r+=t);return r}var ud=`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.onDragCapture.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`.split(`.`);function dd(e){return typeof e==`string`?ud.includes(e):!1}var fd=new Set(`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.colorRendering.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`.split(`.`));function pd(e){return typeof e==`string`?fd.has(e):!1}function md(e){return typeof e==`string`&&e.startsWith(`data-`)}function hd(e){if(typeof e!=`object`||!e)return{};var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(pd(n)||md(n))&&(t[n]=e[n]);return t}function gd(e){if(e==null)return null;if((0,S.isValidElement)(e)&&typeof e.props==`object`&&e.props!==null){var t=e.props;return hd(t)}return typeof e==`object`&&!Array.isArray(e)?hd(e):null}function _d(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(pd(n)||md(n)||dd(n))&&(t[n]=e[n]);return t}function vd(e){return e==null?null:(0,S.isValidElement)(e)?_d(e.props):typeof e==`object`&&!Array.isArray(e)?_d(e):null}var yd=[`children`,`width`,`height`,`viewBox`,`className`,`style`,`title`,`desc`];function bd(){return bd=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bd.apply(null,arguments)}function xd(e,t){if(e==null)return{};var n,r,i=Sd(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Sd(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Cd=(0,S.forwardRef)((e,t)=>{var n=e.children,r=e.width,i=e.height,a=e.viewBox,o=e.className,s=e.style,c=e.title,l=e.desc,u=xd(e,yd),d=a||{width:r,height:i,x:0,y:0},f=ld(`recharts-surface`,o);return S.createElement(`svg`,bd({},_d(u),{className:f,width:r,height:i,style:s,viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,ref:t}),S.createElement(`title`,null,c),S.createElement(`desc`,null,l),n)});function wd(e){return function(){return e}}var Td=Math.cos,Ed=Math.sin,Dd=Math.sqrt,Od=Math.PI;Od/2;var kd=2*Od,Ad=Math.PI,jd=2*Ad,Md=1e-6,Nd=jd-Md;function Pd(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function Fd(e){let t=Math.floor(e);if(!(t>=0))throw Error(`invalid digits: ${e}`);if(t>15)return Pd;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;t<r;++t)this._+=Math.round(arguments[t]*n)/n+e[t]}}var Id=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?Pd:Fd(e)}moveTo(e,t){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,t){this._append`L${this._x1=+e},${this._y1=+t}`}quadraticCurveTo(e,t,n,r){this._append`Q${+e},${+t},${this._x1=+n},${this._y1=+r}`}bezierCurveTo(e,t,n,r,i,a){this._append`C${+e},${+t},${+n},${+r},${this._x1=+i},${this._y1=+a}`}arcTo(e,t,n,r,i){if(e=+e,t=+t,n=+n,r=+r,i=+i,i<0)throw Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(this._x1===null)this._append`M${this._x1=e},${this._y1=t}`;else if(d>Md)if(!(Math.abs(u*s-c*l)>Md)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((Ad-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>Md&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>Md||Math.abs(this._y1-l)>Md)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%jd+jd),d>Nd?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>Md&&this._append`A${n},${n},0,${+(d>=Ad)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};function Ld(){return new Id}Ld.prototype=Id.prototype;function Rd(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new Id(t)}Array.prototype.slice;function zd(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Bd(e){this._context=e}Bd.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function Vd(e){return new Bd(e)}function Hd(e){return e[0]}function Ud(e){return e[1]}function Wd(e,t){var n=wd(!0),r=null,i=Vd,a=null,o=Rd(s);e=typeof e==`function`?e:e===void 0?Hd:wd(e),t=typeof t==`function`?t:t===void 0?Ud:wd(t);function s(s){var c,l=(s=zd(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c<l&&n(u=s[c],c,s))===d&&((d=!d)?a.lineStart():a.lineEnd()),d&&a.point(+e(u,c,s),+t(u,c,s));if(f)return a=null,f+``||null}return s.x=function(t){return arguments.length?(e=typeof t==`function`?t:wd(+t),s):e},s.y=function(e){return arguments.length?(t=typeof e==`function`?e:wd(+e),s):t},s.defined=function(e){return arguments.length?(n=typeof e==`function`?e:wd(!!e),s):n},s.curve=function(e){return arguments.length?(i=e,r!=null&&(a=i(r)),s):i},s.context=function(e){return arguments.length?(e==null?r=a=null:a=i(r=e),s):r},s}function Gd(e,t,n){var r=null,i=wd(!0),a=null,o=Vd,s=null,c=Rd(l);e=typeof e==`function`?e:e===void 0?Hd:wd(+e),t=typeof t==`function`?t:wd(t===void 0?0:+t),n=typeof n==`function`?n:n===void 0?Ud:wd(+n);function l(l){var u,d,f,p=(l=zd(l)).length,m,h=!1,g,_=Array(p),v=Array(p);for(a??(s=o(g=c())),u=0;u<=p;++u){if(!(u<p&&i(m=l[u],u,l))===h)if(h=!h)d=u,s.areaStart(),s.lineStart();else{for(s.lineEnd(),s.lineStart(),f=u-1;f>=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return Wd().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:wd(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:wd(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:wd(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:wd(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:wd(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:wd(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:wd(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}var Kd=class{constructor(e,t){this._context=e,this._x=t}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(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,t,e,t):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+t)/2,e,this._y0,e,t);break}this._x0=e,this._y0=t}};function qd(e){return new Kd(e,!0)}function Jd(e){return new Kd(e,!1)}var Yd={draw(e,t){let n=Dd(t/Od);e.moveTo(n,0),e.arc(0,0,n,0,kd)}},Xd={draw(e,t){let n=Dd(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},Zd=Dd(1/3),Qd=Zd*2,$d={draw(e,t){let n=Dd(t/Qd),r=n*Zd;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},ef={draw(e,t){let n=Dd(t),r=-n/2;e.rect(r,r,n,n)}},tf=.8908130915292852,nf=Ed(Od/10)/Ed(7*Od/10),rf=Ed(kd/10)*nf,af=-Td(kd/10)*nf,of={draw(e,t){let n=Dd(t*tf),r=rf*n,i=af*n;e.moveTo(0,-n),e.lineTo(r,i);for(let t=1;t<5;++t){let a=kd*t/5,o=Td(a),s=Ed(a);e.lineTo(s*n,-o*n),e.lineTo(o*r-s*i,s*r+o*i)}e.closePath()}},sf=Dd(3),cf={draw(e,t){let n=-Dd(t/(sf*3));e.moveTo(0,n*2),e.lineTo(-sf*n,-n),e.lineTo(sf*n,-n),e.closePath()}},lf=-.5,uf=Dd(3)/2,df=1/Dd(12),ff=(df/2+1)*3,pf={draw(e,t){let n=Dd(t/ff),r=n/2,i=n*df,a=r,o=n*df+n,s=-a,c=o;e.moveTo(r,i),e.lineTo(a,o),e.lineTo(s,c),e.lineTo(lf*r-uf*i,uf*r+lf*i),e.lineTo(lf*a-uf*o,uf*a+lf*o),e.lineTo(lf*s-uf*c,uf*s+lf*c),e.lineTo(lf*r+uf*i,lf*i-uf*r),e.lineTo(lf*a+uf*o,lf*o-uf*a),e.lineTo(lf*s+uf*c,lf*c-uf*s),e.closePath()}};function mf(e,t){let n=null,r=Rd(i);e=typeof e==`function`?e:wd(e||Yd),t=typeof t==`function`?t:wd(t===void 0?64:+t);function i(){let i;if(n||=i=r(),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),i)return n=null,i+``||null}return i.type=function(t){return arguments.length?(e=typeof t==`function`?t:wd(t),i):e},i.size=function(e){return arguments.length?(t=typeof e==`function`?e:wd(+e),i):t},i.context=function(e){return arguments.length?(n=e??null,i):n},i}function hf(){}function gf(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function _f(e){this._context=e}_f.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:gf(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:gf(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function vf(e){return new _f(e)}function yf(e){this._context=e}yf.prototype={areaStart:hf,areaEnd:hf,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:gf(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function bf(e){return new yf(e)}function xf(e){this._context=e}xf.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:gf(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Sf(e){return new xf(e)}function Cf(e){this._context=e}Cf.prototype={areaStart:hf,areaEnd:hf,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function wf(e){return new Cf(e)}function Tf(e){return e<0?-1:1}function Ef(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(Tf(a)+Tf(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function Df(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function Of(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function kf(e){this._context=e}kf.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:Of(this,this._t0,Df(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Of(this,Df(this,n=Ef(this,e,t)),n);break;default:Of(this,this._t0,n=Ef(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function Af(e){this._context=new jf(e)}(Af.prototype=Object.create(kf.prototype)).point=function(e,t){kf.prototype.point.call(this,t,e)};function jf(e){this._context=e}jf.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function Mf(e){return new kf(e)}function Nf(e){return new Af(e)}function Pf(e){this._context=e}Pf.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=Ff(e),i=Ff(t),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],e[o],t[o]);(this._line||this._line!==0&&n===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function Ff(e){var t,n=e.length-1,r,i=Array(n),a=Array(n),o=Array(n);for(i[0]=0,a[0]=2,o[0]=e[0]+2*e[1],t=1;t<n-1;++t)i[t]=1,a[t]=4,o[t]=4*e[t]+2*e[t+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)r=i[t]/a[t-1],a[t]-=r,o[t]-=r*o[t-1];for(i[n-1]=o[n-1]/a[n-1],t=n-2;t>=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t<n-1;++t)a[t]=2*e[t+1]-i[t+1];return[i,a]}function If(e){return new Pf(e)}function Lf(e,t){this._context=e,this._t=t}Lf.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}this._x=e,this._y=t}};function Rf(e){return new Lf(e,.5)}function zf(e){return new Lf(e,0)}function Bf(e){return new Lf(e,1)}function Vf(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n<o;++n)for(i=a,a=e[t[n]],r=0;r<s;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function Hf(e){for(var t=e.length,n=Array(t);--t>=0;)n[t]=t;return n}function Uf(e,t){return e[t]}function Wf(e){let t=[];return t.key=e,t}function Gf(){var e=wd([]),t=Hf,n=Vf,r=Uf;function i(i){var a=Array.from(e.apply(this,arguments),Wf),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o<s;++o)(a[o][c]=[0,+r(e,a[o].key,c,i)]).data=e;for(o=0,l=zd(t(a));o<s;++o)a[l[o]].index=o;return n(a,l),a}return i.keys=function(t){return arguments.length?(e=typeof t==`function`?t:wd(Array.from(t)),i):e},i.value=function(e){return arguments.length?(r=typeof e==`function`?e:wd(+e),i):r},i.order=function(e){return arguments.length?(t=e==null?Hf:typeof e==`function`?e:wd(Array.from(e)),i):t},i.offset=function(e){return arguments.length?(n=e??Vf,i):n},i}function Kf(e,t){if((r=e.length)>0){for(var n,r,i=0,a=e[0].length,o;i<a;++i){for(o=n=0;n<r;++n)o+=e[n][i][1]||0;if(o)for(n=0;n<r;++n)e[n][i][1]/=o}Vf(e,t)}}function qf(e,t){if((i=e.length)>0){for(var n=0,r=e[t[0]],i,a=r.length;n<a;++n){for(var o=0,s=0;o<i;++o)s+=e[o][n][1]||0;r[n][1]+=r[n][0]=-s/2}Vf(e,t)}}function Jf(e,t){if(!(!((o=e.length)>0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var s=0,c=0,l=0;s<o;++s){for(var u=e[t[s]],d=u[r][1]||0,f=(d-(u[r-1][1]||0))/2,p=0;p<s;++p){var m=e[t[p]],h=m[r][1]||0,g=m[r-1][1]||0;f+=h-g}c+=d,l+=f*d}i[r-1][1]+=i[r-1][0]=n,c&&(n-=l/c)}i[r-1][1]+=i[r-1][0]=n,Vf(e,t)}}function Yf(e){return e===`__proto__`}function Xf(e){switch(typeof e){case`number`:case`symbol`:return!1;case`string`:return e.includes(`.`)||e.includes(`[`)||e.includes(`]`)}}function Zf(e){return typeof e==`string`||typeof e==`symbol`?e:Object.is(e?.valueOf?.(),-0)?`-0`:String(e)}function Qf(e){if(e==null)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Qf).join(`,`);let t=String(e);return t===`0`&&Object.is(Number(e),-0)?`-0`:t}function $f(e){if(Array.isArray(e))return e.map(Zf);if(typeof e==`symbol`)return[e];e=Qf(e);let t=[],n=e.length;if(n===0)return t;let r=0,i=``,a=``,o=!1;for(e.charCodeAt(0)===46&&t.push(``);r<n;){let s=e[r];if(a)s===`\\`&&r+1<n?(r++,i+=e[r]):s===a?a=``:i+=s;else if(o)s===`"`||s===`'`?a=s:s===`]`?(o=!1,t.push(i),i=``):i+=s;else if(s===`[`)o=!0,i&&=(t.push(i),``);else if(s===`.`){i&&=(t.push(i),``);let n=e[r+1];(n===void 0||n===`.`)&&t.push(``)}else i+=s;r++}return i&&t.push(i),t}function ep(e,t,n){if(e==null)return n;switch(typeof t){case`string`:{if(Yf(t))return n;let r=e[t];return r===void 0?Xf(t)&&!Object.hasOwn(e,t)?ep(e,$f(t),n):n:r}case`number`:case`symbol`:{typeof t==`number`&&(t=Zf(t));let r=e[t];return r===void 0?n:r}default:{if(Array.isArray(t))return tp(e,t,n);if(t=Object.is(t?.valueOf(),-0)?`-0`:String(t),Yf(t))return n;let r=e[t];return r===void 0?n:r}}}function tp(e,t,n){if(t.length===0)return n;let r=e;for(let e=0;e<t.length;e++){if(r==null||Yf(t[e]))return n;r=r[t[e]]}return r===void 0?n:r}var np=4;function rp(e){var t=10**(arguments.length>1&&arguments[1]!==void 0?arguments[1]:np),n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function ip(e){var t=[...arguments].slice(1);return e.reduce((e,n,r)=>{var i=t[r-1];return typeof i==`string`?e+i+n:i===void 0?e+n:e+rp(i)+n},``)}var ap=e=>e===0?0:e>0?1:-1,op=e=>typeof e==`number`&&e!=+e,sp=e=>typeof e==`string`&&e.length>1&&e.indexOf(`%`)===e.length-1,X=e=>(typeof e==`number`||e instanceof Number)&&!op(e),cp=e=>X(e)||typeof e==`string`,lp=0,up=e=>{var t=++lp;return`${e||``}${t}`},dp=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!X(e)&&typeof e!=`string`)return n;var i;if(sp(e)){if(t==null)return n;var a=e.indexOf(`%`);i=t*parseFloat(e.slice(0,a))/100}else i=+e;return op(i)&&(i=n),r&&t!=null&&i>t&&(i=t),i},fp=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;r<t;r++)if(!n[String(e[r])])n[String(e[r])]=!0;else return!0;return!1};function pp(e,t,n){return X(e)&&X(t)?rp(e+n*(t-e)):t}function mp(e,t,n){if(!(!e||!e.length))return e.find(e=>e&&(typeof t==`function`?t(e):ep(e,t))===n)}var hp=e=>e==null,gp=e=>hp(e)?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function _p(e){return e!=null}function vp(){}var yp=[`type`,`size`,`sizeType`];function bp(){return bp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bp.apply(null,arguments)}function xp(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Sp(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?xp(Object(n),!0).forEach(function(t){Cp(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xp(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Cp(e,t,n){return(t=wp(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wp(e){var t=Tp(e,`string`);return typeof t==`symbol`?t:t+``}function Tp(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ep(e,t){if(e==null)return{};var n,r,i=Dp(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Dp(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Op={symbolCircle:Yd,symbolCross:Xd,symbolDiamond:$d,symbolSquare:ef,symbolStar:of,symbolTriangle:cf,symbolWye:pf},kp=Math.PI/180,Ap=e=>Op[`symbol${gp(e)}`]||Yd,jp=(e,t,n)=>{if(t===`area`)return e;switch(n){case`cross`:return 5*e*e/9;case`diamond`:return .5*e*e/Math.sqrt(3);case`square`:return e*e;case`star`:var r=18*kp;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2);case`triangle`:return Math.sqrt(3)*e*e/4;case`wye`:return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},Mp=(e,t)=>{Op[`symbol${gp(e)}`]=t},Np=e=>{var t=e.type,n=t===void 0?`circle`:t,r=e.size,i=r===void 0?64:r,a=e.sizeType,o=a===void 0?`area`:a,s=Sp(Sp({},Ep(e,yp)),{},{type:n,size:i,sizeType:o}),c=`circle`;typeof n==`string`&&(c=n);var l=()=>{var e=Ap(c),t=mf().type(e).size(jp(i,o,c))();if(t!==null)return t},u=s.className,d=s.cx,f=s.cy,p=_d(s);return X(d)&&X(f)&&X(i)?S.createElement(`path`,bp({},p,{className:ld(`recharts-symbols`,u),transform:`translate(${d}, ${f})`,d:l()})):null};Np.registerSymbol=Mp;var Pp=e=>`radius`in e&&`startAngle`in e&&`endAngle`in e,Fp=(e,t)=>{if(!e||typeof e==`function`||typeof e==`boolean`)return null;var n=e;if((0,S.isValidElement)(e)&&(n=e.props),typeof n!=`object`&&typeof n!=`function`)return null;var r={};return Object.keys(n).forEach(e=>{dd(e)&&typeof n[e]==`function`&&(r[e]=t||(t=>n[e](n,t)))}),r},Ip=(e,t,n)=>r=>(e(t,n,r),null),Lp=(e,t,n)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];dd(i)&&typeof a==`function`&&(r||={},r[i]=Ip(a,t,n))}),r};function Rp(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zp(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Rp(Object(n),!0).forEach(function(t){Bp(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rp(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Bp(e,t,n){return(t=Vp(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vp(e){var t=Hp(e,`string`);return typeof t==`symbol`?t:t+``}function Hp(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Up(e,t){var n=zp({},e),r=t;return Object.keys(t).reduce((e,t)=>(e[t]===void 0&&r[t]!==void 0&&(e[t]=r[t]),e),n)}function Wp(){return Wp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Wp.apply(null,arguments)}function Gp(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Kp(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Gp(Object(n),!0).forEach(function(t){qp(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Gp(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qp(e,t,n){return(t=Jp(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jp(e){var t=Yp(e,`string`);return typeof t==`symbol`?t:t+``}function Yp(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Xp=32,Zp={align:`center`,iconSize:14,inactiveColor:`#ccc`,layout:`horizontal`,verticalAlign:`middle`,labelStyle:{}};function Qp(e){if(typeof e==`object`&&e&&`strokeDasharray`in e)return String(e.strokeDasharray)}function $p(e){var t=e.data,n=e.iconType,r=e.inactiveColor,i=Xp/2,a=Xp/6,o=Xp/3,s=t.inactive?r:t.color,c=n??t.type;if(c===`none`)return null;if(c===`plainline`)return S.createElement(`line`,{strokeWidth:4,fill:`none`,stroke:s,strokeDasharray:Qp(t.payload),x1:0,y1:i,x2:Xp,y2:i,className:`recharts-legend-icon`});if(c===`line`)return S.createElement(`path`,{strokeWidth:4,fill:`none`,stroke:s,d:`M0,${i}h${o}
A${a},${a},0,1,1,${2*o},${i}
H${Xp}M${2*o},${i}
A${a},${a},0,1,1,${o},${i}`,className:`recharts-legend-icon`});if(c===`rect`)return S.createElement(`path`,{stroke:`none`,fill:s,d:`M0,${Xp/8}h${Xp}v${Xp*3/4}h${-Xp}z`,className:`recharts-legend-icon`});if(S.isValidElement(t.legendIcon)){var l=Kp({},t);return delete l.legendIcon,S.cloneElement(t.legendIcon,l)}return S.createElement(Np,{fill:s,cx:i,cy:i,size:Xp,sizeType:`diameter`,type:c})}function em(e){var t=e.payload,n=e.iconSize,r=e.layout,i=e.formatter,a=e.inactiveColor,o=e.iconType,s=e.labelStyle,c={x:0,y:0,width:Xp,height:Xp},l={display:r===`horizontal`?`inline-block`:`block`,marginRight:10},u={display:`inline-block`,verticalAlign:`middle`,marginRight:4};return t.map((t,r)=>{var d=t.formatter||i,f=ld({"recharts-legend-item":!0,[`legend-item-${r}`]:!0,inactive:t.inactive});if(t.type===`none`)return null;var p=typeof s==`object`?Kp({},s):{};p.color=t.inactive?a:p.color||t.color;var m=d?d(t.value,t,r):t.value;return S.createElement(`li`,Wp({className:f,style:l,key:`legend-item-${r}`},Lp(e,t,r)),S.createElement(Cd,{width:n,height:n,viewBox:c,style:u,"aria-label":`${t.value} legend icon`},S.createElement($p,{data:t,iconType:o,inactiveColor:a})),S.createElement(`span`,{className:`recharts-legend-item-text`,style:p},m))})}var tm=e=>{var t=Up(e,Zp),n=t.payload,r=t.layout,i=t.align;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r===`horizontal`?i:`left`};return S.createElement(`ul`,{className:`recharts-default-legend`,style:a},S.createElement(em,Wp({},t,{payload:n})))};function nm(e,t){let n=new Map;for(let r=0;r<e.length;r++){let i=e[r],a=t(i,r,e);n.has(a)||n.set(a,i)}return Array.from(n.values())}function rm(e,t){return function(...n){return e.apply(this,n.slice(0,t))}}function im(e){return e}function am(e){return function(t){return ep(t,e)}}function om(e){return e==null||typeof e!=`object`&&typeof e!=`function`}function sm(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function cm(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function lm(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var um=`[object RegExp]`,dm=`[object String]`,fm=`[object Number]`,pm=`[object Boolean]`,mm=`[object Arguments]`,hm=`[object Symbol]`,gm=`[object Date]`,_m=`[object Map]`,vm=`[object Set]`,ym=`[object Array]`,bm=`[object ArrayBuffer]`,xm=`[object Object]`,Sm=`[object DataView]`,Cm=`[object Uint8Array]`,wm=`[object Uint8ClampedArray]`,Tm=`[object Uint16Array]`,Em=`[object Uint32Array]`,Dm=`[object Int8Array]`,Om=`[object Int16Array]`,km=`[object Int32Array]`,Am=`[object Float32Array]`,jm=`[object Float64Array]`,Mm=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window||typeof self==`object`&&self||typeof global==`object`&&global||(function(){return this})();function Nm(e){return Mm.Buffer!==void 0&&Mm.Buffer.isBuffer(e)}function Pm(e,t){return Fm(e,void 0,e,new Map,t)}function Fm(e,t,n,r=new Map,i=void 0){let a=i?.(e,t,n,r);if(a!==void 0)return a;if(om(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){let t=Array(e.length);r.set(e,t);for(let a=0;a<e.length;a++)t[a]=Fm(e[a],a,n,r,i);return Object.hasOwn(e,`index`)&&(t.index=e.index),Object.hasOwn(e,`input`)&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){let t=new Map;r.set(e,t);for(let[a,o]of e)t.set(a,Fm(o,a,n,r,i));return t}if(e instanceof Set){let t=new Set;r.set(e,t);for(let a of e)t.add(Fm(a,void 0,n,r,i));return t}if(Nm(e))return e.subarray();if(sm(e)){let t=new(Object.getPrototypeOf(e)).constructor(e.length);r.set(e,t);for(let a=0;a<e.length;a++)t[a]=Fm(e[a],a,n,r,i);return t}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return r.set(e,t),Im(t,e,n,r,i),t}if(typeof File<`u`&&e instanceof File){let t=new File([e],e.name,{type:e.type});return r.set(e,t),Im(t,e,n,r,i),t}if(typeof Blob<`u`&&e instanceof Blob){let t=new Blob([e],{type:e.type});return r.set(e,t),Im(t,e,n,r,i),t}if(e instanceof Error){let t=structuredClone(e);return r.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,t.constructor=e.constructor,Im(t,e,n,r,i),t}if(e instanceof Boolean){let t=new Boolean(e.valueOf());return r.set(e,t),Im(t,e,n,r,i),t}if(e instanceof Number){let t=new Number(e.valueOf());return r.set(e,t),Im(t,e,n,r,i),t}if(e instanceof String){let t=new String(e.valueOf());return r.set(e,t),Im(t,e,n,r,i),t}if(typeof e==`object`&&Lm(e)){let t=Object.create(Object.getPrototypeOf(e));return r.set(e,t),Im(t,e,n,r,i),t}return e}function Im(e,t,n=e,r,i){let a=[...Object.keys(t),...cm(t)];for(let o=0;o<a.length;o++){let s=a[o],c=Object.getOwnPropertyDescriptor(e,s);(c==null||c.writable)&&(e[s]=Fm(t[s],s,n,r,i))}}function Lm(e){switch(lm(e)){case mm:case ym:case bm:case Sm:case pm:case gm:case Am:case jm:case Dm:case Om:case km:case _m:case fm:case xm:case um:case vm:case dm:case hm:case Cm:case wm:case Tm:case Em:return!0;default:return!1}}function Rm(e){return Fm(e,void 0,e,new Map,void 0)}function zm(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Bm(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}function Vm(e,t,n){return typeof n==`function`?Hm(e,t,function e(t,r,i,a,o,s){let c=n(t,r,i,a,o,s);return c===void 0?Hm(t,r,e,s,!1):!!c},new Map,!0):Vm(e,t,()=>void 0)}function Hm(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case`object`:return Um(e,t,n,r);case`function`:return Object.keys(t).length>0?Hm(e,{...t},n,r,i):zm(e,t);default:return Bm(e)&&i?typeof t==`string`?t===``:!0:zm(e,t)}}function Um(e,t,n,r){if(t==null)return!0;if(Array.isArray(t))return Gm(e,t,n,r);if(t instanceof Map)return Wm(e,t,n,r);if(t instanceof Set)return Km(e,t,n,r);let i=Object.keys(t);if(e==null||om(e))return i.length===0;if(i.length===0)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let a=0;a<i.length;a++){let o=i[a];if(!om(e)&&!(o in e)||t[o]===void 0&&e[o]!==void 0||t[o]===null&&e[o]!==null||!n(e[o],t[o],o,e,t,r))return!1}return!0}finally{r?.delete(t)}}function Wm(e,t,n,r){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[i,a]of t.entries())if(n(e.get(i),a,i,e,t,r)===!1)return!1;return!0}function Gm(e,t,n,r){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let i=new Set;for(let a=0;a<t.length;a++){let o=t[a],s=!1;for(let c=0;c<e.length;c++){if(i.has(c))continue;let l=e[c],u=!1;if(n(l,o,a,e,t,r)&&(u=!0),u){i.add(c),s=!0;break}}if(!s)return!1}return!0}function Km(e,t,n,r){return t.size===0?!0:e instanceof Set?Gm([...e],[...t],n,r):!1}function qm(e,t){return Vm(e,t,()=>void 0)}function Jm(e){return e=Rm(e),t=>qm(t,e)}function Ym(e,t){return Pm(e,(n,r,i,a)=>{let o=t?.(n,r,i,a);if(o!==void 0)return o;if(typeof e==`object`){if(lm(e)===`[object Object]`&&typeof e.constructor!=`function`){let t={};return a.set(e,t),Im(t,e,i,a),t}switch(Object.prototype.toString.call(e)){case fm:case dm:case pm:{let t=new e.constructor(e?.valueOf());return Im(t,e),t}case mm:{let t={};return Im(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}})}function Xm(e){return Ym(e)}var Zm=/^(?:0|[1-9]\d*)$/;function Qm(e,t=2**53-1){switch(typeof e){case`number`:return Number.isInteger(e)&&e>=0&&e<t;case`symbol`:return!1;case`string`:return Zm.test(e)}}function $m(e){return typeof e==`object`&&!!e&&lm(e)===`[object Arguments]`}function eh(e,t){let n;if(n=Array.isArray(t)?t:typeof t==`string`&&Xf(t)&&e?.[t]==null?$f(t):[t],n.length===0)return!1;let r=e;for(let e=0;e<n.length;e++){let t=n[e];if((r==null||!Object.hasOwn(r,t))&&!((Array.isArray(r)||$m(r))&&Qm(t)&&t<r.length))return!1;r=r[t]}return!0}function th(e,t){switch(typeof e){case`object`:Object.is(e?.valueOf(),-0)&&(e=`-0`);break;case`number`:e=Zf(e);break}return t=Xm(t),function(n){let r=ep(n,e);return r===void 0?eh(n,e):t===void 0?r===void 0:qm(r,t)}}function nh(e){if(e==null)return im;switch(typeof e){case`function`:return e;case`object`:return Array.isArray(e)&&e.length===2?th(e[0],e[1]):Jm(e);case`string`:case`symbol`:case`number`:return am(e)}}function rh(e){return Number.isSafeInteger(e)&&e>=0}function ih(e){return e!=null&&typeof e!=`function`&&rh(e.length)}function ah(e){return typeof e==`object`&&!!e}function oh(e){return ah(e)&&ih(e)}function sh(e,t=im){return oh(e)?nm(Array.from(e),rm(nh(t),1)):[]}function ch(e,t,n){return t===!0?sh(e,n):typeof t==`function`?sh(e,t):e}var lh=o((e=>{var t=d();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),uh=o(((e,t)=>{t.exports=lh()})),dh=o((e=>{var t=d(),n=uh();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),fh=o(((e,t)=>{t.exports=dh()})),ph=(0,S.createContext)(null),mh=fh(),hh=e=>e,gh=()=>{var e=(0,S.useContext)(ph);return e?e.store.dispatch:hh},_h=()=>{},vh=()=>_h,yh=(e,t)=>e===t;function Z(e){var t=(0,S.useContext)(ph),n=(0,S.useMemo)(()=>t?t=>{if(t!=null)return e(t)}:_h,[t,e]);return(0,mh.useSyncExternalStoreWithSelector)(t?t.subscription.addNestedSub:vh,t?t.store.getState:_h,t?t.store.getState:_h,n,yh)}function bh(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function xh(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var Sh=e=>Array.isArray(e)?e:[e];function Ch(e){let t=Array.isArray(e[0])?e[0]:e;return xh(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function wh(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}var Th=class{constructor(e){this.value=e}deref(){return this.value}},Eh=typeof WeakRef>`u`?Th:WeakRef,Dh=0,Oh=1;function kh(){return{s:Dh,v:void 0,o:null,p:null}}function Ah(e){return e instanceof Eh?e.deref():e}function jh(e,t={}){let n=kh(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e<n;e++){let n=arguments[e];if(typeof n==`function`||typeof n==`object`&&n){let e=t.o;e===null&&(t.o=e=new WeakMap);let r=e.get(n);r===void 0?(t=kh(),e.set(n,t)):t=r}else{let e=t.p;e===null&&(t.p=e=new Map);let r=e.get(n);r===void 0?(t=kh(),e.set(n,t)):t=r}}let s=t,c;if(t.s===Oh)c=t.v;else if(c=e.apply(null,arguments),a++,r){let e=Ah(i);e!=null&&r(e,c)&&(c=e,a!==0&&a--),i=typeof c==`object`&&c||typeof c==`function`?new Eh(c):c}return s.s=Oh,s.v=c,c}return o.clearCache=()=>{n=kh(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Mh(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),bh(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=jh,argsMemoizeOptions:u=[]}={...n,...a},d=Sh(c),f=Sh(u),p=Ch(e),m=s(function(){return t++,o.apply(null,arguments)},...d),h=l(function(){r++;let e=wh(p,arguments);return i=m.apply(null,e),i},...f);return Object.assign(h,{resultFunc:o,memoizedResultFunc:m,dependencies:p,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var Q=Mh(jh);function Nh(e,t=1){let n=[],r=Math.floor(t),i=(e,t)=>{for(let a=0;a<e.length;a++){let o=e[a];Array.isArray(o)&&t<r?i(o,t+1):n.push(o)}};return i(e,0),n}function Ph(e,t,n){return Bm(n)&&(typeof t==`number`&&ih(n)&&Qm(t)&&t<n.length||typeof t==`string`&&t in n)?zm(n[t],e):!1}function Fh(e){return typeof e==`symbol`?1:e===null?2:e===void 0?3:e===e?0:4}var Ih=(e,t,n)=>{if(e!==t){let r=Fh(e),i=Fh(t);if(r===i&&r===0){if(e<t)return n===`desc`?1:-1;if(e>t)return n===`desc`?-1:1}return n===`desc`?i-r:r-i}return 0};function Lh(e){return typeof e==`symbol`||e instanceof Symbol}var Rh=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,zh=/^\w*$/;function Bh(e,t){return Array.isArray(e)?!1:typeof e==`number`||typeof e==`boolean`||e==null||Lh(e)?!0:typeof e==`string`&&(zh.test(e)||!Rh.test(e))||t!=null&&Object.hasOwn(t,e)}function Vh(e,t,n,r){if(e==null)return[];n=r?void 0:n,Array.isArray(e)||(e=Object.values(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(n)||(n=n==null?[]:[n]),n=n.map(e=>String(e));let i=(e,t)=>{let n=e;for(let e=0;e<t.length&&n!=null;++e)n=n[t[e]];return n},a=(e,t)=>t==null||e==null?t:typeof e==`object`&&`key`in e?Object.hasOwn(t,e.key)?t[e.key]:i(t,e.path):typeof e==`function`?e(t):Array.isArray(e)?i(t,e):typeof t==`object`?t[e]:t,o=t.map(e=>(Array.isArray(e)&&e.length===1&&(e=e[0]),e==null||typeof e==`function`||Array.isArray(e)||Bh(e)?e:{key:e,path:$f(e)}));return e.map(e=>({original:e,criteria:o.map(t=>a(t,e))})).slice().sort((e,t)=>{for(let r=0;r<o.length;r++){let i=Ih(e.criteria[r],t.criteria[r],n[r]);if(i!==0)return i}return 0}).map(e=>e.original)}function Hh(e,...t){let n=t.length;return n>1&&Ph(e,t[0],t[1])?t=[]:n>2&&Ph(t[0],t[1],t[2])&&(t=[t[0]]),Vh(e,Nh(t),[`asc`])}var Uh=e=>e.legend.settings,Wh=e=>e.legend.size,Gh=Q([e=>e.legend.payload,Uh],(e,t)=>{var n=t.itemSorter,r=e.flat(1);return n?Hh(r,n):r});function Kh(){return Z(Gh)}function qh(e,t){return Qh(e)||Zh(e,t)||Yh(e,t)||Jh()}function Jh(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Yh(e,t){if(e){if(typeof e==`string`)return Xh(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xh(e,t):void 0}}function Xh(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Zh(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Qh(e){if(Array.isArray(e))return e}var $h=1;function eg(e,t){return Math.abs(e.height-t.height)>$h||Math.abs(e.left-t.left)>$h||Math.abs(e.top-t.top)>$h||Math.abs(e.width-t.width)>$h}function tg(e){var t=e.getBoundingClientRect();return{height:t.height,left:t.left,top:t.top,width:t.width}}function ng(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=qh((0,S.useState)({height:0,left:0,top:0,width:0}),2),n=t[0],r=t[1],i=(0,S.useRef)(null),a=(0,S.useRef)(n);a.current=n;var o=(0,S.useCallback)(e=>{if(i.current!=null&&(i.current.disconnect(),i.current=null),e!=null){var t=tg(e);if(eg(t,a.current)&&r(t),typeof ResizeObserver<`u`){var n=new ResizeObserver(()=>{var t=tg(e);eg(t,a.current)&&r(t)});n.observe(e),i.current=n}}},[...e]);return(0,S.useEffect)(()=>()=>{var e;(e=i.current)==null||e.disconnect()},[]),[n,o]}function rg(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var ig=typeof Symbol==`function`&&Symbol.observable||`@@observable`,ag=()=>Math.random().toString(36).substring(7).split(``).join(`.`),og={INIT:`@@redux/INIT${ag()}`,REPLACE:`@@redux/REPLACE${ag()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ag()}`};function sg(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function cg(e,t,n){if(typeof e!=`function`)throw Error(rg(2));if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error(rg(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error(rg(1));return n(cg)(e,t)}let r=e,i=t,a=new Map,o=a,s=0,c=!1;function l(){o===a&&(o=new Map,a.forEach((e,t)=>{o.set(t,e)}))}function u(){if(c)throw Error(rg(3));return i}function d(e){if(typeof e!=`function`)throw Error(rg(4));if(c)throw Error(rg(5));let t=!0;l();let n=s++;return o.set(n,e),function(){if(t){if(c)throw Error(rg(6));t=!1,l(),o.delete(n),a=null}}}function f(e){if(!sg(e))throw Error(rg(7));if(e.type===void 0)throw Error(rg(8));if(typeof e.type!=`string`)throw Error(rg(17));if(c)throw Error(rg(9));try{c=!0,i=r(i,e)}finally{c=!1}return(a=o).forEach(e=>{e()}),e}function p(e){if(typeof e!=`function`)throw Error(rg(10));r=e,f({type:og.REPLACE})}function m(){let e=d;return{subscribe(t){if(typeof t!=`object`||!t)throw Error(rg(11));function n(){let e=t;e.next&&e.next(u())}return n(),{unsubscribe:e(n)}},[ig](){return this}}}return f({type:og.INIT}),{dispatch:f,subscribe:d,getState:u,replaceReducer:p,[ig]:m}}function lg(e){Object.keys(e).forEach(t=>{let n=e[t];if(n(void 0,{type:og.INIT})===void 0)throw Error(rg(12));if(n(void 0,{type:og.PROBE_UNKNOWN_ACTION()})===void 0)throw Error(rg(13))})}function ug(e){let t=Object.keys(e),n={};for(let r=0;r<t.length;r++){let i=t[r];typeof e[i]==`function`&&(n[i]=e[i])}let r=Object.keys(n),i;try{lg(n)}catch(e){i=e}return function(e={},t){if(i)throw i;let a=!1,o={};for(let i=0;i<r.length;i++){let s=r[i],c=n[s],l=e[s],u=c(l,t);if(u===void 0)throw t&&t.type,Error(rg(14));o[s]=u,a||=u!==l}return a||=r.length!==Object.keys(e).length,a?o:e}}function dg(...e){return e.length===0?e=>e:e.length===1?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}function fg(...e){return t=>(n,r)=>{let i=t(n,r),a=()=>{throw Error(rg(15))},o={getState:i.getState,dispatch:(e,...t)=>a(e,...t)};return a=dg(...e.map(e=>e(o)))(i.dispatch),{...i,dispatch:a}}}function pg(e){return sg(e)&&`type`in e&&typeof e.type==`string`}var mg=Symbol.for(`immer-nothing`),hg=Symbol.for(`immer-draftable`),gg=Symbol.for(`immer-state`);function _g(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var vg=Object,yg=vg.getPrototypeOf,bg=`constructor`,xg=`prototype`,Sg=`configurable`,Cg=`enumerable`,wg=`writable`,Tg=`value`,Eg=e=>!!e&&!!e[gg];function Dg(e){return e?Ag(e)||Lg(e)||!!e[hg]||!!e[bg]?.[hg]||Rg(e)||zg(e):!1}var Og=vg[xg][bg].toString(),kg=new WeakMap;function Ag(e){if(!e||!Bg(e))return!1;let t=yg(e);if(t===null||t===vg[xg])return!0;let n=vg.hasOwnProperty.call(t,bg)&&t[bg];if(n===Object)return!0;if(!Vg(n))return!1;let r=kg.get(n);return r===void 0&&(r=Function.toString.call(n),kg.set(n,r)),r===Og}function jg(e,t,n=!0){Mg(e)===0?(n?Reflect.ownKeys(e):vg.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function Mg(e){let t=e[gg];return t?t.type_:Lg(e)?1:Rg(e)?2:zg(e)?3:0}var Ng=(e,t,n=Mg(e))=>n===2?e.has(t):vg[xg].hasOwnProperty.call(e,t),Pg=(e,t,n=Mg(e))=>n===2?e.get(t):e[t],Fg=(e,t,n,r=Mg(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Ig(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var Lg=Array.isArray,Rg=e=>e instanceof Map,zg=e=>e instanceof Set,Bg=e=>typeof e==`object`,Vg=e=>typeof e==`function`,Hg=e=>typeof e==`boolean`;function Ug(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Wg=e=>e.copy_||e.base_,Gg=e=>e.modified_?e.copy_:e.base_;function Kg(e,t){if(Rg(e))return new Map(e);if(zg(e))return new Set(e);if(Lg(e))return Array[xg].slice.call(e);let n=Ag(e);if(t===!0||t===`class_only`&&!n){let t=vg.getOwnPropertyDescriptors(e);delete t[gg];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a[wg]===!1&&(a[wg]=!0,a[Sg]=!0),(a.get||a.set)&&(t[i]={[Sg]:!0,[wg]:!0,[Cg]:a[Cg],[Tg]:e[i]})}return vg.create(yg(e),t)}else{let t=yg(e);if(t!==null&&n)return{...e};let r=vg.create(t);return vg.assign(r,e)}}function qg(e,t=!1){return Xg(e)||Eg(e)||!Dg(e)?e:(Mg(e)>1&&vg.defineProperties(e,{set:Yg,add:Yg,clear:Yg,delete:Yg}),vg.freeze(e),t&&jg(e,(e,t)=>{qg(t,!0)},!1),e)}function Jg(){_g(2)}var Yg={[Tg]:Jg};function Xg(e){return e===null||!Bg(e)?!0:vg.isFrozen(e)}var Zg=`MapSet`,Qg=`Patches`,$g=`ArrayMethods`,e_={};function t_(e){let t=e_[e];return t||_g(0,e),t}var n_=e=>!!e_[e],r_,i_=()=>r_,a_=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:n_(Zg)?t_(Zg):void 0,arrayMethodsPlugin_:n_($g)?t_($g):void 0});function o_(e,t){t&&(e.patchPlugin_=t_(Qg),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function s_(e){c_(e),e.drafts_.forEach(u_),e.drafts_=null}function c_(e){e===r_&&(r_=e.parent_)}var l_=e=>r_=a_(r_,e);function u_(e){let t=e[gg];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function d_(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[gg].modified_&&(s_(t),_g(4)),Dg(e)&&(e=f_(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[gg].base_,e,t)}else e=f_(t,n);return p_(t,e,!0),s_(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===mg?void 0:e}function f_(e,t){if(Xg(t))return t;let n=t[gg];if(!n)return x_(t,e.handledSet_,e);if(!h_(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);y_(n,e)}return n.copy_}function p_(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&qg(t,n)}function m_(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var h_=(e,t)=>e.scope_===t,g_=[];function __(e,t,n,r){let i=Wg(e),a=e.type_;if(r!==void 0&&Pg(i,r,a)===t){Fg(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;jg(i,(e,n)=>{if(Eg(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??g_;for(let e of o)Fg(i,e,n,a)}function v_(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!h_(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=Gg(i);__(e,i.draft_??i,a,n),y_(i,r)})}function y_(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}m_(e)}}function b_(e,t,n){let{scope_:r}=e;if(Eg(n)){let i=n[gg];h_(i,r)&&i.callbacks_.push(function(){k_(e),__(e,n,Gg(i),t)})}else Dg(n)&&e.callbacks_.push(function(){let i=Wg(e);e.type_===3?i.has(n)&&x_(n,r.handledSet_,r):Pg(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&x_(Pg(e.copy_,t,e.type_),r.handledSet_,r)})}function x_(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Eg(e)||t.has(e)||!Dg(e)||Xg(e)?e:(t.add(e),jg(e,(r,i)=>{if(Eg(i)){let t=i[gg];h_(t,n)&&(Fg(e,r,Gg(t),e.type_),m_(t))}else Dg(i)&&x_(i,t,n)}),e)}function S_(e,t){let n=Lg(e),r={type_:+!!n,scope_:t?t.scope_:i_(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=C_;n&&(i=[r],a=w_);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var C_={get(e,t){if(t===gg)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=Wg(e);if(!Ng(i,t,e.type_))return E_(e,i,t);let a=i[t];if(e.finalized_||!Dg(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Ug(t))return a;if(a===T_(e.base_,t)){k_(e);let n=e.type_===1?+t:t,r=j_(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in Wg(e)},ownKeys(e){return Reflect.ownKeys(Wg(e))},set(e,t,n){let r=D_(Wg(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=T_(Wg(e),t),i=r?.[gg];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Ig(n,r)&&(n!==void 0||Ng(e.base_,t,e.type_)))return!0;k_(e),O_(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),b_(e,t,n),!0)},deleteProperty(e,t){return k_(e),T_(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),O_(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Wg(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[wg]:!0,[Sg]:e.type_!==1||t!==`length`,[Cg]:r[Cg],[Tg]:n[t]}},defineProperty(){_g(11)},getPrototypeOf(e){return yg(e.base_)},setPrototypeOf(){_g(12)}},w_={};for(let e in C_){let t=C_[e];w_[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}w_.deleteProperty=function(e,t){return w_.set.call(this,e,t,void 0)},w_.set=function(e,t,n){return C_.set.call(this,e[0],t,n,e[0])};function T_(e,t){let n=e[gg];return(n?Wg(n):e)[t]}function E_(e,t,n){let r=D_(t,n);return r?Tg in r?r[Tg]:r.get?.call(e.draft_):void 0}function D_(e,t){if(!(t in e))return;let n=yg(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=yg(n)}}function O_(e){e.modified_||(e.modified_=!0,e.parent_&&O_(e.parent_))}function k_(e){e.copy_||=(e.assigned_=new Map,Kg(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var A_=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(Vg(e)&&!Vg(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}Vg(t)||_g(6),n!==void 0&&!Vg(n)&&_g(7);let r;if(Dg(e)){let i=l_(this),a=j_(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?s_(i):c_(i)}return o_(i,n),d_(r,i)}else if(!e||!Bg(e)){if(r=t(e),r===void 0&&(r=e),r===mg&&(r=void 0),this.autoFreeze_&&qg(r,!0),n){let t=[],i=[];t_(Qg).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else _g(1,e)},this.produceWithPatches=(e,t)=>{if(Vg(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},Hg(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Hg(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Hg(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Dg(e)||_g(8),Eg(e)&&(e=M_(e));let t=l_(this),n=j_(t,e,void 0);return n[gg].isManual_=!0,c_(t),n}finishDraft(e,t){let n=e&&e[gg];(!n||!n.isManual_)&&_g(9);let{scope_:r}=n;return o_(r,t),d_(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=t_(Qg).applyPatches_;return Eg(e)?r(e,t):this.produce(e,e=>r(e,t))}};function j_(e,t,n,r){let[i,a]=Rg(t)?t_(Zg).proxyMap_(t,n):zg(t)?t_(Zg).proxySet_(t,n):S_(t,n);return(n?.scope_??i_()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?v_(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function M_(e){return Eg(e)||_g(10,e),N_(e)}function N_(e){if(!Dg(e)||Xg(e))return e;let t=e[gg],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Kg(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=Kg(e,!0);return jg(n,(e,t)=>{Fg(n,e,N_(t))},r),t&&(t.finalized_=!1),n}var P_=new A_().produce;function F_(e){return({dispatch:t,getState:n})=>r=>i=>typeof i==`function`?i(t,n,e):r(i)}var I_=F_(),L_=F_,R_=typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]==`object`?dg:dg.apply(null,arguments)};typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;function z_(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw Error(Jv(0));return{type:e,payload:r.payload,...`meta`in r&&{meta:r.meta},...`error`in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>pg(t)&&t.type===e,n}var B_=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function V_(e){return Dg(e)?P_(e,()=>{}):e}function H_(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function U_(e){return typeof e==`boolean`}var W_=()=>function(e){let{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=e??{},a=new B_;return t&&(U_(t)?a.push(I_):a.push(L_(t.extraArgument))),a},G_=`RTK_autoBatch`,K_=()=>e=>({payload:e,meta:{[G_]:!0}}),q_=e=>t=>{setTimeout(t,e)},J_=(e,t)=>n=>{let r=!1,i=()=>{r||(r=!0,cancelAnimationFrame(a),clearTimeout(o),n())},a=e(i),o=setTimeout(i,t)},Y_=(e={type:`raf`})=>t=>(...n)=>{let r=t(...n),i=!0,a=!1,o=!1,s=new Set,c=e.type===`tick`?queueMicrotask:e.type===`raf`?typeof window<`u`&&window.requestAnimationFrame?J_(window.requestAnimationFrame,100):q_(10):e.type===`callback`?e.queueNotification:q_(e.timeout),l=()=>{o=!1,a&&(a=!1,s.forEach(e=>e()))};return Object.assign({},r,{subscribe(e){let t=r.subscribe(()=>i&&e());return s.add(e),()=>{t(),s.delete(e)}},dispatch(e){try{return i=!e?.meta?.[G_],a=!i,a&&(o||(o=!0,c(l))),r.dispatch(e)}finally{i=!0}}})},X_=e=>function(t){let{autoBatch:n=!0}=t??{},r=new B_(e);return n&&r.push(Y_(typeof n==`object`?n:void 0)),r};function Z_(e){let t=W_(),{reducer:n=void 0,middleware:r,devTools:i=!0,duplicateMiddlewareCheck:a=!0,preloadedState:o=void 0,enhancers:s=void 0}=e||{},c;if(typeof n==`function`)c=n;else if(sg(n))c=ug(n);else throw Error(Jv(1));let l;l=typeof r==`function`?r(t):t();let u=dg;i&&(u=R_({trace:!1,...typeof i==`object`&&i}));let d=X_(fg(...l)),f=typeof s==`function`?s(d):d(),p=u(...f);return cg(c,o,p)}function Q_(e){let t={},n=[],r,i={addCase(e,n){let r=typeof e==`string`?e:e.type;if(!r)throw Error(Jv(28));if(r in t)throw Error(Jv(29));return t[r]=n,i},addAsyncThunk(e,r){return r.pending&&(t[e.pending.type]=r.pending),r.rejected&&(t[e.rejected.type]=r.rejected),r.fulfilled&&(t[e.fulfilled.type]=r.fulfilled),r.settled&&n.push({matcher:e.settled,reducer:r.settled}),i},addMatcher(e,t){return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){return r=e,i}};return e(i),[t,n,r]}function $_(e){return typeof e==`function`}function ev(e,t){let[n,r,i]=Q_(t),a;if($_(e))a=()=>V_(e());else{let t=V_(e);a=()=>t}function o(e=a(),t){let o=[n[t.type],...r.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return o.filter(e=>!!e).length===0&&(o=[i]),o.reduce((e,n)=>{if(n)if(Eg(e)){let r=n(e,t);return r===void 0?e:r}else if(Dg(e))return P_(e,e=>n(e,t));else{let r=n(e,t);if(r===void 0){if(e===null)return e;throw Error(`A case reducer on a non-draftable value must not return undefined`)}return r}return e},e)}return o.getInitialState=a,o}var tv=`ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW`,nv=(e=21)=>{let t=``,n=e;for(;n--;)t+=tv[Math.random()*64|0];return t},rv=Symbol.for(`rtk-slice-createasyncthunk`);function iv(e,t){return`${e}/${t}`}function av({creators:e}={}){let t=e?.asyncThunk?.[rv];return function(e){let{name:n,reducerPath:r=n}=e;if(!n)throw Error(Jv(11));let i=(typeof e.reducers==`function`?e.reducers(cv()):e.reducers)||{},a=Object.keys(i),o={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},s={addCase(e,t){let n=typeof e==`string`?e:e.type;if(!n)throw Error(Jv(12));if(n in o.sliceCaseReducersByType)throw Error(Jv(13));return o.sliceCaseReducersByType[n]=t,s},addMatcher(e,t){return o.sliceMatchers.push({matcher:e,reducer:t}),s},exposeAction(e,t){return o.actionCreators[e]=t,s},exposeCaseReducer(e,t){return o.sliceCaseReducersByName[e]=t,s}};a.forEach(r=>{let a=i[r],o={reducerName:r,type:iv(n,r),createNotation:typeof e.reducers==`function`};uv(a)?fv(o,a,s,t):lv(o,a,s)});function c(){let[t={},n=[],r=void 0]=typeof e.extraReducers==`function`?Q_(e.extraReducers):[e.extraReducers],i={...t,...o.sliceCaseReducersByType};return ev(e.initialState,e=>{for(let t in i)e.addCase(t,i[t]);for(let t of o.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)})}let l=e=>e,u=new Map,d=new WeakMap,f;function p(e,t){return f||=c(),f(e,t)}function m(){return f||=c(),f.getInitialState()}function h(t,n=!1){function r(e){let i=e[t];return i===void 0&&n&&(i=H_(d,r,m)),i}function i(t=l){return H_(H_(u,n,()=>new WeakMap),t,()=>{let r={};for(let[i,a]of Object.entries(e.selectors??{}))r[i]=ov(a,t,()=>H_(d,t,m),n);return r})}return{reducerPath:t,getSelectors:i,get selectors(){return i(r)},selectSlice:r}}let g={name:n,reducer:p,actions:o.actionCreators,caseReducers:o.sliceCaseReducersByName,getInitialState:m,...h(r),injectInto(e,{reducerPath:t,...n}={}){let i=t??r;return e.inject({reducerPath:i,reducer:p},n),{...g,...h(i,!0)}}};return g}}function ov(e,t,n,r){function i(i,...a){let o=t(i);return o===void 0&&r&&(o=n()),e(o,...a)}return i.unwrapped=e,i}var sv=av();function cv(){function e(e,t){return{_reducerDefinitionType:`asyncThunk`,payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer(e){return Object.assign({[e.name](...t){return e(...t)}}[e.name],{_reducerDefinitionType:`reducer`})},preparedReducer(e,t){return{_reducerDefinitionType:`reducerWithPrepare`,prepare:e,reducer:t}},asyncThunk:e}}function lv({type:e,reducerName:t,createNotation:n},r,i){let a,o;if(`reducer`in r){if(n&&!dv(r))throw Error(Jv(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,o?z_(e,o):z_(e))}function uv(e){return e._reducerDefinitionType===`asyncThunk`}function dv(e){return e._reducerDefinitionType===`reducerWithPrepare`}function fv({type:e,reducerName:t},n,r,i){if(!i)throw Error(Jv(18));let{payloadCreator:a,fulfilled:o,pending:s,rejected:c,settled:l,options:u}=n,d=i(e,a,u);r.exposeAction(t,d),o&&r.addCase(d.fulfilled,o),s&&r.addCase(d.pending,s),c&&r.addCase(d.rejected,c),l&&r.addMatcher(d.settled,l),r.exposeCaseReducer(t,{fulfilled:o||pv,pending:s||pv,rejected:c||pv,settled:l||pv})}function pv(){}var mv=`task`,hv=`listener`,gv=`completed`,_v=`cancelled`,vv=`task-${_v}`,yv=`task-${gv}`,bv=`${hv}-${_v}`,xv=`${hv}-${gv}`,Sv=class{constructor(e){this.code=e,this.message=`${mv} ${_v} (reason: ${e})`}code;name=`TaskAbortError`;message},Cv=(e,t)=>{if(typeof e!=`function`)throw TypeError(Jv(32))},wv=()=>{},Tv=(e,t=wv)=>(e.catch(t),e),Ev=(e,t)=>(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)),Dv=e=>{if(e.aborted)throw new Sv(e.reason)};function Ov(e,t){let n=wv;return new Promise((r,i)=>{let a=()=>i(new Sv(e.reason));if(e.aborted){a();return}n=Ev(e,a),t.finally(()=>n()).then(r,i)}).finally(()=>{n=wv})}var kv=async(e,t)=>{try{return await Promise.resolve(),{status:`ok`,value:await e()}}catch(e){return{status:e instanceof Sv?`cancelled`:`rejected`,error:e}}finally{t?.()}},Av=e=>t=>Tv(Ov(e,t).then(t=>(Dv(e),t))),jv=e=>{let t=Av(e);return e=>t(new Promise(t=>setTimeout(t,e)))},{assign:Mv}=Object,Nv={},Pv=`listenerMiddleware`,Fv=(e,t)=>{let n=t=>Ev(e,()=>t.abort(e.reason));return(r,i)=>{Cv(r,`taskExecutor`);let a=new AbortController;n(a);let o=kv(async()=>{Dv(e),Dv(a.signal);let t=await r({pause:Av(a.signal),delay:jv(a.signal),signal:a.signal});return Dv(a.signal),t},()=>a.abort(yv));return i?.autoJoin&&t.push(o.catch(wv)),{result:Av(e)(o),cancel(){a.abort(vv)}}}},Iv=(e,t)=>{let n=async(n,r)=>{Dv(t);let i=()=>{},a=[new Promise((t,r)=>{let a=e({predicate:n,effect:(e,n)=>{n.unsubscribe(),t([e,n.getState(),n.getOriginalState()])}});i=()=>{a(),r()}})];r!=null&&a.push(new Promise(e=>setTimeout(e,r,null)));try{let e=await Ov(t,Promise.race(a));return Dv(t),e}finally{i()}};return((e,t)=>Tv(n(e,t)))},Lv=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:a}=e;if(t)i=z_(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw Error(Jv(21));return Cv(a,`options.listener`),{predicate:i,type:t,effect:a}},Rv=Mv(e=>{let{type:t,predicate:n,effect:r}=Lv(e);return{id:nv(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw Error(Jv(22))}}},{withTypes:()=>Rv}),zv=(e,t)=>{let{type:n,effect:r,predicate:i}=Lv(t);return Array.from(e.values()).find(e=>(typeof n==`string`?e.type===n:e.predicate===i)&&e.effect===r)},Bv=e=>{e.pending.forEach(e=>{e.abort(bv)})},Vv=(e,t)=>()=>{for(let e of t.keys())Bv(e);e.clear()},Hv=(e,t,n)=>{try{e(t,n)}catch(e){setTimeout(()=>{throw e},0)}},Uv=Mv(z_(`${Pv}/add`),{withTypes:()=>Uv}),Wv=z_(`${Pv}/removeAll`),Gv=Mv(z_(`${Pv}/remove`),{withTypes:()=>Gv}),Kv=(...e)=>{console.error(`${Pv}/error`,...e)},qv=(e={})=>{let t=new Map,n=new Map,r=e=>{let t=n.get(e)??0;n.set(e,t+1)},i=e=>{let t=n.get(e)??1;t===1?n.delete(e):n.set(e,t-1)},{extra:a,onError:o=Kv}=e;Cv(o,`onError`);let s=e=>(e.unsubscribe=()=>t.delete(e.id),t.set(e.id,e),t=>{e.unsubscribe(),t?.cancelActive&&Bv(e)}),c=(e=>s(zv(t,e)??Rv(e)));Mv(c,{withTypes:()=>c});let l=e=>{let n=zv(t,e);return n&&(n.unsubscribe(),e.cancelActive&&Bv(n)),!!n};Mv(l,{withTypes:()=>l});let u=async(e,n,s,l)=>{let u=new AbortController,d=Iv(c,u.signal),f=[];try{e.pending.add(u),r(e),await Promise.resolve(e.effect(n,Mv({},s,{getOriginalState:l,condition:(e,t)=>d(e,t).then(Boolean),take:d,delay:jv(u.signal),pause:Av(u.signal),extra:a,signal:u.signal,fork:Fv(u.signal,f),unsubscribe:e.unsubscribe,subscribe:()=>{t.set(e.id,e)},cancelActiveListeners:()=>{e.pending.forEach((e,t,n)=>{e!==u&&(e.abort(bv),n.delete(e))})},cancel:()=>{u.abort(bv),e.pending.delete(u)},throwIfCancelled:()=>{Dv(u.signal)}})))}catch(e){e instanceof Sv||Hv(o,e,{raisedBy:`effect`})}finally{await Promise.all(f),u.abort(xv),i(e),e.pending.delete(u)}},d=Vv(t,n);return{middleware:e=>n=>r=>{if(!pg(r))return n(r);if(Uv.match(r))return c(r.payload);if(Wv.match(r)){d();return}if(Gv.match(r))return l(r.payload);let i=e.getState(),a=()=>{if(i===Nv)throw Error(Jv(23));return i},s;try{if(s=n(r),t.size>0){let n=e.getState(),s=Array.from(t.values());for(let t of s){let s=!1;try{s=t.predicate(r,n,i)}catch(e){s=!1,Hv(o,e,{raisedBy:`predicate`})}s&&u(t,r,e,a)}}}finally{i=Nv}return s},startListening:c,stopListening:l,clearListeners:d}};function Jv(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Yv=sv({name:`chartLayout`,initialState:{layoutType:`horizontal`,width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){e.margin.top=t.payload.top??0,e.margin.right=t.payload.right??0,e.margin.bottom=t.payload.bottom??0,e.margin.left=t.payload.left??0},setScale(e,t){e.scale=t.payload}}}),Xv=Yv.actions,Zv=Xv.setMargin,Qv=Xv.setLayout,$v=Xv.setChartSize,ey=Xv.setScale,ty=Yv.reducer;function ny(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function ry(e){return Number.isFinite(e)}function iy(e){return typeof e==`number`&&e>0&&Number.isFinite(e)}function ay(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function oy(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ay(Object(n),!0).forEach(function(t){sy(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ay(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function sy(e,t,n){return(t=cy(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cy(e){var t=ly(e,`string`);return typeof t==`symbol`?t:t+``}function ly(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function uy(e,t,n){return hp(e)||hp(t)?n:cp(t)?ep(e,t,n):typeof t==`function`?t(e):n}var dy=(e,t,n)=>{if(t&&n){var r=n.width,i=n.height,a=t.align,o=t.verticalAlign,s=t.layout;if((s===`vertical`||s===`horizontal`&&o===`middle`)&&a!==`center`&&X(e[a]))return oy(oy({},e),{},{[a]:e[a]+(r||0)});if((s===`horizontal`||s===`vertical`&&a===`center`)&&o!==`middle`&&X(e[o]))return oy(oy({},e),{},{[o]:e[o]+(i||0)})}return e},fy=(e,t)=>e===`horizontal`&&t===`xAxis`||e===`vertical`&&t===`yAxis`||e===`centric`&&t===`angleAxis`||e===`radial`&&t===`radiusAxis`,py=(e,t,n,r)=>{if(r)return e.map(e=>e.coordinate);var i,a,o=e.map(e=>(e.coordinate===t&&(i=!0),e.coordinate===n&&(a=!0),e.coordinate));return i||o.push(t),a||o.push(n),o},my=(e,t,n)=>{if(!e)return null;var r=e.duplicateDomain,i=e.type,a=e.range,o=e.scale,s=e.realScaleType,c=e.isCategorical,l=e.categoricalDomain,u=e.tickCount,d=e.ticks,f=e.niceTicks,p=e.axisType;if(!o)return null;var m=s===`scaleBand`&&o.bandwidth?o.bandwidth()/2:2,h=(t||n)&&i===`category`&&o.bandwidth?o.bandwidth()/m:0;return h=p===`angleAxis`&&a&&a.length>=2?ap(a[0]-a[1])*2*h:h,t&&(d||f)?(d||f||[]).map((e,t)=>{var n=r?r.indexOf(e):e,i=o.map(n);return ry(i)?{coordinate:i+h,value:e,offset:h,index:t}:null}).filter(_p):c&&l?l.map((e,t)=>{var n=o.map(e);return ry(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(_p):o.ticks&&!n&&u!=null?o.ticks(u).map((e,t)=>{var n=o.map(e);return ry(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(_p):o.domain().map((e,t)=>{var n=o.map(e);return ry(n)?{coordinate:n+h,value:r?r[e]:e,index:t,offset:h}:null}).filter(_p)},hy=(e,t)=>{if(!t||t.length!==2||!X(t[0])||!X(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),i=[e[0],e[1]];return(!X(e[0])||e[0]<n)&&(i[0]=n),(!X(e[1])||e[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},gy={sign:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r<n;++r)for(var i=0,a=0,o=0;o<t;++o){var s=e[o]?.[r];if(s!=null){var c=s[1],l=s[0],u=op(c)?l:c;u>=0?(s[0]=i,i+=u,s[1]=i):(s[0]=a,a+=u,s[1]=a)}}}},expand:Kf,none:Vf,silhouette:qf,wiggle:Jf,positive:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r<n;++r)for(var i=0,a=0;a<t;++a){var o=e[a]?.[r];if(o!=null){var s=op(o[1])?o[0]:o[1];s>=0?(o[0]=i,i+=s,o[1]=i):(o[0]=0,o[1]=0)}}}}},_y=(e,t,n)=>{var r=gy[n]??Vf,i=Gf().keys(t).value((e,t)=>Number(uy(e,t,0))).order(Hf).offset(r)(e);return i.forEach((n,r)=>{n.forEach((n,i)=>{var a=uy(e[i],t[r],0);Array.isArray(a)&&a.length===2&&X(a[0])&&X(a[1])&&(n[0]=a[0],n[1]=a[1])})}),i};function vy(e){return e==null?void 0:String(e)}function yy(e){var t=e.axis,n=e.ticks,r=e.bandSize,i=e.entry,a=e.index,o=e.dataKey;if(t.type===`category`){if(!t.allowDuplicatedCategory&&t.dataKey&&!hp(i[t.dataKey])){var s=mp(n,`value`,i[t.dataKey]);if(s)return s.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var c=uy(i,hp(o)?t.dataKey:o),l=t.scale.map(c);return X(l)?l:null}var by=e=>{var t=e.axis,n=e.ticks,r=e.offset,i=e.bandSize,a=e.entry,o=e.index;if(t.type===`category`)return n[o]?n[o].coordinate+r:null;var s=uy(a,t.dataKey,t.scale.domain()[o]);if(hp(s))return null;var c=t.scale.map(s);return X(c)?c-i/2+r:null},xy=e=>{var t=e.numericAxis,n=t.scale.domain();if(t.type===`number`){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},Sy=e=>{var t=e.flat(2).filter(X);return[Math.min(...t),Math.max(...t)]},Cy=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],wy=(e,t,n)=>{if(!(e==null||Object.keys(e).length===0))return Cy(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var o=a.stackedData.reduce((e,r)=>{var i=Sy(ny(r,t,n));return!ry(i[0])||!ry(i[1])?e:[Math.min(e[0],i[0]),Math.max(e[1],i[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},Ty=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Ey=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Dy=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=Hh(t,e=>e.coordinate),a=1/0,o=1,s=i.length;o<s;o++){var c=i[o],l=i[o-1];a=Math.min((c?.coordinate||0)-(l?.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function Oy(e){var t=e.tooltipEntrySettings,n=e.dataKey,r=e.payload,i=e.value,a=e.name;return oy(oy({},t),{},{dataKey:n,payload:r,value:i,name:a})}function ky(e,t){if(e!=null)return String(e);if(typeof t==`string`)return t}var Ay=(e,t)=>{if(t===`horizontal`)return e.relativeX;if(t===`vertical`)return e.relativeY},jy=(e,t)=>t===`centric`?e.angle:e.radius,My=e=>e.layout.width,Ny=e=>e.layout.height,Py=e=>e.layout.scale,Fy=e=>e.layout.margin,Iy=Q(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Ly=Q(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),Ry=`data-recharts-item-index`,zy=`data-recharts-item-id`;function By(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Vy(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?By(Object(n),!0).forEach(function(t){Hy(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):By(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Hy(e,t,n){return(t=Uy(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Uy(e){var t=Wy(e,`string`);return typeof t==`symbol`?t:t+``}function Wy(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Gy=e=>e.brush.height;function Ky(e){return Ly(e).reduce((e,t)=>t.orientation===`left`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function qy(e){return Ly(e).reduce((e,t)=>t.orientation===`right`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Jy(e){return Iy(e).reduce((e,t)=>t.orientation===`top`&&!t.mirror&&!t.hide?e+t.height:e,0)}function Yy(e){return Iy(e).reduce((e,t)=>t.orientation===`bottom`&&!t.mirror&&!t.hide?e+t.height:e,0)}var Xy=Q([My,Ny,Fy,Gy,Ky,qy,Jy,Yy,Uh,Wh],(e,t,n,r,i,a,o,s,c,l)=>{var u={left:(n.left||0)+i,right:(n.right||0)+a},d=Vy(Vy({},{top:(n.top||0)+o,bottom:(n.bottom||0)+s}),u),f=d.bottom;d.bottom+=r,d=dy(d,c,l);var p=e-d.left-d.right,m=t-d.top-d.bottom;return Vy(Vy({brushBottom:f},d),{},{width:Math.max(p,0),height:Math.max(m,0)})}),Zy=Q(Xy,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),Qy=Q(My,Ny,(e,t)=>({x:0,y:0,width:e,height:t})),$y=(0,S.createContext)(null),eb=()=>(0,S.useContext)($y)!=null,tb=e=>e.brush,nb=Q([tb,Xy,Fy],(e,t,n)=>({height:e.height,x:X(e.x)?e.x:t.left,y:X(e.y)?e.y:t.top+t.height+t.brushBottom-(n?.bottom||0),width:X(e.width)?e.width:t.width}));function rb(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}function ib(e,t=0,n={}){typeof n!=`object`&&(n={});let{leading:r=!1,trailing:i=!0,maxWait:a}=n,o=[,,];r&&(o[0]=`leading`),i&&(o[1]=`trailing`);let s,c=null,l=rb(function(...t){s=e.apply(this,t),c=null},t,{edges:o}),u=function(...t){return a!=null&&(c===null&&(c=Date.now()),Date.now()-c>=a)?(s=e.apply(this,t),c=Date.now(),l.cancel(),l.schedule(),s):(l.apply(this,t),s)};return u.cancel=l.cancel,u.flush=()=>(l.flush(),s),u}function ab(e,t=0,n={}){let{leading:r=!0,trailing:i=!0}=n;return ib(e,t,{leading:r,maxWait:t,trailing:i})}var ob=function(e,t){var n=[...arguments].slice(2);if(typeof console<`u`&&console.warn&&(t===void 0&&console.warn(`LogUtils requires an error message argument`),!e))if(t===void 0)console.warn(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var r=0;console.warn(t.replace(/%s/g,()=>n[r++]))}},sb={width:`100%`,height:`100%`,debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},cb=(e,t,n)=>{var r=n.width,i=r===void 0?sb.width:r,a=n.height,o=a===void 0?sb.height:a,s=n.aspect,c=n.maxHeight,l=sp(i)?e:Number(i),u=sp(o)?t:Number(o);return s&&s>0&&(l?u=l/s:u&&(l=u*s),c&&u!=null&&u>c&&(u=c)),{calculatedWidth:l,calculatedHeight:u}},lb={width:0,height:0,overflow:`visible`},ub={width:0,overflowX:`visible`},db={height:0,overflowY:`visible`},fb={},pb=e=>{var t=e.width,n=e.height,r=sp(t),i=sp(n);return r&&i?lb:r?ub:i?db:fb};function mb(e){var t=e.width,n=e.height,r=e.aspect,i=t,a=n;return i===void 0&&a===void 0?(i=sb.width,a=sb.height):i===void 0?i=r&&r>0?void 0:sb.width:a===void 0&&(a=r&&r>0?void 0:sb.height),{width:i,height:a}}var hb=[`aspect`,`initialDimension`,`width`,`height`,`minWidth`,`minHeight`,`maxHeight`,`children`,`debounce`,`id`,`className`,`onResize`,`style`];function gb(){return gb=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gb.apply(null,arguments)}function _b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function vb(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?_b(Object(n),!0).forEach(function(t){yb(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_b(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function yb(e,t,n){return(t=bb(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bb(e){var t=xb(e,`string`);return typeof t==`symbol`?t:t+``}function xb(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Sb(e,t){return Db(e)||Eb(e,t)||wb(e,t)||Cb()}function Cb(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wb(e,t){if(e){if(typeof e==`string`)return Tb(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Tb(e,t):void 0}}function Tb(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Eb(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Db(e){if(Array.isArray(e))return e}function Ob(e,t){if(e==null)return{};var n,r,i=kb(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function kb(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Ab=(0,S.createContext)(sb.initialDimension);function jb(e){return iy(e.width)&&iy(e.height)}function Mb(e){var t=e.children,n=e.width,r=e.height,i=(0,S.useMemo)(()=>({width:n,height:r}),[n,r]);return jb(i)?S.createElement(Ab.Provider,{value:i},t):null}var Nb=()=>(0,S.useContext)(Ab),Pb=(0,S.forwardRef)((e,t)=>{var n=e.aspect,r=e.initialDimension,i=r===void 0?sb.initialDimension:r,a=e.width,o=e.height,s=e.minWidth,c=s===void 0?sb.minWidth:s,l=e.minHeight,u=e.maxHeight,d=e.children,f=e.debounce,p=f===void 0?sb.debounce:f,m=e.id,h=e.className,g=e.onResize,_=e.style,v=_===void 0?{}:_,y=Ob(e,hb),b=(0,S.useRef)(null),x=(0,S.useRef)();x.current=g,(0,S.useImperativeHandle)(t,()=>b.current);var C=Sb((0,S.useState)({containerWidth:i.width,containerHeight:i.height}),2),w=C[0],T=C[1],E=(0,S.useCallback)((e,t)=>{T(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]);(0,S.useEffect)(()=>{if(b.current==null||typeof ResizeObserver>`u`)return vp;var e=e=>{var t,n=e[0];if(n!=null){var r=n.contentRect,i=r.width,a=r.height;E(i,a),(t=x.current)==null||t.call(x,i,a)}};p>0&&(e=ab(e,p,{trailing:!0,leading:!1}));var t=new ResizeObserver(e),n=b.current.getBoundingClientRect(),r=n.width,i=n.height;return E(r,i),t.observe(b.current),()=>{t.disconnect()}},[E,p]);var D=w.containerWidth,O=w.containerHeight;ob(!n||n>0,`The aspect(%s) must be greater than zero.`,n);var k=cb(D,O,{width:a,height:o,aspect:n,maxHeight:u}),A=k.calculatedWidth,j=k.calculatedHeight;return ob(D<0||O<0||A!=null&&A>0||j!=null&&j>0,`The width(%s) and height(%s) of chart should be greater than 0,
please check the style of container, or the props width(%s) and height(%s),
or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
height and width.`,A,j,a,o,c,l,n),S.createElement(`div`,gb({id:m?`${m}`:void 0,className:ld(`recharts-responsive-container`,h),style:vb(vb({},v),{},{width:a,height:o,minWidth:c,minHeight:l,maxHeight:u}),ref:b},y),S.createElement(`div`,{style:pb({width:a,height:o})},S.createElement(Mb,{width:A,height:j},d)))}),Fb=(0,S.forwardRef)((e,t)=>{var n=Nb();if(iy(n.width)&&iy(n.height))return e.children;var r=mb({width:e.width,height:e.height,aspect:e.aspect}),i=r.width,a=r.height,o=cb(void 0,void 0,{width:i,height:a,aspect:e.aspect,maxHeight:e.maxHeight}),s=o.calculatedWidth,c=o.calculatedHeight;return X(s)&&X(c)?S.createElement(Mb,{width:s,height:c},e.children):S.createElement(Pb,gb({},e,{width:i,height:a,ref:t}))});function Ib(e){if(e)return{x:e.x,y:e.y,upperWidth:`upperWidth`in e?e.upperWidth:e.width,lowerWidth:`lowerWidth`in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var Lb=()=>{var e=eb(),t=Z(Zy),n=Z(nb),r=Z(tb)?.padding;return!e||!n||!r?t:{width:n.width-r.left-r.right,height:n.height-r.top-r.bottom,x:r.left,y:r.top}},Rb={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},zb=()=>Z(Xy)??Rb,Bb=()=>Z(My),Vb=()=>Z(Ny),Hb=()=>Z(e=>e.layout.margin),Ub=e=>e.layout.layoutType,Wb=()=>Z(Ub),Gb=()=>{var e=Wb();if(e===`horizontal`||e===`vertical`)return e},Kb=e=>{var t=e.layout.layoutType;if(t===`centric`||t===`radial`)return t},qb=()=>Z(Kb),Jb=()=>Wb()!==void 0,Yb=e=>{var t=gh(),n=eb(),r=e.width,i=e.height,a=Nb(),o=r,s=i;return a&&(o=a.width>0?a.width:r,s=a.height>0?a.height:i),(0,S.useEffect)(()=>{!n&&iy(o)&&iy(s)&&t($v({width:o,height:s}))},[t,n,o,s]),null},Xb=Symbol.for(`immer-nothing`),Zb=Symbol.for(`immer-draftable`),Qb=Symbol.for(`immer-state`);function $b(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ex=Object.getPrototypeOf;function tx(e){return!!e&&!!e[Qb]}function nx(e){return e?ax(e)||Array.isArray(e)||!!e[Zb]||!!e.constructor?.[Zb]||dx(e)||fx(e):!1}var rx=Object.prototype.constructor.toString(),ix=new WeakMap;function ax(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;let n=Object.hasOwnProperty.call(t,`constructor`)&&t.constructor;if(n===Object)return!0;if(typeof n!=`function`)return!1;let r=ix.get(n);return r===void 0&&(r=Function.toString.call(n),ix.set(n,r)),r===rx}function ox(e,t,n=!0){sx(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function sx(e){let t=e[Qb];return t?t.type_:Array.isArray(e)?1:dx(e)?2:fx(e)?3:0}function cx(e,t){return sx(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function lx(e,t,n){let r=sx(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function ux(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}function dx(e){return e instanceof Map}function fx(e){return e instanceof Set}function px(e){return e.copy_||e.base_}function mx(e,t){if(dx(e))return new Map(e);if(fx(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=ax(e);if(t===!0||t===`class_only`&&!n){let t=Object.getOwnPropertyDescriptors(e);delete t[Qb];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){let i=n[r],a=t[i];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(t[i]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[i]})}return Object.create(ex(e),t)}else{let t=ex(e);if(t!==null&&n)return{...e};let r=Object.create(t);return Object.assign(r,e)}}function hx(e,t=!1){return vx(e)||tx(e)||!nx(e)?e:(sx(e)>1&&Object.defineProperties(e,{set:_x,add:_x,clear:_x,delete:_x}),Object.freeze(e),t&&Object.values(e).forEach(e=>hx(e,!0)),e)}function gx(){$b(2)}var _x={value:gx};function vx(e){return typeof e!=`object`||!e?!0:Object.isFrozen(e)}var yx={};function bx(e){let t=yx[e];return t||$b(0,e),t}var xx;function Sx(){return xx}function Cx(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function wx(e,t){t&&(bx(`Patches`),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Tx(e){Ex(e),e.drafts_.forEach(Ox),e.drafts_=null}function Ex(e){e===xx&&(xx=e.parent_)}function Dx(e){return xx=Cx(xx,e)}function Ox(e){let t=e[Qb];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function kx(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[Qb].modified_&&(Tx(t),$b(4)),nx(e)&&(e=Ax(t,e),t.parent_||Mx(t,e)),t.patches_&&bx(`Patches`).generateReplacementPatches_(n[Qb].base_,e,t.patches_,t.inversePatches_)):e=Ax(t,n,[]),Tx(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===Xb?void 0:e}function Ax(e,t,n){if(vx(t))return t;let r=e.immer_.shouldUseStrictIteration(),i=t[Qb];if(!i)return ox(t,(r,a)=>jx(e,i,t,r,a,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return Mx(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;let t=i.copy_,a=t,o=!1;i.type_===3&&(a=new Set(t),t.clear(),o=!0),ox(a,(r,a)=>jx(e,i,t,r,a,n,o),r),Mx(e,t,!1),n&&e.patches_&&bx(`Patches`).generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function jx(e,t,n,r,i,a,o){if(i==null||typeof i!=`object`&&!o)return;let s=vx(i);if(!(s&&!o)){if(tx(i)){let o=Ax(e,i,a&&t&&t.type_!==3&&!cx(t.assigned_,r)?a.concat(r):void 0);if(lx(n,r,o),tx(o))e.canAutoFreeze_=!1;else return}else o&&n.add(i);if(nx(i)&&!s){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&s)return;Ax(e,i),(!t||!t.scope_.parent_)&&typeof r!=`symbol`&&(dx(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&Mx(e,i)}}}function Mx(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&hx(t,n)}function Nx(e,t){let n=Array.isArray(e),r={type_:+!!n,scope_:t?t.scope_:Sx(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},i=r,a=Px;n&&(i=[r],a=Fx);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,s}var Px={get(e,t){if(t===Qb)return e;let n=px(e);if(!cx(n,t))return Lx(e,n,t);let r=n[t];return e.finalized_||!nx(r)?r:r===Ix(e.base_,t)?(Bx(e),e.copy_[t]=Hx(r,e)):r},has(e,t){return t in px(e)},ownKeys(e){return Reflect.ownKeys(px(e))},set(e,t,n){let r=Rx(px(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=Ix(px(e),t),i=r?.[Qb];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(ux(n,r)&&(n!==void 0||cx(e.base_,t)))return!0;Bx(e),zx(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_[t]=!0,!0)},deleteProperty(e,t){return Ix(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Bx(e),zx(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=px(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!==`length`,enumerable:r.enumerable,value:n[t]}},defineProperty(){$b(11)},getPrototypeOf(e){return ex(e.base_)},setPrototypeOf(){$b(12)}},Fx={};ox(Px,(e,t)=>{Fx[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),Fx.deleteProperty=function(e,t){return Fx.set.call(this,e,t,void 0)},Fx.set=function(e,t,n){return Px.set.call(this,e[0],t,n,e[0])};function Ix(e,t){let n=e[Qb];return(n?px(n):e)[t]}function Lx(e,t,n){let r=Rx(t,n);return r?`value`in r?r.value:r.get?.call(e.draft_):void 0}function Rx(e,t){if(!(t in e))return;let n=ex(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=ex(n)}}function zx(e){e.modified_||(e.modified_=!0,e.parent_&&zx(e.parent_))}function Bx(e){e.copy_||=mx(e.base_,e.scope_.immer_.useStrictShallowCopy_)}var Vx=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,t,n)=>{if(typeof e==`function`&&typeof t!=`function`){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}typeof t!=`function`&&$b(6),n!==void 0&&typeof n!=`function`&&$b(7);let r;if(nx(e)){let i=Dx(this),a=Hx(e,void 0),o=!0;try{r=t(a),o=!1}finally{o?Tx(i):Ex(i)}return wx(i,n),kx(r,i)}else if(!e||typeof e!=`object`){if(r=t(e),r===void 0&&(r=e),r===Xb&&(r=void 0),this.autoFreeze_&&hx(r,!0),n){let t=[],i=[];bx(`Patches`).generateReplacementPatches_(e,r,t,i),n(t,i)}return r}else $b(1,e)},this.produceWithPatches=(e,t)=>{if(typeof e==`function`)return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},typeof e?.autoFreeze==`boolean`&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy==`boolean`&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof e?.useStrictIteration==`boolean`&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){nx(e)||$b(8),tx(e)&&(e=Ux(e));let t=Dx(this),n=Hx(e,void 0);return n[Qb].isManual_=!0,Ex(t),n}finishDraft(e,t){let n=e&&e[Qb];(!n||!n.isManual_)&&$b(9);let{scope_:r}=n;return wx(r,t),kx(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=bx(`Patches`).applyPatches_;return tx(e)?r(e,t):this.produce(e,e=>r(e,t))}};function Hx(e,t){let n=dx(e)?bx(`MapSet`).proxyMap_(e,t):fx(e)?bx(`MapSet`).proxySet_(e,t):Nx(e,t);return(t?t.scope_:Sx()).drafts_.push(n),n}function Ux(e){return tx(e)||$b(10,e),Wx(e)}function Wx(e){if(!nx(e)||vx(e))return e;let t=e[Qb],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=mx(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=mx(e,!0);return ox(n,(e,t)=>{lx(n,e,Wx(t))},r),t&&(t.finalized_=!1),n}new Vx().produce;function Gx(e){return e}var Kx=sv({name:`legend`,initialState:{settings:{layout:`horizontal`,align:`center`,verticalAlign:`bottom`,itemSorter:`value`},size:{width:0,height:0},payload:[]},reducers:{setLegendSize(e,t){e.size.width=t.payload.width,e.size.height=t.payload.height},setLegendSettings(e,t){e.settings.align=t.payload.align,e.settings.layout=t.payload.layout,e.settings.verticalAlign=t.payload.verticalAlign,e.settings.itemSorter=t.payload.itemSorter},addLegendPayload:{reducer(e,t){e.payload.push(Gx(t.payload))},prepare:K_()},replaceLegendPayload:{reducer(e,t){var n=t.payload,r=n.prev,i=n.next,a=M_(e).payload.indexOf(Gx(r));a>-1&&(e.payload[a]=Gx(i))},prepare:K_()},removeLegendPayload:{reducer(e,t){var n=M_(e).payload.indexOf(Gx(t.payload));n>-1&&e.payload.splice(n,1)},prepare:K_()}}}),qx=Kx.actions,Jx=qx.setLegendSize,Yx=qx.setLegendSettings,Xx=qx.addLegendPayload,Zx=qx.replaceLegendPayload,Qx=qx.removeLegendPayload,$x=Kx.reducer,eS=o((e=>{var t=d();t.useSyncExternalStore,t.useRef,t.useEffect,t.useMemo,t.useDebugValue}));o(((e,t)=>{t.exports=eS()}))();function tS(e){e()}function nS(){let e=null,t=null;return{clear(){e=null,t=null},notify(){tS(()=>{let t=e;for(;t;)t.callback(),t=t.next})},get(){let t=[],n=e;for(;n;)t.push(n),n=n.next;return t},subscribe(n){let r=!0,i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var rS={notify(){},get:()=>[]};function iS(e,t){let n,r=rS,i=0,a=!1;function o(e){u();let t=r.subscribe(e),n=!1;return()=>{n||(n=!0,t(),d())}}function s(){r.notify()}function c(){m.onStateChange&&m.onStateChange()}function l(){return a}function u(){i++,n||(n=t?t.addNestedSub(c):e.subscribe(c),r=nS())}function d(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=rS)}function f(){a||(a=!0,u())}function p(){a&&(a=!1,d())}let m={addNestedSub:o,notifyNestedSubs:s,handleChangeWrapper:c,isSubscribed:l,trySubscribe:f,tryUnsubscribe:p,getListeners:()=>r};return m}var aS=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,oS=typeof navigator<`u`&&navigator.product===`ReactNative`,sS=aS||oS?S.useLayoutEffect:S.useEffect;function cS(e,t){return e===t?e!==0||t!==0||1/e==1/t:e!==e&&t!==t}function lS(e,t){if(cS(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!cS(e[n[r]],t[n[r]]))return!1;return!0}var uS=Symbol.for(`react-redux-context`),dS=typeof globalThis<`u`?globalThis:{};function fS(){if(!S.createContext)return{};let e=dS[uS]??=new Map,t=e.get(S.createContext);return t||(t=S.createContext(null),e.set(S.createContext,t)),t}var pS=fS();function mS(e){let{children:t,context:n,serverState:r,store:i}=e,a=S.useMemo(()=>({store:i,subscription:iS(i),getServerState:r?()=>r:void 0}),[i,r]),o=S.useMemo(()=>i.getState(),[i]);sS(()=>{let{subscription:e}=a;return e.onStateChange=e.notifyNestedSubs,e.trySubscribe(),o!==i.getState()&&e.notifyNestedSubs(),()=>{e.tryUnsubscribe(),e.onStateChange=void 0}},[a,o]);let s=n||pS;return S.createElement(s.Provider,{value:a},t)}var hS=mS,gS=new Set([`axisLine`,`tickLine`,`activeBar`,`activeDot`,`activeLabel`,`activeShape`,`allowEscapeViewBox`,`background`,`cursor`,`dot`,`label`,`line`,`margin`,`padding`,`position`,`shape`,`style`,`tick`,`wrapperStyle`,`radius`,`throttledEvents`]);function _S(e,t){return e==null&&t==null?!0:typeof e==`number`&&typeof t==`number`?e===t||e!==e&&t!==t:e===t}function vS(e,t){for(var n of new Set([...Object.keys(e),...Object.keys(t)]))if(gS.has(n)){if(e[n]==null&&t[n]==null)continue;if(!lS(e[n],t[n]))return!1}else if(!_S(e[n],t[n]))return!1;return!0}var yS=h(),bS=[`contextPayload`];function xS(){return xS=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xS.apply(null,arguments)}function SS(e,t){return DS(e)||ES(e,t)||wS(e,t)||CS()}function CS(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wS(e,t){if(e){if(typeof e==`string`)return TS(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?TS(e,t):void 0}}function TS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ES(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function DS(e){if(Array.isArray(e))return e}function OS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kS(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?OS(Object(n),!0).forEach(function(t){AS(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):OS(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function AS(e,t,n){return(t=jS(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jS(e){var t=MS(e,`string`);return typeof t==`symbol`?t:t+``}function MS(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function NS(e,t){if(e==null)return{};var n,r,i=PS(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function PS(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function FS(e){return e.value}function IS(e){var t=e.contextPayload,n=NS(e,bS),r=ch(t,e.payloadUniqBy,FS),i=kS(kS({},n),{},{payload:r});return S.isValidElement(e.content)?S.cloneElement(e.content,i):typeof e.content==`function`?S.createElement(e.content,i):S.createElement(tm,i)}function LS(e,t,n,r,i,a){var o=t.layout,s=t.align,c=t.verticalAlign,l,u;return(!e||(e.left===void 0||e.left===null)&&(e.right===void 0||e.right===null))&&(l=s===`center`&&o===`vertical`?{left:((r||0)-a.width)/2}:s===`right`?{right:n&&n.right||0}:{left:n&&n.left||0}),(!e||(e.top===void 0||e.top===null)&&(e.bottom===void 0||e.bottom===null))&&(u=c===`middle`?{top:((i||0)-a.height)/2}:c===`bottom`?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),kS(kS({},l),u)}function RS(e){var t=e.align,n=e.layout,r=e.verticalAlign,i=e.itemSorter,a=gh();return(0,S.useLayoutEffect)(()=>{a(Yx({align:t,layout:n,verticalAlign:r,itemSorter:i}))},[a,t,n,r,i]),null}function zS(e){var t=e.width,n=e.height,r=gh();return(0,S.useLayoutEffect)(()=>{r(Jx({width:t,height:n}))},[r,t,n]),(0,S.useLayoutEffect)(()=>()=>{r(Jx({width:0,height:0}))},[r]),null}function BS(e,t,n,r){return e===`vertical`&&t!=null?{height:t}:e===`horizontal`?{width:n||r}:null}var VS={align:`center`,iconSize:14,inactiveColor:`#ccc`,itemSorter:`value`,labelStyle:{},layout:`horizontal`,verticalAlign:`bottom`};function HS(e){var t=Up(e,VS),n=Kh(),r=sd(),i=Hb(),a=t.width,o=t.height,s=t.wrapperStyle,c=t.portal,l=SS(ng([n]),2),u=l[0],d=l[1],f=Bb(),p=Vb();if(f==null||p==null)return null;var m=f-(i?.left||0)-(i?.right||0),h=BS(t.layout,o,a,m),g=c?s:kS(kS({position:`absolute`,width:h?.width||a||`auto`,height:h?.height||o||`auto`},LS(s,t,i,f,p,u)),s),_=c??r;return _==null||n==null?null:(0,yS.createPortal)(S.createElement(`div`,{className:`recharts-legend-wrapper`,style:g,ref:d},S.createElement(RS,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!c&&S.createElement(zS,{width:u.width,height:u.height}),S.createElement(IS,xS({},t,h,{margin:i,chartWidth:f,chartHeight:p,contextPayload:n}))),_)}var US=S.memo(HS,vS);US.displayName=`Legend`;function WS(){return WS=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},WS.apply(null,arguments)}function GS(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function KS(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?GS(Object(n),!0).forEach(function(t){qS(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):GS(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qS(e,t,n){return(t=JS(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function JS(e){var t=YS(e,`string`);return typeof t==`symbol`?t:t+``}function YS(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function XS(e,t){return tC(e)||eC(e,t)||QS(e,t)||ZS()}function ZS(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function QS(e,t){if(e){if(typeof e==`string`)return $S(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$S(e,t):void 0}}function $S(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eC(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function tC(e){if(Array.isArray(e))return e}function nC(e){return Array.isArray(e)&&cp(e[0])&&cp(e[1])?e.join(` ~ `):e}var rC={separator:` : `,contentStyle:{margin:0,padding:10,backgroundColor:`#fff`,border:`1px solid #ccc`,whiteSpace:`nowrap`},itemStyle:{display:`block`,paddingTop:4,paddingBottom:4,color:`#000`},labelStyle:{},accessibilityLayer:!1};function iC(e,t){return t==null?e:Hh(e,t)}var aC=e=>{var t=e.separator,n=t===void 0?rC.separator:t,r=e.contentStyle,i=e.itemStyle,a=e.labelStyle,o=a===void 0?rC.labelStyle:a,s=e.payload,c=e.formatter,l=e.itemSorter,u=e.wrapperClassName,d=e.labelClassName,f=e.label,p=e.labelFormatter,m=e.accessibilityLayer,h=m===void 0?rC.accessibilityLayer:m,g=()=>{if(s&&s.length){var e={padding:0,margin:0},t=iC(s,l).map((e,t)=>{if(!e||e.type===`none`)return null;var r=e.formatter||c||nC,a=e.value,o=e.name,l=a,u=o;if(r){var d=r(a,o,e,t,s);if(Array.isArray(d)){var f=XS(d,2);l=f[0],u=f[1]}else if(d!=null)l=d;else return null}var p=KS(KS({},rC.itemStyle),{},{color:e.color||rC.itemStyle.color},i);return S.createElement(`li`,{className:`recharts-tooltip-item`,key:`tooltip-item-${t}`,style:p},cp(u)?S.createElement(`span`,{className:`recharts-tooltip-item-name`},u):null,cp(u)?S.createElement(`span`,{className:`recharts-tooltip-item-separator`},n):null,S.createElement(`span`,{className:`recharts-tooltip-item-value`},l),S.createElement(`span`,{className:`recharts-tooltip-item-unit`},e.unit||``))});return S.createElement(`ul`,{className:`recharts-tooltip-item-list`,style:e},t)}return null},_=KS(KS({},rC.contentStyle),r),v=KS({margin:0},o),y=!hp(f),b=y?f:``,x=ld(`recharts-default-tooltip`,u),C=ld(`recharts-tooltip-label`,d);y&&p&&s!=null&&(b=p(f,s));var w=h?{role:`status`,"aria-live":`assertive`}:{};return S.createElement(`div`,WS({className:x,style:_},w),S.createElement(`p`,{className:C,style:v},S.isValidElement(b)?b:`${b}`),g())},oC=`recharts-tooltip-wrapper`,sC={visibility:`hidden`};function cC(e){var t=e.coordinate,n=e.translateX,r=e.translateY;return ld(oC,{[`${oC}-right`]:X(n)&&t&&X(t.x)&&n>=t.x,[`${oC}-left`]:X(n)&&t&&X(t.x)&&n<t.x,[`${oC}-bottom`]:X(r)&&t&&X(t.y)&&r>=t.y,[`${oC}-top`]:X(r)&&t&&X(t.y)&&r<t.y})}function lC(e){var t=e.allowEscapeViewBox,n=e.coordinate,r=e.key,i=e.offset,a=e.position,o=e.reverseDirection,s=e.tooltipDimension,c=e.viewBox,l=e.viewBoxDimension;if(a&&X(a[r]))return a[r];var u=n[r]-s-(i>0?i:0),d=n[r]+i;if(t[r])return o[r]?u:d;var f=c[r];return f==null?0:o[r]?Math.max(u<f?d:u,f):l==null?0:d+s>f+l?Math.max(u,f):Math.max(d,f)}function uC(e){var t=e.translateX,n=e.translateY;return{transform:e.useTranslate3d?`translate3d(${t}px, ${n}px, 0)`:`translate(${t}px, ${n}px)`}}function dC(e){var t=e.allowEscapeViewBox,n=e.coordinate,r=e.offsetTop,i=e.offsetLeft,a=e.position,o=e.reverseDirection,s=e.tooltipBox,c=e.useTranslate3d,l=e.viewBox,u,d,f;return s.height>0&&s.width>0&&n?(d=lC({allowEscapeViewBox:t,coordinate:n,key:`x`,offset:i,position:a,reverseDirection:o,tooltipDimension:s.width,viewBox:l,viewBoxDimension:l.width}),f=lC({allowEscapeViewBox:t,coordinate:n,key:`y`,offset:r,position:a,reverseDirection:o,tooltipDimension:s.height,viewBox:l,viewBoxDimension:l.height}),u=uC({translateX:d,translateY:f,useTranslate3d:c})):u=sC,{cssProperties:u,cssClasses:cC({translateX:d,translateY:f,coordinate:n})}}var fC={devToolsEnabled:!0,isSsr:!(typeof window<`u`&&window.document&&window.document.createElement&&window.setTimeout)};function pC(e,t){return vC(e)||_C(e,t)||hC(e,t)||mC()}function mC(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hC(e,t){if(e){if(typeof e==`string`)return gC(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?gC(e,t):void 0}}function gC(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _C(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function vC(e){if(Array.isArray(e))return e}function yC(){var e=pC((0,S.useState)(()=>fC.isSsr||!window.matchMedia?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches),2),t=e[0],n=e[1];return(0,S.useEffect)(()=>{if(window.matchMedia){var e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>{n(e.matches)};return e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t)}}},[]),t}function bC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xC(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?bC(Object(n),!0).forEach(function(t){SC(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bC(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function SC(e,t,n){return(t=CC(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function CC(e){var t=wC(e,`string`);return typeof t==`symbol`?t:t+``}function wC(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function TC(e,t){return AC(e)||kC(e,t)||DC(e,t)||EC()}function EC(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function DC(e,t){if(e){if(typeof e==`string`)return OC(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?OC(e,t):void 0}}function OC(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function kC(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function AC(e){if(Array.isArray(e))return e}function jC(e){if(!(e.prefersReducedMotion&&e.isAnimationActive===`auto`)&&e.isAnimationActive&&e.active){var t=typeof e.animationEasing==`string`?e.animationEasing:`ease`;return`transform ${e.animationDuration}ms ${t}`}}function MC(e){var t=yC(),n=TC(S.useState(()=>({dismissed:!1,dismissedAtCoordinate:{x:0,y:0}})),2),r=n[0],i=n[1];S.useEffect(()=>{var t=t=>{t.key===`Escape`&&i({dismissed:!0,dismissedAtCoordinate:{x:e.coordinate?.x??0,y:e.coordinate?.y??0}})};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t)}},[e.coordinate?.x,e.coordinate?.y]),r.dismissed&&((e.coordinate?.x??0)!==r.dismissedAtCoordinate.x||(e.coordinate?.y??0)!==r.dismissedAtCoordinate.y)&&i(xC(xC({},r),{},{dismissed:!1}));var a=dC({allowEscapeViewBox:e.allowEscapeViewBox,coordinate:e.coordinate,offsetLeft:typeof e.offset==`number`?e.offset:e.offset.x,offsetTop:typeof e.offset==`number`?e.offset:e.offset.y,position:e.position,reverseDirection:e.reverseDirection,tooltipBox:{height:e.lastBoundingBox.height,width:e.lastBoundingBox.width},useTranslate3d:e.useTranslate3d,viewBox:e.viewBox}),o=a.cssClasses,s=a.cssProperties,c=xC(xC({},e.hasPortalFromProps?{}:xC(xC({transition:jC({prefersReducedMotion:t,isAnimationActive:e.isAnimationActive,active:e.active,animationDuration:e.animationDuration,animationEasing:e.animationEasing})},s),{},{pointerEvents:`none`,position:`absolute`,top:0,left:0})),{},{visibility:!r.dismissed&&e.active&&e.hasPayload?`visible`:`hidden`},e.wrapperStyle);return S.createElement(`div`,{xmlns:`http://www.w3.org/1999/xhtml`,tabIndex:-1,className:o,style:c,ref:e.innerRef},e.children)}var NC=S.memo(MC),PC=()=>Z(e=>e.rootProps.accessibilityLayer)??!0;function FC(){return FC=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},FC.apply(null,arguments)}function IC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function LC(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?IC(Object(n),!0).forEach(function(t){RC(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):IC(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function RC(e,t,n){return(t=zC(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function zC(e){var t=BC(e,`string`);return typeof t==`symbol`?t:t+``}function BC(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var VC={curveBasisClosed:bf,curveBasisOpen:Sf,curveBasis:vf,curveBumpX:qd,curveBumpY:Jd,curveLinearClosed:wf,curveLinear:Vd,curveMonotoneX:Mf,curveMonotoneY:Nf,curveNatural:If,curveStep:Rf,curveStepAfter:Bf,curveStepBefore:zf},HC=e=>ry(e.x)&&ry(e.y),UC=e=>e.base!=null&&HC(e.base)&&HC(e),WC=e=>e.x,GC=e=>e.y,KC=(e,t)=>{if(typeof e==`function`)return e;var n=`curve${gp(e)}`;if((n===`curveMonotone`||n===`curveBump`)&&t){var r=VC[`${n}${t===`vertical`?`Y`:`X`}`];if(r)return r}return VC[n]||Vd},qC={connectNulls:!1,type:`linear`},JC=e=>{var t=e.type,n=t===void 0?qC.type:t,r=e.points,i=r===void 0?[]:r,a=e.baseLine,o=e.layout,s=e.connectNulls,c=s===void 0?qC.connectNulls:s,l=KC(n,o),u=c?i.filter(HC):i;if(Array.isArray(a)){var d,f=i.map((e,t)=>LC(LC({},e),{},{base:a[t]}));return d=o===`vertical`?Gd().y(GC).x1(WC).x0(e=>e.base.x):Gd().x(WC).y1(GC).y0(e=>e.base.y),d.defined(UC).curve(l)(c?f.filter(UC):f)}return(o===`vertical`&&X(a)?Gd().y(GC).x1(WC).x0(a):X(a)?Gd().x(WC).y1(GC).y0(a):Wd().x(WC).y(GC)).defined(HC).curve(l)(u)},YC=e=>{var t=e.className,n=e.points,r=e.path,i=e.pathRef,a=Wb();if((!n||!n.length)&&!r)return null;var o={type:e.type,points:e.points,baseLine:e.baseLine,layout:e.layout||a,connectNulls:e.connectNulls},s=n&&n.length?JC(o):r;return S.createElement(`path`,FC({},hd(e),Fp(e),{className:ld(`recharts-curve`,t),d:s===null?void 0:s,ref:i}))},XC=[`x`,`y`,`top`,`left`,`width`,`height`,`className`];function ZC(){return ZC=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ZC.apply(null,arguments)}function QC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $C(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?QC(Object(n),!0).forEach(function(t){ew(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QC(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ew(e,t,n){return(t=tw(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tw(e){var t=nw(e,`string`);return typeof t==`symbol`?t:t+``}function nw(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function rw(e,t){if(e==null)return{};var n,r,i=iw(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function iw(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var aw=(e,t,n,r,i,a)=>`M${e},${i}v${r}M${a},${t}h${n}`,ow=e=>{var t=e.x,n=t===void 0?0:t,r=e.y,i=r===void 0?0:r,a=e.top,o=a===void 0?0:a,s=e.left,c=s===void 0?0:s,l=e.width,u=l===void 0?0:l,d=e.height,f=d===void 0?0:d,p=e.className,m=rw(e,XC),h=$C({x:n,y:i,top:o,left:c,width:u,height:f},m);return!X(n)||!X(i)||!X(u)||!X(f)||!X(o)||!X(c)?null:S.createElement(`path`,ZC({},_d(h),{className:ld(`recharts-cross`,p),d:aw(n,i,u,f,o,c)}))};function sw(e,t,n,r){var i=r/2;return{stroke:`none`,fill:`#ccc`,x:e===`horizontal`?t.x-i:n.left+.5,y:e===`horizontal`?n.top+.5:t.y-i,width:e===`horizontal`?r:n.width-1,height:e===`horizontal`?n.height-1:r}}var cw=(e,t)=>[0,3*e,3*t-6*e,3*e-3*t+1],lw=(e,t)=>e.map((e,n)=>e*t**n).reduce((e,t)=>e+t),uw=(e,t)=>n=>lw(cw(e,t),n),dw=(e,t)=>n=>lw([...cw(e,t).map((e,t)=>e*t).slice(1),0],n),fw=e=>{var t,n=e.split(`(`);if(n.length!==2||n[0]!==`cubic-bezier`)return null;var r=(t=n[1])==null||(t=t.split(`)`)[0])==null?void 0:t.split(`,`);if(r==null||r.length!==4)return null;var i=r.map(e=>parseFloat(e));return[i[0],i[1],i[2],i[3]]},pw=function(){var e=[...arguments];if(e.length===1)switch(e[0]){case`linear`:return[0,0,1,1];case`ease`:return[.25,.1,.25,1];case`ease-in`:return[.42,0,1,1];case`ease-out`:return[.42,0,.58,1];case`ease-in-out`:return[0,0,.58,1];default:var t=fw(e[0]);if(t)return t}return e.length===4?e:[0,0,1,1]},mw=(e,t,n,r)=>{var i=uw(e,n),a=uw(t,r),o=dw(e,n),s=e=>e>1?1:e<0?0:e,c=e=>{for(var t=e>1?1:e,n=t,r=0;r<8;++r){var c=i(n)-t,l=o(n);if(Math.abs(c-t)<1e-4||l<1e-4)return a(n);n=s(n-c/l)}return a(n)};return c.isStepper=!1,c},hw=function(){return mw(...pw(...arguments))},gw=function(){for(var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.stiff,n=t===void 0?100:t,r=e.damping,i=r===void 0?8:r,a=e.dt,o=a===void 0?16.67:a,s=1,c=[0],l=0,u=0,d=1e4,f=0;f<d;){var p=-(l-s)*n,m=u*i;if(u+=(p-m)*o/1e3,l+=u*o/1e3,c.push(l),Math.abs(l-s)<1e-4&&Math.abs(u)<1e-4)break;f++}c[c.length-1]=s;var h=c.length-1;return e=>{if(e<=0)return 0;if(e>=1)return s;var t=e*h,n=Math.floor(t),r=t-n;return(c[n]??0)+((c[n+1]??0)-(c[n]??0))*r}},_w=e=>{if(typeof e==`string`)switch(e){case`ease`:case`ease-in-out`:case`ease-out`:case`ease-in`:case`linear`:return hw(e);case`spring`:return gw();default:if(e.split(`(`)[0]===`cubic-bezier`)return hw(e)}return typeof e==`function`?e:null},vw=(0,S.createContext)((e,t,n)=>{var r,i=a=>{var o=t.tick(a);if(t.getState()===`active`){if(n(t.getInterpolated()),t.getProgress()===1){t.complete(),r=void 0;return}r=e.setTimeout(i,o);return}r=e.setTimeout(i,o)};return r=e.setTimeout(i,0),()=>r?.()});vw.Provider;function yw(e){var t=(0,S.useContext)(vw);return(0,S.useMemo)(()=>e??t,[e,t])}function bw(e,t,n){return(t=xw(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function xw(e){var t=Sw(e,`string`);return typeof t==`symbol`?t:t+``}function Sw(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Cw=`init`,ww=`pending`,Tw=`active`,Ew=`completed`;function Dw(e){return Math.max(0,e)}var Ow=class{getAnimationStartedTime(){return this.animationStartedTime}getBeginStartedTime(){return this.beginStartedTime}constructor(e){var t;bw(this,`state`,Cw),this.animationId=e.animationId,this.onAnimationEnd=e.onAnimationEnd,this.animationDuration=Dw(e.animationDuration),this.animationBegin=Dw(e.animationBegin),this.progress=0,this.from=e.from,this.to=e.to,this.easing=e.easing,(t=e.onAnimationStart)==null||t.call(e)}getState(){return this.state}getEasing(){return this.easing}getAnimationDuration(){return this.animationDuration}tick(e){if(this.getState()===Cw)return this.state=ww,this.beginStartedTime=e,this.animationBegin;if(this.getState()===ww){if(this.beginStartedTime==null)throw Error();var t=e-this.beginStartedTime;return t>=this.animationBegin?(this.state=Tw,this.animationStartedTime=e,this.nextAnimationUpdate(0)):Dw(this.animationBegin-t)}if(this.getState()===Tw){if(this.animationStartedTime==null)throw Error();var n=e-this.animationStartedTime;return this.setProgress(n/this.animationDuration),this.nextAnimationUpdate(n)}return 0}setProgress(e){this.progress=Math.min(1,Math.max(0,e))}getProgress(){return this.progress}complete(){if(this.progress=1,this.state===`active`){var e;(e=this.onAnimationEnd)==null||e.call(this)}this.state=Ew}getFrom(){return this.from}getTo(){return this.to}getAnimationId(){return this.animationId}getAnimationBegin(){return this.animationBegin}},kw=class extends Ow{nextAnimationUpdate(){return 0}getInterpolated(){return this.easing(pp(this.getFrom(),this.getTo(),this.getProgress()))}},Aw=class{setTimeout(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=performance.now(),r=null,i=a=>{a-n>=t?e(a):r=requestAnimationFrame(i)};return r=requestAnimationFrame(i),()=>{r!=null&&cancelAnimationFrame(r)}}};function jw(e,t){return Iw(e)||Fw(e,t)||Nw(e,t)||Mw()}function Mw(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nw(e,t){if(e){if(typeof e==`string`)return Pw(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Pw(e,t):void 0}}function Pw(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Fw(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Iw(e){if(Array.isArray(e))return e}var Lw={begin:0,duration:1e3,easing:`ease`,isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},Rw=0,zw=1;function Bw(e){var t=Up(e,Lw),n=t.animationId,r=t.isActive,i=t.canBegin,a=t.duration,o=t.easing,s=t.begin,c=t.onAnimationEnd,l=t.onAnimationStart,u=t.children,d=yC(),f=r===`auto`?!fC.isSsr&&!d:r,p=yw(t.animationController),m=jw((0,S.useState)(f?Rw:zw),2),h=m[0],g=m[1];return(0,S.useEffect)(()=>{f||g(zw)},[f]),(0,S.useEffect)(()=>{var e=_w(o);return!f||!i||e==null?vp:p(new Aw,new kw({animationId:n,easing:e,animationDuration:a,animationBegin:s,onAnimationStart:l,onAnimationEnd:c,from:Rw,to:zw}),g)},[p,n,f,i,a,o,s,l,c]),u(Number(h))}function Vw(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`animation-`,n=(0,S.useRef)(up(t)),r=(0,S.useRef)(e);return r.current!==e&&(n.current=up(t),r.current=e),n.current}var Hw=e=>e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`),Uw=(e,t,n)=>e.map(e=>`${Hw(e)} ${t}ms ${n}`).join(`,`),Ww=[`radius`],Gw=[`radius`],Kw,qw,Jw,Yw,Xw,Zw,Qw,$w,eT,tT;function nT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function rT(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?nT(Object(n),!0).forEach(function(t){iT(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nT(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function iT(e,t,n){return(t=aT(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function aT(e){var t=oT(e,`string`);return typeof t==`symbol`?t:t+``}function oT(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function sT(){return sT=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sT.apply(null,arguments)}function cT(e,t){if(e==null)return{};var n,r,i=lT(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function lT(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function uT(e,t){return hT(e)||mT(e,t)||fT(e,t)||dT()}function dT(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fT(e,t){if(e){if(typeof e==`string`)return pT(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pT(e,t):void 0}}function pT(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function mT(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function hT(e){if(Array.isArray(e))return e}function gT(e,t){return t||=e.slice(0),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var _T=(e,t,n,r,i)=>{var a=rp(n),o=rp(r),s=Math.min(Math.abs(a)/2,Math.abs(o)/2),c=o>=0?1:-1,l=a>=0?1:-1,u=+(o>=0&&a>=0||o<0&&a<0),d;if(s>0&&Array.isArray(i)){for(var f=[0,0,0,0],p=0,m=4;p<m;p++){var h=i[p]??0;f[p]=h>s?s:h}d=ip(Kw||=gT([`M`,`,`,``]),e,t+c*f[0]),f[0]>0&&(d+=ip(qw||=gT([`A `,`,`,`,0,0,`,`,`,`,`,``]),f[0],f[0],u,e+l*f[0],t)),d+=ip(Jw||=gT([`L `,`,`,``]),e+n-l*f[1],t),f[1]>0&&(d+=ip(Yw||=gT([`A `,`,`,`,0,0,`,`,
`,`,`,``]),f[1],f[1],u,e+n,t+c*f[1])),d+=ip(Xw||=gT([`L `,`,`,``]),e+n,t+r-c*f[2]),f[2]>0&&(d+=ip(Zw||=gT([`A `,`,`,`,0,0,`,`,
`,`,`,``]),f[2],f[2],u,e+n-l*f[2],t+r)),d+=ip(Qw||=gT([`L `,`,`,``]),e+l*f[3],t+r),f[3]>0&&(d+=ip($w||=gT([`A `,`,`,`,0,0,`,`,
`,`,`,``]),f[3],f[3],u,e,t+r-c*f[3])),d+=`Z`}else if(s>0&&i===+i&&i>0){var g=Math.min(s,i);d=ip(eT||=gT(`M .,.
A .,.,0,0,.,.,.
L .,.
A .,.,0,0,.,.,.
L .,.
A .,.,0,0,.,.,.
L .,.
A .,.,0,0,.,.,. Z`.split(`.`)),e,t+c*g,g,g,u,e+l*g,t,e+n-l*g,t,g,g,u,e+n,t+c*g,e+n,t+r-c*g,g,g,u,e+n-l*g,t+r,e+l*g,t+r,g,g,u,e,t+r-c*g)}else d=ip(tT||=gT([`M `,`,`,` h `,` v `,` h `,` Z`]),e,t,n,r,-n);return d},vT={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:`ease`},yT=e=>{var t=Up(e,vT),n=(0,S.useRef)(null),r=uT((0,S.useState)(-1),2),i=r[0],a=r[1];(0,S.useEffect)(()=>{if(n.current&&n.current.getTotalLength)try{var e=n.current.getTotalLength();e&&a(e)}catch{}},[]);var o=t.x,s=t.y,c=t.width,l=t.height,u=t.radius,d=t.className,f=t.animationEasing,p=t.animationDuration,m=t.animationBegin,h=t.isAnimationActive,g=t.isUpdateAnimationActive,_=(0,S.useRef)(c),v=(0,S.useRef)(l),y=(0,S.useRef)(o),b=(0,S.useRef)(s),x=Vw((0,S.useMemo)(()=>({x:o,y:s,width:c,height:l,radius:u}),[o,s,c,l,u]),`rectangle-`);if(o!==+o||s!==+s||c!==+c||l!==+l||c===0||l===0)return null;var C=ld(`recharts-rectangle`,d);if(!g){var w=_d(t);w.radius;var T=cT(w,Ww);return S.createElement(`path`,sT({},T,{x:rp(o),y:rp(s),width:rp(c),height:rp(l),radius:typeof u==`number`?u:void 0,className:C,d:_T(o,s,c,l,u)}))}var E=_.current,D=v.current,O=y.current,k=b.current,A=`0px ${i===-1?1:i}px`,j=`${i}px ${i}px`,M=Uw([`strokeDasharray`],p,typeof f==`string`?f:vT.animationEasing);return S.createElement(Bw,{animationId:x,key:x,canBegin:i>0,duration:p,easing:f,isActive:g,begin:m},e=>{var r=pp(E,c,e),i=pp(D,l,e),a=pp(O,o,e),d=pp(k,s,e);n.current&&(_.current=r,v.current=i,y.current=a,b.current=d);var f=h?e>0?{transition:M,strokeDasharray:j}:{strokeDasharray:A}:{strokeDasharray:j},p=_d(t);p.radius;var m=cT(p,Gw);return S.createElement(`path`,sT({},m,{radius:typeof u==`number`?u:void 0,className:C,d:_T(a,d,r,i,u),ref:n,style:rT(rT({},f),t.style)}))})};function bT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xT(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?bT(Object(n),!0).forEach(function(t){ST(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bT(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ST(e,t,n){return(t=CT(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function CT(e){var t=wT(e,`string`);return typeof t==`symbol`?t:t+``}function wT(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var TT=Math.PI/180,ET=e=>e*180/Math.PI,DT=(e,t,n,r)=>({x:e+Math.cos(-TT*r)*n,y:t+Math.sin(-TT*r)*n}),OT=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0,width:0,height:0,brushBottom:0};return Math.min(Math.abs(e-(n.left||0)-(n.right||0)),Math.abs(t-(n.top||0)-(n.bottom||0)))/2},kT=(e,t)=>{var n=e.x,r=e.y,i=t.x,a=t.y;return Math.sqrt((n-i)**2+(r-a)**2)},AT=(e,t)=>{var n=e.x,r=e.y,i=t.cx,a=t.cy,o=kT({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var s=(n-i)/o,c=Math.acos(s);return r>a&&(c=2*Math.PI-c),{radius:o,angle:ET(c),angleInRadian:c}},jT=e=>{var t=e.startAngle,n=e.endAngle,r=Math.floor(t/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:t-a*360,endAngle:n-a*360}},MT=(e,t)=>{var n=t.startAngle,r=t.endAngle,i=Math.floor(n/360),a=Math.floor(r/360);return e+Math.min(i,a)*360},NT=(e,t)=>{var n=e.relativeX,r=e.relativeY,i=AT({x:n,y:r},t),a=i.radius,o=i.angle,s=t.innerRadius,c=t.outerRadius;if(a<s||a>c||a===0)return null;var l=jT(t),u=l.startAngle,d=l.endAngle,f=o,p;if(u<=d){for(;f>d;)f-=360;for(;f<u;)f+=360;p=f>=u&&f<=d}else{for(;f>u;)f-=360;for(;f<d;)f+=360;p=f>=d&&f<=u}return p?xT(xT({},t),{},{radius:a,angle:MT(f,t)}):null};function PT(e){var t=e.cx,n=e.cy,r=e.radius,i=e.startAngle,a=e.endAngle;return{points:[DT(t,n,r,i),DT(t,n,r,a)],cx:t,cy:n,radius:r,startAngle:i,endAngle:a}}var FT,IT,LT,RT,zT,BT,VT;function HT(){return HT=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},HT.apply(null,arguments)}function UT(e,t){return t||=e.slice(0),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var WT=(e,t)=>ap(t-e)*Math.min(Math.abs(t-e),359.999),GT=e=>{var t=e.cx,n=e.cy,r=e.radius,i=e.angle,a=e.sign,o=e.isExternal,s=e.cornerRadius,c=e.cornerIsExternal,l=s*(o?1:-1)+r,u=Math.asin(s/l)/TT,d=c?i:i+a*u,f=DT(t,n,l,d),p=DT(t,n,r,d),m=c?i-a*u:i;return{center:f,circleTangency:p,lineTangency:DT(t,n,l*Math.cos(u*TT),m),theta:u}},KT=e=>{var t=e.cx,n=e.cy,r=e.innerRadius,i=e.outerRadius,a=e.startAngle,o=e.endAngle,s=WT(a,o),c=a+s,l=DT(t,n,i,a),u=DT(t,n,i,c),d=ip(FT||=UT([`M `,`,`,`
A `,`,`,`,0,
`,`,`,`,
`,`,`,`
`]),l.x,l.y,i,i,+(Math.abs(s)>180),+(a>c),u.x,u.y);if(r>0){var f=DT(t,n,r,a),p=DT(t,n,r,c);d+=ip(IT||=UT([`L `,`,`,`
A `,`,`,`,0,
`,`,`,`,
`,`,`,` Z`]),p.x,p.y,r,r,+(Math.abs(s)>180),+(a<=c),f.x,f.y)}else d+=ip(LT||=UT([`L `,`,`,` Z`]),t,n);return d},qT=e=>{var t=e.cx,n=e.cy,r=e.innerRadius,i=e.outerRadius,a=e.cornerRadius,o=e.forceCornerRadius,s=e.cornerIsExternal,c=e.startAngle,l=e.endAngle,u=ap(l-c),d=GT({cx:t,cy:n,radius:i,angle:c,sign:u,cornerRadius:a,cornerIsExternal:s}),f=d.circleTangency,p=d.lineTangency,m=d.theta,h=GT({cx:t,cy:n,radius:i,angle:l,sign:-u,cornerRadius:a,cornerIsExternal:s}),g=h.circleTangency,_=h.lineTangency,v=h.theta,y=s?Math.abs(c-l):Math.abs(c-l)-m-v;if(y<0)return o?ip(RT||=UT([`M `,`,`,`
a`,`,`,`,0,0,1,`,`,0
a`,`,`,`,0,0,1,`,`,0
`]),p.x,p.y,a,a,a*2,a,a,-a*2):KT({cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:l});var b=ip(zT||=UT([`M `,`,`,`
A`,`,`,`,0,0,`,`,`,`,`,`
A`,`,`,`,0,`,`,`,`,`,`,`,`
A`,`,`,`,0,0,`,`,`,`,`,`
`]),p.x,p.y,a,a,+(u<0),f.x,f.y,i,i,+(y>180),+(u<0),g.x,g.y,a,a,+(u<0),_.x,_.y);if(r>0){var x=GT({cx:t,cy:n,radius:r,angle:c,sign:u,isExternal:!0,cornerRadius:a,cornerIsExternal:s}),S=x.circleTangency,C=x.lineTangency,w=x.theta,T=GT({cx:t,cy:n,radius:r,angle:l,sign:-u,isExternal:!0,cornerRadius:a,cornerIsExternal:s}),E=T.circleTangency,D=T.lineTangency,O=T.theta,k=s?Math.abs(c-l):Math.abs(c-l)-w-O;if(k<0&&a===0)return`${b}L${t},${n}Z`;b+=ip(BT||=UT([`L`,`,`,`
A`,`,`,`,0,0,`,`,`,`,`,`
A`,`,`,`,0,`,`,`,`,`,`,`,`
A`,`,`,`,0,0,`,`,`,`,`,`Z`]),D.x,D.y,a,a,+(u<0),E.x,E.y,r,r,+(k>180),+(u>0),S.x,S.y,a,a,+(u<0),C.x,C.y)}else b+=ip(VT||=UT([`L`,`,`,`Z`]),t,n);return b},JT={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},YT=e=>{var t=Up(e,JT),n=t.cx,r=t.cy,i=t.innerRadius,a=t.outerRadius,o=t.cornerRadius,s=t.forceCornerRadius,c=t.cornerIsExternal,l=t.startAngle,u=t.endAngle,d=t.className;if(a<i||l===u)return null;var f=ld(`recharts-sector`,d),p=a-i,m=dp(o,p,0,!0),h=m>0&&Math.abs(l-u)<360?qT({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(m,p/2),forceCornerRadius:s,cornerIsExternal:c,startAngle:l,endAngle:u}):KT({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:l,endAngle:u});return S.createElement(`path`,HT({},_d(t),{className:f,d:h}))};function XT(e,t,n){if(e===`horizontal`)return[{x:t.x,y:n.top},{x:t.x,y:n.top+n.height}];if(e===`vertical`)return[{x:n.left,y:t.y},{x:n.left+n.width,y:t.y}];if(Pp(t)){if(e===`centric`){var r=t.cx,i=t.cy,a=t.innerRadius,o=t.outerRadius,s=t.angle,c=DT(r,i,a,s),l=DT(r,i,o,s);return[{x:c.x,y:c.y},{x:l.x,y:l.y}]}return PT(t)}}function ZT(e){return Lh(e)?NaN:Number(e)}function QT(e){return e?(e=ZT(e),e===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e===e?e:0):e===0?e:0}function $T(e,t,n){n&&typeof n!=`number`&&Ph(e,t,n)&&(t=n=void 0),e=QT(e),t===void 0?(t=e,e=0):t=QT(t),n=n===void 0?e<t?1:-1:QT(n);let r=Math.max(Math.ceil((t-e)/(n||1)),0),i=Array(r);for(let t=0;t<r;t++)i[t]=e,e+=n;return i}var eE=e=>e.chartData,tE=Q([eE],e=>{var t=e.chartData==null?0:e.chartData.length-1;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),nE=(e,t,n,r)=>r?tE(e):eE(e),rE=(e,t,n)=>n?tE(e):eE(e),iE=Q([nE],e=>{var t=e.chartData,n=e.dataStartIndex,r=e.dataEndIndex;return t==null?[]:t.slice(n,r+1)}),aE=Q([tE],e=>{var t=e.chartData,n=e.dataStartIndex,r=e.dataEndIndex;return t==null?[]:t.slice(n,r+1)}),oE=Q([eE],e=>{var t=e.chartData,n=e.dataStartIndex,r=e.dataEndIndex;return t==null?[]:t.slice(n,r+1)});function sE(e,t){return fE(e)||dE(e,t)||lE(e,t)||cE()}function cE(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lE(e,t){if(e){if(typeof e==`string`)return uE(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uE(e,t):void 0}}function uE(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function dE(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function fE(e){if(Array.isArray(e))return e}function pE(e){if(Array.isArray(e)&&e.length===2){var t=sE(e,2),n=t[0],r=t[1];if(ry(n)&&ry(r))return!0}return!1}function mE(e,t,n){return n?e:[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function hE(e,t){if(t&&typeof e!=`function`&&Array.isArray(e)&&e.length===2){var n=sE(e,2),r=n[0],i=n[1],a,o;if(ry(r))a=r;else if(typeof r==`function`)return;if(ry(i))o=i;else if(typeof i==`function`)return;var s=[a,o];if(pE(s))return s}}function gE(e,t,n){if(!(!n&&t==null)){if(typeof e==`function`&&t!=null)try{var r=e(t,n);if(pE(r))return mE(r,t,n)}catch{}if(Array.isArray(e)&&e.length===2){var i=sE(e,2),a=i[0],o=i[1],s,c;if(a===`auto`)t!=null&&(s=Math.min(...t));else if(X(a))s=a;else if(typeof a==`function`)try{t!=null&&(s=a(t?.[0]))}catch{}else if(typeof a==`string`&&Ty.test(a)){var l=Ty.exec(a);if(l==null||l[1]==null||t==null)s=void 0;else{var u=+l[1];s=t[0]-u}}else s=t?.[0];if(o===`auto`)t!=null&&(c=Math.max(...t));else if(X(o))c=o;else if(typeof o==`function`)try{t!=null&&(c=o(t?.[1]))}catch{}else if(typeof o==`string`&&Ey.test(o)){var d=Ey.exec(o);if(d==null||d[1]==null||t==null)c=void 0;else{var f=+d[1];c=t[1]+f}}else c=t?.[1];var p=[s,c];if(pE(p))return t==null?p:mE(p,t,n)}}}var _E=l(o(((e,t)=>{(function(e){var n=1e9,r={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},i=!0,a=`[DecimalError] `,o=a+`Invalid argument: `,s=a+`Exponent out of range: `,c=Math.floor,l=Math.pow,u=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,d,f=1e7,p=7,m=9007199254740991,h=c(m/p),g={};g.absoluteValue=g.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},g.comparedTo=g.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=r<i?r:i;t<n;++t)if(a.d[t]!==e.d[t])return a.d[t]>e.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},g.decimalPlaces=g.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*p;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},g.dividedBy=g.div=function(e){return b(this,new this.constructor(e))},g.dividedToIntegerBy=g.idiv=function(e){var t=this,n=t.constructor;return D(b(t,new n(e),0,1),n.precision)},g.equals=g.eq=function(e){return!this.cmp(e)},g.exponent=function(){return S(this)},g.greaterThan=g.gt=function(e){return this.cmp(e)>0},g.greaterThanOrEqualTo=g.gte=function(e){return this.cmp(e)>=0},g.isInteger=g.isint=function(){return this.e>this.d.length-2},g.isNegative=g.isneg=function(){return this.s<0},g.isPositive=g.ispos=function(){return this.s>0},g.isZero=function(){return this.s===0},g.lessThan=g.lt=function(e){return this.cmp(e)<0},g.lessThanOrEqualTo=g.lte=function(e){return this.cmp(e)<1},g.logarithm=g.log=function(e){var t,n=this,r=n.constructor,o=r.precision,s=o+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(d))throw Error(a+`NaN`);if(n.s<1)throw Error(a+(n.s?`NaN`:`-Infinity`));return n.eq(d)?new r(0):(i=!1,t=b(T(n,s),T(e,s),s),i=!0,D(t,o))},g.minus=g.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?O(t,e):_(t,(e.s=-e.s,e))},g.modulo=g.mod=function(e){var t,n=this,r=n.constructor,o=r.precision;if(e=new r(e),!e.s)throw Error(a+`NaN`);return n.s?(i=!1,t=b(n,e,0,1).times(e),i=!0,n.minus(t)):D(new r(n),o)},g.naturalExponential=g.exp=function(){return x(this)},g.naturalLogarithm=g.ln=function(){return T(this)},g.negated=g.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},g.plus=g.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?_(t,e):O(t,(e.s=-e.s,e))},g.precision=g.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(o+e);if(t=S(i)+1,r=i.d.length-1,n=r*p+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},g.squareRoot=g.sqrt=function(){var e,t,n,r,o,s,l,u=this,d=u.constructor;if(u.s<1){if(!u.s)return new d(0);throw Error(a+`NaN`)}for(e=S(u),i=!1,o=Math.sqrt(+u),o==0||o==1/0?(t=y(u.d),(t.length+e)%2==0&&(t+=`0`),o=Math.sqrt(t),e=c((e+1)/2)-(e<0||e%2),o==1/0?t=`5e`+e:(t=o.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new d(t)):r=new d(o.toString()),n=d.precision,o=l=n+3;;)if(s=r,r=s.plus(b(u,s,l+2)).times(.5),y(s.d).slice(0,l)===(t=y(r.d)).slice(0,l)){if(t=t.slice(l-3,l+1),o==l&&t==`4999`){if(D(s,n+1,0),s.times(s).eq(u)){r=s;break}}else if(t!=`9999`)break;l+=4}return i=!0,D(r,n)},g.times=g.mul=function(e){var t,n,r,a,o,s,c,l,u,d=this,p=d.constructor,m=d.d,h=(e=new p(e)).d;if(!d.s||!e.s)return new p(0);for(e.s*=d.s,n=d.e+e.e,l=m.length,u=h.length,l<u&&(o=m,m=h,h=o,s=l,l=u,u=s),o=[],s=l+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(t=0,a=l+r;a>r;)c=o[a]+h[r]*m[a-r-1]+t,o[a--]=c%f|0,t=c/f|0;o[a]=(o[a]+t)%f|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,i?D(e,p.precision):e},g.toDecimalPlaces=g.todp=function(e,t){var r=this,i=r.constructor;return r=new i(r),e===void 0?r:(v(e,0,n),t===void 0?t=i.rounding:v(t,0,8),D(r,e+S(r)+1,t))},g.toExponential=function(e,t){var r,i=this,a=i.constructor;return e===void 0?r=k(i,!0):(v(e,0,n),t===void 0?t=a.rounding:v(t,0,8),i=D(new a(i),e+1,t),r=k(i,!0,e+1)),r},g.toFixed=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?k(a):(v(e,0,n),t===void 0?t=o.rounding:v(t,0,8),i=D(new o(a),e+S(a)+1,t),r=k(i.abs(),!1,e+S(i)+1),a.isneg()&&!a.isZero()?`-`+r:r)},g.toInteger=g.toint=function(){var e=this,t=e.constructor;return D(new t(e),S(e)+1,t.rounding)},g.toNumber=function(){return+this},g.toPower=g.pow=function(e){var t,n,r,o,s,l,u=this,f=u.constructor,h=12,g=+(e=new f(e));if(!e.s)return new f(d);if(u=new f(u),!u.s){if(e.s<1)throw Error(a+`Infinity`);return u}if(u.eq(d))return u;if(r=f.precision,e.eq(d))return D(u,r);if(t=e.e,n=e.d.length-1,l=t>=n,s=u.s,!l){if(s<0)throw Error(a+`NaN`)}else if((n=g<0?-g:g)<=m){for(o=new f(d),t=Math.ceil(r/p+4),i=!1;n%2&&(o=o.times(u),A(o.d,t)),n=c(n/2),n!==0;)u=u.times(u),A(u.d,t);return i=!0,e.s<0?new f(d).div(o):D(o,r)}return s=s<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,i=!1,o=e.times(T(u,r+h)),i=!0,o=x(o),o.s=s,o},g.toPrecision=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?(r=S(a),i=k(a,r<=o.toExpNeg||r>=o.toExpPos)):(v(e,1,n),t===void 0?t=o.rounding:v(t,0,8),a=D(new o(a),e,t),r=S(a),i=k(a,e<=r||r<=o.toExpNeg,e)),i},g.toSignificantDigits=g.tosd=function(e,t){var r=this,i=r.constructor;return e===void 0?(e=i.precision,t=i.rounding):(v(e,1,n),t===void 0?t=i.rounding:v(t,0,8)),D(new i(r),e,t)},g.toString=g.valueOf=g.val=g.toJSON=function(){var e=this,t=S(e),n=e.constructor;return k(e,t<=n.toExpNeg||t>=n.toExpPos)};function _(e,t){var n,r,a,o,s,c,l,u,d=e.constructor,m=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),i?D(t,m):t;if(l=e.d,u=t.d,s=e.e,a=t.e,l=l.slice(),o=s-a,o){for(o<0?(r=l,o=-o,c=u.length):(r=u,a=s,c=l.length),s=Math.ceil(m/p),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=l.length,o=u.length,c-o<0&&(o=c,r=u,u=l,l=r),n=0;o;)n=(l[--o]=l[o]+u[o]+n)/f|0,l[o]%=f;for(n&&(l.unshift(n),++a),c=l.length;l[--c]==0;)l.pop();return t.d=l,t.e=a,i?D(t,m):t}function v(e,t,n){if(e!==~~e||e<t||e>n)throw Error(o+e)}function y(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=p-r.length,n&&(a+=w(n)),a+=r;o=e[t],r=o+``,n=p-r.length,n&&(a+=w(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}var b=(function(){function e(e,t){var n,r=0,i=e.length;for(e=e.slice();i--;)n=e[i]*t+r,e[i]=n%f|0,r=n/f|0;return r&&e.unshift(r),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]<t[n]),e[n]=r*f+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,o,s){var c,l,u,d,m,h,g,_,v,y,b,x,C,w,T,E,O,k,A=r.constructor,j=r.s==i.s?1:-1,M=r.d,N=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(a+`Division by zero`);for(l=r.e-i.e,O=N.length,T=M.length,g=new A(j),_=g.d=[],u=0;N[u]==(M[u]||0);)++u;if(N[u]>(M[u]||0)&&--l,x=o==null?o=A.precision:s?o+(S(r)-S(i))+1:o,x<0)return new A(0);if(x=x/p+2|0,u=0,O==1)for(d=0,N=N[0],x++;(u<T||d)&&x--;u++)C=d*f+(M[u]||0),_[u]=C/N|0,d=C%N|0;else{for(d=f/(N[0]+1)|0,d>1&&(N=e(N,d),M=e(M,d),O=N.length,T=M.length),w=O,v=M.slice(0,O),y=v.length;y<O;)v[y++]=0;k=N.slice(),k.unshift(0),E=N[0],N[1]>=f/2&&++E;do d=0,c=t(N,v,O,y),c<0?(b=v[0],O!=y&&(b=b*f+(v[1]||0)),d=b/E|0,d>1?(d>=f&&(d=f-1),m=e(N,d),h=m.length,y=v.length,c=t(m,v,h,y),c==1&&(d--,n(m,O<h?k:N,h))):(d==0&&(c=d=1),m=N.slice()),h=m.length,h<y&&m.unshift(0),n(v,m,y),c==-1&&(y=v.length,c=t(N,v,O,y),c<1&&(d++,n(v,O<y?k:N,y))),y=v.length):c===0&&(d++,v=[0]),_[u++]=d,c&&v[0]?v[y++]=M[w]||0:(v=[M[w]],y=1);while((w++<T||v[0]!==void 0)&&x--)}return _[0]||_.shift(),g.e=l,D(g,s?o+S(g)+1:o)}})();function x(e,t){var n,r,a,o,c,u,f=0,p=0,m=e.constructor,h=m.precision;if(S(e)>16)throw Error(s+S(e));if(!e.s)return new m(d);for(t==null?(i=!1,u=h):u=t,c=new m(.03125);e.abs().gte(.1);)e=e.times(c),p+=5;for(r=Math.log(l(2,p))/Math.LN10*2+5|0,u+=r,n=a=o=new m(d),m.precision=u;;){if(a=D(a.times(e),u),n=n.times(++f),c=o.plus(b(a,n,u)),y(c.d).slice(0,u)===y(o.d).slice(0,u)){for(;p--;)o=D(o.times(o),u);return m.precision=h,t==null?(i=!0,D(o,h)):o}o=c}}function S(e){for(var t=e.e*p,n=e.d[0];n>=10;n/=10)t++;return t}function C(e,t,n){if(t>e.LN10.sd())throw i=!0,n&&(e.precision=n),Error(a+`LN10 precision limit exceeded`);return D(new e(e.LN10),t)}function w(e){for(var t=``;e--;)t+=`0`;return t}function T(e,t){var n,r,o,s,c,l,u,f,p,m=1,h=10,g=e,_=g.d,v=g.constructor,x=v.precision;if(g.s<1)throw Error(a+(g.s?`NaN`:`-Infinity`));if(g.eq(d))return new v(0);if(t==null?(i=!1,f=x):f=t,g.eq(10))return t??(i=!0),C(v,f);if(f+=h,v.precision=f,n=y(_),r=n.charAt(0),s=S(g),Math.abs(s)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=y(g.d),r=n.charAt(0),m++;s=S(g),r>1?(g=new v(`0.`+n),s++):g=new v(r+`.`+n.slice(1))}else return u=C(v,f+2,x).times(s+``),g=T(new v(r+`.`+n.slice(1)),f-h).plus(u),v.precision=x,t==null?(i=!0,D(g,x)):g;for(l=c=g=b(g.minus(d),g.plus(d),f),p=D(g.times(g),f),o=3;;){if(c=D(c.times(p),f),u=l.plus(b(c,new v(o),f)),y(u.d).slice(0,f)===y(l.d).slice(0,f))return l=l.times(2),s!==0&&(l=l.plus(C(v,f+2,x).times(s+``))),l=b(l,new v(m),f),v.precision=x,t==null?(i=!0,D(l,x)):l;l=u,o+=2}}function E(e,t){var n,r,a;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(r,a),t){if(a-=r,n=n-r-1,e.e=c(n/p),e.d=[],r=(n+1)%p,n<0&&(r+=p),r<a){for(r&&e.d.push(+t.slice(0,r)),a-=p;r<a;)e.d.push(+t.slice(r,r+=p));t=t.slice(r),r=p-t.length}else r-=a;for(;r--;)t+=`0`;if(e.d.push(+t),i&&(e.e>h||e.e<-h))throw Error(s+n)}else e.s=0,e.e=0,e.d=[0];return e}function D(e,t,n){var r,a,o,u,d,m,g,_,v=e.d;for(u=1,o=v[0];o>=10;o/=10)u++;if(r=t-u,r<0)r+=p,a=t,g=v[_=0];else{if(_=Math.ceil((r+1)/p),o=v.length,_>=o)return e;for(g=o=v[_],u=1;o>=10;o/=10)u++;r%=p,a=r-p+u}if(n!==void 0&&(o=l(10,u-a-1),d=g/o%10|0,m=t<0||v[_+1]!==void 0||g%o,m=n<4?(d||m)&&(n==0||n==(e.s<0?3:2)):d>5||d==5&&(n==4||m||n==6&&(r>0?a>0?g/l(10,u-a):0:v[_-1])%10&1||n==(e.s<0?8:7))),t<1||!v[0])return m?(o=S(e),v.length=1,t=t-o-1,v[0]=l(10,(p-t%p)%p),e.e=c(-t/p)||0):(v.length=1,v[0]=e.e=e.s=0),e;if(r==0?(v.length=_,o=1,_--):(v.length=_+1,o=l(10,p-r),v[_]=a>0?(g/l(10,u-a)%l(10,a)|0)*o:0),m)for(;;)if(_==0){(v[0]+=o)==f&&(v[0]=1,++e.e);break}else{if(v[_]+=o,v[_]!=f)break;v[_--]=0,o=1}for(r=v.length;v[--r]===0;)v.pop();if(i&&(e.e>h||e.e<-h))throw Error(s+S(e));return e}function O(e,t){var n,r,a,o,s,c,l,u,d,m,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),i?D(t,g):t;if(l=e.d,m=t.d,r=t.e,u=e.e,l=l.slice(),s=u-r,s){for(d=s<0,d?(n=l,s=-s,c=m.length):(n=m,r=u,c=l.length),a=Math.max(Math.ceil(g/p),c)+2,s>a&&(s=a,n.length=1),n.reverse(),a=s;a--;)n.push(0);n.reverse()}else{for(a=l.length,c=m.length,d=a<c,d&&(c=a),a=0;a<c;a++)if(l[a]!=m[a]){d=l[a]<m[a];break}s=0}for(d&&(n=l,l=m,m=n,t.s=-t.s),c=l.length,a=m.length-c;a>0;--a)l[c++]=0;for(a=m.length;a>s;){if(l[--a]<m[a]){for(o=a;o&&l[--o]===0;)l[o]=f-1;--l[o],l[a]+=f}l[a]-=m[a]}for(;l[--c]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(t.d=l,t.e=r,i?D(t,g):t):new h(0)}function k(e,t,n){var r,i=S(e),a=y(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+w(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+w(-i-1)+a,n&&(r=n-o)>0&&(a+=w(r))):i>=o?(a+=w(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+w(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=w(r))),e.s<0?`-`+a:a}function A(e,t){if(e.length>t)return e.length=t,!0}function j(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i){t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;return}if(typeof e==`number`){if(e*0!=0)throw Error(o+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return E(t,e.toString())}else if(typeof e!=`string`)throw Error(o+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,u.test(e))E(t,e);else throw Error(o+e)}if(i.prototype=g,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=j,i.config=i.set=M,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function M(e){if(!e||typeof e!=`object`)throw Error(a+`Object expected`);var t,r,i,s=[`precision`,1,n,`rounding`,0,8,`toExpNeg`,-1/0,0,`toExpPos`,0,1/0];for(t=0;t<s.length;t+=3)if((i=e[r=s[t]])!==void 0)if(c(i)===i&&i>=s[t+1]&&i<=s[t+2])this[r]=i;else throw Error(o+r+`: `+i);if((i=e[r=`LN10`])!==void 0)if(i==Math.LN10)this[r]=new this(i);else throw Error(o+r+`: `+i);return this}r=j(r),r.default=r.Decimal=r,d=new r(1),typeof define==`function`&&define.amd?define(function(){return r}):t!==void 0&&t.exports?t.exports=r:(e||=typeof self<`u`&&self&&self.self==self?self:Function(`return this`)(),e.Decimal=r)})(e)}))());function vE(e){return e===0?1:Math.floor(new _E.default(e).abs().log(10).toNumber())+1}function yE(e,t,n){for(var r=new _E.default(e),i=0,a=[];r.lt(t)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}function bE(e,t){return TE(e)||wE(e,t)||SE(e,t)||xE()}function xE(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function SE(e,t){if(e){if(typeof e==`string`)return CE(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?CE(e,t):void 0}}function CE(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function wE(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function TE(e){if(Array.isArray(e))return e}var EE=e=>{var t=bE(e,2),n=t[0],r=t[1],i=n,a=r;return n>r&&(i=r,a=n),[i,a]},DE=(e,t,n)=>{if(e.lte(0))return new _E.default(0);var r=vE(e.toNumber()),i=new _E.default(10).pow(r),a=e.div(i),o=r===1?.1:.05,s=new _E.default(Math.ceil(a.div(o).toNumber())).add(n).mul(o).mul(i);return t?new _E.default(s.toNumber()):new _E.default(Math.ceil(s.toNumber()))},OE=(e,t,n)=>{if(e.lte(0))return new _E.default(0);var r=[1,2,2.5,5],i=e.toNumber(),a=Math.floor(new _E.default(i).abs().log(10).toNumber()),o=new _E.default(10).pow(a),s=e.div(o).toNumber(),c=r.findIndex(e=>e>=s-1e-10);if(c===-1&&(o=o.mul(10),c=0),c+=n,c>=r.length){var l=Math.floor(c/r.length);c%=r.length,o=o.mul(new _E.default(10).pow(l))}var u=new _E.default(r[c]??1).mul(o);return t?u:new _E.default(Math.ceil(u.toNumber()))},kE=(e,t,n)=>{var r=new _E.default(1),i=new _E.default(e);if(!i.isint()&&n){var a=Math.abs(e);a<1?(r=new _E.default(10).pow(vE(e)-1),i=new _E.default(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new _E.default(Math.floor(e)))}else e===0?i=new _E.default(Math.floor((t-1)/2)):n||(i=new _E.default(Math.floor(e)));for(var o=Math.floor((t-1)/2),s=[],c=0;c<t;c++)s.push(i.add(new _E.default(c-o).mul(r)).toNumber());return s},AE=function(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:DE;if(!Number.isFinite((t-e)/(n-1)))return{step:new _E.default(0),tickMin:new _E.default(0),tickMax:new _E.default(0)};var o=a(new _E.default(t).sub(e).div(n-1),r,i),s;e<=0&&t>=0?s=new _E.default(0):(s=new _E.default(e).add(t).div(2),s=s.sub(new _E.default(s).mod(o)));var c=Math.ceil(s.sub(e).div(o).toNumber()),l=Math.ceil(new _E.default(t).sub(s).div(o).toNumber()),u=c+l+1;return u>n?AE(e,t,n,r,i+1,a):(u<n&&(l=t>0?l+(n-u):l,c=t>0?c:c+(n-u)),{step:o,tickMin:s.sub(new _E.default(c).mul(o)),tickMax:s.add(new _E.default(l).mul(o))})},jE=function(e){var t=bE(e,2),n=t[0],r=t[1],i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`auto`,s=Math.max(i,2),c=bE(EE([n,r]),2),l=c[0],u=c[1];if(l===-1/0||u===1/0){var d=u===1/0?[l,...Array(i-1).fill(1/0)]:[...Array(i-1).fill(-1/0),u];return n>r?d.reverse():d}if(l===u)return kE(l,i,a);var f=AE(l,u,s,a,0,o===`snap125`?OE:DE),p=f.step,m=f.tickMin,h=f.tickMax,g=yE(m,h.add(new _E.default(.1).mul(p)),p);return n>r?g.reverse():g},ME=function(e,t){var n=bE(e,2),r=n[0],i=n[1],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`auto`,s=bE(EE([r,i]),2),c=s[0],l=s[1];if(c===-1/0||l===1/0)return[r,i];if(c===l)return[c];var u=o===`snap125`?OE:DE,d=Math.max(t,2),f=u(new _E.default(l).sub(c).div(d-1),a,0),p=[...yE(new _E.default(c),new _E.default(l),f),l];return a===!1&&(p=p.map(e=>Math.round(e))),r>i?p.reverse():p},NE=e=>e.rootProps.maxBarSize,PE=e=>e.rootProps.barGap,FE=e=>e.rootProps.barCategoryGap,IE=e=>e.rootProps.barSize,LE=e=>e.rootProps.stackOffset,RE=e=>e.rootProps.reverseStackOrder,zE=e=>e.options.chartName,BE=e=>e.rootProps.syncId,VE=e=>e.rootProps.syncMethod,HE=e=>e.options.eventEmitter,UE=e=>e.rootProps.baseValue,WE={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},GE={allowDecimals:!1,allowDuplicatedCategory:!0,allowDataOverflow:!1,angle:0,angleAxisId:0,axisLine:!0,axisLineType:`polygon`,cx:0,cy:0,hide:!1,includeHidden:!1,label:!1,niceTicks:`auto`,orientation:`outer`,reversed:!1,scale:`auto`,tick:!0,tickLine:!0,tickSize:8,type:`auto`,zIndex:WE.axis},KE={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,angle:0,axisLine:!0,includeHidden:!1,hide:!1,niceTicks:`auto`,label:!1,orientation:`right`,radiusAxisId:0,reversed:!1,scale:`auto`,stroke:`#ccc`,tick:!0,tickCount:5,tickLine:!0,type:`auto`,zIndex:WE.axis},qE=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t};function JE(e,t,n){if(n!==`auto`)return n;if(e!=null)return fy(e,t)?`category`:`number`}function YE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function XE(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?YE(Object(n),!0).forEach(function(t){ZE(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YE(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ZE(e,t,n){return(t=QE(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QE(e){var t=$E(e,`string`);return typeof t==`symbol`?t:t+``}function $E(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var eD={allowDataOverflow:GE.allowDataOverflow,allowDecimals:GE.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:GE.angleAxisId,includeHidden:!1,name:void 0,reversed:GE.reversed,scale:GE.scale,tick:GE.tick,tickCount:void 0,ticks:void 0,type:GE.type,unit:void 0,niceTicks:`auto`},tD={allowDataOverflow:KE.allowDataOverflow,allowDecimals:KE.allowDecimals,allowDuplicatedCategory:KE.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:KE.radiusAxisId,includeHidden:KE.includeHidden,name:void 0,reversed:KE.reversed,scale:KE.scale,tick:KE.tick,tickCount:KE.tickCount,ticks:void 0,type:KE.type,unit:void 0,niceTicks:`auto`},nD=Q([(e,t)=>{if(t!=null)return e.polarAxis.angleAxis[t]},Kb],(e,t)=>{if(e!=null)return e;var n=JE(t,`angleAxis`,eD.type)??`category`;return XE(XE({},eD),{},{type:n})}),rD=Q([(e,t)=>e.polarAxis.radiusAxis[t],Kb],(e,t)=>{if(e!=null)return e;var n=JE(t,`radiusAxis`,tD.type)??`category`;return XE(XE({},tD),{},{type:n})}),iD=e=>e.polarOptions,aD=Q([My,Ny,Xy],OT),oD=Q([iD,aD],(e,t)=>{if(e!=null)return dp(e.innerRadius,t,0)}),sD=Q([iD,aD],(e,t)=>{if(e!=null)return dp(e.outerRadius,t,t*.8)}),cD=Q([iD],e=>e==null?[0,0]:[e.startAngle,e.endAngle]);Q([nD,cD],qE);var lD=Q([aD,oD,sD],(e,t,n)=>{if(!(e==null||t==null||n==null))return[t,n]});Q([rD,lD],qE);var uD=Q([Ub,iD,oD,sD,My,Ny],(e,t,n,r,i,a)=>{if(!(e!==`centric`&&e!==`radial`||t==null||n==null||r==null)){var o=t.cx,s=t.cy,c=t.startAngle,l=t.endAngle;return{cx:dp(o,i,i/2),cy:dp(s,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:l,clockWise:!1}}}),dD=(e,t)=>t,fD=(e,t,n)=>n;function pD(e){return e?.id}function mD(e,t,n){var r=t.chartData,i=r===void 0?[]:r,a=n.allowDuplicatedCategory,o=n.dataKey,s=new Map;return e.forEach(e=>{var t=e.data??i;if(!(t==null||t.length===0)){var n=pD(e);t.forEach((t,r)=>{var i=o==null||a?r:String(uy(t,o,null)),c=uy(t,e.dataKey,0),l=s.has(i)?s.get(i):{};Object.assign(l,{[n]:c}),s.set(i,l)})}}),Array.from(s.values())}function hD(e){return`stackId`in e&&e.stackId!=null&&e.dataKey!=null}var gD=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function _D(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function vD(e,t){if(e.length===t.length){for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return!1}var yD=e=>{var t=Ub(e);return t===`horizontal`?`xAxis`:t===`vertical`?`yAxis`:t===`centric`?`angleAxis`:`radiusAxis`},bD=e=>e.tooltip.settings.axisId;function xD(e){if(e!=null){var t=e.ticks,n=e.bandwidth,r=e.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>e.domain(),range:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(e){var t=i[0],n=i[1];return t<=n?e>=t&&e<=n:e>=n&&e<=t},bandwidth:n?()=>n.call(e):void 0,ticks:t?n=>t.call(e,n):void 0,map:(t,n)=>{var r=e(t);if(r!=null){if(e.bandwidth&&n!=null&&n.position){var i=e.bandwidth();switch(n.position){case`middle`:r+=i/2;break;case`end`:r+=i;break;default:break}}return r}}}}}var SD=(e,t)=>{if(t!=null)switch(e){case`linear`:if(!pE(t)){for(var n,r,i=0;i<t.length;i++){var a=t[i];ry(a)&&((n===void 0||a<n)&&(n=a),(r===void 0||a>r)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return t;default:return t}};function CD(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function wD(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function TD(e){let t,n,r;e.length===2?(t=e===CD||e===wD?e:ED,n=e,r=e):(t=CD,n=(t,n)=>CD(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function ED(){return 0}function DD(e){return e===null?NaN:+e}function*OD(e,t){if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)(r=t(r,++n,e))!=null&&(r=+r)>=r&&(yield r)}}var kD=TD(CD),AD=kD.right;kD.left,TD(DD).center;function jD(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n<t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n<i||n===void 0&&i>=i)&&(n=i)}return n}function MD(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n>t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}function ND(e=CD){if(e===CD)return PD;if(typeof e!=`function`)throw TypeError(`compare is not a function`);return(t,n)=>{let r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function PD(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(e<t?-1:+(e>t))}function FD(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?PD:ND(i);r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1),u=Math.max(n,Math.floor(t-o*c/a+l)),d=Math.min(r,Math.floor(t+(a-o)*c/a+l));FD(e,t,u,d,i)}let a=e[t],o=n,s=r;for(ID(e,n,t),i(e[r],a)>0&&ID(e,n,r);o<s;){for(ID(e,o,s),++o,--s;i(e[o],a)<0;)++o;for(;i(e[s],a)>0;)--s}i(e[n],a)===0?ID(e,n,s):(++s,ID(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}return e}function ID(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function LD(e,t,n){if(e=Float64Array.from(OD(e,n)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return MD(e);if(t>=1)return jD(e);var r,i=(r-1)*t,a=Math.floor(i),o=jD(FD(e,a).subarray(0,a+1));return o+(MD(e.subarray(a+1))-o)*(i-a)}}function RD(e,t,n=DD){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}function zD(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}var BD=Math.sqrt(50),VD=Math.sqrt(10),HD=Math.sqrt(2);function UD(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=BD?10:a>=VD?5:a>=HD?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?UD(e,t,n*2):[s,c,l]}function WD(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?UD(t,e,n):UD(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o;else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function GD(e,t,n){return t=+t,e=+e,n=+n,UD(e,t,n)[2]}function KD(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?GD(t,e,n):GD(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}var qD=class extends Map{constructor(e,t=ZD){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(JD(this,e))}has(e){return super.has(JD(this,e))}set(e,t){return super.set(YD(this,e),t)}delete(e){return super.delete(XD(this,e))}};function JD({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function YD({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function XD({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function ZD(e){return typeof e==`object`&&e?e.valueOf():e}function QD(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function $D(e,t){switch(arguments.length){case 0:break;case 1:typeof e==`function`?this.interpolator(e):this.range(e);break;default:this.domain(e),typeof t==`function`?this.interpolator(t):this.range(t);break}return this}var eO=Symbol(`implicit`);function tO(){var e=new qD,t=[],n=[],r=eO;function i(i){let a=e.get(i);if(a===void 0){if(r!==eO)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new qD;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return tO(t,n).unknown(r)},QD.apply(i,arguments),i}function nO(){var e=tO().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=zD(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return nO(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},QD.apply(d(),arguments)}function rO(e){var t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return rO(t())},e}function iO(){return rO(nO.apply(null,arguments).paddingInner(1))}function aO(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function oO(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function sO(){}var cO=.7,lO=1/cO,uO=`\\s*([+-]?\\d+)\\s*`,dO=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,fO=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,pO=/^#([0-9a-f]{3,8})$/,mO=RegExp(`^rgb\\(${uO},${uO},${uO}\\)$`),hO=RegExp(`^rgb\\(${fO},${fO},${fO}\\)$`),gO=RegExp(`^rgba\\(${uO},${uO},${uO},${dO}\\)$`),_O=RegExp(`^rgba\\(${fO},${fO},${fO},${dO}\\)$`),vO=RegExp(`^hsl\\(${dO},${fO},${fO}\\)$`),yO=RegExp(`^hsla\\(${dO},${fO},${fO},${dO}\\)$`),bO={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};aO(sO,TO,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:xO,formatHex:xO,formatHex8:SO,formatHsl:CO,formatRgb:wO,toString:wO});function xO(){return this.rgb().formatHex()}function SO(){return this.rgb().formatHex8()}function CO(){return RO(this).formatHsl()}function wO(){return this.rgb().formatRgb()}function TO(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=pO.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?EO(t):n===3?new AO(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?DO(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?DO(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=mO.exec(e))?new AO(t[1],t[2],t[3],1):(t=hO.exec(e))?new AO(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=gO.exec(e))?DO(t[1],t[2],t[3],t[4]):(t=_O.exec(e))?DO(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=vO.exec(e))?LO(t[1],t[2]/100,t[3]/100,1):(t=yO.exec(e))?LO(t[1],t[2]/100,t[3]/100,t[4]):bO.hasOwnProperty(e)?EO(bO[e]):e===`transparent`?new AO(NaN,NaN,NaN,0):null}function EO(e){return new AO(e>>16&255,e>>8&255,e&255,1)}function DO(e,t,n,r){return r<=0&&(e=t=n=NaN),new AO(e,t,n,r)}function OO(e){return e instanceof sO||(e=TO(e)),e?(e=e.rgb(),new AO(e.r,e.g,e.b,e.opacity)):new AO}function kO(e,t,n,r){return arguments.length===1?OO(e):new AO(e,t,n,r??1)}function AO(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}aO(AO,kO,oO(sO,{brighter(e){return e=e==null?lO:lO**+e,new AO(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?cO:cO**+e,new AO(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new AO(FO(this.r),FO(this.g),FO(this.b),PO(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:jO,formatHex:jO,formatHex8:MO,formatRgb:NO,toString:NO}));function jO(){return`#${IO(this.r)}${IO(this.g)}${IO(this.b)}`}function MO(){return`#${IO(this.r)}${IO(this.g)}${IO(this.b)}${IO((isNaN(this.opacity)?1:this.opacity)*255)}`}function NO(){let e=PO(this.opacity);return`${e===1?`rgb(`:`rgba(`}${FO(this.r)}, ${FO(this.g)}, ${FO(this.b)}${e===1?`)`:`, ${e})`}`}function PO(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function FO(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function IO(e){return e=FO(e),(e<16?`0`:``)+e.toString(16)}function LO(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new BO(e,t,n,r)}function RO(e){if(e instanceof BO)return new BO(e.h,e.s,e.l,e.opacity);if(e instanceof sO||(e=TO(e)),!e)return new BO;if(e instanceof BO)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new BO(o,s,c,e.opacity)}function zO(e,t,n,r){return arguments.length===1?RO(e):new BO(e,t,n,r??1)}function BO(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}aO(BO,zO,oO(sO,{brighter(e){return e=e==null?lO:lO**+e,new BO(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?cO:cO**+e,new BO(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new AO(UO(e>=240?e-240:e+120,i,r),UO(e,i,r),UO(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new BO(VO(this.h),HO(this.s),HO(this.l),PO(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(){let e=PO(this.opacity);return`${e===1?`hsl(`:`hsla(`}${VO(this.h)}, ${HO(this.s)*100}%, ${HO(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function VO(e){return e=(e||0)%360,e<0?e+360:e}function HO(e){return Math.max(0,Math.min(1,e||0))}function UO(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var WO=e=>()=>e;function GO(e,t){return function(n){return e+n*t}}function KO(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function qO(e){return(e=+e)==1?JO:function(t,n){return n-t?KO(t,n,e):WO(isNaN(t)?n:t)}}function JO(e,t){var n=t-e;return n?GO(e,n):WO(isNaN(e)?t:e)}var YO=(function e(t){var n=qO(t);function r(e,t){var r=n((e=kO(e)).r,(t=kO(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=JO(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function XO(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function ZO(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function QO(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=sk(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function $O(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ek(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function tk(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=sk(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var nk=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,rk=new RegExp(nk.source,`g`);function ik(e){return function(){return e}}function ak(e){return function(t){return e(t)+``}}function ok(e,t){var n=nk.lastIndex=rk.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=nk.exec(e))&&(i=rk.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:ek(r,i)})),n=rk.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?ak(c[0].x):ik(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function sk(e,t){var n=typeof t,r;return t==null||n===`boolean`?WO(t):(n===`number`?ek:n===`string`?(r=TO(t))?(t=r,YO):ok:t instanceof TO?YO:t instanceof Date?$O:ZO(t)?XO:Array.isArray(t)?QO:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?tk:ek)(e,t)}function ck(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function lk(e,t){t===void 0&&(t=e,e=sk);for(var n=0,r=t.length-1,i=t[0],a=Array(r<0?0:r);n<r;)a[n]=e(i,i=t[++n]);return function(e){var t=Math.max(0,Math.min(r-1,Math.floor(e*=r)));return a[t](e-t)}}function uk(e){return function(){return e}}function dk(e){return+e}var fk=[0,1];function pk(e){return e}function mk(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:uk(isNaN(t)?NaN:.5)}function hk(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function gk(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=mk(i,r),a=n(o,a)):(r=mk(r,i),a=n(a,o)),function(e){return a(r(e))}}function _k(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=mk(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=AD(e,t,1,r)-1;return a[n](i[n](t))}}function vk(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function yk(){var e=fk,t=fk,n=sk,r,i,a,o=pk,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==pk&&(o=hk(e[0],e[n-1])),s=n>2?_k:gk,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),ek))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,dk),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=ck,u()},d.clamp=function(e){return arguments.length?(o=e?!0:pk,u()):o!==pk},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function bk(){return yk()(pk,pk)}function xk(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function Sk(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Ck(e){return e=Sk(Math.abs(e)),e?e[1]:NaN}function wk(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function Tk(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var Ek=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Dk(e){if(!(t=Ek.exec(e)))throw Error(`invalid format: `+e);var t;return new Ok({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Dk.prototype=Ok.prototype;function Ok(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+``}Ok.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 kk(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var Ak;function jk(e,t){var n=Sk(e,t);if(!n)return Ak=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(Ak=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+Sk(e,Math.max(0,t+a-1))[0]}function Mk(e,t){var n=Sk(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var Nk={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:xk,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Mk(e*100,t),r:Mk,s:jk,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Pk(e){return e}var Fk=Array.prototype.map,Ik=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function Lk(e){var t=e.grouping===void 0||e.thousands===void 0?Pk:wk(Fk.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?Pk:Tk(Fk.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=Dk(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):Nk[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=Nk[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=kk(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&Ak!==void 0?Ik[8+Ak/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(Ck(t)/3)))*3,r=10**-n,i=l((e=Dk(e),e.type=`f`,e),{suffix:Ik[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var Rk,zk,Bk;Vk({thousands:`,`,grouping:[3],currency:[`$`,``]});function Vk(e){return Rk=Lk(e),zk=Rk.format,Bk=Rk.formatPrefix,Rk}function Hk(e){return Math.max(0,-Ck(Math.abs(e)))}function Uk(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Ck(t)/3)))*3-Ck(Math.abs(e)))}function Wk(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Ck(t)-Ck(e))+1}function Gk(e,t,n,r){var i=KD(e,t,n),a;switch(r=Dk(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=Uk(i,o))&&(r.precision=a),Bk(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=Wk(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=Hk(i))&&(r.precision=a-(r.type===`%`)*2);break}return zk(r)}function Kk(e){var t=e.domain;return e.ticks=function(e){var n=t();return WD(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return Gk(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-->0;){if(l=GD(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function qk(){var e=bk();return e.copy=function(){return vk(e,qk())},QD.apply(e,arguments),Kk(e)}function Jk(e){var t;function n(e){return e==null||isNaN(e=+e)?t:e}return n.invert=n,n.domain=n.range=function(t){return arguments.length?(e=Array.from(t,dk),n):e.slice()},n.unknown=function(e){return arguments.length?(t=e,n):t},n.copy=function(){return Jk(e).unknown(t)},e=arguments.length?Array.from(e,dk):[0,1],Kk(n)}function Yk(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),e[n]=t.floor(i),e[r]=t.ceil(a),e}function Xk(e){return Math.log(e)}function Zk(e){return Math.exp(e)}function Qk(e){return-Math.log(-e)}function $k(e){return-Math.exp(-e)}function eA(e){return isFinite(e)?+(`1e`+e):e<0?0:e}function tA(e){return e===10?eA:e===Math.E?Math.exp:t=>e**+t}function nA(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function rA(e){return(t,n)=>-e(-t,n)}function iA(e){let t=e(Xk,Zk),n=t.domain,r=10,i,a;function o(){return i=nA(r),a=tA(r),n()[0]<0?(i=rA(i),a=rA(a),e(Qk,$k)):e(Xk,Zk),t}return t.base=function(e){return arguments.length?(r=+e,o()):r},t.domain=function(e){return arguments.length?(n(e),o()):n()},t.ticks=e=>{let t=n(),o=t[0],s=t[t.length-1],c=s<o;c&&([o,s]=[s,o]);let l=i(o),u=i(s),d,f,p=e==null?10:+e,m=[];if(!(r%1)&&u-l<p){if(l=Math.floor(l),u=Math.ceil(u),o>0){for(;l<=u;++l)for(d=1;d<r;++d)if(f=l<0?d/a(-l):d*a(l),!(f<o)){if(f>s)break;m.push(f)}}else for(;l<=u;++l)for(d=r-1;d>=1;--d)if(f=l>0?d/a(-l):d*a(l),!(f<o)){if(f>s)break;m.push(f)}m.length*2<p&&(m=WD(o,s,p))}else m=WD(l,u,Math.min(u-l,p)).map(a);return c?m.reverse():m},t.tickFormat=(e,n)=>{if(e??=10,n??=r===10?`s`:`,`,typeof n!=`function`&&(!(r%1)&&(n=Dk(n)).precision==null&&(n.trim=!0),n=zk(n)),e===1/0)return n;let o=Math.max(1,r*e/t.ticks().length);return e=>{let t=e/a(Math.round(i(e)));return t*r<r-.5&&(t*=r),t<=o?n(e):``}},t.nice=()=>n(Yk(n(),{floor:e=>a(Math.floor(i(e))),ceil:e=>a(Math.ceil(i(e)))})),t}function aA(){let e=iA(yk()).domain([1,10]);return e.copy=()=>vk(e,aA()).base(e.base()),QD.apply(e,arguments),e}function oA(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function sA(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function cA(e){var t=1,n=e(oA(t),sA(t));return n.constant=function(n){return arguments.length?e(oA(t=+n),sA(t)):t},Kk(n)}function lA(){var e=cA(yk());return e.copy=function(){return vk(e,lA()).constant(e.constant())},QD.apply(e,arguments)}function uA(e){return function(t){return t<0?-((-t)**+e):t**+e}}function dA(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function fA(e){return e<0?-e*e:e*e}function pA(e){var t=e(pk,pk),n=1;function r(){return n===1?e(pk,pk):n===.5?e(dA,fA):e(uA(n),uA(1/n))}return t.exponent=function(e){return arguments.length?(n=+e,r()):n},Kk(t)}function mA(){var e=pA(yk());return e.copy=function(){return vk(e,mA()).exponent(e.exponent())},QD.apply(e,arguments),e}function hA(){return mA.apply(null,arguments).exponent(.5)}function gA(e){return Math.sign(e)*e*e}function _A(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function vA(){var e=bk(),t=[0,1],n=!1,r;function i(t){var i=_A(e(t));return isNaN(i)?r:n?Math.round(i):i}return i.invert=function(t){return e.invert(gA(t))},i.domain=function(t){return arguments.length?(e.domain(t),i):e.domain()},i.range=function(n){return arguments.length?(e.range((t=Array.from(n,dk)).map(gA)),i):t.slice()},i.rangeRound=function(e){return i.range(e).round(!0)},i.round=function(e){return arguments.length?(n=!!e,i):n},i.clamp=function(t){return arguments.length?(e.clamp(t),i):e.clamp()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return vA(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},QD.apply(i,arguments),Kk(i)}function yA(){var e=[],t=[],n=[],r;function i(){var r=0,i=Math.max(1,t.length);for(n=Array(i-1);++r<i;)n[r-1]=RD(e,r/i);return a}function a(e){return e==null||isNaN(e=+e)?r:t[AD(n,e)]}return a.invertExtent=function(r){var i=t.indexOf(r);return i<0?[NaN,NaN]:[i>0?n[i-1]:e[0],i<n.length?n[i]:e[e.length-1]]},a.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(CD),i()},a.range=function(e){return arguments.length?(t=Array.from(e),i()):t.slice()},a.unknown=function(e){return arguments.length?(r=e,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return yA().domain(e).range(t).unknown(r)},QD.apply(a,arguments)}function bA(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[AD(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i<n;)r[i]=((i+1)*t-(i-n)*e)/(n+1);return o}return o.domain=function(n){return arguments.length?([e,t]=n,e=+e,t=+t,s()):[e,t]},o.range=function(e){return arguments.length?(n=(i=Array.from(e)).length-1,s()):i.slice()},o.invertExtent=function(a){var o=i.indexOf(a);return o<0?[NaN,NaN]:o<1?[e,r[0]]:o>=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return bA().domain([e,t]).range(i).unknown(a)},QD.apply(Kk(o),arguments)}function xA(){var e=[.5],t=[0,1],n,r=1;function i(i){return i!=null&&i<=i?t[AD(e,i,0,r)]:n}return i.domain=function(n){return arguments.length?(e=Array.from(n),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(n){return arguments.length?(t=Array.from(n),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(n){var r=t.indexOf(n);return[e[r-1],e[r]]},i.unknown=function(e){return arguments.length?(n=e,i):n},i.copy=function(){return xA().domain(e).range(t).unknown(n)},QD.apply(i,arguments)}var SA=new Date,CA=new Date;function wA(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t<n-e?t:n},i.offset=(e,n)=>(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n<r)||!(a>0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(s<n&&n<r);return o},i.filter=n=>wA(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}),n&&(i.count=(t,r)=>(SA.setTime(+t),CA.setTime(+r),e(SA),e(CA),Math.floor(n(SA,CA))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var TA=1e3,EA=TA*60,DA=EA*60,OA=DA*24,kA=OA*7,AA=OA*30,jA=OA*365,MA=wA(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*TA)},(e,t)=>(t-e)/TA,e=>e.getUTCSeconds());MA.range;var NA=wA(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*TA)},(e,t)=>{e.setTime(+e+t*EA)},(e,t)=>(t-e)/EA,e=>e.getMinutes());NA.range;var PA=wA(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*EA)},(e,t)=>(t-e)/EA,e=>e.getUTCMinutes());PA.range;var FA=wA(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*TA-e.getMinutes()*EA)},(e,t)=>{e.setTime(+e+t*DA)},(e,t)=>(t-e)/DA,e=>e.getHours());FA.range;var IA=wA(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*DA)},(e,t)=>(t-e)/DA,e=>e.getUTCHours());IA.range;var LA=wA(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*EA)/OA,e=>e.getDate()-1);LA.range;var RA=wA(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/OA,e=>e.getUTCDate()-1);RA.range;var zA=wA(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/OA,e=>Math.floor(e/OA));zA.range;function BA(e){return wA(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*EA)/kA)}var VA=BA(0),HA=BA(1),UA=BA(2),WA=BA(3),GA=BA(4),KA=BA(5),qA=BA(6);VA.range,HA.range,UA.range,WA.range,GA.range,KA.range,qA.range;function JA(e){return wA(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/kA)}var YA=JA(0),XA=JA(1),ZA=JA(2),QA=JA(3),$A=JA(4),ej=JA(5),tj=JA(6);YA.range,XA.range,ZA.range,QA.range,$A.range,ej.range,tj.range;var nj=wA(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());nj.range;var rj=wA(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());rj.range;var ij=wA(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());ij.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:wA(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),ij.range;var aj=wA(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());aj.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:wA(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),aj.range;var oj=wA(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);oj.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?wA(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):oj),oj.range;function sj(e,t,n,r,i,a){let o=[[MA,1,TA],[MA,5,5*TA],[MA,15,15*TA],[MA,30,30*TA],[a,1,EA],[a,5,5*EA],[a,15,15*EA],[a,30,30*EA],[i,1,DA],[i,3,3*DA],[i,6,6*DA],[i,12,12*DA],[r,1,OA],[r,2,2*OA],[n,1,kA],[t,1,AA],[t,3,3*AA],[e,1,jA]];function s(e,t,n){let r=t<e;r&&([e,t]=[t,e]);let i=n&&typeof n.range==`function`?n:c(e,t,n),a=i?i.range(e,+t+1):[];return r?a.reverse():a}function c(t,n,r){let i=Math.abs(n-t)/r,a=TD(([,,e])=>e).right(o,i);if(a===o.length)return e.every(KD(t/jA,n/jA,r));if(a===0)return oj.every(Math.max(KD(t,n,r),1));let[s,c]=o[i/o[a-1][2]<o[a][2]/i?a-1:a];return s.every(c)}return[s,c]}var[cj,lj]=sj(aj,rj,YA,zA,IA,PA),[uj,dj]=sj(ij,nj,VA,LA,FA,NA);function fj(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function pj(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function mj(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function hj(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,a=e.days,o=e.shortDays,s=e.months,c=e.shortMonths,l=Sj(i),u=Cj(i),d=Sj(a),f=Cj(a),p=Sj(o),m=Cj(o),h=Sj(s),g=Cj(s),_=Sj(c),v=Cj(c),y={a:N,A:ee,b:te,B:P,c:null,d:Wj,e:Wj,f:Yj,g:oM,G:cM,H:Gj,I:Kj,j:qj,L:Jj,m:Xj,M:Zj,p:F,q:ne,Q:jM,s:MM,S:Qj,u:$j,U:eM,V:nM,w:rM,W:iM,x:null,X:null,y:aM,Y:sM,Z:lM,"%":AM},b={a:re,A:ie,b:ae,B:oe,c:null,d:uM,e:uM,f:hM,g:EM,G:OM,H:dM,I:fM,j:pM,L:mM,m:gM,M:_M,p:se,q:ce,Q:jM,s:MM,S:vM,u:yM,U:bM,V:SM,w:CM,W:wM,x:null,X:null,y:TM,Y:DM,Z:kM,"%":AM},x={a:E,A:D,b:O,B:k,c:A,d:Pj,e:Pj,f:Bj,g:Aj,G:kj,H:Ij,I:Ij,j:Fj,L:zj,m:Nj,M:Lj,p:T,q:Mj,Q:Hj,s:Uj,S:Rj,u:Tj,U:Ej,V:Dj,w:wj,W:Oj,x:j,X:M,y:Aj,Y:kj,Z:jj,"%":Vj};y.x=S(n,y),y.X=S(r,y),y.c=S(t,y),b.x=S(n,b),b.X=S(r,b),b.c=S(t,b);function S(e,t){return function(n){var r=[],i=-1,a=0,o=e.length,s,c,l;for(n instanceof Date||(n=new Date(+n));++i<o;)e.charCodeAt(i)===37&&(r.push(e.slice(a,i)),(c=gj[s=e.charAt(++i)])==null?c=s===`e`?` `:`0`:s=e.charAt(++i),(l=t[s])&&(s=l(n,c)),r.push(s),a=i+1);return r.push(e.slice(a,i)),r.join(``)}}function C(e,t){return function(n){var r=mj(1900,void 0,1),i=w(r,e,n+=``,0),a,o;if(i!=n.length)return null;if(`Q`in r)return new Date(r.Q);if(`s`in r)return new Date(r.s*1e3+(`L`in r?r.L:0));if(t&&!(`Z`in r)&&(r.Z=0),`p`in r&&(r.H=r.H%12+r.p*12),r.m===void 0&&(r.m=`q`in r?r.q:0),`V`in r){if(r.V<1||r.V>53)return null;`w`in r||(r.w=1),`Z`in r?(a=pj(mj(r.y,0,1)),o=a.getUTCDay(),a=o>4||o===0?XA.ceil(a):XA(a),a=RA.offset(a,(r.V-1)*7),r.y=a.getUTCFullYear(),r.m=a.getUTCMonth(),r.d=a.getUTCDate()+(r.w+6)%7):(a=fj(mj(r.y,0,1)),o=a.getDay(),a=o>4||o===0?HA.ceil(a):HA(a),a=LA.offset(a,(r.V-1)*7),r.y=a.getFullYear(),r.m=a.getMonth(),r.d=a.getDate()+(r.w+6)%7)}else(`W`in r||`U`in r)&&(`w`in r||(r.w=`u`in r?r.u%7:+(`W`in r)),o=`Z`in r?pj(mj(r.y,0,1)).getUTCDay():fj(mj(r.y,0,1)).getDay(),r.m=0,r.d=`W`in r?(r.w+6)%7+r.W*7-(o+5)%7:r.w+r.U*7-(o+6)%7);return`Z`in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,pj(r)):fj(r)}}function w(e,t,n,r){for(var i=0,a=t.length,o=n.length,s,c;i<a;){if(r>=o)return-1;if(s=t.charCodeAt(i++),s===37){if(s=t.charAt(i++),c=x[s in gj?t.charAt(i++):s],!c||(r=c(e,n,r))<0)return-1}else if(s!=n.charCodeAt(r++))return-1}return r}function T(e,t,n){var r=l.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1}function E(e,t,n){var r=p.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1}function D(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=f.get(r[0].toLowerCase()),n+r[0].length):-1}function O(e,t,n){var r=_.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1}function k(e,t,n){var r=h.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1}function A(e,n,r){return w(e,t,n,r)}function j(e,t,r){return w(e,n,t,r)}function M(e,t,n){return w(e,r,t,n)}function N(e){return o[e.getDay()]}function ee(e){return a[e.getDay()]}function te(e){return c[e.getMonth()]}function P(e){return s[e.getMonth()]}function F(e){return i[+(e.getHours()>=12)]}function ne(e){return 1+~~(e.getMonth()/3)}function re(e){return o[e.getUTCDay()]}function ie(e){return a[e.getUTCDay()]}function ae(e){return c[e.getUTCMonth()]}function oe(e){return s[e.getUTCMonth()]}function se(e){return i[+(e.getUTCHours()>=12)]}function ce(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var t=S(e+=``,y);return t.toString=function(){return e},t},parse:function(e){var t=C(e+=``,!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=S(e+=``,b);return t.toString=function(){return e},t},utcParse:function(e){var t=C(e+=``,!0);return t.toString=function(){return e},t}}}var gj={"-":``,_:` `,0:`0`},_j=/^\s*\d+/,vj=/^%/,yj=/[\\^$*+?|[\]().{}]/g;function bj(e,t,n){var r=e<0?`-`:``,i=(r?-e:e)+``,a=i.length;return r+(a<n?Array(n-a+1).join(t)+i:i)}function xj(e){return e.replace(yj,`\\$&`)}function Sj(e){return RegExp(`^(?:`+e.map(xj).join(`|`)+`)`,`i`)}function Cj(e){return new Map(e.map((e,t)=>[e.toLowerCase(),t]))}function wj(e,t,n){var r=_j.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function Tj(e,t,n){var r=_j.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function Ej(e,t,n){var r=_j.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function Dj(e,t,n){var r=_j.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function Oj(e,t,n){var r=_j.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function kj(e,t,n){var r=_j.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function Aj(e,t,n){var r=_j.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function jj(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||`00`)),n+r[0].length):-1}function Mj(e,t,n){var r=_j.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function Nj(e,t,n){var r=_j.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function Pj(e,t,n){var r=_j.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function Fj(e,t,n){var r=_j.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function Ij(e,t,n){var r=_j.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function Lj(e,t,n){var r=_j.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function Rj(e,t,n){var r=_j.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function zj(e,t,n){var r=_j.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function Bj(e,t,n){var r=_j.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Vj(e,t,n){var r=vj.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Hj(e,t,n){var r=_j.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function Uj(e,t,n){var r=_j.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function Wj(e,t){return bj(e.getDate(),t,2)}function Gj(e,t){return bj(e.getHours(),t,2)}function Kj(e,t){return bj(e.getHours()%12||12,t,2)}function qj(e,t){return bj(1+LA.count(ij(e),e),t,3)}function Jj(e,t){return bj(e.getMilliseconds(),t,3)}function Yj(e,t){return Jj(e,t)+`000`}function Xj(e,t){return bj(e.getMonth()+1,t,2)}function Zj(e,t){return bj(e.getMinutes(),t,2)}function Qj(e,t){return bj(e.getSeconds(),t,2)}function $j(e){var t=e.getDay();return t===0?7:t}function eM(e,t){return bj(VA.count(ij(e)-1,e),t,2)}function tM(e){var t=e.getDay();return t>=4||t===0?GA(e):GA.ceil(e)}function nM(e,t){return e=tM(e),bj(GA.count(ij(e),e)+(ij(e).getDay()===4),t,2)}function rM(e){return e.getDay()}function iM(e,t){return bj(HA.count(ij(e)-1,e),t,2)}function aM(e,t){return bj(e.getFullYear()%100,t,2)}function oM(e,t){return e=tM(e),bj(e.getFullYear()%100,t,2)}function sM(e,t){return bj(e.getFullYear()%1e4,t,4)}function cM(e,t){var n=e.getDay();return e=n>=4||n===0?GA(e):GA.ceil(e),bj(e.getFullYear()%1e4,t,4)}function lM(e){var t=e.getTimezoneOffset();return(t>0?`-`:(t*=-1,`+`))+bj(t/60|0,`0`,2)+bj(t%60,`0`,2)}function uM(e,t){return bj(e.getUTCDate(),t,2)}function dM(e,t){return bj(e.getUTCHours(),t,2)}function fM(e,t){return bj(e.getUTCHours()%12||12,t,2)}function pM(e,t){return bj(1+RA.count(aj(e),e),t,3)}function mM(e,t){return bj(e.getUTCMilliseconds(),t,3)}function hM(e,t){return mM(e,t)+`000`}function gM(e,t){return bj(e.getUTCMonth()+1,t,2)}function _M(e,t){return bj(e.getUTCMinutes(),t,2)}function vM(e,t){return bj(e.getUTCSeconds(),t,2)}function yM(e){var t=e.getUTCDay();return t===0?7:t}function bM(e,t){return bj(YA.count(aj(e)-1,e),t,2)}function xM(e){var t=e.getUTCDay();return t>=4||t===0?$A(e):$A.ceil(e)}function SM(e,t){return e=xM(e),bj($A.count(aj(e),e)+(aj(e).getUTCDay()===4),t,2)}function CM(e){return e.getUTCDay()}function wM(e,t){return bj(XA.count(aj(e)-1,e),t,2)}function TM(e,t){return bj(e.getUTCFullYear()%100,t,2)}function EM(e,t){return e=xM(e),bj(e.getUTCFullYear()%100,t,2)}function DM(e,t){return bj(e.getUTCFullYear()%1e4,t,4)}function OM(e,t){var n=e.getUTCDay();return e=n>=4||n===0?$A(e):$A.ceil(e),bj(e.getUTCFullYear()%1e4,t,4)}function kM(){return`+0000`}function AM(){return`%`}function jM(e){return+e}function MM(e){return Math.floor(e/1e3)}var NM,PM,FM;IM({dateTime:`%x, %X`,date:`%-m/%-d/%Y`,time:`%-I:%M:%S %p`,periods:[`AM`,`PM`],days:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],shortDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],shortMonths:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]});function IM(e){return NM=hj(e),PM=NM.format,NM.parse,FM=NM.utcFormat,NM.utcParse,NM}function LM(e){return new Date(e)}function RM(e){return e instanceof Date?+e:+new Date(+e)}function zM(e,t,n,r,i,a,o,s,c,l){var u=bk(),d=u.invert,f=u.domain,p=l(`.%L`),m=l(`:%S`),h=l(`%I:%M`),g=l(`%I %p`),_=l(`%a %d`),v=l(`%b %d`),y=l(`%B`),b=l(`%Y`);function x(e){return(c(e)<e?p:s(e)<e?m:o(e)<e?h:a(e)<e?g:r(e)<e?i(e)<e?_:v:n(e)<e?y:b)(e)}return u.invert=function(e){return new Date(d(e))},u.domain=function(e){return arguments.length?f(Array.from(e,RM)):f().map(LM)},u.ticks=function(t){var n=f();return e(n[0],n[n.length-1],t??10)},u.tickFormat=function(e,t){return t==null?x:l(t)},u.nice=function(e){var n=f();return(!e||typeof e.range!=`function`)&&(e=t(n[0],n[n.length-1],e??10)),e?f(Yk(n,e)):u},u.copy=function(){return vk(u,zM(e,t,n,r,i,a,o,s,c,l))},u}function BM(){return QD.apply(zM(uj,dj,ij,nj,VA,LA,FA,NA,MA,PM).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function VM(){return QD.apply(zM(cj,lj,aj,rj,YA,RA,IA,PA,MA,FM).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function HM(){var e=0,t=1,n,r,i,a,o=pk,s=!1,c;function l(e){return e==null||isNaN(e=+e)?c:o(i===0?.5:(e=(a(e)-n)*i,s?Math.max(0,Math.min(1,e)):e))}l.domain=function(o){return arguments.length?([e,t]=o,n=a(e=+e),r=a(t=+t),i=n===r?0:1/(r-n),l):[e,t]},l.clamp=function(e){return arguments.length?(s=!!e,l):s},l.interpolator=function(e){return arguments.length?(o=e,l):o};function u(e){return function(t){var n,r;return arguments.length?([n,r]=t,o=e(n,r),l):[o(0),o(1)]}}return l.range=u(sk),l.rangeRound=u(ck),l.unknown=function(e){return arguments.length?(c=e,l):c},function(o){return a=o,n=o(e),r=o(t),i=n===r?0:1/(r-n),l}}function UM(e,t){return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function WM(){var e=Kk(HM()(pk));return e.copy=function(){return UM(e,WM())},$D.apply(e,arguments)}function GM(){var e=iA(HM()).domain([1,10]);return e.copy=function(){return UM(e,GM()).base(e.base())},$D.apply(e,arguments)}function KM(){var e=cA(HM());return e.copy=function(){return UM(e,KM()).constant(e.constant())},$D.apply(e,arguments)}function qM(){var e=pA(HM());return e.copy=function(){return UM(e,qM()).exponent(e.exponent())},$D.apply(e,arguments)}function JM(){return qM.apply(null,arguments).exponent(.5)}function YM(){var e=[],t=pk;function n(n){if(n!=null&&!isNaN(n=+n))return t((AD(e,n,1)-1)/(e.length-1))}return n.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(CD),n},n.interpolator=function(e){return arguments.length?(t=e,n):t},n.range=function(){return e.map((n,r)=>t(r/(e.length-1)))},n.quantiles=function(t){return Array.from({length:t+1},(n,r)=>LD(e,r/t))},n.copy=function(){return YM(t).domain(e)},$D.apply(n,arguments)}function XM(){var e=0,t=.5,n=1,r=1,i,a,o,s,c,l=pk,u,d=!1,f;function p(e){return isNaN(e=+e)?f:(e=.5+((e=+u(e))-a)*(r*e<r*a?s:c),l(d?Math.max(0,Math.min(1,e)):e))}p.domain=function(l){return arguments.length?([e,t,n]=l,i=u(e=+e),a=u(t=+t),o=u(n=+n),s=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p):[e,t,n]},p.clamp=function(e){return arguments.length?(d=!!e,p):d},p.interpolator=function(e){return arguments.length?(l=e,p):l};function m(e){return function(t){var n,r,i;return arguments.length?([n,r,i]=t,l=lk(e,[n,r,i]),p):[l(0),l(.5),l(1)]}}return p.range=m(sk),p.rangeRound=m(ck),p.unknown=function(e){return arguments.length?(f=e,p):f},function(l){return u=l,i=l(e),a=l(t),o=l(n),s=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function ZM(){var e=Kk(XM()(pk));return e.copy=function(){return UM(e,ZM())},$D.apply(e,arguments)}function QM(){var e=iA(XM()).domain([.1,1,10]);return e.copy=function(){return UM(e,QM()).base(e.base())},$D.apply(e,arguments)}function $M(){var e=cA(XM());return e.copy=function(){return UM(e,$M()).constant(e.constant())},$D.apply(e,arguments)}function eN(){var e=pA(XM());return e.copy=function(){return UM(e,eN()).exponent(e.exponent())},$D.apply(e,arguments)}function tN(){return eN.apply(null,arguments).exponent(.5)}var nN=s({scaleBand:()=>nO,scaleDiverging:()=>ZM,scaleDivergingLog:()=>QM,scaleDivergingPow:()=>eN,scaleDivergingSqrt:()=>tN,scaleDivergingSymlog:()=>$M,scaleIdentity:()=>Jk,scaleImplicit:()=>eO,scaleLinear:()=>qk,scaleLog:()=>aA,scaleOrdinal:()=>tO,scalePoint:()=>iO,scalePow:()=>mA,scaleQuantile:()=>yA,scaleQuantize:()=>bA,scaleRadial:()=>vA,scaleSequential:()=>WM,scaleSequentialLog:()=>GM,scaleSequentialPow:()=>qM,scaleSequentialQuantile:()=>YM,scaleSequentialSqrt:()=>JM,scaleSequentialSymlog:()=>KM,scaleSqrt:()=>hA,scaleSymlog:()=>lA,scaleThreshold:()=>xA,scaleTime:()=>BM,scaleUtc:()=>VM,tickFormat:()=>Gk});function rN(e){var t=nN;if(e in t&&typeof t[e]==`function`)return t[e]();var n=`scale${gp(e)}`;if(n in t&&typeof t[n]==`function`)return t[n]()}function iN(e,t,n){if(typeof e==`function`)return e.copy().domain(t).range(n);if(e!=null){var r=rN(e);if(r!=null)return r.domain(t).range(n),r}}function aN(e,t,n,r){if(!(n==null||r==null))return typeof e.scale==`function`?iN(e.scale,n,r):iN(t,n,r)}function oN(e){return`scale${gp(e)}`}function sN(e){return oN(e)in nN}var cN=(e,t,n)=>{if(e!=null){var r=e.scale,i=e.type;if(r===`auto`)return i===`category`&&n&&(n.indexOf(`LineChart`)>=0||n.indexOf(`AreaChart`)>=0||n.indexOf(`ComposedChart`)>=0&&!t)?`point`:i===`category`?`band`:`linear`;if(typeof r==`string`)return sN(r)?r:`point`}};function lN(e,t){for(var n=0,r=e.length,i=e[0]<e[e.length-1];n<r;){var a=Math.floor((n+r)/2);(i?e[a]<t:e[a]>t)?n=a+1:r=a}return n}function uN(e,t){if(e){var n=t??e.domain(),r=n.map(t=>e(t)??0),i=e.range();if(!(n.length===0||i.length<2))return e=>{var t=lN(r,e);if(t<=0)return n[0];if(t>=n.length)return n[n.length-1];var i=r[t-1]??0,a=r[t]??0;return Math.abs(e-i)<=Math.abs(e-a)?n[t-1]:n[t]}}}function dN(e){if(e!=null)return`invert`in e&&typeof e.invert==`function`?e.invert.bind(e):uN(e,void 0)}function fN(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pN(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?fN(Object(n),!0).forEach(function(t){mN(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fN(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mN(e,t,n){return(t=hN(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function hN(e){var t=gN(e,`string`);return typeof t==`symbol`?t:t+``}function gN(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _N(e,t){return SN(e)||xN(e,t)||yN(e,t)||vN()}function vN(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yN(e,t){if(e){if(typeof e==`string`)return bN(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bN(e,t):void 0}}function bN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function xN(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function SN(e){if(Array.isArray(e))return e}var CN=[0,`auto`],wN={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:void 0,height:30,hide:!0,id:0,includeHidden:!1,interval:`preserveEnd`,minTickGap:5,mirror:!1,name:void 0,orientation:`bottom`,padding:{left:0,right:0},reversed:!1,scale:`auto`,tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:`category`,unit:void 0,niceTicks:`auto`},TN=(e,t)=>e.cartesianAxis.xAxis[t],EN=(e,t)=>TN(e,t)??wN,DN={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:CN,hide:!0,id:0,includeHidden:!1,interval:`preserveEnd`,minTickGap:5,mirror:!1,name:void 0,orientation:`left`,padding:{top:0,bottom:0},reversed:!1,scale:`auto`,tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:`number`,unit:void 0,niceTicks:`auto`,width:60},ON=(e,t)=>e.cartesianAxis.yAxis[t],kN=(e,t)=>ON(e,t)??DN,AN={domain:[0,`auto`],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:``,range:[64,64],scale:`auto`,type:`number`,unit:``},jN=(e,t)=>e.cartesianAxis.zAxis[t]??AN,MN=(e,t,n)=>{switch(t){case`xAxis`:return EN(e,n);case`yAxis`:return kN(e,n);case`zAxis`:return jN(e,n);case`angleAxis`:return nD(e,n);case`radiusAxis`:return rD(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},NN=(e,t,n)=>{switch(t){case`xAxis`:return EN(e,n);case`yAxis`:return kN(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},PN=(e,t,n)=>{switch(t){case`xAxis`:return EN(e,n);case`yAxis`:return kN(e,n);case`angleAxis`:return nD(e,n);case`radiusAxis`:return rD(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},FN=e=>e.graphicalItems.cartesianItems.some(e=>e.type===`bar`)||e.graphicalItems.polarItems.some(e=>e.type===`radialBar`);function IN(e,t){return n=>{switch(e){case`xAxis`:return`xAxisId`in n&&n.xAxisId===t;case`yAxis`:return`yAxisId`in n&&n.yAxisId===t;case`zAxis`:return`zAxisId`in n&&n.zAxisId===t;case`angleAxis`:return`angleAxisId`in n&&n.angleAxisId===t;case`radiusAxis`:return`radiusAxisId`in n&&n.radiusAxisId===t;default:return!1}}}var LN=e=>e.graphicalItems.cartesianItems,RN=Q([dD,fD],IN),zN=(e,t,n)=>e.filter(n).filter(e=>t?.includeHidden===!0?!0:!e.hide),BN=Q([LN,MN,RN],zN,{memoizeOptions:{resultEqualityCheck:_D}}),VN=Q([BN],e=>e.filter(e=>e.type===`area`||e.type===`bar`).filter(hD)),HN=e=>e.filter(e=>!(`stackId`in e)||e.stackId===void 0),UN=Q([BN],HN),WN=e=>e.map(e=>e.data).filter(Boolean).flat(1),GN=Q([BN],e=>e.some(e=>!e.data)),KN=Q([BN],WN,{memoizeOptions:{resultEqualityCheck:_D}}),qN=(e,t)=>{var n=t.chartData,r=n===void 0?[]:n,i=t.dataStartIndex,a=t.dataEndIndex;return e.length>0?e:r.slice(i,a+1)},JN=Q([KN,nE],qN),YN=(e,t,n)=>t?.dataKey==null?n.length>0?n.map(e=>e.dataKey).flatMap(t=>e.map(e=>({value:uy(e,t)}))):e.map(e=>({value:e})):e.map(e=>({value:uy(e,t.dataKey)})),XN=(e,t,n,r,i,a)=>{var o=r.chartData,s=o===void 0?[]:o,c=r.dataStartIndex,l=r.dataEndIndex,u=YN(e,t,n);return i&&t?.dataKey!=null&&a.length>0?[...s.slice(c,l+1).map(e=>({value:uy(e,t.dataKey)})).filter(e=>e.value!=null),...u]:u},ZN=Q([JN,MN,BN,nE,GN,KN],XN);function QN(e){if(cp(e)||e instanceof Date){var t=Number(e);if(ry(t))return t}}function $N(e){if(Array.isArray(e)){var t=[QN(e[0]),QN(e[1])];return pE(t)?t:void 0}var n=QN(e);if(n!=null)return[n,n]}function eP(e){return e.map(QN).filter(_p)}function tP(e,t){var n=QN(e),r=QN(t);return n==null&&r==null?0:n==null?-1:r==null?1:n-r}var nP=Q([ZN],e=>e?.map(e=>e.value).sort(tP));function rP(e,t){switch(e){case`xAxis`:return t.direction===`x`;case`yAxis`:return t.direction===`y`;default:return!1}}function iP(e,t,n){if(!n||!n.length)return[];var r;if(typeof t==`number`&&!op(t))r=t;else if(Array.isArray(t)){var i=eP(t);i.length>0&&(r=Math.max(...i))}return r==null?[]:eP(n.flatMap(t=>{var n=uy(e,t.dataKey),i,a;if(Array.isArray(n)){var o=_N(n,2);i=o[0],a=o[1]}else i=a=n;if(!(!ry(i)||!ry(a)))return[r-i,r+a]}))}var aP=e=>PN(e,yD(e),bD(e)),oP=Q([aP],e=>e?.dataKey),sP=Q([VN,nE,aP],mD),cP=(e,t,n,r)=>{var i=t.reduce((e,t)=>{if(t.stackId==null)return e;var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},{});return Object.fromEntries(Object.entries(i).map(t=>{var i=_N(t,2),a=i[0],o=i[1],s=r?[...o].reverse():o;return[a,{stackedData:_y(e,s.map(pD),n),graphicalItems:s}]}))},lP=Q([sP,VN,LE,RE],cP),uP=(e,t,n,r)=>{var i=t.dataStartIndex,a=t.dataEndIndex;if(r==null&&n!==`zAxis`)return wy(e,i,a)},dP=Q([MN],e=>e.allowDataOverflow),fP=e=>{if(e==null||!(`domain`in e))return CN;if(e.domain!=null)return e.domain;if(`ticks`in e&&e.ticks!=null){if(e.type===`number`){var t=eP(e.ticks);return[Math.min(...t),Math.max(...t)]}if(e.type===`category`)return e.ticks.map(String)}return e?.domain??CN},pP=Q([MN],fP),mP=Q([pP,dP],hE),hP=Q([lP,eE,dD,mP],uP,{memoizeOptions:{resultEqualityCheck:gD}}),gP=e=>e.errorBars,_P=(e,t,n)=>e.flatMap(e=>t[e.id]).filter(Boolean).filter(e=>rP(n,e)),vP=function(){var e=[...arguments].filter(Boolean);if(e.length!==0){var t=e.flat();return[Math.min(...t),Math.max(...t)]}},yP=function(e,t,n,r,i){var a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:[],o,s;if(n.length>0&&n.forEach(e=>{var n=e.data==null?a:[...e.data],c=r[e.id]?.filter(e=>rP(i,e));n.forEach(n=>{var r=uy(n,t.dataKey??e.dataKey),i=iP(n,r,c);if(i.length>=2){var a=Math.min(...i),l=Math.max(...i);(o==null||a<o)&&(o=a),(s==null||l>s)&&(s=l)}var u=$N(r);u!=null&&(o=o==null?u[0]:Math.min(o,u[0]),s=s==null?u[1]:Math.max(s,u[1]))})}),t?.dataKey!=null&&n.length===0&&e.forEach(e=>{var n=$N(uy(e,t.dataKey));n!=null&&(o=o==null?n[0]:Math.min(o,n[0]),s=s==null?n[1]:Math.max(s,n[1]))}),ry(o)&&ry(s))return[o,s]},bP=Q([JN,MN,UN,gP,dD,iE],yP,{memoizeOptions:{resultEqualityCheck:gD}});function xP(e){var t=e.value;if(cp(t)||t instanceof Date)return t}var SP=(e,t,n)=>{var r=e.map(xP).filter(e=>e!=null);return n&&(t.dataKey==null||t.allowDuplicatedCategory&&fp(r))?$T(0,e.length):t.allowDuplicatedCategory?r:Array.from(new Set(r))},CP=e=>e.referenceElements.dots,wP=(e,t,n)=>e.filter(e=>e.ifOverflow===`extendDomain`).filter(e=>t===`xAxis`?e.xAxisId===n:e.yAxisId===n),TP=Q([CP,dD,fD],wP),EP=e=>e.referenceElements.areas,DP=Q([EP,dD,fD],wP),OP=e=>e.referenceElements.lines,kP=Q([OP,dD,fD],wP),AP=(e,t)=>{if(e!=null){var n=eP(e.map(e=>t===`xAxis`?e.x:e.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},jP=Q(TP,dD,AP),MP=(e,t)=>{if(e!=null){var n=eP(e.flatMap(e=>[t===`xAxis`?e.x1:e.y1,t===`xAxis`?e.x2:e.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},NP=Q([DP,dD],MP);function PP(e){if(e.x!=null)return eP([e.x]);var t=e.segment?.map(e=>e.x);return t==null||t.length===0?[]:eP(t)}function FP(e){if(e.y!=null)return eP([e.y]);var t=e.segment?.map(e=>e.y);return t==null||t.length===0?[]:eP(t)}var IP=(e,t)=>{if(e!=null){var n=e.flatMap(e=>t===`xAxis`?PP(e):FP(e));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},LP=Q(jP,Q([kP,dD],IP),NP,(e,t,n)=>vP(e,n,t)),RP=(e,t,n,r,i,a,o,s)=>n??gE(t,o===`vertical`&&s===`xAxis`||o===`horizontal`&&s===`yAxis`?vP(r,a,i):vP(a,i),e.allowDataOverflow),zP=Q([MN,pP,mP,hP,bP,LP,Ub,dD],RP,{memoizeOptions:{resultEqualityCheck:gD}}),BP=[0,1],VP=(e,t,n,r,i,a,o)=>{if(!((e==null||n==null||n.length===0)&&o===void 0)){var s=e.dataKey,c=e.type,l=fy(t,a);return l&&s==null?$T(0,n?.length??0):c===`category`?SP(r,e,l):i===`expand`&&!l?BP:o}},HP=Q([MN,Ub,JN,ZN,LE,dD,zP],VP),UP=Q([MN,FN,zE],cN),WP=(e,t,n)=>{var r=t.niceTicks;if(r!==`none`){var i=fP(t),a=Array.isArray(i)&&(i[0]===`auto`||i[1]===`auto`);if((r===`snap125`||r===`adaptive`)&&t!=null&&t.tickCount&&pE(e)){if(a)return jE(e,t.tickCount,t.allowDecimals,r);if(t.type===`number`)return ME(e,t.tickCount,t.allowDecimals,r)}if(r===`auto`&&n===`linear`&&t!=null&&t.tickCount){if(a&&pE(e))return jE(e,t.tickCount,t.allowDecimals,`adaptive`);if(t.type===`number`&&pE(e))return ME(e,t.tickCount,t.allowDecimals,`adaptive`)}}},GP=Q([HP,PN,UP],WP),KP=(e,t,n,r)=>{if(r!==`angleAxis`&&e?.type===`number`&&pE(t)&&Array.isArray(n)&&n.length>0){var i=t[0],a=n[0]??0,o=t[1],s=n[n.length-1]??0;return[Math.min(i,a),Math.max(o,s)]}return t},qP=Q([MN,HP,GP,dD],KP),JP=Q(Q(ZN,MN,(e,t)=>{if(!(!t||t.type!==`number`)){var n=1/0,r=Array.from(eP(e.map(e=>e.value))).sort((e,t)=>e-t),i=r[0],a=r[r.length-1];if(i==null||a==null)return 1/0;var o=a-i;if(o===0)return 1/0;for(var s=0;s<r.length-1;s++){var c=r[s],l=r[s+1];if(!(c==null||l==null)){var u=l-c;n=Math.min(n,u)}}return n/o}}),Ub,FE,Xy,(e,t,n,r,i)=>i,(e,t,n,r,i)=>{if(!ry(e))return 0;var a=t===`vertical`?r.height:r.width;if(i===`gap`)return e*a/2;if(i===`no-gap`){var o=dp(n,e*a),s=e*a/2;return s-o-(s-o)/a*o}return 0}),YP=(e,t,n)=>{var r=EN(e,t);return r==null||typeof r.padding!=`string`?0:JP(e,`xAxis`,t,n,r.padding)},XP=(e,t,n)=>{var r=kN(e,t);return r==null||typeof r.padding!=`string`?0:JP(e,`yAxis`,t,n,r.padding)},ZP=Q(EN,YP,(e,t)=>{if(e==null)return{left:0,right:0};var n=e.padding;return typeof n==`string`?{left:t,right:t}:{left:(n.left??0)+t,right:(n.right??0)+t}}),QP=Q(kN,XP,(e,t)=>{if(e==null)return{top:0,bottom:0};var n=e.padding;return typeof n==`string`?{top:t,bottom:t}:{top:(n.top??0)+t,bottom:(n.bottom??0)+t}}),$P=Q([Xy,ZP,nb,tb,(e,t,n)=>n],(e,t,n,r,i)=>{var a=r.padding;return i?[a.left,n.width-a.right]:[e.left+t.left,e.left+e.width-t.right]}),eF=Q([Xy,Ub,QP,nb,tb,(e,t,n)=>n],(e,t,n,r,i,a)=>{var o=i.padding;return a?[r.height-o.bottom,o.top]:t===`horizontal`?[e.top+e.height-n.bottom,e.top+n.top]:[e.top+n.top,e.top+e.height-n.bottom]}),tF=(e,t,n,r)=>{switch(t){case`xAxis`:return $P(e,n,r);case`yAxis`:return eF(e,n,r);case`zAxis`:return jN(e,n)?.range;case`angleAxis`:return cD(e);case`radiusAxis`:return lD(e,n);default:return}},nF=Q([MN,tF],qE),rF=Q([MN,UP,Q([UP,qP],SD),nF],aN),iF=(e,t,n,r)=>{if(!(n==null||n.dataKey==null)){var i=n.type,a=n.scale;if(fy(e,r)&&(i===`number`||a!==`auto`))return t.map(e=>e.value)}},aF=Q([Ub,ZN,PN,dD],iF),oF=Q([rF],xD);Q([rF],dN),Q([rF,nP],uN),Q([BN,gP,dD],_P);function sF(e,t){return e.id<t.id?-1:+(e.id>t.id)}var cF=(e,t)=>t,lF=(e,t,n)=>n,uF=Q(Iy,cF,lF,(e,t,n)=>e.filter(e=>e.orientation===t).filter(e=>e.mirror===n).sort(sF)),dF=Q(Ly,cF,lF,(e,t,n)=>e.filter(e=>e.orientation===t).filter(e=>e.mirror===n).sort(sF)),fF=(e,t)=>({width:e.width,height:t.height}),pF=(e,t)=>({width:typeof t.width==`number`?t.width:60,height:e.height}),mF=Q(Xy,EN,fF),hF=(e,t,n)=>{switch(t){case`top`:return e.top;case`bottom`:return n-e.bottom;default:return 0}},gF=(e,t,n)=>{switch(t){case`left`:return e.left;case`right`:return n-e.right;default:return 0}},_F=Q(Ny,Xy,uF,cF,lF,(e,t,n,r,i)=>{var a={},o;return n.forEach(n=>{var s=fF(t,n);o??=hF(t,r,e);var c=r===`top`&&!i||r===`bottom`&&i;a[n.id]=o-Number(c)*s.height,o+=(c?-1:1)*s.height}),a}),vF=Q(My,Xy,dF,cF,lF,(e,t,n,r,i)=>{var a={},o;return n.forEach(n=>{var s=pF(t,n);o??=gF(t,r,e);var c=r===`left`&&!i||r===`right`&&i;a[n.id]=o-Number(c)*s.width,o+=(c?-1:1)*s.width}),a}),yF=Q([Xy,EN,(e,t)=>{var n=EN(e,t);if(n!=null)return _F(e,n.orientation,n.mirror)},(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n?.[r];return i==null?{x:e.left,y:0}:{x:e.left,y:i}}}),bF=Q([Xy,kN,(e,t)=>{var n=kN(e,t);if(n!=null)return vF(e,n.orientation,n.mirror)},(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n?.[r];return i==null?{x:0,y:e.top}:{x:i,y:e.top}}}),xF=Q(Xy,kN,(e,t)=>({width:typeof t.width==`number`?t.width:60,height:e.height})),SF=(e,t,n)=>{switch(t){case`xAxis`:return mF(e,n).width;case`yAxis`:return xF(e,n).height;default:return}},CF=(e,t,n,r)=>{if(n!=null){var i=n.allowDuplicatedCategory,a=n.type,o=n.dataKey,s=fy(e,r),c=t.map(e=>e.value),l=c.filter(e=>e!=null);if(o&&s&&a===`category`&&i&&fp(l))return c}},wF=Q([Ub,ZN,MN,dD],CF),TF=Q([Ub,NN,UP,oF,wF,aF,tF,GP,dD],(e,t,n,r,i,a,o,s,c)=>{if(t!=null){var l=fy(e,c);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:l,niceTicks:s,range:o,realScaleType:n,scale:r}}}),EF=Q([Ub,PN,UP,oF,GP,tF,wF,aF,dD],(e,t,n,r,i,a,o,s,c)=>{if(!(t==null||r==null)){var l=fy(e,c),u=t.type,d=t.ticks,f=t.tickCount,p=n===`scaleBand`&&typeof r.bandwidth==`function`?r.bandwidth()/2:2,m=u===`category`&&r.bandwidth?r.bandwidth()/p:0;m=c===`angleAxis`&&a!=null&&a.length>=2?ap(a[0]-a[1])*2*m:m;var h=d||i;return h?h.map((e,t)=>{var n=o?o.indexOf(e):e,i=r.map(n);return ry(i)?{index:t,coordinate:i+m,value:e,offset:m}:null}).filter(_p):l&&s?s.map((e,t)=>{var n=r.map(e);return ry(n)?{coordinate:n+m,value:e,index:t,offset:m}:null}).filter(_p):r.ticks?r.ticks(f).map((e,t)=>{var n=r.map(e);return ry(n)?{coordinate:n+m,value:e,index:t,offset:m}:null}).filter(_p):r.domain().map((e,t)=>{var n=r.map(e);return ry(n)?{coordinate:n+m,value:o?o[e]:e,index:t,offset:m}:null}).filter(_p)}}),DF=Q([Ub,PN,oF,tF,wF,aF,dD],(e,t,n,r,i,a,o)=>{if(!(t==null||n==null||r==null||r[0]===r[1])){var s=fy(e,o),c=t.tickCount,l=0;return l=o===`angleAxis`&&r?.length>=2?ap(r[0]-r[1])*2*l:l,s&&a?a.map((e,t)=>{var r=n.map(e);return ry(r)?{coordinate:r+l,value:e,index:t,offset:l}:null}).filter(_p):n.ticks?n.ticks(c).map((e,t)=>{var r=n.map(e);return ry(r)?{coordinate:r+l,value:e,index:t,offset:l}:null}).filter(_p):n.domain().map((e,t)=>{var r=n.map(e);return ry(r)?{coordinate:r+l,value:i?i[e]:e,index:t,offset:l}:null}).filter(_p)}}),OF=Q(MN,oF,(e,t)=>{if(!(e==null||t==null))return pN(pN({},e),{},{scale:t})});Q((e,t,n)=>jN(e,n),Q([Q([MN,UP,HP,nF],aN)],xD),(e,t)=>{if(!(e==null||t==null))return pN(pN({},e),{},{scale:t})});var kF=Q([Ub,Iy,Ly],(e,t,n)=>{switch(e){case`horizontal`:return t.some(e=>e.reversed)?`right-to-left`:`left-to-right`;case`vertical`:return n.some(e=>e.reversed)?`bottom-to-top`:`top-to-bottom`;case`centric`:case`radial`:return`left-to-right`;default:return}});Q([(e,t,n)=>e.renderedTicks[t]?.[n]],e=>{if(!(!e||e.length===0))return t=>{var n=1/0,r=e[0];for(var i of e){var a=Math.abs(i.coordinate-t);a<n&&(n=a,r=i)}return r?.value}});var AF=e=>e.options.defaultTooltipEventType,jF=e=>e.options.validateTooltipEventTypes;function MF(e,t,n){if(e==null)return t;var r=e?`axis`:`item`;return n==null?t:n.includes(r)?r:t}function NF(e,t){return MF(t,AF(e),jF(e))}function PF(e){return Z(t=>NF(t,e))}var FF=(e,t)=>{var n,r=Number(t);if(!(op(r)||t==null))return r>=0?e==null||(n=e[r])==null?void 0:n.value:void 0},IF=e=>e.tooltip.settings,LF={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},RF=sv({name:`tooltip`,initialState:{itemInteraction:{click:LF,hover:LF},axisInteraction:{click:LF,hover:LF},keyboardInteraction:LF,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:`hover`,axisId:0,active:!1,defaultIndex:void 0}},reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(Gx(t.payload))},prepare:K_()},replaceTooltipEntrySettings:{reducer(e,t){var n=t.payload,r=n.prev,i=n.next,a=M_(e).tooltipItemPayloads.indexOf(Gx(r));a>-1&&(e.tooltipItemPayloads[a]=Gx(i))},prepare:K_()},removeTooltipEntrySettings:{reducer(e,t){var n=M_(e).tooltipItemPayloads.indexOf(Gx(t.payload));n>-1&&e.tooltipItemPayloads.splice(n,1)},prepare:K_()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate}}}),zF=RF.actions,BF=zF.addTooltipEntrySettings,VF=zF.replaceTooltipEntrySettings,HF=zF.removeTooltipEntrySettings,UF=zF.setTooltipSettingsState,WF=zF.setActiveMouseOverItemIndex,GF=zF.mouseLeaveItem,KF=zF.mouseLeaveChart,qF=zF.setActiveClickItemIndex,JF=zF.setMouseOverAxisIndex,YF=zF.setMouseClickAxisIndex,XF=zF.setSyncInteraction,ZF=zF.setKeyboardInteraction,QF=RF.reducer;function $F(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?$F(Object(n),!0).forEach(function(t){tI(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$F(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function tI(e,t,n){return(t=nI(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nI(e){var t=rI(e,`string`);return typeof t==`symbol`?t:t+``}function rI(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function iI(e,t,n){return t===`axis`?n===`click`?e.axisInteraction.click:e.axisInteraction.hover:n===`click`?e.itemInteraction.click:e.itemInteraction.hover}function aI(e){return e.index!=null}var oI=(e,t,n,r)=>{if(t==null)return LF;var i=iI(e,t,n);if(i==null)return LF;if(i.active)return i;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var a=e.settings.active===!0;if(aI(i)){if(a)return eI(eI({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return eI(eI({},LF),{},{coordinate:i.coordinate})};function sI(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(e instanceof Date){var t=e.valueOf();return Number.isFinite(t)?t:void 0}var n=Number(e);return Number.isFinite(n)?n:void 0}function cI(e,t){var n=sI(e),r=t[0],i=t[1];return n===void 0?!1:n>=Math.min(r,i)&&n<=Math.max(r,i)}function lI(e,t,n){if(n==null||t==null)return!0;var r=uy(e,t);return r==null||!pE(n)?!0:cI(r,n)}var uI=(e,t,n,r)=>{var i=e?.index;if(i==null)return null;var a=Number(i);if(!ry(a))return i;var o=0,s=1/0;t.length>0&&(s=t.length-1);var c=Math.max(o,Math.min(a,s)),l=t[c];return l==null||lI(l,n,r)?String(c):null},dI=(e,t,n,r,i,a,o)=>{if(a!=null){var s=o[0]?.getPosition(a);if(s!=null)return s;var c=i?.[Number(a)];if(c)switch(n){case`horizontal`:return{x:c.coordinate,y:(r.top+t)/2};default:return{x:(r.left+e)/2,y:c.coordinate}}}},fI=(e,t,n,r)=>{if(t===`axis`)return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var i=n===`hover`?e.itemInteraction.hover.graphicalItemId:e.itemInteraction.click.graphicalItemId;if(e.syncInteraction.active&&i==null)return e.tooltipItemPayloads;if(i==null&&(r!=null||e.keyboardInteraction.active)){var a=e.tooltipItemPayloads[0];return a==null?[]:[a]}return e.tooltipItemPayloads.filter(e=>e.settings?.graphicalItemId===i)},pI=e=>e.options.tooltipPayloadSearcher,mI=e=>e.tooltip;function hI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function gI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?hI(Object(n),!0).forEach(function(t){_I(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hI(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _I(e,t,n){return(t=vI(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vI(e){var t=yI(e,`string`);return typeof t==`symbol`?t:t+``}function yI(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function bI(e){if(typeof e==`string`||typeof e==`number`)return e}function xI(e){if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e}function SI(e){if(typeof e==`string`||typeof e==`number`)return e;if(typeof e==`function`)return t=>e(t)}function CI(e){if(typeof e==`string`)return e}function wI(e){if(!(typeof e!=`object`||!e))return{name:`name`in e?bI(e.name):void 0,unit:`unit`in e?xI(e.unit):void 0,dataKey:`dataKey`in e?SI(e.dataKey):void 0,payload:`payload`in e?e.payload:void 0,color:`color`in e?CI(e.color):void 0,fill:`fill`in e?CI(e.fill):void 0}}function TI(e,t){return e??t}var EI=(e,t,n,r,i,a,o)=>{if(!(t==null||a==null)){var s=n.chartData,c=n.computedData,l=n.dataStartIndex,u=n.dataEndIndex;return e.reduce((e,n)=>{var d=n.dataDefinedOnItem,f=n.settings,p=TI(d,s),m=Array.isArray(p)?ny(p,l,u):p,h=f?.dataKey??r,g=f?.nameKey,_=r&&Array.isArray(m)&&!Array.isArray(m[0])&&o===`axis`?mp(m,r,i):a(m,t,c,g);return Array.isArray(_)?_.forEach(t=>{var n=wI(t),r=n?.name,i=n?.dataKey,a=n?.payload,o=gI(gI({},f),{},{name:r,unit:n?.unit,color:n?.color??f?.color,fill:n?.fill??f?.fill});e.push(Oy({tooltipEntrySettings:o,dataKey:i,payload:a,value:uy(a,i),name:r==null?void 0:String(r)}))}):e.push(Oy({tooltipEntrySettings:f,dataKey:h,payload:_,value:uy(_,h),name:uy(_,g)??f?.name})),e},[])}},DI=Q([aP,FN,zE],cN),OI=Q([Q([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),aP,Q([yD,bD],IN)],zN,{memoizeOptions:{resultEqualityCheck:_D}}),kI=Q([OI],e=>e.filter(hD)),AI=Q([OI],WN,{memoizeOptions:{resultEqualityCheck:_D}}),jI=Q([OI],e=>e.some(e=>!e.data)),MI=Q([AI,eE],qN),NI=Q([kI,eE,aP],mD),PI=Q([MI,aP,OI,eE,jI,AI],XN),FI=Q([aP],fP),II=Q([FI,Q([aP],e=>e.allowDataOverflow)],hE),LI=Q([Q([NI,Q([OI],e=>e.filter(hD)),LE,RE],cP),eE,yD,II],uP),RI=Q([MI,aP,Q([OI],HN),gP,yD,oE],yP,{memoizeOptions:{resultEqualityCheck:gD}}),zI=Q([Q([CP,yD,bD],wP),yD],AP),BI=Q([Q([EP,yD,bD],wP),yD],MP),VI=Q([aP,Ub,MI,PI,LE,yD,Q([aP,FI,II,LI,RI,Q([zI,Q([Q([OP,yD,bD],wP),yD],IP),BI],vP),Ub,yD],RP)],VP),HI=Q([aP,VI,Q([VI,aP,DI],WP),yD],KP),UI=e=>tF(e,yD(e),bD(e),!1),WI=Q([aP,UI],qE),GI=Q([Q([aP,DI,HI,WI],aN)],xD),KI=Q([Ub,aP,DI,GI,UI,Q([Ub,PI,aP,yD],CF),Q([Ub,PI,aP,yD],iF),yD],(e,t,n,r,i,a,o,s)=>{if(t){var c=t.type,l=fy(e,s);if(r){var u=n===`scaleBand`&&r.bandwidth?r.bandwidth()/2:2,d=c===`category`&&r.bandwidth?r.bandwidth()/u:0;return d=s===`angleAxis`&&i!=null&&i?.length>=2?ap(i[0]-i[1])*2*d:d,l&&o?o.map((e,t)=>{var n=r.map(e);return ry(n)?{coordinate:n+d,value:e,index:t,offset:d}:null}).filter(_p):r.domain().map((e,t)=>{var n=r.map(e);return ry(n)?{coordinate:n+d,value:a?a[e]:e,index:t,offset:d}:null}).filter(_p)}}}),qI=Q([AF,jF,IF],(e,t,n)=>MF(n.shared,e,t)),JI=e=>e.tooltip.settings.trigger,YI=e=>e.tooltip.settings.defaultIndex,XI=Q([mI,qI,JI,YI],oI),ZI=Q([XI,MI,oP,VI],uI),QI=Q([KI,ZI],FF),$I=Q([XI],e=>{if(e)return e.dataKey}),eL=Q([XI],e=>{if(e)return e.graphicalItemId}),tL=Q([mI,qI,JI,YI],fI),nL=Q([XI,Q([My,Ny,Ub,Xy,KI,YI,tL],dI)],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),rL=Q([XI],e=>e?.active??!1),iL=Q([Q([tL,ZI,eE,oP,QI,pI,qI],EI)],e=>{if(e!=null){var t=e.map(e=>e.payload).filter(e=>e!=null);return Array.from(new Set(t))}});function aL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function oL(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?aL(Object(n),!0).forEach(function(t){sL(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function sL(e,t,n){return(t=cL(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cL(e){var t=lL(e,`string`);return typeof t==`symbol`?t:t+``}function lL(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var uL=()=>Z(aP),dL=()=>{var e=uL(),t=Z(KI),n=Z(GI);return Dy(!e||!n?void 0:oL(oL({},e),{},{scale:n}),t)};function fL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pL(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?fL(Object(n),!0).forEach(function(t){mL(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mL(e,t,n){return(t=hL(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function hL(e){var t=gL(e,`string`);return typeof t==`symbol`?t:t+``}function gL(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var _L=(e,t,n,r)=>{var i=t.find(e=>e&&e.index===n);if(i){if(e===`horizontal`)return{x:i.coordinate,y:r.relativeY};if(e===`vertical`)return{x:r.relativeX,y:i.coordinate}}return{x:0,y:0}},vL=(e,t,n,r)=>{var i=t.find(e=>e&&e.index===n);if(i){if(e===`centric`){var a=i.coordinate,o=r.radius;return pL(pL(pL({},r),DT(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var s=i.coordinate,c=r.angle;return pL(pL(pL({},r),DT(r.cx,r.cy,s,c)),{},{angle:c,radius:s})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function yL(e,t){var n=e.relativeX,r=e.relativeY;return n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height}var bL=(e,t,n,r,i)=>{var a=t?.length??0;if(a<=1||e==null)return 0;if(r===`angleAxis`&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var o=0;o<a;o++){var s=o>0?n[o-1]?.coordinate:n[a-1]?.coordinate,c=n[o]?.coordinate,l=o>=a-1?n[0]?.coordinate:n[o+1]?.coordinate,u=void 0;if(!(s==null||c==null||l==null))if(ap(c-s)!==ap(l-c)){var d=[];if(ap(l-c)===ap(i[1]-i[0])){u=l;var f=c+i[1]-i[0];d[0]=Math.min(f,(f+s)/2),d[1]=Math.max(f,(f+s)/2)}else{u=s;var p=l+i[1]-i[0];d[0]=Math.min(c,(p+c)/2),d[1]=Math.max(c,(p+c)/2)}var m=[Math.min(c,(u+c)/2),Math.max(c,(u+c)/2)];if(e>m[0]&&e<=m[1]||e>=d[0]&&e<=d[1])return n[o]?.index}else{var h=Math.min(s,l),g=Math.max(s,l);if(e>(h+c)/2&&e<=(g+c)/2)return n[o]?.index}}else if(t)for(var _=0;_<a;_++){var v=t[_];if(v!=null){var y=t[_+1],b=t[_-1];if(_===0&&y!=null&&e<=(v.coordinate+y.coordinate)/2||_===a-1&&b!=null&&e>(v.coordinate+b.coordinate)/2||_>0&&_<a-1&&b!=null&&y!=null&&e>(v.coordinate+b.coordinate)/2&&e<=(v.coordinate+y.coordinate)/2)return v.index}}return-1},xL=()=>Z(zE),SL=(e,t)=>t,CL=(e,t,n)=>n,wL=(e,t,n,r)=>r,TL=Q(KI,e=>Hh(e,e=>e.coordinate)),EL=Q([mI,SL,CL,wL],oI),DL=Q([EL,MI,oP,VI],uI),OL=(e,t,n)=>{if(t!=null){var r=mI(e);return t===`axis`?n===`hover`?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n===`hover`?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},kL=Q([mI,SL,CL,wL],fI),AL=Q([My,Ny,Ub,Xy,KI,wL,kL],dI),jL=Q([EL,AL],(e,t)=>e.coordinate??t),ML=Q([KI,DL],FF),NL=Q([kL,DL,eE,oP,ML,pI,SL],EI),PL=Q([EL,DL],(e,t)=>({isActive:e.active&&t!=null,activeIndex:t})),FL=(e,t,n,r,i,a,o)=>{if(!(!e||!n||!r||!i)&&yL(e,o)){var s=bL(Ay(e,t),a,i,n,r),c=_L(t,i,s,e);return{activeIndex:String(s),activeCoordinate:c}}},IL=(e,t,n,r,i,a,o)=>{if(!(!e||!r||!i||!a||!n)){var s=NT(e,n);if(s){var c=bL(jy(s,t),o,a,r,i),l=vL(t,a,c,s);return{activeIndex:String(c),activeCoordinate:l}}}},LL=(e,t,n,r,i,a,o,s)=>{if(!(!e||!t||!r||!i||!a))return t===`horizontal`||t===`vertical`?FL(e,t,r,i,a,o,s):IL(e,t,n,r,i,a,o)},RL=Q(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,n)=>n,(e,t,n)=>{if(t!=null){var r=e[t];if(r!=null)return n?r.panoramaElement:r.element}}),zL=Q(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(e=>parseInt(e,10)).concat(Object.values(WE));return Array.from(new Set(t)).sort((e,t)=>e-t)},{memoizeOptions:{resultEqualityCheck:vD}});function BL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function VL(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?BL(Object(n),!0).forEach(function(t){HL(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):BL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function HL(e,t,n){return(t=UL(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function UL(e){var t=WL(e,`string`);return typeof t==`symbol`?t:t+``}function WL(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var GL={zIndexMap:Object.values(WE).reduce((e,t)=>VL(VL({},e),{},{[t]:{element:void 0,panoramaElement:void 0,consumers:0}}),{})},KL=new Set(Object.values(WE));function qL(e){return KL.has(e)}var JL=sv({name:`zIndex`,initialState:GL,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var n=t.payload.zIndex;e.zIndexMap[n]?e.zIndexMap[n].consumers+=1:e.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:K_()},unregisterZIndexPortal:{reducer:(e,t)=>{var n=t.payload.zIndex;e.zIndexMap[n]&&(--e.zIndexMap[n].consumers,e.zIndexMap[n].consumers<=0&&!qL(n)&&delete e.zIndexMap[n])},prepare:K_()},registerZIndexPortalElement:{reducer:(e,t)=>{var n=t.payload,r=n.zIndex,i=n.element,a=n.isPanorama;e.zIndexMap[r]?a?e.zIndexMap[r].panoramaElement=Gx(i):e.zIndexMap[r].element=Gx(i):e.zIndexMap[r]={consumers:0,element:a?void 0:Gx(i),panoramaElement:a?Gx(i):void 0}},prepare:K_()},unregisterZIndexPortalElement:{reducer:(e,t)=>{var n=t.payload.zIndex;e.zIndexMap[n]&&(t.payload.isPanorama?e.zIndexMap[n].panoramaElement=void 0:e.zIndexMap[n].element=void 0)},prepare:K_()}}}),YL=JL.actions,XL=YL.registerZIndexPortal,ZL=YL.unregisterZIndexPortal,QL=YL.registerZIndexPortalElement,$L=YL.unregisterZIndexPortalElement,eR=JL.reducer;function tR(e){var t=e.zIndex,n=e.children,r=Jb()&&t!==void 0&&t!==0,i=eb(),a=(0,S.useRef)(void 0),o=(0,S.useRef)(new Set),s=gh(),c=Z(e=>RL(e,t,i));if((0,S.useLayoutEffect)(()=>{if(!r){var e=o.current;e.forEach(e=>{s(ZL({zIndex:e}))}),e.clear(),a.current=void 0;return}if(o.current.has(t)||(s(XL({zIndex:t})),o.current.add(t)),c){a.current=c;var n=o.current;n.forEach(e=>{e!==t&&(s(ZL({zIndex:e})),n.delete(e))})}},[s,t,r,c]),(0,S.useLayoutEffect)(()=>{var e=o.current;return()=>{e.forEach(e=>{s(ZL({zIndex:e}))}),e.clear()}},[s]),!r)return n;var l=c??a.current;return l?(0,yS.createPortal)(n,l):null}function nR(){return nR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nR.apply(null,arguments)}function rR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function iR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?rR(Object(n),!0).forEach(function(t){aR(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function aR(e,t,n){return(t=oR(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oR(e){var t=sR(e,`string`);return typeof t==`symbol`?t:t+``}function sR(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function cR(e){var t=e.cursor,n=e.cursorComp,r=e.cursorProps;return(0,S.isValidElement)(t)?(0,S.cloneElement)(t,r):(0,S.createElement)(n,r)}function lR(e){var t=e.coordinate,n=e.payload,r=e.index,i=e.offset,a=e.tooltipAxisBandSize,o=e.layout,s=e.cursor,c=e.tooltipEventType,l=e.chartName,u=t,d=n,f=r;if(!s||!u||l!==`ScatterChart`&&c!==`axis`)return null;var p,m,h;if(l===`ScatterChart`)p=u,m=ow,h=WE.cursorLine;else if(l===`BarChart`)p=sw(o,u,i,a),m=yT,h=WE.cursorRectangle;else if(o===`radial`&&Pp(u)){var g=PT(u),_=g.cx,v=g.cy,y=g.radius;p={cx:_,cy:v,startAngle:g.startAngle,endAngle:g.endAngle,innerRadius:y,outerRadius:y},m=YT,h=WE.cursorLine}else p={points:XT(o,u,i)},m=YC,h=WE.cursorLine;var b=typeof s==`object`&&`className`in s?s.className:void 0,x=iR(iR(iR(iR({stroke:`#ccc`,pointerEvents:`none`},i),p),gd(s)),{},{payload:d,payloadIndex:f,className:ld(`recharts-tooltip-cursor`,b)});return S.createElement(tR,{zIndex:e.zIndex??h},S.createElement(cR,{cursor:s,cursorComp:m,cursorProps:x}))}function uR(e){var t=dL(),n=zb(),r=Wb(),i=xL();return t==null||n==null||r==null||i==null?null:S.createElement(lR,nR({},e,{offset:n,layout:r,tooltipAxisBandSize:t,chartName:i}))}var dR=(0,S.createContext)(null),fR=()=>(0,S.useContext)(dR),pR=l(o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1).default,mR=new pR,hR=`recharts.syncEvent.tooltip`,gR=`recharts.syncEvent.brush`,_R=(e,t)=>{if(t&&Array.isArray(e)){var n=Number.parseInt(t,10);if(!op(n))return e[n]}},vR=sv({name:`options`,initialState:{chartName:``,tooltipPayloadSearcher:()=>void 0,eventEmitter:void 0,defaultTooltipEventType:`axis`},reducers:{createEventEmitter:e=>{e.eventEmitter??=Symbol(`rechartsEventEmitter`)}}}),yR=vR.reducer,bR=vR.actions.createEventEmitter;function xR(e){return e.tooltip.syncInteraction}var SR=sv({name:`chartData`,initialState:{chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},reducers:{setChartData(e,t){if(e.chartData=Gx(t.payload),t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var n=t.payload,r=n.startIndex,i=n.endIndex;r!=null&&(e.dataStartIndex=r),i!=null&&(e.dataEndIndex=i)}}}),CR=SR.actions,wR=CR.setChartData,TR=CR.setDataStartEndIndexes;CR.setComputedData;var ER=SR.reducer,DR=[`x`,`y`];function OR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?OR(Object(n),!0).forEach(function(t){AR(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):OR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function AR(e,t,n){return(t=jR(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jR(e){var t=MR(e,`string`);return typeof t==`symbol`?t:t+``}function MR(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function NR(e,t){if(e==null)return{};var n,r,i=PR(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function PR(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function FR(){var e=Z(BE),t=Z(HE),n=gh(),r=Z(VE),i=Z(KI),a=Wb(),o=Lb();(0,S.useEffect)(()=>{if(e==null)return vp;var s=(s,c,l)=>{if(t!==l&&e===s){if(c.payload.active===!1){n(XF({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(r===`index`){var u;if(o&&c!=null&&(u=c.payload)!=null&&u.coordinate&&c.payload.sourceViewBox){var d=c.payload.coordinate,f=d.x,p=d.y,m=NR(d,DR),h=c.payload.sourceViewBox,g=h.x,_=h.y,v=h.width,y=h.height,b=kR(kR({},m),{},{x:o.x+(v?(f-g)/v:0)*o.width,y:o.y+(y?(p-_)/y:0)*o.height});n(kR(kR({},c),{},{payload:kR(kR({},c.payload),{},{coordinate:b})}))}else n(c);return}if(i!=null){var x;typeof r==`function`?x=i[r(i,{activeTooltipIndex:c.payload.index==null?void 0:Number(c.payload.index),isTooltipActive:c.payload.active,activeIndex:c.payload.index==null?void 0:Number(c.payload.index),activeLabel:c.payload.label,activeDataKey:c.payload.dataKey,activeCoordinate:c.payload.coordinate})]:r===`value`&&(x=i.find(e=>String(e.value)===c.payload.label));var S=c.payload.coordinate;if(S==null||o==null){n(XF({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(x==null){n(XF({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:c.payload.sourceViewBox,graphicalItemId:void 0}));return}var C=S.x,w=S.y,T=Math.min(C,o.x+o.width),E=Math.min(w,o.y+o.height),D={x:a===`horizontal`?x.coordinate:T,y:a===`horizontal`?E:x.coordinate};n(XF({active:c.payload.active,coordinate:D,dataKey:c.payload.dataKey,index:String(x.index),label:c.payload.label,sourceViewBox:c.payload.sourceViewBox,graphicalItemId:c.payload.graphicalItemId}))}}};return mR.on(hR,s),()=>{mR.off(hR,s)}},[Z(e=>e.rootProps.className),n,t,e,r,i,a,o])}function IR(){var e=Z(BE),t=Z(HE),n=gh();(0,S.useEffect)(()=>{if(e==null)return vp;var r=(r,i,a)=>{t!==a&&e===r&&n(TR(i))};return mR.on(gR,r),()=>{mR.off(gR,r)}},[n,t,e])}function LR(){var e=gh();(0,S.useEffect)(()=>{e(bR())},[e]),FR(),IR()}function RR(e,t,n,r,i,a){var o=Z(n=>OL(n,e,t)),s=Z(eL),c=Z(HE),l=Z(BE),u=Z(VE),d=Z(xR)?.sourceViewBox!=null,f=Lb();(0,S.useEffect)(()=>{if(!d&&l!=null&&c!=null){var e=XF({active:a,coordinate:n,dataKey:o,index:i,label:typeof r==`number`?String(r):r,sourceViewBox:f,graphicalItemId:s});mR.emit(hR,l,e,c)}},[d,n,o,s,i,r,c,l,u,a,f])}function zR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function BR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?zR(Object(n),!0).forEach(function(t){VR(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function VR(e,t,n){return(t=HR(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function HR(e){var t=UR(e,`string`);return typeof t==`symbol`?t:t+``}function UR(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function WR(e,t){return YR(e)||JR(e,t)||KR(e,t)||GR()}function GR(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function KR(e,t){if(e){if(typeof e==`string`)return qR(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qR(e,t):void 0}}function qR(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function JR(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function YR(e){if(Array.isArray(e))return e}function XR(e){return e.dataKey}function ZR(e,t){return S.isValidElement(e)?S.cloneElement(e,t):typeof e==`function`?S.createElement(e,t):S.createElement(aC,t)}var QR=[],$R={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:`ease`,axisId:0,contentStyle:{},cursor:!0,filterNull:!0,includeHidden:!1,isAnimationActive:`auto`,itemSorter:`name`,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:` : `,trigger:`hover`,useTranslate3d:!1,wrapperStyle:{}};function ez(e){var t=Up(e,$R),n=t.active,r=t.allowEscapeViewBox,i=t.animationDuration,a=t.animationEasing,o=t.content,s=t.filterNull,c=t.isAnimationActive,l=t.offset,u=t.payloadUniqBy,d=t.position,f=t.reverseDirection,p=t.useTranslate3d,m=t.wrapperStyle,h=t.cursor,g=t.shared,_=t.trigger,v=t.defaultIndex,y=t.portal,b=t.axisId,x=gh(),C=typeof v==`number`?String(v):v;(0,S.useEffect)(()=>{x(UF({shared:g,trigger:_,axisId:b,active:n,defaultIndex:C}))},[x,g,_,b,n,C]);var w=Lb(),T=PC(),E=PF(g),D=Z(e=>PL(e,E,_,C))??{},O=D.activeIndex,k=D.isActive,A=Z(e=>NL(e,E,_,C)),j=Z(e=>ML(e,E,_,C)),M=Z(e=>jL(e,E,_,C)),N=A,ee=fR(),te=n??k??!1,P=WR(ng([N,te]),2),F=P[0],ne=P[1],re=E===`axis`?j:void 0;RR(E,_,M,re,O,te);var ie=y??ee;if(ie==null||w==null||E==null)return null;var ae=N??QR;te||(ae=QR),s&&ae.length&&(ae=ch(ae.filter(e=>e.value!=null&&(e.hide!==!0||t.includeHidden)),u,XR));var oe=ae.length>0,se=BR(BR({},t),{},{payload:ae,label:re,active:te,activeIndex:O,coordinate:M,accessibilityLayer:T}),ce=S.createElement(NC,{allowEscapeViewBox:r,animationDuration:i,animationEasing:a,isAnimationActive:c,active:te,coordinate:M,hasPayload:oe,offset:l,position:d,reverseDirection:f,useTranslate3d:p,viewBox:w,wrapperStyle:m,lastBoundingBox:F,innerRef:ne,hasPortalFromProps:!!y},ZR(o,se));return S.createElement(S.Fragment,null,(0,yS.createPortal)(ce,ie),te&&S.createElement(uR,{cursor:h,tooltipEventType:E,coordinate:M,payload:ae,index:O}))}var tz=e=>null;tz.displayName=`Cell`;var nz=e=>e.graphicalItems.polarItems,rz=Q([nz,MN,Q([dD,fD],IN)],zN),iz=Q([Q([rz],WN),tE],qN),az=Q([iz,MN,rz],YN);Q([iz,MN,rz],(e,t,n)=>n.length>0?e.flatMap(e=>n.flatMap(n=>({value:uy(e,t.dataKey??n.dataKey),errorDomain:[]}))).filter(Boolean):t?.dataKey==null?e.map(e=>({value:e,errorDomain:[]})):e.map(e=>({value:uy(e,t.dataKey),errorDomain:[]})));var oz=()=>void 0,sz=Q([MN,Ub,iz,az,LE,dD,Q([MN,pP,mP,oz,Q([iz,MN,rz,gP,dD,aE],yP),oz,Ub,dD],RP)],VP);Q([UP,Q([MN,sz,Q([sz,PN,UP],WP),dD],KP)],SD);function cz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function lz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?cz(Object(n),!0).forEach(function(t){uz(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function uz(e,t,n){return(t=dz(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dz(e){var t=fz(e,`string`);return typeof t==`symbol`?t:t+``}function fz(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var pz=Q([nz,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`pie`).find(e=>e.id===t)),mz=[],hz=(e,t,n)=>n?.length===0?mz:n,gz=Q([tE,pz,hz],(e,t,n)=>{var r=e.chartData;if(t!=null){var i=t?.data!=null&&t.data.length>0?t.data:r;if((!i||!i.length)&&n!=null&&(i=n.map(e=>lz(lz({},t.presentationProps),e.props))),i!=null)return i}}),_z=Q([gz,pz,hz],(e,t,n)=>{if(!(e==null||t==null))return e.map((e,r)=>{var i,a=uy(e,t.nameKey,t.name),o=n!=null&&(i=n[r])!=null&&(i=i.props)!=null&&i.fill?n[r].props.fill:typeof e==`object`&&e&&`fill`in e?e.fill:t.fill;return{value:ky(a,t.dataKey),dataKey:t.dataKey,color:o,payload:e,type:t.legendType}})}),vz=Q([gz,pz,hz,Xy],(e,t,n,r)=>{if(!(t==null||e==null))return gU({offset:r,pieSettings:t,displayedData:e,cells:n})}),yz=[`children`,`className`];function bz(){return bz=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bz.apply(null,arguments)}function xz(e,t){if(e==null)return{};var n,r,i=Sz(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Sz(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Cz=S.forwardRef((e,t)=>{var n=e.children,r=e.className,i=xz(e,yz),a=ld(`recharts-layer`,r);return S.createElement(`g`,bz({className:a},_d(i),{ref:t}),n)});function wz(e,t,n){return(t=Tz(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Tz(e){var t=Ez(e,`string`);return typeof t==`symbol`?t:t+``}function Ez(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Dz=class{constructor(e){wz(this,`cache`,new Map),this.maxSize=e}get(e){var t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){var n=this.cache.keys().next().value;n!=null&&this.cache.delete(n)}this.cache.set(e,t)}clear(){this.cache.clear()}size(){return this.cache.size}};function Oz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Oz(Object(n),!0).forEach(function(t){Az(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Az(e,t,n){return(t=jz(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jz(e){var t=Mz(e,`string`);return typeof t==`symbol`?t:t+``}function Mz(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Nz=kz({},{cacheSize:2e3,enableCache:!0}),Pz=new Dz(Nz.cacheSize),Fz={position:`absolute`,top:`-20000px`,left:0,padding:0,margin:0,border:`none`,whiteSpace:`pre`},Iz=`recharts_measurement_span`;function Lz(e,t){return`${e}|${t.fontSize||``}|${t.fontFamily||``}|${t.fontWeight||``}|${t.fontStyle||``}|${t.letterSpacing||``}|${t.textTransform||``}`}var Rz=(e,t)=>{try{var n=document.getElementById(Iz);n||(n=document.createElement(`span`),n.setAttribute(`id`,Iz),n.setAttribute(`aria-hidden`,`true`),document.body.appendChild(n)),Object.assign(n.style,Fz,t),n.textContent=`${e}`;var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},zz=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||fC.isSsr)return{width:0,height:0};if(!Nz.enableCache)return Rz(e,t);var n=Lz(e,t),r=Pz.get(n);if(r)return r;var i=Rz(e,t);return Pz.set(n,i),i},Bz;function Vz(e,t){return Kz(e)||Gz(e,t)||Uz(e,t)||Hz()}function Hz(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Uz(e,t){if(e){if(typeof e==`string`)return Wz(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Wz(e,t):void 0}}function Wz(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Gz(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Kz(e){if(Array.isArray(e))return e}function qz(e,t,n){return(t=Jz(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jz(e){var t=Yz(e,`string`);return typeof t==`symbol`?t:t+``}function Yz(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Xz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Zz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Qz=/^(px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q)$/,$z=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,eB={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},tB=[`cm`,`mm`,`pt`,`pc`,`in`,`Q`,`px`];function nB(e){return tB.includes(e)}var rB=`NaN`;function iB(e,t){return e*eB[t]}var aB=class e{static parse(t){var n=Vz($z.exec(t)??[],3),r=n[1],i=n[2];return r==null?e.NaN:new e(parseFloat(r),i??``)}constructor(e,t){this.num=e,this.unit=t,this.num=e,this.unit=t,op(e)&&(this.unit=``),t!==``&&!Qz.test(t)&&(this.num=NaN,this.unit=``),nB(t)&&(this.num=iB(e,t),this.unit=`px`)}add(t){return this.unit===t.unit?new e(this.num+t.num,this.unit):new e(NaN,``)}subtract(t){return this.unit===t.unit?new e(this.num-t.num,this.unit):new e(NaN,``)}multiply(t){return this.unit!==``&&t.unit!==``&&this.unit!==t.unit?new e(NaN,``):new e(this.num*t.num,this.unit||t.unit)}divide(t){return this.unit!==``&&t.unit!==``&&this.unit!==t.unit?new e(NaN,``):new e(this.num/t.num,this.unit||t.unit)}toString(){return`${this.num}${this.unit}`}isNaN(){return op(this.num)}};Bz=aB,qz(aB,`NaN`,new Bz(NaN,``));function oB(e){if(e==null||e.includes(rB))return rB;for(var t=e;t.includes(`*`)||t.includes(`/`);){var n=Vz(Xz.exec(t)??[],4),r=n[1],i=n[2],a=n[3],o=aB.parse(r??``),s=aB.parse(a??``),c=i===`*`?o.multiply(s):o.divide(s);if(c.isNaN())return rB;t=t.replace(Xz,c.toString())}for(;t.includes(`+`)||/.-\d+(?:\.\d+)?/.test(t);){var l=Vz(Zz.exec(t)??[],4),u=l[1],d=l[2],f=l[3],p=aB.parse(u??``),m=aB.parse(f??``),h=d===`+`?p.add(m):p.subtract(m);if(h.isNaN())return rB;t=t.replace(Zz,h.toString())}return t}var sB=/\(([^()]*)\)/;function cB(e){for(var t=e,n;(n=sB.exec(t))!=null;){var r=Vz(n,2)[1];t=t.replace(sB,oB(r))}return t}function lB(e){var t=e.replace(/\s+/g,``);return t=cB(t),t=oB(t),t}function uB(e){try{return lB(e)}catch{return rB}}function dB(e){var t=uB(e.slice(5,-1));return t===rB?``:t}var fB=[`x`,`y`,`lineHeight`,`capHeight`,`fill`,`scaleToFit`,`textAnchor`,`verticalAnchor`],pB=[`dx`,`dy`,`angle`,`className`,`breakAll`];function mB(){return mB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mB.apply(null,arguments)}function hB(e,t){if(e==null)return{};var n,r,i=gB(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function gB(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function _B(e,t){return SB(e)||xB(e,t)||yB(e,t)||vB()}function vB(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yB(e,t){if(e){if(typeof e==`string`)return bB(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bB(e,t):void 0}}function bB(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function xB(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function SB(e){if(Array.isArray(e))return e}var CB=/[ \f\n\r\t\v\u2028\u2029]+/,wB=e=>{var t=e.children,n=e.breakAll,r=e.style;try{var i=[];return hp(t)||(i=n?t.toString().split(``):t.toString().split(CB)),{wordsWithComputedWidth:i.map(e=>({word:e,width:zz(e,r).width})),spaceWidth:n?0:zz(`\xA0`,r).width}}catch{return null}};function TB(e){return e===`start`||e===`middle`||e===`end`||e===`inherit`}function EB(e){return hp(e)||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}var DB=(e,t,n,r)=>e.reduce((e,i)=>{var a=i.word,o=i.width,s=e[e.length-1];if(s&&o!=null&&(t==null||r||s.width+o+n<Number(t)))s.words.push(a),s.width+=o+n;else{var c={words:[a],width:o};e.push(c)}return e},[]),OB=e=>e.reduce((e,t)=>e.width>t.width?e:t),kB=`…`,AB=(e,t,n,r,i,a,o,s)=>{var c=wB({breakAll:n,style:r,children:e.slice(0,t)+kB});if(!c)return[!1,[]];var l=DB(c.wordsWithComputedWidth,a,o,s);return[l.length>i||OB(l).width>Number(a),l]},jB=(e,t,n,r,i)=>{var a=e.maxLines,o=e.children,s=e.style,c=e.breakAll,l=X(a),u=String(o),d=DB(t,r,n,i);if(!l||i||!(d.length>a||OB(d).width>Number(r)))return d;for(var f=0,p=u.length-1,m=0,h;f<=p&&m<=u.length-1;){var g=Math.floor((f+p)/2),_=_B(AB(u,g-1,c,s,a,r,n,i),2),v=_[0],y=_[1],b=_B(AB(u,g,c,s,a,r,n,i),1)[0];if(!v&&!b&&(f=g+1),v&&b&&(p=g-1),!v&&b){h=y;break}m++}return h||d},MB=e=>[{words:hp(e)?[]:e.toString().split(CB),width:void 0}],NB=e=>{var t=e.width,n=e.scaleToFit,r=e.children,i=e.style,a=e.breakAll,o=e.maxLines;if((t||n)&&!fC.isSsr){var s,c,l=wB({breakAll:a,children:r,style:i});if(l){var u=l.wordsWithComputedWidth,d=l.spaceWidth;s=u,c=d}else return MB(r);return jB({breakAll:a,children:r,maxLines:o,style:i},s,c,t,!!n)}return MB(r)},PB=`#808080`,FB={angle:0,breakAll:!1,capHeight:`0.71em`,fill:PB,lineHeight:`1em`,scaleToFit:!1,textAnchor:`start`,verticalAnchor:`end`,x:0,y:0},IB=(0,S.forwardRef)((e,t)=>{var n=Up(e,FB),r=n.x,i=n.y,a=n.lineHeight,o=n.capHeight,s=n.fill,c=n.scaleToFit,l=n.textAnchor,u=n.verticalAnchor,d=hB(n,fB),f=(0,S.useMemo)(()=>NB({breakAll:d.breakAll,children:d.children,maxLines:d.maxLines,scaleToFit:c,style:d.style,width:d.width}),[d.breakAll,d.children,d.maxLines,c,d.style,d.width]),p=d.dx,m=d.dy,h=d.angle,g=d.className,_=d.breakAll,v=hB(d,pB);if(!cp(r)||!cp(i)||f.length===0)return null;var y=Number(r)+(X(p)?p:0),b=Number(i)+(X(m)?m:0);if(!ry(y)||!ry(b))return null;var x;switch(u){case`start`:x=dB(`calc(${o})`);break;case`middle`:x=dB(`calc(${(f.length-1)/2} * -${a} + (${o} / 2))`);break;default:x=dB(`calc(${f.length-1} * -${a})`);break}var C=[],w=f[0];if(c&&w!=null){var T=w.width,E=d.width;C.push(`scale(${X(E)&&X(T)?E/T:1})`)}return h&&C.push(`rotate(${h}, ${y}, ${b})`),C.length&&(v.transform=C.join(` `)),S.createElement(`text`,mB({},_d(v),{ref:t,x:y,y:b,className:ld(`recharts-text`,g),textAnchor:l,fill:s.includes(`url`)?PB:s}),f.map((e,t)=>{var n=e.words.join(_?``:` `);return S.createElement(`tspan`,{x:y,dy:t===0?x:a,key:`${n}-${t}`},n)}))});IB.displayName=`Text`;var LB=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.suspense_list`),d=Symbol.for(`react.memo`),f=Symbol.for(`react.lazy`),p=Symbol.for(`react.view_transition`);function m(e){if(typeof e==`object`&&e){var m=e.$$typeof;switch(m){case t:switch(e=e.type,e){case r:case a:case i:case l:case u:case p:return e;default:switch(e&&=e.$$typeof,e){case s:case c:case f:case d:return e;case o:return e;default:return m}}case n:return m}}}e.isFragment=function(e){return m(e)===r}})),RB=o(((e,t)=>{t.exports=LB()}))(),zB=e=>typeof e==`string`?e:e?e.displayName||e.name||`Component`:``,BB=null,VB=null,HB=e=>{if(e===BB&&Array.isArray(VB))return VB;var t=[];return S.Children.forEach(e,e=>{hp(e)||((0,RB.isFragment)(e)?t=t.concat(HB(e.props.children)):t.push(e))}),VB=t,BB=e,t};function UB(e,t){var n=[],r=[];return r=Array.isArray(t)?t.map(e=>zB(e)):[zB(t)],HB(e).forEach(e=>{var t=ep(e,`type.displayName`)||ep(e,`type.name`);t&&r.indexOf(t)!==-1&&n.push(e)}),n}var WB=e=>e&&typeof e==`object`&&`clipDot`in e?!!e.clipDot:!0;function GB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function KB(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?GB(Object(n),!0).forEach(function(t){qB(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):GB(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qB(e,t,n){return(t=JB(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function JB(e){var t=YB(e,`string`);return typeof t==`symbol`?t:t+``}function YB(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function XB(e,t){return KB(KB({},t),e)}function ZB(e){return(0,S.isValidElement)(e)?e.props:e}function QB(e,t){return(0,S.cloneElement)(e,XB(ZB(e),t))}function $B(e){if(`index`in e){var t=e.index;return typeof t==`number`||typeof t==`string`?t:void 0}}function eV(e){return`isActive`in e&&e.isActive===!0}function tV(e){var t=e.option,n=e.DefaultShape,r=e.shapeProps,i=e.activeClassName,a=i===void 0?`recharts-active-shape`:i,o=e.inActiveClassName,s=o===void 0?`recharts-shape`:o,c=$B(r),l=(0,S.isValidElement)(t)?QB(t,r):t===n?S.createElement(n,r):typeof t==`function`?t(r,c):typeof t==`object`?S.createElement(n,XB(t,r)):S.createElement(n,r);return eV(r)?S.createElement(Cz,{className:a},l):S.createElement(Cz,{className:s},l)}var nV=(e,t,n)=>{var r=gh();return(i,a)=>o=>{e?.(i,a,o),r(WF({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},rV=e=>{var t=gh();return(n,r)=>i=>{e?.(n,r,i),t(GF())}},iV=(e,t,n)=>{var r=gh();return(i,a)=>o=>{e?.(i,a,o),r(qF({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function aV(e){var t=e.tooltipEntrySettings,n=gh(),r=eb(),i=(0,S.useRef)(null);return(0,S.useLayoutEffect)(()=>{r||(i.current===null?n(BF(t)):i.current!==t&&n(VF({prev:i.current,next:t})),i.current=t)},[t,n,r]),(0,S.useLayoutEffect)(()=>()=>{i.current&&=(n(HF(i.current)),null)},[n]),null}function oV(e){var t=e.legendPayload,n=gh(),r=eb(),i=(0,S.useRef)(null);return(0,S.useLayoutEffect)(()=>{r||(i.current===null?n(Xx(t)):i.current!==t&&n(Zx({prev:i.current,next:t})),i.current=t)},[n,r,t]),(0,S.useLayoutEffect)(()=>()=>{i.current&&=(n(Qx(i.current)),null)},[n]),null}function sV(e){var t=e.legendPayload,n=gh(),r=Z(Ub),i=(0,S.useRef)(null);return(0,S.useLayoutEffect)(()=>{r!==`centric`&&r!==`radial`||(i.current===null?n(Xx(t)):i.current!==t&&n(Zx({prev:i.current,next:t})),i.current=t)},[n,r,t]),(0,S.useLayoutEffect)(()=>()=>{i.current&&=(n(Qx(i.current)),null)},[n]),null}function cV(e,t){return pV(e)||fV(e,t)||uV(e,t)||lV()}function lV(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uV(e,t){if(e){if(typeof e==`string`)return dV(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?dV(e,t):void 0}}function dV(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function fV(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function pV(e){if(Array.isArray(e))return e}var mV=`index`,hV=`append`;function gV(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],r=[];for(var i of n)r.push({status:`removed`,prev:i});for(var a=0;a<t.length;a++){var o=e[a],s=t[a];o==null?r.push({status:`added`,next:s}):r.push({status:`matched`,prev:o,next:s})}return r}function _V(e,t){var n=e.length/t.length;return gV(t.map((t,r)=>e[Math.floor(r*n)]),t)}function vV(e,t){return gV(t.map((t,n)=>e[n]),t)}function yV(e,t){for(var n=new Map,r=0;r<e.length;r++){var i=e[r];if(i!=null){var a=t(i,r);a!=null&&!n.has(a)&&n.set(a,i)}}return n}function bV(e,t,n){var r=yV(e,n),i=new Set,a=t.map((e,t)=>{var a=n(e,t);if(a!=null){var o=r.get(a);if(o!==void 0)return i.add(a),o}}),o=[];for(var s of r){var c=cV(s,2),l=c[0],u=c[1];i.has(l)||o.push(u)}return gV(a,t,o)}function xV(e,t,n){return t==null?null:e==null?t.map(e=>({status:`added`,next:e})):n===`index`?_V(e,t):n===`append`?vV(e,t):bV(e,t,n)}function SV(e,t){var n=(0,S.useRef)(e),r=(0,S.useRef)(t.current),i=(0,S.useRef)(!0);n.current!==e&&(n.current=e,r.current=t.current,i.current=!1);var a=(0,S.useCallback)(function(e,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(n===0){i.current=!0;return}n===1&&(r.current=e),n>0&&i.current&&a&&(t.current=e)},[t]);return{startValue:r.current,syncStepValue:a}}function CV(e,t){return OV(e)||DV(e,t)||TV(e,t)||wV()}function wV(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function TV(e,t){if(e){if(typeof e==`string`)return EV(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?EV(e,t):void 0}}function EV(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function DV(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function OV(e){if(Array.isArray(e))return e}function kV(e,t){var n=CV((0,S.useState)(!1),2),r=n[0],i=n[1];return{isAnimating:r,handleAnimationStart:(0,S.useCallback)(()=>{typeof e==`function`&&e(),i(!0)},[e]),handleAnimationEnd:(0,S.useCallback)(()=>{typeof t==`function`&&t(),i(!1)},[t])}}function AV(e){var t=e.animationInput,n=e.animationIdPrefix,r=e.items,i=e.previousItemsRef,a=e.isAnimationActive,o=e.animationBegin,s=e.animationDuration,c=e.animationEasing,l=e.onAnimationStart,u=e.onAnimationEnd,d=e.animationInterpolateFn,f=e.animationMatchBy,p=e.shouldUpdatePreviousRef,m=e.children,h=e.layout,g=Vw(t,n),_=SV(g,i),v=_.startValue??null,y=xV(v,r,f??mV);return S.createElement(Bw,{animationId:g,begin:o,duration:s,isActive:a,easing:c,onAnimationEnd:u,onAnimationStart:l,key:g},e=>{var t=v==null,n=r==null?r:d(y,e,h),i=p?p(e):e>0;return _.syncStepValue(n,e,i),n==null?null:m(n,e,t)})}function jV(e,t){return IV(e)||FV(e,t)||NV(e,t)||MV()}function MV(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function NV(e,t){if(e){if(typeof e==`string`)return PV(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?PV(e,t):void 0}}function PV(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function FV(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function IV(e){if(Array.isArray(e))return e}var LV=S.useId??(()=>jV(S.useState(()=>up(`uid-`)),1)[0]);function RV(e,t){var n=LV();return t||(e?`${e}-${n}`:n)}var zV=(0,S.createContext)(void 0),BV=e=>{var t=e.id,n=e.type,r=e.children,i=RV(`recharts-${n}`,t);return S.createElement(zV.Provider,{value:i},r(i))},VV=sv({name:`graphicalItems`,initialState:{cartesianItems:[],polarItems:[]},reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(Gx(t.payload))},prepare:K_()},replaceCartesianGraphicalItem:{reducer(e,t){var n=t.payload,r=n.prev,i=n.next,a=M_(e).cartesianItems.indexOf(Gx(r));a>-1&&(e.cartesianItems[a]=Gx(i))},prepare:K_()},removeCartesianGraphicalItem:{reducer(e,t){var n=M_(e).cartesianItems.indexOf(Gx(t.payload));n>-1&&e.cartesianItems.splice(n,1)},prepare:K_()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(Gx(t.payload))},prepare:K_()},removePolarGraphicalItem:{reducer(e,t){var n=M_(e).polarItems.indexOf(Gx(t.payload));n>-1&&e.polarItems.splice(n,1)},prepare:K_()},replacePolarGraphicalItem:{reducer(e,t){var n=t.payload,r=n.prev,i=n.next,a=M_(e).polarItems.indexOf(Gx(r));a>-1&&(e.polarItems[a]=Gx(i))},prepare:K_()}}}),HV=VV.actions,UV=HV.addCartesianGraphicalItem,WV=HV.replaceCartesianGraphicalItem,GV=HV.removeCartesianGraphicalItem,KV=HV.addPolarGraphicalItem,qV=HV.removePolarGraphicalItem,JV=HV.replacePolarGraphicalItem,YV=VV.reducer,XV=(0,S.memo)(e=>{var t=gh(),n=(0,S.useRef)(null);return(0,S.useLayoutEffect)(()=>{n.current===null?t(UV(e)):n.current!==e&&t(WV({prev:n.current,next:e})),n.current=e},[t,e]),(0,S.useLayoutEffect)(()=>()=>{n.current&&=(t(GV(n.current)),null)},[t]),null}),ZV=(0,S.memo)(e=>{var t=gh(),n=(0,S.useRef)(null);return(0,S.useLayoutEffect)(()=>{n.current===null?t(KV(e)):n.current!==e&&t(JV({prev:n.current,next:e})),n.current=e},[t,e]),(0,S.useLayoutEffect)(()=>()=>{n.current&&=(t(qV(n.current)),null)},[t]),null});function QV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $V(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?QV(Object(n),!0).forEach(function(t){eH(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eH(e,t,n){return(t=tH(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tH(e){var t=nH(e,`string`);return typeof t==`symbol`?t:t+``}function nH(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var rH=e=>{var t=e.viewBox,n=e.position,r=e.offset,i=r===void 0?0:r,a=e.parentViewBox,o=e.clamp,s=Ib(t),c=s.x,l=s.y,u=s.height,d=s.upperWidth,f=s.lowerWidth,p=c,m=c+(d-f)/2,h=(p+m)/2,g=(d+f)/2,_=p+d/2,v=u>=0?1:-1,y=v*i,b=v>0?`end`:`start`,x=v>0?`start`:`end`,S=d>=0?1:-1,C=S*i,w=S>0?`end`:`start`,T=S>0?`start`:`end`,E=a;if(n===`top`){var D={x:p+d/2,y:l-y,horizontalAnchor:`middle`,verticalAnchor:b};return o&&E&&(D.height=Math.max(l-E.y,0),D.width=d),D}if(n===`bottom`){var O={x:m+f/2,y:l+u+y,horizontalAnchor:`middle`,verticalAnchor:x};return o&&E&&(O.height=Math.max(E.y+E.height-(l+u),0),O.width=f),O}if(n===`left`){var k={x:h-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`};return o&&E&&(k.width=Math.max(k.x-E.x,0),k.height=u),k}if(n===`right`){var A={x:h+g+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`};return o&&E&&(A.width=Math.max(E.x+E.width-A.x,0),A.height=u),A}var j=o&&E?{width:g,height:u}:{};return n===`insideLeft`?$V({x:h+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`},j):n===`insideRight`?$V({x:h+g-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`},j):n===`insideTop`?$V({x:p+d/2,y:l+y,horizontalAnchor:`middle`,verticalAnchor:x},j):n===`insideBottom`?$V({x:m+f/2,y:l+u-y,horizontalAnchor:`middle`,verticalAnchor:b},j):n===`insideTopLeft`?$V({x:p+C,y:l+y,horizontalAnchor:T,verticalAnchor:x},j):n===`insideTopRight`?$V({x:p+d-C,y:l+y,horizontalAnchor:w,verticalAnchor:x},j):n===`insideBottomLeft`?$V({x:m+C,y:l+u-y,horizontalAnchor:T,verticalAnchor:b},j):n===`insideBottomRight`?$V({x:m+f-C,y:l+u-y,horizontalAnchor:w,verticalAnchor:b},j):n&&typeof n==`object`&&(X(n.x)||sp(n.x))&&(X(n.y)||sp(n.y))?$V({x:c+dp(n.x,g),y:l+dp(n.y,u),horizontalAnchor:`end`,verticalAnchor:`end`},j):$V({x:_,y:l+u/2,horizontalAnchor:`middle`,verticalAnchor:`middle`},j)},iH=[`labelRef`],aH=[`content`];function oH(e,t){if(e==null)return{};var n,r,i=sH(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function sH(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function cH(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function lH(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?cH(Object(n),!0).forEach(function(t){uH(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cH(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function uH(e,t,n){return(t=dH(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dH(e){var t=fH(e,`string`);return typeof t==`symbol`?t:t+``}function fH(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function pH(){return pH=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},pH.apply(null,arguments)}var mH=(0,S.createContext)(null),hH=e=>{var t=e.x,n=e.y,r=e.upperWidth,i=e.lowerWidth,a=e.width,o=e.height,s=e.children,c=(0,S.useMemo)(()=>({x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[t,n,r,i,a,o]);return S.createElement(mH.Provider,{value:c},s)},gH=()=>{var e=(0,S.useContext)(mH),t=Lb();return e||(t?Ib(t):void 0)},_H=(0,S.createContext)(null),vH=()=>{var e=(0,S.useContext)(_H),t=Z(uD);return e||t},yH=e=>{var t=e.value,n=e.formatter,r=hp(e.children)?t:e.children;return typeof n==`function`?n(r):r},bH=e=>e!=null&&typeof e==`function`,xH=(e,t)=>ap(t-e)*Math.min(Math.abs(t-e),360),SH=(e,t,n,r,i)=>{var a=e.offset,o=e.className,s=i.cx,c=i.cy,l=i.innerRadius,u=i.outerRadius,d=i.startAngle,f=i.endAngle,p=i.clockWise,m=(l+u)/2,h=xH(d,f),g=h>=0?1:-1,_,v;switch(t){case`insideStart`:_=d+g*a,v=p;break;case`insideEnd`:_=f-g*a,v=!p;break;case`end`:_=f+g*a,v=p;break;default:throw Error(`Unsupported position ${t}`)}v=h<=0?v:!v;var y=DT(s,c,m,_),b=DT(s,c,m,_+(v?1:-1)*359),x=`M${y.x},${y.y}
A${m},${m},0,1,${+!v},
${b.x},${b.y}`,C=hp(e.id)?up(`recharts-radial-line-`):e.id;return S.createElement(`text`,pH({},r,{dominantBaseline:`central`,className:ld(`recharts-radial-bar-label`,o)}),S.createElement(`defs`,null,S.createElement(`path`,{id:C,d:x})),S.createElement(`textPath`,{xlinkHref:`#${C}`},n))},CH=(e,t,n)=>{var r=e.cx,i=e.cy,a=e.innerRadius,o=e.outerRadius,s=(e.startAngle+e.endAngle)/2;if(n===`outside`){var c=DT(r,i,o+t,s),l=c.x;return{x:l,y:c.y,textAnchor:l>=r?`start`:`end`,verticalAnchor:`middle`}}if(n===`center`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`middle`};if(n===`centerTop`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`start`};if(n===`centerBottom`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`end`};var u=DT(r,i,(a+o)/2,s);return{x:u.x,y:u.y,textAnchor:`middle`,verticalAnchor:`middle`}},wH=e=>e!=null&&`cx`in e&&X(e.cx),TH={angle:0,offset:5,zIndex:WE.label,position:`middle`,textBreakAll:!1};function EH(e){if(!wH(e))return e;var t=e.cx,n=e.cy,r=e.outerRadius,i=r*2;return{x:t-r,y:n-r,width:i,upperWidth:i,lowerWidth:i,height:i}}function DH(e){var t=Up(e,TH),n=t.viewBox,r=t.parentViewBox,i=t.position,a=t.value,o=t.children,s=t.content,c=t.className,l=c===void 0?``:c,u=t.textBreakAll,d=t.labelRef,f=vH(),p=gH(),m=n==null?i===`center`?p:f??p:wH(n)?n:Ib(n),h,g,_=EH(m);if(!m||hp(a)&&hp(o)&&!(0,S.isValidElement)(s)&&typeof s!=`function`)return null;var v=lH(lH({},t),{},{viewBox:m});if((0,S.isValidElement)(s))return v.labelRef,(0,S.cloneElement)(s,oH(v,iH));if(typeof s==`function`){if(v.content,h=(0,S.createElement)(s,oH(v,aH)),(0,S.isValidElement)(h))return h}else h=yH(t);var y=_d(t);if(wH(m)){if(i===`insideStart`||i===`insideEnd`||i===`end`)return SH(t,i,h,y,m);g=CH(m,t.offset,t.position)}else{if(!_)return null;var b=rH({viewBox:_,position:i,offset:t.offset,parentViewBox:wH(r)?void 0:r,clamp:!0});g=lH(lH({x:b.x,y:b.y,textAnchor:b.horizontalAnchor,verticalAnchor:b.verticalAnchor},b.width===void 0?{}:{width:b.width}),b.height===void 0?{}:{height:b.height})}return S.createElement(tR,{zIndex:t.zIndex},S.createElement(IB,pH({ref:d,className:ld(`recharts-label`,l)},y,g,{textAnchor:TB(y.textAnchor)?y.textAnchor:g.textAnchor,breakAll:u}),h))}DH.displayName=`Label`;var OH=(e,t,n)=>{if(!e)return null;var r={viewBox:t,labelRef:n};return e===!0?S.createElement(DH,pH({key:`label-implicit`},r)):cp(e)?S.createElement(DH,pH({key:`label-implicit`,value:e},r)):(0,S.isValidElement)(e)?e.type===DH?(0,S.cloneElement)(e,lH({key:`label-implicit`},r)):S.createElement(DH,pH({key:`label-implicit`,content:e},r)):bH(e)?S.createElement(DH,pH({key:`label-implicit`,content:e},r)):e&&typeof e==`object`?S.createElement(DH,pH({},e,{key:`label-implicit`},r)):null};function kH(e){var t=e.label,n=e.labelRef;return OH(t,gH(),n)||null}var AH=[`valueAccessor`],jH=[`dataKey`,`clockWise`,`id`,`textBreakAll`,`zIndex`];function MH(){return MH=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},MH.apply(null,arguments)}function NH(e,t){if(e==null)return{};var n,r,i=PH(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function PH(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var FH=e=>{var t=Array.isArray(e.value)?e.value[e.value.length-1]:e.value;if(EB(t))return t},IH=(0,S.createContext)(void 0),LH=IH.Provider,RH=(0,S.createContext)(void 0),zH=RH.Provider;function BH(){return(0,S.useContext)(IH)}function VH(){return(0,S.useContext)(RH)}function HH(e){var t=e.valueAccessor,n=t===void 0?FH:t,r=NH(e,AH),i=r.dataKey;r.clockWise;var a=r.id,o=r.textBreakAll,s=r.zIndex,c=NH(r,jH),l=BH(),u=VH(),d=l||u;return!d||!d.length?null:S.createElement(tR,{zIndex:s??WE.label},S.createElement(Cz,{className:`recharts-label-list`},d.map((e,t)=>{var s=hp(i)?n(e,t):uy(e.payload,i),l=hp(a)?{}:{id:`${a}-${t}`};return S.createElement(DH,MH({key:`label-${t}`},_d(e),c,l,{fill:r.fill??e.fill,parentViewBox:e.parentViewBox,value:s,textBreakAll:o,viewBox:e.viewBox,index:t,zIndex:0}))})))}HH.displayName=`LabelList`;function UH(e){var t=e.label;return t?t===!0?S.createElement(HH,{key:`labelList-implicit`}):S.isValidElement(t)||bH(t)?S.createElement(HH,{key:`labelList-implicit`,content:t}):typeof t==`object`?S.createElement(HH,MH({key:`labelList-implicit`},t,{type:String(t.type)})):null:null}function WH(e){return e&&typeof e==`object`&&`className`in e&&typeof e.className==`string`?e.className:``}var GH=[`key`],KH=[`onMouseEnter`,`onClick`,`onMouseLeave`],qH=[`id`],JH=[`id`];function YH(){return YH=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},YH.apply(null,arguments)}function XH(e,t){if(e==null)return{};var n,r,i=ZH(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ZH(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function QH(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $H(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?QH(Object(n),!0).forEach(function(t){eU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QH(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eU(e,t,n){return(t=tU(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tU(e){var t=nU(e,`string`);return typeof t==`symbol`?t:t+``}function nU(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var rU=YT;function iU(e){var t=(0,S.useMemo)(()=>UB(e.children,tz),[e.children]),n=Z(n=>_z(n,e.id,t));return n==null?null:S.createElement(sV,{legendPayload:n})}function aU(e){if(!(e==null||typeof e==`boolean`||typeof e==`function`)){if(S.isValidElement(e)){var t=e.props?.fill;return typeof t==`string`?t:void 0}var n=e.fill;return typeof n==`string`?n:void 0}}var oU=S.memo(e=>{var t=e.dataKey,n=e.nameKey,r=e.sectors,i=e.stroke,a=e.strokeWidth,o=e.fill,s=e.name,c=e.hide,l=e.tooltipType,u=e.id,d=e.activeShape,f=aU(d),p={dataDefinedOnItem:r.map(e=>{var t=e.tooltipPayload;return f==null||t==null?t:t.map(e=>$H($H({},e),{},{color:f,fill:f}))}),getPosition:e=>r[Number(e)]?.tooltipPosition,settings:{stroke:i,strokeWidth:a,fill:o,dataKey:t,nameKey:n,name:ky(s,t),hide:c,type:l,color:o,unit:``,graphicalItemId:u}};return S.createElement(aV,{tooltipEntrySettings:p})}),sU=(e,t)=>e>t?`start`:e<t?`end`:`middle`,cU=(e,t,n)=>dp(typeof t==`function`?t(e):t,n,n*.8),lU=(e,t,n)=>{var r=t.top,i=t.left,a=t.width,o=t.height,s=OT(a,o);return{cx:i+dp(e.cx,a,a/2),cy:r+dp(e.cy,o,o/2),innerRadius:dp(e.innerRadius,s,0),outerRadius:cU(n,e.outerRadius,s),maxRadius:e.maxRadius||Math.sqrt(a*a+o*o)/2}},uU=(e,t)=>ap(t-e)*Math.min(Math.abs(t-e),360),dU=(e,t)=>{if(S.isValidElement(e))return S.cloneElement(e,t);if(typeof e==`function`)return e(t);var n=ld(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className);t.key;var r=XH(t,GH);return S.createElement(YC,YH({},r,{type:`linear`,className:n}))},fU=(e,t,n)=>{if(S.isValidElement(e))return S.cloneElement(e,t);var r=n;if(typeof e==`function`&&(r=e(t),S.isValidElement(r)))return r;var i=ld(`recharts-pie-label-text`,WH(e));return S.createElement(IB,YH({},t,{alignmentBaseline:`middle`,className:i}),r)};function pU(e){var t=e.sectors,n=e.props,r=e.showLabels,i=n.label,a=n.labelLine,o=n.dataKey;if(!r||!i||!t)return null;var s=hd(n),c=gd(i),l=gd(a),u=typeof i==`object`&&`offsetRadius`in i&&typeof i.offsetRadius==`number`&&i.offsetRadius||20,d=t.map((e,t)=>{var n=(e.startAngle+e.endAngle)/2,r=DT(e.cx,e.cy,e.outerRadius+u,n),d=$H($H($H($H({},s),e),{},{stroke:`none`},c),{},{index:t,textAnchor:sU(r.x,e.cx)},r),f=$H($H($H($H({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:t,points:[DT(e.cx,e.cy,e.outerRadius,n),r],key:`line`});return S.createElement(tR,{zIndex:WE.label,key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${t}`},S.createElement(Cz,null,a&&dU(a,f),fU(i,d,uy(e,o))))});return S.createElement(Cz,{className:`recharts-pie-labels`},d)}function mU(e){var t=e.sectors,n=e.props,r=e.showLabels,i=n.label;return typeof i==`object`&&i&&`position`in i?S.createElement(UH,{label:i}):S.createElement(pU,{sectors:t,props:n,showLabels:r})}function hU(e){var t=e.sectors,n=e.activeShape,r=e.inactiveShape,i=e.allOtherPieProps,a=e.shape,o=e.id,s=e.animationElapsedTime,c=e.isAnimating,l=e.isEntrance,u=Z(ZI),d=Z($I),f=Z(eL),p=i.onMouseEnter,m=i.onClick,h=i.onMouseLeave,g=XH(i,KH),_=nV(p,i.dataKey,o),v=rV(h),y=iV(m,i.dataKey,o);return t==null||t.length===0?null:S.createElement(S.Fragment,null,t.map((e,p)=>{if(e?.startAngle===0&&e?.endAngle===0&&t.length!==1)return null;var m=f==null||f===o,h=String(p)===u&&(d==null||i.dataKey===d)&&m,b=n&&h?n:u?r:null,x=$H($H({},e),{},{stroke:e.stroke,tabIndex:-1,index:p,isActive:h,animationElapsedTime:s,isAnimating:c,isEntrance:l,[Ry]:p,[zy]:o});return S.createElement(Cz,YH({key:`sector-${e?.startAngle}-${e?.endAngle}-${e.midAngle}-${p}`,tabIndex:-1,className:`recharts-pie-sector`},Lp(g,e,p),{onMouseEnter:_(e,p),onMouseLeave:v(e,p),onClick:y(e,p)}),S.createElement(tV,{option:b??a,DefaultShape:rU,shapeProps:x}))}))}function gU(e){var t=e.pieSettings,n=e.displayedData,r=e.cells,i=e.offset,a=t.cornerRadius,o=t.startAngle,s=t.endAngle,c=t.dataKey,l=t.nameKey,u=t.tooltipType,d=Math.abs(t.minAngle),f=uU(o,s),p=Math.abs(f),m=n.length<=1?0:t.paddingAngle??0,h=n.filter(e=>uy(e,c,0)!==0).length,g=(p>=360?h:h-1)*m,_=n.reduce((e,t)=>{var n=uy(t,c,0);return e+(X(n)?n:0)},0),v=d>0&&_>0&&n.some(e=>{var t=uy(e,c,0),n=(X(t)?t:0)/_;return t!==0&&n*p<d})?d:0,y=p-h*v-g,b;if(_>0){var x;b=n.map((e,n)=>{var s=uy(e,c,0),d=uy(e,l,n),p=lU(t,i,e),h=(X(s)?s:0)/_,g,b=$H($H({},e),r&&r[n]&&r[n].props),S=b!=null&&`fill`in b&&typeof b.fill==`string`?b.fill:t.fill;g=n?x.endAngle+ap(f)*m*(s===0?0:1):o;var C=g+ap(f)*((s===0?0:v)+h*y),w=(g+C)/2,T=(p.innerRadius+p.outerRadius)/2,E=[{name:d,value:s,payload:b,dataKey:c,type:u,color:S,fill:S,graphicalItemId:t.id}],D=DT(p.cx,p.cy,T,w);return x=$H($H($H($H({},t.presentationProps),{},{percent:h,cornerRadius:typeof a==`string`?parseFloat(a):a,name:d,tooltipPayload:E,midAngle:w,middleRadius:T,tooltipPosition:D},b),p),{},{value:s,dataKey:c,startAngle:g,endAngle:C,payload:b,paddingAngle:s===0?0:ap(f)*m}),x})}return b}function _U(e){var t=e.showLabels,n=e.sectors,r=e.children,i=(0,S.useMemo)(()=>!t||!n?[]:n.map(e=>({value:e.value,payload:e.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:e.cx,cy:e.cy,innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,clockWise:!1},fill:e.fill})),[n,t]);return S.createElement(zH,{value:t?i:void 0},r)}var vU=(e,t)=>{if(e==null)return[];var n=[],r=e.find(e=>e.status!==`removed`),i=r?r.next.startAngle:0;return e.forEach((e,r)=>{if(e.status!==`removed`){var a=r>0?ep(e.next,`paddingAngle`,0):0;if(e.status===`matched`){var o=pp(e.prev.endAngle-e.prev.startAngle,e.next.endAngle-e.next.startAngle,t),s=$H($H({},e.next),{},{startAngle:i+a,endAngle:i+o+a});n.push(s),i=s.endAngle}else{var c=pp(0,e.next.endAngle-e.next.startAngle,t),l=$H($H({},e.next),{},{startAngle:i+a,endAngle:i+c+a});n.push(l),i=l.endAngle}}}),n};function yU(e){var t=e.props,n=e.previousSectorsRef,r=e.id,i=t.sectors,a=t.activeShape,o=t.inactiveShape,s=t.animationInterpolateFn,c=kV(t.onAnimationStart,t.onAnimationEnd),l=c.isAnimating,u=c.handleAnimationStart,d=c.handleAnimationEnd,f=qb();return f==null?null:S.createElement(_U,{showLabels:!l,sectors:i},S.createElement(AV,{animationInput:t,animationIdPrefix:`recharts-pie-`,items:i,previousItemsRef:n,isAnimationActive:t.isAnimationActive,animationBegin:t.animationBegin,animationDuration:t.animationDuration,animationEasing:t.animationEasing,onAnimationStart:u,onAnimationEnd:d,animationInterpolateFn:s,animationMatchBy:t.animationMatchBy,layout:f},(e,n,i)=>S.createElement(Cz,null,S.createElement(hU,{sectors:e,activeShape:a,inactiveShape:o,allOtherPieProps:t,shape:t.shape,id:r,animationElapsedTime:n,isAnimating:l||n<1,isEntrance:i}))),S.createElement(mU,{showLabels:!l,sectors:i,props:t}),t.children)}var bU={animationBegin:400,animationDuration:1500,animationEasing:`ease`,animationInterpolateFn:vU,animationMatchBy:hV,cx:`50%`,cy:`50%`,dataKey:`value`,endAngle:360,fill:`#808080`,hide:!1,innerRadius:0,isAnimationActive:`auto`,label:!1,labelLine:!0,legendType:`rect`,minAngle:0,nameKey:`name`,outerRadius:`80%`,paddingAngle:0,rootTabIndex:0,shape:rU,startAngle:0,stroke:`#fff`,zIndex:WE.area};function xU(e){var t=e.id,n=XH(e,qH),r=e.hide,i=e.className,a=e.rootTabIndex,o=(0,S.useMemo)(()=>UB(e.children,tz),[e.children]),s=Z(e=>vz(e,t,o)),c=(0,S.useRef)(null),l=ld(`recharts-pie`,i);return r||s==null?(c.current=null,S.createElement(Cz,{tabIndex:a,className:l})):S.createElement(tR,{zIndex:e.zIndex},S.createElement(oU,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:s,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t,activeShape:e.activeShape}),S.createElement(Cz,{tabIndex:a,className:l},S.createElement(yU,{props:$H($H({},n),{},{sectors:s}),previousSectorsRef:c,id:t})))}function SU(e){var t=Up(e,bU),n=t.id,r=XH(t,JH),i=hd(r);return S.createElement(BV,{id:n,type:`pie`},e=>S.createElement(S.Fragment,null,S.createElement(ZV,{type:`pie`,id:e,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:t.maxRadius}),S.createElement(iU,YH({},r,{id:e})),S.createElement(xU,YH({},r,{id:e}))))}var CU=SU;CU.displayName=`Pie`;var wU=(e,t)=>{var n=e.x,r=e.y,i=t.x,a=t.y;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},TU=e=>{var t=e.x1,n=e.y1,r=e.x2,i=e.y2;return wU({x:t,y:n},{x:r,y:i})};function EU(e){return(e%180+180)%180}var DU=function(e){var t=e.width,n=e.height,r=EU(arguments.length>1&&arguments[1]!==void 0?arguments[1]:0)*Math.PI/180,i=Math.atan(n/t),a=r>i&&r<Math.PI-i?n/Math.sin(r):t/Math.cos(r);return Math.abs(a)},OU=sv({name:`referenceElements`,initialState:{dots:[],areas:[],lines:[]},reducers:{addDot:(e,t)=>{e.dots.push(t.payload)},removeDot:(e,t)=>{var n=M_(e).dots.findIndex(e=>e===t.payload);n!==-1&&e.dots.splice(n,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var n=M_(e).areas.findIndex(e=>e===t.payload);n!==-1&&e.areas.splice(n,1)},addLine:(e,t)=>{e.lines.push(Gx(t.payload))},removeLine:(e,t)=>{var n=M_(e).lines.findIndex(e=>e===t.payload);n!==-1&&e.lines.splice(n,1)}}}),kU=OU.actions;kU.addDot,kU.removeDot,kU.addArea,kU.removeArea;var AU=kU.addLine,jU=kU.removeLine,MU=OU.reducer;function NU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function PU(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?NU(Object(n),!0).forEach(function(t){FU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):NU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function FU(e,t,n){return(t=IU(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function IU(e){var t=LU(e,`string`);return typeof t==`symbol`?t:t+``}function LU(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var RU=sv({name:`cartesianAxis`,initialState:{xAxis:{},yAxis:{},zAxis:{}},reducers:{addXAxis:{reducer(e,t){e.xAxis[t.payload.id]=Gx(t.payload)},prepare:K_()},replaceXAxis:{reducer(e,t){var n=t.payload,r=n.prev,i=n.next;e.xAxis[r.id]!==void 0&&(r.id!==i.id&&delete e.xAxis[r.id],e.xAxis[i.id]=Gx(i))},prepare:K_()},removeXAxis:{reducer(e,t){delete e.xAxis[t.payload.id]},prepare:K_()},addYAxis:{reducer(e,t){e.yAxis[t.payload.id]=Gx(t.payload)},prepare:K_()},replaceYAxis:{reducer(e,t){var n=t.payload,r=n.prev,i=n.next;e.yAxis[r.id]!==void 0&&(r.id!==i.id&&delete e.yAxis[r.id],e.yAxis[i.id]=Gx(i))},prepare:K_()},removeYAxis:{reducer(e,t){delete e.yAxis[t.payload.id]},prepare:K_()},addZAxis:{reducer(e,t){e.zAxis[t.payload.id]=Gx(t.payload)},prepare:K_()},replaceZAxis:{reducer(e,t){var n=t.payload,r=n.prev,i=n.next;e.zAxis[r.id]!==void 0&&(r.id!==i.id&&delete e.zAxis[r.id],e.zAxis[i.id]=Gx(i))},prepare:K_()},removeZAxis:{reducer(e,t){delete e.zAxis[t.payload.id]},prepare:K_()},updateYAxisWidth(e,t){var n=t.payload,r=n.id,i=n.width,a=e.yAxis[r];if(a){var o=a.widthHistory||[];if(o.length===3&&o[0]===o[2]&&i===o[1]&&i!==a.width&&Math.abs(i-(o[0]??0))<=1)return;var s=[...o,i].slice(-3);e.yAxis[r]=PU(PU({},a),{},{width:i,widthHistory:s})}}}}),zU=RU.actions,BU=zU.addXAxis,VU=zU.replaceXAxis,HU=zU.removeXAxis,UU=zU.addYAxis,WU=zU.replaceYAxis,GU=zU.removeYAxis;zU.addZAxis,zU.replaceZAxis,zU.removeZAxis;var KU=zU.updateYAxisWidth,qU=RU.reducer,JU=Q([Q([Xy],e=>({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),My,Ny],(e,t,n)=>{if(!(!e||t==null||n==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,n-e.top-e.bottom)}}),YU=()=>Z(JU),XU=()=>Z(iL);function ZU(e,t){return nW(e)||tW(e,t)||$U(e,t)||QU()}function QU(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $U(e,t){if(e){if(typeof e==`string`)return eW(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?eW(e,t):void 0}}function eW(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function tW(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function nW(e){if(Array.isArray(e))return e}var rW=(0,S.createContext)(void 0),iW=e=>{var t=e.children,n=ZU((0,S.useState)(`${up(`recharts`)}-clip`),1)[0],r=YU();if(r==null)return null;var i=r.x,a=r.y,o=r.width,s=r.height;return S.createElement(rW.Provider,{value:n},S.createElement(`defs`,null,S.createElement(`clipPath`,{id:n},S.createElement(`rect`,{x:i,y:a,height:s,width:o}))),t)},aW=()=>(0,S.useContext)(rW),oW=class{constructor(e){var t=e.x,n=e.y;this.xAxisScale=t,this.yAxisScale=n}map(e,t){var n=t.position;return{x:this.xAxisScale.map(e.x,{position:n})??0,y:this.yAxisScale.map(e.y,{position:n})??0}}mapWithFallback(e,t){var n=t.position,r=t.fallback,i=r===`rangeMin`?this.yAxisScale.rangeMin():r===`rangeMax`?this.yAxisScale.rangeMax():0,a=r===`rangeMin`?this.xAxisScale.rangeMin():r===`rangeMax`?this.xAxisScale.rangeMax():0;return{x:this.xAxisScale.map(e.x,{position:n})??a,y:this.yAxisScale.map(e.y,{position:n})??i}}isInRange(e){var t=e.x,n=e.y,r=t==null||this.xAxisScale.isInRange(t),i=n==null||this.yAxisScale.isInRange(n);return r&&i}};function sW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?sW(Object(n),!0).forEach(function(t){lW(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function lW(e,t,n){return(t=uW(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function uW(e){var t=dW(e,`string`);return typeof t==`symbol`?t:t+``}function dW(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function fW(){return fW=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},fW.apply(null,arguments)}var pW=(e,t)=>{var n;if(S.isValidElement(e))n=S.cloneElement(e,t);else if(typeof e==`function`)n=e(t);else{if(!ry(t.x1)||!ry(t.y1)||!ry(t.x2)||!ry(t.y2))return null;n=S.createElement(`line`,fW({},t,{className:`recharts-reference-line-line`}))}return n},mW=(e,t,n,r,i,a)=>{var o=a.x,s=a.width,c=i.map(e,{position:n});if(!ry(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:o+s,y:c},{x:o,y:c}];return r===`left`?l.reverse():l},hW=(e,t,n,r,i,a)=>{var o=a.y,s=a.height,c=i.map(e,{position:n});if(!ry(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:c,y:o+s},{x:c,y:o}];return r===`top`?l.reverse():l},gW=(e,t,n,r)=>{var i=[r.mapWithFallback(e[0],{position:n,fallback:`rangeMin`}),r.mapWithFallback(e[1],{position:n,fallback:`rangeMax`})];return t===`discard`&&i.some(e=>!r.isInRange(e))?null:i},_W=(e,t,n,r,i,a,o)=>{var s=o.x,c=o.y,l=o.segment,u=o.ifOverflow,d=cp(s);return cp(c)?mW(c,u,r,a,t,n):d?hW(s,u,r,i,e,n):l!=null&&l.length===2?gW(l,u,r,new oW({x:e,y:t})):null};function vW(e){var t=gh();return(0,S.useEffect)(()=>(t(AU(e)),()=>{t(jU(e))})),null}function yW(e){var t=e.xAxisId,n=e.yAxisId,r=e.shape,i=e.className,a=e.ifOverflow,o=eb(),s=aW(),c=Z(e=>EN(e,t)),l=Z(e=>kN(e,n)),u=Z(e=>oF(e,`xAxis`,t,o)),d=Z(e=>oF(e,`yAxis`,n,o)),f=Lb();if(!s||!f||c==null||l==null||u==null||d==null)return null;var p=_W(u,d,f,e.position,c.orientation,l.orientation,e);if(!p)return null;var m=p[0],h=p[1];if(m==null||h==null)return null;var g=m.x,_=m.y,v=h.x,y=h.y,b=cW(cW({clipPath:a===`hidden`?`url(#${s})`:void 0},_d(e)),{},{x1:g,y1:_,x2:v,y2:y}),x=TU({x1:g,y1:_,x2:v,y2:y});return S.createElement(tR,{zIndex:e.zIndex},S.createElement(Cz,{className:ld(`recharts-reference-line`,i)},pW(r,b),S.createElement(hH,fW({},x,{lowerWidth:x.width,upperWidth:x.width}),S.createElement(kH,{label:e.label}),e.children)))}var bW={ifOverflow:`discard`,xAxisId:0,yAxisId:0,fill:`none`,label:!1,stroke:`#ccc`,fillOpacity:1,strokeWidth:1,position:`middle`,zIndex:WE.line};function xW(e){var t=Up(e,bW);return S.createElement(S.Fragment,null,S.createElement(vW,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x:t.x,y:t.y,segment:t.segment}),S.createElement(yW,t))}xW.displayName=`ReferenceLine`;function SW(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;r<e.length;r+=t){var i=e[r];i!==void 0&&n.push(i)}return n}function CW(e,t,n){return DU({width:e.width+t.width,height:e.height+t.height},n)}function wW(e,t,n){var r=n===`width`,i=e.x,a=e.y,o=e.width,s=e.height;return t===1?{start:r?i:a,end:r?i+o:a+s}:{start:r?i+o:a+s,end:r?i:a}}function TW(e,t,n,r,i){if(e*t<e*r||e*t>e*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function EW(e,t){return SW(e,t+1)}function DW(e,t,n,r,i){for(var a=(r||[]).slice(),o=t.start,s=t.end,c=0,l=1,u=o,d=function(){var t=r?.[c];if(t===void 0)return{v:SW(r,l)};var a=c,d,f=()=>(d===void 0&&(d=n(t,a)),d),p=t.coordinate,m=c===0||TW(e,p,f,u,s);m||(c=0,u=o,l+=1),m&&(u=p+e*(f()/2+i),c+=l)},f;l<=a.length;)if(f=d(),f)return f.v;return[]}function OW(e,t,n,r,i){var a=(r||[]).slice().length;if(a===0)return[];for(var o=t.start,s=t.end,c=1;c<=a;c++){for(var l=(a-1)%c,u=o,d=!0,f=function(){var t=r[m];if(t==null)return 0;var a=m,o,c=()=>(o===void 0&&(o=n(t,a)),o),f=t.coordinate,p=m===l||TW(e,f,c,u,s);if(!p)return d=!1,1;p&&(u=f+e*(c()/2+i))},p,m=l;m<a&&(p=f(),!(p!==0&&p===1));m+=c);if(d){for(var h=[],g=l;g<a;g+=c){var _=r[g];_!=null&&h.push(_)}return h}}return[]}function kW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function AW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?kW(Object(n),!0).forEach(function(t){jW(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function jW(e,t,n){return(t=MW(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function MW(e){var t=NW(e,`string`);return typeof t==`symbol`?t:t+``}function NW(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function PW(e,t,n,r,i){for(var a=(r||[]).slice(),o=a.length,s=t.start,c=t.end,l=function(t){var r=a[t];if(r==null)return 1;var l=r,u,d=()=>(u===void 0&&(u=n(r,t)),u);if(t===o-1){var f=e*(l.coordinate+e*d()/2-c);a[t]=l=AW(AW({},l),{},{tickCoord:f>0?l.coordinate-f*e:l.coordinate})}else a[t]=l=AW(AW({},l),{},{tickCoord:l.coordinate});l.tickCoord!=null&&TW(e,l.tickCoord,d,s,c)&&(c=l.tickCoord-e*(d()/2+i),a[t]=AW(AW({},l),{},{isShow:!0}))},u=o-1;u>=0;u--)if(l(u))continue;return a}function FW(e,t,n,r,i,a){var o=(r||[]).slice(),s=o.length,c=t.start,l=t.end;if(a){var u=r[s-1];if(u!=null){var d=n(u,s-1),f=e*(u.coordinate+e*d/2-l);o[s-1]=u=AW(AW({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate}),u.tickCoord!=null&&TW(e,u.tickCoord,()=>d,c,l)&&(l=u.tickCoord-e*(d/2+i),o[s-1]=AW(AW({},u),{},{isShow:!0}))}}for(var p=a?s-1:s,m=function(t){var r=o[t];if(r==null)return 1;var a=r,s,u=()=>(s===void 0&&(s=n(r,t)),s);if(t===0){var d=e*(a.coordinate-e*u()/2-c);o[t]=a=AW(AW({},a),{},{tickCoord:d<0?a.coordinate-d*e:a.coordinate})}else o[t]=a=AW(AW({},a),{},{tickCoord:a.coordinate});a.tickCoord!=null&&TW(e,a.tickCoord,u,c,l)&&(c=a.tickCoord+e*(u()/2+i),o[t]=AW(AW({},a),{},{isShow:!0}))},h=0;h<p;h++)if(m(h))continue;return o}function IW(e,t,n){var r=e.tick,i=e.ticks,a=e.viewBox,o=e.minTickGap,s=e.orientation,c=e.interval,l=e.tickFormatter,u=e.unit,d=e.angle;if(!i||!i.length||!r)return[];if(X(c)||fC.isSsr)return EW(i,X(c)?c:0)??[];var f=[],p=s===`top`||s===`bottom`?`width`:`height`,m=u&&p===`width`?zz(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},h=(e,r)=>{var i=typeof l==`function`?l(e.value,r):e.value;return p===`width`?CW(zz(i,{fontSize:t,letterSpacing:n}),m,d):zz(i,{fontSize:t,letterSpacing:n})[p]},g=i[0],_=i[1],v=i.length>=2&&g!=null&&_!=null?ap(_.coordinate-g.coordinate):1,y=wW(a,v,p);return c===`equidistantPreserveStart`?DW(v,y,h,i,o):c===`equidistantPreserveEnd`?OW(v,y,h,i,o):(f=c===`preserveStart`||c===`preserveStartEnd`?FW(v,y,h,i,o,c===`preserveStartEnd`):PW(v,y,h,i,o),f.filter(e=>e.isShow))}var LW=e=>{var t=e.ticks,n=e.label,r=e.labelGapWithTick,i=r===void 0?5:r,a=e.tickSize,o=a===void 0?0:a,s=e.tickMargin,c=s===void 0?0:s,l=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>l&&(l=t.width)}});var u=n?n.getBoundingClientRect().width:0,d=o+c,f=l+d+u+(n?i:0);return Math.round(f)}return 0},RW=sv({name:`renderedTicks`,initialState:{xAxis:{},yAxis:{}},reducers:{setRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,i=n.axisId,a=n.ticks;e[r][i]=Gx(a)},removeRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,i=n.axisId;delete e[r][i]}}}),zW=RW.actions,BW=zW.setRenderedTicks,VW=zW.removeRenderedTicks,HW=RW.reducer,UW=[`axisLine`,`width`,`height`,`className`,`hide`,`ticks`,`axisType`,`axisId`];function WW(e,t){return YW(e)||JW(e,t)||KW(e,t)||GW()}function GW(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function KW(e,t){if(e){if(typeof e==`string`)return qW(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qW(e,t):void 0}}function qW(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function JW(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function YW(e){if(Array.isArray(e))return e}function XW(e,t){if(e==null)return{};var n,r,i=ZW(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ZW(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function QW(){return QW=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},QW.apply(null,arguments)}function $W(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?$W(Object(n),!0).forEach(function(t){tG(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$W(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function tG(e,t,n){return(t=nG(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nG(e){var t=rG(e,`string`);return typeof t==`symbol`?t:t+``}function rG(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var iG={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`,zIndex:WE.axis};function aG(e){var t=e.x,n=e.y,r=e.width,i=e.height,a=e.orientation,o=e.mirror,s=e.axisLine,c=e.otherSvgProps;if(!s)return null;var l=eG(eG(eG({},c),hd(s)),{},{fill:`none`});if(a===`top`||a===`bottom`){var u=+(a===`top`&&!o||a===`bottom`&&o);l=eG(eG({},l),{},{x1:t,y1:n+u*i,x2:t+r,y2:n+u*i})}else{var d=+(a===`left`&&!o||a===`right`&&o);l=eG(eG({},l),{},{x1:t+d*r,y1:n,x2:t+d*r,y2:n+i})}return S.createElement(`line`,QW({},l,{className:ld(`recharts-cartesian-axis-line`,ep(s,`className`))}))}function oG(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h=s?-1:1,g=e.tickSize||o,_=X(e.tickCoord)?e.tickCoord:e.coordinate;switch(a){case`top`:l=u=e.coordinate,f=n+ +!s*i,d=f-h*g,m=d-h*c,p=_;break;case`left`:d=f=e.coordinate,u=t+ +!s*r,l=u-h*g,p=l-h*c,m=_;break;case`right`:d=f=e.coordinate,u=t+ +s*r,l=u+h*g,p=l+h*c,m=_;break;default:l=u=e.coordinate,f=n+ +s*i,d=f+h*g,m=d+h*c,p=_;break}return{line:{x1:l,y1:d,x2:u,y2:f},tick:{x:p,y:m}}}function sG(e,t){switch(e){case`left`:return t?`start`:`end`;case`right`:return t?`end`:`start`;default:return`middle`}}function cG(e,t){switch(e){case`left`:case`right`:return`middle`;case`top`:return t?`start`:`end`;default:return t?`end`:`start`}}function lG(e){var t=e.option,n=e.tickProps,r=e.value,i,a=ld(n.className,`recharts-cartesian-axis-tick-value`);if(S.isValidElement(t))i=S.cloneElement(t,eG(eG({},n),{},{className:a}));else if(typeof t==`function`)i=t(eG(eG({},n),{},{className:a}));else{var o=`recharts-cartesian-axis-tick-value`;typeof t!=`boolean`&&(o=ld(o,WH(t))),i=S.createElement(IB,QW({},n,{className:o}),r)}return i}function uG(e){var t=e.ticks,n=e.axisType,r=e.axisId,i=gh();return(0,S.useEffect)(()=>r==null||n==null?vp:(i(BW({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{i(VW({axisId:r,axisType:n}))}),[i,t,r,n]),null}var dG=(0,S.forwardRef)((e,t)=>{var n=e.ticks,r=n===void 0?[]:n,i=e.tick,a=e.tickLine,o=e.stroke,s=e.tickFormatter,c=e.unit,l=e.padding,u=e.tickTextProps,d=e.orientation,f=e.mirror,p=e.x,m=e.y,h=e.width,g=e.height,_=e.tickSize,v=e.tickMargin,y=e.fontSize,b=e.letterSpacing,x=e.getTicksConfig,C=e.events,w=e.axisType,T=e.axisId,E=IW(eG(eG({},x),{},{ticks:r}),y,b),D=hd(x),O=gd(i),k=TB(D.textAnchor)?D.textAnchor:sG(d,f),A=cG(d,f),j={};typeof a==`object`&&(j=a);var M=eG(eG({},D),{},{fill:`none`},j),N=E.map(e=>eG({entry:e},oG(e,p,m,h,g,d,_,f,v))),ee=N.map(e=>{var t=e.entry,n=e.line;return S.createElement(Cz,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},a&&S.createElement(`line`,QW({},M,n,{className:ld(`recharts-cartesian-axis-tick-line`,ep(a,`className`))})))}),te=N.map((e,t)=>{var n=e.entry,r=e.tick,a=eG(eG({},eG(eG(eG(eG({verticalAnchor:A},D),{},{textAnchor:k,stroke:`none`,fill:o},r),{},{index:t,payload:n,visibleTicksCount:E.length,tickFormatter:s,padding:l},u),{},{angle:u?.angle??D.angle??0})),O);return S.createElement(Cz,QW({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},Lp(C,n,t)),i&&S.createElement(lG,{option:i,tickProps:a,value:`${typeof s==`function`?s(n.value,t):n.value}${c||``}`}))});return S.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${w}-ticks`},S.createElement(uG,{ticks:E,axisId:T,axisType:w}),te.length>0&&S.createElement(tR,{zIndex:WE.label},S.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${w}-tick-labels`,ref:t},te)),ee.length>0&&S.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${w}-tick-lines`},ee))}),fG=(0,S.forwardRef)((e,t)=>{var n=e.axisLine,r=e.width,i=e.height,a=e.className,o=e.hide,s=e.ticks,c=e.axisType,l=e.axisId,u=XW(e,UW),d=WW((0,S.useState)(``),2),f=d[0],p=d[1],m=WW((0,S.useState)(``),2),h=m[0],g=m[1],_=(0,S.useRef)(null);(0,S.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>LW({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var v=(0,S.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);_.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==f||a!==h)&&(p(i),g(a))}}},[f,h]);return o||r!=null&&r<=0||i!=null&&i<=0?null:S.createElement(tR,{zIndex:e.zIndex},S.createElement(Cz,{className:ld(`recharts-cartesian-axis`,a)},S.createElement(aG,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:hd(e)}),S.createElement(dG,{ref:v,axisType:c,events:u,fontSize:f,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:l}),S.createElement(hH,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},S.createElement(kH,{label:e.label,labelRef:e.labelRef}),e.children)))}),pG=S.forwardRef((e,t)=>{var n=Up(e,iG);return S.createElement(fG,QW({},n,{ref:t}))});pG.displayName=`CartesianAxis`;var mG=[`x1`,`y1`,`x2`,`y2`,`key`],hG=[`offset`],gG=[`xAxisId`,`yAxisId`],_G=[`xAxisId`,`yAxisId`];function vG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?vG(Object(n),!0).forEach(function(t){bG(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function bG(e,t,n){return(t=xG(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function xG(e){var t=SG(e,`string`);return typeof t==`symbol`?t:t+``}function SG(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function CG(){return CG=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},CG.apply(null,arguments)}function wG(e,t){if(e==null)return{};var n,r,i=TG(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function TG(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var EG=e=>{var t=e.fill;if(!t||t===`none`)return null;var n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.ry;return S.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function DG(e){var t=e.option,n=e.lineItemProps,r;if(S.isValidElement(t))r=S.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var i=n.x1,a=n.y1,o=n.x2,s=n.y2,c=n.key,l=hd(wG(n,mG))??{};l.offset;var u=wG(l,hG);r=S.createElement(`line`,CG({},u,{x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function OG(e){var t=e.x,n=e.width,r=e.horizontal,i=r===void 0?!0:r,a=e.horizontalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=wG(e,gG),s=a.map((e,r)=>{var a=yG(yG({},o),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${r}`,index:r});return S.createElement(DG,{key:`line-${r}`,option:i,lineItemProps:a})});return S.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},s)}function kG(e){var t=e.y,n=e.height,r=e.vertical,i=r===void 0?!0:r,a=e.verticalPoints;if(!i||!a||!a.length)return null;e.xAxisId,e.yAxisId;var o=wG(e,_G),s=a.map((e,r)=>{var a=yG(yG({},o),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${r}`,index:r});return S.createElement(DG,{option:i,lineItemProps:a,key:`line-${r}`})});return S.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},s)}function AG(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,i=e.y,a=e.width,o=e.height,s=e.horizontalPoints,c=e.horizontal;if(!(c===void 0||c)||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return S.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return S.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function jG(e){var t=e.vertical,n=t===void 0?!0:t,r=e.verticalFill,i=e.fillOpacity,a=e.x,o=e.y,s=e.width,c=e.height,l=e.verticalPoints;if(!n||!r||!r.length)return null;var u=l.map(e=>Math.round(e+a-a)).sort((e,t)=>e-t);a!==u[0]&&u.unshift(0);var d=u.map((e,t)=>{var n=u[t+1],l=n==null?a+s-e:n-e;if(l<=0)return null;var d=t%r.length;return S.createElement(`rect`,{key:`react-${t}`,x:e,y:o,width:l,height:c,stroke:`none`,fill:r[d],fillOpacity:i,className:`recharts-cartesian-grid-bg`})});return S.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},d)}var MG=(e,t)=>{var n=e.xAxis,r=e.width,i=e.height,a=e.offset;return py(IW(yG(yG(yG({},iG),n),{},{ticks:my(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},NG=(e,t)=>{var n=e.yAxis,r=e.width,i=e.height,a=e.offset;return py(IW(yG(yG(yG({},iG),n),{},{ticks:my(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},PG={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:`#ccc`,fill:`none`,verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:WE.grid};function FG(e){var t=Bb(),n=Vb(),r=zb(),i=yG(yG({},Up(e,PG)),{},{x:X(e.x)?e.x:r.left,y:X(e.y)?e.y:r.top,width:X(e.width)?e.width:r.width,height:X(e.height)?e.height:r.height}),a=i.xAxisId,o=i.yAxisId,s=i.x,c=i.y,l=i.width,u=i.height,d=i.syncWithTicks,f=i.horizontalValues,p=i.verticalValues,m=eb(),h=Z(e=>TF(e,`xAxis`,a,m)),g=Z(e=>TF(e,`yAxis`,o,m));if(!iy(l)||!iy(u)||!X(s)||!X(c))return null;var _=i.verticalCoordinatesGenerator||MG,v=i.horizontalCoordinatesGenerator||NG,y=i.horizontalPoints,b=i.verticalPoints;if((!y||!y.length)&&typeof v==`function`){var x=f&&f.length,C=v({yAxis:g?yG(yG({},g),{},{ticks:x?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},x?!0:d);ob(Array.isArray(C),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof C}]`),Array.isArray(C)&&(y=C)}if((!b||!b.length)&&typeof _==`function`){var w=p&&p.length,T=_({xAxis:h?yG(yG({},h),{},{ticks:w?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},w?!0:d);ob(Array.isArray(T),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof T}]`),Array.isArray(T)&&(b=T)}return S.createElement(tR,{zIndex:i.zIndex},S.createElement(`g`,{className:`recharts-cartesian-grid`},S.createElement(EG,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),S.createElement(AG,CG({},i,{horizontalPoints:y})),S.createElement(jG,CG({},i,{verticalPoints:b})),S.createElement(OG,CG({},i,{offset:r,horizontalPoints:y,xAxis:h,yAxis:g})),S.createElement(kG,CG({},i,{offset:r,verticalPoints:b,xAxis:h,yAxis:g}))))}FG.displayName=`CartesianGrid`;var IG=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function LG(){return LG=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},LG.apply(null,arguments)}function RG(e,t){if(e==null)return{};var n,r,i=zG(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function zG(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function BG(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function VG(e,t){return`${t}px ${e}px`}function HG(e){return e.length%2==0?e:[...e,...e]}function UG(e,t){for(var n=[],r=0;r<t;++r)n.push(...e);return n}function WG(e,t,n){var r=HG(n),i=r.reduce((e,t)=>e+t,0);if(!i)return VG(t,e);for(var a=Math.floor(e/i),o=e%i,s=[],c=0,l=0;c<r.length;l+=(u=r[c])??0,++c){var u,d=r[c];if(d!=null&&l+d>o){s=[...r.slice(0,c),o-l];break}}var f=s.length%2==0?[0,t]:[t];return[...UG(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function GG(e,t,n){return e?WG(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):VG(t,n)}function KG(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=RG(e,IG),a=r??!1,o;if(t!=null){var s=i.pathRef;o=GG(n,BG(s?.current??null),t)}else n!=null&&(o=String(n));return S.createElement(YC,LG({},i,{connectNulls:a,strokeDasharray:o}))}function qG(e){var t=(0,S.useRef)(0),n=(0,S.useRef)(0),r=(0,S.useRef)(!1),i=(0,S.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,S.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(rp(t.current+e*i),i);return e>0&&i>0&&(n.current=Math.max(n.current,a),a>=i)?(r.current=!0,null):a},[])}function JG(){return JG=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},JG.apply(null,arguments)}var YG=e=>{var t=e.cx,n=e.cy,r=e.r,i=e.className,a=ld(`recharts-dot`,i);return X(t)&&X(n)&&X(r)?S.createElement(`circle`,JG({},hd(e),Fp(e),{className:a,cx:t,cy:n,r})):null},XG=[`points`];function ZG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function QG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ZG(Object(n),!0).forEach(function(t){$G(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $G(e,t,n){return(t=eK(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eK(e){var t=tK(e,`string`);return typeof t==`symbol`?t:t+``}function tK(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function nK(){return nK=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nK.apply(null,arguments)}function rK(e,t){if(e==null)return{};var n,r,i=iK(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function iK(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function aK(e){var t=e.option,n=e.dotProps,r=e.className;if((0,S.isValidElement)(t))return(0,S.cloneElement)(t,n);if(typeof t==`function`)return t(n);var i=ld(r,typeof t==`boolean`?``:t.className),a=n??{};a.points;var o=rK(a,XG);return S.createElement(YG,nK({},o,{className:i}))}function oK(e,t){return e==null?!1:t?!0:e.length===1}function sK(e){var t=e.points,n=e.dot,r=e.className,i=e.dotClassName,a=e.dataKey,o=e.baseProps,s=e.needClip,c=e.clipPathId,l=e.zIndex,u=l===void 0?WE.scatter:l;if(!oK(t,n))return null;var d=WB(n),f=vd(n),p=t.map((e,r)=>{var s=QG(QG(QG({r:3},o),f),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return S.createElement(aK,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${d?``:`dots-`}${c})`),S.createElement(tR,{zIndex:u},S.createElement(Cz,nK({className:r},m),p))}function cK(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function lK(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?cK(Object(n),!0).forEach(function(t){uK(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cK(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function uK(e,t,n){return(t=dK(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dK(e){var t=fK(e,`string`);return typeof t==`symbol`?t:t+``}function fK(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var pK=e=>{var t=e.point,n=e.childIndex,r=e.mainColor,i=e.activeDot,a=e.dataKey,o=e.clipPath;if(i===!1||t.x==null||t.y==null)return null;var s=lK(lK(lK({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),gd(i)),Fp(i)),c=(0,S.isValidElement)(i)?(0,S.cloneElement)(i,s):typeof i==`function`?i(s):S.createElement(YG,s);return S.createElement(Cz,{className:`recharts-active-dot`,clipPath:o},c)};function mK(e){var t=e.points,n=e.mainColor,r=e.activeDot,i=e.itemDataKey,a=e.clipPath,o=e.zIndex,s=o===void 0?WE.activeDot:o,c=Z(ZI),l=XU();if(t==null||l==null)return null;var u=t.find(e=>l.includes(e.payload));return hp(u)?null:S.createElement(tR,{zIndex:s},S.createElement(pK,{point:u,childIndex:Number(c),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var hK=sv({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]||(e[r]=[]),e[r].push(i)},replaceErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.prev,a=n.next;e[r]&&(e[r]=e[r].map(e=>e.dataKey===i.dataKey&&e.direction===i.direction?a:e))},removeErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]&&(e[r]=e[r].filter(e=>e.dataKey!==i.dataKey||e.direction!==i.direction))}}}),gK=hK.actions;gK.addErrorBar,gK.replaceErrorBar,gK.removeErrorBar;var _K=hK.reducer,vK=[`children`];function yK(e,t){if(e==null)return{};var n,r,i=bK(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function bK(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var xK=(0,S.createContext)({data:[],xAxisId:`xAxis-0`,yAxisId:`yAxis-0`,dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function SK(e){var t=e.children,n=yK(e,vK);return S.createElement(xK.Provider,{value:n},t)}function CK(e,t){var n=Z(t=>EN(t,e)),r=Z(e=>kN(e,t)),i=n?.allowDataOverflow??wN.allowDataOverflow,a=r?.allowDataOverflow??DN.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function wK(e){var t=e.xAxisId,n=e.yAxisId,r=e.clipPathId,i=YU(),a=CK(t,n),o=a.needClipX,s=a.needClipY,c=a.needClip,l=Z(e=>$P(e,t,!1)),u=Z(e=>eF(e,n,!1));if(!c||!i)return null;var d=i.x,f=i.y,p=i.width,m=i.height,h=o&&l?Math.min(l[0],l[1]):d-p/2,g=s&&u?Math.min(u[0],u[1]):f-m/2,_=o&&l?Math.abs(l[1]-l[0]):p*2,v=s&&u?Math.abs(u[1]-u[0]):m*2;return S.createElement(`clipPath`,{id:`clipPath-${r}`},S.createElement(`rect`,{x:h,y:g,width:_,height:v}))}var TK=(e,t,n,r)=>OF(e,`xAxis`,t,r),EK=(e,t,n,r)=>DF(e,`xAxis`,t,r),DK=(e,t,n,r)=>OF(e,`yAxis`,n,r),OK=(e,t,n,r)=>DF(e,`yAxis`,n,r),kK=Q([Ub,TK,DK,EK,OK],(e,t,n,r,i)=>fy(e,`xAxis`)?Dy(t,r,!1):Dy(n,i,!1)),AK=(e,t,n,r,i)=>i;function jK(e){return e.type===`line`}var MK=Q([Ub,TK,DK,EK,OK,Q([LN,AK],(e,t)=>e.filter(jK).find(e=>e.id===t)),kK,nE],(e,t,n,r,i,a,o,s)=>{var c=s.chartData,l=s.dataStartIndex,u=s.dataEndIndex;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var d=a.dataKey,f=a.data,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return iq({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function NK(e){var t=gd(e),n=3,r=2;if(t!=null){var i=t.r,a=t.strokeWidth,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var PK=[`id`],FK=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],IK=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function LK(){return LK=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},LK.apply(null,arguments)}function RK(e,t){if(e==null)return{};var n,r,i=zK(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function zK(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function BK(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function VK(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?BK(Object(n),!0).forEach(function(t){HK(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):BK(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function HK(e,t,n){return(t=UK(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function UK(e){var t=WK(e,`string`);return typeof t==`symbol`?t:t+``}function WK(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function GK(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function KK(e){var t=0,n=0;for(var r of e)r.status===`matched`&&r.prev.x!=null&&r.next.x!=null&&(t+=r.next.x-r.prev.x,n++);return n>0?t/n:0}var qK={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationInterpolateFn:(e,t)=>{if(e==null)return[];if(t===1)return e.flatMap(e=>e.status===`removed`?[]:[e.next]);var n=KK(e),r=[];for(var i of e)if(i.status===`matched`)r.push(VK(VK({},i.next),{},{x:pp(i.prev.x,i.next.x,t),y:pp(i.prev.y,i.next.y,t)}));else if(i.status===`added`)if(i.next.x!=null){var a=i.next.x-n;r.push(VK(VK({},i.next),{},{x:pp(a,i.next.x,t),y:i.next.y}))}else r.push(i.next);else if(i.status===`removed`&&i.prev.x!=null){var o=i.prev.x+n;r.push(VK(VK({},i.prev),{},{x:pp(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:mV,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:KG,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:WE.line,type:`linear`},JK=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:ky(n,t),payload:e}]},YK=S.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.tooltipType,u=e.id,d={dataDefinedOnItem:n,getPosition:vp,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:ky(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return S.createElement(aV,{tooltipEntrySettings:d})});function XK(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=hd(RK(r,PK));return S.createElement(sK,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:s,needClip:o,clipPathId:t})}function ZK(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,S.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return VK(VK({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return S.createElement(LH,{value:t?i:void 0},n)}function QK(e){var t=e.clipPathId,n=e.pathRef,r=e.points,i=e.props,a=e.animationElapsedTime,o=e.isAnimating,s=e.isEntrance,c=e.visibleLength,l=i.type,u=i.layout,d=i.connectNulls,f=i.needClip,p=i.shape,m=i.strokeDasharray,h=VK(VK({},_d(RK(i,FK))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:f?`url(#clipPath-${t})`:void 0,points:r,type:l,layout:u,connectNulls:d,strokeDasharray:m??i.strokeDasharray,pathRef:n,animationElapsedTime:a,isAnimating:o,isEntrance:i.animateNewValues?s:!1,visibleLength:c});return S.createElement(S.Fragment,null,r?.length>1&&S.createElement(tV,{option:p,DefaultShape:qK.shape,shapeProps:h}),S.createElement(XK,{points:r,clipPathId:t,props:i}))}function $K(e){var t=e.clipPathId,n=e.props,r=e.pathRef,i=e.previousPointsRef,a=n.points,o=n.isAnimationActive,s=n.animationBegin,c=n.animationDuration,l=n.animationEasing,u=n.animationMatchBy,d=n.animationInterpolateFn,f=n.layout,p=GK(r.current),m=kV(n.onAnimationStart,n.onAnimationEnd),h=m.isAnimating,g=m.handleAnimationStart,_=m.handleAnimationEnd,v=!h,y=qG(a),b=(0,S.useCallback)(e=>e>0&&p>0,[p]);return S.createElement(ZK,{points:a,showLabels:v},n.children,S.createElement(AV,{animationInput:a,animationIdPrefix:`recharts-line-`,items:a,previousItemsRef:i,isAnimationActive:o,animationBegin:s,animationDuration:c,animationEasing:l,onAnimationStart:g,onAnimationEnd:_,animationInterpolateFn:d,animationMatchBy:u,shouldUpdatePreviousRef:b,layout:f},(e,i,a)=>{var o=h||i<1,s=o?y(i,p):null;return S.createElement(QK,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),S.createElement(UH,{label:n.label}))}function eq(e){var t=e.clipPathId,n=e.props,r=(0,S.useRef)(null),i=(0,S.useRef)(null);return S.createElement($K,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var tq=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:uy(e.payload,t)}),nq=class extends S.Component{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.xAxisId,o=e.yAxisId,s=e.top,c=e.left,l=e.width,u=e.height,d=e.id,f=e.needClip,p=e.zIndex;if(t)return null;var m=ld(`recharts-line`,i),h=d,g=NK(n),_=g.r,v=g.strokeWidth,y=WB(n),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${h})`:void 0;return S.createElement(tR,{zIndex:p},S.createElement(Cz,{className:m},f&&S.createElement(`defs`,null,S.createElement(wK,{clipPathId:h,xAxisId:a,yAxisId:o}),!y&&S.createElement(`clipPath`,{id:`clipPath-dots-${h}`},S.createElement(`rect`,{x:c-b/2,y:s-b/2,width:l+b,height:u+b}))),S.createElement(SK,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:tq,errorBarOffset:0},S.createElement(eq,{props:this.props,clipPathId:h}))),S.createElement(mK,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}};function rq(e){var t=Up(e,qK),n=t.activeDot,r=t.animateNewValues,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.connectNulls,c=t.dot,l=t.hide,u=t.isAnimationActive,d=t.label,f=t.legendType,p=t.xAxisId,m=t.yAxisId,h=t.id,g=RK(t,IK),_=CK(p,m).needClip,v=YU(),y=Wb(),b=eb(),x=Z(e=>MK(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var C=v.height,w=v.width,T=v.x,E=v.y;return S.createElement(nq,LK({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:C,width:w,left:T,top:E,needClip:_}))}function iq(e){var t=e.layout,n=e.xAxis,r=e.yAxis,i=e.xAxisTicks,a=e.yAxisTicks,o=e.dataKey,s=e.bandSize;return e.displayedData.map((e,c)=>{var l=uy(e,o);if(t===`horizontal`)return{x:yy({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(hp(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=hp(l)?null:n.scale.map(l),d=yy({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function aq(e){var t=Up(e,qK),n=eb();return S.createElement(BV,{id:t.id,type:`line`},e=>S.createElement(S.Fragment,null,S.createElement(oV,{legendPayload:JK(t)}),S.createElement(YK,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),S.createElement(XV,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),S.createElement(rq,LK({},t,{id:e}))))}var oq=S.memo(aq,vS);oq.displayName=`Line`;function sq(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function cq(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var lq=(e,t,n)=>OF(e,`xAxis`,sq(e,t),n),uq=(e,t,n)=>DF(e,`xAxis`,sq(e,t),n),dq=(e,t,n)=>OF(e,`yAxis`,cq(e,t),n),fq=(e,t,n)=>DF(e,`yAxis`,cq(e,t),n),pq=Q([Ub,lq,dq,uq,fq],(e,t,n,r,i)=>fy(e,`xAxis`)?Dy(t,r,!1):Dy(n,i,!1)),mq=Q([LN,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),hq=e=>fy(Ub(e),`xAxis`)?`yAxis`:`xAxis`,gq=(e,t)=>hq(e)===`yAxis`?cq(e,t):sq(e,t),_q=Q([Ub,lq,dq,uq,fq,Q([mq,(e,t,n)=>lP(e,hq(e),gq(e,t),n)],(e,t)=>{if(!(e==null||t==null)){var n=e.stackId,r=pD(e);if(!(n==null||r==null)){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),rE,pq,mq,UE],(e,t,n,r,i,a,o,s,c,l)=>{var u=o.chartData,d=o.dataStartIndex,f=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var p=c.data,m=p&&p.length>0?p:u?.slice(d,f+1);if(m!=null)return Xq({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:d,areaSettings:c,stackedData:a,displayedData:m,chartBaseValue:l,bandSize:s})}}),vq=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],yq=[`id`,`baseLine`];function bq(){return bq=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bq.apply(null,arguments)}function xq(e,t){if(e==null)return{};var n,r,i=Sq(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Sq(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Cq(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!ry(a)||!ry(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return X(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),X(c)?S.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function wq(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!ry(a)||!ry(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return X(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),X(c)?S.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function Tq(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?S.createElement(wq,{alpha:t,points:r,baseLine:i,strokeWidth:a}):S.createElement(Cq,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Eq(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r===void 0?!1:r,a=e.isEntrance,o=a===void 0?!1:a,s=e.layout,c=e.isRange,l=e.stroke,u=e.connectNulls,d=xq(e,vq),f=s===`vertical`?`vertical`:`horizontal`,p=u??!1,m=LV(),h=d.id,g=d.baseLine,_=hd(xq(d,yq)),v=S.createElement(YC,bq({},d,{id:h,baseLine:g,connectNulls:p,stroke:`none`,className:`recharts-area-area`,layout:f})),y=l!==`none`&&S.createElement(YC,bq({},_,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:d.points})),b=l!==`none`&&c&&Array.isArray(g)&&S.createElement(YC,bq({},_,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:g}));return o&&(i||n<1)?S.createElement(Cz,null,S.createElement(`defs`,null,S.createElement(`clipPath`,{id:m},S.createElement(Tq,{alpha:n,points:d.points??[],baseLine:g,layout:f,strokeWidth:d.strokeWidth}))),S.createElement(Cz,{clipPath:`url(#${m})`},v,y,b)):S.createElement(S.Fragment,null,v,y,b)}var Dq=[`id`],Oq=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function kq(){return kq=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},kq.apply(null,arguments)}function Aq(e,t){if(e==null)return{};var n,r,i=jq(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function jq(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Mq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nq(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Mq(Object(n),!0).forEach(function(t){Pq(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Pq(e,t,n){return(t=Fq(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Fq(e){var t=Iq(e,`string`);return typeof t==`symbol`?t:t+``}function Iq(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Lq={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:mV,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[Nq(Nq({},e.next),{},{x:pp(e.prev.x,e.next.x,t),y:pp(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:Eq,xAxisId:0,yAxisId:0,zIndex:WE.area};function Rq(e,t){return e&&e!==`none`?e:t}var zq=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:Rq(r,i),value:ky(n,t),payload:e}]},Bq=S.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.tooltipType,u=e.id,d={dataDefinedOnItem:n,getPosition:vp,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:ky(o,t),hide:s,type:l,color:Rq(r,a),unit:c,graphicalItemId:u}};return S.createElement(aV,{tooltipEntrySettings:d})});function Vq(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=hd(r);return S.createElement(sK,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function Hq(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Nq(Nq({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return S.createElement(LH,{value:t?r:void 0},n)}function Uq(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,s=e.isAnimating,c=e.isEntrance,l=a.layout,u=a.type,d=a.stroke,f=a.connectNulls,p=a.isRange,m=a.shape,h=a.id,g=Aq(a,Dq),_=Nq(Nq({},_d(g)),{},{id:h,points:t,connectNulls:f,type:u,baseLine:n,layout:l,stroke:d,isRange:p,animationElapsedTime:o,isAnimating:s,isEntrance:c});return S.createElement(S.Fragment,null,t?.length>1&&S.createElement(Cz,{clipPath:r?`url(#clipPath-${i})`:void 0},S.createElement(tV,{option:m,DefaultShape:Lq.shape,shapeProps:_})),S.createElement(Vq,{points:t,props:g,clipPathId:i}))}function Wq(e,t,n){return X(e)?pp(X(t)?t:void 0,e,n):hp(e)||op(e)?pp(X(t)?t:void 0,0,n):e}function Gq(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,u=r.animationDuration,d=r.animationEasing,f=r.animationMatchBy,p=r.animationInterpolateFn,m=(0,S.useMemo)(()=>({points:o,baseLine:s}),[o,s]),h=SV(m,a),g=Gb(),_=kV(r.onAnimationStart,r.onAnimationEnd),v=_.isAnimating,y=_.handleAnimationStart,b=_.handleAnimationEnd,x=h.startValue;if(g==null)return null;var C=Array.isArray(s)&&Array.isArray(x)?xV(x,s,f):Array.isArray(s)?xV(null,s,f):null;return S.createElement(AV,{animationInput:m,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:y,onAnimationEnd:b,animationInterpolateFn:p,animationMatchBy:f,layout:g},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?p(C,i,g):a?s:Wq(s,x,i);return h.syncStepValue(c,i),S.createElement(Hq,{showLabels:!v,points:o},r.children,S.createElement(Uq,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:v||i<1,isEntrance:a}),S.createElement(UH,{label:r.label}))})}function Kq(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=(0,S.useRef)(null),a=(0,S.useRef)();return S.createElement(Gq,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var qq=class extends S.PureComponent{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.needClip,c=e.xAxisId,l=e.yAxisId,u=e.width,d=e.height,f=e.id,p=e.baseLine,m=e.zIndex;if(t)return null;var h=ld(`recharts-area`,i),g=f,_=NK(n),v=_.r,y=_.strokeWidth,b=WB(n),x=v*2+y,C=s?`url(#clipPath-${b?``:`dots-`}${g})`:void 0;return S.createElement(tR,{zIndex:m},S.createElement(Cz,{className:h},s&&S.createElement(`defs`,null,S.createElement(wK,{clipPathId:g,xAxisId:c,yAxisId:l}),!b&&S.createElement(`clipPath`,{id:`clipPath-dots-${g}`},S.createElement(`rect`,{x:o-x/2,y:a-x/2,width:u+x,height:d+x}))),S.createElement(Kq,{needClip:s,clipPathId:g,props:this.props})),S.createElement(mK,{points:r,mainColor:Rq(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}),this.props.isRange&&Array.isArray(p)&&S.createElement(mK,{points:p,mainColor:Rq(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}))}};function Jq(e){var t=e.activeDot,n=e.animationBegin,r=e.animationDuration,i=e.animationEasing,a=e.connectNulls,o=e.dot,s=e.fill,c=e.fillOpacity,l=e.hide,u=e.isAnimationActive,d=e.legendType,f=e.stroke,p=e.xAxisId,m=e.yAxisId,h=Aq(e,Oq),g=Wb(),_=xL(),v=CK(p,m).needClip,y=eb(),b=Z(t=>_q(t,e.id,y))??{},x=b.points,C=b.isRange,w=b.baseLine,T=YU();if(g!==`horizontal`&&g!==`vertical`||T==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var E=T.height,D=T.width,O=T.x,k=T.y;return!x||!x.length?null:S.createElement(qq,kq({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:w,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:E,hide:l,layout:g,isAnimationActive:u,isRange:C,legendType:d,needClip:v,points:x,stroke:f,width:D,left:O,top:k,xAxisId:p,yAxisId:m}))}var Yq=(e,t,n,r,i)=>{var a=n??t;if(X(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function Xq(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=a&&a.length,g=Yq(o,s,r,c,l),_=o===`horizontal`,v=!1,y=u.map((e,t)=>{var r;if(h)r=a[d+t];else{var o=uy(e,i);Array.isArray(o)?(r=o,v=!0):r=[g,o]}var s=r?.[1]??null,u=s==null||h&&!n&&uy(e,i)==null;return _?{x:yy({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:u?null:l.scale.map(s)??null,value:r,payload:e}:{x:u?null:c.scale.map(s)??null,y:yy({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:y,baseLine:(h||v?y.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return _?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):_?l.scale.map(g):c.scale.map(g))??0,isRange:v}}function Zq(e){var t=Up(e,Lq),n=eb();return S.createElement(BV,{id:t.id,type:`area`},e=>S.createElement(S.Fragment,null,S.createElement(oV,{legendPayload:zq(t)}),S.createElement(Bq,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),S.createElement(XV,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:vy(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),S.createElement(Jq,kq({},t,{id:e}))))}var Qq=S.memo(Zq,vS);Qq.displayName=`Area`;var $q=`Invariant failed`;function eJ(e,t){if(!e)throw Error($q)}var tJ=[`option`];function nJ(e,t){if(e==null)return{};var n,r,i=rJ(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function rJ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var iJ=yT;function aJ(e){var t=e.option,n=nJ(e,tJ);return S.createElement(tV,{option:t,DefaultShape:iJ,shapeProps:n,activeClassName:`recharts-active-bar`,inActiveClassName:`recharts-inactive-bar`})}var oJ=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(n,r)=>{if(X(e))return e;var i=X(n)||hp(n);return i?e(n,r):(!i&&eJ(!1,`minPointSize callback function received a value with type of ${typeof n}. Currently only numbers or null/undefined are supported.`),t)}};function sJ(e,t){return fJ(e)||dJ(e,t)||lJ(e,t)||cJ()}function cJ(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lJ(e,t){if(e){if(typeof e==`string`)return uJ(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uJ(e,t):void 0}}function uJ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function dJ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function fJ(e){if(Array.isArray(e))return e}var pJ=(e,t,n)=>{var r=n??e;if(!hp(r))return dp(r,t,0)},mJ=(e,t,n)=>{var r={},i=e.filter(hD),a=e.filter(e=>e.stackId==null),o=i.reduce((e,t)=>{var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},r),s=Object.entries(o).map(e=>{var r=sJ(e,2),i=r[0],a=r[1];return{stackId:i,dataKeys:a.map(e=>e.dataKey),barSize:pJ(t,n,a[0]?.barSize)}}),c=a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>e!=null),barSize:pJ(t,n,e.barSize)}));return[...s,...c]};function hJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function gJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?hJ(Object(n),!0).forEach(function(t){_J(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _J(e,t,n){return(t=vJ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vJ(e){var t=yJ(e,`string`);return typeof t==`symbol`?t:t+``}function yJ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function bJ(e,t,n,r,i){var a=r.length;if(!(a<1)){var o=dp(e,n,0,!0),s,c=[];if(ry(r[0]?.barSize)){var l=!1,u=n/a,d=r.reduce((e,t)=>e+(t.barSize||0),0);d+=(a-1)*o,d>=n&&(d-=(a-1)*o,o=0),d>=n&&u>0&&(l=!0,u*=.9,d=a*u);var f={offset:Math.round((n-d)/2)-o,size:0};s=r.reduce((e,t)=>{var n={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:f.offset+f.size+o,size:l?u:t.barSize??0}},r=[...e,n];return f=n.position,r},c)}else{var p=dp(t,n,0,!0);n-2*p-(a-1)*o<=0&&(o=0);var m=(n-2*p-(a-1)*o)/a;m>1&&(m=Math.round(m));var h=ry(i)?Math.min(m,i):m;s=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:p+(m+o)*n+(m-h)/2,size:h}}],c)}return s}}var xJ=(e,t,n,r,i,a,o)=>{var s=hp(o)?t:o,c=bJ(n,r,i===a?a:i,e,s);return i!==a&&c!=null&&(c=c.map(e=>gJ(gJ({},e),{},{position:gJ(gJ({},e.position),{},{offset:e.position.offset-i/2})}))),c},SJ=(e,t)=>{var n=pD(t);if(!(!e||n==null||t==null)){var r=t.stackId;if(r!=null){var i=e[r];if(i){var a=i.stackedData;if(a)return a.find(e=>e.key===n)}}}},CJ=(e,t)=>{if(!(e==null||t==null)){var n=e.find(e=>e.stackId===t.stackId&&t.dataKey!=null&&e.dataKeys.includes(t.dataKey));if(n!=null)return n.position}},wJ=(e,t,n)=>n,TJ=Q([LN,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`bar`).find(e=>e.id===t)),EJ=Q([TJ],e=>e?.maxBarSize),DJ=(e,t,n,r)=>r,OJ=Q([Ub,LN,sq,cq,wJ],(e,t,n,r,i)=>t.filter(t=>e===`horizontal`?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===i).filter(e=>e.hide===!1).filter(e=>e.type===`bar`)),kJ=(e,t,n)=>{var r=Ub(e),i=sq(e,t),a=cq(e,t);if(!(i==null||a==null))return r===`horizontal`?lP(e,`yAxis`,a,n):lP(e,`xAxis`,i,n)},AJ=Q([OJ,IE,(e,t)=>{var n=Ub(e),r=sq(e,t),i=cq(e,t);if(!(r==null||i==null))return n===`horizontal`?SF(e,`xAxis`,r):SF(e,`yAxis`,i)}],mJ),jJ=(e,t,n)=>{var r=TJ(e,t);if(r==null)return 0;var i=sq(e,t),a=cq(e,t);if(i==null||a==null)return 0;var o=Ub(e),s=NE(e),c=r.maxBarSize,l=hp(c)?s:c,u,d;return o===`horizontal`?(u=OF(e,`xAxis`,i,n),d=DF(e,`xAxis`,i,n)):(u=OF(e,`yAxis`,a,n),d=DF(e,`yAxis`,a,n)),Dy(u,d,!0)??l??0},MJ=(e,t,n)=>{var r=Ub(e),i=sq(e,t),a=cq(e,t);if(!(i==null||a==null)){var o,s;return r===`horizontal`?(o=OF(e,`xAxis`,i,n),s=DF(e,`xAxis`,i,n)):(o=OF(e,`yAxis`,a,n),s=DF(e,`yAxis`,a,n)),Dy(o,s)}},NJ=Q([Xy,Qy,(e,t,n)=>{var r=sq(e,t);if(r!=null)return OF(e,`xAxis`,r,n)},(e,t,n)=>{var r=cq(e,t);if(r!=null)return OF(e,`yAxis`,r,n)},(e,t,n)=>{var r=sq(e,t);if(r!=null)return DF(e,`xAxis`,r,n)},(e,t,n)=>{var r=cq(e,t);if(r!=null)return DF(e,`yAxis`,r,n)},Q([Q([AJ,NE,PE,FE,jJ,MJ,EJ],xJ),TJ],CJ),Ub,rE,MJ,Q([kJ,TJ],SJ),TJ,DJ],(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{var p=c.chartData,m=c.dataStartIndex,h=c.dataEndIndex;if(!(d==null||o==null||t==null||s!==`horizontal`&&s!==`vertical`||n==null||r==null||i==null||a==null||l==null)){var g=d.data,_=g!=null&&g.length>0?g:p?.slice(m,h+1);if(_!=null)return CY({layout:s,barSettings:d,pos:o,parentViewBox:t,bandSize:l,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:_,offset:e,cells:f,dataStartIndex:m})}});function PJ(e,t){return e&&typeof e==`object`&&`zIndex`in e&&typeof e.zIndex==`number`&&ry(e.zIndex)?e.zIndex:t}var FJ=[`index`];function IJ(){return IJ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},IJ.apply(null,arguments)}function LJ(e,t){if(e==null)return{};var n,r,i=RJ(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function RJ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var zJ=(0,S.createContext)(void 0),BJ=e=>{var t=(0,S.useContext)(zJ);if(t!=null)return t.stackId;if(e!=null)return vy(e)},VJ=(e,t)=>`recharts-bar-stack-clip-path-${e}-${t}`,HJ=e=>{var t=(0,S.useContext)(zJ);if(t!=null){var n=t.stackId;return`url(#${VJ(n,e)})`}},UJ=e=>{var t=e.index,n=LJ(e,FJ),r=HJ(t);return S.createElement(Cz,IJ({className:`recharts-bar-stack-layer`,clipPath:r},n))},WJ=[`onMouseEnter`,`onMouseLeave`,`onClick`],GJ=[`value`,`background`,`tooltipPosition`],KJ=[`id`],qJ=[`onMouseEnter`,`onClick`,`onMouseLeave`];function JJ(e,t){return $J(e)||QJ(e,t)||XJ(e,t)||YJ()}function YJ(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function XJ(e,t){if(e){if(typeof e==`string`)return ZJ(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ZJ(e,t):void 0}}function ZJ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function QJ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function $J(e){if(Array.isArray(e))return e}function eY(){return eY=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},eY.apply(null,arguments)}function tY(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nY(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?tY(Object(n),!0).forEach(function(t){rY(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tY(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rY(e,t,n){return(t=iY(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function iY(e){var t=aY(e,`string`);return typeof t==`symbol`?t:t+``}function aY(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function oY(e,t){if(e==null)return{};var n,r,i=sY(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function sY(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var cY=e=>{var t=e.dataKey,n=e.name,r=e.fill,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:ky(n,t),payload:e}]},lY=S.memo(e=>{var t=e.dataKey,n=e.stroke,r=e.strokeWidth,i=e.fill,a=e.name,o=e.hide,s=e.unit,c=e.tooltipType,l=e.id,u={dataDefinedOnItem:void 0,getPosition:vp,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:ky(a,t),hide:o,type:c,color:i,unit:s,graphicalItemId:l}};return S.createElement(aV,{tooltipEntrySettings:u})});function uY(e){var t=Z(ZI),n=e.data,r=e.dataKey,i=e.background,a=e.allOtherBarProps,o=a.onMouseEnter,s=a.onMouseLeave,c=a.onClick,l=oY(a,WJ),u=nV(o,r,a.id),d=rV(s),f=iV(c,r,a.id);if(!i||n==null)return null;var p=gd(i);return S.createElement(tR,{zIndex:PJ(i,WE.barBackground)},n.map((e,n)=>{e.value;var a=e.background;e.tooltipPosition;var o=oY(e,GJ);if(!a)return null;var s=u(e,e.originalDataIndex),c=d(e,e.originalDataIndex),m=f(e,e.originalDataIndex),h=nY(nY(nY(nY(nY({option:i,isActive:String(e.originalDataIndex)===t},o),{},{fill:`#eee`},a),p),Lp(l,e,n)),{},{onMouseEnter:s,onMouseLeave:c,onClick:m,dataKey:r,index:n,className:`recharts-bar-background-rectangle`});return S.createElement(aJ,eY({key:`background-bar-${n}`},h))}))}function dY(e){var t=e.showLabels,n=e.children,r=e.rects?.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return nY(nY({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return S.createElement(LH,{value:t?r:void 0},n)}function fY(e){var t=e.shape,n=e.activeBar,r=e.baseProps,i=e.entry,a=e.index,o=e.dataKey,s=Z(ZI),c=Z($I),l=n&&String(i.originalDataIndex)===s&&(c==null||o===c),u=JJ((0,S.useState)(!1),2),d=u[0],f=u[1],p=JJ((0,S.useState)(!1),2),m=p[0],h=p[1];(0,S.useEffect)(()=>{var e;return l?(f(!0),e=requestAnimationFrame(()=>{h(!0)})):h(!1),()=>{cancelAnimationFrame(e)}},[l]);var g=(0,S.useCallback)(()=>{l||f(!1)},[l]),_=l&&m,v=l||d,y=l?n===!0?t:n:t,b=S.createElement(aJ,eY({},r,{name:String(r.name)},i,{isActive:_,option:y,index:a,dataKey:o,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance,onTransitionEnd:g}));return v?S.createElement(tR,{zIndex:WE.activeBar},S.createElement(UJ,{index:i.originalDataIndex},b)):b}function pY(e){var t=e.shape,n=e.baseProps,r=e.entry,i=e.index,a=e.dataKey;return S.createElement(aJ,eY({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance}))}function mY(e){var t=e.data,n=e.props,r=e.animationElapsedTime,i=e.isAnimating,a=e.isEntrance,o=hd(n)??{},s=o.id,c=oY(o,KJ),l=n.shape,u=n.dataKey,d=n.activeBar,f=n.onMouseEnter,p=n.onClick,m=n.onMouseLeave,h=oY(n,qJ),g=nV(f,u,s),_=rV(m),v=iV(p,u,s);return t?S.createElement(S.Fragment,null,t.map((e,t)=>S.createElement(UJ,eY({index:e.originalDataIndex,key:`rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,className:`recharts-bar-rectangle`},Lp(h,e,t),{onMouseEnter:g(e,e.originalDataIndex),onMouseLeave:_(e,e.originalDataIndex),onClick:v(e,e.originalDataIndex)}),d?S.createElement(fY,{shape:l,activeBar:d,baseProps:c,entry:e,index:t,dataKey:u,animationElapsedTime:r,isAnimating:i,isEntrance:a}):S.createElement(pY,{shape:l,baseProps:c,entry:e,index:t,dataKey:u,animationElapsedTime:r,isAnimating:i,isEntrance:a})))):null}var hY=(e,t,n)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>{if(e.status===`removed`)return n===`horizontal`?[nY(nY({},e.prev),{},{height:pp(e.prev.height,0,t),y:pp(e.prev.y,e.prev.y+e.prev.height,t)})]:[nY(nY({},e.prev),{},{width:pp(e.prev.width,0,t)})];if(e.status===`matched`)return[nY(nY({},e.next),{},{x:pp(e.prev.x,e.next.x,t),y:pp(e.prev.y,e.next.y,t),width:pp(e.prev.width,e.next.width,t),height:pp(e.prev.height,e.next.height,t)})];var r=e.next;return n===`horizontal`?[nY(nY({},r),{},{height:pp(0,r.height,t),y:pp(r.stackedBarStart,r.y,t)})]:[nY(nY({},r),{},{width:pp(0,r.width,t),x:pp(r.stackedBarStart,r.x,t)})]});function gY(e){var t=e.props,n=e.previousRectanglesRef,r=t.data,i=t.isAnimationActive,a=t.animationBegin,o=t.animationDuration,s=t.animationEasing,c=t.animationInterpolateFn,l=t.layout,u=kV(t.onAnimationStart,t.onAnimationEnd),d=u.isAnimating,f=u.handleAnimationStart,p=u.handleAnimationEnd;return S.createElement(dY,{showLabels:!d,rects:r},S.createElement(AV,{animationInput:r,animationIdPrefix:`recharts-bar-`,items:r,previousItemsRef:n,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s,onAnimationStart:f,onAnimationEnd:p,animationInterpolateFn:c,animationMatchBy:t.animationMatchBy,layout:l},(e,n,r)=>S.createElement(Cz,null,S.createElement(mY,{props:t,data:e,animationElapsedTime:n,isAnimating:d||n<1,isEntrance:r}))),S.createElement(UH,{label:t.label}),t.children)}function _Y(e){var t=(0,S.useRef)(null);return S.createElement(gY,{previousRectanglesRef:t,props:e})}var vY=0,yY=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:uy(e,t)}},bY=class extends S.PureComponent{render(){var e=this.props,t=e.hide,n=e.data,r=e.dataKey,i=e.className,a=e.xAxisId,o=e.yAxisId,s=e.needClip,c=e.background,l=e.id;if(t||n==null)return null;var u=ld(`recharts-bar`,i),d=l;return S.createElement(Cz,{className:u,id:l},s&&S.createElement(`defs`,null,S.createElement(wK,{clipPathId:d,xAxisId:a,yAxisId:o})),S.createElement(Cz,{className:`recharts-bar-rectangles`,clipPath:s?`url(#clipPath-${d})`:void 0},S.createElement(uY,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),S.createElement(_Y,this.props)))}},xY={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:`ease`,animationInterpolateFn:hY,animationMatchBy:hV,background:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:vY,shape:iJ,xAxisId:0,yAxisId:0,zIndex:WE.bar};function SY(e){var t=e.xAxisId,n=e.yAxisId,r=e.hide,i=e.legendType,a=e.minPointSize,o=e.activeBar,s=e.animationBegin,c=e.animationDuration,l=e.animationEasing,u=e.isAnimationActive,d=CK(t,n).needClip,f=Wb(),p=eb(),m=UB(e.children,tz),h=Z(t=>NJ(t,e.id,p,m));if(f!==`vertical`&&f!==`horizontal`)return null;var g,_=h?.[0];return g=_==null||_.height==null||_.width==null?0:f===`vertical`?_.height/2:_.width/2,S.createElement(SK,{xAxisId:t,yAxisId:n,data:h,dataPointFormatter:yY,errorBarOffset:g},S.createElement(bY,eY({},e,{layout:f,needClip:d,data:h,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u})))}function CY(e){var t=e.layout,n=e.barSettings,r=n.dataKey,i=n.minPointSize,a=n.hasCustomShape,o=e.pos,s=e.bandSize,c=e.xAxis,l=e.yAxis,u=e.xAxisTicks,d=e.yAxisTicks,f=e.stackedData,p=e.displayedData,m=e.offset,h=e.cells,g=e.parentViewBox,_=e.dataStartIndex,v=t===`horizontal`?l:c,y=f?v.scale.domain():null,b=xy({numericAxis:v}),x=v.scale.map(b);return p.map((e,n)=>{var p,v,S,C,w,T;if(f){var E=f[n+_];if(E==null)return null;p=hy(E,y)}else p=uy(e,r),Array.isArray(p)||(p=[b,p]);var D=oJ(i,vY)(p[1],n);if(t===`horizontal`){var O=l.scale.map(p[0]),k=l.scale.map(p[1]);if(O==null||k==null)return null;v=by({axis:c,ticks:u,bandSize:s,offset:o.offset,entry:e,index:n}),S=k??O??void 0,C=o.size;var A=O-k;if(w=op(A)?0:A,T={x:v,y:m.top,width:C,height:m.height},Math.abs(D)>0&&Math.abs(w)<Math.abs(D)){var j=ap(w||D)*(Math.abs(D)-Math.abs(w));S-=j,w+=j}}else{var M=c.scale.map(p[0]),N=c.scale.map(p[1]);if(M==null||N==null)return null;if(v=M,S=by({axis:l,ticks:d,bandSize:s,offset:o.offset,entry:e,index:n}),C=N-M,w=o.size,T={x:m.left,y:S,width:m.width,height:w},Math.abs(D)>0&&Math.abs(C)<Math.abs(D)){var ee=ap(C||D)*(Math.abs(D)-Math.abs(C));C+=ee}}return v==null||S==null||C==null||w==null||!a&&(C===0||w===0)?null:nY(nY({},e),{},{stackedBarStart:x,x:v,y:S,width:C,height:w,value:f?p:p[1],payload:e,background:T,tooltipPosition:{x:v+C/2,y:S+w/2},parentViewBox:g,originalDataIndex:n},h&&h[n]&&h[n].props)}).filter(Boolean)}function wY(e){var t=Up(e,xY),n=BJ(t.stackId),r=eb();return S.createElement(BV,{id:t.id,type:`bar`},e=>S.createElement(S.Fragment,null,S.createElement(oV,{legendPayload:cY(t)}),S.createElement(lY,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),S.createElement(XV,{type:`bar`,id:e,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r,hasCustomShape:t.shape!=null&&t.shape!==iJ}),S.createElement(tR,{zIndex:t.zIndex},S.createElement(SY,eY({},t,{id:e})))))}var TY=S.memo(wY,vS);TY.displayName=`Bar`;var EY=[`domain`,`range`],DY=[`domain`,`range`];function OY(e,t){if(e==null)return{};var n,r,i=kY(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function kY(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function AY(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function jY(e,t){if(e===t)return!0;var n=e.domain,r=e.range,i=OY(e,EY),a=t.domain,o=t.range,s=OY(t,DY);return!AY(n,a)||!AY(r,o)?!1:vS(i,s)}var MY=[`type`],NY=[`dangerouslySetInnerHTML`,`ticks`,`scale`],PY=[`id`,`scale`];function FY(){return FY=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},FY.apply(null,arguments)}function IY(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function LY(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?IY(Object(n),!0).forEach(function(t){RY(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):IY(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function RY(e,t,n){return(t=zY(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function zY(e){var t=BY(e,`string`);return typeof t==`symbol`?t:t+``}function BY(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function VY(e,t){if(e==null)return{};var n,r,i=HY(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function HY(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function UY(e){var t=gh(),n=(0,S.useRef)(null),r=Gb(),i=e.type,a=VY(e,MY),o=JE(r,`xAxis`,i),s=(0,S.useMemo)(()=>{if(o!=null)return LY(LY({},a),{},{type:o})},[a,o]);return(0,S.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(BU(s)):n.current!==s&&t(VU({prev:n.current,next:s})),n.current=s)},[s,t]),(0,S.useLayoutEffect)(()=>()=>{n.current&&=(t(HU(n.current)),null)},[t]),null}var WY=e=>{var t=e.xAxisId,n=e.className,r=Z(Qy),i=eb(),a=`xAxis`,o=Z(e=>EF(e,a,t,i)),s=Z(e=>mF(e,t)),c=Z(e=>yF(e,t)),l=Z(e=>TN(e,t));if(s==null||c==null||l==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var u=VY(e,NY);l.id,l.scale;var d=VY(l,PY);return S.createElement(pG,FY({},u,d,{x:c.x,y:c.y,width:s.width,height:s.height,className:ld(`recharts-${a} ${a}`,n),viewBox:r,ticks:o,axisType:a,axisId:t}))},GY={allowDataOverflow:wN.allowDataOverflow,allowDecimals:wN.allowDecimals,allowDuplicatedCategory:wN.allowDuplicatedCategory,angle:wN.angle,axisLine:iG.axisLine,height:wN.height,hide:!1,includeHidden:wN.includeHidden,interval:wN.interval,label:!1,minTickGap:wN.minTickGap,mirror:wN.mirror,orientation:wN.orientation,padding:wN.padding,reversed:wN.reversed,scale:wN.scale,tick:wN.tick,tickCount:wN.tickCount,tickLine:iG.tickLine,tickSize:iG.tickSize,type:wN.type,niceTicks:wN.niceTicks,xAxisId:0},KY=S.memo(e=>{var t=Up(e,GY);return S.createElement(S.Fragment,null,S.createElement(UY,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),S.createElement(WY,t))},jY);KY.displayName=`XAxis`;var qY=[`type`],JY=[`dangerouslySetInnerHTML`,`ticks`,`scale`],YY=[`id`,`scale`];function XY(){return XY=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},XY.apply(null,arguments)}function ZY(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function QY(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ZY(Object(n),!0).forEach(function(t){$Y(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZY(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $Y(e,t,n){return(t=eX(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eX(e){var t=tX(e,`string`);return typeof t==`symbol`?t:t+``}function tX(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function nX(e,t){if(e==null)return{};var n,r,i=rX(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function rX(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function iX(e){var t=gh(),n=(0,S.useRef)(null),r=Gb(),i=e.type,a=nX(e,qY),o=JE(r,`yAxis`,i),s=(0,S.useMemo)(()=>{if(o!=null)return QY(QY({},a),{},{type:o})},[o,a]);return(0,S.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(UU(s)):n.current!==s&&t(WU({prev:n.current,next:s})),n.current=s)},[s,t]),(0,S.useLayoutEffect)(()=>()=>{n.current&&=(t(GU(n.current)),null)},[t]),null}function aX(e){var t=e.yAxisId,n=e.className,r=e.width,i=e.label,a=(0,S.useRef)(null),o=(0,S.useRef)(null),s=Z(Qy),c=eb(),l=gh(),u=`yAxis`,d=Z(e=>xF(e,t)),f=Z(e=>bF(e,t)),p=Z(e=>EF(e,u,t,c)),m=Z(e=>ON(e,t));if((0,S.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||bH(i)||(0,S.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(KU({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=nX(e,JY);m.id,m.scale;var g=nX(m,YY);return S.createElement(pG,XY({},h,g,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:ld(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u,axisId:t}))}var oX={allowDataOverflow:DN.allowDataOverflow,allowDecimals:DN.allowDecimals,allowDuplicatedCategory:DN.allowDuplicatedCategory,angle:DN.angle,axisLine:iG.axisLine,hide:!1,includeHidden:DN.includeHidden,interval:DN.interval,label:!1,minTickGap:DN.minTickGap,mirror:DN.mirror,orientation:DN.orientation,padding:DN.padding,reversed:DN.reversed,scale:DN.scale,tick:DN.tick,tickCount:DN.tickCount,tickLine:iG.tickLine,tickSize:iG.tickSize,type:DN.type,niceTicks:DN.niceTicks,width:DN.width,yAxisId:0},sX=S.memo(e=>{var t=Up(e,oX);return S.createElement(S.Fragment,null,S.createElement(iX,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),S.createElement(aX,t))},jY);sX.displayName=`YAxis`;var cX=Q([(e,t)=>t,Ub,uD,yD,WI,KI,TL,Xy],LL);function lX(e){return`getBBox`in e.currentTarget&&typeof e.currentTarget.getBBox==`function`}function uX(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(lX(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(e,i)=>({relativeX:Math.round((e-t.left)/n),relativeY:Math.round((i-t.top)/r)});return`touches`in e?Array.from(e.touches).map(e=>o(e.clientX,e.clientY)):o(e.clientX,e.clientY)}var dX=z_(`mouseClick`),fX=qv();fX.startListening({actionCreator:dX,effect:(e,t)=>{var n=e.payload,r=cX(t.getState(),uX(n));r?.activeIndex!=null&&t.dispatch(YF({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var pX=z_(`mouseMove`),mX=qv(),hX=null,gX=null,_X=null;mX.startListening({actionCreator:pX,effect:(e,t)=>{var n=e.payload,r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a?.includes(`mousemove`);hX!==null&&(cancelAnimationFrame(hX),hX=null),gX!==null&&(typeof i!=`number`||!o)&&(clearTimeout(gX),gX=null),_X=uX(n);var s=()=>{var e=t.getState(),n=NF(e,e.tooltip.settings.shared);if(!_X){hX=null,gX=null;return}if(n===`axis`){var r=cX(e,_X);r?.activeIndex==null?t.dispatch(KF()):t.dispatch(JF({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}hX=null,gX=null};if(!o){s();return}i===`raf`?hX=requestAnimationFrame(s):typeof i==`number`&&gX===null&&(gX=setTimeout(s,i))}});function vX(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<<CHILDREN>>`:t}var yX={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},bX=sv({name:`brush`,initialState:yX,reducers:{setBrushSettings(e,t){return t.payload==null?yX:t.payload}}});bX.actions.setBrushSettings;var xX=bX.reducer,SX={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},CX=sv({name:`rootProps`,initialState:SX,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??SX.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),wX=CX.reducer,TX=CX.actions.updateOptions,EX=sv({name:`polarAxis`,initialState:{radiusAxis:{},angleAxis:{}},reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=Gx(t.payload)},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=Gx(t.payload)},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),DX=EX.actions;DX.addRadiusAxis,DX.removeRadiusAxis,DX.addAngleAxis,DX.removeAngleAxis;var OX=EX.reducer,kX=sv({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)}}),AX=kX.actions.updatePolarOptions,jX=kX.reducer,MX=z_(`keyDown`),NX=z_(`focus`),PX=z_(`blur`),FX=qv(),IX=null,LX=null,RX=null;FX.startListening({actionCreator:MX,effect:(e,t)=>{RX=e.payload,IX!==null&&(cancelAnimationFrame(IX),IX=null);var n=t.getState().eventSettings,r=n.throttleDelay,i=n.throttledEvents,a=i===`all`||i.includes(`keydown`);LX!==null&&(typeof r!=`number`||!a)&&(clearTimeout(LX),LX=null);var o=()=>{try{var e=t.getState();if(e.rootProps.accessibilityLayer===!1)return;var n=e.tooltip.keyboardInteraction,r=RX;if(r!==`ArrowRight`&&r!==`ArrowLeft`&&r!==`Enter`)return;var i=uI(n,MI(e),oP(e),VI(e)),a=i==null?-1:Number(i),o=!Number.isFinite(a)||a<0,s=KI(e),c=MI(e),l=NF(e,e.tooltip.settings.shared);if(r===`Enter`){if(o)return;var u=AL(e,l,`hover`,String(n.index));t.dispatch(ZF({active:!n.active,activeIndex:n.index,activeCoordinate:u}));return}var d=kF(e)===`left-to-right`?1:-1,f=r===`ArrowRight`?1:-1,p;if(o){var m=oP(e),h=VI(e),g=f*d,_=e=>({active:!1,index:String(e),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(p=-1,g>0){for(var v=0;v<c.length;v++)if(uI(_(v),c,m,h)!=null){p=v;break}}else for(var y=c.length-1;y>=0;y--)if(uI(_(y),c,m,h)!=null){p=y;break}if(p<0)return}else{p=a+f*d;var b=s?.length||c.length;if(b===0||p>=b||p<0)return}var x=AL(e,l,`hover`,String(p));t.dispatch(ZF({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}finally{IX=null,LX=null}};if(!a){o();return}r===`raf`?IX=requestAnimationFrame(o):typeof r==`number`&&LX===null&&(o(),RX=null,LX=setTimeout(()=>{RX?o():(LX=null,IX=null)},r))}}),FX.startListening({actionCreator:NX,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;if(!r.active&&r.index==null){var i=`0`,a=AL(n,NF(n,n.tooltip.settings.shared),`hover`,String(i));t.dispatch(ZF({active:!0,activeIndex:i,activeCoordinate:a}))}}}}),FX.startListening({actionCreator:PX,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;r.active&&t.dispatch(ZF({active:!1,activeIndex:r.index,activeCoordinate:r.coordinate}))}}});function zX(e){e.persist();var t=e.currentTarget;return new Proxy(e,{get:(e,n)=>{if(n===`currentTarget`)return t;var r=Reflect.get(e,n);return typeof r==`function`?r.bind(e):r}})}var BX=z_(`externalEvent`),VX=qv(),HX=new Map,UX=new Map,WX=new Map;VX.startListening({actionCreator:BX,effect:(e,t)=>{var n=e.payload,r=n.handler,i=n.reactEvent;if(r!=null){var a=i.type,o=zX(i);WX.set(a,{handler:r,reactEvent:o});var s=HX.get(a);s!==void 0&&(cancelAnimationFrame(s),HX.delete(a));var c=t.getState().eventSettings,l=c.throttleDelay,u=c.throttledEvents,d=u===`all`||u?.includes(a),f=UX.get(a);f!==void 0&&(typeof l!=`number`||!d)&&(clearTimeout(f),UX.delete(a));var p=()=>{var e=WX.get(a);try{if(!e)return;var n=e.handler,r=e.reactEvent,i=t.getState(),o={activeCoordinate:nL(i),activeDataKey:$I(i),activeIndex:ZI(i),activeLabel:QI(i),activeTooltipIndex:ZI(i),isTooltipActive:rL(i)};n&&n(o,r)}finally{HX.delete(a),UX.delete(a),WX.delete(a)}};if(!d){p();return}if(l===`raf`){var m=requestAnimationFrame(p);HX.set(a,m)}else if(typeof l==`number`){if(!UX.has(a)){p();var h=setTimeout(p,l);UX.set(a,h)}}else p()}}});var GX=Q([Q([mI],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var i=r.getPosition;if(i!=null)return i(t)}}}),KX=z_(`touchMove`),qX=qv(),JX=null,YX=null,XX=null,ZX=null;qX.startListening({actionCreator:KX,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){ZX=zX(n);var r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a.includes(`touchmove`);JX!==null&&(cancelAnimationFrame(JX),JX=null),YX!==null&&(typeof i!=`number`||!o)&&(clearTimeout(YX),YX=null),XX=Array.from(n.touches).map(e=>uX({clientX:e.clientX,clientY:e.clientY,currentTarget:n.currentTarget}));var s=()=>{if(ZX!=null){var e=t.getState(),n=NF(e,e.tooltip.settings.shared);if(n===`axis`){var r=XX?.[0];if(r==null){JX=null,YX=null;return}var i=cX(e,r);i?.activeIndex!=null&&t.dispatch(JF({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(n===`item`){var a=ZX.touches[0];if(document.elementFromPoint==null||a==null)return;var o=document.elementFromPoint(a.clientX,a.clientY);if(!o||!o.getAttribute)return;var s=o.getAttribute(Ry),c=o.getAttribute(`data-recharts-item-id`)??void 0,l=OI(e).find(e=>e.id===c);if(s==null||l==null||c==null)return;var u=l.dataKey,d=GX(e,s,c);t.dispatch(WF({activeDataKey:u,activeIndex:s,activeCoordinate:d,activeGraphicalItemId:c}))}JX=null,YX=null}};if(!o){s();return}i===`raf`?JX=requestAnimationFrame(s):typeof i==`number`&&YX===null&&(s(),ZX=null,YX=setTimeout(()=>{ZX?s():(YX=null,JX=null)},i))}}});var QX={throttleDelay:`raf`,throttledEvents:[`mousemove`,`touchmove`,`pointermove`,`scroll`,`wheel`]},$X=sv({name:`eventSettings`,initialState:QX,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=Gx(t.payload.throttledEvents))}}}),eZ=$X.actions.setEventSettings,tZ=$X.reducer,nZ=ug({brush:xX,cartesianAxis:qU,chartData:ER,errorBars:_K,eventSettings:tZ,graphicalItems:YV,layout:ty,legend:$x,options:yR,polarAxis:OX,polarOptions:jX,referenceElements:MU,renderedTicks:HW,rootProps:wX,tooltip:QF,zIndex:eR}),rZ=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return Z_({reducer:nZ,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([fX.middleware,mX.middleware,FX.middleware,VX.middleware,qX.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(Y_({type:`raf`}))},devTools:fC.devToolsEnabled&&{serialize:{replacer:vX},name:`recharts-${t}`}})};function iZ(e){var t=e.preloadedState,n=e.children,r=e.reduxStoreName,i=eb(),a=(0,S.useRef)(null);if(i)return n;a.current??=rZ(t,r);var o=ph;return S.createElement(hS,{context:o,store:a.current},n)}var aZ=e=>{var t=e.chartData,n=gh(),r=eb();return(0,S.useEffect)(()=>r?()=>{}:(n(wR(t)),()=>{n(wR(void 0))}),[t,n,r]),null};function oZ(e){var t=e.layout,n=e.margin,r=gh(),i=eb();return(0,S.useEffect)(()=>{i||(r(Qv(t)),r(Zv(n)))},[r,i,t,n]),null}var sZ=(0,S.memo)(oZ,vS);function cZ(e){var t=gh();return(0,S.useEffect)(()=>{t(TX(e))},[t,e]),null}var lZ=(0,S.memo)(e=>{var t=gh();return(0,S.useEffect)(()=>{t(eZ(e))},[t,e]),null},vS);function uZ(e){var t=e.zIndex,n=e.isPanorama,r=(0,S.useRef)(null),i=gh();return(0,S.useLayoutEffect)(()=>(r.current&&i(QL({zIndex:t,element:r.current,isPanorama:n})),()=>{i($L({zIndex:t,isPanorama:n}))}),[i,t,n]),S.createElement(`g`,{tabIndex:-1,ref:r,className:`recharts-zIndex-layer_${t}`})}function dZ(e){var t=e.children,n=e.isPanorama,r=Z(zL);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return S.createElement(S.Fragment,null,i.map(e=>S.createElement(uZ,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>S.createElement(uZ,{key:e,zIndex:e,isPanorama:n})))}var fZ=[`children`];function pZ(e,t){if(e==null)return{};var n,r,i=mZ(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function mZ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function hZ(){return hZ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},hZ.apply(null,arguments)}var gZ={width:`100%`,height:`100%`,display:`block`},_Z=(0,S.forwardRef)((e,t)=>{var n=Bb(),r=Vb(),i=PC();if(!iy(n)||!iy(r))return null;var a=e.children,o=e.otherAttributes,s=e.title,c=e.desc,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),S.createElement(Cd,hZ({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:gZ,ref:t}),a)}),vZ=e=>{var t=e.children,n=Z(nb);if(!n)return null;var r=n.width,i=n.height,a=n.y,o=n.x;return S.createElement(Cd,{width:r,height:i,x:o,y:a},t)},yZ=(0,S.forwardRef)((e,t)=>{var n=e.children,r=pZ(e,fZ);return eb()?S.createElement(vZ,null,S.createElement(dZ,{isPanorama:!0},n)):S.createElement(_Z,hZ({ref:t},r),S.createElement(dZ,{isPanorama:!1},n))});function bZ(e,t){return TZ(e)||wZ(e,t)||SZ(e,t)||xZ()}function xZ(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function SZ(e,t){if(e){if(typeof e==`string`)return CZ(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?CZ(e,t):void 0}}function CZ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function wZ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function TZ(e){if(Array.isArray(e))return e}function EZ(){var e=gh(),t=bZ((0,S.useState)(null),2),n=t[0],r=t[1],i=Z(Py);return(0,S.useEffect)(()=>{if(n!=null){var t=n.getBoundingClientRect().width/n.offsetWidth;ry(t)&&t!==i&&e(ey(t))}},[n,e,i]),r}function DZ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function OZ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?DZ(Object(n),!0).forEach(function(t){kZ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):DZ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kZ(e,t,n){return(t=AZ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function AZ(e){var t=jZ(e,`string`);return typeof t==`symbol`?t:t+``}function jZ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function MZ(){return MZ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},MZ.apply(null,arguments)}function NZ(e,t){return RZ(e)||LZ(e,t)||FZ(e,t)||PZ()}function PZ(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function FZ(e,t){if(e){if(typeof e==`string`)return IZ(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?IZ(e,t):void 0}}function IZ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function LZ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function RZ(e){if(Array.isArray(e))return e}var zZ=()=>(LR(),null);function BZ(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var VZ=(0,S.forwardRef)((e,t)=>{var n=(0,S.useRef)(null),r=NZ((0,S.useState)({containerWidth:BZ(e.style?.width),containerHeight:BZ(e.style?.height)}),2),i=r[0],a=r[1],o=(0,S.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,S.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,S.useEffect)(()=>()=>{n.current?.disconnect()},[o]),S.createElement(S.Fragment,null,S.createElement(Yb,{width:i.containerWidth,height:i.containerHeight}),S.createElement(`div`,MZ({ref:s},e)))}),HZ=(0,S.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=NZ((0,S.useState)({containerWidth:BZ(n),containerHeight:BZ(r)}),2),a=i[0],o=i[1],s=(0,S.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,S.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return S.createElement(S.Fragment,null,S.createElement(Yb,{width:a.containerWidth,height:a.containerHeight}),S.createElement(`div`,MZ({ref:c},e)))}),UZ=(0,S.forwardRef)((e,t)=>{var n=e.width,r=e.height;return S.createElement(S.Fragment,null,S.createElement(Yb,{width:n,height:r}),S.createElement(`div`,MZ({ref:t},e)))}),WZ=(0,S.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?S.createElement(HZ,MZ({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?S.createElement(UZ,MZ({},e,{width:n,height:r,ref:t})):S.createElement(S.Fragment,null,S.createElement(Yb,{width:n,height:r}),S.createElement(`div`,MZ({ref:t},e)))});function GZ(e){return e?VZ:WZ}var KZ=(0,S.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,v=e.responsive,y=e.dispatchTouchEvents,b=y===void 0?!0:y,x=(0,S.useRef)(null),C=gh(),w=NZ((0,S.useState)(null),2),T=w[0],E=w[1],D=NZ((0,S.useState)(null),2),O=D[0],k=D[1],A=EZ(),j=Nb(),M=j?.width>0?j.width:_,N=j?.height>0?j.height:i,ee=(0,S.useCallback)(e=>{A(e),typeof t==`function`&&t(e),E(e),k(e),e!=null&&(x.current=e)},[A,t,E,k]),te=(0,S.useCallback)(e=>{C(dX(e)),C(BX({handler:a,reactEvent:e}))},[C,a]),P=(0,S.useCallback)(e=>{C(pX(e)),C(BX({handler:l,reactEvent:e}))},[C,l]),F=(0,S.useCallback)(e=>{C(KF()),C(BX({handler:u,reactEvent:e}))},[C,u]),ne=(0,S.useCallback)(e=>{C(pX(e)),C(BX({handler:d,reactEvent:e}))},[C,d]),re=(0,S.useCallback)(()=>{C(NX())},[C]),ie=(0,S.useCallback)(()=>{C(PX())},[C]),ae=(0,S.useCallback)(e=>{C(MX(e.key))},[C]),oe=(0,S.useCallback)(e=>{C(BX({handler:o,reactEvent:e}))},[C,o]),se=(0,S.useCallback)(e=>{C(BX({handler:s,reactEvent:e}))},[C,s]),ce=(0,S.useCallback)(e=>{C(BX({handler:c,reactEvent:e}))},[C,c]),le=(0,S.useCallback)(e=>{C(BX({handler:f,reactEvent:e}))},[C,f]),ue=(0,S.useCallback)(e=>{C(BX({handler:h,reactEvent:e}))},[C,h]),de=(0,S.useCallback)(e=>{b&&C(KX(e)),C(BX({handler:m,reactEvent:e}))},[C,b,m]),fe=(0,S.useCallback)(e=>{C(BX({handler:p,reactEvent:e}))},[C,p]),pe=GZ(v);return S.createElement(dR.Provider,{value:T},S.createElement(od.Provider,{value:O},S.createElement(pe,{width:M??g?.width,height:N??g?.height,className:ld(`recharts-wrapper`,r),style:OZ({position:`relative`,cursor:`default`,width:M,height:N},g),onClick:te,onContextMenu:oe,onDoubleClick:se,onFocus:re,onBlur:ie,onKeyDown:ae,onMouseDown:ce,onMouseEnter:P,onMouseLeave:F,onMouseMove:ne,onMouseUp:le,onTouchEnd:fe,onTouchMove:de,onTouchStart:ue,ref:ee},S.createElement(zZ,null),n)))}),qZ=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function JZ(e,t){if(e==null)return{};var n,r,i=YZ(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function YZ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var XZ=(0,S.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=hd(JZ(e,qZ));return c?S.createElement(S.Fragment,null,S.createElement(Yb,{width:n,height:r}),S.createElement(yZ,{otherAttributes:d,title:l,desc:u},a)):S.createElement(KZ,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},S.createElement(yZ,{otherAttributes:d,title:l,desc:u,ref:t},S.createElement(iW,null,a)))});function ZZ(){return ZZ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ZZ.apply(null,arguments)}function QZ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?QZ(Object(n),!0).forEach(function(t){eQ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QZ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eQ(e,t,n){return(t=tQ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tQ(e){var t=nQ(e,`string`);return typeof t==`symbol`?t:t+``}function nQ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var rQ=$Z({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},QX),iQ=(0,S.forwardRef)(function(e,t){var n=Up(e.categoricalChartProps,rQ),r=e.chartName,i=e.defaultTooltipEventType,a=e.validateTooltipEventTypes,o=e.tooltipPayloadSearcher,s=e.categoricalChartProps,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return S.createElement(iZ,{preloadedState:{options:c},reduxStoreName:s.id??r},S.createElement(aZ,{chartData:s.data}),S.createElement(sZ,{layout:n.layout,margin:n.margin}),S.createElement(lZ,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),S.createElement(cZ,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),S.createElement(XZ,ZZ({},n,{ref:t})))}),aQ=[`axis`],oQ=(0,S.forwardRef)((e,t)=>S.createElement(iQ,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:aQ,tooltipPayloadSearcher:_R,categoricalChartProps:e,ref:t})),sQ=[`axis`,`item`],cQ=(0,S.forwardRef)((e,t)=>S.createElement(iQ,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:sQ,tooltipPayloadSearcher:_R,categoricalChartProps:e,ref:t}));function lQ(e){var t=gh();return(0,S.useEffect)(()=>{t(AX(e))},[t,e]),null}var uQ=[`layout`];function dQ(){return dQ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},dQ.apply(null,arguments)}function fQ(e,t){if(e==null)return{};var n,r,i=pQ(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function pQ(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function mQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function hQ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?mQ(Object(n),!0).forEach(function(t){gQ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mQ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gQ(e,t,n){return(t=_Q(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _Q(e){var t=vQ(e,`string`);return typeof t==`symbol`?t:t+``}function vQ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var yQ=hQ({accessibilityLayer:!0,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`,layout:`radial`,responsive:!1,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`},QX),bQ=(0,S.forwardRef)(function(e,t){var n=Up(e.categoricalChartProps,yQ),r=n.layout,i=fQ(n,uQ),a=e.chartName,o={chartName:a,defaultTooltipEventType:e.defaultTooltipEventType,validateTooltipEventTypes:e.validateTooltipEventTypes,tooltipPayloadSearcher:e.tooltipPayloadSearcher,eventEmitter:void 0};return S.createElement(iZ,{preloadedState:{options:o},reduxStoreName:n.id??a},S.createElement(aZ,{chartData:n.data}),S.createElement(sZ,{layout:r,margin:n.margin}),S.createElement(lZ,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),S.createElement(cZ,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),S.createElement(lQ,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),S.createElement(XZ,dQ({},i,{ref:t})))});function xQ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function SQ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?xQ(Object(n),!0).forEach(function(t){CQ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xQ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function CQ(e,t,n){return(t=wQ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wQ(e){var t=TQ(e,`string`);return typeof t==`symbol`?t:t+``}function TQ(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var EQ=[`item`],DQ=SQ(SQ({},yQ),{},{layout:`centric`,startAngle:0,endAngle:360}),OQ=(0,S.forwardRef)((e,t)=>{var n=Up(e,DQ);return S.createElement(bQ,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:EQ,tooltipPayloadSearcher:_R,categoricalChartProps:n,ref:t})}),kQ=[`axis`],AQ=(0,S.forwardRef)((e,t)=>S.createElement(iQ,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:kQ,tooltipPayloadSearcher:_R,categoricalChartProps:e,ref:t})),jQ={bg:`#0a0f1a`,cardBg:`rgba(255,255,255,0.04)`,green:`#22c55e`,blue:`#3b82f6`,amber:`#f59e0b`},MQ={"home-services":{slug:`home-services`,name:`Home Services`,tagline:`HVAC · Plumbing · Electrical · Landscaping`,headline:`Run every truck like a profit center`,subhead:`Home service companies live and die by booked-call rate, average ticket, and technician utilization. Command Center pulls your CRM, ads, and books into one forecast so you know this week — not next quarter — whether you will hit your number.`,metrics:[{label:`Booked-call rate`,value:`+18%`,sub:`avg. lift after cascading goals rollout`,icon:yu},{label:`Average ticket`,value:`+$212`,sub:`from real-time upsell coaching signals`,icon:dl},{label:`Tech utilization`,value:`87%`,sub:`vs. 71% industry median`,icon:yl},{label:`Forecast accuracy`,value:`±4%`,sub:`weekly revenue landing forecast`,icon:wu}],useCases:[{title:`Dispatch-to-revenue visibility`,desc:`See how today’s call board translates into this month’s landing number, by trade and by tech.`},{title:`Seasonal demand forecasting`,desc:`Model shoulder-season dips before they hit cash flow and shift ad spend into the right zip codes early.`},{title:`Membership program tracking`,desc:`Track maintenance agreement attach rate as a cascading goal for every CSR and technician.`}],chartLabel:`Monthly revenue vs. baseline ($K)`,chart:[{month:`Jan`,baseline:310,withCC:310},{month:`Feb`,baseline:295,withCC:318},{month:`Mar`,baseline:330,withCC:365},{month:`Apr`,baseline:355,withCC:410},{month:`May`,baseline:372,withCC:448},{month:`Jun`,baseline:390,withCC:486}],checklist:[`Connect ServiceTitan, Housecall Pro, or your CRM in minutes`,`Booked-call rate and average ticket as live KPIs`,`Per-technician scorecards tied to the company forecast`,`Ad spend recommendations by service line and zip`]},roofing:{slug:`roofing`,name:`Roofing`,tagline:`Residential · Commercial · Storm restoration`,headline:`From lead to shingle, know your landing number`,subhead:`Roofing margins swing with material costs, crew availability, and storm cycles. Command Center forecasts your close rate, backlog burn-down, and gross margin per square — so you can commit to jobs you can actually staff and price.`,metrics:[{label:`Close rate`,value:`+9pts`,sub:`with rep-level cascading targets`,icon:yu},{label:`Gross margin / square`,value:`+6.4%`,sub:`from material cost drift alerts`,icon:dl},{label:`Backlog visibility`,value:`10 wks`,sub:`forward crew-loading forecast`,icon:mc},{label:`Storm-surge response`,value:`48 hrs`,sub:`to re-forecast after weather events`,icon:Ru}],useCases:[{title:`Storm-cycle revenue modeling`,desc:`Re-forecast pipeline within hours of a hail event and rank markets by expected insurance claim volume.`},{title:`Material cost drift alerts`,desc:`Catch shingle and underlayment price creep before it eats the margin you quoted three weeks ago.`},{title:`Crew capacity planning`,desc:`See backlog burn-down against crew availability so sales never commits to a date production can’t hit.`}],chartLabel:`Quarterly gross margin trend (%)`,chart:[{month:`Q1 ’24`,baseline:24,withCC:24},{month:`Q2 ’24`,baseline:23,withCC:26},{month:`Q3 ’24`,baseline:25,withCC:29},{month:`Q4 ’24`,baseline:24,withCC:30},{month:`Q1 ’25`,baseline:23,withCC:31},{month:`Q2 ’25`,baseline:24,withCC:32}],checklist:[`Insurance vs. retail job mix tracked separately`,`Margin-per-square as a first-class KPI`,`Supplier price drift monitoring`,`Crew-loading forecast tied to sales pipeline`]},remodeling:{slug:`remodeling`,name:`Remodeling`,tagline:`Kitchen & bath · Whole-home · Design-build`,headline:`Long projects, short feedback loops`,subhead:`Remodelers get surprised at the end of 12-week projects. Command Center tracks slippage, change-order capture, and design-to-build conversion continuously — so a project that’s drifting off budget shows up in week 2, not week 11.`,metrics:[{label:`Change-order capture`,value:`+31%`,sub:`billable scope changes actually invoiced`,icon:dl},{label:`Slippage detection`,value:`Wk 2`,sub:`vs. end-of-project surprises`,icon:yl},{label:`Design→build conversion`,value:`+12pts`,sub:`with pipeline-stage forecasting`,icon:yu},{label:`Referral pipeline`,value:`38%`,sub:`of new revenue tracked to past clients`,icon:Pu}],useCases:[{title:`Project margin tracking`,desc:`Live budget-vs-actual per project, rolled up to a company landing number your bookkeeper doesn’t have to rebuild.`},{title:`Change-order discipline`,desc:`Every scope change gets a dollar value and a status — no more free work discovered at final invoice.`},{title:`Design-phase pipeline`,desc:`Forecast build revenue from design contracts signed today, 4–6 months ahead of the crews.`}],chartLabel:`Project margin: quoted vs. delivered (%)`,chart:[{month:`Jan`,baseline:18,withCC:18},{month:`Feb`,baseline:16,withCC:19},{month:`Mar`,baseline:17,withCC:21},{month:`Apr`,baseline:15,withCC:22},{month:`May`,baseline:17,withCC:24},{month:`Jun`,baseline:16,withCC:25}],checklist:[`Budget-vs-actual per project, updated continuously`,`Change-order pipeline with capture-rate KPI`,`Design-to-build conversion forecasting`,`Client referral revenue attribution`]}};function NQ(){let{slug:e}=mt(),t=e?MQ[e]:void 0;return t?(0,L.jsxs)(`div`,{className:`min-h-screen text-white`,style:{background:jQ.bg},children:[(0,L.jsx)(`header`,{className:`z-50 pt-3 px-4`,children:(0,L.jsxs)(`nav`,{className:`max-w-6xl mx-auto rounded-full border border-white/10 backdrop-blur-xl pl-5 pr-2.5 h-14 flex items-center justify-between shadow-xl shadow-black/30`,style:{background:`rgba(10,16,28,0.7)`},children:[(0,L.jsxs)(Mn,{to:`/`,className:`flex items-center gap-2.5`,children:[(0,L.jsx)(`div`,{className:`w-7 h-7 rounded-lg flex items-center justify-center font-black text-[11px]`,style:{background:jQ.green},children:`CC`}),(0,L.jsx)(`span`,{className:`font-bold text-sm tracking-tight`,children:`Command Center`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Mn,{to:`/auth/login`,className:`text-sm text-white/70 hover:text-white transition-colors px-3 py-2 min-h-[44px] flex items-center`,children:`Log in`}),(0,L.jsx)(Mn,{to:`/auth/signup`,className:`px-5 py-2.5 rounded-full text-sm font-semibold transition-all hover:opacity-90 min-h-[44px] flex items-center`,style:{background:jQ.green},children:`Start free trial`})]})]})}),(0,L.jsx)(`section`,{className:`pt-16 pb-12 px-6`,children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsxs)(Mn,{to:`/`,className:`inline-flex items-center gap-1 text-sm text-white/50 hover:text-white transition-colors mb-6`,children:[(0,L.jsx)(Fc,{size:14}),` Back to home`]}),(0,L.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wider mb-3`,style:{color:jQ.blue},children:t.tagline}),(0,L.jsx)(`h1`,{className:`text-4xl md:text-5xl font-black mb-4 max-w-3xl`,children:t.headline}),(0,L.jsx)(`p`,{className:`text-lg text-white/60 leading-relaxed max-w-3xl mb-8`,children:t.subhead}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,L.jsxs)(Mn,{to:`/auth/signup`,className:`px-6 py-3 rounded-full text-sm font-semibold flex items-center gap-2 transition-all hover:opacity-90`,style:{background:jQ.green},children:[`Start free trial `,(0,L.jsx)(Lc,{size:16})]}),(0,L.jsx)(Mn,{to:`/#demo`,className:`px-6 py-3 rounded-full text-sm font-semibold border border-white/20 hover:border-white/40 transition-colors`,children:`Book a demo`})]})]})}),(0,L.jsx)(`section`,{className:`py-12 px-6`,style:{background:`rgba(255,255,255,0.02)`},children:(0,L.jsx)(`div`,{className:`max-w-6xl mx-auto grid grid-cols-2 md:grid-cols-4 gap-4`,children:t.metrics.map(e=>{let t=e.icon;return(0,L.jsxs)(`div`,{className:`p-5 rounded-2xl border border-white/10`,style:{background:jQ.cardBg},children:[(0,L.jsx)(t,{size:18,style:{color:jQ.green},className:`mb-3`}),(0,L.jsx)(`div`,{className:`text-2xl font-black`,children:e.value}),(0,L.jsx)(`div`,{className:`text-sm font-semibold text-white/80 mt-1`,children:e.label}),(0,L.jsx)(`div`,{className:`text-xs text-white/50 mt-1`,children:e.sub})]},e.label)})})}),(0,L.jsx)(`section`,{className:`py-16 px-6`,children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto grid md:grid-cols-2 gap-10 items-center`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h2`,{className:`text-2xl md:text-3xl font-black mb-3`,children:[`What `,t.name.toLowerCase(),` operators see`]}),(0,L.jsxs)(`p`,{className:`text-white/60 mb-6`,children:[`Illustrative example of the operating picture Command Center builds for `,t.name.toLowerCase(),` companies.`]}),(0,L.jsx)(`ul`,{className:`space-y-3`,children:t.checklist.map(e=>(0,L.jsxs)(`li`,{className:`flex items-start gap-3 text-sm text-white/80`,children:[(0,L.jsx)(Xc,{size:16,style:{color:jQ.green},className:`mt-0.5 shrink-0`}),e]},e))})]}),(0,L.jsxs)(`div`,{className:`p-5 rounded-2xl border border-white/10`,style:{background:jQ.cardBg},children:[(0,L.jsx)(`div`,{className:`text-sm font-semibold text-white/70 mb-4`,children:t.chartLabel}),(0,L.jsx)(`div`,{className:`h-64`,children:(0,L.jsx)(Fb,{width:`100%`,height:`100%`,children:(0,L.jsxs)(AQ,{data:t.chart,margin:{top:5,right:5,bottom:0,left:-20},children:[(0,L.jsx)(`defs`,{children:(0,L.jsxs)(`linearGradient`,{id:`ccGreen`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,L.jsx)(`stop`,{offset:`0%`,stopColor:jQ.green,stopOpacity:.35}),(0,L.jsx)(`stop`,{offset:`100%`,stopColor:jQ.green,stopOpacity:0})]})}),(0,L.jsx)(FG,{stroke:`rgba(255,255,255,0.06)`,vertical:!1}),(0,L.jsx)(KY,{dataKey:`month`,tick:{fill:`rgba(255,255,255,0.5)`,fontSize:12},axisLine:!1,tickLine:!1}),(0,L.jsx)(sX,{tick:{fill:`rgba(255,255,255,0.5)`,fontSize:12},axisLine:!1,tickLine:!1}),(0,L.jsx)(ez,{contentStyle:{background:`#111827`,border:`1px solid rgba(255,255,255,0.1)`,borderRadius:8},labelStyle:{color:`#fff`}}),(0,L.jsx)(Qq,{type:`monotone`,dataKey:`baseline`,name:`Baseline`,stroke:`rgba(255,255,255,0.35)`,fill:`transparent`,strokeDasharray:`4 4`}),(0,L.jsx)(Qq,{type:`monotone`,dataKey:`withCC`,name:`With Command Center`,stroke:jQ.green,fill:`url(#ccGreen)`,strokeWidth:2})]})})})]})]})}),(0,L.jsx)(`section`,{className:`py-12 px-6`,style:{background:`rgba(255,255,255,0.02)`},children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsxs)(`h2`,{className:`text-2xl md:text-3xl font-black mb-8 text-center`,children:[`How `,t.name.toLowerCase(),` teams use Command Center`]}),(0,L.jsx)(`div`,{className:`grid md:grid-cols-3 gap-6`,children:t.useCases.map(e=>(0,L.jsxs)(`div`,{className:`p-6 rounded-2xl border border-white/10`,style:{background:jQ.cardBg},children:[(0,L.jsx)(`h3`,{className:`font-bold text-lg mb-2`,children:e.title}),(0,L.jsx)(`p`,{className:`text-sm text-white/60 leading-relaxed`,children:e.desc})]},e.title))})]})}),(0,L.jsx)(`section`,{className:`py-12 px-6`,children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsx)(`h3`,{className:`text-lg font-bold mb-4 text-white/70`,children:`Also built for`}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:Object.values(MQ).filter(e=>e.slug!==t.slug).map(e=>(0,L.jsxs)(Mn,{to:`/industries/${e.slug}`,className:`px-5 py-2.5 rounded-full text-sm font-semibold border border-white/15 hover:border-white/40 transition-colors flex items-center gap-2`,children:[e.name,` `,(0,L.jsx)(Lc,{size:14,style:{color:jQ.green}})]},e.slug))})]})}),(0,L.jsx)(`section`,{className:`py-16 px-6 text-center`,style:{background:`rgba(34,197,94,0.06)`},children:(0,L.jsxs)(`div`,{className:`max-w-3xl mx-auto`,children:[(0,L.jsx)(`h2`,{className:`text-3xl font-black mb-4`,children:`See your landing number this week`}),(0,L.jsx)(`p`,{className:`text-white/60 mb-8`,children:`Connect your CRM and books, and Command Center builds your first forecast in under an hour.`}),(0,L.jsxs)(Mn,{to:`/auth/signup`,className:`inline-flex items-center gap-2 px-8 py-3.5 rounded-full font-semibold transition-all hover:opacity-90`,style:{background:jQ.green},children:[`Start free trial `,(0,L.jsx)(Lc,{size:16})]})]})}),(0,L.jsxs)(`footer`,{className:`py-8 px-6 border-t border-white/10 text-center text-sm text-white/40`,children:[`© `,new Date().getFullYear(),` Command Center. All rights reserved.`]})]}):(0,L.jsx)(Rt,{to:`/`,replace:!0})}function PQ({size:e=`md`}){return(0,L.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,L.jsx)(`div`,{className:`${{sm:`h-4 w-4`,md:`h-8 w-8`,lg:`h-12 w-12`}[e]} animate-spin rounded-full border-2 border-surface-200 border-t-brand-600`})})}function FQ(){return(0,L.jsx)(`div`,{className:`flex h-96 items-center justify-center`,children:(0,L.jsx)(PQ,{size:`lg`})})}function IQ(){let{login:e,isAuthenticated:t,isLoading:n}=W(),r=ft(),[i,a]=(0,S.useState)(``),[o,s]=(0,S.useState)(``),[c,l]=(0,S.useState)(``),[u,d]=(0,S.useState)(!1),[f,p]=(0,S.useState)(!1);return n?(0,L.jsx)(`div`,{className:`flex min-h-screen items-center justify-center`,children:(0,L.jsx)(PQ,{size:`lg`})}):t?(0,L.jsx)(Rt,{to:`/app`,replace:!0}):(0,L.jsxs)(`div`,{className:`flex min-h-screen bg-surface-50`,children:[(0,L.jsxs)(`div`,{className:`hidden flex-1 flex-col items-center justify-center bg-brand-600 p-8 sm:flex sm:p-12`,children:[(0,L.jsxs)(Mn,{to:`/`,className:`self-start flex items-center gap-2 rounded-lg px-3 py-2 text-white/70 hover:text-white hover:bg-white/10 transition-colors mb-8 min-h-[44px]`,children:[(0,L.jsx)(Fc,{size:16}),(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:`Back to home`})]}),(0,L.jsxs)(`div`,{className:`max-w-md text-white`,children:[(0,L.jsx)(`div`,{className:`mb-8 flex h-12 w-12 items-center justify-center rounded-xl bg-white/10 text-xl font-bold`,children:`CS`}),(0,L.jsx)(`h1`,{className:`text-4xl font-bold leading-tight`,children:`Command Center for Home Services Leaders`}),(0,L.jsx)(`p`,{className:`mt-4 text-lg text-brand-200`,children:`Revenue intelligence and portfolio management for multi-location operators and their partners.`}),(0,L.jsx)(`div`,{className:`mt-12 grid grid-cols-2 gap-6`,children:[{label:`Revenue Forecasting`,value:`AI-Powered`},{label:`Portfolio View`,value:`Multi-Market`},{label:`Partner Network`,value:`Commission Tracked`},{label:`Goal Alignment`,value:`Real-Time`}].map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-brand-200`,children:e.label}),(0,L.jsx)(`p`,{className:`text-lg font-semibold`,children:e.value})]},e.label))})]})]}),(0,L.jsx)(`div`,{className:`flex w-full items-center justify-center bg-white p-8 lg:w-1/2`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,L.jsxs)(Mn,{to:`/`,className:`flex items-center gap-2 rounded-lg px-3 py-2 text-surface-400 hover:text-surface-600 hover:bg-surface-50 transition-colors mb-8 min-h-[44px]`,children:[(0,L.jsx)(Fc,{size:16}),(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:`Back to home`})]}),(0,L.jsxs)(`div`,{className:`mb-8`,children:[(0,L.jsx)(`h2`,{className:`text-2xl font-bold text-surface-900`,children:`Sign in to Command Center`}),(0,L.jsx)(`p`,{className:`mt-2 text-surface-500`,children:`Enter your credentials to access your account`})]}),c&&(0,L.jsx)(`div`,{className:`mb-6 rounded-lg bg-error/10 p-4 text-sm text-error`,children:c}),(0,L.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),l(``),d(!0);try{await e(i,o),r(`/app`)}catch(e){l(e.response?.data?.error||`Login failed. Please check your credentials.`)}finally{d(!1)}},className:`space-y-5`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`email`,className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Email`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Fl,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{id:`email`,type:`email`,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-gray-300 bg-white py-3 pl-10 pr-4 text-sm text-gray-900 outline-none transition-colors placeholder:text-gray-400 focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`you@company.com`,required:!0,autoFocus:!0})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`password`,className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Password`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Nl,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{id:`password`,type:f?`text`:`password`,value:o,onChange:e=>s(e.target.value),className:`w-full rounded-lg border border-gray-300 bg-white py-3 pl-10 pr-10 text-sm text-gray-900 outline-none transition-colors placeholder:text-gray-400 focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`••••••••`,required:!0}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`absolute right-3 top-1/2 -translate-y-1/2 text-surface-400 hover:text-surface-600 p-1.5 rounded min-w-[44px] min-h-[44px] flex items-center justify-center`,children:f?(0,L.jsx)(ml,{className:`h-4 w-4`}):(0,L.jsx)(hl,{className:`h-4 w-4`})})]})]}),(0,L.jsx)(`button`,{type:`submit`,disabled:u,className:`w-full rounded-lg bg-brand-600 py-3 text-sm font-semibold text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-50`,children:u?(0,L.jsx)(PQ,{size:`sm`}):`Sign In`}),(0,L.jsx)(`p`,{className:`text-center text-sm`,children:(0,L.jsx)(Mn,{to:`/auth/forgot-password`,className:`font-medium text-brand-600 hover:text-brand-700`,children:`Forgot your password?`})})]}),(0,L.jsxs)(`p`,{className:`mt-6 text-center text-sm text-surface-500`,children:[`Don't have an account?`,` `,(0,L.jsx)(Mn,{to:`/auth/signup`,className:`font-medium text-brand-600 hover:text-brand-700`,children:`Create one`})]}),(0,L.jsxs)(`div`,{className:`mt-8 rounded-xl border border-surface-200 bg-gradient-to-br from-brand-50 to-surface-50 p-5`,children:[(0,L.jsx)(`p`,{className:`text-xs font-semibold text-surface-700 tracking-wide uppercase`,children:`Demo Account`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-surface-600 font-mono bg-white/60 rounded-lg px-3 py-2 border border-surface-200`,children:`demo@commandcenter.com / CmdSov-Demo-Xh1F_yVwAhs4`})]})]})})]})}function LQ(e){let t=0;return e.length>=8&&t++,/[A-Z]/.test(e)&&t++,/[0-9]/.test(e)&&t++,/[^A-Za-z0-9]/.test(e)&&t++,t}var RQ=[`Weak`,`Fair`,`Good`,`Strong`],zQ=[`bg-red-400`,`bg-orange-400`,`bg-yellow-400`,`bg-green-500`],BQ=[`text-red-500`,`text-orange-500`,`text-yellow-600`,`text-green-600`];function VQ(){let{signup:e,isAuthenticated:t,isLoading:n}=W(),r=ft(),[i]=Bn(),a=i.get(`plan`),[o,s]=(0,S.useState)(``),[c,l]=(0,S.useState)(``),[u,d]=(0,S.useState)(``),[f,p]=(0,S.useState)(``),[m,h]=(0,S.useState)(``),[g,_]=(0,S.useState)(!1),[v,y]=(0,S.useState)(!1),[b,x]=(0,S.useState)(!1);return n?(0,L.jsx)(`div`,{className:`flex min-h-screen items-center justify-center`,children:(0,L.jsx)(PQ,{size:`lg`})}):t?(r(`/app`),null):(0,L.jsxs)(`div`,{className:`flex min-h-screen bg-surface-50`,children:[(0,L.jsxs)(`div`,{className:`hidden w-1/2 flex-col items-center bg-brand-900 p-12 lg:flex`,children:[(0,L.jsxs)(Mn,{to:`/`,className:`self-start flex items-center gap-2 rounded-lg px-3 py-2 text-white/70 hover:text-white hover:bg-white/10 transition-colors mb-8 min-h-[44px]`,children:[(0,L.jsx)(Fc,{size:16}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Back to home`})]}),(0,L.jsxs)(`div`,{className:`max-w-md text-white`,children:[(0,L.jsx)(`div`,{className:`mb-8 flex h-12 w-12 items-center justify-center rounded-xl bg-white/10 text-xl font-bold`,children:`CS`}),(0,L.jsx)(`h1`,{className:`text-4xl font-bold leading-tight`,children:`Start Your Command Center Journey`}),(0,L.jsx)(`p`,{className:`mt-4 text-lg text-brand-200`,children:`Join partners who use Command Center to drive revenue growth across their portfolios.`}),(0,L.jsx)(`div`,{className:`mt-12 space-y-6`,children:[`7-day free trial on all plans`,`No credit card required to start`,`Dedicated onboarding support`,`Full API access on Command tier`].map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-full bg-white/10`,children:(0,L.jsx)(`span`,{className:`text-sm`,children:`✓`})}),(0,L.jsx)(`span`,{className:`text-brand-100`,children:e})]},e))})]})]}),(0,L.jsx)(`div`,{className:`flex w-full items-center justify-center bg-white p-8 lg:w-1/2`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,L.jsxs)(Mn,{to:`/`,className:`flex items-center gap-2 rounded-lg px-3 py-2 text-surface-400 hover:text-surface-600 hover:bg-surface-50 transition-colors mb-8 min-h-[44px]`,children:[(0,L.jsx)(Fc,{size:16}),(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:`Back to home`})]}),(0,L.jsxs)(`div`,{className:`mb-8`,children:[(0,L.jsx)(`h2`,{className:`text-2xl font-bold text-surface-900`,children:`Create your account`}),(0,L.jsx)(`p`,{className:`mt-2 text-surface-500`,children:`Set up your Command Center account in minutes`})]}),m&&(0,L.jsx)(`div`,{className:`mb-6 rounded-lg bg-error/10 p-4 text-sm text-error`,children:m}),b&&(0,L.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-lg bg-success/10 p-4 text-sm text-success`,children:[(0,L.jsx)(yc,{className:`h-5 w-5 shrink-0`}),(0,L.jsx)(`span`,{children:`Account created! Redirecting you to your dashboard…`})]}),(0,L.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),h(``),_(!0);try{await e({email:o,password:c,companyName:u,fullName:f}),x(!0),setTimeout(()=>{r(a?`/app/billing?plan=${a}`:`/app`)},2e3)}catch(e){h(e.response?.data?.error||`Signup failed. Please try again.`)}finally{_(!1)}},className:`space-y-5`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`fullName`,className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Full Name`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Nu,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{id:`fullName`,type:`text`,value:f,onChange:e=>p(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white py-3 pl-10 pr-4 text-sm text-surface-900 outline-none transition-colors placeholder:text-surface-400 focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`John Smith`,required:!0})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`companyName`,className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Company Name`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Kc,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{id:`companyName`,type:`text`,value:u,onChange:e=>d(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white py-3 pl-10 pr-4 text-sm text-surface-900 outline-none transition-colors placeholder:text-surface-400 focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`Acme Landscaping`,required:!0})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`email`,className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Email`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Fl,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{id:`email`,type:`email`,value:o,onChange:e=>s(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white py-3 pl-10 pr-4 text-sm text-surface-900 outline-none transition-colors placeholder:text-surface-400 focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`you@company.com`,required:!0})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`password`,className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Password`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Nl,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{id:`password`,type:v?`text`:`password`,value:c,onChange:e=>l(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white py-3 pl-10 pr-10 text-sm text-surface-900 outline-none transition-colors placeholder:text-surface-400 focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`Min. 8 characters`,required:!0,minLength:8}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>y(!v),className:`absolute right-3 top-1/2 -translate-y-1/2 text-surface-400 hover:text-surface-600 p-1.5 rounded min-w-[44px] min-h-[44px] flex items-center justify-center`,children:v?(0,L.jsx)(ml,{className:`h-4 w-4`}):(0,L.jsx)(hl,{className:`h-4 w-4`})})]}),c.length>0&&(0,L.jsxs)(`div`,{className:`mt-2`,children:[(0,L.jsx)(`div`,{className:`flex gap-1 mb-1`,children:[0,1,2,3].map(e=>(0,L.jsx)(`div`,{className:`h-1 flex-1 rounded-full transition-colors ${e<LQ(c)?zQ[Math.min(LQ(c)-1,3)]:`bg-surface-200`}`},e))}),(0,L.jsx)(`p`,{className:`text-xs ${BQ[Math.min(LQ(c)-1,3)]||`text-surface-400`}`,children:LQ(c)>0?RQ[Math.min(LQ(c)-1,3)]:`Too short`})]})]}),(0,L.jsx)(`button`,{type:`submit`,disabled:g,className:`w-full rounded-lg bg-brand-600 py-3 text-sm font-semibold text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-50`,children:g?(0,L.jsx)(PQ,{size:`sm`}):`Create Account`})]}),(0,L.jsxs)(`p`,{className:`mt-6 text-center text-sm text-surface-500`,children:[`Already have an account?`,` `,(0,L.jsx)(Mn,{to:`/auth/login`,className:`font-medium text-brand-600 hover:text-brand-700`,children:`Sign in`})]}),(0,L.jsxs)(`div`,{className:`mt-8 text-center text-xs text-surface-400`,children:[`By creating an account, you agree to our`,` `,(0,L.jsx)(Mn,{to:`/terms`,className:`underline hover:text-surface-600`,children:`Terms of Service`}),` `,`and`,` `,(0,L.jsx)(Mn,{to:`/privacy`,className:`underline hover:text-surface-600`,children:`Privacy Policy`}),`.`]})]})})]})}function HQ(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(``),[i,a]=(0,S.useState)(!1),[o,s]=(0,S.useState)(!1);return(0,L.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-surface-50 p-8`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-surface-200 bg-white p-8 shadow-sm`,children:[(0,L.jsxs)(Mn,{to:`/auth/login`,className:`mb-6 flex items-center gap-2 text-sm font-medium text-surface-400 hover:text-surface-600 transition-colors`,children:[(0,L.jsx)(Fc,{size:16}),`Back to sign in`]}),(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Forgot your password?`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-surface-500`,children:`Enter the email associated with your account and we'll send you a reset link.`}),i?(0,L.jsxs)(`div`,{className:`mt-6 rounded-lg bg-success/10 p-4 text-sm text-surface-700`,children:[`If an account exists for `,(0,L.jsx)(`span`,{className:`font-medium`,children:e}),`, a password reset link has been sent. The link expires in 1 hour — check your inbox (and spam folder).`]}):(0,L.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),r(``),s(!0);try{await Qs.forgotPassword(e),a(!0)}catch(e){r(e.response?.data?.error||`Something went wrong. Please try again.`)}finally{s(!1)}},className:`mt-6 space-y-5`,children:[n&&(0,L.jsx)(`div`,{className:`rounded-lg bg-error/10 p-4 text-sm text-error`,children:n}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`email`,className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Email`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Fl,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{id:`email`,type:`email`,value:e,onChange:e=>t(e.target.value),className:`w-full rounded-lg border border-gray-300 bg-white py-3 pl-10 pr-4 text-sm text-gray-900 outline-none transition-colors placeholder:text-gray-400 focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`you@company.com`,required:!0,autoFocus:!0})]})]}),(0,L.jsx)(`button`,{type:`submit`,disabled:o,className:`w-full rounded-lg bg-brand-600 py-3 text-sm font-semibold text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-50`,children:o?(0,L.jsx)(PQ,{size:`sm`}):`Send reset link`})]})]})})}function UQ(){let[e]=Bn(),t=e.get(`token`)||``,n=ft(),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(!1),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(!1),[p,m]=(0,S.useState)(!1);return(0,L.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-surface-50 p-8`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-surface-200 bg-white p-8 shadow-sm`,children:[(0,L.jsxs)(Mn,{to:`/auth/login`,className:`mb-6 flex items-center gap-2 text-sm font-medium text-surface-400 hover:text-surface-600 transition-colors`,children:[(0,L.jsx)(Fc,{size:16}),`Back to sign in`]}),(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Choose a new password`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-surface-500`,children:`Minimum 8 characters with at least two of: uppercase, lowercase, digits, symbols.`}),t?d?(0,L.jsx)(`div`,{className:`mt-6 rounded-lg bg-success/10 p-4 text-sm text-surface-700`,children:`Password reset successfully. Redirecting you to sign in…`}):(0,L.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),u(``),r!==a){u(`Passwords do not match.`);return}m(!0);try{await Qs.resetPassword(t,r),f(!0),setTimeout(()=>n(`/auth/login`),2500)}catch(e){u(e.response?.data?.error||`Reset failed. The link may have expired.`)}finally{m(!1)}},className:`mt-6 space-y-5`,children:[l&&(0,L.jsx)(`div`,{className:`rounded-lg bg-error/10 p-4 text-sm text-error`,children:l}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`password`,className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`New password`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Nl,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{id:`password`,type:s?`text`:`password`,value:r,onChange:e=>i(e.target.value),className:`w-full rounded-lg border border-gray-300 bg-white py-3 pl-10 pr-10 text-sm text-gray-900 outline-none transition-colors placeholder:text-gray-400 focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`••••••••`,minLength:8,required:!0,autoFocus:!0}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>c(!s),className:`absolute right-3 top-1/2 -translate-y-1/2 flex min-h-[44px] min-w-[44px] items-center justify-center rounded p-1.5 text-surface-400 hover:text-surface-600`,children:s?(0,L.jsx)(ml,{className:`h-4 w-4`}):(0,L.jsx)(hl,{className:`h-4 w-4`})})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`confirm`,className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Confirm new password`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Nl,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{id:`confirm`,type:s?`text`:`password`,value:a,onChange:e=>o(e.target.value),className:`w-full rounded-lg border border-gray-300 bg-white py-3 pl-10 pr-4 text-sm text-gray-900 outline-none transition-colors placeholder:text-gray-400 focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`••••••••`,minLength:8,required:!0})]})]}),(0,L.jsx)(`button`,{type:`submit`,disabled:p,className:`w-full rounded-lg bg-brand-600 py-3 text-sm font-semibold text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-50`,children:p?(0,L.jsx)(PQ,{size:`sm`}):`Reset password`})]}):(0,L.jsxs)(`div`,{className:`mt-6 rounded-lg bg-error/10 p-4 text-sm text-error`,children:[`Missing reset token. Please use the link from your email, or`,` `,(0,L.jsx)(Mn,{to:`/auth/forgot-password`,className:`font-medium underline`,children:`request a new one`}),`.`]})]})})}var WQ={getOverview:async()=>{let{data:e}=await H.get(`/api/partner/overview`);return e},getProfile:async()=>{let{data:e}=await H.get(`/api/partner/me`);return e.partner},getOrganizations:async()=>{let{data:e}=await H.get(`/api/partner/organizations`);return e},getOrganizationActivity:async e=>{let{data:t}=await H.get(`/api/partner/organizations/${e}/activity`);return t},getCommissions:async()=>{let{data:e}=await H.get(`/api/partner/commissions`);return e}},GQ={listConnectors:async e=>{let{data:t}=await H.get(`/api/super-admin/company/${e}/connectors`);return{connectors:t?.data||[]}},availableConnectors:async()=>{let{data:e}=await H.get(`/api/connectors/available`);return e},connectorStatus:async(e,t)=>{let{data:n}=await H.get(`/api/super-admin/company/${e}/connectors/${t}/status`);return n},syncConnector:async(e,t)=>{let{data:n}=await H.post(`/api/super-admin/company/${e}/connectors/${t}/sync`);return n},refreshConnector:async(e,t)=>{let{data:n}=await H.post(`/api/super-admin/company/${e}/connectors/${t}/refresh`);return n},connectorLogs:async(e,t)=>{let{data:n}=await H.get(`/api/super-admin/company/${e}/connectors/${t}/logs`);return n},disconnectConnector:async(e,t)=>{let{data:n}=await H.post(`/api/super-admin/company/${e}/connectors/${t}/disconnect`);return n},updateConnector:async(e,t,n)=>{let{data:r}=await H.put(`/api/super-admin/company/${e}/connectors/${t}`,n);return r},createConnector:async(e,t,n,r=`hourly`)=>{let{data:i}=await H.post(`/api/super-admin/company/${e}/connectors`,{service:t,config:n,sync_frequency:r});return i},getSubscription:async e=>{let{data:t}=await H.get(`/api/super-admin/company/${e}/billing/subscription`);return t},companyOverview:async e=>{let{data:t}=await H.get(`/api/super-admin/company/${e}/overview`);return t}},KQ={getOverview:async()=>{let{data:e}=await H.get(`/api/super-admin/overview`);return e},getAnalytics:async()=>{let{data:e}=await H.get(`/api/super-admin/analytics`);return e},getOrganizations:async()=>{let{data:e}=await H.get(`/api/super-admin/organizations`);return e},createOrganization:async e=>{let{data:t}=await H.post(`/api/super-admin/organizations`,e);return t},deleteOrganization:async e=>{let{data:t}=await H.delete(`/api/super-admin/organizations/${e}`);return t},getUsers:async e=>{let{data:t}=await H.get(`/api/super-admin/users`,{params:e});return t},createUser:async e=>{let{data:t}=await H.post(`/api/super-admin/users`,e);return t},deleteUser:async e=>{let{data:t}=await H.delete(`/api/super-admin/users/${e}`);return t},updateUserRole:async(e,t)=>{let{data:n}=await H.put(`/api/super-admin/users/${e}/role`,{role:t});return n.user},updateCompanyRole:async(e,t,n)=>{let r={role:t};n&&(r.company_id=n);let{data:i}=await H.put(`/api/super-admin/users/${e}/company-role`,r);return i.user},updateUser:async(e,t)=>{let{data:n}=await H.put(`/api/super-admin/users/${e}`,t);return n.user},getAuditLogs:async e=>{let{data:t}=await H.get(`/api/super-admin/audit`,{params:e});return t},getGroups:async()=>{let{data:e}=await H.get(`/api/super-admin/groups`);return e},getLeads:async()=>{let{data:e}=await H.get(`/api/super-admin/leads`);return e},getLeadRecipients:async()=>{let{data:e}=await H.get(`/api/super-admin/lead-recipients`);return e},getEmailFailures:async e=>{let{data:t}=await H.get(`/api/super-admin/email-failures`,{params:{status:e}});return t},getPortfolios:async()=>{let{data:e}=await H.get(`/api/portfolios/`);return e},getPortfolio:async e=>{let{data:t}=await H.get(`/api/portfolios/${e}`);return t},createPortfolio:async e=>{let{data:t}=await H.post(`/api/portfolios/`,e);return t},updatePortfolio:async(e,t)=>{let{data:n}=await H.put(`/api/portfolios/${e}`,t);return n},deletePortfolio:async e=>{let{data:t}=await H.delete(`/api/portfolios/${e}`);return t},addPortfolioCompanies:async(e,t)=>{let{data:n}=await H.post(`/api/portfolios/${e}/companies`,{company_ids:t});return n},removePortfolioCompanies:async(e,t)=>{let{data:n}=await H.delete(`/api/portfolios/${e}/companies`,{data:{company_ids:t}});return n},getEmailCampaigns:async()=>{let{data:e}=await H.get(`/api/email-campaigns/`);return e},getEmailCampaign:async e=>{let{data:t}=await H.get(`/api/email-campaigns/${e}`);return t},createEmailCampaign:async e=>{let{data:t}=await H.post(`/api/email-campaigns/`,e);return t},updateEmailCampaign:async(e,t)=>{let{data:n}=await H.put(`/api/email-campaigns/${e}`,t);return n},deleteEmailCampaign:async e=>{let{data:t}=await H.delete(`/api/email-campaigns/${e}`);return t},getPartners:async()=>{let{data:e}=await H.get(`/api/super-admin/partners`);return e},createPartner:async e=>{let{data:t}=await H.post(`/api/super-admin/partners`,{name:e});return t}},qQ={getCrmSummary:async()=>{let{data:e}=await H.get(`/api/analytics/crm/summary`);return e},getPipeline:async()=>{let{data:e}=await H.get(`/api/analytics/pipeline`);return e},getContacts:async()=>{let{data:e}=await H.get(`/api/analytics/contacts`);return e},getDealsVelocity:async()=>{let{data:e}=await H.get(`/api/analytics/deals/velocity`);return e},getForecasts:async()=>{let{data:e}=await H.get(`/api/analytics/forecasts`);return e}},JQ={getRevenueForecast:async()=>{let{data:e}=await H.get(`/api/analytics/forecast/revenue`);return e},getPipelineForecast:async()=>{let{data:e}=await H.get(`/api/analytics/forecast/pipeline`);return e},getKPIs:async e=>{let t=e?{period_days:e}:{},{data:n}=await H.get(`/api/analytics/kpis`,{params:t});return n}},YQ={getGoals:async e=>{let{data:t}=await H.get(`/api/analytics/goals`,{params:e});return t},getGoalMetrics:async e=>{let{data:t}=await H.get(`/api/analytics/goals/${e}/metrics`);return t},createGoalMetric:async(e,t)=>{let{data:n}=await H.post(`/api/analytics/goals/${e}/metrics`,t);return n},updateGoalMetric:async(e,t,n)=>{let{data:r}=await H.put(`/api/analytics/goals/${e}/metrics/${t}`,n);return r},deleteGoalMetric:async(e,t)=>{let{data:n}=await H.delete(`/api/analytics/goals/${e}/metrics/${t}`);return n},updateProgress:async(e,t,n)=>{let{data:r}=await H.put(`/api/analytics/goals/${e}/progress`,{current_value:t,roll_up:n??!1});return r},createGoal:async e=>{let{data:t}=await H.post(`/api/analytics/goals`,e);return t},updateGoal:async(e,t)=>{let{data:n}=await H.put(`/api/analytics/goals/${e}`,t);return n},deleteGoal:async e=>{let{data:t}=await H.delete(`/api/analytics/goals/${e}`);return t},getUsers:async()=>{let{data:e}=await H.get(`/api/analytics/users`);return e}},XQ={getOverview:async()=>{let{data:e}=await H.get(`/api/analytics/strategic-intelligence/overview`);return e},getWaterfall:async()=>{let{data:e}=await H.get(`/api/analytics/strategic-intelligence/waterfall`);return e},getRootCause:async()=>{let{data:e}=await H.get(`/api/analytics/strategic-intelligence/root-cause`);return e},getContribution:async()=>{let{data:e}=await H.get(`/api/analytics/strategic-intelligence/contribution`);return e}},ZQ={getOverview:async()=>{let{data:e}=await H.get(`/api/analytics/scale-optimization/overview`);return e},getRunRate:async()=>{let{data:e}=await H.get(`/api/analytics/scale-optimization/run-rate`);return e},getChannels:async()=>{let{data:e}=await H.get(`/api/analytics/scale-optimization/channels`);return e},getMatrix:async()=>{let{data:e}=await H.get(`/api/analytics/scale-optimization/matrix`);return e},getRecommendations:async()=>{let{data:e}=await H.get(`/api/analytics/scale-optimization/recommendations`);return e}},QQ={getSSOConfig:async()=>{let{data:e}=await H.get(`/api/enterprise/sso-config`);return e},saveSSOConfig:async e=>{let{data:t}=await H.post(`/api/enterprise/sso-config`,e);return t},getSPMetadata:async()=>{let{data:e}=await H.get(`/api/enterprise/sso-config/metadata`);return e},getBranding:async()=>{let{data:e}=await H.get(`/api/enterprise/branding`);return e},updateBranding:async e=>{let{data:t}=await H.put(`/api/enterprise/branding`,e);return t},resetBranding:async()=>{let{data:e}=await H.post(`/api/enterprise/branding/reset`);return e},uploadLogo:async e=>{let t=new FormData;t.append(`file`,e);let{data:n}=await H.post(`/api/enterprise/branding/upload-logo`,t,{headers:{"Content-Type":`multipart/form-data`}});return n}},$Q={getTeam:async()=>{let{data:e}=await H.get(`/api/partner/team`);return e},addMember:async e=>{let{data:t}=await H.post(`/api/partner/team`,e);return t},updateRole:async(e,t)=>{let{data:n}=await H.put(`/api/partner/team/${e}`,{role:t});return n},removeMember:async e=>{let{data:t}=await H.delete(`/api/partner/team/${e}`);return t}},e$={getInsights:async()=>{let{data:e}=await H.get(`/api/coaching/insights`);return e},getScore:async()=>{let{data:e}=await H.get(`/api/coaching/score`);return e},dismissInsight:async e=>{await H.post(`/api/coaching/insights/${encodeURIComponent(e)}/dismiss`)}};e$.getInsights,e$.getScore,e$.dismissInsight;var t$=`/api/company`;async function n$(e,t){return(await U.get(`${t$}/${e}/coaching-assignments`,{params:t})).data.coaching_assignments}async function r$(e,t){return(await U.post(`${t$}/${e}/coaching-assignments`,t)).data.coaching_assignment}async function i$(e,t,n){return(await U.put(`${t$}/${e}/coaching-assignments/${t}`,n)).data.coaching_assignment}async function a$(e,t){return(await U.delete(`${t$}/${e}/coaching-assignments/${t}`)).data}var o$=`/api/company`;async function s$(e){return(await U.get(`${o$}/${e}/coaching-scorecards`)).data.coaching_scorecards}async function c$(e,t){return(await U.post(`${o$}/${e}/coaching-scorecards`,t)).data.coaching_scorecard}async function l$(e,t,n){return(await U.put(`${o$}/${e}/coaching-scorecards/${t}`,n)).data.coaching_scorecard}async function u$(e,t){return(await U.delete(`${o$}/${e}/coaching-scorecards/${t}`)).data}var d$={sendSms:async e=>{let{data:t}=await H.post(`/api/sms/send`,e);return t},listMessages:async e=>{let{data:t}=await H.get(`/api/sms/messages`,{params:e});return t},getMessage:async e=>{let{data:t}=await H.get(`/api/sms/messages/${e}`);return t},triggerCall:async e=>{let{data:t}=await H.post(`/api/sms/call`,e);return t},listCalls:async e=>{let{data:t}=await H.get(`/api/sms/calls`,{params:e});return t},updateCallDisposition:async(e,t)=>{let{data:n}=await H.put(`/api/sms/calls/${e}/disposition`,{disposition:t});return n},getLeadTimeline:async e=>{let{data:t}=await H.get(`/api/sms/leads/${e}/timeline`);return t},listOptOuts:async e=>{let{data:t}=await H.get(`/api/sms/opt-outs`,{params:e});return t},addOptOut:async e=>{let{data:t}=await H.post(`/api/sms/opt-outs`,e);return t},removeOptOut:async e=>{let{data:t}=await H.delete(`/api/sms/opt-outs/${e}`);return t},getLeadMetrics:async e=>{let{data:t}=await H.get(`/api/sms/leads/${e}/metrics`);return t}},f$={available:async()=>{let{data:e}=await H.get(`/api/connectors/available`);return e},list:async()=>{let{data:e}=await H.get(`/api/connectors`);return e},update:async(e,t)=>{let{data:n}=await H.put(`/api/connectors/${e}`,t);return n},create:async(e,t,n=`hourly`)=>{let{data:r}=await H.post(`/api/connectors`,{service:e,config:t,sync_frequency:n});return r},remove:async e=>{let{data:t}=await H.delete(`/api/connectors/${e}`);return t},status:async e=>{let{data:t}=await H.get(`/api/connectors/${e}/status`);return t},sync:async e=>{let{data:t}=await H.post(`/api/connectors/${e}/sync`);return t},logs:async e=>{let{data:t}=await H.get(`/api/connectors/${e}/logs`);return t},oauthAuthorize:async(e,t)=>{let n=t?`?next=${encodeURIComponent(t)}`:``;window.location.href=`/api/connectors/oauth/authorize/${e}${n}`},listSpreadsheets:async()=>{let{data:e}=await H.get(`/api/connectors/oauth/connected-sheets`);return e},selectSpreadsheet:async e=>{let{data:t}=await H.post(`/api/connectors/oauth/connected-sheets/select`,{spreadsheet_id:e});return t}},p$=`/api/company`;async function m$(e,t){return(await U.get(`${p$}/${e}/forecasts`,{params:t})).data.forecasts}async function h$(e,t){return(await U.post(`${p$}/${e}/forecasts`,t)).data.forecast}async function g$(e,t,n){return(await U.put(`${p$}/${e}/forecasts/${t}`,n)).data.forecast}async function _$(e,t){return(await U.delete(`${p$}/${e}/forecasts/${t}`)).data}async function v$(e){return(await U.post(`${p$}/${e}/forecasts/sync`)).data.result}async function y$(e){return(await U.get(`${p$}/${e}/forecasts/sync-status`)).data}var b$=`/api/company`;async function x$(e,t){return(await U.get(`${b$}/${e}/optimization-moves`,{params:t})).data.optimization_moves}async function S$(e,t){return(await U.post(`${b$}/${e}/optimization-moves`,t)).data.optimization_move}async function C$(e,t,n){return(await U.put(`${b$}/${e}/optimization-moves/${t}`,n)).data.optimization_move}async function w$(e,t){return(await U.delete(`${b$}/${e}/optimization-moves/${t}`)).data}async function T$(e,t){return(await U.patch(`${b$}/${e}/optimization-moves/${t}/accept`)).data.optimization_move}async function E$(e,t){return(await U.patch(`${b$}/${e}/optimization-moves/${t}/reject`)).data.optimization_move}var D$=`/api/company`;async function O$(e,t){return(await U.get(`${D$}/${e}/revenue-leaks`,{params:t})).data.revenue_leaks}async function k$(e,t,n){return(await U.patch(`${D$}/${e}/revenue-leaks/${t}/resolve`,n?{resolution_notes:n}:{})).data.revenue_leak}async function A$(e,t){return(await U.post(`${D$}/${e}/revenue-leaks/scan`,t?{detectors:t}:{})).data}async function j$(e,t){return(await U.get(`${D$}/${e}/revenue-leaks/${t}/remediation`)).data}async function M$(e,t,n){return(await U.post(`${D$}/${e}/revenue-leaks/${t}/remediation`,{suggestion_index:n})).data}async function N$(e,t){return(await U.get(`${D$}/${e}/revenue-leaks/${t}/resolution-history`)).data}async function P$(e,t=90){return(await U.get(`${D$}/${e}/revenue-leaks/recurring`,{params:{days:t}})).data}async function F$(e,t=30){return(await U.get(`${D$}/${e}/revenue-leaks/stats`,{params:{days:t}})).data}async function I$(e){return(await U.get(`${D$}/${e}/leak-settings/severity`)).data}async function L$(e,t){return(await U.put(`${D$}/${e}/leak-settings/severity`,{severity_rules:t})).data}async function R$(e){return(await U.get(`${D$}/${e}/leak-settings/alerts`)).data}async function z$(e,t){return(await U.put(`${D$}/${e}/leak-settings/alerts`,t)).data}async function B$(e=90){return(await U.get(`/api/analytics/locations`,{params:{period_days:e}})).data}async function V$(e=90){return(await U.get(`/api/analytics/locations/comparison`,{params:{period_days:e}})).data}async function H$(e){return(await U.post(`/api/analytics/locations/detector`,e)).data}var U$={getOverview:async()=>{let{data:e}=await H.get(`/api/analytics/multi-market/overview`);return e},getComparison:async()=>{let{data:e}=await H.get(`/api/analytics/multi-market/comparison`);return e},getDrillDown:async e=>{let{data:t}=await H.get(`/api/analytics/multi-market/market/${encodeURIComponent(e)}`);return t},getUnderperforming:async()=>{let{data:e}=await H.get(`/api/analytics/multi-market/underperforming`);return e}},W$=e=>`/api/company/${e}/facebook_ads`,G$={async getCampaigns(e,t){return(await U.get(`${W$(e)}/campaigns`,{params:t})).data},async getCampaign(e,t){return(await U.get(`${W$(e)}/campaigns/${t}`)).data},async getMetrics(e,t){return(await U.get(`${W$(e)}/metrics`,{params:t})).data},async getAnalytics(e){return(await U.get(`${W$(e)}/analytics`)).data},async sync(e){return(await U.post(`${W$(e)}/sync`)).data}},K$=[{title:`Dashboard`,items:[{path:`/app`,label:`Dashboard`,icon:kl}]},{title:`Pipeline`,items:[{path:`/app/estimates`,label:`Estimates`,icon:_l},{path:`/app/angi-leads`,label:`Angi Leads`,icon:il}]},{title:`Ad Channels`,items:[{path:`/app/lead-gen`,label:`Lead Gen Dashboard`,icon:yu},{path:`/app/lead-gen/campaigns/new`,label:`New Campaign`,icon:eu},{path:`/app/lead-gen/creatives`,label:`Creatives`,icon:Wl},{path:`/app/lead-gen/optimization`,label:`Optimization`,icon:mu},{path:`/app/lead-gen/attribution`,label:`Attribution`,icon:wu},{path:`/app/google-ads`,label:`Google Ads`,icon:J},{path:`/app/facebook-ads`,label:`Facebook Ads`,icon:J}]},{title:`Communications`,items:[{path:`/app/slack`,label:`Slack`,icon:Sl},{path:`/app/sms-call`,label:`SMS / Calls`,icon:Zl}]},{title:`Revenue`,items:[{path:`/app/revenue-leaks`,label:`Revenue Leaks`,icon:jc},{path:`/app/optimization-moves`,label:`Optimizations`,icon:Ru},{path:`/app/forecasts`,label:`Forecasts`,icon:wu},{path:`/app/commissions`,label:`Commissions`,icon:mc,permission:`view_reports`}]},{title:`Coaching`,items:[{path:`/app/coaching-assignments`,label:`Assignments`,icon:il},{path:`/app/coaching-scorecards`,label:`Scorecards`,icon:Bc},{path:`/app/coaching`,label:`Smart Coaching`,icon:Al}]},{title:`Team & Org`,items:[{path:`/app/organizations`,label:`Organizations`,icon:Kc},{path:`/app/team`,label:`Team`,icon:Pu,permission:`manage_team`}]},{title:`Settings`,items:[{path:`/app/integrations`,label:`Integrations`,icon:$l,permission:`edit_integrations`},{path:`/app/billing`,label:`Billing`,icon:cl},{path:`/app/settings`,label:`Settings`,icon:cu,permission:`edit_settings`}]}],q$=[{title:`Overview`,items:[{path:`/admin`,label:`Dashboard`,icon:kl}]},{title:`People`,items:[{path:`/admin/organizations`,label:`Organizations`,icon:Kc},{path:`/admin/partners`,label:`Partners`,icon:xl},{path:`/admin/commissions`,label:`Commissions`,icon:cl},{path:`/admin/super-admins`,label:`Super Admins`,icon:ll},{path:`/admin/users`,label:`Users`,icon:Pu},{path:`/admin/leads`,label:`Leads`,icon:_l}]},{title:`Insights`,items:[{path:`/admin/analytics`,label:`Analytics`,icon:mc},{path:`/admin/crm-analytics`,label:`CRM Analytics`,icon:hc},{path:`/admin/forecasting`,label:`Forecasting`,icon:wu},{path:`/admin/goals`,label:`Goals`,icon:yu},{path:`/admin/strategic-intelligence`,label:`Strategic Intel`,icon:fu}]},{title:`Growth`,items:[{path:`/admin/scale-optimization`,label:`Scale Optimization`,icon:wu},{path:`/admin/multi-market`,label:`Multi-Market`,icon:Ll},{path:`/admin/coaching`,label:`Smart Coaching`,icon:Al},{path:`/admin/portfolios`,label:`Portfolios`,icon:vl}]},{title:`Operations`,items:[{path:`/admin/email-campaigns`,label:`Email Campaigns`,icon:Fl},{path:`/admin/integrations`,label:`Integrations`,icon:$l},{path:`/admin/enterprise`,label:`Enterprise`,icon:fu},{path:`/admin/audit`,label:`Audit Log`,icon:_l},{path:`/admin/access-levels`,label:`Access Levels`,icon:Dl}]},{title:`Settings`,items:[{path:`/admin/settings`,label:`Settings`,icon:cu}]}],J$=`cs-sidebar-sections`,Y$=`cs-view-mode`;function X$(){try{return localStorage.getItem(Y$)||`partner`}catch{return`partner`}}var Z$={super_admin:`Super Admin`,partner:`Partner`,user:`User`},Q$={super_admin:`bg-red-100 text-red-700`,partner:`bg-blue-100 text-blue-700`,user:`bg-gray-100 text-gray-600`},$$={owner:`Owner`,admin:`Admin`,manager:`Manager`,rep:`Rep`,viewer:`Viewer`},e1={owner:`bg-purple-100 text-purple-700`,admin:`bg-indigo-100 text-indigo-700`,manager:`bg-amber-100 text-amber-700`,rep:`bg-emerald-100 text-emerald-700`,viewer:`bg-slate-100 text-slate-600`};function t1(e){let t=e===`partner`?K$:q$;return t.reduce((e,n)=>({...e,[n.title]:n.title===t[0].title}),{})}function n1(e){try{let t=JSON.parse(localStorage.getItem(J$)||`{}`);return{...t1(e),...t}}catch{return t1(e)}}function r1(e,t){return e===t||t!==`/app`&&t!==`/admin`&&e.startsWith(t)}function i1({open:e,onClose:t}){let n=lt(),{user:r,isRole:i,hasCompanyPermission:a}=W(),o=i(`super_admin`),[s,c]=(0,S.useState)(()=>o?X$():`partner`);(0,S.useEffect)(()=>{localStorage.setItem(Y$,s)},[s]);let l=(s===`admin`?q$:K$).map(e=>({...e,items:o?e.items:e.items.filter(e=>!e.permission||a(e.permission))})).filter(e=>e.items.length>0),[u,d]=(0,S.useState)(()=>n1(s));(0,S.useEffect)(()=>{d(t1(s))},[s]),(0,S.useEffect)(()=>{let e=l.find(e=>e.items.some(e=>r1(n.pathname,e.path)));e&&!u[e.title]&&d(t=>({...t,[e.title]:!0}))},[n.pathname]),(0,S.useEffect)(()=>{localStorage.setItem(J$,JSON.stringify(u))},[u]),(0,S.useEffect)(()=>{e&&window.innerWidth<768&&t?.()},[n.pathname]),(0,S.useEffect)(()=>{let n=n=>{n.key===`Escape`&&e&&t?.()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let f=e=>{d(t=>({...t,[e]:!t[e]}))};return(0,L.jsxs)(L.Fragment,{children:[e&&(0,L.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/50 lg:hidden`,onClick:t,"aria-hidden":`true`}),(0,L.jsxs)(`aside`,{className:`fixed left-0 top-0 z-50 flex h-screen w-64 flex-col border-r border-surface-200 bg-white transition-transform duration-200 ease-in-out ${e?`translate-x-0`:`-translate-x-full`} lg:translate-x-0`,children:[t&&(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`absolute right-3 top-3 flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg text-surface-500 hover:bg-surface-100 hover:text-surface-600 lg:hidden`,"aria-label":`Close sidebar`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-surface-200 px-4 py-4 sm:px-6`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-brand-600 text-white`,children:(0,L.jsx)(`span`,{className:`text-sm font-bold`,children:`CS`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h1`,{className:`truncate text-sm font-semibold text-surface-900`,children:`Command Sovereignty`}),(0,L.jsx)(`p`,{className:`truncate text-xs text-surface-500`,children:s===`admin`?`Admin Panel`:`Command Center`})]})]}),o&&(0,L.jsx)(`div`,{className:`px-3 pb-2`,children:(0,L.jsxs)(`div`,{className:`flex rounded-lg border border-surface-200 p-1 bg-surface-50`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>c(`partner`),className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-semibold transition-colors min-h-[36px] ${s===`partner`?`bg-white text-surface-900 shadow-sm`:`text-surface-400 hover:text-surface-600`}`,children:[(0,L.jsx)(kl,{className:`h-3.5 w-3.5`}),`Partner`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>c(`admin`),className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-semibold transition-colors min-h-[36px] ${s===`admin`?`bg-white text-surface-900 shadow-sm`:`text-surface-400 hover:text-surface-600`}`,children:[(0,L.jsx)(du,{className:`h-3.5 w-3.5`}),`Admin`]})]})}),(0,L.jsx)(`nav`,{className:`flex-1 overflow-y-auto px-3 py-4`,children:l.map(e=>{let t=u[e.title],r=e.items.some(e=>r1(n.pathname,e.path));return(0,L.jsxs)(`div`,{className:`mb-1`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>f(e.title),className:`flex w-full items-center gap-1 rounded-md px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-surface-400 hover:text-surface-600 transition-colors`,"aria-expanded":t,children:[(0,L.jsx)(Zc,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-180`:``}`}),(0,L.jsx)(`span`,{children:e.title}),r&&!t&&(0,L.jsx)(`span`,{className:`ml-auto h-1.5 w-1.5 rounded-full bg-brand-500`})]}),(0,L.jsx)(`div`,{className:`grid transition-all duration-200 ${t?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`}`,children:(0,L.jsx)(`div`,{className:`overflow-hidden`,children:(0,L.jsx)(`ul`,{className:`space-y-0.5 pt-1 pb-1`,children:e.items.map(e=>{let t=e.icon,r=r1(n.pathname,e.path);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(Mn,{to:e.path,className:`group flex items-center gap-3 rounded-md px-3 py-2 text-sm font-medium transition-colors min-h-[40px] ${r?`bg-brand-50 text-brand-700`:`text-surface-600 hover:bg-surface-100 hover:text-surface-900`}`,children:[(0,L.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.path)})})})})]},e.title)})}),(0,L.jsx)(`div`,{className:`border-t border-surface-200 px-4 py-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-200 text-xs font-semibold text-surface-700`,children:r?.full_name?.charAt(0)?.toUpperCase()||`?`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,L.jsx)(`p`,{className:`truncate text-sm font-medium text-surface-900`,children:r?.full_name||`User`}),r?.role&&(0,L.jsx)(`span`,{className:`shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-semibold ${Q$[r.role]||Q$.user}`,children:Z$[r.role]||r.role})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,L.jsx)(`p`,{className:`truncate text-xs text-surface-500`,children:r?.email}),!o&&r?.companyRole&&(0,L.jsx)(`span`,{className:`shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-semibold ${e1[r.companyRole]||e1.viewer}`,children:$$[r.companyRole]})]})]})]})})]})]})}var a1=(0,S.createContext)({branding:{logo_url:``,primary_color:`#00A846`,secondary_color:`#008036`,favicon_url:``,custom_domain:``,app_name:`Command Sovereignty`,login_bg_url:``},loading:!0});function o1(){return(0,S.useContext)(a1)}function s1({title:e,onMenuClick:t}){let{user:n,logout:r}=W(),{branding:i}=o1(),a=ft(),[o,s]=(0,S.useState)(!1),c=(0,S.useRef)(null);return(0,S.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,L.jsxs)(`header`,{className:`sticky top-0 z-30 flex h-14 sm:h-16 items-center justify-between border-b border-surface-200 bg-white px-4 sm:px-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[t&&(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg text-surface-500 hover:bg-surface-100 hover:text-surface-700 lg:hidden min-w-[44px] min-h-[44px]`,"aria-label":`Open menu`,children:(0,L.jsx)(Rl,{className:`h-5 w-5`})}),i.logo_url?(0,L.jsx)(`img`,{src:i.logo_url,alt:i.app_name||`Company logo`,className:`h-8 max-w-[120px] object-contain`}):null,(0,L.jsx)(`h2`,{className:`text-base sm:text-lg font-semibold text-surface-900 truncate`,children:e})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-4`,children:[(0,L.jsx)(`button`,{type:`button`,"aria-label":`Notifications`,className:`relative flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-surface-500 hover:bg-surface-100 hover:text-surface-700 min-w-[44px] min-h-[44px]`,children:(0,L.jsx)(Uc,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`relative`,ref:c,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),"aria-expanded":o,"aria-haspopup":`true`,className:`flex items-center gap-2 rounded-lg px-2 py-2 text-sm font-medium text-surface-700 hover:bg-surface-100 min-h-[44px]`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-200 text-xs font-semibold text-surface-700`,children:n?.full_name?.charAt(0)?.toUpperCase()||`?`}),(0,L.jsx)(`span`,{className:`hidden sm:inline truncate max-w-[120px]`,children:n?.full_name}),(0,L.jsx)(Zc,{className:`h-4 w-4 text-surface-400 transition-transform ${o?`rotate-180`:``}`})]}),o&&(0,L.jsx)(`div`,{className:`absolute right-0 top-full z-50 mt-2 w-48 rounded-lg border border-surface-200 bg-white p-1 shadow-lg`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:async()=>{await r(),a(`/auth/login`)},className:`flex w-full items-center gap-2 rounded-md px-3 py-2.5 text-sm text-surface-700 hover:bg-surface-100 min-h-[44px]`,children:[(0,L.jsx)(Pl,{className:`h-4 w-4`}),`Sign out`]})})]})]})]})}function $({children:e,title:t}){let[n,r]=(0,S.useState)(!1),i=(0,S.useCallback)(()=>r(!1),[]),a=(0,S.useCallback)(()=>r(e=>!e),[]);return(0,L.jsxs)(`div`,{className:`min-h-screen bg-surface-50 grid grid-cols-[1fr] lg:grid-cols-[256px_1fr]`,children:[(0,L.jsx)(i1,{open:n,onClose:i}),(0,L.jsxs)(`div`,{className:`col-start-1 lg:col-start-2`,children:[(0,L.jsx)(s1,{title:t,onMenuClick:a}),(0,L.jsx)(`main`,{className:`p-4 sm:p-6`,children:e})]})]})}function c1({title:e,value:t,change:n,changeType:r=`neutral`,icon:i,iconBg:a=`bg-brand-100 text-brand-600`,href:o}){let s=(0,L.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500 truncate`,children:e}),(0,L.jsx)(`p`,{className:`mt-1 text-xl sm:text-2xl font-semibold text-surface-900 truncate`,children:t}),n&&(0,L.jsx)(`p`,{className:`mt-1 text-xs font-medium ${{positive:`text-success`,negative:`text-error`,neutral:`text-surface-500`}[r]}`,children:n})]}),i&&(0,L.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${a}`,children:(0,L.jsx)(i,{className:`h-5 w-5`})})]}),c=`rounded-xl border border-surface-200 bg-white p-4 sm:p-5 transition-shadow hover:shadow-md`;return o?(0,L.jsx)(Mn,{to:o,className:`${c} block no-underline cursor-pointer transition-colors hover:border-brand-300`,children:s}):(0,L.jsx)(`div`,{className:c,children:s})}var l1={high:0,medium:1,low:2},u1={high:`bg-red-100 text-red-700`,medium:`bg-amber-100 text-amber-700`,low:`bg-emerald-100 text-emerald-700`};function d1({coachingPath:e=`/admin/coaching`}){let[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(`loading`);return(0,S.useEffect)(()=>{let e=!1;return e$.getInsights().then(t=>{if(e)return;let r=t.insights.filter(e=>!e.dismissed).sort((e,t)=>l1[e.severity]-l1[t.severity])[0];r?(n(r),i(`ready`)):i(`clear`)}).catch(()=>{e||i(`error`)}),()=>{e=!0}},[]),r===`loading`||r===`error`?null:r===`clear`?(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-emerald-100 text-emerald-600`,children:(0,L.jsx)(yc,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`text-xs font-bold uppercase tracking-wider text-surface-400`,children:`Next Move`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-700`,children:`All clear — no coaching recommendations right now.`})]}),(0,L.jsx)(Mn,{to:e,className:`shrink-0 text-sm font-medium text-brand-600 hover:text-brand-700`,children:`View all`})]})}):(0,L.jsx)(`div`,{className:`rounded-xl border border-brand-200 bg-gradient-to-r from-brand-50 to-white p-5`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-brand-100 text-brand-600`,children:(0,L.jsx)(Al,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`p`,{className:`text-xs font-bold uppercase tracking-wider text-brand-600`,children:`Next Move`}),t&&(0,L.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-semibold uppercase ${u1[t.severity]}`,children:t.severity})]}),(0,L.jsx)(`h3`,{className:`mt-1 truncate text-sm font-semibold text-surface-900`,children:t?.title}),(0,L.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-surface-600`,children:t?.narrative})]}),(0,L.jsxs)(Mn,{to:e,className:`inline-flex shrink-0 items-center gap-1 text-sm font-semibold text-brand-600 hover:text-brand-700`,children:[`View all `,(0,L.jsx)(Lc,{className:`h-3.5 w-3.5`})]})]})})}function f1(e,t){let[n,r]=(0,S.useState)(null);return(0,S.useEffect)(()=>{if(!e)return;let t=()=>{let t=document.querySelector(e);t&&r(t.getBoundingClientRect())},n=requestAnimationFrame(t);window.addEventListener(`resize`,t),window.addEventListener(`scroll`,t,!0);let i=Array.from({length:5},(e,n)=>setTimeout(t,(n+1)*200));return()=>{cancelAnimationFrame(n),window.removeEventListener(`resize`,t),window.removeEventListener(`scroll`,t,!0),i.forEach(clearTimeout)}},[e]),n}function p1({targetRect:e}){return e?(0,L.jsx)(`div`,{className:`fixed inset-0 z-[9998] pointer-events-none`,style:{backgroundColor:`rgba(0, 0, 0, 0.6)`,backdropFilter:`blur(2px)`,clipPath:`inset(
${Math.max(0,e.top-12)}px
${Math.max(0,window.innerWidth-e.right-12)}px
${Math.max(0,window.innerHeight-e.bottom-12)}px
${Math.max(0,e.left-12)}px
)`}}):(0,L.jsx)(`div`,{className:`fixed inset-0 z-[9998] bg-black/60 backdrop-blur-[2px]`})}function m1({current:e,total:t}){return(0,L.jsx)(`div`,{className:`flex items-center gap-1.5 justify-center`,children:Array.from({length:t}).map((t,n)=>(0,L.jsx)(`div`,{className:`h-1.5 rounded-full transition-all duration-300 ${n===e?`w-6 bg-brand-600`:`w-1.5 bg-surface-300`}`},n))})}function h1({title:e,description:t,stepIndex:n,totalSteps:r,onPrev:i,onNext:a,onSkip:o}){let s=(0,S.useRef)(null),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)({x:0,y:0}),[f,p]=(0,S.useState)(!1),m=(0,S.useRef)(n);(0,S.useEffect)(()=>{let e=requestAnimationFrame(()=>p(!0));return()=>cancelAnimationFrame(e)},[]),(0,S.useEffect)(()=>{m.current!==n&&(m.current=n,d({x:0,y:0}))},[n]);let h=(0,S.useCallback)(e=>{let t=e.touches[0];s.current={x:t.clientX,y:t.clientY},l(!0),d({x:0,y:0})},[]),g=(0,S.useCallback)(e=>{if(!c||!s.current)return;let t=e.touches[0],n=t.clientX-s.current.x,r=t.clientY-s.current.y;(Math.abs(n)>4||Math.abs(r)>4)&&d({x:n,y:r})},[c]);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-[9998] bg-black/50 backdrop-blur-sm transition-opacity duration-300`,style:{opacity:+!!f},onClick:o}),(0,L.jsxs)(`div`,{className:`fixed left-0 right-0 z-[9999] rounded-t-2xl border-t border-surface-200 bg-white shadow-2xl`,style:{bottom:0,maxHeight:`70vh`,transform:f?`translateY(${Math.min(u.y,0)}px) translateX(${u.x*.3}px)`:`translateY(100%)`,transition:c?`none`:`transform 0.4s cubic-bezier(0.32, 0.72, 0, 1)`,willChange:`transform`},onTouchStart:h,onTouchMove:g,onTouchEnd:e=>{if(l(!1),!s.current)return;let t=e.changedTouches[0],n=t.clientX-s.current.x,r=t.clientY-s.current.y;n<-50&&Math.abs(n)>Math.abs(r)?a():n>50&&Math.abs(n)>Math.abs(r)?i():r>50&&Math.abs(r)>Math.abs(n)&&o(),s.current=null,d({x:0,y:0})},children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between px-5 pt-4 pb-2`,children:[(0,L.jsx)(`button`,{onClick:o,className:`min-w-[44px] min-h-[44px] flex items-center justify-center rounded-lg text-surface-400 hover:bg-surface-100 hover:text-surface-600 transition-colors`,"aria-label":`Skip tour`,children:(0,L.jsx)(Iu,{size:18})}),(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,L.jsx)(`div`,{className:`h-1 w-10 rounded-full bg-surface-300`}),(0,L.jsxs)(`span`,{className:`text-xs font-medium text-surface-400`,children:[`Step `,n,` of `,r]})]}),(0,L.jsx)(`div`,{className:`min-w-[44px]`}),` `]}),(0,L.jsx)(`div`,{className:`px-5 pb-3`,children:(0,L.jsx)(m1,{current:n-1,total:r})}),(0,L.jsxs)(`div`,{className:`overflow-y-auto px-5 pb-2`,style:{maxHeight:`calc(70vh - 160px)`},children:[(0,L.jsx)(`h3`,{className:`text-lg font-bold text-surface-900 mb-2`,children:e}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 leading-relaxed`,children:t})]}),(0,L.jsxs)(`div`,{className:`sticky bottom-0 flex items-center gap-3 border-t border-surface-100 bg-white px-5 py-3`,children:[(0,L.jsxs)(`button`,{onClick:i,disabled:n===1,className:`flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-surface-200 py-3 text-sm font-medium text-surface-600 hover:bg-surface-50 hover:text-surface-900 transition-colors disabled:opacity-30 disabled:cursor-not-allowed min-h-[44px]`,children:[(0,L.jsx)(Qc,{size:16}),`Back`]}),(0,L.jsxs)(`button`,{onClick:a,className:`flex flex-1 items-center justify-center gap-1.5 rounded-lg bg-brand-600 py-3 text-sm font-semibold text-white hover:bg-brand-700 transition-colors min-h-[44px]`,children:[n===r?`All Set`:`Next`,(0,L.jsx)(el,{size:16})]})]})]})]})}function g1({title:e,description:t,stepIndex:n,totalSteps:r,onPrev:i,onNext:a,onSkip:o,rect:s,position:c}){let[l,u]=(0,S.useState)({});return(0,S.useEffect)(()=>{if(!s)return;let e=0,t=0;switch(c){case`bottom`:e=s.bottom+16,t=s.left+s.width/2-320/2;break;case`top`:e=s.top-180-16,t=s.left+s.width/2-320/2;break;case`right`:e=s.top+s.height/2-180/2,t=s.right+16;break;case`left`:e=s.top+s.height/2-180/2,t=s.left-320-16;break}t=Math.max(12,Math.min(t,window.innerWidth-320-12)),e=Math.max(12,Math.min(e,window.innerHeight-180-12)),u({position:`fixed`,top:e,left:t,width:`max-content`,zIndex:9999})},[s,c]),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5 shadow-2xl transition-all`,style:{...l,maxWidth:320,animation:`fadeSlideIn 0.25s ease-out`},children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,L.jsxs)(`span`,{className:`text-xs font-medium text-surface-400`,children:[`Step `,n,` of `,r]}),(0,L.jsx)(`button`,{onClick:o,className:`rounded-lg p-1.5 text-surface-400 hover:bg-surface-100 hover:text-surface-600 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center`,"aria-label":`Skip tour`,children:(0,L.jsx)(Iu,{size:16})})]}),(0,L.jsx)(`h3`,{className:`text-base font-bold text-surface-900 mb-1`,children:e}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 leading-relaxed`,children:t}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,L.jsxs)(`button`,{onClick:i,disabled:n===1,className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium text-surface-600 hover:bg-surface-100 hover:text-surface-900 transition-colors disabled:opacity-30 disabled:cursor-not-allowed min-h-[44px]`,children:[(0,L.jsx)(Qc,{size:16}),`Back`]}),(0,L.jsxs)(`button`,{onClick:a,className:`flex items-center gap-1.5 rounded-lg bg-brand-600 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-700 transition-colors min-h-[44px]`,children:[n===r?`All Set`:`Next`,(0,L.jsx)(el,{size:16})]})]})]})}function _1({onStart:e,onSkip:t}){return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center bg-black/60 backdrop-blur-[2px] p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-surface-200 bg-white p-8 shadow-2xl text-center`,style:{animation:`fadeSlideIn 0.3s ease-out`},children:[(0,L.jsx)(`div`,{className:`mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-full bg-brand-100`,children:(0,L.jsx)(iu,{className:`h-7 w-7 text-brand-600`})}),(0,L.jsx)(`h2`,{className:`text-xl font-bold text-surface-900`,children:`Welcome to Command Center!`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-surface-500`,children:`Here's a quick tour of the key features. It'll only take a minute.`}),(0,L.jsxs)(`div`,{className:`mt-6 flex gap-3`,children:[(0,L.jsx)(`button`,{onClick:t,className:`flex-1 rounded-lg border border-surface-200 py-2.5 text-sm font-medium text-surface-600 hover:bg-surface-50 transition-colors min-h-[44px]`,children:`Skip Tour`}),(0,L.jsx)(`button`,{onClick:e,className:`flex-1 rounded-lg bg-brand-600 py-2.5 text-sm font-semibold text-white hover:bg-brand-700 transition-colors min-h-[44px]`,children:`Take a Tour`})]})]})})}function v1({onComplete:e}){return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center bg-black/60 backdrop-blur-[2px] p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl border border-surface-200 bg-white p-8 shadow-2xl text-center`,style:{animation:`fadeSlideIn 0.3s ease-out`},children:[(0,L.jsx)(`div`,{className:`mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-full bg-success/10`,children:(0,L.jsx)(yc,{className:`h-7 w-7 text-success`})}),(0,L.jsx)(`h2`,{className:`text-xl font-bold text-surface-900`,children:`You're all set!`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-surface-500`,children:`You've seen the dashboard, sidebar navigation, integrations, revenue leaks, forecasts, optimizations, security settings, and company configuration. Connect your first integration to start tracking your data.`}),(0,L.jsx)(`button`,{onClick:e,className:`mt-6 w-full rounded-lg bg-brand-600 py-2.5 text-sm font-semibold text-white hover:bg-brand-700 transition-colors min-h-[44px]`,children:`Start Exploring`})]})})}var y1=[{title:`Your Dashboard`,description:`This is your command center. At a glance, you can see your portfolio overview — total organizations, active markets, revenue, and more.`,selector:`[data-testid="stats-grid"]`,position:`bottom`,path:`/app`},{title:`Navigate with the Sidebar`,description:`Everything you need is in this sidebar. Organizations, Analytics, Commissions, Integrations — all one click away.`,mobileDescription:`Navigate with the Menu — tap the hamburger icon to access all sections: Organizations, Analytics, Commissions, Integrations, and more.`,selector:`aside.fixed.left-0.top-0`,position:`right`,path:`/app`},{title:`Connect Your Data`,description:`Integrations are where the magic happens. Connect your CRM, job management, or accounting tools to start tracking revenue.`,mobileDescription:`Connect your CRM, job management, or accounting tools from the Integrations section (accessible via the menu) to start tracking revenue.`,selector:`[data-testid="page-content"]`,position:`top`,path:`/app/integrations`},{title:`Spot Revenue Leaks`,description:`Revenue Leaks identifies where you're leaving money on the table — missed quotes, slow follow-ups, and deals slipping through the cracks.`,mobileDescription:`Revenue Leaks (in the menu) identifies where you're leaving money on the table — missed quotes, slow follow-ups, and deals slipping through the cracks.`,selector:`[data-testid="page-content"]`,position:`top`,path:`/app/revenue-leaks`},{title:`Revenue Forecasts`,description:`Forecasts gives you AI-powered revenue projections based on your pipeline, historical performance, and market trends.`,mobileDescription:`Revenue Forecasts (in the menu) gives you AI-powered revenue projections based on your pipeline, historical performance, and market trends.`,selector:`[data-testid="page-content"]`,position:`top`,path:`/app/forecasts`},{title:`Optimization Moves`,description:`Actionable recommendations ranked by impact. See exactly what to fix first to move the needle on revenue and efficiency.`,mobileDescription:`Optimization Moves (in the menu) shows actionable recommendations ranked by impact — see what to fix first for revenue and efficiency.`,selector:`[data-testid="page-content"]`,position:`top`,path:`/app/optimization-moves`},{title:`Security Settings`,description:`Manage your security from Settings > Security: active sessions, two-factor authentication, API keys, and login history.`,mobileDescription:`Find Security Settings in Settings > Security (via the menu): active sessions, two-factor authentication, API keys, and login history.`,selector:`[data-testid="security-content"]`,position:`top`,path:`/app/settings?tab=security`},{title:`Company Configuration`,description:`Set your timezone, currency, fiscal year, and company details from Settings > Company. These defaults shape how all your data is displayed.`,mobileDescription:`Set your timezone, currency, fiscal year, and company details from Settings > Company (via the menu). These shape how all your data is displayed.`,selector:`[data-testid="company-content"]`,position:`top`,path:`/app/settings?tab=company`}],b1=`cs_onboarding_complete`;function x1({onComplete:e}){let t=ft(),[n,r]=(0,S.useState)(`welcome`),[i,a]=(0,S.useState)(0),[o,s]=(0,S.useState)(!1),[c,l]=(0,S.useState)(!1),u=y1[i],d=f1(!o&&!c?u?.selector:void 0,u?.position??`bottom`);(0,S.useEffect)(()=>{if(!(n!==`tour`||!u?.path)&&window.location.pathname!==new URL(u.path,window.location.origin).pathname){l(!0),t(u.path);let e=setTimeout(()=>l(!1),600);return()=>clearTimeout(e)}},[i,n,u?.path,t]),(0,S.useEffect)(()=>{let e=()=>s(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let f=(0,S.useCallback)(()=>{i<y1.length-1?a(e=>e+1):r(`done`)},[i]),p=(0,S.useCallback)(()=>{i>0&&a(e=>e-1)},[i]),m=(0,S.useCallback)(t=>{n!==`tour`||o||(t.key===`Escape`?e():t.key===`ArrowRight`||t.key===`Enter`?(t.preventDefault(),f()):t.key===`ArrowLeft`&&(t.preventDefault(),p()))},[n,o,i,e,f,p]);(0,S.useEffect)(()=>(window.addEventListener(`keydown`,m),()=>window.removeEventListener(`keydown`,m)),[m]),(0,S.useEffect)(()=>(document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=``}),[]);let h=(0,S.useCallback)(()=>{r(`tour`),a(0)},[]),g=(0,S.useCallback)(()=>{localStorage.setItem(b1,`true`),e()},[e]),_=(0,S.useCallback)(()=>{localStorage.setItem(b1,`true`),t(`/app`,{replace:!0}),e()},[e,t]);if(n===`welcome`)return(0,L.jsx)(_1,{onStart:h,onSkip:g});if(n===`done`)return(0,L.jsx)(v1,{onComplete:_});let v=o&&u.mobileDescription?u.mobileDescription:u.description;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`style`,{children:`
@keyframes fadeSlideIn {
from {
opacity: 0;
transform: translateY(8px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
`}),o?(0,L.jsx)(h1,{title:u.title,description:v,stepIndex:i+1,totalSteps:y1.length,onPrev:p,onNext:f,onSkip:g}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(p1,{targetRect:d}),(0,L.jsx)(g1,{title:u.title,description:u.description,stepIndex:i+1,totalSteps:y1.length,onPrev:p,onNext:f,onSkip:g,rect:d,position:u.position??`bottom`})]})]})}var S1=`cs_onboarding_complete`,C1={totalOrganizations:0,totalUsers:0,totalActive:0,totalSuspended:0,totalRevenue:0,avgRevenue:0,recentActivity:[]},w1=[{id:`profile`,label:`Complete your profile`,icon:Pu},{id:`integration`,label:`Connect your first integration`,icon:$l},{id:`goals`,label:`Set your revenue goals`,icon:yu},{id:`coaching`,label:`Explore Smart Coaching tips`,icon:Al}];function T1(){let{data:e,isLoading:t,isError:n}=R({queryKey:[`partner-overview`],queryFn:()=>WQ.getOverview(),retry:!1}),r=n?C1:e,{data:i}=R({queryKey:[`partner-profile`],queryFn:()=>WQ.getProfile()}),[a,o]=(0,S.useState)(!1),[s,c]=(0,S.useState)(!1);(0,S.useEffect)(()=>{if(!s&&(c(!0),!localStorage.getItem(S1))){if(sessionStorage.getItem(`cs_tour_pending`)){sessionStorage.removeItem(`cs_tour_pending`),o(!0);return}(r?.totalOrganizations===0||r===void 0)&&i?.is_active&&o(!0)}},[r,i,s]);let l=(0,S.useCallback)(()=>{localStorage.setItem(S1,`true`),o(!1)},[]);return t?(0,L.jsx)($,{title:`Dashboard`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Dashboard`,children:[a&&(0,L.jsx)(x1,{onComplete:l}),(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900 truncate`,children:[`Welcome back, `,i?.full_name?.split(` `)[0]||`Partner`]}),(0,L.jsx)(`p`,{className:`mt-1 text-surface-500`,children:`Here's what's happening with your portfolio`})]}),i?.is_active&&(r?.totalOrganizations===0||r===void 0)&&(0,L.jsx)(`div`,{className:`mb-6 rounded-lg border border-brand-200 bg-brand-50 p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-brand-100 text-brand-600`,children:(0,L.jsx)(Al,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-brand-900`,children:`Welcome to your Command Center!`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-brand-700`,children:`You're on a 7-day free trial. Connect your first integration to start seeing your data and unlock the full experience.`})]})]})}),(r?.totalOrganizations===0||r===void 0)&&(0,L.jsxs)(`div`,{className:`mb-8 rounded-xl border border-surface-200 bg-white p-8 text-center`,children:[(0,L.jsx)(`div`,{className:`mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-surface-100`,children:(0,L.jsx)(Kc,{className:`h-8 w-8 text-surface-400`})}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`No data yet`}),(0,L.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm text-surface-500`,children:`Connect your first integration to start seeing your data.`})]}),(r?.totalOrganizations===0||r===void 0)&&(0,L.jsxs)(`div`,{className:`mb-8 rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-surface-700`,children:`Get Started`}),(0,L.jsx)(`div`,{className:`space-y-3`,children:w1.map(e=>{let t=e.icon;return(0,L.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-100 text-surface-400`,children:(0,L.jsx)(rl,{className:`h-4 w-4`})}),(0,L.jsx)(t,{className:`h-4 w-4 shrink-0 text-surface-400`}),(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:e.label})]},e.id)})})]}),(0,L.jsx)(`div`,{className:`mb-6`,children:(0,L.jsx)(d1,{coachingPath:`/app/coaching`})}),(0,L.jsxs)(`div`,{"data-testid":`stats-grid`,className:`mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,L.jsx)(c1,{title:`Total Organizations`,value:r?.totalOrganizations??0,icon:Kc,iconBg:`bg-brand-100 text-brand-600`,href:`/app/organizations`}),(0,L.jsx)(c1,{title:`Active Markets`,value:r?.totalActive??0,icon:wu,iconBg:`bg-success/10 text-success`,change:`${r?.totalSuspended??0} suspended`,changeType:`neutral`,href:`/app/integrations`}),(0,L.jsx)(c1,{title:`Total Revenue`,value:`$${r?.totalRevenue?.toLocaleString()??0}`,icon:dl,iconBg:`bg-success/10 text-success`,href:`/app/commissions`}),(0,L.jsx)(c1,{title:`Avg. Revenue`,value:`$${r?.avgRevenue?.toLocaleString()??0}`,icon:Pu,iconBg:`bg-warning/10 text-warning`,href:`/app/coaching`})]}),r?.systemHealth&&(0,L.jsxs)(`div`,{className:`mb-8 rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700`,children:`System Health`}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Email Failures`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-surface-900`,children:r.systemHealth.emailFailures})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Integration Errors`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-surface-900`,children:r.systemHealth.integrationErrors})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Active Alerts`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-surface-900`,children:r.systemHealth.activeAlerts})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Last Sync`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-surface-900`,children:r.systemHealth.lastSync?new Date(r.systemHealth.lastSync).toLocaleDateString():`N/A`})]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700`,children:`Recent Activity`}),r?.recentActivity?.length===0?(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No recent activity`}):(0,L.jsx)(`div`,{className:`space-y-3`,children:r?.recentActivity?.map(e=>(0,L.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg p-3 hover:bg-surface-50`,children:[(0,L.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 items-center justify-center rounded-full bg-brand-100 text-brand-600`,children:(0,L.jsx)(`span`,{className:`text-xs`,children:`•`})}),(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:e.description}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.timestamp?new Date(e.timestamp).toLocaleString():`Recent`})]})]},e.id))})]})]})}function E1(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(null),{hasCompanyPermission:i}=W(),{data:a,isLoading:o}=R({queryKey:[`organizations`],queryFn:()=>WQ.getOrganizations()}),s=a?.items??[],c=i(`create_org`),l=s.filter(t=>t.name.toLowerCase().includes(e.toLowerCase())||t.location.toLowerCase().includes(e.toLowerCase()));return o?(0,L.jsx)($,{title:`Organizations`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Organizations`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900 truncate`,children:`Organizations`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-surface-500`,children:[s.length,` organization`,s.length===1?``:`s`,` in your portfolio`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[c&&(0,L.jsxs)(`button`,{className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 transition-colors min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`New Organization`]}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search organizations...`,className:`w-full rounded-lg border border-surface-300 py-2.5 pl-9 pr-4 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100 sm:w-72`})]})]})]}),l.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(Kc,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:e?`No organizations match your search`:`No organizations yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:e?`Try a different search term`:`Add your first organization to get started`})]}):(0,L.jsx)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:l.map(e=>(0,L.jsxs)(`div`,{onClick:()=>r(n===e.id?null:e.id),className:`cursor-pointer rounded-xl border bg-white p-5 transition-all hover:shadow-md ${n===e.id?`border-brand-300 ring-2 ring-brand-100`:`border-surface-200`}`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-brand-100 text-brand-600`,children:(0,L.jsx)(Kc,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`font-semibold text-surface-900`,children:e.name}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.location||`No location`})]})]}),(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${e.status===`active`?`bg-success/10 text-success`:`bg-surface-200 text-surface-600`}`,children:e.status})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Revenue`}),(0,L.jsxs)(`p`,{className:`text-sm font-semibold text-surface-900`,children:[`$`,e.annual_revenue.toLocaleString()]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Growth`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[e.revenue_growth>=0?(0,L.jsx)(Rc,{className:`h-3 w-3 text-success`}):(0,L.jsx)(Nc,{className:`h-3 w-3 text-error`}),(0,L.jsxs)(`p`,{className:`text-sm font-semibold ${e.revenue_growth>=0?`text-success`:`text-error`}`,children:[Math.abs(e.revenue_growth).toFixed(1),`%`]})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Projects`}),(0,L.jsx)(`p`,{className:`text-sm font-semibold text-surface-900`,children:e.active_projects})]})]}),n===e.id&&(0,L.jsxs)(`div`,{className:`mt-4 animate-fade-in rounded-lg bg-surface-50 p-4`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Tier:`}),` `,(0,L.jsx)(`span`,{className:`font-medium capitalize`,children:e.tier})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Industry:`}),` `,(0,L.jsx)(`span`,{className:`font-medium`,children:e.industry})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Target:`}),` `,(0,L.jsxs)(`span`,{className:`font-medium`,children:[`$`,e.target_revenue.toLocaleString()]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Commission:`}),` `,(0,L.jsxs)(`span`,{className:`font-medium`,children:[(e.commission_rate*100).toFixed(0),`%`]})]})]}),e.website&&(0,L.jsxs)(`a`,{href:e.website,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`mt-3 inline-flex items-center gap-1 rounded-md px-2 py-1.5 text-sm font-medium text-brand-600 hover:text-brand-700 hover:bg-brand-50 transition-colors min-h-[44px]`,children:[`Visit Website `,(0,L.jsx)(pl,{className:`h-3 w-3`})]})]})]},e.id))})]})}function D1(){let{data:e,isLoading:t}=R({queryKey:[`commissions`],queryFn:()=>WQ.getCommissions()});if(t)return(0,L.jsx)($,{title:`Commissions`,children:(0,L.jsx)(FQ,{})});let n=e?.total_commission??0,r=e?.pending??0,i=e?.paid??0;return(0,L.jsxs)($,{title:`Commissions`,children:[(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900 truncate`,children:`Commissions`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Track your partner commissions and payouts`})]}),(0,L.jsxs)(`div`,{className:`mb-8 grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,L.jsx)(c1,{title:`Total Commission`,value:`$${n.toLocaleString(void 0,{maximumFractionDigits:0})}`,icon:dl,iconBg:`bg-brand-100 text-brand-600`}),(0,L.jsx)(c1,{title:`Pending`,value:`$${r.toLocaleString(void 0,{maximumFractionDigits:0})}`,icon:Yc,iconBg:`bg-warning/10 text-warning`}),(0,L.jsx)(c1,{title:`Paid`,value:`$${i.toLocaleString(void 0,{maximumFractionDigits:0})}`,icon:wu,iconBg:`bg-success/10 text-success`})]}),(0,L.jsxs)(`div`,{className:`mb-8 rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700`,children:`Payout Schedule`}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Next Payout Date`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-surface-900`,children:e?.next_payout_date?new Date(e.next_payout_date).toLocaleDateString():`N/A`})]}),(0,L.jsxs)(`div`,{className:`sm:text-right`,children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Commission Rate`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-surface-900`,children:e?.commission_rate?`${(e.commission_rate*100).toFixed(0)}%`:`—`})]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700`,children:`Monthly Breakdown`}),(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Organization`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500`,children:`Monthly Revenue`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500`,children:`Commission`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500`,children:`Status`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:e?.monthly_breakdown?.map(e=>(0,L.jsxs)(`tr`,{className:`hover:bg-surface-50 min-h-[44px]`,children:[(0,L.jsx)(`td`,{className:`py-3 font-medium text-surface-900`,children:e.organization_name}),(0,L.jsxs)(`td`,{className:`py-3 text-right text-surface-600`,children:[`$`,e.monthly_revenue.toLocaleString(void 0,{maximumFractionDigits:0})]}),(0,L.jsxs)(`td`,{className:`py-3 text-right font-medium text-surface-900`,children:[`$`,e.commission_amount.toLocaleString(void 0,{maximumFractionDigits:0})]}),(0,L.jsx)(`td`,{className:`py-3 text-right`,children:(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${e.status===`paid`?`bg-success/10 text-success`:`bg-warning/10 text-warning`}`,children:e.status})})]},e.organization_id))})]})})]})]})}function O1(){let{data:e,isLoading:t}=R({queryKey:[`admin-overview`],queryFn:()=>KQ.getOverview()});return t?(0,L.jsx)($,{title:`Admin Dashboard`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Admin Dashboard`,children:[(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`System Overview`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Platform-wide metrics and health status`})]}),(0,L.jsx)(`div`,{className:`mb-6`,children:(0,L.jsx)(d1,{coachingPath:`/admin/coaching`})}),(0,L.jsxs)(`div`,{className:`mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,L.jsx)(c1,{title:`Total Organizations`,value:e?.totalOrganizations??0,icon:Kc,iconBg:`bg-brand-100 text-brand-600`,href:`/admin/organizations`}),(0,L.jsx)(c1,{title:`Active Organizations`,value:e?.totalActive??0,icon:wu,iconBg:`bg-success/10 text-success`,change:`${e?.totalSuspended??0} suspended`,changeType:`neutral`,href:`/admin/organizations`}),(0,L.jsx)(c1,{title:`Total Users`,value:e?.totalUsers??0,icon:Pu,iconBg:`bg-warning/10 text-warning`,href:`/admin/users`}),(0,L.jsx)(c1,{title:`Total Revenue`,value:`$${e?.totalRevenue?.toLocaleString()??0}`,icon:dl,iconBg:`bg-brand-100 text-brand-600`})]}),e?.systemHealth&&(0,L.jsxs)(`div`,{className:`mb-8 rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,L.jsx)(jc,{className:`h-4 w-4 text-warning`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-700`,children:`System Health`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Email Failures`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold ${e.systemHealth.emailFailures>0?`text-error`:`text-success`}`,children:e.systemHealth.emailFailures})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Integration Errors`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold ${e.systemHealth.integrationErrors>0?`text-error`:`text-success`}`,children:e.systemHealth.integrationErrors})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Active Alerts`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold ${e.systemHealth.activeAlerts>0?`text-error`:`text-success`}`,children:e.systemHealth.activeAlerts})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Last Sync`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-surface-900`,children:e.systemHealth.lastSync?new Date(e.systemHealth.lastSync).toLocaleDateString():`N/A`})]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700`,children:`Recent Activity`}),e?.recentActivity?.length===0?(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No recent activity`}):(0,L.jsx)(`div`,{className:`space-y-3`,children:e?.recentActivity?.map(e=>(0,L.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg p-3 hover:bg-surface-50`,children:[(0,L.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 items-center justify-center rounded-full bg-brand-100 text-brand-600`,children:(0,L.jsx)(`span`,{className:`text-xs`,children:`•`})}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:e.description}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-500`,children:[e.timestamp?new Date(e.timestamp).toLocaleString():`Recent`,` · `,e.user_id||`System`]})]})]},e.id))})]})]})}function k1(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(!1),[i,a]=(0,S.useState)(null),[o,s]=(0,S.useState)(null),c=ft(),l=ci(),{data:u,isLoading:d}=R({queryKey:[`admin-organizations`],queryFn:()=>KQ.getOrganizations()}),f=u?.items??[],p=z({mutationFn:e=>KQ.createOrganization(e),onSuccess:()=>{l.invalidateQueries({queryKey:[`admin-organizations`]}),r(!1)}}),m=z({mutationFn:e=>KQ.deleteOrganization(e),onSuccess:()=>{l.invalidateQueries({queryKey:[`admin-organizations`]}),a(null)},onError:e=>{s(e?.response?.data?.error||e?.message||`Failed to delete organization`)}}),h=f.filter(t=>t.name.toLowerCase().includes(e.toLowerCase())||t.location.toLowerCase().includes(e.toLowerCase()));return d?(0,L.jsx)($,{title:`Organizations`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Organizations`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`All Organizations`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-surface-500`,children:[f.length,` organization`,f.length===1?``:`s`,` across all partners`]})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search organizations...`,className:`w-full rounded-lg border border-surface-300 py-2.5 pl-9 pr-4 text-sm outline-none focus:border-brand-500 sm:w-72`})]}),(0,L.jsxs)(`button`,{onClick:()=>r(!0),className:`inline-flex items-center justify-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px] w-full sm:w-auto`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Add Organization`]})]})]}),h.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(Kc,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:e?`No organizations match your search`:`No organizations yet`})]}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white`,children:(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 pl-5 text-left font-medium text-surface-500`,children:`Organization`}),(0,L.jsx)(`th`,{className:`pb-3 px-4 text-left font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`pb-3 px-4 text-right font-medium text-surface-500`,children:`Revenue`}),(0,L.jsx)(`th`,{className:`pb-3 px-4 text-right font-medium text-surface-500`,children:`Growth`}),(0,L.jsx)(`th`,{className:`pb-3 px-4 text-center font-medium text-surface-500 pr-5`,children:`Projects`}),(0,L.jsx)(`th`,{className:`pb-3 pr-5 w-10`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:h.map(e=>(0,L.jsxs)(`tr`,{className:`hover:bg-surface-50 cursor-pointer`,onClick:()=>c(`/admin/organizations/${e.id}`),children:[(0,L.jsx)(`td`,{className:`py-3 pl-5`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-brand-100 text-brand-600`,children:(0,L.jsx)(Kc,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`font-medium text-surface-900 truncate`,children:e.name}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.location||`No location`})]})]})}),(0,L.jsx)(`td`,{className:`py-3 px-4`,children:(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${e.status===`active`?`bg-success/10 text-success`:`bg-surface-200 text-surface-600`}`,children:e.status})}),(0,L.jsxs)(`td`,{className:`py-3 px-4 text-right font-medium text-surface-900`,children:[`$`,e.annual_revenue.toLocaleString()]}),(0,L.jsx)(`td`,{className:`py-3 px-4 text-right`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[e.revenue_growth>=0?(0,L.jsx)(Rc,{className:`h-3 w-3 text-success`}):(0,L.jsx)(Nc,{className:`h-3 w-3 text-error`}),(0,L.jsxs)(`span`,{className:`text-sm font-medium ${e.revenue_growth>=0?`text-success`:`text-error`}`,children:[Math.abs(e.revenue_growth).toFixed(1),`%`]})]})}),(0,L.jsx)(`td`,{className:`py-3 px-4 text-center text-surface-600 pr-5`,children:e.active_projects}),(0,L.jsx)(`td`,{className:`py-3 pr-5 text-right`,children:(0,L.jsx)(`button`,{onClick:t=>{t.stopPropagation(),s(null),a(e.id)},className:`inline-flex items-center justify-center rounded-md p-1.5 text-surface-400 hover:text-red-600 hover:bg-red-50 transition-colors`,title:`Delete organization`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})})]},e.id))})]})})}),n&&(0,L.jsx)(A1,{onClose:()=>r(!1),onCreate:p.mutate,isPending:p.isPending,error:p.error?.message??null}),i&&(0,L.jsx)(j1,{org:h.find(e=>e.id===i),onConfirm:()=>m.mutate(i),onClose:()=>{a(null),s(null)},isPending:m.isPending,error:o})]})}function A1({onClose:e,onCreate:t,isPending:n,error:r}){let[i,a]=(0,S.useState)(``),[o,s]=(0,S.useState)(``),[c,l]=(0,S.useState)(``),[u,d]=(0,S.useState)(``),[f,p]=(0,S.useState)(``),[m,h]=(0,S.useState)(``),[g,_]=(0,S.useState)(``),[v,y]=(0,S.useState)(``),[b,x]=(0,S.useState)(``),[C,w]=(0,S.useState)(``);return(0,yS.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:e}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-lg max-h-[90vh] overflow-y-auto rounded-xl bg-white shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 p-5`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Add Organization`}),(0,L.jsx)(`button`,{onClick:e,className:`rounded-md p-1 text-surface-400 hover:text-surface-600`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),t({name:i,industry:o||void 0,annual_revenue:c?parseFloat(c):void 0,address:u||void 0,city:f||void 0,state:m||void 0,postal_code:g||void 0,country:v||void 0,phone:b||void 0,website:C||void 0})},className:`p-5 space-y-4`,children:[r&&(0,L.jsx)(`div`,{className:`rounded-lg bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700`,children:r}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Organization Name *`}),(0,L.jsx)(`input`,{type:`text`,required:!0,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`Acme Corp`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Industry`}),(0,L.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`e.g. Roofing, HVAC, Plumbing`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Annual Revenue ($)`}),(0,L.jsx)(`input`,{type:`number`,value:c,onChange:e=>l(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`500000`,min:`0`,step:`1000`})]}),(0,L.jsxs)(`div`,{className:`border-t border-surface-200 pt-4 space-y-3`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide`,children:`Contact & Address (optional)`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Phone`}),(0,L.jsx)(`input`,{type:`tel`,value:b,onChange:e=>x(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`(555) 123-4567`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Website`}),(0,L.jsx)(`input`,{type:`url`,value:C,onChange:e=>w(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`https://example.com`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Address`}),(0,L.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`123 Main St`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`City`}),(0,L.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`New York`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`State`}),(0,L.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`NY`})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Postal Code`}),(0,L.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`10001`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Country`}),(0,L.jsx)(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`US`})]})]})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-3 pt-4 border-t border-surface-200`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:e,className:`rounded-lg px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-100 min-h-[44px]`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`submit`,disabled:n,className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:[n&&(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),`Create Organization`]})]})]})]})]}),document.body)}function j1({org:e,onConfirm:t,onClose:n,isPending:r,error:i}){return(0,yS.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[300] flex items-center justify-center p-4`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:n}),(0,L.jsx)(`div`,{className:`relative w-full max-w-md rounded-xl bg-white shadow-xl`,children:(0,L.jsxs)(`div`,{className:`p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-red-100`,children:(0,L.jsx)(jc,{className:`h-5 w-5 text-red-600`})}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-surface-900`,children:`Delete Organization`})]}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-600 mb-2`,children:[`Are you sure you want to delete `,(0,L.jsx)(`span`,{className:`font-semibold text-surface-900`,children:e.name}),`?`]}),(0,L.jsx)(`div`,{className:`rounded-lg bg-amber-50 border border-amber-200 px-4 py-3 text-xs text-amber-800 mb-4`,children:`This will permanently remove the organization and all associated data including users, projects, and invoices. This action cannot be undone.`}),i&&(0,L.jsx)(`div`,{className:`rounded-lg bg-red-50 border border-red-200 px-4 py-3 text-sm text-red-700 mb-4`,children:i}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:`rounded-lg px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-100 disabled:opacity-50`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,onClick:t,disabled:r,className:`inline-flex items-center gap-2 rounded-lg bg-red-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-red-700 disabled:opacity-50`,children:[r&&(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),`Delete Organization`]})]})]})})]}),document.body)}function M1(){let{orgId:e}=mt(),t=ft(),{data:n,isLoading:r}=R({queryKey:[`admin-organizations`],queryFn:()=>KQ.getOrganizations()}),{data:i,isLoading:a}=R({queryKey:[`admin-users`],queryFn:()=>KQ.getUsers()}),o=n?.items.find(t=>String(t.id)===e),s=i?.items??[],c=o?s.filter(e=>e.fullName.toLowerCase().includes(o.name.toLowerCase())||e.email.toLowerCase().includes(o.name.toLowerCase())||e.email.toLowerCase().includes((o.slug||``).toLowerCase())):[];return r||a?(0,L.jsx)($,{title:`Organization`,children:(0,L.jsx)(FQ,{})}):o?(0,L.jsxs)($,{title:o.name,children:[(0,L.jsxs)(`button`,{onClick:()=>t(`/admin/organizations`),className:`mb-4 inline-flex items-center gap-1 text-sm text-brand-600 hover:text-brand-700`,children:[(0,L.jsx)(Fc,{className:`h-4 w-4`}),`Back to Organizations`]}),(0,L.jsx)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,L.jsx)(`div`,{className:`flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-lg bg-brand-50 text-brand-600`,children:(0,L.jsx)(Kc,{className:`h-6 w-6`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:o.name}),(0,L.jsx)(N1,{status:o.status})]}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-surface-500`,children:[o.industry||`No industry set`,o.location?` · ${o.location}`:``]})]})]})}),(0,L.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,L.jsx)(P1,{icon:(0,L.jsx)(dl,{className:`h-5 w-5`}),label:`Annual Revenue`,value:`$${o.annual_revenue.toLocaleString()}`}),(0,L.jsx)(P1,{icon:(0,L.jsx)(wu,{className:`h-5 w-5`}),label:`Revenue Growth`,value:`${o.revenue_growth>=0?`+`:``}${o.revenue_growth.toFixed(1)}%`,positive:o.revenue_growth>=0}),(0,L.jsx)(P1,{icon:(0,L.jsx)(Gc,{className:`h-5 w-5`}),label:`Active Projects`,value:String(o.active_projects)}),(0,L.jsx)(P1,{icon:(0,L.jsx)(Pu,{className:`h-5 w-5`}),label:`Commission Rate`,value:`${o.commission_rate}%`})]}),(0,L.jsxs)(`div`,{className:`mb-6 rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h2`,{className:`mb-4 text-sm font-semibold text-surface-700`,children:`Organization Details`}),(0,L.jsxs)(`dl`,{className:`grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,L.jsx)(F1,{icon:(0,L.jsx)(Kc,{className:`h-4 w-4`}),label:`Name`,children:o.name}),(0,L.jsx)(F1,{icon:(0,L.jsx)(gl,{className:`h-4 w-4`}),label:`Industry`,children:o.industry||`—`}),(0,L.jsx)(F1,{icon:(0,L.jsx)(vu,{className:`h-4 w-4`}),label:`Tier`,children:o.tier||`—`}),(0,L.jsx)(F1,{icon:(0,L.jsx)(vu,{className:`h-4 w-4`}),label:`Size`,children:o.size||`—`}),(0,L.jsx)(F1,{icon:(0,L.jsx)(vu,{className:`h-4 w-4`}),label:`Slug`,children:o.slug||`—`}),(0,L.jsx)(F1,{icon:(0,L.jsx)(Il,{className:`h-4 w-4`}),label:`Location`,children:o.location||`—`}),(0,L.jsx)(F1,{icon:(0,L.jsx)(bl,{className:`h-4 w-4`}),label:`Website`,children:o.website?(0,L.jsxs)(`a`,{href:o.website.startsWith(`http`)?o.website:`https://${o.website}`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-brand-600 hover:text-brand-700`,children:[o.website,(0,L.jsx)(Ml,{className:`h-3 w-3`})]}):`—`}),(0,L.jsx)(F1,{icon:(0,L.jsx)(Yc,{className:`h-4 w-4`}),label:`Last Updated`,children:o.last_updated?new Date(o.last_updated).toLocaleDateString(`en-US`,{year:`numeric`,month:`long`,day:`numeric`}):`—`})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white`,children:[(0,L.jsxs)(`div`,{className:`border-b border-surface-200 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Pu,{className:`h-5 w-5 text-surface-500`}),(0,L.jsxs)(`h2`,{className:`text-sm font-semibold text-surface-700`,children:[`Related Users (`,c.length,`)`]})]}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-400`,children:`Users associated with this organization`})]}),c.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12`,children:[(0,L.jsx)(Nu,{className:`h-10 w-10 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm font-medium text-surface-500`,children:`No related users found`})]}):(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-t border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 pl-6 text-left font-medium text-surface-500`,children:`User`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Role`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500 pr-6`,children:`Last Login`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:c.map(e=>(0,L.jsxs)(`tr`,{className:`hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`py-3 pl-6`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-brand-100 text-xs font-semibold text-brand-700`,children:e.fullName.charAt(0).toUpperCase()}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`font-medium text-surface-900 truncate`,children:e.fullName}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500 truncate`,children:e.email})]})]})}),(0,L.jsxs)(`td`,{className:`py-3`,children:[(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium bg-brand-50 text-brand-700`,children:e.role}),e.companyRole&&(0,L.jsx)(`span`,{className:`ml-2 inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium bg-surface-100 text-surface-600`,children:e.companyRole})]}),(0,L.jsx)(`td`,{className:`py-3`,children:(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${e.status===`active`?`bg-success/10 text-success`:`bg-surface-200 text-surface-600`}`,children:e.status})}),(0,L.jsx)(`td`,{className:`py-3 text-right text-surface-500 pr-6`,children:e.lastLogin?new Date(e.lastLogin).toLocaleDateString():`Never`})]},e.id))})]})})]})]}):(0,L.jsx)($,{title:`Organization`,children:(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16`,children:[(0,L.jsx)(Kc,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`Organization not found`}),(0,L.jsxs)(`button`,{onClick:()=>t(`/admin/organizations`),className:`mt-4 inline-flex items-center gap-2 text-sm text-brand-600 hover:text-brand-700`,children:[(0,L.jsx)(Fc,{className:`h-4 w-4`}),`Back to Organizations`]})]})})}function N1({status:e}){return(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${e===`active`?`bg-success/10 text-success`:`bg-surface-200 text-surface-600`}`,children:e})}function P1({icon:e,label:t,value:n,positive:r}){return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-surface-400`,children:[e,(0,L.jsx)(`span`,{className:`text-xs font-medium`,children:t})]}),(0,L.jsx)(`p`,{className:`mt-2 text-lg font-bold ${r===!0?`text-success`:r===!1?`text-error`:`text-surface-900`}`,children:n})]})}function F1({icon:e,label:t,children:n}){return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`dt`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium text-surface-400`,children:[e,t]}),(0,L.jsx)(`dd`,{className:`text-sm text-surface-700`,children:n})]})}function I1(){let{data:e,isLoading:t}=R({queryKey:[`admin-analytics`],queryFn:()=>KQ.getAnalytics()});return t?(0,L.jsx)($,{title:`Analytics`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Analytics`,children:[(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Analytics`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Revenue trends, growth metrics, and portfolio performance`})]}),(0,L.jsxs)(`div`,{className:`mb-8 grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,L.jsx)(c1,{title:`Total Revenue`,value:`$${e?.totalRevenue?.toLocaleString()??0}`,icon:dl,iconBg:`bg-brand-100 text-brand-600`}),(0,L.jsx)(c1,{title:`Avg. Revenue`,value:`$${e?.avgRevenue?.toLocaleString()??0}`,icon:wu,iconBg:`bg-success/10 text-success`}),(0,L.jsx)(c1,{title:`Organizations`,value:e?.totalOrganizations??0,icon:Kc,iconBg:`bg-warning/10 text-warning`})]}),(0,L.jsxs)(`div`,{className:`mb-8 rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(mc,{className:`h-4 w-4 text-surface-500`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-700`,children:`Revenue Trend`})]}),e?.revenueTrend?.length===0?(0,L.jsx)(`div`,{className:`flex h-48 sm:h-64 items-center justify-center`,children:(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Revenue trend data coming soon`})}):(0,L.jsx)(`div`,{className:`h-48 sm:h-64`,children:(0,L.jsx)(`div`,{className:`flex h-full items-end gap-2`,children:e?.revenueTrend?.map(t=>(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`div`,{className:`w-full rounded-t bg-brand-200`,style:{height:`${Math.max(t.revenue/Math.max(...e.revenueTrend.map(e=>e.revenue),1)*100,4)}%`}}),(0,L.jsx)(`p`,{className:`mt-1 text-center text-[10px] sm:text-xs text-surface-500`,children:t.month})]},t.month))})})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-surface-700`,children:`Top Organizations by Revenue`}),e?.topOrganizations?.length===0?(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No organization data yet`}):(0,L.jsx)(`div`,{className:`space-y-3`,children:e?.topOrganizations?.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-4 rounded-lg p-3 hover:bg-surface-50`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-full bg-brand-100 text-xs font-semibold text-brand-600`,children:t+1}),(0,L.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900 truncate`,children:e.name})}),(0,L.jsx)(`div`,{className:`text-right`,children:(0,L.jsxs)(`p`,{className:`text-sm font-semibold text-surface-900`,children:[`$`,e.revenue.toLocaleString()]})})]},e.id))})]})]})}var L1=[{value:`super_admin`,label:`Super Admin`,color:`bg-red-100 text-red-700`},{value:`admin`,label:`Admin`,color:`bg-orange-100 text-orange-700`},{value:`partner`,label:`Partner`,color:`bg-blue-100 text-blue-700`},{value:`user`,label:`User`,color:`bg-gray-100 text-gray-600`}],R1=[{value:`owner`,label:`Owner`,color:`bg-purple-100 text-purple-700`},{value:`admin`,label:`Admin`,color:`bg-indigo-100 text-indigo-700`},{value:`manager`,label:`Manager`,color:`bg-emerald-100 text-emerald-700`},{value:`rep`,label:`Rep`,color:`bg-amber-100 text-amber-700`},{value:`viewer`,label:`Viewer`,color:`bg-slate-100 text-slate-600`}],z1=[{value:``,label:`All Roles`},{value:`super_admin`,label:`Super Admin`},{value:`admin`,label:`Admin`},{value:`partner`,label:`Partner`},{value:`user`,label:`User`}];function B1({userId:e,currentRole:t,onRoleChange:n}){let[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(null),s=(0,S.useRef)(null),c=ci(),l=z({mutationFn:({userId:e,role:t})=>KQ.updateUserRole(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[`admin-users`]}),i(!1)}});(0,S.useEffect)(()=>{r&&s.current&&o(s.current.getBoundingClientRect())},[r]);let u=r=>{r!==t&&(n(e,r),l.mutate({userId:e,role:r}))},d=L1.find(e=>e.value===t),f=(0,L.jsx)(`div`,{className:`w-40 rounded-lg border border-surface-200 bg-white shadow-lg py-1`,style:{position:`fixed`,top:a?a.bottom+4:0,left:a?a.right-160:0,zIndex:100},children:L1.map(e=>(0,L.jsxs)(`button`,{onClick:()=>u(e.value),className:`flex w-full items-center gap-2 px-3 py-2 text-sm hover:bg-surface-50`,children:[t===e.value&&(0,L.jsx)(Xc,{className:`h-3.5 w-3.5 text-brand-600`}),(0,L.jsx)(`span`,{className:t===e.value?`text-brand-700 font-medium`:`text-surface-700`,children:e.label})]},e.value))});return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`button`,{ref:s,onClick:()=>i(!r),disabled:l.isPending,className:`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium hover:opacity-80 disabled:opacity-50 min-w-[80px] justify-center`,children:l.isPending?(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`rounded-full px-2.5 py-0.5 text-xs font-medium ${d?.color||`bg-gray-100 text-gray-600`}`,children:d?.label||t}),(0,L.jsx)(Zc,{className:`h-3 w-3 text-surface-400`})]})}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-[99]`,onClick:()=>i(!1)}),(0,yS.createPortal)(f,document.body)]})]})}function V1({userId:e,currentRole:t,onRoleChange:n}){let[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(null),s=(0,S.useRef)(null),c=ci(),{data:l}=R({queryKey:[`admin-organizations`],queryFn:KQ.getOrganizations,enabled:!t&&r}),u=z({mutationFn:({userId:e,role:t,companyId:n})=>KQ.updateCompanyRole(e,t,n),onSuccess:()=>{c.invalidateQueries({queryKey:[`admin-users`]}),i(!1)}});(0,S.useEffect)(()=>{r&&s.current&&o(s.current.getBoundingClientRect())},[r]);let d=(r,i)=>{r===t&&!i||(n(e,r,i),u.mutate({userId:e,role:r,companyId:i}))},f=R1.find(e=>e.value===t);if(!t){let e=l?.items||[];return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsxs)(`button`,{ref:s,onClick:()=>i(!r),disabled:e.length===0&&!l,className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium bg-brand-50 text-brand-700 hover:bg-brand-100 border border-brand-200 transition-colors`,children:[(0,L.jsx)(Kc,{className:`h-3 w-3`}),`Assign Company`,(0,L.jsx)(Zc,{className:`h-3 w-3`})]}),r&&e.length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-[99]`,onClick:()=>i(!1)}),(0,yS.createPortal)((0,L.jsxs)(`div`,{className:`w-64 rounded-lg border border-surface-200 bg-white shadow-lg py-1`,style:{position:`fixed`,top:a?a.bottom+4:0,left:a?a.left:0,zIndex:100},children:[(0,L.jsx)(`p`,{className:`px-3 py-1.5 text-xs font-semibold text-surface-500 uppercase tracking-wide`,children:`Select Company & Role`}),e.map(e=>(0,L.jsxs)(`div`,{className:`border-t border-surface-100`,children:[(0,L.jsx)(`p`,{className:`px-3 py-1 text-xs font-medium text-surface-700`,children:e.name}),R1.map(t=>(0,L.jsx)(`button`,{onClick:()=>d(t.value,e.id),className:`flex w-full items-center gap-2 px-3 py-1.5 text-sm hover:bg-surface-50`,children:(0,L.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-xs ${t.color}`,children:t.label})},t.value))]},e.id))]}),document.body)]})]})}let p=(0,L.jsx)(`div`,{className:`w-40 rounded-lg border border-surface-200 bg-white shadow-lg py-1`,style:{position:`fixed`,top:a?a.bottom+4:0,left:a?a.right-160:0,zIndex:100},children:R1.map(e=>(0,L.jsxs)(`button`,{onClick:()=>d(e.value),className:`flex w-full items-center gap-2 px-3 py-2 text-sm hover:bg-surface-50`,children:[t===e.value&&(0,L.jsx)(Xc,{className:`h-3.5 w-3.5 text-brand-600`}),(0,L.jsx)(`span`,{className:t===e.value?`text-brand-700 font-medium`:`text-surface-700`,children:e.label})]},e.value))});return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`button`,{ref:s,onClick:()=>i(!r),disabled:u.isPending,className:`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium hover:opacity-80 disabled:opacity-50 min-w-[80px] justify-center`,children:u.isPending?(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`rounded-full px-2.5 py-0.5 text-xs font-medium ${f?.color||`bg-gray-100 text-gray-600`}`,children:f?.label||t}),(0,L.jsx)(Zc,{className:`h-3 w-3 text-surface-400`})]})}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-[99]`,onClick:()=>i(!1)}),(0,yS.createPortal)(p,document.body)]})]})}function H1(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(``),[i,a]=(0,S.useState)(!1),[o,s]=(0,S.useState)(null),{user:c}=W(),l=ci(),{data:u,isLoading:d}=R({queryKey:[`admin-users`,n],queryFn:()=>KQ.getUsers({role:n||void 0})}),f=u?.items??[],p=f.filter(t=>t.email.toLowerCase().includes(e.toLowerCase())||t.fullName.toLowerCase().includes(e.toLowerCase())),m=z({mutationFn:e=>KQ.deleteUser(e),onSuccess:()=>{l.invalidateQueries({queryKey:[`admin-users`]}),s(null)}}),h=z({mutationFn:e=>KQ.createUser(e),onSuccess:()=>{l.invalidateQueries({queryKey:[`admin-users`]}),a(!1)}}),g=(0,S.useCallback)((e,t)=>{},[]),_=(0,S.useCallback)((e,t,n)=>{},[]);return d?(0,L.jsx)($,{title:`Users`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Users`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Users`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-surface-500`,children:[f.length,` user`,f.length===1?``:`s`,` in the system`]})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`select`,{value:n,onChange:e=>r(e.target.value),className:`rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px] w-full sm:w-40`,children:z1.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search users...`,className:`w-full border border-surface-300 pl-9 pr-3 py-2.5 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px] w-full sm:w-56`})]})]}),(0,L.jsxs)(`button`,{onClick:()=>a(!0),className:`inline-flex items-center justify-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px] w-full sm:w-auto`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Add User`]})]})]}),p.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(Nu,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:e||n?`No users match your filters`:`No users yet`})]}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white`,children:(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 pl-5 text-left font-medium text-surface-500`,children:`User`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Platform Role`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Company Role`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500 pr-2`,children:`Last Login`}),(0,L.jsx)(`th`,{className:`pb-3 pr-5 w-10`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:p.map(e=>(0,L.jsxs)(`tr`,{className:`hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`py-3 pl-5`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-brand-100 text-xs font-semibold text-brand-700`,children:e.fullName.charAt(0).toUpperCase()}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900 truncate`,children:e.fullName}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500 truncate`,children:e.email})]})]})}),(0,L.jsx)(`td`,{className:`py-3`,children:(0,L.jsx)(B1,{userId:e.id,currentRole:e.role,onRoleChange:g})}),(0,L.jsx)(`td`,{className:`py-3`,children:(0,L.jsx)(V1,{userId:e.id,currentRole:e.companyRole??null,onRoleChange:_})}),(0,L.jsx)(`td`,{className:`py-3`,children:(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${e.status===`active`?`bg-success/10 text-success`:`bg-surface-200 text-surface-600`}`,children:e.status})}),(0,L.jsx)(`td`,{className:`py-3 text-right text-surface-500 pr-2`,children:e.lastLogin?new Date(e.lastLogin).toLocaleDateString():`Never`}),(0,L.jsx)(`td`,{className:`py-3 pr-5 text-right`,children:e.id!==c?.id&&(0,L.jsx)(`button`,{onClick:()=>s(e.id),className:`inline-flex items-center justify-center rounded-md p-1.5 text-surface-400 hover:text-red-600 hover:bg-red-50 transition-colors`,title:`Delete user`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})})]},e.id))})]})})}),i&&(0,L.jsx)(U1,{onClose:()=>a(!1),onCreate:h.mutate,isPending:h.isPending}),o&&(0,L.jsx)(W1,{user:p.find(e=>e.id===o),onConfirm:()=>m.mutate(o),onClose:()=>s(null),isPending:m.isPending})]})}function U1({onClose:e,onCreate:t,isPending:n}){let[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(``),[l,u]=(0,S.useState)(`user`),[d,f]=(0,S.useState)(``),[p,m]=(0,S.useState)(`member`);return(0,yS.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:e}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-md rounded-xl bg-white shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 p-5`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Add User`}),(0,L.jsx)(`button`,{onClick:e,className:`rounded-md p-1 text-surface-400 hover:text-surface-600`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),t({email:r,full_name:a,password:s,role:l,company_name:d,company_role:d?p:void 0})},className:`p-5 space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Email *`}),(0,L.jsx)(`input`,{type:`email`,required:!0,value:r,onChange:e=>i(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`user@example.com`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Full Name`}),(0,L.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`John Doe`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Password *`}),(0,L.jsx)(`input`,{type:`password`,required:!0,minLength:8,value:s,onChange:e=>c(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`Min 8 characters`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Platform Role`}),(0,L.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,children:L1.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,L.jsxs)(`div`,{className:`border-t border-surface-200 pt-4 space-y-3`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide`,children:`Company (optional)`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Company Name`}),(0,L.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`Acme Corp`})]}),d&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Company Role`}),(0,L.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[R1.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value)),(0,L.jsx)(`option`,{value:`member`,children:`Member`})]})]})]}),(0,L.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:e,className:`flex-1 rounded-lg border border-surface-300 px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,disabled:n,className:`flex-1 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:n?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin mx-auto`}):`Create User`})]})]})]})]}),document.body)}function W1({user:e,onConfirm:t,onClose:n,isPending:r}){return(0,yS.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:n}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl bg-white shadow-xl p-6 text-center`,children:[(0,L.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-red-100`,children:(0,L.jsx)(jc,{className:`h-6 w-6 text-red-600`})}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-surface-900 mb-2`,children:`Delete User`}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500 mb-6`,children:[`Are you sure you want to delete `,(0,L.jsx)(`strong`,{className:`text-surface-700`,children:e.fullName}),` (`,e.email,`)? This action cannot be undone.`]}),(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsx)(`button`,{onClick:n,disabled:r,className:`flex-1 rounded-lg border border-surface-300 px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{onClick:t,disabled:r,className:`flex-1 rounded-lg bg-red-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-red-700 disabled:opacity-50 min-h-[44px]`,children:r?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin mx-auto`}):`Delete`})]})]})]}),document.body)}function G1(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(``),{data:i,isLoading:a}=R({queryKey:[`admin-audit`,n],queryFn:()=>KQ.getAuditLogs({entityType:n||void 0})}),o=(i?.items??[]).filter(t=>t.description.toLowerCase().includes(e.toLowerCase())||t.actorEmail.toLowerCase().includes(e.toLowerCase())||t.action.toLowerCase().includes(e.toLowerCase()));return a?(0,L.jsx)($,{title:`Audit Log`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Audit Log`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Audit Log`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Track all system activity and changes`})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[(0,L.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value),className:`w-full sm:w-48 rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:``,children:`All Types`}),(0,L.jsx)(`option`,{value:`login`,children:`Login`}),(0,L.jsx)(`option`,{value:`user`,children:`User`}),(0,L.jsx)(`option`,{value:`organization`,children:`Organization`}),(0,L.jsx)(`option`,{value:`settings`,children:`Settings`})]}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search logs...`,className:`w-full rounded-lg border border-surface-300 py-2.5 pl-9 pr-4 text-sm outline-none focus:border-brand-500 sm:w-64 min-h-[44px]`})]})]})]}),o.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(fu,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:e||n?`No logs match your filters`:`No audit logs yet`})]}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white`,children:(0,L.jsx)(`div`,{className:`divide-y divide-surface-100`,children:o.map(e=>(0,L.jsx)(`div`,{className:`p-4 hover:bg-surface-50`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`mt-0.5 flex h-8 w-8 items-center justify-center rounded-full bg-brand-100 text-brand-600`,children:(0,L.jsx)(fu,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-surface-100 px-2 py-0.5 text-xs font-medium text-surface-600`,children:e.entityType}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-surface-900 truncate`,children:e.action})]}),(0,L.jsx)(`span`,{className:`text-xs text-surface-500 whitespace-nowrap`,children:e.timestamp?new Date(e.timestamp).toLocaleString():`N/A`})]}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-600 line-clamp-2`,children:e.description}),(0,L.jsxs)(`p`,{className:`mt-0.5 text-xs text-surface-500`,children:[`by `,e.actorEmail]})]})]})},e.id))})})]})}var K1=e=>new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,maximumFractionDigits:0}).format(e),q1=e=>`${e.toFixed(1)}%`,J1=e=>({maxCount:Math.max(...e.map(e=>e.count),1),maxValue:Math.max(...e.map(e=>e.value),1)});function Y1(){let{data:e,isLoading:t}=R({queryKey:[`analytics-crm-summary`],queryFn:()=>qQ.getCrmSummary()}),{data:n,isLoading:r}=R({queryKey:[`analytics-pipeline`],queryFn:()=>qQ.getPipeline()}),{data:i,isLoading:a}=R({queryKey:[`analytics-contacts`],queryFn:()=>qQ.getContacts()}),{data:o,isLoading:s}=R({queryKey:[`analytics-deals-velocity`],queryFn:()=>qQ.getDealsVelocity()}),{data:c,isLoading:l}=R({queryKey:[`analytics-forecasts`],queryFn:()=>qQ.getForecasts()});if(t||r||a||s||l)return(0,L.jsx)($,{title:`CRM Analytics`,children:(0,L.jsx)(FQ,{})});let u=n?.stages??[],{maxCount:d,maxValue:f}=J1(u),p={lead:`bg-surface-400`,prospecting:`bg-surface-500`,qualified:`bg-brand-300`,proposal:`bg-brand-400`,negotiation:`bg-warning`,closed_won:`bg-success`,closed_lost:`bg-error`},m=e=>{let t=e.toLowerCase().replace(/[\s-]/g,`_`);for(let[e,n]of Object.entries(p))if(t.includes(e))return n;return`bg-brand-200`};return(0,L.jsxs)($,{title:`CRM Analytics`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`CRM Analytics`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Pipeline performance, contact insights, and deal velocity`})]}),(0,L.jsxs)(Mn,{to:`/admin/leads`,className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(Lc,{className:`h-4 w-4`}),`Go to Leads`]})]}),(0,L.jsxs)(`div`,{className:`mb-8 grid grid-cols-2 gap-4 lg:grid-cols-4`,children:[(0,L.jsx)(c1,{title:`Companies`,value:e?.companies??0,icon:Kc,iconBg:`bg-brand-100 text-brand-600`}),(0,L.jsx)(c1,{title:`Contacts`,value:e?.contacts??0,icon:Pu,iconBg:`bg-blue-100 text-blue-600`}),(0,L.jsx)(c1,{title:`Active Deals`,value:e?.deals??0,icon:xl,iconBg:`bg-purple-100 text-purple-600`}),(0,L.jsx)(c1,{title:`Pipeline Value`,value:K1(e?.pipeline_value??0),icon:dl,iconBg:`bg-success/10 text-success`})]}),(0,L.jsxs)(`div`,{className:`mb-8 grid grid-cols-1 gap-6 lg:grid-cols-5`,children:[(0,L.jsxs)(`div`,{className:`lg:col-span-3 rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(mc,{className:`h-4 w-4 text-brand-600`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-700`,children:`Pipeline by Stage`})]}),u.length===0?(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No pipeline data available`}):(0,L.jsx)(`div`,{className:`space-y-3`,children:u.map(e=>{let t=Math.round(e.count/d*100),n=Math.round(e.value/f*100);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-surface-700`,children:e.name}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-surface-500`,children:[(0,L.jsxs)(`span`,{children:[e.count,` deals`]}),(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:K1(e.value)})]})]}),(0,L.jsx)(`div`,{className:`h-3 w-full overflow-hidden rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${m(e.name)}`,style:{width:`${t}%`}})}),(0,L.jsx)(`div`,{className:`mt-1 h-2 w-full overflow-hidden rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${m(e.name)} opacity-50`,style:{width:`${n}%`},title:`Value: ${K1(e.value)}`})})]},e.name)})})]}),(0,L.jsxs)(`div`,{className:`lg:col-span-2 space-y-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(Pu,{className:`h-4 w-4 text-blue-600`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-700`,children:`Contacts Overview`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Contacts`}),(0,L.jsx)(`p`,{className:`mt-1 text-xl font-semibold text-surface-900`,children:i?.total?.toLocaleString()??0})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`30-Day Growth`}),(0,L.jsx)(`p`,{className:`mt-1 text-xl font-semibold text-success`,children:i?.growth_30d??`N/A`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Avg Lifecycle`}),(0,L.jsxs)(`p`,{className:`mt-1 text-xl font-semibold text-surface-900`,children:[i?.avg_lifecycle_days??0,` days`]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Sources`}),(0,L.jsx)(`p`,{className:`mt-1 text-xl font-semibold text-surface-900`,children:i?.source_breakdown?Object.keys(i.source_breakdown).length:0})]})]})]}),i?.source_breakdown&&Object.keys(i.source_breakdown).length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700`,children:`Contact Sources`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:Object.entries(i.source_breakdown).sort(([,e],[,t])=>t-e).map(([e,t])=>{let n=Math.max(...Object.values(i.source_breakdown),1),r=Math.round(t/n*100);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-xs`,children:[(0,L.jsx)(`span`,{className:`font-medium text-surface-600`,children:e}),(0,L.jsx)(`span`,{className:`text-surface-500`,children:t})]}),(0,L.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-brand-400 transition-all duration-500`,style:{width:`${r}%`}})})]},e)})})]})]})]}),(0,L.jsxs)(`div`,{className:`mb-8 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(Mc,{className:`h-4 w-4 text-purple-600`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-700`,children:`Deals Velocity`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Avg Days to Close`}),(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1`,children:[(0,L.jsx)(al,{className:`h-4 w-4 text-surface-400`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-surface-900`,children:o?.avg_days_to_close??0})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Monthly Wins`}),(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1`,children:[(0,L.jsx)(yu,{className:`h-4 w-4 text-success`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-success`,children:o?.monthly_wins??0})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Win Rate`}),(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1`,children:[(0,L.jsx)(wu,{className:`h-4 w-4 text-brand-600`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-brand-700`,children:q1(o?.win_rate??0)})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Velocity Score`}),(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1`,children:[(0,L.jsx)(mc,{className:`h-4 w-4 text-warning`}),(0,L.jsx)(`p`,{className:`text-lg font-semibold text-surface-900`,children:o?.pipeline_velocity_score??0})]})]})]}),(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-xs`,children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Win Rate Progress`}),(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:q1(o?.win_rate??0)})]}),(0,L.jsx)(`div`,{className:`h-3 w-full overflow-hidden rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-gradient-to-r from-brand-300 to-brand-600 transition-all duration-500`,style:{width:`${Math.min(o?.win_rate??0,100)}%`}})})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(wu,{className:`h-4 w-4 text-success`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-700`,children:`Revenue Forecast`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Monthly Revenue`}),(0,L.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-surface-900`,children:K1(c?.monthly_revenue??0)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Monthly Deals`}),(0,L.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-surface-900`,children:c?.monthly_deals??0})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Quarterly Revenue`}),(0,L.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-surface-900`,children:K1(c?.quarterly_revenue??0)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Quarterly Deals`}),(0,L.jsx)(`p`,{className:`mt-1 text-lg font-semibold text-surface-900`,children:c?.quarterly_deals??0})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-xs`,children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Monthly Revenue Target`}),(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:c?`${Math.round(c.monthly_revenue/(c.quarterly_revenue||1)*100)}% of quarterly`:`—`})]}),(0,L.jsx)(`div`,{className:`h-2.5 w-full overflow-hidden rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-brand-500 transition-all duration-500`,style:{width:`${c?Math.min(c.monthly_revenue/(c.quarterly_revenue||1)*100,100):0}%`}})})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-xs`,children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Monthly Deals vs Quarterly`}),(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:c&&c.quarterly_deals>0?`${Math.round(c.monthly_deals/c.quarterly_deals*100)}% of quarterly`:`—`})]}),(0,L.jsx)(`div`,{className:`h-2.5 w-full overflow-hidden rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-purple-500 transition-all duration-500`,style:{width:`${c&&c.quarterly_deals>0?Math.min(c.monthly_deals/c.quarterly_deals*100,100):0}%`}})})]})]})]})]})]})}var X1=e=>new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,maximumFractionDigits:0}).format(e),Z1=e=>e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(0)}`,Q1=e=>e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),$1=`cs-revenue-target-annual`;function e0(){try{let e=localStorage.getItem($1);if(e){let t=parseFloat(e);if(!isNaN(t)&&t>0)return t}}catch{}return null}function t0(e){try{localStorage.setItem($1,String(e))}catch{}}function n0({currentTarget:e,onSet:t,onClear:n}){let[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(``);return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,L.jsx)(yu,{className:`h-5 w-5 text-brand-600`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-900`,children:`Annual Revenue Target`})]}),e===null?null:(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-green-50 px-3 py-2.5 min-h-[44px]`,children:[(0,L.jsx)(dl,{className:`h-4 w-4 text-green-600`}),(0,L.jsx)(`span`,{className:`text-lg font-bold text-green-700`,children:X1(e)}),(0,L.jsx)(`span`,{className:`text-xs text-green-600`,children:`/ year`})]}),(0,L.jsxs)(`button`,{onClick:()=>{n()},className:`inline-flex items-center gap-1.5 self-start rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs font-medium text-red-700 hover:bg-red-100 min-h-[44px]`,children:[(0,L.jsx)(nu,{className:`h-3.5 w-3.5`}),`Clear Target`]})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-col sm:flex-row gap-2`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1`,children:[(0,L.jsx)(`span`,{className:`absolute inset-y-0 left-0 flex items-center pl-3 text-surface-400`,children:`$`}),(0,L.jsx)(`input`,{type:`text`,value:r,onChange:e=>{i(e.target.value),o(``)},placeholder:`e.g. 500000`,className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 pl-7 pr-3 text-sm text-surface-900 placeholder:text-surface-400 focus:border-brand-600 focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`})]}),(0,L.jsxs)(`button`,{onClick:()=>{let e=parseFloat(r.replace(/[^0-9.]/g,``));if(isNaN(e)||e<=0){o(`Enter a valid target amount`);return}if(e>1e9){o(`Target seems unusually large — double-check your input`);return}o(``),t(e),i(``)},className:`inline-flex items-center justify-center gap-1.5 rounded-lg bg-brand-600 px-5 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(yu,{className:`h-4 w-4`}),`Set Target`]})]}),a&&(0,L.jsx)(`p`,{className:`mt-2 text-xs text-red-600`,children:a})]})}function r0({kpi:e}){let t=e.trend===`up`||e.invert_trend&&e.trend===`down`;e.trend===`down`||e.invert_trend&&e.trend;let n=e.trend===`flat`,r=t=>e.unit===`currency`?X1(t):e.unit===`percent`?`${t.toFixed(1)}%`:t.toLocaleString(),i=n?Bl:t?wu:Cu,a=n?`text-surface-500`:t?`text-green-600`:`text-red-600`;return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:e.label}),(0,L.jsxs)(`div`,{className:`mt-2 flex items-end justify-between`,children:[(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:r(e.value)}),!n&&(0,L.jsxs)(`div`,{className:`flex items-center gap-1 text-xs font-medium ${a}`,children:[(0,L.jsx)(i,{className:`h-3.5 w-3.5`}),(0,L.jsxs)(`span`,{children:[Math.abs(e.pct_change).toFixed(1),`%`]})]})]}),!n&&(0,L.jsxs)(`p`,{className:`mt-1 text-xs text-surface-500`,children:[`vs prev period (`,r(e.previous_value),`)`]})]})}function i0({score:e}){let t=2*Math.PI*54,n=Math.max(0,Math.min(e,100)),r=t-n/100*t,i;return i=n>=70?`#059669`:n>=40?`#F59E0B`:`#EF4444`,(0,L.jsxs)(`div`,{className:`relative flex h-32 w-32 items-center justify-center`,children:[(0,L.jsxs)(`svg`,{className:`h-full w-full -rotate-90`,viewBox:`0 0 120 120`,children:[(0,L.jsx)(`circle`,{cx:`60`,cy:`60`,r:54,fill:`none`,stroke:`#E5E7EB`,strokeWidth:`8`}),(0,L.jsx)(`circle`,{cx:`60`,cy:`60`,r:54,fill:`none`,stroke:i,strokeWidth:`8`,strokeLinecap:`round`,strokeDasharray:t,strokeDashoffset:r,className:`transition-all duration-700 ease-out`})]}),(0,L.jsxs)(`div`,{className:`absolute flex flex-col items-center`,children:[(0,L.jsx)(`span`,{className:`text-2xl font-bold text-surface-900`,children:Math.round(n)}),(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:`/ 100`})]})]})}function a0(){let{data:e,isLoading:t}=R({queryKey:[`forecast-revenue`],queryFn:()=>JQ.getRevenueForecast()}),{data:n,isLoading:r}=R({queryKey:[`forecast-pipeline`],queryFn:()=>JQ.getPipelineForecast()}),{data:i,isLoading:a}=R({queryKey:[`analytics-kpis`,90],queryFn:()=>JQ.getKPIs(90)}),[o,s]=(0,S.useState)(e0),c=e=>{s(e),t0(e)},l=()=>{s(null);try{localStorage.removeItem($1)}catch{}},u=e?.forecast,d=u?.avg_monthly_actual??0,f=(u?.trailing_actuals??[]).reduce((e,t)=>e+t.actual,0),p=new Date().getMonth()+1,m=Math.max(12-p+1,1);p-1;let h=0,g=0,_=!1;if(o&&(h=(o-f)/m,g=f+d*m,_=d>=h&&h>0),t||r||a)return(0,L.jsx)($,{title:`Revenue Forecasting`,children:(0,L.jsx)(FQ,{})});let v=n?.pipeline_health,y=n?.at_risk_deals??[],b=n?.stage_distribution??[],x=i?.kpis??[],C=[...u?.trailing_actuals??[],...u?.forecast_months??[]].map(e=>({...e,isActual:e.actual>0})),w=({active:e,payload:t})=>{if(!e||!t||!t.length)return null;let n=t[0].payload;return(0,L.jsxs)(`div`,{className:`rounded-lg border border-surface-200 bg-white p-3 shadow-lg`,children:[(0,L.jsx)(`p`,{className:`text-sm font-semibold text-surface-900`,children:n.label}),n.actual>0&&(0,L.jsxs)(`p`,{className:`text-xs text-surface-600`,children:[`Actual: `,X1(n.actual)]}),(0,L.jsxs)(`p`,{className:`text-xs text-green-600`,children:[`Likely: `,X1(n.likely)]}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[`Best: `,X1(n.best)]}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[`Conservative: `,X1(n.conservative)]})]})},T=({active:e,payload:t})=>{if(!e||!t||!t.length)return null;let n=t[0].payload;return(0,L.jsxs)(`div`,{className:`rounded-lg border border-surface-200 bg-white p-3 shadow-lg`,children:[(0,L.jsx)(`p`,{className:`text-sm font-semibold text-surface-900`,children:n.stage}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-600`,children:[n.count,` deals`]}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-600`,children:[`Value: `,X1(n.value)]})]})},E=x.filter(e=>e.category===`revenue`),D=x.filter(e=>e.category===`deals`),O=x.filter(e=>e.category===`efficiency`),k=x.filter(e=>e.category===`customers`),A=[x.find(e=>e.label===`Win Rate`),x.find(e=>e.label===`Avg Deal Size`),x.find(e=>e.label===`Avg Days to Close`),x.find(e=>e.label===`New Contacts`),x.find(e=>e.label===`Total Revenue`),x.find(e=>e.label===`Deals Created/Month`)].filter(Boolean);return(0,L.jsxs)($,{title:`Revenue Forecasting`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Revenue Forecasting`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Pipeline analysis, revenue projections, and key performance metrics`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-surface-200 bg-white px-3 py-2 min-h-[44px]`,children:[(0,L.jsx)(Jc,{className:`h-4 w-4 text-surface-400`}),(0,L.jsxs)(`span`,{className:`text-sm text-surface-600`,children:[`Last 90 days • Updated `,Q1(new Date)]})]})]}),(0,L.jsx)(`div`,{className:`mb-8`,children:(0,L.jsx)(n0,{currentTarget:o,onSet:c,onClear:l})}),o&&h>0&&(0,L.jsx)(`div`,{className:`mb-8`,children:(0,L.jsxs)(`div`,{className:`rounded-xl border p-4 sm:p-6 ${_?`border-green-200 bg-gradient-to-r from-green-50 to-emerald-50`:`border-red-200 bg-gradient-to-r from-red-50 to-orange-50`}`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-12 w-12 shrink-0 items-center justify-center rounded-full text-xl ${_?`bg-green-100`:`bg-red-100`}`,children:_?`🟢`:`🔴`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-base font-bold ${_?`text-green-800`:`text-red-800`}`,children:_?`On Track`:`Behind Pace`}),(0,L.jsxs)(`p`,{className:`text-xs ${_?`text-green-600`:`text-red-600`}`,children:[`Based on your `,X1(o),` annual target`]})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-1 flex-wrap items-center gap-4 sm:gap-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:`Avg Pace`}),(0,L.jsxs)(`span`,{className:`text-sm font-bold text-surface-900`,children:[X1(d),`/mo`]})]}),(0,L.jsx)(Lc,{className:`h-4 w-4 shrink-0 text-surface-300`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:`Required`}),(0,L.jsxs)(`span`,{className:`text-sm font-bold ${_?`text-green-700`:`text-red-700`}`,children:[X1(h),`/mo`]})]}),(0,L.jsx)(`div`,{className:`hidden sm:block h-6 w-px bg-surface-200`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Jc,{className:`h-4 w-4 text-surface-400`}),(0,L.jsxs)(`span`,{className:`text-xs text-surface-500`,children:[`Projected YE: `,(0,L.jsx)(`span`,{className:`font-bold text-surface-900`,children:X1(g)})]})]})]})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-6 gap-y-1 pt-3 border-t border-surface-200/50`,children:[(0,L.jsxs)(`p`,{className:`text-xs text-surface-500`,children:[`Won so far: `,(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:X1(f)}),` (last 3 months)`]}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-500`,children:[`Remaining: `,(0,L.jsxs)(`span`,{className:`font-medium text-surface-700`,children:[m,` months`]})]}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-500`,children:[`Gap to close: `,(0,L.jsx)(`span`,{className:`font-medium ${o-g>=0?`text-green-600`:`text-red-600`}`,children:X1(Math.max(0,o-g))})]})]})]})}),(0,L.jsxs)(`div`,{className:`mb-8`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(wu,{className:`h-5 w-5 text-brand-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Revenue Forecast`})]}),(0,L.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 lg:grid-cols-4`,children:[(0,L.jsx)(c1,{title:`Pipeline Value`,value:Z1(u?.total_pipeline_value??0),icon:dl,iconBg:`bg-brand-100 text-brand-600`}),(0,L.jsx)(c1,{title:`Weighted Pipeline`,value:Z1(u?.total_weighted_value??0),icon:Mc,iconBg:`bg-blue-100 text-blue-600`}),(0,L.jsx)(c1,{title:`Avg Monthly Revenue`,value:Z1(u?.avg_monthly_actual??0),icon:yu,iconBg:`bg-purple-100 text-purple-600`}),(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-surface-100 text-surface-600`,children:(0,L.jsx)(yl,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Confidence`}),(0,L.jsxs)(`p`,{className:`text-lg font-bold text-surface-900`,children:[u?.confidence_score??0,`%`]})]})]})})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(mc,{className:`h-4 w-4 text-brand-600`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-700`,children:`6-Month Revenue Projection`})]}),C.length===0?(0,L.jsx)(`div`,{className:`flex h-64 items-center justify-center`,children:(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No forecast data available`})}):(0,L.jsx)(Fb,{width:`100%`,height:320,children:(0,L.jsxs)(AQ,{data:C,margin:{top:10,right:10,left:0,bottom:0},children:[(0,L.jsxs)(`defs`,{children:[(0,L.jsxs)(`linearGradient`,{id:`colorLikely`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,L.jsx)(`stop`,{offset:`5%`,stopColor:`#00A846`,stopOpacity:.3}),(0,L.jsx)(`stop`,{offset:`95%`,stopColor:`#00A846`,stopOpacity:.05})]}),(0,L.jsxs)(`linearGradient`,{id:`colorBest`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,L.jsx)(`stop`,{offset:`5%`,stopColor:`#9CA3AF`,stopOpacity:.15}),(0,L.jsx)(`stop`,{offset:`95%`,stopColor:`#9CA3AF`,stopOpacity:.02})]}),(0,L.jsxs)(`linearGradient`,{id:`colorConservative`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,L.jsx)(`stop`,{offset:`5%`,stopColor:`#D1D5DB`,stopOpacity:.1}),(0,L.jsx)(`stop`,{offset:`95%`,stopColor:`#D1D5DB`,stopOpacity:.02})]})]}),(0,L.jsx)(FG,{strokeDasharray:`3 3`,stroke:`#F3F4F6`}),(0,L.jsx)(KY,{dataKey:`label`,tick:{fontSize:12,fill:`#6B7280`},axisLine:{stroke:`#E5E7EB`},tickLine:!1}),(0,L.jsx)(sX,{tickFormatter:e=>Z1(e),tick:{fontSize:12,fill:`#6B7280`},axisLine:!1,tickLine:!1}),(0,L.jsx)(ez,{content:(0,L.jsx)(w,{})}),(0,L.jsx)(US,{wrapperStyle:{fontSize:`12px`,paddingTop:`8px`},formatter:e=>e.charAt(0).toUpperCase()+e.slice(1)}),o&&h>0&&(0,L.jsx)(xW,{y:h,stroke:_?`#059669`:`#EF4444`,strokeWidth:2,strokeDasharray:`8 4`,label:{value:`Required pace: ${Z1(h)}/mo`,position:`right`,fill:_?`#059669`:`#EF4444`,fontSize:11,fontWeight:600,className:`text-shadow`}}),(0,L.jsx)(Qq,{type:`monotone`,dataKey:`best`,name:`Best Case`,stroke:`#9CA3AF`,fill:`url(#colorBest)`,strokeWidth:1.5,dot:!1}),(0,L.jsx)(Qq,{type:`monotone`,dataKey:`likely`,name:`Likely`,stroke:`#00A846`,fill:`url(#colorLikely)`,strokeWidth:2,dot:!1}),(0,L.jsx)(Qq,{type:`monotone`,dataKey:`conservative`,name:`Conservative`,stroke:`#D1D5DB`,fill:`url(#colorConservative)`,strokeWidth:1.5,dot:!1}),C.map((e,t)=>e.actual>0?(0,L.jsx)(Qq,{type:`monotone`,dataKey:`actual`,name:`Actual`,stroke:`#00A846`,fill:`none`,strokeWidth:2.5,strokeDasharray:`6 3`,connectNulls:!0,dot:e.isActual?{r:4,fill:`#00A846`,stroke:`#fff`,strokeWidth:2}:!1},`actual-${t}`):null)]})}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4 text-xs text-surface-500`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-brand-600`}),(0,L.jsx)(`span`,{children:`Actual (trailing 3 months)`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-brand-600 opacity-70`}),(0,L.jsx)(`span`,{children:`Likely (weighted by probability)`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-surface-400`}),(0,L.jsx)(`span`,{children:`Best (100% of all deals)`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`div`,{className:`h-2.5 w-2.5 rounded-full bg-surface-300`}),(0,L.jsx)(`span`,{children:`Conservative (50% of weighted)`})]}),o&&h>0&&(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`div`,{className:`h-0.5 w-3 ${_?`bg-green-600`:`bg-red-600`}`,style:{borderTop:`2px dashed`,borderColor:_?`#059669`:`#EF4444`,background:`none`}}),(0,L.jsxs)(`span`,{children:[`Required pace (`,Z1(h),`/mo)`]})]})]})]})]}),(0,L.jsxs)(`div`,{className:`mb-8`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(yl,{className:`h-5 w-5 text-brand-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Pipeline Health`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-surface-700`,children:`Health Score`}),(0,L.jsx)(`div`,{className:`flex justify-center`,children:(0,L.jsx)(i0,{score:v?.health_score??0})}),(0,L.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Coverage Ratio`}),(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:v?.coverage_ratio?`${v.coverage_ratio.toFixed(1)}x`:`N/A`})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Growth Rate`}),(0,L.jsxs)(`span`,{className:`font-medium ${(v?.growth_rate_pct??0)>=0?`text-green-600`:`text-red-600`}`,children:[(v?.growth_rate_pct??0)>=0?`+`:``,(v?.growth_rate_pct??0).toFixed(1),`%`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Open Deals`}),(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:v?.open_deals_count??0})]})]})]}),(0,L.jsxs)(`div`,{className:`lg:col-span-2 rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-surface-700`,children:`Stage Distribution`}),b.length===0?(0,L.jsx)(`div`,{className:`flex h-48 items-center justify-center`,children:(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No pipeline data available`})}):(0,L.jsx)(Fb,{width:`100%`,height:200,children:(0,L.jsxs)(cQ,{data:b,layout:`vertical`,margin:{top:5,right:20,left:100,bottom:5},children:[(0,L.jsx)(FG,{strokeDasharray:`3 3`,stroke:`#F3F4F6`}),(0,L.jsx)(KY,{type:`number`,tickFormatter:e=>Z1(e),tick:{fontSize:11,fill:`#6B7280`},axisLine:!1,tickLine:!1}),(0,L.jsx)(sX,{type:`category`,dataKey:`stage`,tick:{fontSize:11,fill:`#6B7280`},axisLine:!1,tickLine:!1,width:90}),(0,L.jsx)(ez,{content:(0,L.jsx)(T,{})}),(0,L.jsx)(TY,{dataKey:`value`,name:`Value`,fill:`#00A846`,radius:[0,4,4,0],barSize:20})]})})]})]}),y.length>0&&(0,L.jsxs)(`div`,{className:`mt-6 rounded-xl border border-red-200 bg-red-50 p-4 sm:p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,L.jsx)(jc,{className:`h-4 w-4 text-red-600`}),(0,L.jsxs)(`h3`,{className:`text-sm font-semibold text-red-900`,children:[`At-Risk Deals (`,y.length,`)`]})]}),(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-red-200`,children:[(0,L.jsx)(`th`,{className:`pb-2 text-left text-xs font-medium text-red-800`,children:`Deal`}),(0,L.jsx)(`th`,{className:`pb-2 text-left text-xs font-medium text-red-800`,children:`Stage`}),(0,L.jsx)(`th`,{className:`pb-2 text-right text-xs font-medium text-red-800`,children:`Amount`}),(0,L.jsx)(`th`,{className:`pb-2 text-right text-xs font-medium text-red-800`,children:`Due Date`}),(0,L.jsx)(`th`,{className:`pb-2 text-right text-xs font-medium text-red-800`,children:`Overdue`})]})}),(0,L.jsx)(`tbody`,{children:y.slice(0,5).map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-red-100 last:border-b-0`,children:[(0,L.jsx)(`td`,{className:`py-2 font-medium text-red-900 truncate max-w-[200px]`,children:e.deal_name}),(0,L.jsx)(`td`,{className:`py-2 text-red-700`,children:e.stage}),(0,L.jsx)(`td`,{className:`py-2 text-right text-red-900`,children:X1(e.amount)}),(0,L.jsx)(`td`,{className:`py-2 text-right text-red-700`,children:e.expected_close_date??`N/A`}),(0,L.jsxs)(`td`,{className:`py-2 text-right font-medium text-red-700`,children:[e.days_overdue,` days`]})]},e.deal_name))})]})})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(yu,{className:`h-5 w-5 text-brand-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Key Performance Indicators`})]}),A.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-8 text-center`,children:[(0,L.jsx)(Mc,{className:`mx-auto h-8 w-8 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-surface-500`,children:`No KPI data available yet`}),(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:`KPIs will appear once CRM data is synced`})]}):(0,L.jsx)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-3`,children:A.map(e=>(0,L.jsx)(r0,{kpi:e},e.label))}),x.length>0&&(0,L.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsxs)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700 flex items-center gap-2`,children:[(0,L.jsx)(xl,{className:`h-4 w-4 text-brand-600`}),`Revenue & Deal Metrics`]}),(0,L.jsx)(`div`,{className:`space-y-3`,children:[...E,...D].map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:e.label}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-semibold text-surface-900`,children:e.unit===`currency`?X1(e.value):e.unit===`percent`?`${e.value.toFixed(1)}%`:e.value.toLocaleString()}),e.trend!==`flat`&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded-full px-2 py-0.5 text-xs font-medium ${e.trend===`up`?`bg-green-100 text-green-700`:`bg-red-100 text-red-700`}`,children:[e.trend===`up`?`↑`:`↓`,Math.abs(e.pct_change).toFixed(1),`%`]})]})]},e.label))})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsxs)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700 flex items-center gap-2`,children:[(0,L.jsx)(Pu,{className:`h-4 w-4 text-blue-600`}),`Efficiency & Customer Metrics`]}),(0,L.jsx)(`div`,{className:`space-y-3`,children:[...O,...k].map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:e.label}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-semibold text-surface-900`,children:e.unit===`currency`?X1(e.value):e.unit===`percent`?`${e.value.toFixed(1)}%`:e.value.toLocaleString()}),e.trend!==`flat`&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded-full px-2 py-0.5 text-xs font-medium ${e.invert_trend&&e.trend===`down`||e.trend===`up`?`bg-green-100 text-green-700`:`bg-red-100 text-red-700`}`,children:[e.trend===`up`?`↑`:`↓`,Math.abs(e.pct_change).toFixed(1),`%`]})]})]},e.label))})]})]})]})]})}var o0=e=>e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(0)}`,s0=e=>e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`});function c0(e){return e>=80?`bg-green-500`:e>=50?`bg-yellow-500`:`bg-red-500`}function l0(e){return e>=80?`text-green-700`:e>=50?`text-yellow-700`:`text-red-700`}function u0(e){return e>=100?{label:`Ahead`,className:`bg-green-100 text-green-700`}:e>=80?{label:`On Pace`,className:`bg-blue-100 text-blue-700`}:{label:`Behind`,className:`bg-red-100 text-red-700`}}function d0(e){switch(e){case`org`:return{label:`Org`,className:`bg-purple-100 text-purple-700`,icon:Kc};case`department`:return{label:`Dept`,className:`bg-blue-100 text-blue-700`,icon:Gc};case`team`:return{label:`Team`,className:`bg-amber-100 text-amber-700`,icon:Pu};case`rep`:return{label:`Rep`,className:`bg-emerald-100 text-emerald-700`,icon:Pu};default:return{label:e,className:`bg-surface-100 text-surface-600`,icon:yu}}}function f0(e){switch(e){case`active`:return{label:`Active`,className:`bg-green-100 text-green-700`};case`completed`:return{label:`Completed`,className:`bg-blue-100 text-blue-700`};case`paused`:return{label:`Paused`,className:`bg-yellow-100 text-yellow-700`};case`cancelled`:return{label:`Cancelled`,className:`bg-red-100 text-red-700`};default:return{label:e,className:`bg-gray-100 text-gray-700`}}}function p0(e){return e.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}function m0({value:e,max:t,height:n=`h-2`}){let r=t>0?Math.min(e/t*100,100):0;return(0,L.jsx)(`div`,{className:`w-full ${n} rounded-full bg-surface-200 overflow-hidden`,children:(0,L.jsx)(`div`,{className:`${n} rounded-full ${c0(r)} transition-all duration-500`,style:{width:`${r}%`}})})}function h0({metrics:e}){return!e||e.length===0?(0,L.jsx)(`div`,{className:`mt-3 py-4 text-center text-sm text-surface-400`,children:`No metrics tracked for this goal yet.`}):(0,L.jsx)(`div`,{className:`mt-3 grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`rounded-lg border border-surface-200 bg-surface-50 p-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-surface-600`,children:e.metric_name}),(0,L.jsxs)(`span`,{className:`text-xs font-bold ${l0(e.progress_percentage)}`,children:[e.progress_percentage.toFixed(1),`%`]})]}),(0,L.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,L.jsx)(m0,{value:e.actual_value,max:e.target_value,height:`h-1.5`}),(0,L.jsxs)(`span`,{className:`text-xs text-surface-500 whitespace-nowrap`,children:[o0(e.actual_value),` / `,o0(e.target_value)]})]}),e.period&&(0,L.jsxs)(`p`,{className:`mt-1 text-xs text-surface-400`,children:[`Period: `,e.period]})]},e.id))})}function g0({level:e,status:t,search:n,includeCascade:r,onLevelChange:i,onStatusChange:a,onSearchChange:o,onIncludeCascadeChange:s,onReset:c}){return(0,L.jsxs)(`div`,{className:`mb-6 rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,L.jsx)(mu,{className:`h-4 w-4 text-surface-400`}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-surface-700`,children:`Filters`}),(e||t||n)&&(0,L.jsx)(`button`,{onClick:c,className:`ml-auto text-xs text-brand-600 hover:text-brand-700 font-medium min-h-[24px]`,children:`Reset All`})]}),(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,L.jsx)(`div`,{className:`flex-1 min-w-[200px]`,children:(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,value:n,onChange:e=>o(e.target.value),placeholder:`Search goals by name or description...`,className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2 pl-9 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`})]})}),(0,L.jsx)(`div`,{className:`shrink-0`,children:(0,L.jsxs)(`select`,{value:e,onChange:e=>i(e.target.value),className:`w-full sm:w-36 rounded-lg border border-surface-200 bg-surface-50 py-2 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:``,children:`All Levels`}),(0,L.jsx)(`option`,{value:`org`,children:`Org`}),(0,L.jsx)(`option`,{value:`department`,children:`Department`}),(0,L.jsx)(`option`,{value:`team`,children:`Team`}),(0,L.jsx)(`option`,{value:`rep`,children:`Rep`})]})}),(0,L.jsx)(`div`,{className:`shrink-0`,children:(0,L.jsxs)(`select`,{value:t,onChange:e=>a(e.target.value),className:`w-full sm:w-40 rounded-lg border border-surface-200 bg-surface-50 py-2 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:``,children:`All Status`}),(0,L.jsx)(`option`,{value:`active`,children:`Active`}),(0,L.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,L.jsx)(`option`,{value:`paused`,children:`Paused`}),(0,L.jsx)(`option`,{value:`cancelled`,children:`Cancelled`})]})}),(0,L.jsx)(`div`,{className:`shrink-0 flex items-center gap-2 self-center`,children:(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-surface-600 cursor-pointer`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>s(e.target.checked),className:`rounded border-surface-300 text-brand-600 focus:ring-brand-600`}),`Cascade tree`]})})]})]})}function _0({goal:e,onClose:t,onSubmit:n,companies:r,users:i,allGoals:a,isNew:o}){let[s,c]=(0,S.useState)(e?.name??``),[l,u]=(0,S.useState)(e?.description??``),[d,f]=(0,S.useState)(e?.target_value?.toString()??``),[p,m]=(0,S.useState)(e?.current_value?.toString()??`0`),[h,g]=(0,S.useState)(e?.level??`org`),[_,v]=(0,S.useState)(e?.status??`active`),[y,b]=(0,S.useState)(e?.company_id??r[0]?.id??``),[x,C]=(0,S.useState)(e?.assigned_to??``),[w,T]=(0,S.useState)(e?.start_date??``),[E,D]=(0,S.useState)(e?.end_date??``),[O,k]=(0,S.useState)(e?.unit??`$`),[A,j]=(0,S.useState)(e?.weight?.toString()??`1`),[M,N]=(0,S.useState)(e?.parent_goal_id??``),[ee,te]=(0,S.useState)(``),P=(0,S.useMemo)(()=>{let t=new Set;if(e){t.add(e.id);let n=e=>{e.sub_goals&&e.sub_goals.forEach(e=>{t.add(e.id),n(e)})};n(e)}return a.filter(e=>!t.has(e.id))},[a,e]);return(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onClick:t,children:(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6 w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,L.jsx)(`h3`,{className:`text-lg font-bold text-surface-900`,children:o?`Create New Goal`:`Edit Goal`}),(0,L.jsx)(`button`,{onClick:t,className:`p-1 rounded-md hover:bg-surface-100 min-h-[36px] min-w-[36px] flex items-center justify-center`,children:(0,L.jsx)(Iu,{className:`h-5 w-5 text-surface-400`})})]}),(0,L.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),te(``),!s.trim()){te(`Goal name is required`);return}let t=parseFloat(d);if(isNaN(t)||t<=0){te(`Enter a valid target value`);return}let r={name:s.trim(),description:l.trim()||void 0,target_value:t,current_value:parseFloat(p)||0,level:h,status:_,unit:O,weight:parseFloat(A)||1};o&&y&&(r.company_id=y),x&&(r.assigned_to=x),M&&(r.parent_goal_id=M),w&&(r.start_date=w),E&&(r.end_date=E),n(r)},children:[(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Goal Name *`}),(0,L.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`e.g., Increase Q4 Revenue by 20%`,className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`,autoFocus:!0})]}),(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Description (optional)`}),(0,L.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),placeholder:`Brief description of this goal...`,rows:2,className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px] resize-none`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Target Value *`}),(0,L.jsx)(`input`,{type:`number`,step:`any`,value:d,onChange:e=>f(e.target.value),placeholder:`100000`,className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Current Value`}),(0,L.jsx)(`input`,{type:`number`,step:`any`,value:p,onChange:e=>m(e.target.value),placeholder:`0`,className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Level`}),(0,L.jsxs)(`select`,{value:h,onChange:e=>g(e.target.value),className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`org`,children:`Organization`}),(0,L.jsx)(`option`,{value:`department`,children:`Department`}),(0,L.jsx)(`option`,{value:`team`,children:`Team`}),(0,L.jsx)(`option`,{value:`rep`,children:`Individual Rep`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Status`}),(0,L.jsxs)(`select`,{value:_,onChange:e=>v(e.target.value),className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`active`,children:`Active`}),(0,L.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,L.jsx)(`option`,{value:`paused`,children:`Paused`}),(0,L.jsx)(`option`,{value:`cancelled`,children:`Cancelled`})]})]})]}),(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Assigned To`}),(0,L.jsxs)(`select`,{value:x,onChange:e=>C(e.target.value),className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:``,children:`Unassigned`}),i.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.full_name,` (`,e.email,`)`]},e.id))]})]}),(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Parent Goal`}),(0,L.jsxs)(`select`,{value:M,onChange:e=>N(e.target.value),className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:``,children:`None (top-level goal)`}),P.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.name,` (`,d0(e.level).label,`)`]},e.id))]})]}),(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Weight`}),(0,L.jsx)(`input`,{type:`number`,step:`any`,value:A,onChange:e=>j(e.target.value),placeholder:`1`,className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Start Date`}),(0,L.jsx)(`input`,{type:`date`,value:w,onChange:e=>T(e.target.value),className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`End Date`}),(0,L.jsx)(`input`,{type:`date`,value:E,onChange:e=>D(e.target.value),className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`})]})]}),(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Unit`}),(0,L.jsxs)(`select`,{value:O,onChange:e=>k(e.target.value),className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`$`,children:`USD ($)`}),(0,L.jsx)(`option`,{value:`#`,children:`Count (#)`}),(0,L.jsx)(`option`,{value:`%`,children:`Percentage (%)`})]})]}),o&&(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Company`}),(0,L.jsx)(`select`,{value:y,onChange:e=>b(e.target.value),className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2.5 px-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`,children:r.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),ee&&(0,L.jsx)(`p`,{className:`mb-3 text-sm text-red-600`,children:ee}),(0,L.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-lg border border-surface-200 px-4 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,className:`rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px] flex items-center gap-1.5`,children:o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Create Goal`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Xc,{className:`h-4 w-4`}),`Save Changes`]})})]})]})]})})}function v0({goal:e,depth:t=0,onUpdateProgress:n,onDeleteGoal:r,onEditGoal:i,assignedUserNames:a}){let[o,s]=(0,S.useState)(t<1),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(!1),[f,p]=(0,S.useState)(e.current_value.toString()),[m,h]=(0,S.useState)(`overview`),g=e.sub_goals&&e.sub_goals.length>0,_=d0(e.level),v=u0(e.progress_percentage),y=f0(e.status),b=_.icon,x=e.assigned_to?a[e.assigned_to]||e.assigned_to.slice(0,8)+`...`:null,C=t===0?`pl-0`:t===1?`pl-4`:t===2?`pl-8`:`pl-12`;return(0,L.jsxs)(`div`,{className:`${C}`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border bg-white p-4 mb-2 hover:border-surface-300 transition-colors ${t>0?`border-surface-100`:`border-surface-200`}`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start gap-3`,children:[(0,L.jsx)(`button`,{onClick:()=>{g&&s(!o)},className:`self-start p-1 rounded-md hover:bg-surface-100 min-h-[44px] min-w-[44px] flex items-center justify-center ${g?`cursor-pointer`:`cursor-default`}`,"aria-label":o?`Collapse`:`Expand`,disabled:!g,children:g?o?(0,L.jsx)(Zc,{className:`h-4 w-4 text-surface-400`}):(0,L.jsx)(el,{className:`h-4 w-4 text-surface-400`}):(0,L.jsx)(`div`,{className:`h-4 w-4`})}),t>0&&(0,L.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-px bg-surface-200`,style:{left:t===1?`1.5rem`:t===2?`3rem`:`4.5rem`}}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-1`,children:[(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium ${_.className}`,children:[(0,L.jsx)(b,{className:`h-3 w-3`}),_.label]}),(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-md px-2 py-0.5 text-xs font-medium ${y.className}`,children:y.label}),(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-md px-2 py-0.5 text-xs font-medium ${v.className}`,children:v.label}),e.assigned_to&&x&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md px-2 py-0.5 text-xs font-medium bg-surface-100 text-surface-600`,children:[(0,L.jsx)(`span`,{className:`inline-flex items-center justify-center w-4 h-4 rounded-full bg-brand-200 text-brand-700 text-[9px] font-bold`,children:p0(x)}),x]}),e.start_date&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-surface-400`,children:[(0,L.jsx)(Jc,{className:`h-3 w-3`}),s0(new Date(e.start_date)),e.end_date&&` → ${s0(new Date(e.end_date))}`]})]}),(0,L.jsx)(`h4`,{className:`text-sm font-semibold text-surface-900 truncate`,children:e.name}),e.description&&(0,L.jsx)(`p`,{className:`text-xs text-surface-500 mt-0.5 line-clamp-1`,children:e.description}),g&&(0,L.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,L.jsx)(jl,{className:`h-3 w-3 text-brand-500`}),(0,L.jsxs)(`span`,{className:`text-xs text-brand-600 font-medium`,children:[e.sub_goals.length,` sub-goal`,e.sub_goals.length===1?``:`s`,` `,o?`expanded`:`(click to expand)`]})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-4`,children:[(0,L.jsxs)(`div`,{className:`text-right min-w-[100px]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 justify-end`,children:[(0,L.jsxs)(`span`,{className:`text-lg font-bold ${l0(e.progress_percentage)}`,children:[e.progress_percentage.toFixed(1),`%`]}),e.progress_percentage>=100?(0,L.jsx)(wu,{className:`h-4 w-4 text-green-600`}):e.progress_percentage<50?(0,L.jsx)(Cu,{className:`h-4 w-4 text-red-600`}):null]}),(0,L.jsxs)(`div`,{className:`text-xs text-surface-500`,children:[o0(e.current_value),` / `,o0(e.target_value)]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,L.jsx)(`button`,{onClick:()=>i(e),className:`p-1.5 rounded-md hover:bg-brand-50 text-surface-400 hover:text-brand-600 min-h-[36px] min-w-[36px] flex items-center justify-center`,title:`Edit goal`,children:(0,L.jsx)(Oc,{className:`h-4 w-4`})}),(0,L.jsx)(`button`,{onClick:()=>d(!0),className:`p-1.5 rounded-md hover:bg-surface-100 text-surface-400 hover:text-surface-600 min-h-[36px] min-w-[36px] flex items-center justify-center`,title:`Update progress`,children:(0,L.jsx)(`svg`,{className:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,L.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z`})})}),c?(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`button`,{onClick:()=>{r(e.id),l(!1)},className:`p-1.5 rounded-md bg-red-100 text-red-600 hover:bg-red-200 min-h-[36px] min-w-[36px] flex items-center justify-center`,title:`Confirm delete`,children:(0,L.jsx)(Xc,{className:`h-4 w-4`})}),(0,L.jsx)(`button`,{onClick:()=>l(!1),className:`p-1.5 rounded-md hover:bg-surface-100 text-surface-400 min-h-[36px] min-w-[36px] flex items-center justify-center`,title:`Cancel`,children:(0,L.jsx)(Iu,{className:`h-4 w-4`})})]}):(0,L.jsx)(`button`,{onClick:()=>l(!0),className:`p-1.5 rounded-md hover:bg-red-50 text-surface-400 hover:text-red-600 min-h-[36px] min-w-[36px] flex items-center justify-center`,title:`Delete goal`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})]})]})]}),o&&(0,L.jsxs)(`div`,{className:`mt-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-surface-200`,children:[(0,L.jsxs)(`button`,{onClick:()=>h(`overview`),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-t-md transition-colors min-h-[36px] ${m===`overview`?`bg-surface-100 text-brand-700 border-b-2 border-brand-600`:`text-surface-500 hover:text-surface-700 hover:bg-surface-50`}`,children:[(0,L.jsx)(hl,{className:`h-3 w-3`}),`Overview`]}),(0,L.jsxs)(`button`,{onClick:()=>h(`metrics`),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-t-md transition-colors min-h-[36px] ${m===`metrics`?`bg-surface-100 text-brand-700 border-b-2 border-brand-600`:`text-surface-500 hover:text-surface-700 hover:bg-surface-50`}`,children:[(0,L.jsx)(gc,{className:`h-3 w-3`}),`Metrics (`,e.metrics?.length||0,`)`]})]}),(0,L.jsxs)(`div`,{className:`p-3`,children:[m===`overview`&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`mb-2`,children:(0,L.jsx)(m0,{value:e.current_value,max:e.target_value})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-surface-400 font-medium`,children:`Target`}),(0,L.jsx)(`p`,{className:`text-sm font-bold text-surface-900`,children:o0(e.target_value)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-surface-400 font-medium`,children:`Current`}),(0,L.jsx)(`p`,{className:`text-sm font-bold text-surface-900`,children:o0(e.current_value)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-surface-400 font-medium`,children:`Remaining`}),(0,L.jsx)(`p`,{className:`text-sm font-bold text-surface-900`,children:o0(Math.max(e.target_value-e.current_value,0))})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-2`,children:[(0,L.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-surface-400 font-medium`,children:`Weight`}),(0,L.jsx)(`p`,{className:`text-sm font-bold text-surface-900`,children:e.weight??1})]})]}),(e.start_date||e.end_date)&&(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3 text-xs text-surface-400`,children:[e.start_date&&(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(Jc,{className:`h-3 w-3`}),`Started: `,s0(new Date(e.start_date))]}),e.end_date&&(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(Jc,{className:`h-3 w-3`}),`Ends: `,s0(new Date(e.end_date))]})]})]}),m===`metrics`&&(0,L.jsx)(h0,{metrics:e.metrics})]})]})]}),u&&(0,L.jsx)(`div`,{className:`mt-2 rounded-xl border border-brand-200 bg-brand-50 p-4`,children:(0,L.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let r=parseFloat(f);!isNaN(r)&&r>=0&&n(e.id,r),d(!1)},className:`flex flex-col sm:flex-row gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`label`,{className:`block text-xs font-medium text-surface-700 mb-1`,children:`Update Current Value`}),(0,L.jsx)(`input`,{type:`number`,step:`any`,value:f,onChange:e=>p(e.target.value),className:`w-full rounded-lg border border-surface-200 bg-white py-2 pl-3 pr-3 text-sm focus:outline-none focus:ring-1 focus:ring-brand-600 min-h-[44px]`,autoFocus:!0})]}),(0,L.jsxs)(`div`,{className:`flex gap-2 self-end`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>d(!1),className:`rounded-lg border border-surface-200 px-4 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,className:`rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:`Update`})]})]})}),c&&(0,L.jsx)(`div`,{className:`mt-2 rounded-xl border border-red-200 bg-red-50 p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(jc,{className:`h-5 w-5 text-red-600 shrink-0 mt-0.5`}),(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-red-800`,children:`Delete this goal?`}),(0,L.jsx)(`p`,{className:`text-xs text-red-600 mt-1`,children:`This will also delete all sub-goals. This cannot be undone.`})]})]})}),o&&g&&(0,L.jsx)(`div`,{className:`mt-2 border-l-2 border-brand-100 ml-3 sm:ml-4`,children:e.sub_goals.map(e=>(0,L.jsx)(v0,{goal:e,depth:t+1,onUpdateProgress:n,onDeleteGoal:r,onEditGoal:i,assignedUserNames:a},e.id))})]})}function y0({cascade:e}){let t=[{label:`Departments`,targets:e.dept_targets,totalTarget:e.dept_total_target,totalCurrent:e.dept_total_current,icon:Gc},{label:`Teams`,targets:e.team_targets,totalTarget:e.team_total_target,totalCurrent:e.team_total_current,icon:Pu},{label:`Reps`,targets:e.rep_targets,totalTarget:e.rep_total_target,totalCurrent:e.rep_total_current,icon:Pu}];return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,L.jsx)(mc,{className:`h-5 w-5 text-brand-600`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-900`,children:`Cascade Breakdown`})]}),(0,L.jsx)(`div`,{className:`space-y-4`,children:t.map(e=>{let t=e.totalTarget>0?e.totalCurrent/e.totalTarget*100:0,n=e.icon,r=u0(t);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(n,{className:`h-4 w-4 text-surface-400`}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-surface-700`,children:e.label}),(0,L.jsxs)(`span`,{className:`text-xs text-surface-400`,children:[`(`,e.targets.length,`)`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-md px-2 py-0.5 text-xs font-medium ${r.className}`,children:r.label}),(0,L.jsxs)(`span`,{className:`text-sm font-bold text-surface-900`,children:[t.toFixed(1),`%`]})]})]}),(0,L.jsx)(m0,{value:e.totalCurrent,max:e.totalTarget}),(0,L.jsxs)(`div`,{className:`mt-1 text-xs text-surface-500`,children:[o0(e.totalCurrent),` of `,o0(e.totalTarget)]})]},e.label)})}),e.cascade_variance!==0&&(0,L.jsx)(`div`,{className:`mt-4 pt-3 border-t border-surface-200`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:`Cascade Variance`}),(0,L.jsxs)(`span`,{className:`text-xs font-bold ${e.cascade_variance>=0?`text-green-600`:`text-red-600`}`,children:[e.cascade_variance>0?`+`:``,e.cascade_variance,`%`]})]})})]})}function b0(){let e=ci(),[t,n]=(0,S.useState)(!1),[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)([]),[s,c]=(0,S.useState)(``),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(``),[p,m]=(0,S.useState)(!0),h=(0,S.useMemo)(()=>{let e={include_cascade:p};return s&&(e.level=s),l&&(e.status=l),d&&(e.search=d),e},[s,l,d,p]),{data:g,isLoading:_,error:v}=R({queryKey:[`analytics-goals`,h],queryFn:()=>YQ.getGoals(h)}),{data:y}=R({queryKey:[`analytics-users`],queryFn:()=>YQ.getUsers()}),b=y?.users??[],x=(0,S.useMemo)(()=>{let e={};return b.forEach(t=>{e[t.id]=t.full_name}),e},[b]);(0,S.useEffect)(()=>{(async()=>{try{let e=localStorage.getItem(`auth_token`);if(!e)return;let t=await fetch(`/api/admin/companies`,{headers:{Authorization:`Bearer ${e}`}});if(t.ok){let e=await t.json();e.companies&&o(e.companies)}}catch(e){console.error(`Failed to fetch companies:`,e)}})()},[]);let C=z({mutationFn:({goalId:e,value:t})=>YQ.updateProgress(e,t,!0),onSuccess:()=>{e.invalidateQueries({queryKey:[`analytics-goals`]})}}),w=z({mutationFn:e=>YQ.createGoal(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`analytics-goals`]}),n(!1)}}),T=z({mutationFn:({goalId:e,payload:t})=>YQ.updateGoal(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`analytics-goals`]}),i(null)}}),E=z({mutationFn:e=>YQ.deleteGoal(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`analytics-goals`]})}}),D=(0,S.useCallback)((e,t)=>{C.mutate({goalId:e,value:t})},[C]),O=(0,S.useCallback)(e=>{w.mutate(e)},[w]),k=(0,S.useCallback)(e=>{r&&T.mutate({goalId:r.id,payload:e})},[r,T]),A=(0,S.useCallback)(e=>{E.mutate(e)},[E]),j=(0,S.useCallback)(e=>{i(e)},[]),M=(0,S.useCallback)(()=>{c(``),u(``),f(``),m(!0)},[]);if(_)return(0,L.jsx)($,{title:`Cascading Goals`,children:(0,L.jsx)(FQ,{})});if(v)return(0,L.jsx)($,{title:`Cascading Goals`,children:(0,L.jsxs)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 p-6 text-center`,children:[(0,L.jsx)(`p`,{className:`text-red-700 font-medium`,children:`Failed to load goals`}),(0,L.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:v.message})]})});let N=g?.cascade_summary,ee=g?.goals??[];return(0,L.jsxs)($,{title:`Cascading Goals`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Cascading Goals`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Forecast → Cascade → Track`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-surface-200 bg-white px-3 py-2 min-h-[44px]`,children:[(0,L.jsx)(Jc,{className:`h-4 w-4 text-surface-400`}),(0,L.jsxs)(`span`,{className:`text-sm text-surface-600`,children:[`Updated `,s0(new Date)]})]}),(0,L.jsxs)(`button`,{onClick:()=>e.invalidateQueries({queryKey:[`analytics-goals`]}),className:`inline-flex items-center gap-1.5 rounded-lg border border-surface-200 bg-white px-3 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:[(0,L.jsx)(nu,{className:`h-4 w-4`}),`Refresh`]}),(0,L.jsxs)(`button`,{onClick:()=>n(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-2 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`New Goal`]})]})]}),(0,L.jsx)(g0,{level:s,status:l,search:d,includeCascade:p,onLevelChange:c,onStatusChange:u,onSearchChange:f,onIncludeCascadeChange:m,onReset:M}),N&&(0,L.jsx)(`div`,{className:`mb-8`,children:(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-12 w-12 shrink-0 items-center justify-center rounded-full text-xl ${N.org_progress_percentage>=80?`bg-green-100`:N.org_progress_percentage>=50?`bg-yellow-100`:`bg-red-100`}`,children:N.org_progress_percentage>=80?`🟢`:N.org_progress_percentage>=50?`🟡`:`🔴`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-base font-bold text-surface-900`,children:`Org Revenue Target`}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500`,children:[o0(N.org_current),` of `,o0(N.org_target)]})]})]}),(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-surface-700`,children:`Overall Progress`}),(0,L.jsxs)(`span`,{className:`text-sm font-bold ${l0(N.org_progress_percentage)}`,children:[N.org_progress_percentage.toFixed(1),`%`]})]}),(0,L.jsx)(m0,{value:N.org_current,max:N.org_target})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Org Target`}),(0,L.jsx)(`p`,{className:`text-sm font-bold text-surface-900`,children:o0(N.org_target)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Current`}),(0,L.jsx)(`p`,{className:`text-sm font-bold text-surface-900`,children:o0(N.org_current)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Goals`}),(0,L.jsx)(`p`,{className:`text-sm font-bold text-surface-900`,children:g?.total_goals??0})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Cascade Variance`}),(0,L.jsxs)(`p`,{className:`text-sm font-bold ${N.cascade_variance>=0?`text-green-600`:`text-red-600`}`,children:[N.cascade_variance>0?`+`:``,N.cascade_variance,`%`]})]})]})]})}),N&&(0,L.jsx)(`div`,{className:`mb-8`,children:(0,L.jsx)(y0,{cascade:N})}),(0,L.jsxs)(`div`,{className:`mb-8`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(yu,{className:`h-5 w-5 text-brand-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Goal Hierarchy`}),(0,L.jsxs)(`span`,{className:`text-xs text-surface-400 ml-auto`,children:[ee.length,` org goal`,ee.length===1?``:`s`]})]}),ee.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-8 text-center`,children:[(0,L.jsx)(yu,{className:`h-12 w-12 text-surface-300 mx-auto mb-3`}),(0,L.jsx)(`p`,{className:`text-surface-500 font-medium`,children:`No goals configured`}),(0,L.jsx)(`p`,{className:`text-surface-400 text-sm mt-1 mb-4`,children:`Set up your org goals to start tracking progress`}),(0,L.jsxs)(`button`,{onClick:()=>n(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Create First Goal`]})]}):ee.map(e=>(0,L.jsx)(v0,{goal:e,onUpdateProgress:D,onDeleteGoal:A,onEditGoal:j,assignedUserNames:x},e.id))]}),t&&(0,L.jsx)(_0,{goal:null,onClose:()=>n(!1),onSubmit:O,companies:a,users:b,allGoals:ee,isNew:!0}),r&&(0,L.jsx)(_0,{goal:r,onClose:()=>i(null),onSubmit:k,companies:a,users:b,allGoals:ee,isNew:!1})]})}var x0=`#00A846`;function S0(e){let t=Math.abs(e);return t>=1e6?`${e>=0?`+`:`-`}$${(t/1e6).toFixed(1)}M`:t>=1e3?`${e>=0?`+`:`-`}$${(t/1e3).toFixed(1)}K`:`${e>=0?`+`:``}$${t.toFixed(0)}`}function C0(e){return`$`+e.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:0})}function w0({data:e}){return(0,L.jsx)(Fb,{width:`100%`,height:280,children:(0,L.jsxs)(oQ,{data:e,children:[(0,L.jsx)(KY,{dataKey:`label`,tick:{fontSize:12}}),(0,L.jsx)(sX,{tick:{fontSize:12},tickFormatter:e=>`$${e>=1e3?(e/1e3).toFixed(0)+`K`:e}`}),(0,L.jsx)(ez,{formatter:e=>[`$`+e.toLocaleString(),``],contentStyle:{borderRadius:8,fontSize:13}}),(0,L.jsx)(US,{wrapperStyle:{fontSize:13}}),(0,L.jsx)(oq,{type:`monotone`,dataKey:`actual`,name:`Actual`,stroke:x0,strokeWidth:2,dot:{r:4}}),(0,L.jsx)(oq,{type:`monotone`,dataKey:`budget`,name:`Budget`,stroke:`#94A3B8`,strokeWidth:2,strokeDasharray:`6 4`,dot:{r:3}})]})})}function T0({steps:e}){let t=Math.max(...e.map(e=>Math.abs(e.cumulative)),1),n=e.map((t,n)=>{let r=n===0,i=n===e.length-1;if(r||i)return{label:t.label,baseline:0,value:t.value,color:t.color,type:`total`};let a=e[n-1].cumulative,o=t.value,s=o>=0?a:a+o;return{label:t.label,baseline:s,value:Math.abs(o),color:t.color,type:`delta`}});return(0,L.jsx)(Fb,{width:`100%`,height:320,children:(0,L.jsxs)(cQ,{data:n,barGap:2,children:[(0,L.jsx)(KY,{dataKey:`label`,tick:{fontSize:11},interval:0,angle:-30,textAnchor:`end`,height:60}),(0,L.jsx)(sX,{tick:{fontSize:12},domain:[-t*.1,t*1.1],tickFormatter:e=>`$${Math.abs(e)>=1e3?(Math.abs(e)/1e3).toFixed(0)+`K`:Math.abs(e)}`}),(0,L.jsx)(ez,{formatter:(e,t)=>t===`value`?[`$`+e.toLocaleString(),`Amount`]:[e,t],contentStyle:{borderRadius:8,fontSize:13}}),(0,L.jsx)(TY,{dataKey:`value`,stackId:`waterfall`,children:n.map((e,t)=>(0,L.jsx)(tz,{fill:e.color},`cell-${t}`))})]})})}function E0({node:e,depth:t=0,totalVariance:n}){let[r,i]=(0,S.useState)(t<1),a=e.children.length>0,o=n===0?0:Math.abs(e.value/n*100),s=e.value>=0;return(0,L.jsxs)(`div`,{className:`ml-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 min-h-[44px] px-2 rounded-lg cursor-pointer transition-colors hover:bg-gray-50`,style:{paddingLeft:`${t*16+8}px`},onClick:()=>a&&i(e=>!e),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a&&i(e=>!e))},children:[a?r?(0,L.jsx)(Zc,{className:`w-4 h-4 text-gray-400 flex-shrink-0`}):(0,L.jsx)(el,{className:`w-4 h-4 text-gray-400 flex-shrink-0`}):(0,L.jsx)(`div`,{className:`w-4 flex-shrink-0`}),(0,L.jsx)(`span`,{className:`text-sm font-medium flex-1`,children:e.label}),(0,L.jsx)(`span`,{className:`text-sm font-semibold ${s?`text-green-600`:`text-red-600`}`,children:S0(e.value)}),(0,L.jsxs)(`span`,{className:`text-xs text-gray-400 w-12 text-right`,children:[o.toFixed(1),`%`]})]}),r&&a&&(0,L.jsx)(`div`,{className:`ml-2 border-l-2 border-gray-100 pl-2`,children:e.children.map((e,r)=>(0,L.jsx)(E0,{node:e,depth:t+1,totalVariance:n},`${e.label}-${r}`))}),r&&e.details&&(0,L.jsx)(`div`,{className:`ml-8 mt-1 mb-2 p-2 bg-gray-50 rounded-md`,children:Object.entries(e.details).map(([e,t])=>(0,L.jsxs)(`div`,{className:`text-xs text-gray-500`,children:[(0,L.jsxs)(`span`,{className:`font-medium text-gray-600`,children:[e.replace(/_/g,` `),`:`]}),` `,typeof t==`number`?t>=0&&e.includes(`rate`)?`${(t*100).toFixed(1)}%`:t.toLocaleString():String(t)]},e))})]})}function D0({factor:e,index:t}){let n=e.value>=0,r=e.direction===`neutral`,i=[x0,`#3B82F6`,`#F59E0B`,`#8B5CF6`],a=i[t%i.length];return(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-100 p-4 flex flex-col gap-3 hover:shadow-sm transition-shadow`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`w-3 h-3 rounded-full`,style:{backgroundColor:a}}),(0,L.jsx)(`span`,{className:`text-sm font-semibold text-gray-800`,children:e.label})]}),r?(0,L.jsx)(vc,{className:`w-4 h-4 text-gray-400`}):n?(0,L.jsx)(wu,{className:`w-4 h-4 text-green-500`}):(0,L.jsx)(Cu,{className:`w-4 h-4 text-red-500`})]}),(0,L.jsx)(`div`,{className:`text-2xl font-bold ${n?`text-green-600`:r?`text-gray-400`:`text-red-600`}`,children:S0(e.value)}),(0,L.jsxs)(`div`,{className:`text-xs text-gray-500`,children:[e.percentage.toFixed(1),`% of total • `,e.description]}),(0,L.jsxs)(`div`,{className:`text-xs text-gray-400 border-t pt-2 mt-auto`,children:[`💡 `,e.recommendation]})]})}function O0(){let{data:e,isLoading:t}=R({queryKey:[`strategic-overview`],queryFn:XQ.getOverview,staleTime:6e4}),{data:n,isLoading:r}=R({queryKey:[`strategic-waterfall`],queryFn:XQ.getWaterfall,staleTime:6e4}),{data:i,isLoading:a}=R({queryKey:[`strategic-root-cause`],queryFn:XQ.getRootCause,staleTime:6e4}),{data:o,isLoading:s}=R({queryKey:[`strategic-contribution`],queryFn:XQ.getContribution,staleTime:6e4});if(t||r||a||s)return(0,L.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,L.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-2 border-gray-200 border-t-brand-600`})});let c=e?.variance>=0;return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-gray-900`,children:`Strategic Intelligence`}),(0,L.jsxs)(`p`,{className:`text-sm text-gray-500 mt-1`,children:[`FP&A-grade waterfall analysis and drillable root-cause trees. See every dollar explained.`,e?.period_label&&` — ${e.period_label}`]})]}),(0,L.jsx)(`div`,{className:`bg-white rounded-xl border border-gray-100 p-6`,children:(0,L.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs text-gray-400 uppercase tracking-wider`,children:`Budget`}),(0,L.jsx)(`div`,{className:`text-2xl font-bold text-gray-800 mt-1`,children:e?.budget?C0(e.budget):`$0`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs text-gray-400 uppercase tracking-wider`,children:`Actual`}),(0,L.jsx)(`div`,{className:`text-2xl font-bold text-gray-800 mt-1`,children:e?.actual?C0(e.actual):`$0`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs text-gray-400 uppercase tracking-wider`,children:`Forecast`}),(0,L.jsx)(`div`,{className:`text-2xl font-bold text-gray-800 mt-1`,children:e?.forecast?C0(e.forecast):`$0`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xs text-gray-400 uppercase tracking-wider`,children:`Variance`}),(0,L.jsxs)(`div`,{className:`text-2xl font-bold mt-1 flex items-center gap-1 ${c?`text-green-600`:`text-red-600`}`,children:[c?(0,L.jsx)(zc,{className:`w-5 h-5`}):(0,L.jsx)(Pc,{className:`w-5 h-5`}),S0(e?.variance??0)]}),(0,L.jsx)(`div`,{className:`text-xs mt-1 ${c?`text-green-500`:`text-red-500`}`,children:S0(e?.variance_pct??0)})]})]})}),(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-100 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,L.jsx)(mc,{className:`w-5 h-5 text-brand-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-gray-800`,children:`Revenue Waterfall`})]}),n?.waterfall&&n.waterfall.length>0?(0,L.jsx)(T0,{steps:n.waterfall}):(0,L.jsx)(`div`,{className:`text-center text-gray-400 py-12`,children:`No waterfall data available. Add CRM deals to see the revenue breakdown.`}),n?.market_mix&&n.market_mix.length>0&&(0,L.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-gray-100`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-gray-600 mb-2`,children:`Revenue by Source`}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.market_mix.map(e=>(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 bg-gray-50 rounded-md text-xs text-gray-600`,children:[e.source,`: `,(0,L.jsx)(`span`,{className:`font-semibold`,children:C0(e.value)})]},e.source))})]})]}),(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-100 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,L.jsx)(Tc,{className:`w-5 h-5 text-brand-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-gray-800`,children:`Contribution Analysis`})]}),o?.factors&&o.factors.length>0?(0,L.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:o.factors.map((e,t)=>(0,L.jsx)(D0,{factor:e,index:t},e.name))}):(0,L.jsx)(`div`,{className:`text-center text-gray-400 py-8`,children:`No contribution data available.`}),o?.source_breakdown&&o.source_breakdown.length>0&&(0,L.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-gray-100`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-gray-600 mb-2`,children:`Source Breakdown`}),(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-xs text-gray-600`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b`,children:[(0,L.jsx)(`th`,{className:`text-left py-1 px-2`,children:`Source`}),(0,L.jsx)(`th`,{className:`text-right py-1 px-2`,children:`Current`}),(0,L.jsx)(`th`,{className:`text-right py-1 px-2`,children:`Previous`}),(0,L.jsx)(`th`,{className:`text-right py-1 px-2`,children:`Change`})]})}),(0,L.jsx)(`tbody`,{children:o.source_breakdown.map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-gray-50`,children:[(0,L.jsx)(`td`,{className:`py-1 px-2`,children:e.source}),(0,L.jsx)(`td`,{className:`text-right py-1 px-2`,children:C0(e.current)}),(0,L.jsx)(`td`,{className:`text-right py-1 px-2`,children:C0(e.previous)}),(0,L.jsx)(`td`,{className:`text-right py-1 px-2 font-semibold ${e.change>=0?`text-green-600`:`text-red-600`}`,children:S0(e.change)})]},e.source))})]})})]})]}),(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-100 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,L.jsx)(_l,{className:`w-5 h-5 text-brand-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-gray-800`,children:`Root Cause Drill-Down`})]}),i?.root&&i.root.children.length>0?(0,L.jsxs)(`div`,{className:`border rounded-lg p-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 bg-gray-50 rounded-md mb-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-bold text-gray-700`,children:i.root.label}),(0,L.jsx)(`span`,{className:`text-sm font-bold ${i.root.value>=0?`text-green-600`:`text-red-600`}`,children:S0(i.root.value)}),(0,L.jsxs)(`span`,{className:`text-xs text-gray-400`,children:[`Budget: `,C0(i.root.budget),` → Actual: `,C0(i.root.actual)]})]}),i.root.children.map((e,t)=>(0,L.jsx)(E0,{node:e,depth:0,totalVariance:i.root.value},`${e.label}-${t}`))]}):(0,L.jsx)(`div`,{className:`text-center text-gray-400 py-8`,children:`No root cause data available. Add CRM deals to see variance drill-down.`})]}),(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-100 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,L.jsx)(wu,{className:`w-5 h-5 text-brand-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-gray-800`,children:`6-Month Trend`})]}),e?.trend&&e.trend.length>0?(0,L.jsx)(w0,{data:e.trend}):(0,L.jsx)(`div`,{className:`text-center text-gray-400 py-12`,children:`No trend data available yet.`})]})]})}function k0(){return(0,L.jsx)($,{children:(0,L.jsx)(O0,{})})}var A0=e=>e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(2)}`,j0=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(0),M0=e=>`${(e*100).toFixed(1)}%`;function N0({title:e,value:t,subtitle:n,icon:r,color:i}){return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:e}),(0,L.jsx)(`div`,{className:`rounded-lg p-2 ${i}`,children:(0,L.jsx)(r,{className:`h-4 w-4`})})]}),(0,L.jsx)(`p`,{className:`mt-2 text-2xl font-bold text-surface-900`,children:t}),n&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:n})]})}function P0({trend:e}){return e===`up`?(0,L.jsx)(Rc,{className:`h-4 w-4 text-green-600`}):e===`down`?(0,L.jsx)(Nc,{className:`h-4 w-4 text-red-500`}):(0,L.jsx)(Bl,{className:`h-4 w-4 text-surface-400`})}function F0(e){return e>=4?`bg-green-100 text-green-800`:e>=2?`bg-yellow-100 text-yellow-800`:`bg-red-100 text-red-800`}function I0(e){return e>=4?`text-green-700`:e>=2?`text-yellow-700`:`text-red-700`}function L0({confidence:e}){return(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${{high:`bg-green-100 text-green-800`,medium:`bg-yellow-100 text-yellow-800`,low:`bg-red-100 text-red-800`}[e]}`,children:e})}function R0({channels:e}){let[t,n]=(0,S.useState)(`roas`),[r,i]=(0,S.useState)(`desc`),a=[...e].sort((e,n)=>{let i=e[t],a=n[t];return typeof i==`number`&&typeof a==`number`?r===`asc`?i-a:a-i:r===`asc`?String(i).localeCompare(String(a)):String(a).localeCompare(String(i))}),o=e=>{t===e?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))},s=({col:e})=>t===e?(0,L.jsx)(`span`,{className:`ml-1`,children:r===`asc`?`↑`:`↓`}):(0,L.jsx)(`span`,{className:`ml-1 opacity-30`,children:`↕`});return(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[[{key:`channel`,label:`Channel`},{key:`spend`,label:`Spend`},{key:`clicks`,label:`Clicks`},{key:`ctr`,label:`CTR`},{key:`cpc`,label:`CPC`},{key:`conversions`,label:`Conversions`},{key:`attributed_revenue`,label:`Revenue`},{key:`roas`,label:`ROAS`},{key:`ltv_cac`,label:`LTV:CAC`}].map(e=>(0,L.jsxs)(`th`,{className:`cursor-pointer whitespace-nowrap px-4 py-3 font-semibold text-surface-700 hover:bg-surface-100`,onClick:()=>o(e.key),children:[e.label,(0,L.jsx)(s,{col:e.key})]},e.key)),(0,L.jsx)(`th`,{className:`whitespace-nowrap px-4 py-3 font-semibold text-surface-700`,children:`Trend`})]})}),(0,L.jsx)(`tbody`,{children:a.map((e,t)=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 last:border-0 ${t%2==0?`bg-white`:`bg-surface-50/50`}`,children:[(0,L.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3 font-medium text-surface-900`,children:e.channel}),(0,L.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3 text-surface-600`,children:A0(e.spend)}),(0,L.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3 text-surface-600`,children:j0(e.clicks)}),(0,L.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3 text-surface-600`,children:M0(e.ctr)}),(0,L.jsxs)(`td`,{className:`whitespace-nowrap px-4 py-3 text-surface-600`,children:[`$`,e.cpc.toFixed(2)]}),(0,L.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3 text-surface-600`,children:j0(e.conversions)}),(0,L.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3 text-surface-600`,children:A0(e.attributed_revenue)}),(0,L.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-semibold ${F0(e.roas)}`,children:[e.roas.toFixed(2),`x`]})}),(0,L.jsxs)(`td`,{className:`whitespace-nowrap px-4 py-3 font-medium ${I0(e.ltv_cac)}`,children:[e.ltv_cac.toFixed(2),`x`]}),(0,L.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3`,children:(0,L.jsx)(P0,{trend:e.trend})})]},e.source_service))})]})})}function z0({matrixData:e}){let{rows:t,channels:n,channel_names:r}=e;if(!t.length||!n.length)return(0,L.jsx)(`div`,{className:`flex h-40 items-center justify-center rounded-xl border border-dashed border-surface-300 bg-white text-surface-400`,children:`No matrix data available`});let i=e=>e>=4?`bg-green-200 text-green-900`:e>=2?`bg-yellow-200 text-yellow-900`:e>=1?`bg-orange-100 text-orange-900`:`bg-red-100 text-red-900`;return(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`px-4 py-3 font-semibold text-surface-700`,children:`Dimension`}),(0,L.jsx)(`th`,{className:`px-2 py-3 font-semibold text-surface-700`,children:`Type`}),n.map(e=>(0,L.jsx)(`th`,{className:`px-4 py-3 font-semibold text-surface-700`,children:r[e]||e.replace(`_`,` `)},e))]})}),(0,L.jsx)(`tbody`,{children:t.map((e,t)=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 last:border-0 ${t%2==0?`bg-white`:`bg-surface-50/50`}`,children:[(0,L.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3 font-medium text-surface-900`,children:e.dimension}),(0,L.jsx)(`td`,{className:`whitespace-nowrap px-2 py-3 text-xs text-surface-500 uppercase`,children:e.type}),n.map(t=>{let n=e[t],r=n?.roas??0;return(0,L.jsx)(`td`,{className:`whitespace-nowrap px-4 py-3 text-center`,children:(0,L.jsxs)(`div`,{className:`inline-flex flex-col items-center rounded-lg px-3 py-2 ${i(r)}`,children:[(0,L.jsxs)(`span`,{className:`text-xs font-bold`,children:[r.toFixed(2),`x`]}),(0,L.jsx)(`span`,{className:`text-[10px] opacity-70`,children:n?.revenue?A0(n.revenue):`$0`})]})},t)})]},`${e.type}-${e.dimension}`))})]})})}function B0({data:e}){let t=(0,S.useState)(()=>{try{let e=localStorage.getItem(`applied_recommendations`);return e?JSON.parse(e):[]}catch{return[]}})[0],n=e=>{let n=[...t,e];localStorage.setItem(`applied_recommendations`,JSON.stringify(n))};return e.recommendations.length?(0,L.jsx)(`div`,{className:`space-y-4`,children:e.recommendations.map(e=>{let r=t.includes(e.id);return(0,L.jsx)(`div`,{className:`rounded-xl border p-4 sm:p-5 transition-colors ${r?`border-green-300 bg-green-50`:`border-surface-200 bg-white`}`,children:(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Ic,{className:`h-4 w-4 text-brand-600`}),(0,L.jsx)(`h4`,{className:`text-sm font-semibold text-surface-900`,children:e.description}),(0,L.jsx)(L0,{confidence:e.confidence}),r&&(0,L.jsx)(yc,{className:`h-4 w-4 text-green-600`})]}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:e.reason}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-4 text-xs`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-400`,children:`Current Revenue: `}),(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:A0(e.current_revenue)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-400`,children:`Projected: `}),(0,L.jsx)(`span`,{className:`font-medium text-green-700`,children:A0(e.projected_revenue)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-400`,children:`Revenue Lift: `}),(0,L.jsxs)(`span`,{className:`font-semibold text-green-700`,children:[`+`,A0(e.revenue_lift),` (`,e.revenue_lift_pct,`%)`]})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsxs)(`span`,{className:`text-red-600`,children:[e.from_channel,` (`,e.current_roas_from,`x ROAS)`]}),(0,L.jsx)(V0,{className:`h-3 w-3 text-surface-400`}),(0,L.jsxs)(`span`,{className:`text-green-700`,children:[e.to_channel,` (`,e.current_roas_to,`x ROAS)`]})]})]})]}),(0,L.jsx)(`button`,{onClick:()=>n(e.id),disabled:r,className:`shrink-0 min-h-[44px] rounded-lg px-4 py-2 text-sm font-medium transition-colors ${r?`cursor-not-allowed bg-green-200 text-green-800`:`bg-brand-600 text-white hover:bg-brand-700`}`,children:r?`Applied ✓`:`Apply`})]})},e.id)})}):(0,L.jsxs)(`div`,{className:`rounded-xl border border-dashed border-surface-300 bg-white p-8 text-center`,children:[(0,L.jsx)(Ru,{className:`mx-auto h-8 w-8 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm font-medium text-surface-500`,children:`No recommendations yet`}),(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:`Add ad spend data to generate budget reallocation suggestions.`})]})}function V0(e){return(0,L.jsxs)(`svg`,{...e,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`,children:[(0,L.jsx)(`path`,{d:`m13 17 5-5-5-5`}),(0,L.jsx)(`path`,{d:`m13 12 5 5-5 5`}),(0,L.jsx)(`path`,{d:`M2 12h20`}),(0,L.jsx)(`path`,{d:`m2 12 5 5-5 5`}),(0,L.jsx)(`path`,{d:`m2 17 5-5-5-5`})]})}function H0(){let{data:e,isLoading:t}=R({queryKey:[`scale-overview`],queryFn:ZQ.getOverview}),{data:n,isLoading:r}=R({queryKey:[`scale-channels`],queryFn:ZQ.getChannels}),{data:i,isLoading:a}=R({queryKey:[`scale-matrix`],queryFn:ZQ.getMatrix}),{data:o,isLoading:s}=R({queryKey:[`scale-recommendations`],queryFn:ZQ.getRecommendations}),{data:c,isLoading:l}=R({queryKey:[`scale-run-rate`],queryFn:ZQ.getRunRate});return(0,L.jsx)($,{title:`Scale Optimization`,children:(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Scale Optimization`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`ROAS, LTV:CAC by product × channel × market. AI-powered budget reallocation.`})]}),(t||r||a||s||l)&&!e&&(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,L.jsx)(K,{className:`h-8 w-8 animate-spin text-brand-600`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading analytics data...`})]}),e&&(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 lg:grid-cols-3 xl:grid-cols-6`,children:[(0,L.jsx)(N0,{title:`Ad Spend (30d)`,value:A0(e.total_spend_30d),subtitle:`90d: ${A0(e.total_spend_90d)}`,icon:dl,color:`bg-blue-100 text-blue-700`}),(0,L.jsx)(N0,{title:`ROAS`,value:`${e.overall_roas.toFixed(2)}x`,subtitle:`Overall return on ad spend`,icon:wu,color:e.overall_roas>=4?`bg-green-100 text-green-700`:e.overall_roas>=2?`bg-yellow-100 text-yellow-700`:`bg-red-100 text-red-700`}),(0,L.jsx)(N0,{title:`LTV:CAC`,value:`${e.avg_ltv_cac.toFixed(2)}x`,subtitle:`Lifetime value vs acquisition cost`,icon:yu,color:`bg-purple-100 text-purple-700`}),(0,L.jsx)(N0,{title:`Conversions`,value:j0(e.total_conversions),subtitle:`Last 30 days`,icon:Pu,color:`bg-indigo-100 text-indigo-700`}),(0,L.jsx)(N0,{title:`Attributed Revenue`,value:A0(e.attributed_revenue),subtitle:`Won deals (90d)`,icon:mc,color:`bg-emerald-100 text-emerald-700`}),(0,L.jsx)(N0,{title:`Active Campaigns`,value:String(e.total_active_campaigns),subtitle:`Across ${Object.keys(e.campaigns_by_channel).length} channels`,icon:Ru,color:`bg-orange-100 text-orange-700`})]}),c&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2`,children:[(0,L.jsx)(wu,{className:`h-5 w-5 text-surface-700`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Run Rate vs Annual Target`}),c.pace&&(0,L.jsx)(`span`,{className:`ml-auto inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${c.pace===`on_track`?`bg-green-100 text-green-800`:`bg-red-100 text-red-800`}`,children:c.pace===`on_track`?`● On Track`:`● Behind Pace`})]}),c.annual_target?(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsxs)(`div`,{className:`mb-1 flex justify-between text-sm`,children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`YTD Revenue`}),(0,L.jsxs)(`span`,{className:`font-semibold text-surface-900`,children:[A0(c.ytd_revenue),` / `,A0(c.annual_target)]})]}),(0,L.jsx)(`div`,{className:`h-4 w-full overflow-hidden rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full transition-all ${c.pace===`on_track`?`bg-green-500`:`bg-amber-500`}`,style:{width:`${Math.min(c.annual_target>0?c.ytd_revenue/c.annual_target*100:0,100)}%`}})}),(0,L.jsxs)(`div`,{className:`mt-1 flex justify-between text-xs text-surface-400`,children:[(0,L.jsxs)(`span`,{children:[c.months_elapsed,` mo elapsed`]}),(0,L.jsxs)(`span`,{children:[c.months_remaining,` mo remaining`]})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Annualized Run Rate`}),(0,L.jsx)(`p`,{className:`mt-1 text-lg font-bold text-surface-900`,children:c.run_rate?A0(c.run_rate):`—`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Pace`}),(0,L.jsx)(`p`,{className:`mt-1 text-lg font-bold ${c.pace===`on_track`?`text-green-600`:`text-amber-600`}`,children:c.pace===`on_track`?`On Track`:`Behind`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Required Monthly`}),(0,L.jsx)(`p`,{className:`mt-1 text-lg font-bold text-surface-900`,children:c.required_monthly?A0(c.required_monthly):`—`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Remaining Needed`}),(0,L.jsx)(`p`,{className:`mt-1 text-lg font-bold text-surface-900`,children:c.remaining_needed?A0(c.remaining_needed):`—`})]})]})]}):(0,L.jsxs)(`div`,{className:`rounded-lg bg-amber-50 p-4 text-sm text-amber-800`,children:[(0,L.jsx)(`p`,{className:`font-medium`,children:`No annual target set`}),(0,L.jsx)(`p`,{className:`mt-1`,children:`Set a target revenue in Company Settings to track your run rate.`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,L.jsx)(mc,{className:`h-5 w-5 text-surface-700`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Channel Performance`})]}),n&&n.channels.length>0?(0,L.jsx)(R0,{channels:n.channels}):(0,L.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-dashed border-surface-300 bg-white py-12 text-surface-400`,children:(0,L.jsxs)(`div`,{className:`text-center`,children:[(0,L.jsx)(mc,{className:`mx-auto h-8 w-8`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm font-medium`,children:`No channel data`}),(0,L.jsx)(`p`,{className:`text-xs`,children:`Connect Google Ads or Facebook Ads to see channel performance.`})]})})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,L.jsx)(yu,{className:`h-5 w-5 text-surface-700`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Product × Channel Matrix`})]}),i&&!a?(0,L.jsx)(z0,{matrixData:i}):(0,L.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-dashed border-surface-300 bg-white py-12 text-surface-400`,children:(0,L.jsxs)(`div`,{className:`text-center`,children:[(0,L.jsx)(yu,{className:`mx-auto h-8 w-8`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm font-medium`,children:`No matrix data`}),(0,L.jsx)(`p`,{className:`text-xs`,children:`Product and market data from won deals will appear here.`})]})})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,L.jsx)(Ru,{className:`h-5 w-5 text-brand-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Budget Recommendations`})]}),o&&!s?(0,L.jsx)(B0,{data:o}):(0,L.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-dashed border-surface-300 bg-white py-12 text-surface-400`,children:(0,L.jsxs)(`div`,{className:`text-center`,children:[(0,L.jsx)(Ru,{className:`mx-auto h-8 w-8`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm font-medium`,children:`No recommendations yet`}),(0,L.jsx)(`p`,{className:`text-xs`,children:`AI generates budget reallocation suggestions from your ad data.`})]})})]})]})})}var U0=[{value:``,label:`All Statuses`},{value:`new`,label:`New`},{value:`assigned`,label:`Assigned`},{value:`contacted`,label:`Contacted`},{value:`converted`,label:`Converted`},{value:`lost`,label:`Lost`}],W0={new:`bg-brand-100 text-brand-700`,assigned:`bg-surface-200 text-surface-700`,contacted:`bg-warning/10 text-warning`,converted:`bg-success/10 text-success`,lost:`bg-red-100 text-red-700`},G0={new:(0,L.jsx)(wu,{className:`mr-1 h-3 w-3`}),assigned:(0,L.jsx)(hl,{className:`mr-1 h-3 w-3`}),contacted:(0,L.jsx)(Fl,{className:`mr-1 h-3 w-3`}),converted:(0,L.jsx)(wu,{className:`mr-1 h-3 w-3`}),lost:(0,L.jsx)(Zl,{className:`mr-1 h-3 w-3`})};function K0(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(``),{data:i,isLoading:a}=R({queryKey:[`admin-leads`,n],queryFn:()=>KQ.getLeads()}),o=i?.items??[],s=o.filter(t=>{let r=t.name.toLowerCase().includes(e.toLowerCase())||t.email.toLowerCase().includes(e.toLowerCase())||t.company.toLowerCase().includes(e.toLowerCase()),i=!n||t.status===n;return r&&i});return a?(0,L.jsx)($,{title:`Leads`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Leads`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Leads`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-surface-500`,children:[o.length,` lead`,o.length===1?``:`s`,` in the pipeline`]})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(wc,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`select`,{value:n,onChange:e=>r(e.target.value),className:`w-full sm:w-48 rounded-lg border border-surface-300 py-2.5 pl-9 pr-3 text-sm outline-none focus:border-brand-500 appearance-none min-h-[44px]`,children:U0.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search leads...`,className:`w-full rounded-lg border border-surface-300 py-2.5 pl-9 pr-4 text-sm outline-none focus:border-brand-500 sm:w-64 min-h-[44px]`})]})]})]}),s.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(wu,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:e||n?`No leads match your filters`:`No leads yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Leads will appear here when they come through the system`})]}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white`,children:(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 pl-5 text-left font-medium text-surface-500`,children:`Lead`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Company`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Source`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Assigned To`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500 pr-5`,children:`Created`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:s.map(e=>(0,L.jsxs)(`tr`,{className:`hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`py-3 pl-5`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-full bg-brand-100 text-xs font-semibold text-brand-700`,children:e.name.charAt(0).toUpperCase()}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`font-medium text-surface-900 truncate`,children:e.name}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500 truncate`,children:e.email}),e.phone&&(0,L.jsxs)(`p`,{className:`text-xs text-surface-500 flex items-center gap-1 mt-0.5`,children:[(0,L.jsx)(Zl,{className:`h-3 w-3`}),e.phone]})]})]})}),(0,L.jsx)(`td`,{className:`py-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 text-surface-700 min-w-0`,children:[(0,L.jsx)(Kc,{className:`h-3.5 w-3.5 text-surface-500 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.company||`—`})]})}),(0,L.jsx)(`td`,{className:`py-3`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${W0[e.status]||`bg-surface-200 text-surface-600`}`,children:[G0[e.status],e.status]})}),(0,L.jsx)(`td`,{className:`py-3 text-surface-600`,children:e.source||`—`}),(0,L.jsx)(`td`,{className:`py-3 text-surface-600 truncate`,children:e.assignedTo||`Unassigned`}),(0,L.jsx)(`td`,{className:`py-3 text-right text-surface-500 pr-5`,children:new Date(e.createdAt).toLocaleDateString()})]},e.id))})]})})})]})}var q0={crm:{bg:`bg-blue-100`,icon:`text-blue-600`,label:`CRM`},accounting:{bg:`bg-green-100`,icon:`text-green-600`,label:`Accounting`},advertising:{bg:`bg-purple-100`,icon:`text-purple-600`,label:`Advertising`},automation:{bg:`bg-orange-100`,icon:`text-orange-600`,label:`Automation`},telephony:{bg:`bg-amber-100`,icon:`text-amber-600`,label:`Telephony`},default:{bg:`bg-surface-100`,icon:`text-surface-600`,label:`Integration`}};function J0(e){return e===`hubspot`?q0.crm:e===`quickbooks`?q0.accounting:e===`google_ads`||e===`googleads`?q0.advertising:e===`zapier`?q0.automation:e===`sms`?q0.telephony:q0.default}function Y0(e){switch(e){case`connected`:return{icon:yc,color:`text-green-600`,label:`Connected`};case`syncing`:return{icon:nu,color:`text-blue-600`,label:`Syncing...`};case`error`:return{icon:vc,color:`text-red-600`,label:`Error`};default:return{icon:al,color:`text-surface-400`,label:`Inactive`}}}function X0({connector:e,onConnect:t,disabled:n}){let r=J0(e.service);return(0,L.jsxs)(`div`,{className:`group relative flex flex-col rounded-xl border border-surface-200 bg-white p-5 sm:p-6 transition-shadow hover:shadow-md ${n?`opacity-60`:``}`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${r.bg}`,children:(0,L.jsx)($l,{className:`h-5 w-5 ${r.icon}`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-900`,children:e.name}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:r.label})]})]}),(0,L.jsx)(`span`,{className:`rounded-full bg-surface-100 px-2 py-0.5 text-[10px] font-medium text-surface-500`,children:e.auth_type===`oauth2`?`OAuth`:`API Key`})]}),(0,L.jsx)(`p`,{className:`mb-4 text-sm text-surface-600 flex-1`,children:e.description}),(0,L.jsxs)(`div`,{className:`mb-4 flex flex-wrap gap-1.5`,children:[(e.capabilities||[]).slice(0,4).map(e=>(0,L.jsx)(`span`,{className:`rounded-md bg-surface-50 px-2 py-0.5 text-[10px] font-medium text-surface-500`,children:e},e)),e.capabilities&&e.capabilities.length>4&&(0,L.jsxs)(`span`,{className:`rounded-md bg-surface-50 px-2 py-0.5 text-[10px] font-medium text-surface-500`,children:[`+`,e.capabilities.length-4,` more`]})]}),(0,L.jsxs)(`div`,{className:`mt-auto flex items-center justify-between border-t border-surface-100 pt-4`,children:[(0,L.jsxs)(`a`,{href:e.docs_url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-surface-400 hover:text-surface-600 min-h-[44px]`,children:[`Docs `,(0,L.jsx)(pl,{className:`h-3 w-3`})]}),n?(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-100 px-3 py-2 text-sm font-medium text-surface-400 cursor-not-allowed min-h-[44px]`,children:[(0,L.jsx)(hl,{className:`h-4 w-4`}),`View Only`]}):(0,L.jsxs)(`button`,{onClick:()=>t(e),className:`flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Connect`]})]})]})}function Z0({connector:e,onSync:t,onDisconnect:n,onReconnect:r,syncing:i,readOnly:a,isOAuth:o}){let[s,c]=(0,S.useState)(!1),[l,u]=(0,S.useState)([]),d=Y0(e.status),f=d.icon,p=(0,S.useCallback)(async()=>{try{u((await f$.logs(e.id)).logs)}catch{u([])}},[e.id]);return(0,L.jsxs)(`div`,{className:`relative flex flex-col rounded-xl border border-surface-200 bg-white p-5 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${J0(e.service).bg}`,children:(0,L.jsx)($l,{className:`h-5 w-5 ${J0(e.service).icon}`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-900 capitalize`,children:e.service.replace(`_`,` `)}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 ${d.color}`,children:[(0,L.jsx)(f,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),(0,L.jsx)(`span`,{className:`text-xs font-medium`,children:d.label}),e.last_sync_at&&(0,L.jsxs)(`span`,{className:`text-xs text-surface-400`,children:[` · `,`Last synced `,new Date(e.last_sync_at).toLocaleString()]})]})]})]}),(0,L.jsxs)(`select`,{value:e.sync_frequency,onChange:e=>{},className:`rounded-lg border border-surface-200 bg-surface-50 px-2 py-1 text-xs font-medium text-surface-600 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`real_time`,children:`Real-time`}),(0,L.jsx)(`option`,{value:`hourly`,children:`Hourly`}),(0,L.jsx)(`option`,{value:`daily`,children:`Daily`})]})]}),e.error_message&&(0,L.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded-lg bg-red-50 p-3`,children:[(0,L.jsx)(vc,{className:`mt-0.5 h-4 w-4 shrink-0 text-red-600`}),(0,L.jsx)(`p`,{className:`text-xs text-red-700`,children:e.error_message})]}),(0,L.jsx)(`div`,{className:`mt-auto flex items-center gap-2 border-t border-surface-100 pt-4`,children:a?(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-100 px-3 py-2 text-sm font-medium text-surface-400 cursor-not-allowed min-h-[44px]`,children:[(0,L.jsx)(fu,{className:`h-4 w-4`}),`Read Only`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{onClick:()=>t(e.id),disabled:i||e.status===`syncing`,className:`flex items-center gap-1.5 rounded-lg bg-surface-100 px-3 py-2 text-sm font-medium text-surface-700 transition-colors hover:bg-surface-200 disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(nu,{className:`h-4 w-4 ${i?`animate-spin`:``}`}),`Sync Now`]}),(0,L.jsxs)(`button`,{onClick:async()=>{s||await p(),c(e=>!e)},className:`flex items-center gap-1.5 rounded-lg bg-surface-100 px-3 py-2 text-sm font-medium text-surface-700 transition-colors hover:bg-surface-200 min-h-[44px]`,children:[(0,L.jsx)(Mc,{className:`h-4 w-4`}),`Logs`]}),o&&r&&(0,L.jsxs)(`button`,{onClick:()=>r(e),className:`flex items-center gap-1.5 rounded-lg bg-brand-50 px-3 py-2 text-sm font-medium text-brand-700 transition-colors hover:bg-brand-100 min-h-[44px]`,children:[(0,L.jsx)($l,{className:`h-4 w-4`}),`Reconnect`]}),(0,L.jsxs)(`button`,{onClick:()=>n(e.id),className:`ml-auto flex items-center gap-1.5 rounded-lg bg-red-50 px-3 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-100 min-h-[44px]`,children:[(0,L.jsx)(Su,{className:`h-4 w-4`}),`Disconnect`]})]})}),s&&(0,L.jsx)(`div`,{className:`mt-4 max-h-48 overflow-y-auto rounded-lg border border-surface-200 bg-surface-50 p-3`,children:l.length===0?(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:`No sync logs yet`}):(0,L.jsx)(`div`,{className:`space-y-2`,children:l.map(e=>(0,L.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,L.jsx)(`span`,{className:`shrink-0 font-medium ${e.status===`success`?`text-green-600`:e.status===`error`?`text-red-600`:`text-surface-400`}`,children:e.status}),(0,L.jsx)(`span`,{className:`text-surface-600`,children:e.event_type}),e.record_count>0&&(0,L.jsxs)(`span`,{className:`text-surface-400`,children:[e.record_count,` records`]}),e.duration_ms!=null&&(0,L.jsxs)(`span`,{className:`text-surface-400`,children:[e.duration_ms,`ms`]}),(0,L.jsx)(`span`,{className:`ml-auto shrink-0 text-surface-300`,children:new Date(e.created_at).toLocaleTimeString()})]},e.id))})})]})}function Q0({connector:e,onClose:t,onSuccess:n}){let[r,i]=(0,S.useState)({}),[a,o]=(0,S.useState)(!1),[s,c]=(0,S.useState)(``),l=async t=>{t.preventDefault(),c(``),o(!0);try{let t=await f$.create(e.service,r,`hourly`);t.connector.status===`connected`?n():c(t.connector.error_message||`Connection failed`)}catch(e){c(e?.response?.data?.error||`Connection failed`)}finally{o(!1)}},u=e.config_fields||e.auth_fields?.map(e=>({name:e,label:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),type:e.includes(`token`)||e.includes(`secret`)||e.includes(`password`)?`password`:`text`,required:!0}))||[],d=r.provider,f=e=>e.name===`account_sid`?d===`twilio`:e.name===`auth_id`?d===`plivo`:!0;return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl bg-white p-6 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsxs)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:[`Connect `,e.name]}),(0,L.jsx)(`button`,{onClick:t,className:`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg text-surface-400 hover:bg-surface-100 hover:text-surface-600`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:l,className:`space-y-4`,children:[u.map(e=>{if(!f(e))return null;let t=e.label||e.name.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),n=e.type||`text`,a=e.required??!0;return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`mb-1 block text-sm font-medium text-surface-700`,children:[t,!a&&(0,L.jsx)(`span`,{className:`text-surface-400`,children:` (optional)`})]}),n===`select`?(0,L.jsxs)(`select`,{className:`w-full rounded-lg border border-surface-200 px-3 py-2.5 text-sm transition-colors focus:border-brand-500 focus:outline-none focus:ring-2 focus:ring-brand-200 min-h-[44px] bg-white`,value:r[e.name]||``,onChange:t=>i(n=>({...n,[e.name]:t.target.value})),required:a,children:[(0,L.jsx)(`option`,{value:``,children:`Select provider...`}),(e.options||[]).map(e=>(0,L.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]}):(0,L.jsx)(`input`,{type:n,className:`w-full rounded-lg border border-surface-200 px-3 py-2.5 text-sm transition-colors focus:border-brand-500 focus:outline-none focus:ring-2 focus:ring-brand-200 min-h-[44px]`,placeholder:`Enter ${t.toLowerCase()}`,value:r[e.name]||``,onChange:t=>i(n=>({...n,[e.name]:t.target.value})),required:a})]},e.name)}),s&&(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg bg-red-50 p-3`,children:[(0,L.jsx)(vc,{className:`mt-0.5 h-4 w-4 shrink-0 text-red-600`}),(0,L.jsx)(`p`,{className:`text-xs text-red-700`,children:s})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 pt-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`flex-1 rounded-lg border border-surface-200 bg-white px-4 py-3 text-sm font-medium text-surface-700 transition-colors hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,disabled:a,className:`flex-1 flex items-center justify-center gap-2 rounded-lg bg-brand-600 px-4 py-3 text-sm font-medium text-white transition-colors hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:a?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Lc,{className:`h-4 w-4`}),`Connect`]})})]})]})]})})}function $0(e){if(!e)return!1;let t=e.toLowerCase();return t.startsWith(`demo@`)||t===`demo`}function e2(){let{user:e,hasCompanyPermission:t}=W(),[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)([]),[o,s]=(0,S.useState)(!0),[c,l]=(0,S.useState)(null),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(null),m=t(`edit_integrations`),h=$0(e?.email),g=h||!m,_=(0,S.useCallback)(async()=>{try{let[e,t]=await Promise.all([f$.available(),f$.list()]);r(e.connectors),a(t.connectors)}catch{p({message:`Failed to load integrations`,type:`error`})}finally{s(!1)}},[]);(0,S.useEffect)(()=>{_()},[_]);let v=async e=>{if(!g){l(e);try{await f$.sync(e),p({message:`Sync completed`,type:`success`}),await _()}catch(e){p({message:e?.response?.data?.error||`Sync failed`,type:`error`})}finally{l(null)}}},y=async e=>{if(!g)try{await f$.remove(e),p({message:`Integration disconnected`,type:`success`}),await _()}catch(e){p({message:e?.response?.data?.error||`Failed to disconnect`,type:`error`})}},b=e=>{g||(e.auth_type===`oauth2`?window.location.href=`/api/connectors/oauth/authorize/${e.service}`:d(e))},x=e=>{g||(window.location.href=`/api/connectors/oauth/authorize/${e.service}`)},C=new Set(i.map(e=>e.service)),w=n.filter(e=>!C.has(e.service));return(0,S.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t=e.get(`oauth_success`),n=e.get(`oauth_error`),r=e.get(`message`);t?(p({message:`${t} connected successfully!`,type:`success`}),_(),e.delete(`oauth_success`),window.history.replaceState({},``,window.location.pathname)):n&&(p({message:`${r||n} connection failed. Please try again.`,type:`error`}),e.delete(`oauth_error`),e.delete(`message`),window.history.replaceState({},``,window.location.pathname))},[]),(0,S.useEffect)(()=>{if(f){let e=setTimeout(()=>p(null),4e3);return()=>clearTimeout(e)}},[f]),(0,L.jsxs)($,{title:`Integrations`,children:[f&&(0,L.jsxs)(`div`,{className:`fixed top-4 right-4 z-[70] flex items-center gap-2 rounded-lg bg-surface-900 px-4 py-3 text-sm text-white shadow-lg`,children:[f.type===`success`?(0,L.jsx)(yc,{className:`h-4 w-4 text-green-400`}):(0,L.jsx)(vc,{className:`h-4 w-4 text-red-400`}),f.message]}),(0,L.jsxs)(`div`,{"data-testid":`page-content`,className:`space-y-6 sm:space-y-8`,children:[g&&(0,L.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border p-4 ${h?`border-amber-200 bg-amber-50`:`border-blue-200 bg-blue-50`}`,children:[(0,L.jsx)(fu,{className:`mt-0.5 h-5 w-5 shrink-0 ${h?`text-amber-600`:`text-blue-600`}`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-semibold ${h?`text-amber-800`:`text-blue-800`}`,children:h?`Demo Mode`:`View Only`}),(0,L.jsx)(`p`,{className:`mt-0.5 text-xs ${h?`text-amber-700`:`text-blue-700`}`,children:h?`This is a demo account. You can browse available integrations but cannot create, modify, or remove connectors. Contact your admin for full access.`:`Your current role does not have permission to manage integrations. Contact your company admin or owner to make changes.`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Integrations`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Connect your existing tools to pull live data into Command Sovereignty.`})]}),o?(0,L.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,L.jsx)(K,{className:`h-8 w-8 animate-spin text-brand-600`})}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`div`,{className:`mb-4 flex items-center justify-between`,children:(0,L.jsxs)(`h2`,{className:`text-sm font-semibold text-surface-700`,children:[`Connected (`,i.length,`)`]})}),i.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-dashed border-surface-200 bg-surface-50 p-8 text-center`,children:[(0,L.jsx)($l,{className:`mx-auto mb-3 h-8 w-8 text-surface-300`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`No integrations connected yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-400`,children:`Connect your CRM, accounting, or advertising tools to start syncing data.`})]}):(0,L.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:i.map(e=>(0,L.jsx)(Z0,{connector:e,onSync:v,onDisconnect:y,onReconnect:x,syncing:c===e.id,readOnly:g,isOAuth:e.auth_type===`oauth2`},e.id))})]}),w.length>0&&(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`div`,{className:`mb-4 flex items-center justify-between`,children:(0,L.jsxs)(`h2`,{className:`text-sm font-semibold text-surface-700`,children:[`Available Integrations (`,w.length,`)`]})}),(0,L.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:w.map(e=>(0,L.jsx)(X0,{connector:e,onConnect:b,disabled:g},e.service))})]})]})]}),u&&(0,L.jsx)(Q0,{connector:u,onClose:()=>d(null),onSuccess:()=>{d(null),_()}})]})}var t2=[{value:`okta`,label:`Okta`},{value:`azure-ad`,label:`Azure AD / Entra ID`},{value:`one-login`,label:`OneLogin`},{value:`custom`,label:`Custom SAML Provider`}],n2=[{value:`post`,label:`HTTP-POST`},{value:`get`,label:`HTTP-Redirect`}];function r2(){let e=ci(),{data:t,isLoading:n}=R({queryKey:[`sso-config`],queryFn:QQ.getSSOConfig}),r=z({mutationFn:e=>QQ.saveSSOConfig(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`sso-config`]})}}),i=z({mutationFn:async()=>{let e=window.open(`/api/enterprise/sso-config/test`,`_blank`);if(!e||e.closed||e.closed===void 0)try{let e=await fetch(`/api/enterprise/sso-config/test`);e.redirected&&(window.location.href=e.url)}catch{alert(`SSO test popup was blocked. Please allow popups for this site.`)}}}),[a,o]=(0,S.useState)({provider_name:`okta`,sso_binding:`post`,enabled:!1}),[s,c]=(0,S.useState)(!1),l=(0,S.useRef)(null);(0,S.useEffect)(()=>{t?.config&&o(t.config)},[t]),(0,S.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]);let u=(e,t)=>{o(n=>({...n,[e]:t}))},d=()=>{r.mutate(a)},f=(0,S.useCallback)(e=>{navigator.clipboard.writeText(e)},[]),p=async()=>{try{let e=await QQ.getSPMetadata();await navigator.clipboard.writeText(e),c(!0),l.current=setTimeout(()=>c(!1),2e3)}catch{c(!1)}},m=a.acs_url||window.location.origin+`/api/enterprise/sso-config/acs`,h=a.sp_metadata_url||window.location.origin+`/api/enterprise/sso-config/metadata`;return n?(0,L.jsx)(`div`,{className:`flex h-64 items-center justify-center`,children:(0,L.jsx)(K,{className:`h-6 w-6 animate-spin text-brand-600`})}):(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(`div`,{className:`rounded-xl border p-4 ${a.enabled?`border-green-200 bg-green-50`:`border-surface-200 bg-surface-50`}`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg ${a.enabled?`bg-green-100 text-green-700`:`bg-surface-200 text-surface-500`}`,children:(0,L.jsx)(fu,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-semibold ${a.enabled?`text-green-800`:`text-surface-700`}`,children:a.enabled?`SSO is Active`:`SSO is Disabled`}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:a.enabled?`Users can sign in with their IdP credentials`:`Enable SSO to allow SAML-based authentication`})]}),(0,L.jsx)(`div`,{className:`ml-auto`,children:(0,L.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a.enabled,"aria-label":`SSO is ${a.enabled?`enabled`:`disabled`}. Click to ${a.enabled?`disable`:`enable`} SSO.`,onClick:()=>u(`enabled`,!a.enabled),className:`min-h-[44px] min-w-[44px] flex items-center`,children:a.enabled?(0,L.jsx)(xu,{className:`h-7 w-11 text-green-600`}):(0,L.jsx)(bu,{className:`h-7 w-11 text-surface-400`})})})]})}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-lg font-semibold text-surface-900`,children:[(0,L.jsx)(fu,{className:`h-5 w-5 text-brand-600`}),`SAML Provider Configuration`]}),(0,L.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Provider`}),(0,L.jsx)(`select`,{value:a.provider_name||`custom`,onChange:e=>u(`provider_name`,e.target.value),className:`w-full rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,children:t2.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`SAML Binding`}),(0,L.jsx)(`select`,{value:a.sso_binding||`post`,onChange:e=>u(`sso_binding`,e.target.value),className:`w-full rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,children:n2.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,L.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`IdP SSO URL`}),(0,L.jsx)(`input`,{type:`url`,value:a.sso_url||``,onChange:e=>u(`sso_url`,e.target.value),placeholder:`https://your-domain.okta.com/app/...`,className:`w-full rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Single Sign-On URL from your identity provider`})]}),(0,L.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`IdP Entity ID`}),(0,L.jsx)(`input`,{type:`text`,value:a.entity_id||``,onChange:e=>u(`entity_id`,e.target.value),placeholder:`https://your-domain.okta.com/home/app/...`,className:`w-full rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Entity ID (Issuer) from your identity provider`})]}),(0,L.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`IdP Signing Certificate (PEM)`}),(0,L.jsx)(`textarea`,{value:a.idp_cert||``,onChange:e=>u(`idp_cert`,e.target.value),placeholder:`-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJAJ...`,rows:6,className:`w-full rounded-lg border border-surface-300 py-2.5 px-3 font-mono text-xs outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`X.509 certificate used by your IdP to sign SAML assertions`})]})]}),(0,L.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:d,disabled:r.isPending,className:`flex items-center gap-2 rounded-lg bg-brand-600 py-2.5 px-5 text-sm font-semibold text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:[r.isPending&&(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),(0,L.jsx)(ou,{className:`h-4 w-4`}),`Save Configuration`]}),r.isSuccess&&(0,L.jsxs)(`span`,{role:`status`,"aria-live":`polite`,className:`flex items-center gap-1 text-sm text-green-600`,children:[(0,L.jsx)(Xc,{className:`h-4 w-4`}),` Saved`]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-lg font-semibold text-surface-900`,children:[(0,L.jsx)(pl,{className:`h-5 w-5 text-brand-600`}),`Service Provider Metadata`]}),(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`ACS URL (Assertion Consumer Service)`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-surface-200 bg-surface-50 px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`flex-1 truncate text-xs font-mono text-surface-600`,children:m}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>f(m),className:`shrink-0 text-surface-400 hover:text-surface-600 min-h-[44px] min-w-[44px] flex items-center justify-center`,children:s?(0,L.jsx)(Xc,{className:`h-4 w-4 text-green-600`}):(0,L.jsx)(sl,{className:`h-4 w-4`})})]}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Configure this as the ACS URL in your IdP`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`SP Metadata URL`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-surface-200 bg-surface-50 px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`flex-1 truncate text-xs font-mono text-surface-600`,children:h}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>f(h),className:`shrink-0 text-surface-400 hover:text-surface-600 min-h-[44px] min-w-[44px] flex items-center justify-center`,children:(0,L.jsx)(sl,{className:`h-4 w-4`})})]}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`SAML 2.0 SP metadata XML endpoint`})]})]}),(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:p,disabled:r.isPending,className:`flex items-center gap-2 rounded-lg border border-surface-200 bg-white py-2.5 px-4 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-50 min-h-[44px]`,children:[s?(0,L.jsx)(Xc,{className:`h-4 w-4 text-green-600`}):(0,L.jsx)(sl,{className:`h-4 w-4`}),`Copy SP Metadata XML`]})})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-lg font-semibold text-surface-900`,children:[(0,L.jsx)(Ru,{className:`h-5 w-5 text-brand-600`}),`Test SSO`]}),(0,L.jsx)(`p`,{className:`mb-4 text-sm text-surface-500`,children:`Click below to initiate a SAML AuthnRequest and redirect to your IdP for testing.`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i.mutate(),disabled:!a.enabled||!a.sso_url,className:`flex items-center gap-2 rounded-lg bg-brand-600 py-2.5 px-5 text-sm font-semibold text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(Ru,{className:`h-4 w-4`}),`Test SSO Login`]}),!a.enabled&&(0,L.jsxs)(`p`,{className:`mt-2 flex items-center gap-1 text-xs text-orange-600`,children:[(0,L.jsx)(vc,{className:`h-3 w-3`}),`Enable SSO first before testing`]})]})]})}function i2(){let e=ci(),{data:t,isLoading:n}=R({queryKey:[`branding`],queryFn:QQ.getBranding}),r=z({mutationFn:e=>QQ.updateBranding(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`branding`]})}}),i=z({mutationFn:QQ.resetBranding,onSuccess:()=>{e.invalidateQueries({queryKey:[`branding`]})}}),a=z({mutationFn:e=>QQ.uploadLogo(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`branding`]})}}),[o,s]=(0,S.useState)({logo_url:``,primary_color:`#00A846`,secondary_color:`#008036`,favicon_url:``,custom_domain:``,app_name:`Command Sovereignty`,login_bg_url:``});(0,S.useEffect)(()=>{t?.settings&&s(t.settings)},[t]);let c=(e,t)=>{s(n=>({...n,[e]:t}))};return n?(0,L.jsx)(`div`,{className:`flex h-64 items-center justify-center`,children:(0,L.jsx)(K,{className:`h-6 w-6 animate-spin text-brand-600`})}):(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-lg font-semibold text-surface-900`,children:[(0,L.jsx)(Wl,{className:`h-5 w-5 text-brand-600`}),`Brand Settings`]}),(0,L.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Company Logo`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-4`,children:[o.logo_url?(0,L.jsx)(`img`,{loading:`lazy`,decoding:`async`,src:o.logo_url,alt:`Logo`,className:`h-12 w-12 rounded-lg border border-surface-200 object-contain`}):(0,L.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-lg border border-surface-200 bg-surface-50`,children:(0,L.jsx)(wl,{className:`h-6 w-6 text-surface-400`})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-lg border border-surface-200 bg-white py-2 px-4 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:[(0,L.jsx)(Du,{className:`h-4 w-4`}),`Upload Logo`,(0,L.jsx)(`input`,{type:`file`,accept:`image/*`,onChange:async e=>{let t=e.target.files?.[0];t&&a.mutate(t)},className:`hidden`})]}),a.isPending&&(0,L.jsx)(K,{className:`h-4 w-4 animate-spin text-brand-600`})]})]}),(0,L.jsxs)(`div`,{className:`mt-2`,children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-xs text-surface-500`,children:`Or enter logo URL directly`}),(0,L.jsx)(`input`,{type:`url`,value:o.logo_url||``,onChange:e=>c(`logo_url`,e.target.value),placeholder:`https://example.com/logo.png`,className:`w-full rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`mb-1.5 flex items-center gap-1.5 text-sm font-medium text-surface-700`,children:[(0,L.jsx)(Eu,{className:`h-3.5 w-3.5 text-surface-400`}),`App Name`]}),(0,L.jsx)(`input`,{type:`text`,value:o.app_name||``,onChange:e=>c(`app_name`,e.target.value),placeholder:`Command Sovereignty`,className:`w-full rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`mb-1.5 flex items-center gap-1.5 text-sm font-medium text-surface-700`,children:[(0,L.jsx)(bl,{className:`h-3.5 w-3.5 text-surface-400`}),`Custom Domain`]}),(0,L.jsx)(`input`,{type:`text`,value:o.custom_domain||``,onChange:e=>c(`custom_domain`,e.target.value),placeholder:`app.yourcompany.com`,className:`w-full rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`mb-1.5 flex items-center gap-1.5 text-sm font-medium text-surface-700`,children:[(0,L.jsx)(Sl,{className:`h-3.5 w-3.5 text-surface-400`}),`Primary Color`]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`input`,{type:`color`,value:o.primary_color||`#00A846`,onChange:e=>c(`primary_color`,e.target.value),className:`h-10 w-10 rounded-lg border border-surface-200 cursor-pointer min-h-[44px]`}),(0,L.jsx)(`input`,{type:`text`,value:o.primary_color||``,onChange:e=>c(`primary_color`,e.target.value),className:`flex-1 rounded-lg border border-surface-300 py-2.5 px-3 text-sm font-mono outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`mb-1.5 flex items-center gap-1.5 text-sm font-medium text-surface-700`,children:[(0,L.jsx)(Sl,{className:`h-3.5 w-3.5 text-surface-400`}),`Secondary Color`]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`input`,{type:`color`,value:o.secondary_color||`#008036`,onChange:e=>c(`secondary_color`,e.target.value),className:`h-10 w-10 rounded-lg border border-surface-200 cursor-pointer min-h-[44px]`}),(0,L.jsx)(`input`,{type:`text`,value:o.secondary_color||``,onChange:e=>c(`secondary_color`,e.target.value),className:`flex-1 rounded-lg border border-surface-300 py-2.5 px-3 text-sm font-mono outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Favicon URL`}),(0,L.jsx)(`input`,{type:`url`,value:o.favicon_url||``,onChange:e=>c(`favicon_url`,e.target.value),placeholder:`https://example.com/favicon.svg`,className:`w-full rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`mb-1.5 flex items-center gap-1.5 text-sm font-medium text-surface-700`,children:[(0,L.jsx)(wl,{className:`h-3.5 w-3.5 text-surface-400`}),`Login Background URL`]}),(0,L.jsx)(`input`,{type:`url`,value:o.login_bg_url||``,onChange:e=>c(`login_bg_url`,e.target.value),placeholder:`https://example.com/bg.jpg`,className:`w-full rounded-lg border border-surface-300 py-2.5 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]})]}),(0,L.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{r.mutate(o)},disabled:r.isPending,className:`flex items-center gap-2 rounded-lg bg-brand-600 py-2.5 px-5 text-sm font-semibold text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:[r.isPending&&(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),(0,L.jsx)(ou,{className:`h-4 w-4`}),`Save Changes`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{i.mutate()},disabled:i.isPending,className:`flex items-center gap-2 rounded-lg border border-surface-200 bg-white py-2.5 px-5 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-50 min-h-[44px]`,children:[i.isPending&&(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),(0,L.jsx)(nu,{className:`h-4 w-4`}),`Reset to Defaults`]}),(r.isSuccess||i.isSuccess)&&(0,L.jsxs)(`span`,{role:`status`,"aria-live":`polite`,className:`flex items-center gap-1 text-sm text-green-600`,children:[(0,L.jsx)(Xc,{className:`h-4 w-4`}),` Saved`]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-lg font-semibold text-surface-900`,children:[(0,L.jsx)(hl,{className:`h-5 w-5 text-brand-600`}),`Live Preview`]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row`,role:`presentation`,"aria-hidden":`true`,children:[(0,L.jsxs)(`div`,{className:`w-full sm:w-48 sm:shrink-0 rounded-xl border border-surface-200 overflow-hidden`,style:{"--brand-600":o.primary_color},children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-surface-200`,children:[o.logo_url?(0,L.jsx)(`img`,{loading:`lazy`,decoding:`async`,src:o.logo_url,alt:``,className:`h-7 w-7 rounded object-contain`}):(0,L.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center rounded text-white text-xs font-bold`,style:{backgroundColor:o.primary_color},children:o.app_name?.charAt(0)?.toUpperCase()||`C`}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`truncate text-xs font-semibold text-surface-900`,children:o.app_name||`Command Sovereignty`}),(0,L.jsx)(`p`,{className:`truncate text-[10px] text-surface-500`,children:`Enterprise`})]})]}),(0,L.jsx)(`div`,{className:`px-2 py-2 space-y-0.5`,children:[{label:`Dashboard`,active:!0},{label:`Organizations`,active:!1},{label:`Analytics`,active:!1},{label:`Goals`,active:!1}].map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-2 py-2 text-xs font-medium ${e.active?`text-white`:`text-surface-600`}`,style:e.active?{backgroundColor:o.primary_color}:void 0,children:[(0,L.jsx)(el,{className:`h-3 w-3`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.label})]},e.label))})]}),(0,L.jsxs)(`div`,{className:`flex-1 rounded-xl border border-surface-200 overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-b border-surface-200`,children:[(0,L.jsx)(`span`,{className:`text-sm font-semibold text-surface-900`,children:`Dashboard`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:o.primary_color}}),(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:o.custom_domain||`app.commandcenter.io`})]})]}),(0,L.jsx)(`div`,{className:`flex h-48 items-center justify-center bg-surface-50`,children:(0,L.jsxs)(`div`,{className:`w-48 rounded-lg border border-surface-200 bg-white p-3 shadow-sm`,children:[(0,L.jsx)(`div`,{className:`flex justify-center mb-2`,children:o.logo_url?(0,L.jsx)(`img`,{loading:`lazy`,decoding:`async`,src:o.logo_url,alt:``,className:`h-6 w-6 object-contain`}):(0,L.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded text-white text-[8px] font-bold`,style:{backgroundColor:o.primary_color},children:o.app_name?.charAt(0)?.toUpperCase()||`C`})}),(0,L.jsx)(`p`,{className:`text-center text-[8px] font-semibold text-surface-900 mb-2`,children:o.app_name||`Command Sovereignty`}),(0,L.jsx)(`button`,{type:`button`,className:`w-full rounded py-1.5 text-[8px] font-semibold text-white`,style:{backgroundColor:o.primary_color},children:`Sign In`})]})})]})]})]})]})}function a2(){let[e,t]=(0,S.useState)(`sso`);return(0,L.jsxs)($,{title:`Enterprise Settings`,children:[(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Enterprise Settings`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Configure SSO/SAML authentication and white-label branding for your organization`})]}),(0,L.jsx)(`div`,{role:`tablist`,"aria-label":`Enterprise settings`,className:`mb-6 flex gap-1 rounded-lg bg-surface-100 p-1`,children:[{id:`sso`,label:`SSO/SAML`,icon:fu},{id:`branding`,label:`White-Label Branding`,icon:Wl}].map(n=>(0,L.jsxs)(`button`,{type:`button`,role:`tab`,id:`tab-${n.id}`,"aria-controls":`panel-${n.id}`,"aria-selected":e===n.id,onClick:()=>t(n.id),className:`flex items-center gap-2 rounded-md px-4 py-2.5 text-sm font-medium transition-colors min-h-[44px] ${e===n.id?`bg-white text-surface-900 shadow-sm`:`text-surface-600 hover:text-surface-900`}`,children:[(0,L.jsx)(n.icon,{className:`h-4 w-4`}),n.label]},n.id))}),(0,L.jsx)(`div`,{role:`tabpanel`,id:`panel-sso`,"aria-labelledby":`tab-sso`,hidden:e!==`sso`,children:(0,L.jsx)(r2,{})}),(0,L.jsx)(`div`,{role:`tabpanel`,id:`panel-branding`,"aria-labelledby":`tab-branding`,hidden:e!==`branding`,children:(0,L.jsx)(i2,{})})]})}var o2={crm:{bg:`bg-blue-100`,icon:`text-blue-600`,label:`CRM`},accounting:{bg:`bg-green-100`,icon:`text-green-600`,label:`Accounting`},advertising:{bg:`bg-purple-100`,icon:`text-purple-600`,label:`Advertising`},telephony:{bg:`bg-amber-100`,icon:`text-amber-600`,label:`Telephony`},default:{bg:`bg-surface-100`,icon:`text-surface-600`,label:`Integration`}};function s2(e){return e===`hubspot`?o2.crm:e===`quickbooks`?o2.accounting:e===`google_ads`||e===`googleads`?o2.advertising:e===`google_sheets`||e===`googlesheets`?{bg:`bg-indigo-100`,icon:`text-indigo-600`,label:`Data Source`}:e===`sms`?o2.telephony:o2.default}function c2(e){switch(e){case`connected`:return{icon:yc,color:`text-green-600`,label:`Connected`};case`syncing`:return{icon:nu,color:`text-blue-600`,label:`Syncing...`};case`error`:return{icon:vc,color:`text-red-600`,label:`Error`};default:return{icon:al,color:`text-surface-500`,label:`Inactive`}}}function l2({connector:e,onConnect:t}){let n=s2(e.service);return(0,L.jsxs)(`div`,{className:`group relative flex flex-col rounded-xl border border-surface-200 bg-white p-4 sm:p-5 transition-shadow hover:shadow-md`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${n.bg}`,children:(0,L.jsx)($l,{className:`h-5 w-5 ${n.icon}`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-900`,children:e.name}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:n.label})]})]}),(0,L.jsx)(`span`,{className:`rounded-full bg-surface-100 px-2 py-0.5 text-[10px] font-medium text-surface-500`,children:e.auth_type===`oauth2`?`OAuth`:`API Key`})]}),(0,L.jsx)(`p`,{className:`mb-4 min-w-0 text-sm text-surface-500 flex-1`,children:e.description}),(0,L.jsxs)(`div`,{className:`mb-4 flex flex-wrap gap-1.5`,children:[e.capabilities?.slice(0,4).map(e=>(0,L.jsx)(`span`,{className:`rounded-md bg-surface-50 px-2 py-0.5 text-[10px] font-medium text-surface-500`,children:e},e)),e.capabilities&&e.capabilities.length>4&&(0,L.jsxs)(`span`,{className:`rounded-md bg-surface-50 px-2 py-0.5 text-[10px] font-medium text-surface-500`,children:[`+`,e.capabilities.length-4,` more`]})]}),(0,L.jsxs)(`div`,{className:`mt-auto flex items-center justify-between border-t border-surface-100 pt-4`,children:[(0,L.jsxs)(`a`,{href:e.docs_url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-surface-500 hover:text-surface-600 min-h-[44px]`,children:[`Docs `,(0,L.jsx)(pl,{className:`h-3 w-3`})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Connect`]})]})]})}function u2({connector:e,onSync:t,onDisconnect:n,syncing:r,onUpdateFrequency:i}){let[a,o]=(0,S.useState)(!1),[s,c]=(0,S.useState)([]),l=c2(e.status),u=l.icon,d=(0,S.useCallback)(async()=>{try{c((await f$.logs(e.id)).logs)}catch{c([])}},[e.id]);return(0,L.jsxs)(`div`,{className:`relative flex flex-col rounded-xl border border-surface-200 bg-white p-4 sm:p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${s2(e.service).bg}`,children:(0,L.jsx)($l,{className:`h-5 w-5 ${s2(e.service).icon}`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-900 capitalize`,children:e.serviceDisplayName||e.service.replace(`_`,` `)}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 ${l.color}`,children:[(0,L.jsx)(u,{className:`h-3.5 w-3.5 ${r?`animate-spin`:``}`}),(0,L.jsx)(`span`,{className:`text-xs font-medium`,children:l.label}),e.last_sync_at&&(0,L.jsxs)(`span`,{className:`text-xs text-surface-500`,children:[` · `,`Last synced `,new Date(e.last_sync_at).toLocaleString()]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsxs)(`span`,{className:`rounded-full bg-brand-50 px-2 py-0.5 text-[10px] font-medium text-brand-600 flex items-center gap-1`,children:[(0,L.jsx)(fu,{className:`h-3 w-3`}),`Admin`]}),(0,L.jsxs)(`select`,{value:e.sync_frequency,onChange:t=>i(e.id,t.target.value),className:`rounded-lg border border-surface-200 bg-surface-50 px-2 py-1 text-xs font-medium text-surface-600 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`real_time`,children:`Real-time`}),(0,L.jsx)(`option`,{value:`hourly`,children:`Hourly`}),(0,L.jsx)(`option`,{value:`daily`,children:`Daily`})]})]})]}),e.error_message&&(0,L.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded-lg bg-red-50 p-3`,children:[(0,L.jsx)(vc,{className:`mt-0.5 h-4 w-4 shrink-0 text-red-600`}),(0,L.jsx)(`p`,{className:`text-xs text-red-700`,children:e.error_message})]}),(0,L.jsxs)(`div`,{className:`mb-4 grid grid-cols-1 sm:grid-cols-3 gap-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-2 text-center`,children:[(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:e.contacts_count??0}),(0,L.jsxs)(`p`,{className:`text-[10px] font-medium text-surface-500 flex items-center justify-center gap-1`,children:[(0,L.jsx)(Pu,{className:`h-3 w-3`}),` Contacts`]})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-2 text-center`,children:[(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:e.deals_count??0}),(0,L.jsxs)(`p`,{className:`text-[10px] font-medium text-surface-500 flex items-center justify-center gap-1`,children:[(0,L.jsx)(mc,{className:`h-3 w-3`}),` Deals`]})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-2 text-center`,children:[(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:e.sync_count??0}),(0,L.jsxs)(`p`,{className:`text-[10px] font-medium text-surface-500 flex items-center justify-center gap-1`,children:[(0,L.jsx)(Mc,{className:`h-3 w-3`}),` Syncs`]})]})]}),(0,L.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 border-t border-surface-100 pt-4`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>t(e.id),disabled:r||e.status===`syncing`,className:`flex items-center gap-1.5 rounded-lg bg-surface-100 px-3 py-2 text-sm font-medium text-surface-700 transition-colors hover:bg-surface-200 disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(nu,{className:`h-4 w-4 ${r?`animate-spin`:``}`}),`Sync Now`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:async()=>{a||await d(),o(e=>!e)},className:`flex items-center gap-1.5 rounded-lg bg-surface-100 px-3 py-2 text-sm font-medium text-surface-700 transition-colors hover:bg-surface-200 min-h-[44px]`,children:[(0,L.jsx)(Mc,{className:`h-4 w-4`}),`Logs`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:`ml-auto flex items-center gap-1.5 rounded-lg bg-red-50 px-3 py-2 text-sm font-medium text-red-600 transition-colors hover:bg-red-100 min-h-[44px]`,children:[(0,L.jsx)(Su,{className:`h-4 w-4`}),`Disconnect`]})]}),a&&(0,L.jsx)(`div`,{className:`mt-4 max-h-48 overflow-y-auto rounded-lg border border-surface-200 bg-surface-50 p-3`,children:s.length===0?(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`No sync logs yet`}):(0,L.jsx)(`div`,{className:`space-y-2`,children:s.map(e=>(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2 text-xs`,children:[(0,L.jsx)(`span`,{className:`shrink-0 font-medium ${e.status===`success`?`text-green-600`:e.status===`error`?`text-red-600`:`text-surface-500`}`,children:e.status}),(0,L.jsx)(`span`,{className:`text-surface-600`,children:e.event_type}),e.record_count>0&&(0,L.jsxs)(`span`,{className:`text-surface-500`,children:[e.record_count,` records`]}),e.duration_ms!=null&&(0,L.jsxs)(`span`,{className:`text-surface-500`,children:[e.duration_ms,`ms`]}),(0,L.jsx)(`span`,{className:`ml-auto shrink-0 text-surface-400`,children:new Date(e.created_at).toLocaleTimeString()})]},e.id))})})]})}function d2({onClose:e,onSuccess:t}){let[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)(!0),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(``);(0,S.useEffect)(()=>{f$.listSpreadsheets().then(e=>{r(e.spreadsheets)}).catch(e=>{l(e.response?.data?.error||`Failed to load spreadsheets`)}).finally(()=>a(!1))},[]);let u=async e=>{s(e.id);try{await f$.selectSpreadsheet(e.id),t()}catch(e){l(e.response?.data?.error||`Failed to select spreadsheet`),s(null)}};return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-lg rounded-2xl bg-white p-6 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Select a Spreadsheet`}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Close dialog`,onClick:e,className:`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg text-surface-500 hover:bg-surface-100 hover:text-surface-600`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsx)(`p`,{className:`mb-4 text-sm text-surface-500`,children:`Choose a Google Sheet to sync your marketing data from. The sheet should have columns like date, platform, spend, etc.`}),i&&(0,L.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,L.jsx)(K,{className:`h-6 w-6 animate-spin text-brand-600`})}),c&&!i&&(0,L.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded-lg bg-red-50 p-3`,children:[(0,L.jsx)(vc,{className:`mt-0.5 h-4 w-4 shrink-0 text-red-600`}),(0,L.jsx)(`p`,{className:`text-xs text-red-700`,children:c})]}),!i&&!c&&n.length===0&&(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-4 text-center`,children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No spreadsheets found.`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-400`,children:`Make sure your Google account has access to at least one spreadsheet.`})]}),!i&&n.length>0&&(0,L.jsx)(`div`,{className:`max-h-80 overflow-y-auto space-y-2`,children:n.map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>u(e),disabled:o!==null,className:`w-full flex items-center gap-3 rounded-lg border border-surface-200 p-3 text-left transition-colors hover:bg-surface-50 disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-indigo-100`,children:(0,L.jsx)($l,{className:`h-5 w-5 text-indigo-600`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900 truncate`,children:e.name}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:new Date(e.modifiedTime).toLocaleDateString()})]}),o===e.id?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin text-brand-600`}):(0,L.jsx)(Lc,{className:`h-4 w-4 text-surface-400`})]},e.id))})]})})}function f2({connector:e,onClose:t,onSuccess:n}){let[r,i]=(0,S.useState)({}),[a,o]=(0,S.useState)(!1),[s,c]=(0,S.useState)(``),l=async t=>{t.preventDefault(),c(``),o(!0);try{let t=await f$.create(e.service,r,`hourly`);t.connector.status===`connected`?n():c(t.connector.error_message||`Connection failed`)}catch(e){c(e.response?.data?.error||`Connection failed`)}finally{o(!1)}},u=e.config_fields||e.auth_fields?.map(e=>({name:e,label:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),type:e.includes(`token`)||e.includes(`secret`)||e.includes(`password`)?`password`:`text`,required:!0}))||[],d=r.provider,f=e=>e.name===`account_sid`?d===`twilio`:e.name===`auth_id`?d===`plivo`:!0;return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl bg-white p-6 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsxs)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:[`Connect `,e.name]}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Close dialog`,onClick:t,className:`flex min-h-[44px] min-w-[44px] items-center justify-center rounded-lg text-surface-500 hover:bg-surface-100 hover:text-surface-600`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:l,className:`space-y-4`,children:[u.map(e=>{if(!f(e))return null;let t=e.label||e.name.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),n=e.type||`text`,a=e.required??!0;return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`mb-1 block text-sm font-medium text-surface-700`,children:[t,!a&&(0,L.jsx)(`span`,{className:`text-surface-400`,children:` (optional)`})]}),n===`select`?(0,L.jsxs)(`select`,{className:`w-full rounded-lg border border-surface-200 px-3 py-2.5 text-sm transition-colors focus:border-brand-500 focus:outline-none focus:ring-2 focus:ring-brand-200 min-h-[44px] bg-white`,value:r[e.name]||``,onChange:t=>i(n=>({...n,[e.name]:t.target.value})),required:a,children:[(0,L.jsx)(`option`,{value:``,children:`Select provider...`}),(e.options||[]).map(e=>(0,L.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]}):(0,L.jsx)(`input`,{type:n,className:`w-full rounded-lg border border-surface-200 px-3 py-2.5 text-sm transition-colors focus:border-brand-500 focus:outline-none focus:ring-2 focus:ring-brand-200 min-h-[44px]`,placeholder:`Enter ${t.toLowerCase()}`,value:r[e.name]||``,onChange:t=>i(n=>({...n,[e.name]:t.target.value})),required:a})]},e.name)}),s&&(0,L.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg bg-red-50 p-3`,children:[(0,L.jsx)(vc,{className:`mt-0.5 h-4 w-4 shrink-0 text-red-600`}),(0,L.jsx)(`p`,{className:`text-xs text-red-700`,children:s})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row items-center pt-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`flex-1 min-w-0 rounded-lg border border-surface-200 bg-white px-4 py-3 text-sm font-medium text-surface-700 transition-colors hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,disabled:a,className:`flex-1 min-w-0 flex items-center justify-center gap-2 rounded-lg bg-brand-600 px-4 py-3 text-sm font-medium text-white transition-colors hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:a?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Lc,{className:`h-4 w-4`}),`Connect`]})})]})]})]})})}function p2({selectedCompanyId:e,onSelect:t}){let[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)(!0),[o,s]=(0,S.useState)(``);(0,S.useEffect)(()=>{KQ.getOrganizations().then(e=>r(e.items||[])).catch(()=>s(`Failed to load companies`)).finally(()=>a(!1))},[]);let c=n.find(t=>String(t.id)===e);return(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-amber-50 border border-amber-200 px-3 py-2`,children:[(0,L.jsx)(fu,{className:`h-4 w-4 text-amber-600`}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-amber-700`,children:`Super Admin Proxy`})]}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Kc,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400 pointer-events-none`}),i?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-surface-200 bg-white pl-9 pr-3 py-2 text-sm text-surface-500 min-w-[240px]`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),`Loading companies...`]}):o?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-red-200 bg-red-50 pl-9 pr-3 py-2 text-sm text-red-600`,children:[(0,L.jsx)(vc,{className:`h-4 w-4`}),o]}):(0,L.jsxs)(`select`,{value:e||``,onChange:e=>t(e.target.value||null),className:`appearance-none rounded-lg border border-surface-200 bg-white pl-9 pr-10 py-2 text-sm font-medium text-surface-700 transition-colors focus:border-brand-500 focus:outline-none focus:ring-2 focus:ring-brand-200 min-w-[240px] min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:``,children:`— My Company —`}),n.map(e=>(0,L.jsx)(`option`,{value:String(e.id),children:e.name},e.id))]}),(0,L.jsx)(Zc,{className:`absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400 pointer-events-none`})]}),c&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-surface-500`,children:[(0,L.jsxs)(`span`,{className:`rounded-full bg-surface-100 px-2 py-0.5 font-medium`,children:[c.tier||`Unknown`,` plan`]}),(0,L.jsx)(`span`,{className:`rounded-full bg-surface-100 px-2 py-0.5 font-medium`,children:c.status||`Unknown`})]})]})}function m2(){let{isRole:e}=W(),t=e(`super_admin`),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)([]),[o,s]=(0,S.useState)([]),[c,l]=(0,S.useState)(!0),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(null),[m,h]=(0,S.useState)(null),[g,_]=(0,S.useState)(null),[v,y]=(0,S.useState)(!1),[b,x]=(0,S.useState)(!1),C=n!==null,w=(0,S.useCallback)(async()=>{try{if(C){let e=await GQ.listConnectors(n);s(e.connectors),_({tier:`proxy`,connector_limit:999,connectors_used:e.connectors.length})}else{let[e,t]=await Promise.all([f$.available(),f$.list()]);a(e.connectors),s(t.connectors),_({tier:t.tier,connector_limit:t.connector_limit,connectors_used:t.connectors_used})}}catch{h({message:`Failed to load integrations`,type:`error`})}finally{l(!1)}},[C,n]);(0,S.useEffect)(()=>{w()},[w]),(0,S.useEffect)(()=>{C&&GQ.availableConnectors().then(e=>a(e.connectors)).catch(()=>{})},[C]);let[T]=Bn();(0,S.useEffect)(()=>{let e=T.get(`oauth_success`),t=T.get(`oauth_error`),n=T.get(`picker`);t&&(h({message:T.get(`message`)||`OAuth connection failed`,type:`error`}),T.delete(`oauth_error`),T.delete(`message`)),e&&(n?x(!0):(h({message:`${e.replace(/_/g,` `)} connected successfully`,type:`success`}),w()),T.delete(`oauth_success`),T.delete(`picker`))},[T,w]);let E=async e=>{d(e);try{C?await GQ.syncConnector(n,e):await f$.sync(e),h({message:`Sync completed`,type:`success`}),await w()}catch(e){h({message:e.response?.data?.error||`Sync failed`,type:`error`})}finally{d(null)}},D=async e=>{try{C?await GQ.disconnectConnector(n,e):await f$.remove(e),h({message:`Integration disconnected`,type:`success`}),await w()}catch(e){h({message:e.response?.data?.error||`Failed to disconnect`,type:`error`})}},O=async(e,t)=>{try{C?await GQ.updateConnector(n,e,{sync_frequency:t}):await f$.update(e,{sync_frequency:t}),h({message:`Sync frequency updated`,type:`success`}),await w()}catch(e){h({message:e.response?.data?.error||`Update failed`,type:`error`})}},k=e=>{if(g&&!C&&g.connectors_used>=g.connector_limit){y(!0);return}if(e.auth_type===`oauth2`){f$.oauthAuthorize(e.service,`/admin/integrations`);return}p(e)},A=new Set(o.map(e=>e.service)),j=i.filter(e=>!A.has(e.service));(0,S.useEffect)(()=>{if(m){let e=setTimeout(()=>h(null),4e3);return()=>clearTimeout(e)}},[m]);let M=(0,S.useMemo)(()=>`Connected`,[C]);return(0,L.jsxs)($,{title:`Integration Management`,children:[m&&(0,L.jsxs)(`div`,{className:`fixed top-4 right-4 z-[70] flex items-center gap-2 rounded-lg bg-surface-900 px-4 py-3 text-sm text-white shadow-lg`,children:[m.type===`success`?(0,L.jsx)(yc,{className:`h-4 w-4 text-green-400`}):(0,L.jsx)(vc,{className:`h-4 w-4 text-red-400`}),m.message]}),(0,L.jsxs)(`div`,{className:`space-y-6 sm:space-y-8`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Integrations`}),(0,L.jsxs)(`span`,{className:`rounded-full bg-brand-50 px-2 py-0.5 text-[10px] font-medium text-brand-600 flex items-center gap-1`,children:[(0,L.jsx)(fu,{className:`h-3 w-3`}),` Admin`]}),C&&(0,L.jsxs)(`span`,{className:`rounded-full bg-amber-50 px-2 py-0.5 text-[10px] font-medium text-amber-600 flex items-center gap-1`,children:[(0,L.jsx)(Kc,{className:`h-3 w-3`}),` Proxying`]})]}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:C?`Managing integrations for a different company. Select a company below to switch.`:`Manage all integration connections across Command Sovereignty. Admin-level controls for system-wide integrations.`}),g&&!C&&(0,L.jsx)(`div`,{className:`flex items-center gap-2 mt-2`,children:(0,L.jsxs)(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${g.connectors_used>=g.connector_limit?`bg-red-50 text-red-600`:g.connectors_used>=g.connector_limit*.8?`bg-yellow-50 text-yellow-600`:`bg-green-50 text-green-600`}`,children:[g.connectors_used,`/`,g.connector_limit,` connectors (`,g.tier,` plan)`]})})]}),t&&(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-surface-50 p-4`,children:(0,L.jsx)(p2,{selectedCompanyId:n,onSelect:(0,S.useCallback)(e=>{r(e),l(!0)},[])})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-3 sm:p-4`,children:[(0,L.jsx)(`p`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:o.length}),(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:`Connected`})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-3 sm:p-4`,children:[(0,L.jsx)(`p`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:j.length}),(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:`Available`})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-3 sm:p-4`,children:[(0,L.jsx)(`p`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:o.filter(e=>e.status===`connected`).length}),(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:`Active`})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-3 sm:p-4`,children:[(0,L.jsx)(`p`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:o.filter(e=>e.status===`error`).length}),(0,L.jsx)(`p`,{className:`text-xs font-medium text-red-600`,children:`Errors`})]})]}),c?(0,L.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,L.jsx)(K,{className:`h-8 w-8 animate-spin text-brand-600`})}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`div`,{className:`mb-4 flex items-center justify-between`,children:(0,L.jsxs)(`h2`,{className:`text-sm font-semibold text-surface-700`,children:[M,` (`,o.length,`)`]})}),o.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-dashed border-surface-200 bg-surface-50 p-8 text-center`,children:[(0,L.jsx)($l,{className:`mx-auto mb-3 h-8 w-8 text-surface-300`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`No integrations connected yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Connect your CRM, accounting, or advertising tools to start syncing data.`})]}):(0,L.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:o.map(e=>(0,L.jsx)(u2,{connector:e,onSync:E,onDisconnect:D,syncing:u===e.id,onUpdateFrequency:O},e.id))})]}),j.length>0&&(0,L.jsxs)(`section`,{children:[(0,L.jsx)(`div`,{className:`mb-4 flex items-center justify-between`,children:(0,L.jsxs)(`h2`,{className:`text-sm font-semibold text-surface-700`,children:[`Available Integrations (`,j.length,`)`]})}),(0,L.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:j.map(e=>(0,L.jsx)(l2,{connector:e,onConnect:k},e.service))})]})]})]}),f&&(0,L.jsx)(f2,{connector:f,onClose:()=>p(null),onSuccess:()=>{p(null),w(),h({message:`Integration connected successfully`,type:`success`})}}),b&&(0,L.jsx)(d2,{onClose:()=>x(!1),onSuccess:()=>{x(!1),w(),h({message:`Spreadsheet selected`,type:`success`})}}),v&&(0,L.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-2xl bg-white p-6 shadow-xl`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold mb-2`,children:`Connector Limit Reached`}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500 mb-4`,children:[`Your `,g?.tier,` plan includes `,g?.connector_limit,` connectors. Upgrade to add more integrations.`]}),(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>y(!1),className:`flex-1 rounded-lg border border-surface-200 bg-white px-4 py-3 text-sm font-medium text-surface-700 transition-colors hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`a`,{href:`/admin/billing`,className:`flex-1 flex items-center justify-center rounded-lg bg-brand-600 px-4 py-3 text-sm font-medium text-white transition-colors hover:bg-brand-700 min-h-[44px]`,children:`Upgrade Plan`})]})]})})]})}var h2=e=>e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(0)}K`:`$${e.toFixed(0)}`,g2=e=>`${e.toFixed(1)}%`;function _2(){let{data:e,isLoading:t}=R({queryKey:[`multi-market`,`overview`],queryFn:U$.getOverview});return t?(0,L.jsx)(`div`,{className:`flex h-64 items-center justify-center`,children:(0,L.jsx)(K,{className:`h-6 w-6 animate-spin text-brand-600`})}):e?.markets?.length?(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-surface-500`,children:[(0,L.jsx)(Ll,{className:`h-4 w-4`}),`Markets`]}),(0,L.jsx)(`p`,{className:`mt-2 text-2xl font-bold text-surface-900`,children:e.total_markets})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-surface-500`,children:[(0,L.jsx)(dl,{className:`h-4 w-4`}),`Total Revenue`]}),(0,L.jsx)(`p`,{className:`mt-2 text-2xl font-bold text-surface-900`,children:h2(e.markets.reduce((e,t)=>e+t.total_revenue,0))})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-surface-500`,children:[(0,L.jsx)(yu,{className:`h-4 w-4`}),`Avg Close Rate`]}),(0,L.jsx)(`p`,{className:`mt-2 text-2xl font-bold text-surface-900`,children:g2(e.markets.reduce((e,t)=>e+t.close_rate,0)/e.total_markets)})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-surface-500`,children:[(0,L.jsx)(Pu,{className:`h-4 w-4`}),`Active Contacts`]}),(0,L.jsx)(`p`,{className:`mt-2 text-2xl font-bold text-surface-900`,children:e.markets.reduce((e,t)=>e+t.active_contacts,0).toLocaleString()})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-lg font-semibold text-surface-900`,children:[(0,L.jsx)(mc,{className:`h-5 w-5 text-brand-600`}),`Revenue by Market`]}),(0,L.jsx)(Fb,{width:`100%`,height:300,children:(0,L.jsxs)(cQ,{data:e.markets.slice(0,10),children:[(0,L.jsx)(FG,{strokeDasharray:`3 3`,stroke:`#e5e7eb`}),(0,L.jsx)(KY,{dataKey:`market`,tick:{fontSize:12}}),(0,L.jsx)(sX,{tick:{fontSize:12},tickFormatter:h2}),(0,L.jsx)(ez,{formatter:e=>h2(e),contentStyle:{borderRadius:`8px`,border:`1px solid #e5e7eb`}}),(0,L.jsx)(US,{}),(0,L.jsx)(TY,{dataKey:`total_revenue`,name:`Revenue`,fill:`#00A846`,radius:[4,4,0,0]}),(0,L.jsx)(TY,{dataKey:`avg_deal_size`,name:`Avg Deal`,fill:`#008036`,radius:[4,4,0,0]})]})})]})]}):(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-8 text-center`,children:[(0,L.jsx)(Ll,{className:`mx-auto h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-lg font-medium text-surface-700`,children:`No market data available`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-surface-500`,children:`Connect your CRM to start tracking markets`})]})}function v2(){let{data:e,isLoading:t}=R({queryKey:[`multi-market`,`comparison`],queryFn:U$.getComparison});if(t)return(0,L.jsx)(`div`,{className:`flex h-64 items-center justify-center`,children:(0,L.jsx)(K,{className:`h-6 w-6 animate-spin text-brand-600`})});if(!e?.markets?.length)return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-8 text-center`,children:[(0,L.jsx)(Ll,{className:`mx-auto h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-lg font-medium text-surface-700`,children:`No market data available`})]});let n=e.averages?.close_rate??0,r=e.averages?.revenue??0;return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[e.top_performers?.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-green-200 bg-green-50 p-4`,children:[(0,L.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-semibold text-green-800`,children:[(0,L.jsx)(wu,{className:`h-4 w-4`}),`Top Performers`]}),(0,L.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.top_performers.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-green-900`,children:e.market}),(0,L.jsxs)(`span`,{className:`text-sm text-green-700`,children:[g2(e.close_rate),` CR`]})]},e.market))})]}),e.bottom_performers?.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-orange-200 bg-orange-50 p-4`,children:[(0,L.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-semibold text-orange-800`,children:[(0,L.jsx)(Cu,{className:`h-4 w-4`}),`Bottom Performers`]}),(0,L.jsx)(`div`,{className:`mt-3 space-y-2`,children:e.bottom_performers.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-orange-900`,children:e.market}),(0,L.jsxs)(`span`,{className:`text-sm text-orange-700`,children:[g2(e.close_rate),` CR`]})]},e.market))})]})]}),(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{className:`border-b border-surface-200 bg-surface-50`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-semibold text-surface-700`,children:`Market`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-semibold text-surface-700`,children:`Revenue`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-semibold text-surface-700`,children:`Close Rate`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-semibold text-surface-700`,children:`Avg Deal`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-semibold text-surface-700`,children:`Market Share`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-semibold text-surface-700`,children:`Deals/Owner`})]})}),(0,L.jsx)(`tbody`,{children:e.markets.map((e,t)=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 ${t%2==0?`bg-white`:`bg-surface-50/50`}`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900`,children:e.market}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,L.jsx)(`span`,{className:e.revenue>=r?`text-green-600`:`text-red-600`,children:h2(e.revenue)})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ${e.close_rate>=n?`bg-green-100 text-green-700`:`bg-red-100 text-red-700`}`,children:[g2(e.close_rate),e.close_rate>=n?(0,L.jsx)(Rc,{className:`h-3 w-3`}):(0,L.jsx)(Nc,{className:`h-3 w-3`})]})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:h2(e.avg_deal_size)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:g2(e.market_share)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:e.deals_per_owner.toFixed(1)})]},e.market))})]})}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-lg font-semibold text-surface-900`,children:[(0,L.jsx)(_c,{className:`h-5 w-5 text-brand-600`}),`Revenue Distribution`]}),(0,L.jsx)(Fb,{width:`100%`,height:300,children:(0,L.jsxs)(OQ,{children:[(0,L.jsx)(CU,{data:e.markets,dataKey:`revenue`,nameKey:`market`,cx:`50%`,cy:`50%`,outerRadius:100,innerRadius:60,paddingAngle:2,children:e.markets.map((e,t)=>(0,L.jsx)(tz,{fill:[`#00A846`,`#008036`,`#006628`,`#33C75F`,`#66D98A`,`#99E6B1`][t%6]},`cell-${t}`))}),(0,L.jsx)(ez,{formatter:e=>h2(e)}),(0,L.jsx)(US,{})]})})]})]})}function y2({market:e,onBack:t}){let{data:n,isLoading:r}=R({queryKey:[`multi-market`,`drilldown`,e],queryFn:()=>U$.getDrillDown(e)});if(r)return(0,L.jsx)(`div`,{className:`flex h-64 items-center justify-center`,children:(0,L.jsx)(K,{className:`h-6 w-6 animate-spin text-brand-600`})});if(!n)return null;let{summary:i,pipeline_by_stage:a,top_deals:o,revenue_trend:s}=n;return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`button`,{onClick:t,className:`flex items-center gap-2 text-sm font-medium text-surface-600 hover:text-surface-900 min-h-[44px]`,children:[(0,L.jsx)(el,{className:`h-4 w-4 rotate-180`}),`Back to Markets`]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-xl font-bold text-surface-900`,children:e}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Market Drill-Down`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-full px-3 py-1 text-sm font-medium ${i.close_rate>=30?`bg-green-100 text-green-700`:`bg-orange-100 text-orange-700`}`,children:[i.close_rate>=30?(0,L.jsx)(bc,{className:`h-4 w-4`}):(0,L.jsx)(jc,{className:`h-4 w-4`}),g2(i.close_rate),` Close Rate`]})]}),(0,L.jsxs)(`div`,{className:`mt-6 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Total Revenue`}),(0,L.jsx)(`p`,{className:`mt-1 text-xl font-bold text-surface-900`,children:h2(i.total_revenue)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Won Deals`}),(0,L.jsx)(`p`,{className:`mt-1 text-xl font-bold text-surface-900`,children:i.won_deals})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Avg Deal Size`}),(0,L.jsx)(`p`,{className:`mt-1 text-xl font-bold text-surface-900`,children:h2(i.avg_deal_size)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Active Contacts`}),(0,L.jsx)(`p`,{className:`mt-1 text-xl font-bold text-surface-900`,children:i.active_contacts})]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-lg font-semibold text-surface-900`,children:[(0,L.jsx)(mc,{className:`h-5 w-5 text-brand-600`}),`Pipeline by Stage`]}),(0,L.jsx)(Fb,{width:`100%`,height:250,children:(0,L.jsxs)(cQ,{data:a,children:[(0,L.jsx)(FG,{strokeDasharray:`3 3`,stroke:`#e5e7eb`}),(0,L.jsx)(KY,{dataKey:`stage`,tick:{fontSize:11}}),(0,L.jsx)(sX,{tick:{fontSize:12}}),(0,L.jsx)(ez,{}),(0,L.jsx)(US,{}),(0,L.jsx)(TY,{dataKey:`count`,name:`Count`,fill:`#00A846`,radius:[4,4,0,0]}),(0,L.jsx)(TY,{dataKey:`value`,name:`Value`,fill:`#008036`,radius:[4,4,0,0]})]})})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-lg font-semibold text-surface-900`,children:[(0,L.jsx)(wu,{className:`h-5 w-5 text-brand-600`}),`Revenue Trend (6 Months)`]}),(0,L.jsx)(Fb,{width:`100%`,height:250,children:(0,L.jsxs)(AQ,{data:s,children:[(0,L.jsx)(FG,{strokeDasharray:`3 3`,stroke:`#e5e7eb`}),(0,L.jsx)(KY,{dataKey:`month`,tick:{fontSize:12}}),(0,L.jsx)(sX,{tick:{fontSize:12},tickFormatter:h2}),(0,L.jsx)(ez,{formatter:e=>h2(e)}),(0,L.jsx)(Qq,{type:`monotone`,dataKey:`revenue`,stroke:`#00A846`,fill:`#00A846`,fillOpacity:.1,name:`Revenue`})]})})]}),o.length>0&&(0,L.jsxs)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:[(0,L.jsx)(`div`,{className:`border-b border-surface-200 bg-surface-50 px-4 py-3`,children:(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-surface-900`,children:`Top Deals`})}),(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{className:`border-b border-surface-200`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-semibold text-surface-700`,children:`Amount`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-semibold text-surface-700`,children:`Stage`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-semibold text-surface-700`,children:`Probability`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-semibold text-surface-700`,children:`Expected Close`})]})}),(0,L.jsx)(`tbody`,{children:o.map((e,t)=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 ${t%2==0?`bg-white`:`bg-surface-50/50`}`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900`,children:h2(e.amount)}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-flex rounded-full bg-surface-100 px-2 py-0.5 text-xs font-medium text-surface-700`,children:e.stage})}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:e.probability?g2(e.probability*100):`-`}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:e.expected_close_date?new Date(e.expected_close_date).toLocaleDateString():`-`})]},e.id))})]})]})]})}function b2(){let{data:e,isLoading:t}=R({queryKey:[`multi-market`,`underperforming`],queryFn:U$.getUnderperforming});if(t)return(0,L.jsx)(`div`,{className:`flex h-64 items-center justify-center`,children:(0,L.jsx)(K,{className:`h-6 w-6 animate-spin text-brand-600`})});if(!e?.underperforming?.length)return(0,L.jsxs)(`div`,{className:`rounded-xl border border-green-200 bg-green-50 p-8 text-center`,children:[(0,L.jsx)(bc,{className:`mx-auto h-12 w-12 text-green-600`}),(0,L.jsx)(`p`,{className:`mt-4 text-lg font-medium text-green-800`,children:`All markets performing well`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm text-green-600`,children:`No underperforming markets detected`})]});let n={high:`bg-red-100 border-red-200 text-red-800`,medium:`bg-orange-100 border-orange-200 text-orange-800`,low:`bg-yellow-100 border-yellow-200 text-yellow-800`};return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Avg Close Rate`}),(0,L.jsx)(`p`,{className:`mt-1 text-2xl font-bold text-surface-900`,children:g2(e.benchmarks?.avg_close_rate??0)})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Avg Revenue`}),(0,L.jsx)(`p`,{className:`mt-1 text-2xl font-bold text-surface-900`,children:h2(e.benchmarks?.avg_revenue??0)})]})]}),(0,L.jsx)(`div`,{className:`space-y-4`,children:e.underperforming.map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border p-6 ${n[e.severity]}`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(jc,{className:`h-5 w-5`}),(0,L.jsx)(`h4`,{className:`text-lg font-semibold`,children:e.market}),(0,L.jsx)(`span`,{className:`inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${e.severity===`high`?`bg-red-200 text-red-800`:e.severity===`medium`?`bg-orange-200 text-orange-800`:`bg-yellow-200 text-yellow-800`}`,children:e.severity.toUpperCase()})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsxs)(`p`,{className:`text-sm opacity-75`,children:[`Revenue: `,h2(e.metrics.total_revenue)]}),(0,L.jsxs)(`p`,{className:`text-sm opacity-75`,children:[`CR: `,g2(e.metrics.close_rate)]})]})]}),(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium opacity-75`,children:`Issues:`}),(0,L.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:e.issues.map(e=>(0,L.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-white/50 px-2 py-1 text-xs font-medium`,children:e.replace(/_/g,` `)},e))})]}),(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium opacity-75`,children:`Recommendations:`}),(0,L.jsx)(`ul`,{className:`mt-2 space-y-1`,children:e.recommendations.map((e,t)=>(0,L.jsxs)(`li`,{className:`flex items-start gap-2 text-sm`,children:[(0,L.jsx)(Rc,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,L.jsx)(`span`,{children:e})]},t))})]})]},e.market))})]})}function x2(){let[e,t]=(0,S.useState)(`overview`),[n,r]=(0,S.useState)(null);return(0,L.jsx)($,{children:(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl font-bold text-surface-900 sm:text-2xl`,children:`Multi-Market Analytics`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Rank markets by performance and identify coaching opportunities`})]}),(0,L.jsx)(`div`,{className:`flex gap-1 rounded-lg bg-surface-100 p-1`,children:[{id:`overview`,label:`Overview`,icon:Ll},{id:`comparison`,label:`Comparison`,icon:mc},{id:`underperforming`,label:`Underperforming`,icon:jc}].map(n=>{let i=n.icon;return(0,L.jsxs)(`button`,{onClick:()=>{t(n.id),r(null)},className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2.5 text-sm font-medium transition-colors min-h-[44px] ${e===n.id?`bg-white text-surface-900 shadow-sm`:`text-surface-600 hover:text-surface-900`}`,children:[(0,L.jsx)(i,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:n.label})]},n.id)})}),n?(0,L.jsx)(y2,{market:n,onBack:()=>r(null)}):e===`overview`?(0,L.jsx)(_2,{}):e===`comparison`?(0,L.jsx)(v2,{}):(0,L.jsx)(b2,{})]})})}var S2=300*1e3,C2={high:0,medium:1,low:2},w2={high:`border-red-200 bg-red-50/60`,medium:`border-amber-200 bg-amber-50/60`,low:`border-emerald-200 bg-emerald-50/60`},T2={high:`bg-red-100 text-red-700`,medium:`bg-amber-100 text-amber-700`,low:`bg-emerald-100 text-emerald-700`},E2={high:`bg-red-100 text-red-600`,medium:`bg-amber-100 text-amber-600`,low:`bg-emerald-100 text-emerald-600`},D2={market:{label:`Market`,icon:jc},forecast:{label:`Forecast`,icon:wu},goal:{label:`Goals`,icon:yu},scale:{label:`Scale`,icon:Rc},intelligence:{label:`Intelligence`,icon:fu}},O2=[`market`,`forecast`,`goal`,`scale`,`intelligence`];function k2(e){return D2[e]??{label:e.charAt(0).toUpperCase()+e.slice(1),icon:Al}}function A2(e){return e>=80?{text:`text-emerald-600`,stroke:`stroke-emerald-500`,label:`Healthy`}:e>=50?{text:`text-amber-600`,stroke:`stroke-amber-500`,label:`Needs attention`}:{text:`text-red-600`,stroke:`stroke-red-500`,label:`At risk`}}function j2(e){if(e.length===0)return 100;let t=e.filter(e=>e.severity===`high`).length,n=e.filter(e=>e.severity===`medium`).length;return Math.max(30,100-t*20-n*10)}function M2({score:e}){let t=A2(e);return(0,L.jsxs)(`div`,{className:`relative h-28 w-28 shrink-0`,children:[(0,L.jsxs)(`svg`,{viewBox:`0 0 36 36`,className:`h-full w-full -rotate-90`,children:[(0,L.jsx)(`circle`,{cx:`18`,cy:`18`,r:`15.915`,fill:`none`,stroke:`#e5e7eb`,strokeWidth:`3.2`}),(0,L.jsx)(`circle`,{cx:`18`,cy:`18`,r:`15.915`,fill:`none`,strokeWidth:`3.2`,strokeDasharray:`${e} 100`,strokeLinecap:`round`,className:`transition-all duration-700 ${t.stroke}`})]}),(0,L.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center`,children:[(0,L.jsx)(`span`,{className:`text-3xl font-bold ${t.text}`,children:e}),(0,L.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-surface-400`,children:`/ 100`})]})]})}function N2({insight:e,onDismiss:t,dismissing:n}){let r=k2(e.category),i=r.icon;return(0,L.jsx)(`div`,{className:`rounded-xl border p-5 transition-colors ${w2[e.severity]}`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,L.jsx)(`div`,{className:`mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-lg ${E2[e.severity]}`,children:(0,L.jsx)(i,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`font-semibold text-surface-900`,children:e.title}),(0,L.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-semibold uppercase tracking-wide ${T2[e.severity]}`,children:e.severity}),(0,L.jsx)(`span`,{className:`rounded-full bg-white/80 px-2 py-0.5 text-xs font-medium text-surface-600 ring-1 ring-surface-200`,children:r.label})]}),(0,L.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-surface-700`,children:e.narrative}),e.action_url&&(0,L.jsxs)(Mn,{to:e.action_url,className:`mt-3 inline-flex items-center gap-1 text-sm font-semibold text-brand-600 hover:text-brand-700`,children:[`Take action `,(0,L.jsx)(Rc,{className:`h-3.5 w-3.5`})]})]}),(0,L.jsx)(`button`,{onClick:()=>t(e.id),disabled:n,className:`rounded-lg p-1.5 text-surface-400 transition-colors hover:bg-white/60 hover:text-surface-600 disabled:opacity-40`,title:`Dismiss for 24 hours`,"aria-label":`Dismiss ${e.title}`,children:(0,L.jsx)(Iu,{className:`h-4 w-4`})})]})})}function P2(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(!0),[i,a]=(0,S.useState)(!1),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(`all`),[u,d]=(0,S.useState)(`all`),[f,p]=(0,S.useState)(new Set),[m,h]=(0,S.useState)(null),[g,_]=(0,S.useState)(null),[v,y]=(0,S.useState)(null),b=(0,S.useCallback)(async(e=!1)=>{try{e?a(!0):r(!0);let n=await e$.getInsights();t(e=>(e&&y(e.overall_score),n)),_(new Date),s(null)}catch(t){e||s(t instanceof Error?t.message:`Failed to load coaching insights`)}finally{r(!1),a(!1)}},[]);(0,S.useEffect)(()=>{b();let e=setInterval(()=>b(!0),S2);return()=>clearInterval(e)},[b]),(0,S.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>h(null),4e3);return()=>clearTimeout(e)},[m]);let x=async e=>{p(t=>new Set(t).add(e));try{await e$.dismissInsight(e),t(t=>t&&{...t,insights:t.insights.map(t=>t.id===e?{...t,dismissed:!0}:t)}),h({message:`Insight dismissed for 24 hours`,type:`success`})}catch{h({message:`Failed to dismiss insight — please try again`,type:`error`})}finally{p(t=>{let n=new Set(t);return n.delete(e),n})}},C=(0,S.useMemo)(()=>(e?.insights??[]).filter(e=>!e.dismissed).sort((e,t)=>C2[e.severity]-C2[t.severity]),[e]),w=C[0]??null,T=(0,S.useMemo)(()=>C.filter(e=>(c===`all`||e.category===c)&&(u===`all`||e.severity===u)),[C,c,u]),E=(0,S.useMemo)(()=>{let e=new Set(C.map(e=>e.category)),t=O2.filter(t=>e.has(t));for(let n of e)t.includes(n)||t.push(n);return t},[C]),D=e?.overall_score??100,O=A2(D),k=C.filter(e=>e.severity===`high`).length,A=C.filter(e=>e.severity===`medium`).length,j=C.filter(e=>e.severity===`low`).length,M=(e?.insights??[]).filter(e=>e.dismissed).length,N=v===null?0:D-v;return n&&!e?(0,L.jsx)($,{title:`Smart Coaching`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-24`,children:[(0,L.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-brand-600 border-t-transparent`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading coaching insights…`})]})}):(0,L.jsxs)($,{title:`Smart Coaching`,children:[m&&(0,L.jsxs)(`div`,{className:`fixed bottom-6 right-6 z-50 flex items-center gap-2 rounded-lg px-4 py-3 text-sm font-medium shadow-lg ${m.type===`success`?`bg-surface-900 text-white`:`bg-red-600 text-white`}`,children:[m.type===`success`?(0,L.jsx)(yc,{className:`h-4 w-4`}):(0,L.jsx)(vc,{className:`h-4 w-4`}),m.message]}),(0,L.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl font-bold text-surface-900 sm:text-2xl`,children:`Smart Coaching`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Data-driven recommendations across your markets, forecasts, and goals`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[g&&(0,L.jsxs)(`span`,{className:`text-xs text-surface-400`,children:[`Updated `,g.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})]}),(0,L.jsxs)(`button`,{onClick:()=>b(!0),disabled:i,className:`inline-flex items-center gap-1.5 rounded-lg border border-surface-200 bg-white px-3 py-1.5 text-sm font-medium text-surface-600 transition-colors hover:bg-surface-50 disabled:opacity-50`,children:[(0,L.jsx)(nu,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),`Refresh`]})]})]}),o?(0,L.jsxs)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 p-8 text-center`,children:[(0,L.jsx)(vc,{className:`mx-auto h-8 w-8 text-red-400`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm font-medium text-red-800`,children:o}),(0,L.jsx)(`button`,{onClick:()=>b(),className:`mt-3 rounded-lg bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700`,children:`Try again`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-4 lg:grid-cols-3`,children:[(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-5`,children:[(0,L.jsx)(M2,{score:D}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Business Health Score`}),(0,L.jsx)(`p`,{className:`mt-1 text-lg font-semibold ${O.text}`,children:O.label}),v!==null&&N!==0&&(0,L.jsxs)(`p`,{className:`mt-1 inline-flex items-center gap-0.5 text-xs font-medium ${N>0?`text-emerald-600`:`text-red-600`}`,children:[N>0?(0,L.jsx)($c,{className:`h-3.5 w-3.5`}):(0,L.jsx)(Zc,{className:`h-3.5 w-3.5`}),Math.abs(N),` pts since last refresh`]}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-400`,children:`Recalculated every 5 minutes`})]})]})}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Active Recommendations`}),(0,L.jsx)(`p`,{className:`mt-2 text-4xl font-bold text-surface-900`,children:C.length}),(0,L.jsxs)(`div`,{className:`mt-3 flex items-center gap-3 text-xs font-medium`,children:[(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-red-600`,children:[(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-red-500`}),` `,k,` high`]}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-amber-600`,children:[(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-amber-500`}),` `,A,` medium`]}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-emerald-600`,children:[(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-emerald-500`}),` `,j,` low`]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Dismissed`}),(0,L.jsx)(`p`,{className:`mt-2 text-4xl font-bold text-surface-900`,children:M}),(0,L.jsx)(`p`,{className:`mt-3 text-xs text-surface-400`,children:`Hidden for 24 hours`})]})]}),w&&(0,L.jsx)(`div`,{className:`mb-6 overflow-hidden rounded-xl border border-brand-200 bg-gradient-to-r from-brand-50 to-white`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-6 sm:flex-row sm:items-center`,children:[(0,L.jsx)(`div`,{className:`flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-brand-100 text-brand-600`,children:(0,L.jsx)(Al,{className:`h-6 w-6`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`p`,{className:`text-xs font-bold uppercase tracking-wider text-brand-600`,children:`Your Next Move`}),(0,L.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs font-semibold uppercase ${T2[w.severity]}`,children:w.severity})]}),(0,L.jsx)(`h2`,{className:`mt-1 text-lg font-bold text-surface-900`,children:w.title}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-600`,children:w.narrative})]}),w.action_url&&(0,L.jsxs)(Mn,{to:w.action_url,className:`inline-flex shrink-0 items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-brand-700`,children:[`Take action `,(0,L.jsx)(Lc,{className:`h-4 w-4`})]})]})}),C.length>0&&(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700`,children:`Category Scorecards`}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5`,children:O2.map(e=>{let t=C.filter(t=>t.category===e),n=j2(t),r=A2(n),i=k2(e),a=i.icon;return(0,L.jsxs)(`button`,{onClick:()=>l(c===e?`all`:e),className:`rounded-xl border bg-white p-4 text-left transition-all hover:shadow-sm ${c===e?`border-brand-400 ring-1 ring-brand-200`:`border-surface-200`}`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(a,{className:`h-4 w-4 text-surface-400`}),n>=80?(0,L.jsx)(yc,{className:`h-4 w-4 text-emerald-500`}):t.some(e=>e.severity===`high`)?(0,L.jsx)(jc,{className:`h-4 w-4 text-red-500`}):(0,L.jsx)(Bl,{className:`h-4 w-4 text-amber-500`})]}),(0,L.jsx)(`p`,{className:`mt-2 text-xs font-medium text-surface-500`,children:i.label}),(0,L.jsx)(`p`,{className:`text-xl font-bold ${r.text}`,children:n}),(0,L.jsx)(`p`,{className:`text-[11px] text-surface-400`,children:t.length===0?`No issues`:`${t.length} alert${t.length===1?``:`s`}`})]},e)})})]}),(0,L.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(wc,{className:`h-4 w-4 text-surface-400`}),(0,L.jsx)(`button`,{onClick:()=>l(`all`),className:`rounded-full px-3 py-1.5 text-sm font-medium transition-colors ${c===`all`?`bg-brand-100 text-brand-700`:`text-surface-500 hover:bg-surface-100`}`,children:`All categories`}),E.map(e=>{let t=k2(e);return(0,L.jsx)(`button`,{onClick:()=>l(c===e?`all`:e),className:`rounded-full px-3 py-1.5 text-sm font-medium transition-colors ${c===e?`bg-brand-100 text-brand-700`:`text-surface-500 hover:bg-surface-100`}`,children:t.label},e)}),(0,L.jsx)(`span`,{className:`mx-2 h-4 w-px bg-surface-200`}),[`all`,`high`,`medium`,`low`].map(e=>(0,L.jsx)(`button`,{onClick:()=>d(e),className:`rounded-full px-3 py-1.5 text-sm font-medium capitalize transition-colors ${u===e?`bg-surface-900 text-white`:`text-surface-500 hover:bg-surface-100`}`,children:e===`all`?`Any severity`:e},e)),(0,L.jsxs)(`span`,{className:`ml-auto text-xs text-surface-400`,children:[T.length,` insight`,T.length===1?``:`s`]})]}),T.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-12 text-center`,children:[(0,L.jsx)(yc,{className:`mx-auto h-12 w-12 text-emerald-300`}),(0,L.jsx)(`h3`,{className:`mt-4 text-lg font-semibold text-surface-900`,children:C.length===0?`All clear!`:`No matching insights`}),(0,L.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm text-surface-500`,children:C.length===0?`No coaching recommendations right now — your metrics are looking good. We re-check every 5 minutes.`:`Try adjusting your category or severity filters to see other insights.`})]}):(0,L.jsx)(`div`,{className:`space-y-4`,children:T.map(e=>(0,L.jsx)(N2,{insight:e,onDismiss:x,dismissing:f.has(e.id)},e.id))})]})]})}var F2={getTeam:async()=>{let{data:e}=await H.get(`/api/partner/team`);return e.data},addTeamMember:async e=>(await H.post(`/api/partner/team`,e)).data,updateTeamMember:async(e,t)=>(await H.put(`/api/partner/team/${e}`,t)).data,removeTeamMember:async e=>(await H.delete(`/api/partner/team/${e}`)).data,getInvites:async()=>{let{data:e}=await H.get(`/api/user/invites`);return e.data},sendInvite:async e=>(await H.post(`/api/user/invites`,e)).data,cancelInvite:async e=>(await H.delete(`/api/user/invites/${e}`)).data},I2={getUserSettings:async()=>{let{data:e}=await H.get(`/api/user/settings`);return e.data},updateUserSettings:async e=>{await H.put(`/api/user/settings`,{settings:e})},getCompany:async()=>{let{data:e}=await H.get(`/api/user/company`);return e.data},updateCompany:async e=>(await H.put(`/api/user/company`,e)).data.data,getCompanySettings:async()=>{let{data:e}=await H.get(`/api/user/company-settings`);return e.data},updateCompanySettings:async e=>{await H.put(`/api/user/company-settings`,{settings:e})},getSubscription:async()=>{let{data:e}=await H.get(`/api/user/subscription`);return e.data},getUsage:async()=>{let{data:e}=await H.get(`/api/user/usage`);return e.data},upgradeSubscription:async()=>{await H.put(`/api/user/subscription`)}};function L2(){let e=ci();return z({mutationFn:e=>I2.updateCompany(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`company`]}),e.invalidateQueries({queryKey:[`auth-user`]})}})}var R2={getAvailableIntegrations:async()=>{let{data:e}=await H.get(`/api/connectors/available`);return e.connectors},getConnectedIntegrations:async()=>{let{data:e}=await H.get(`/api/connectors`);return e},connectIntegration:async e=>{let{data:t}=await H.get(`/api/connectors/oauth/authorize/${e}`);return t},disconnectIntegration:async e=>{let{data:t}=await H.delete(`/api/connectors/${e}`);return t},triggerSync:async e=>{let{data:t}=await H.post(`/api/connectors/${e}/sync`);return t},getConnectorLogs:async e=>{let{data:t}=await H.get(`/api/connectors/${e}/logs`);return{logs:t.logs}}},z2=`rounded-lg bg-brand-600 py-2 px-4 text-sm font-semibold text-white hover:bg-brand-700 disabled:opacity-50`,B2=`rounded-lg border border-surface-300 py-2 px-4 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-50`;function V2({label:e,icon:t,used:n,limit:r,percentage:i}){return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-surface-700`,children:[(0,L.jsx)(t,{className:`h-4 w-4 text-surface-400`}),e]}),(0,L.jsxs)(`span`,{className:`text-xs text-surface-500`,children:[n,`/`,r,` used`]})]}),(0,L.jsx)(`div`,{className:`h-2.5 w-full overflow-hidden rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full transition-all duration-300 ${i>=90?`bg-red-500`:i>=70?`bg-yellow-500`:`bg-brand-500`}`,style:{width:`${Math.min(i,100)}%`}})})]})}function H2({open:e,onClose:t,onUpgrade:n,isLoading:r,error:i}){return e?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,onClick:t,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border border-surface-200 bg-white p-6 shadow-xl`,onClick:e=>e.stopPropagation(),children:[(0,L.jsx)(`h3`,{className:`mb-2 text-lg font-semibold text-surface-900`,children:`Upgrade Plan`}),(0,L.jsx)(`p`,{className:`mb-4 text-sm text-surface-600`,children:`Stripe billing integration is currently in progress. Upgrade functionality will be available soon.`}),i&&(0,L.jsxs)(`div`,{className:`mb-4 flex items-start gap-2 rounded-lg bg-red-50 p-3 text-sm text-red-700`,children:[(0,L.jsx)(vc,{className:`mt-0.5 h-4 w-4 shrink-0`}),i]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,className:B2,disabled:r,children:`Close`}),(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:r,className:z2,children:r?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),`Processing…`]}):`Try Upgrade`})]})]})}):null}function U2(){let[e,t]=(0,S.useState)(!1),[n,r]=(0,S.useState)(null),{data:i,isLoading:a}=R({queryKey:[`subscription`],queryFn:I2.getSubscription,staleTime:6e4,refetchOnWindowFocus:!1}),{data:o,isLoading:s}=R({queryKey:[`usage`],queryFn:I2.getUsage,staleTime:6e4,refetchOnWindowFocus:!1}),c=z({mutationFn:()=>I2.upgradeSubscription(),onSuccess:()=>{t(!1),r(null)},onError:e=>{r(e?.response?.data?.error||`Upgrade is not yet available — Stripe integration is in progress.`)}}),l=()=>{r(null),c.mutate()},u=i?.plan,d=o?.usage,f=o?.limits,p=o?.percentages;if(a||s)return(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-surface-500`,children:[(0,L.jsx)(K,{className:`h-5 w-5 animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Loading billing information…`})]})});if(!u)return(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No subscription data available.`})});let m=u.currency===`USD`?`$`:u.currency,h=u.name.toLowerCase().includes(`pro`)||u.name.toLowerCase().includes(`enterprise`);return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`rounded-lg p-2 ${h?`bg-brand-50`:`bg-surface-100`}`,children:(0,L.jsx)(ll,{className:`h-5 w-5 ${h?`text-brand-600`:`text-surface-500`}`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h3`,{className:`text-sm font-semibold text-surface-900`,children:[u.name,` Plan`]}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-500`,children:[i?.status,` · `,i?.billing_cycle,` billing`]})]})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsxs)(`div`,{className:`text-2xl font-bold text-surface-900`,children:[m,u.price]}),(0,L.jsx)(`div`,{className:`text-xs text-surface-500`,children:`per month`})]})]}),(0,L.jsx)(`div`,{className:`space-y-2`,children:u.features.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-surface-600`,children:[(0,L.jsx)(Xc,{className:`h-4 w-4 shrink-0 text-green-500`}),e]},e))}),(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>{r(null),t(!0)},className:z2,children:(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(iu,{className:`h-4 w-4`}),`Upgrade Plan`]})})})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-surface-700`,children:[(0,L.jsx)(cl,{className:`h-4 w-4 text-surface-400`}),`Resource Usage`]}),(0,L.jsx)(`div`,{className:`space-y-5`,children:d&&f&&p&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(V2,{label:`Seats`,icon:Pu,used:d.seats,limit:f.seats,percentage:p.seats}),(0,L.jsx)(V2,{label:`Markets`,icon:bl,used:d.markets,limit:f.markets,percentage:p.markets}),(0,L.jsx)(V2,{label:`Integrations`,icon:$l,used:d.integrations,limit:f.integrations,percentage:p.integrations})]})})]}),(0,L.jsx)(H2,{open:e,onClose:()=>t(!1),onUpgrade:l,isLoading:c.isPending,error:n})]})}var W2=`w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100 bg-white`,G2=`rounded-lg bg-brand-600 py-2 px-4 text-sm font-semibold text-white hover:bg-brand-700 disabled:opacity-50`,K2=`rounded-lg bg-red-600 py-2 px-4 text-sm font-semibold text-white hover:bg-red-700 disabled:opacity-50`,q2=`rounded-md border border-surface-300 px-2.5 py-1 text-xs font-medium text-surface-700 hover:bg-surface-50`,J2=`rounded-md px-2.5 py-1 text-xs font-medium text-red-600 hover:bg-red-50 border border-transparent hover:border-red-200`,Y2=[{value:`owner`,label:`Owner`},{value:`admin`,label:`Admin`},{value:`manager`,label:`Manager`},{value:`member`,label:`Member`},{value:`viewer`,label:`Viewer`}];function X2({role:e}){let t={owner:`bg-purple-100 text-purple-700`,admin:`bg-red-100 text-red-700`,manager:`bg-blue-100 text-blue-700`,member:`bg-green-100 text-green-700`,viewer:`bg-surface-100 text-surface-600`};return(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${t[e]||t.viewer}`,children:e})}function Z2({status:e}){let t=e.toLowerCase()===`active`;return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium ${t?`bg-green-100 text-green-700`:`bg-surface-100 text-surface-500`}`,children:[(0,L.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${t?`bg-green-500`:`bg-surface-400`}`}),e]})}function Q2({open:e,title:t,message:n,confirmLabel:r,danger:i,onClose:a,onConfirm:o,isPending:s}){return e?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,onClick:a,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border border-surface-200 bg-white p-6 shadow-xl`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`rounded-lg p-2 ${i?`bg-red-100`:`bg-brand-100`}`,children:(0,L.jsx)(jc,{className:`h-5 w-5 ${i?`text-red-600`:`text-brand-600`}`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`font-semibold text-surface-900`,children:t}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:n})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:a,className:q2,disabled:s,children:`Cancel`}),(0,L.jsx)(`button`,{type:`button`,onClick:o,className:i?K2:G2,disabled:s,children:s?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),`Processing…`]}):r})]})]})}):null}function $2(){let e=ci(),[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(`member`),[a,o]=(0,S.useState)(null),{data:s,isLoading:c}=R({queryKey:[`team`],queryFn:F2.getTeam,staleTime:3e4}),{data:l,isLoading:u}=R({queryKey:[`invites`],queryFn:F2.getInvites,staleTime:3e4}),d=z({mutationFn:({userId:e,role:t})=>F2.updateTeamMember(e,{role:t}),onSuccess:()=>{e.invalidateQueries({queryKey:[`team`]})}}),f=z({mutationFn:e=>F2.removeTeamMember(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`team`]})}}),p=z({mutationFn:e=>F2.sendInvite(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`invites`]}),n(``),i(`member`)}}),m=z({mutationFn:e=>F2.cancelInvite(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`invites`]})}}),h=()=>{t.trim()&&p.mutate({email:t.trim(),role:r})},g=()=>{if(a){switch(a.type){case`update-role`:d.mutate({userId:a.member.id,role:a.newRole});break;case`remove`:f.mutate(a.member.id);break;case`cancel-invite`:m.mutate(a.invite.id);break}o(null)}},_=e=>e?new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}):`—`,v=e=>{if(!e)return!1;switch(e.type){case`update-role`:return d.isPending;case`remove`:return f.isPending;case`cancel-invite`:return m.isPending}};if(c||u)return(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-surface-500`,children:[(0,L.jsx)(K,{className:`h-5 w-5 animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Loading team information…`})]})});let y=s?.items??[],b=l?.invites??[];return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-surface-900`,children:`Team Management`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mt-1`,children:`Invite team members, manage roles, and control access.`})]}),(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,L.jsx)(`div`,{className:`rounded-lg bg-brand-100 p-3 text-brand-700`,children:(0,L.jsx)(ju,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-surface-900`,children:`Invite a Team Member`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mt-1`,children:`Send an invitation email to add someone to your team.`}),(0,L.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 sm:flex-row sm:items-end`,children:[(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-surface-600`,children:`Email address`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Fl,{className:`absolute left-3 top-2.5 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`email`,value:t,onChange:e=>n(e.target.value),placeholder:`colleague@example.com`,className:`w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100 pl-9`,disabled:p.isPending,onKeyDown:e=>{e.key===`Enter`&&h()}})]})]}),(0,L.jsxs)(`div`,{className:`sm:w-44`,children:[(0,L.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-surface-600`,children:`Role`}),(0,L.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),className:W2,disabled:p.isPending,children:Y2.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,L.jsx)(`button`,{type:`button`,onClick:h,className:G2,disabled:p.isPending||!t.trim(),children:p.isPending?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),`Sending…`]}):(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Send Invite`]})})]}),p.isSuccess&&(0,L.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 rounded-lg bg-green-50 p-3 text-sm text-green-700`,children:[(0,L.jsx)(yc,{className:`h-4 w-4 shrink-0`}),`Invitation sent successfully.`]}),p.error&&(0,L.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 rounded-lg bg-red-50 p-3 text-sm text-red-700`,children:[(0,L.jsx)(jc,{className:`h-4 w-4 shrink-0`}),p.error?.response?.data?.error||`Failed to send invitation.`]})]})]})}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`div`,{className:`mb-4 flex items-center justify-between`,children:(0,L.jsxs)(`h4`,{className:`font-medium text-surface-900`,children:[`Team Members`,` `,(0,L.jsxs)(`span`,{className:`ml-1 text-sm font-normal text-surface-500`,children:[`(`,y.length,` of `,s?.total??0,`)`]})]})}),y.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-surface-400`,children:[(0,L.jsx)(Pu,{className:`mb-3 h-10 w-10`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No team members yet.`}),(0,L.jsx)(`p`,{className:`text-xs`,children:`Use the form above to invite your first member.`})]}):(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 text-left text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Name`}),(0,L.jsx)(`th`,{className:`pb-3 text-left text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Email`}),(0,L.jsx)(`th`,{className:`pb-3 text-left text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Role`}),(0,L.jsx)(`th`,{className:`pb-3 text-left text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`pb-3 text-left text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Last Login`}),(0,L.jsx)(`th`,{className:`pb-3 text-right text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Actions`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:y.map(e=>(0,L.jsxs)(`tr`,{className:`group`,children:[(0,L.jsx)(`td`,{className:`py-3 pr-4 font-medium text-surface-900`,children:e.name}),(0,L.jsx)(`td`,{className:`py-3 pr-4 text-surface-600`,children:e.email}),(0,L.jsx)(`td`,{className:`py-3 pr-4`,children:(0,L.jsx)(X2,{role:e.role})}),(0,L.jsx)(`td`,{className:`py-3 pr-4`,children:(0,L.jsx)(Z2,{status:e.status})}),(0,L.jsx)(`td`,{className:`py-3 pr-4 text-surface-500`,children:(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(al,{className:`h-3.5 w-3.5`}),_(e.lastLogin)]})}),(0,L.jsx)(`td`,{className:`py-3 text-right`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2 opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,L.jsxs)(`select`,{value:e.role,onChange:t=>{t.target.value!==e.role&&o({type:`update-role`,member:e,newRole:t.target.value})},className:`rounded-md border border-surface-300 px-2.5 py-1 text-xs font-medium text-surface-700 hover:bg-surface-50 h-7 w-auto text-xs`,children:[(0,L.jsx)(`option`,{value:``,children:`Change role…`}),Y2.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>o({type:`remove`,member:e}),className:J2,title:`Remove member`,children:(0,L.jsx)(Su,{className:`h-3.5 w-3.5`})})]})})]},e.id))})]})})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h4`,{className:`mb-4 font-medium text-surface-900`,children:[`Pending Invitations`,` `,(0,L.jsxs)(`span`,{className:`text-sm font-normal text-surface-500`,children:[`(`,b.length,`)`]})]}),b.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-surface-400`,children:[(0,L.jsx)(Fl,{className:`mb-3 h-10 w-10`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No pending invitations.`})]}):(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 text-left text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Email`}),(0,L.jsx)(`th`,{className:`pb-3 text-left text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Role`}),(0,L.jsx)(`th`,{className:`pb-3 text-left text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Sent`}),(0,L.jsx)(`th`,{className:`pb-3 text-left text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Expires`}),(0,L.jsx)(`th`,{className:`pb-3 text-right text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Actions`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:b.map(e=>(0,L.jsxs)(`tr`,{className:`group`,children:[(0,L.jsx)(`td`,{className:`py-3 pr-4 text-surface-900`,children:e.email}),(0,L.jsx)(`td`,{className:`py-3 pr-4`,children:(0,L.jsx)(X2,{role:e.role})}),(0,L.jsx)(`td`,{className:`py-3 pr-4 text-surface-500`,children:_(e.created_at)}),(0,L.jsx)(`td`,{className:`py-3 pr-4 text-surface-500`,children:_(e.expires_at)}),(0,L.jsx)(`td`,{className:`py-3 text-right`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>o({type:`cancel-invite`,invite:e}),className:J2,title:`Cancel invitation`,children:`Cancel`})})]},e.id))})]})})]}),a&&(0,L.jsx)(Q2,{open:!!a,isPending:v(a),onClose:()=>o(null),onConfirm:g,...(()=>{switch(a.type){case`update-role`:return{title:`Change Role`,message:`Change ${a.member.name}'s role to ${a.newRole}?`,confirmLabel:`Change Role`};case`remove`:return{title:`Remove Team Member`,message:`Remove ${a.member.name} from the team? This cannot be undone.`,confirmLabel:`Remove`,danger:!0};case`cancel-invite`:return{title:`Cancel Invitation`,message:`Cancel the invitation for ${a.invite.email}?`,confirmLabel:`Cancel Invite`}}})()})]})}var e4=`rounded-lg bg-brand-600 py-2 px-4 text-sm font-semibold text-white hover:bg-brand-700 disabled:opacity-50`,t4=`rounded-lg border border-surface-300 py-2 px-4 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-50`,n4=`rounded-lg border border-red-200 py-2 px-4 text-sm font-medium text-red-600 hover:bg-red-50 disabled:opacity-50`;function r4(e){if(!e)return`Never`;let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`Just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function i4(e){switch(e){case`connected`:case`success`:return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-green-50 px-2.5 py-1 text-xs font-medium text-green-700`,children:[(0,L.jsx)(yc,{className:`h-3 w-3`}),` Connected`]});case`error`:case`failed`:return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-red-50 px-2.5 py-1 text-xs font-medium text-red-700`,children:[(0,L.jsx)(vc,{className:`h-3 w-3`}),` Failed`]});case`syncing`:return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-brand-50 px-2.5 py-1 text-xs font-medium text-brand-700`,children:[(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}),` Syncing`]});default:return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-surface-100 px-2.5 py-1 text-xs font-medium text-surface-600`,children:[(0,L.jsx)(xc,{className:`h-3 w-3`}),` Never synced`]})}}function a4(e){switch(e){case`success`:return(0,L.jsx)(`span`,{className:`text-green-600`,children:`Success`});case`failed`:case`error`:return(0,L.jsx)(`span`,{className:`text-red-600`,children:`Failed`});case`pending`:case`syncing`:return(0,L.jsx)(`span`,{className:`text-brand-600`,children:`Running`});default:return(0,L.jsx)(`span`,{className:`text-surface-500`,children:e})}}function o4({connectorId:e,serviceName:t}){let[n,r]=(0,S.useState)(!1),{data:i,isLoading:a}=R({queryKey:[`connector-logs`,e],queryFn:()=>R2.getConnectorLogs(e),enabled:n,staleTime:3e4,refetchOnWindowFocus:!1});return(0,L.jsxs)(`div`,{className:`mt-3 rounded-lg border border-surface-200 bg-surface-50`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`flex w-full items-center justify-between px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-100`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(_l,{className:`h-4 w-4 text-surface-400`}),`Sync Logs for `,t,i&&(0,L.jsxs)(`span`,{className:`text-xs text-surface-400`,children:[`(`,i.logs.length,` entries)`]})]}),n?(0,L.jsx)($c,{className:`h-4 w-4 text-surface-400`}):(0,L.jsx)(Zc,{className:`h-4 w-4 text-surface-400`})]}),n&&(0,L.jsx)(`div`,{className:`max-h-48 overflow-y-auto border-t border-surface-200 px-4 py-2`,children:a?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-surface-500`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),`Loading logs…`]}):i?.logs.length?(0,L.jsx)(`div`,{className:`space-y-1.5`,children:i.logs.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-white px-3 py-1.5 text-xs`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a4(e.status),(0,L.jsx)(`span`,{className:`text-surface-600`,children:e.event_type}),e.record_count>0&&(0,L.jsxs)(`span`,{className:`text-surface-400`,children:[e.record_count,` records`]}),e.duration_ms&&(0,L.jsxs)(`span`,{className:`text-surface-400`,children:[e.duration_ms,`ms`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.error_message&&(0,L.jsx)(`span`,{className:`text-red-500 truncate max-w-[150px]`,title:e.error_message,children:e.error_message}),(0,L.jsx)(`span`,{className:`shrink-0 text-surface-400`,children:r4(e.created_at)})]})]},e.id))}):(0,L.jsx)(`p`,{className:`py-2 text-sm text-surface-400`,children:`No sync logs available.`})})]})}function s4({connector:e,onDisconnect:t,onSync:n,disconnectingIds:r,syncingIds:i}){return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-surface-100`,children:(0,L.jsx)($l,{className:`h-5 w-5 text-surface-500`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-semibold text-surface-900`,children:e.serviceDisplayName}),(0,L.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2`,children:[i4(e.status),(0,L.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-surface-400`,children:[(0,L.jsx)(al,{className:`h-3 w-3`}),r4(e.last_sync_at)]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),disabled:r.includes(e.id)||i.includes(e.id),className:t4,title:`Sync now`,children:i.includes(e.id)?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),`Syncing…`]}):(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(nu,{className:`h-4 w-4`}),`Sync Now`]})}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),disabled:r.includes(e.id)||i.includes(e.id),className:n4,title:`Disconnect`,children:r.includes(e.id)?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Su,{className:`h-4 w-4`}),`Disconnect`]})})]})]}),e.error_message&&(0,L.jsxs)(`div`,{className:`mb-3 flex items-start gap-2 rounded-lg bg-red-50 p-3 text-xs text-red-600`,children:[(0,L.jsx)(vc,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,L.jsx)(`span`,{children:e.error_message})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-surface-500`,children:[(0,L.jsxs)(`span`,{children:[`Sync: `,e.sync_frequency]}),(0,L.jsxs)(`span`,{children:[`Auth: `,e.auth_type===`oauth2`?`OAuth 2.0`:`Manual`]}),(0,L.jsxs)(`span`,{children:[`Connected: `,r4(e.created_at).replace(` ago`,``)]})]}),(0,L.jsx)(o4,{connectorId:e.id,serviceName:e.serviceDisplayName})]})}function c4({service:e,displayName:t,description:n,onConnect:r,connectingService:i}){return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-surface-100`,children:(0,L.jsx)($l,{className:`h-5 w-5 text-surface-500`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-semibold text-surface-900`,children:t}),(0,L.jsx)(`p`,{className:`mt-0.5 text-xs text-surface-500 line-clamp-2`,children:n})]})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>r(e),disabled:i===e,className:e4,children:i===e?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),`Redirecting…`]}):(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(pl,{className:`h-4 w-4`}),`Connect`]})})]})}function l4(){let e=ci(),[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)([]),[a,o]=(0,S.useState)([]),{data:s,isLoading:c}=R({queryKey:[`available-integrations`],queryFn:R2.getAvailableIntegrations,staleTime:3e5,refetchOnWindowFocus:!1}),{data:l,isLoading:u}=R({queryKey:[`connected-integrations`],queryFn:R2.getConnectedIntegrations,staleTime:6e4,refetchOnWindowFocus:!1}),d=z({mutationFn:e=>R2.disconnectIntegration(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`connected-integrations`]})}}),f=z({mutationFn:e=>R2.triggerSync(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`connected-integrations`]}),e.invalidateQueries({queryKey:[`connector-logs`]})}}),p=z({mutationFn:e=>R2.connectIntegration(e),onSuccess:e=>{e.redirect_url&&(window.location.href=e.redirect_url)},onSettled:()=>{n(null)}}),m=e=>{n(e),p.mutate(e)},h=e=>{window.confirm(`Disconnect this integration? This will remove all synced data.`)&&(i(t=>[...t,e]),d.mutate(e,{onSettled:()=>{i(t=>t.filter(t=>t!==e))}}))},g=e=>{o(t=>[...t,e]),f.mutate(e,{onSettled:()=>{o(t=>t.filter(t=>t!==e))}})},_=new Set(l?.connectors.map(e=>e.service)||[]),v=s||[],y=l?.connectors||[],b=v.filter(e=>!_.has(e.service));return c||u?(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-surface-500`,children:[(0,L.jsx)(K,{className:`h-5 w-5 animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Loading integrations…`})]})}):(0,L.jsxs)(`div`,{className:`space-y-8`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Integrations`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Connect your business tools to automate data sync and unlock revenue insights.`})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700`,children:[`Connected Integrations`,` `,(0,L.jsxs)(`span`,{className:`text-xs font-normal text-surface-400`,children:[`(`,y.length,` connected)`]})]}),y.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-8 text-center`,children:[(0,L.jsx)($l,{className:`mx-auto h-8 w-8 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm font-medium text-surface-600`,children:`No integrations connected`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-400`,children:`Connect a service below to get started.`})]}):(0,L.jsx)(`div`,{className:`space-y-3`,children:y.map(e=>(0,L.jsx)(s4,{connector:e,onDisconnect:h,onSync:g,disconnectingIds:r,syncingIds:a},e.id))})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-700`,children:[`Available Integrations`,` `,(0,L.jsxs)(`span`,{className:`text-xs font-normal text-surface-400`,children:[`(`,b.length,` available)`]})]}),b.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6 text-center`,children:[(0,L.jsx)(yc,{className:`mx-auto h-8 w-8 text-green-400`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm font-medium text-surface-600`,children:`All integrations connected`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-400`,children:`You have connected all available integrations.`})]}):(0,L.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:b.map(e=>(0,L.jsx)(c4,{service:e.service,displayName:e.display_name,description:e.description,onConnect:m,connectingService:t},e.service))})]})]})}var u4=e=>e===`json`?`JSON`:`CSV`;async function d4(e){let{data:t,headers:n}=await H.post(`/api/user/data-export`,{format:e},{responseType:`blob`});return{blob:t,filename:(n[`content-disposition`]||``).match(/filename="?([^"]+)"?/i)?.[1]||`command-sovereignty-export.${e}`}}async function f4(){let{data:e}=await H.post(`/api/user/data-delete`);return e}function p4(){let[e,t]=(0,S.useState)(`json`),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(!1),[o,s]=(0,S.useState)(``),[c,l]=(0,S.useState)(null),u=z({mutationFn:()=>d4(e),onSuccess:async t=>{let{blob:n,filename:i}=t,a=window.URL.createObjectURL(n),o=document.createElement(`a`);o.href=a,o.download=i,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(a),document.body.removeChild(o),r(`Data exported successfully (${u4(e)})`)},onError:e=>{let t=e.response?.data;t instanceof Blob&&t.type.includes(`json`)?t.text().then(e=>{r(`Export failed: ${JSON.parse(e).error||`Unknown error`}`)}).catch(()=>{r(`Export failed: Unknown error`)}):r(typeof t==`object`&&t?`Export failed: ${t.error||`Unknown error`}`:`Export failed: ${e.message||`Unknown error`}`)}}),d=z({mutationFn:()=>f4(),onSuccess:e=>{l(e.error||`Request processed.`)},onError:e=>{l(`Error: ${e.response?.data?.error||`Unknown error`}`)}}),f=i&&o.toLowerCase()===`delete my account`;return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-surface-900`,children:`Data Management`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mt-1`,children:`Export your data or request account deletion. GDPR-compliant.`})]}),(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,L.jsx)(`div`,{className:`rounded-lg bg-blue-100 p-3 text-blue-700`,children:(0,L.jsx)(fl,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-surface-900`,children:`Export Your Data`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mt-1`,children:`Download a copy of all your data including projects, estimates, reports, and settings.`}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,L.jsxs)(`select`,{className:`w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,value:e,onChange:e=>t(e.target.value),disabled:u.isPending,children:[(0,L.jsx)(`option`,{value:`json`,children:`JSON`}),(0,L.jsx)(`option`,{value:`csv`,children:`CSV`})]}),(0,L.jsx)(`button`,{className:`rounded-lg bg-brand-600 py-2 px-4 text-sm font-semibold text-white hover:bg-brand-700 disabled:opacity-50`,onClick:()=>u.mutate(),disabled:u.isPending,children:u.isPending?`Requesting…`:`Export Data`})]}),n&&(0,L.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-50 border border-surface-200 p-3 text-sm text-surface-600`,children:[(0,L.jsx)(_l,{className:`h-4 w-4 inline mr-1.5 text-surface-400`}),n]})]})]})}),(0,L.jsx)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 p-6`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,L.jsx)(`div`,{className:`rounded-lg bg-red-100 p-3 text-red-700`,children:(0,L.jsx)(uu,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`h4`,{className:`font-medium text-red-900`,children:`Delete Your Account`}),(0,L.jsx)(`p`,{className:`text-sm text-red-700 mt-1`,children:`This permanently deletes your account and all associated data. This action cannot be undone. If you own a company, you must transfer ownership first.`}),(0,L.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,L.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked),disabled:d.isPending,className:`mt-0.5 h-4 w-4 rounded border-red-300 text-red-600 focus:ring-red-500`}),(0,L.jsx)(`span`,{className:`text-sm text-red-800`,children:`I understand this action is irreversible and will delete all my data permanently.`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`text-sm text-red-800 block mb-1`,children:[`Type `,(0,L.jsx)(`span`,{className:`font-mono font-bold`,children:`"delete my account"`}),` to confirm`]}),(0,L.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),disabled:d.isPending||!i,placeholder:`Type "delete my account"`,className:`w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100 border-red-300 focus:border-red-500 focus:ring-red-100`})]}),(0,L.jsx)(`button`,{className:`rounded-lg bg-red-600 py-2 px-4 text-sm font-semibold text-white hover:bg-red-700 disabled:opacity-50`,onClick:()=>d.mutate(),disabled:d.isPending||!f,children:d.isPending?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Su,{className:`h-4 w-4 animate-spin`}),`Processing…`]}):(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Su,{className:`h-4 w-4`}),`Delete My Account`]})})]}),c&&(0,L.jsxs)(`div`,{className:`mt-3 rounded-lg bg-red-100 border border-red-200 p-3 text-sm text-red-800`,children:[(0,L.jsx)(uu,{className:`h-4 w-4 inline mr-1.5`}),c]})]})]})})]})}var m4={get2faStatus:async()=>{let{data:e}=await H.get(`/api/security/2fa/status`);return e},setup2fa:async()=>{let{data:e}=await H.post(`/api/security/2fa/setup`);return e},enable2fa:async(e,t)=>{let{data:n}=await H.post(`/api/security/2fa/enable`,{code:e,secret:t});return n},disable2fa:async e=>{let{data:t}=await H.post(`/api/security/2fa/disable`,{currentPassword:e});return t},listApiKeys:async()=>{let{data:e}=await H.get(`/api/security/api-keys`);return e.data},createApiKey:async e=>{let{data:t}=await H.post(`/api/security/api-keys`,e);return t.data},updateApiKey:async(e,t)=>{let{data:n}=await H.put(`/api/security/api-keys/${e}`,{name:t});return n.data},revokeApiKey:async e=>{let{data:t}=await H.delete(`/api/security/api-keys/${e}`);return t},getConnectedAccounts:async()=>{let{data:e}=await H.get(`/api/security/connected-accounts`);return e.data},disconnectAccount:async e=>{let{data:t}=await H.post(`/api/security/connected-accounts/${e}/disconnect`);return t},getSessions:async()=>{let{data:e}=await H.get(`/api/security/sessions`);return e},revokeSession:async e=>{let{data:t}=await H.post(`/api/security/sessions/${e}/revoke`);return t},revokeOtherSessions:async()=>{let{data:e}=await H.post(`/api/security/sessions/revoke-other`);return e},getLoginHistory:async()=>{let{data:e}=await H.get(`/api/security/login-history`);return e}};function h4(){let e=ci(),[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(`disabled`),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(``),[p,m]=(0,S.useState)(null),{data:h,isLoading:g}=R({queryKey:[`2fa-status`],queryFn:m4.get2faStatus}),_=z({mutationFn:m4.setup2fa,onSuccess:e=>{n(e.secret),i(e.qr_url),o(e.user_email),c(`setup`)},onError:e=>{m(e.response?.data?.error||`Failed to setup 2FA`)}}),v=z({mutationFn:({code:e,secret:t})=>m4.enable2fa(e,t),onSuccess:()=>{c(`enabled`),u(``),n(null),i(null),m(null),e.invalidateQueries({queryKey:[`2fa-status`]})},onError:e=>{m(e.response?.data?.error||`Invalid verification code. Please try again.`)}}),y=z({mutationFn:e=>m4.disable2fa(e),onSuccess:()=>{c(`disabled`),f(``),m(null),e.invalidateQueries({queryKey:[`2fa-status`]})},onError:e=>{m(e.response?.data?.error||`Failed to disable 2FA. Check your password.`)}}),b=h?.enabled??!1,x=(0,S.useCallback)(()=>{m(null),_.mutate()},[_]),C=(0,S.useCallback)(()=>{m(null),t&&v.mutate({code:l,secret:t})},[l,t,v]),w=(0,S.useCallback)(()=>{m(null),d&&y.mutate(d)},[d,y]),T=(0,S.useCallback)(()=>{c(`disabled`),n(null),i(null),o(null),u(``),m(null)},[]),E=`w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm`;return g?(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,L.jsx)(fu,{className:`h-5 w-5 text-gray-400`}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:`Two-Factor Authentication`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-400`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Loading...`})]})]}):(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(fu,{className:`h-5 w-5 text-gray-600`}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:`Two-Factor Authentication`})]}),b&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800`,children:[(0,L.jsx)(yc,{className:`h-3.5 w-3.5`}),`Enabled`]})]}),(0,L.jsx)(`p`,{className:`text-sm text-gray-500 mb-4`,children:`Add an extra layer of security to your account with time-based one-time passwords (TOTP).`}),p&&(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 px-3 py-2 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700`,children:[(0,L.jsx)(Sc,{className:`h-4 w-4 flex-shrink-0`}),(0,L.jsx)(`span`,{children:p})]}),!b&&s===`disabled`&&(0,L.jsx)(`div`,{children:(0,L.jsxs)(`button`,{onClick:x,disabled:_.isPending,className:`inline-flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white text-sm font-medium rounded-lg transition-colors`,children:[_.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(tu,{className:`h-4 w-4`}),`Enable 2FA`]})}),s===`setup`&&r&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`div`,{className:`bg-blue-50 border border-blue-200 rounded-lg p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(jc,{className:`h-5 w-5 text-blue-600 flex-shrink-0 mt-0.5`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-blue-900`,children:`Scan the QR code below`}),(0,L.jsx)(`p`,{className:`text-xs text-blue-700 mt-1`,children:`Open your authenticator app (Google Authenticator, Authy, etc.) and scan the QR code, or enter the code manually.`})]})]})}),(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,L.jsx)(`div`,{className:`bg-white p-4 rounded-lg border border-gray-200`,children:(0,L.jsx)(`img`,{src:r,alt:`2FA QR Code`,className:`h-48 w-48 object-contain`})}),(0,L.jsxs)(`div`,{className:`w-full max-w-sm`,children:[(0,L.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 mb-1`,children:`Manual entry code`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`input`,{type:`text`,readOnly:!0,value:t||``,className:`${E} font-mono text-center bg-gray-50`}),(0,L.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(t||``)},className:`px-3 py-2 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors flex-shrink-0`,title:`Copy to clipboard`,children:(0,L.jsx)(El,{className:`h-4 w-4`})})]}),a&&(0,L.jsxs)(`p`,{className:`text-xs text-gray-400 mt-1`,children:[`Account: `,a]})]})]}),(0,L.jsx)(`button`,{onClick:()=>c(`verify`),className:`w-full sm:w-auto inline-flex items-center justify-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg transition-colors`,children:`I've scanned the QR code`}),(0,L.jsx)(`button`,{onClick:T,className:`w-full sm:w-auto inline-flex items-center justify-center px-4 py-2 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors`,children:`Cancel`})]}),s===`verify`&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`bg-blue-50 border border-blue-200 rounded-lg p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-blue-900`,children:`Enter your verification code`}),(0,L.jsx)(`p`,{className:`text-xs text-blue-700 mt-1`,children:`Enter the 6-digit code from your authenticator app to confirm setup.`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`input`,{type:`text`,placeholder:`6-digit code`,value:l,onChange:e=>u(e.target.value.replace(/\D/g,``).slice(0,6)),onKeyDown:e=>{e.key===`Enter`&&l.length===6&&C()},className:`${E} font-mono text-center text-lg tracking-widest w-40`,maxLength:6,autoFocus:!0}),(0,L.jsxs)(`button`,{onClick:C,disabled:v.isPending||l.length!==6,className:`inline-flex items-center gap-2 px-4 py-2 bg-green-600 hover:bg-green-700 disabled:opacity-50 text-white text-sm font-medium rounded-lg transition-colors`,children:[v.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(fu,{className:`h-4 w-4`}),`Verify & Enable`]})]}),(0,L.jsx)(`button`,{onClick:T,className:`inline-flex items-center px-4 py-2 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors`,children:`Cancel`})]}),b&&s===`disabled`&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-green-700 bg-green-50 border border-green-200 rounded-lg p-3`,children:[(0,L.jsx)(yc,{className:`h-5 w-5 flex-shrink-0`}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Two-factor authentication is enabled. Your account is more secure.`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`disable-2fa-password`,className:`block text-sm font-medium text-gray-700 mb-1`,children:`Enter your password to disable 2FA`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`input`,{id:`disable-2fa-password`,type:`password`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&w()},placeholder:`Current password`,className:E}),(0,L.jsxs)(`button`,{onClick:w,disabled:y.isPending||!d,className:`inline-flex items-center gap-2 px-4 py-2 bg-red-600 hover:bg-red-700 disabled:opacity-50 text-white text-sm font-medium rounded-lg transition-colors`,children:[y.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(Sc,{className:`h-4 w-4`}),`Disable`]})]})]})]})]})}function g4(e){return e?new Date(e).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`}):`Never`}function _4({isOpen:e,onClose:t}){let[n,r]=(0,S.useState)(``),[i,a]=(0,S.useState)({read:!0,write:!1,admin:!1}),o=ci(),s=z({mutationFn:e=>m4.createApiKey(e),onSuccess:e=>{t(),r(``),a({read:!0,write:!1,admin:!1}),o.invalidateQueries({queryKey:[`api-keys`]}),window.dispatchEvent(new CustomEvent(`new-api-key`,{detail:e}))},onError:()=>{}}),c=e=>{e.preventDefault(),n.trim()&&s.mutate({name:n.trim(),permissions:i})},l=e=>{a(t=>({...t,[e]:!t[e]}))};return e?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 w-full max-w-md mx-4 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200`,children:[(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:`Create API Key`}),(0,L.jsx)(`button`,{onClick:t,className:`p-1 text-gray-400 hover:text-gray-600 rounded-lg hover:bg-gray-100`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:c,className:`p-4 space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{htmlFor:`api-key-name`,className:`block text-sm font-medium text-gray-700 mb-1`,children:`Key Name`}),(0,L.jsx)(`input`,{id:`api-key-name`,type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Production, Development, CI/CD`,className:`w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm`,autoFocus:!0})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 mb-2`,children:`Permissions`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:[{key:`read`,label:`Read`,desc:`View data and resources`},{key:`write`,label:`Write`,desc:`Create and update data`},{key:`admin`,label:`Admin`,desc:`Full administrative access`}].map(({key:e,label:t,desc:n})=>(0,L.jsxs)(`label`,{className:`flex items-start gap-3 p-2 rounded-lg hover:bg-gray-50 cursor-pointer`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:!!i[e],onChange:()=>l(e),className:`mt-0.5 h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-700`,children:t}),(0,L.jsx)(`span`,{className:`text-xs text-gray-500 block`,children:n})]})]},e))})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 pt-2`,children:[(0,L.jsxs)(`button`,{type:`submit`,disabled:s.isPending||!n.trim(),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white text-sm font-medium rounded-lg transition-colors`,children:[s.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(eu,{className:`h-4 w-4`}),`Create API Key`]}),(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-2 text-sm text-gray-600 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors`,children:`Cancel`})]})]})]})}):null}function v4({key:e,onClose:t}){let[n,r]=(0,S.useState)(!1),i=(0,S.useCallback)(async()=>{if(e.key)try{await navigator.clipboard.writeText(e.key),r(!0),setTimeout(()=>r(!1),2e3)}catch{let t=document.createElement(`textarea`);t.value=e.key,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),r(!0),setTimeout(()=>r(!1),2e3)}},[e.key]);return(0,L.jsx)(`div`,{className:`mb-4 bg-amber-50 border border-amber-200 rounded-lg p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-amber-900`,children:`Copy your API key now — you won't be able to see it again!`}),(0,L.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,L.jsx)(`code`,{className:`flex-1 px-3 py-1.5 bg-amber-100 rounded text-sm font-mono break-all`,children:e.key}),(0,L.jsxs)(`button`,{onClick:i,className:`flex items-center gap-1 px-3 py-1.5 rounded text-sm font-medium transition-colors flex-shrink-0 ${n?`bg-green-100 text-green-700`:`bg-amber-100 hover:bg-amber-200 text-amber-700`}`,children:[n?(0,L.jsx)(Xc,{className:`h-4 w-4`}):(0,L.jsx)(sl,{className:`h-4 w-4`}),n?`Copied!`:`Copy`]})]})]}),(0,L.jsx)(`button`,{onClick:t,className:`p-1 text-amber-400 hover:text-amber-600`,children:(0,L.jsx)(Iu,{className:`h-4 w-4`})})]})})}function y4(){let[e,t]=(0,S.useState)(!1),[n,r]=(0,S.useState)(null),{data:i=[],isLoading:a,refetch:o}=R({queryKey:[`api-keys`],queryFn:m4.listApiKeys});(0,S.useState)(()=>{let e=e=>{let t=e.detail;t?.key&&r(t)};return window.addEventListener(`new-api-key`,e),()=>window.removeEventListener(`new-api-key`,e)});let s=z({mutationFn:e=>m4.revokeApiKey(e),onSuccess:()=>{o()}});return(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(Dl,{className:`h-5 w-5 text-gray-600`}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:`API Keys`})]}),(0,L.jsxs)(`button`,{onClick:()=>t(!0),className:`inline-flex items-center gap-2 px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg transition-colors`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Create API Key`]})]}),(0,L.jsx)(`p`,{className:`text-sm text-gray-500 mb-4`,children:`API keys allow you to authenticate programmatic access to Command Sovereignty.`}),n&&(0,L.jsx)(v4,{onClose:()=>r(null)},n),a&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-400 py-8 justify-center`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Loading API keys...`})]}),!a&&i.length===0&&!n&&(0,L.jsxs)(`div`,{className:`text-center py-8 text-gray-400`,children:[(0,L.jsx)(Dl,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No API keys created yet`})]}),!a&&i.length>0&&(0,L.jsx)(`div`,{className:`space-y-3`,children:i.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between p-3 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors`,children:[(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-900`,children:e.name}),(0,L.jsx)(`code`,{className:`text-xs font-mono text-gray-500 bg-gray-100 px-1.5 py-0.5 rounded`,children:e.masked_key})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 text-xs text-gray-400`,children:[(0,L.jsxs)(`span`,{children:[`Created `,g4(e.created_at)]}),(0,L.jsxs)(`span`,{children:[`Last used `,g4(e.last_used_at)]}),e.expires_at&&(0,L.jsxs)(`span`,{children:[`Expires `,g4(e.expires_at)]})]})]}),(0,L.jsx)(`button`,{onClick:()=>s.mutate(e.id),disabled:s.isPending,className:`inline-flex items-center gap-1 ml-3 px-2.5 py-1.5 text-sm text-red-600 hover:text-red-700 hover:bg-red-50 rounded-lg transition-colors flex-shrink-0`,title:`Revoke API key`,children:s.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(Su,{className:`h-4 w-4`})})]},e.id))}),(0,L.jsx)(_4,{isOpen:e,onClose:()=>t(!1)})]})}var b4={servicetitan:`ServiceTitan`,hubspot:`HubSpot`,google_ads:`Google Ads`,facebook_ads:`Facebook Ads`,quickbooks:`QuickBooks`,stripe:`Stripe`,slack:`Slack`,xero:`Xero`},x4={connected:{color:`text-green-700`,bg:`bg-green-100`,label:`Connected`,icon:bc},syncing:{color:`text-blue-700`,bg:`bg-blue-100`,label:`Syncing`,icon:K},error:{color:`text-red-700`,bg:`bg-red-100`,label:`Error`,icon:vc},inactive:{color:`text-gray-700`,bg:`bg-gray-100`,label:`Inactive`,icon:Iu}};function S4(e){return e?new Date(e).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`}):`N/A`}function C4(){let[e,t]=(0,S.useState)(null),{data:n=[],isLoading:r}=R({queryKey:[`connected-accounts`],queryFn:m4.getConnectedAccounts}),i=ci(),a=z({mutationFn:e=>m4.disconnectAccount(e),onSuccess:()=>{t(null),i.invalidateQueries({queryKey:[`connected-accounts`]})},onError:()=>{t(null)}}),o=(0,S.useCallback)(e=>{t(e),a.mutate(e)},[a]);return(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,L.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)($l,{className:`h-5 w-5 text-gray-600`}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:`Connected Accounts`})]})}),(0,L.jsx)(`p`,{className:`text-sm text-gray-500 mb-4`,children:`Manage your connected third-party services and integrations.`}),r&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-400 py-8 justify-center`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Loading connected accounts...`})]}),!r&&n.length===0&&(0,L.jsxs)(`div`,{className:`text-center py-8 text-gray-400`,children:[(0,L.jsx)($l,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No connected accounts`})]}),!r&&n.length>0&&(0,L.jsx)(`div`,{className:`space-y-3`,children:n.map(t=>{let n=x4[t.status]||x4.inactive,r=n.icon,i=b4[t.service]||t.display_name||t.service;return(0,L.jsxs)(`div`,{className:`flex items-center justify-between p-3 border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`text-2xl w-10 h-10 flex items-center justify-center bg-gray-50 rounded-lg`,children:t.icon||`🔌`}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-900`,children:i}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${n.bg} ${n.color}`,children:[(0,L.jsx)(r,{className:`h-3 w-3 ${t.status===`syncing`?`animate-spin`:``}`}),n.label]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 mt-0.5 text-xs text-gray-400`,children:[(0,L.jsxs)(`span`,{children:[`Connected `,S4(t.connected_at)]}),t.last_sync&&(0,L.jsxs)(`span`,{children:[`Last sync `,S4(t.last_sync)]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 ml-3 flex-shrink-0`,children:[t.providerUrl&&(0,L.jsx)(`a`,{href:t.providerUrl,target:`_blank`,rel:`noopener noreferrer`,className:`p-1.5 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors`,title:`Open provider`,children:(0,L.jsx)(pl,{className:`h-4 w-4`})}),t.status!==`inactive`&&(0,L.jsxs)(`button`,{onClick:()=>o(t.service),disabled:a.isPending,className:`inline-flex items-center gap-1 px-2.5 py-1.5 text-sm text-red-600 hover:text-red-700 hover:bg-red-50 rounded-lg transition-colors`,title:`Disconnect`,children:[a.isPending&&e===t.service?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(Iu,{className:`h-4 w-4`}),`Disconnect`]})]})]},t.service)})})]})}function w4(){let e=ci(),{data:t,isLoading:n}=R({queryKey:[`security-sessions`],queryFn:m4.getSessions,refetchOnWindowFocus:!1}),r=z({mutationFn:e=>m4.revokeSession(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`security-sessions`]})}}),i=z({mutationFn:()=>m4.revokeOtherSessions(),onSuccess:()=>{e.invalidateQueries({queryKey:[`security-sessions`]})}});if(n)return(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,L.jsx)(Vl,{className:`h-5 w-5 text-gray-400`}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:`Active Sessions`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-400`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Loading sessions...`})]})]});let a=t?.data||[],o=a.filter(e=>!e.is_current).length,s=e=>{let t=e.toLowerCase();return/mobile|android|iphone|ipad/.test(t)?(0,L.jsx)(hu,{className:`h-4 w-4 text-gray-500`}):/tablet/.test(t)?(0,L.jsx)(_u,{className:`h-4 w-4 text-gray-500`}):(0,L.jsx)(Vl,{className:`h-4 w-4 text-gray-500`})},c=e=>{let t=new Date,n=new Date(e),r=Math.floor((t.getTime()-n.getTime())/1e3);return r<60?`just now`:r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:`${Math.floor(r/86400)}d ago`};return(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(Vl,{className:`h-5 w-5 text-gray-600`}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:`Active Sessions`})]}),o>0&&(0,L.jsxs)(`button`,{onClick:()=>i.mutate(),disabled:i.isPending,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-red-700 bg-red-50 hover:bg-red-100 rounded-lg transition-colors disabled:opacity-50`,children:[i.isPending?(0,L.jsx)(K,{className:`h-3.5 w-3.5 animate-spin`}):(0,L.jsx)(uu,{className:`h-3.5 w-3.5`}),`Sign out other sessions (`,o,`)`]})]}),(0,L.jsx)(`p`,{className:`text-sm text-gray-500 mb-4`,children:`Manage your active sessions across devices.`}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[a.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border ${e.is_current?`border-blue-200 bg-blue-50`:`border-gray-200 bg-white`}`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[s(e.user_agent||``),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-gray-900 truncate`,children:e.device_info||`Unknown device`}),e.is_current&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-700 flex-shrink-0`,children:[(0,L.jsx)(nl,{className:`h-2.5 w-2.5`}),`Current`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500 mt-0.5`,children:[(0,L.jsx)(`span`,{children:e.ip_address}),e.last_seen&&(0,L.jsxs)(`span`,{children:[`· `,c(e.last_seen)]})]})]})]}),!e.is_current&&(0,L.jsx)(`button`,{onClick:()=>r.mutate(e.session_id),disabled:r.isPending,className:`ml-2 p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-md transition-colors flex-shrink-0`,title:`Revoke session`,children:r.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(Sc,{className:`h-4 w-4`})})]},e.id)),a.length===0&&(0,L.jsxs)(`div`,{className:`text-center py-8 text-gray-400`,children:[(0,L.jsx)(Vl,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No active sessions tracked yet.`}),(0,L.jsx)(`p`,{className:`text-xs mt-1`,children:`Sessions will appear here after your next login.`})]})]})]})}function T4(){let{data:e,isLoading:t}=R({queryKey:[`security-login-history`],queryFn:()=>m4.getLoginHistory(),refetchOnWindowFocus:!1}),n=e?.data||[],r=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),i=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`});return t?(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,L.jsx)(Cl,{className:`h-5 w-5 text-gray-400`}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:`Login History`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-400`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm`,children:`Loading login history...`})]})]}):(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-gray-200 p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(Cl,{className:`h-5 w-5 text-gray-600`}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900`,children:`Login History`})]}),n.length>0&&(0,L.jsxs)(`span`,{className:`text-xs text-gray-500 bg-gray-100 px-2 py-1 rounded-full`,children:[n.length,` entries`]})]}),(0,L.jsx)(`p`,{className:`text-sm text-gray-500 mb-4`,children:`Recent login activity on your account.`}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[n.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-lg border border-gray-200 bg-white hover:bg-gray-50 transition-colors`,children:[(0,L.jsx)(`div`,{className:`flex-shrink-0`,children:(0,L.jsx)(Vl,{className:`h-4 w-4 text-gray-400`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium text-gray-900 truncate`,children:e.device_info||`Unknown device`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500 mt-0.5`,children:[(0,L.jsx)(`span`,{children:e.ip_address}),e.location&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{children:`·`}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(Il,{className:`h-3 w-3`}),e.location]})]})]})]}),e.created_at&&(0,L.jsxs)(`div`,{className:`flex-shrink-0 text-right`,children:[(0,L.jsx)(`div`,{className:`text-xs text-gray-600`,children:r(e.created_at)}),(0,L.jsx)(`div`,{className:`text-xs text-gray-400`,children:i(e.created_at)})]})]},e.id)),n.length===0&&(0,L.jsxs)(`div`,{className:`text-center py-8 text-gray-400`,children:[(0,L.jsx)(Cl,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No login history recorded.`}),(0,L.jsx)(`p`,{className:`text-xs mt-1`,children:`Login events will appear here automatically.`})]})]})]})}function E4(e){return(0,S.useMemo)(()=>{if(!e)return{score:0,label:``,color:``};let t=0,n={length:e.length>=8,long:e.length>=12,veryLong:e.length>=16,hasUpper:/[A-Z]/.test(e),hasLower:/[a-z]/.test(e),hasNumber:/[0-9]/.test(e),hasSpecial:/[^A-Za-z0-9]/.test(e),mixedCase:/[A-Z]/.test(e)&&/[a-z]/.test(e)};return n.length&&(t+=1),n.long&&(t+=1),n.veryLong&&(t+=1),n.hasUpper&&(t+=.5),n.hasLower&&(t+=.5),n.hasNumber&&(t+=1),n.hasSpecial&&(t+=1),n.mixedCase&&(t+=.5),t=Math.min(5,t),{score:t,...[{label:``,color:``},{label:`Very weak`,color:`bg-red-500`},{label:`Weak`,color:`bg-orange-500`},{label:`Fair`,color:`bg-yellow-500`},{label:`Good`,color:`bg-blue-500`},{label:`Strong`,color:`bg-green-500`}][Math.floor(t)],checks:n}},[e])}function D4({password:e}){let{score:t,label:n,color:r,checks:i}=E4(e);return t===0?null:(0,L.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`flex gap-1 flex-1`,children:Array.from({length:5},(e,n)=>(0,L.jsx)(`div`,{className:`h-1.5 flex-1 rounded-full transition-all duration-300 ${n<Math.floor(t)?r:`bg-gray-200`}`},n))}),(0,L.jsx)(`span`,{className:`text-xs font-medium ${t<=1?`text-red-600`:t<=2?`text-orange-600`:t<=3?`text-yellow-600`:t<=4?`text-blue-600`:`text-green-600`}`,children:n})]}),e&&(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-1 text-xs text-gray-500`,children:[(0,L.jsx)(O4,{met:i.length,label:`8+ characters`}),(0,L.jsx)(O4,{met:i.long,label:`12+ characters`}),(0,L.jsx)(O4,{met:i.hasUpper,label:`Uppercase`}),(0,L.jsx)(O4,{met:i.hasLower,label:`Lowercase`}),(0,L.jsx)(O4,{met:i.hasNumber,label:`Number`}),(0,L.jsx)(O4,{met:i.hasSpecial,label:`Special char`})]})]})}function O4({met:e,label:t}){return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 ${e?`text-green-600`:`text-gray-400`}`,children:[(0,L.jsx)(e?du:uu,{className:`h-3 w-3`}),(0,L.jsx)(`span`,{children:t})]})}var k4=[`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`America/Anchorage`,`Pacific/Honolulu`,`America/Phoenix`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`Europe/Moscow`,`Asia/Tokyo`,`Asia/Shanghai`,`Asia/Kolkata`,`Australia/Sydney`,`Pacific/Auckland`,`UTC`],A4=[`MM/DD/YYYY`,`DD/MM/YYYY`,`YYYY-MM-DD`],j4=[`single`,`multi`,`enterprise`],M4=[`Roofing`,`HVAC`,`Plumbing`,`Electrical`,`Landscaping`,`Construction`,`Solar`,`Windows & Doors`,`Siding`,`Painting`,`Flooring`,`Remodeling`,`Other`],N4=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`],P4=[`en-US`,`en-GB`,`es-ES`,`fr-FR`,`de-DE`,`ja-JP`],F4=[`USD`,`EUR`,`GBP`,`JPY`,`CAD`,`AUD`],I4={notifications_email:!0,notifications_org:!0,notifications_commission:!0,notifications_security:!0},L4={timezone:`America/New_York`,locale:`en-US`,currency:`USD`,fiscal_year_start:`january`,date_format:`MM/DD/YYYY`},R4={timezone:`America/New_York`,locale:`en-US`,date_format:`MM/DD/YYYY`,week_start:`sunday`};function z4(){let e=ft(),{user:t,updateProfile:n,changePassword:r}=W(),i=ci(),[a,o]=(0,S.useState)(`profile`),[s]=Bn(),c=s.get(`tab`);(0,S.useEffect)(()=>{c&&[`profile`,`security`,`notifications`,`company`,`appearance`].includes(c)&&o(c)},[c]),(0,S.useCallback)(()=>{window.confirm(`Restart the onboarding tour? You will be taken back to the home screen.`)&&(localStorage.removeItem(`cs_onboarding_complete`),sessionStorage.setItem(`cs_tour_pending`,`true`),e(`/app`,{replace:!0}))},[e]);let[l,u]=(0,S.useState)(t?.full_name||``),[d,f]=(0,S.useState)(!1),[p,m]=(0,S.useState)(null);(0,S.useEffect)(()=>{u(t?.full_name||``)},[t?.full_name]);let[h,g]=(0,S.useState)(``),[_,v]=(0,S.useState)(``),[y,b]=(0,S.useState)(!1),[x,C]=(0,S.useState)(null),[w,T]=(0,S.useState)(I4),[E,D]=(0,S.useState)(!1),[O,k]=(0,S.useState)(null),[A,j]=(0,S.useState)({}),[M,N]=(0,S.useState)(!1),[ee,te]=(0,S.useState)(null),[P,F]=(0,S.useState)(L4),[ne,re]=(0,S.useState)(!1),[ie,ae]=(0,S.useState)(null),[oe,se]=(0,S.useState)(R4),[ce,le]=(0,S.useState)(!1),[ue,de]=(0,S.useState)(null),{data:fe}=R({queryKey:[`user-settings`],queryFn:I2.getUserSettings,enabled:a===`notifications`||a===`appearance`,staleTime:0,refetchOnWindowFocus:!1}),{data:pe}=R({queryKey:[`company`],queryFn:I2.getCompany,enabled:a===`company`,staleTime:0,refetchOnWindowFocus:!1}),{data:me}=R({queryKey:[`company-settings`],queryFn:I2.getCompanySettings,enabled:a===`company`,staleTime:0,refetchOnWindowFocus:!1}),he=z({mutationFn:e=>I2.updateUserSettings(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`user-settings`]})}}),ge=L2(),_e=z({mutationFn:e=>I2.updateCompanySettings(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`company-settings`]})}});(0,S.useEffect)(()=>{a===`notifications`&&fe&&(T({notifications_email:fe.notifications_email??I4.notifications_email,notifications_org:fe.notifications_org??I4.notifications_org,notifications_commission:fe.notifications_commission??I4.notifications_commission,notifications_security:fe.notifications_security??I4.notifications_security}),D(!1),k(null))},[a,fe]),(0,S.useEffect)(()=>{a===`appearance`&&fe&&(se({timezone:fe.timezone??R4.timezone,locale:fe.locale??R4.locale,date_format:fe.date_format??R4.date_format,week_start:fe.week_start??R4.week_start}),le(!1),de(null))},[a,fe]),(0,S.useEffect)(()=>{if(a===`company`&&pe&&me){j(pe),N(!1),te(null);let e={};for(let t of Object.keys(L4)){let n=me[t];e[t]=typeof n==`string`?n:L4[t]}F(e),re(!1),ae(null)}},[a,pe,me]);let ve=async()=>{f(!0),m(null);try{await n(l),m(`success`),setTimeout(()=>m(null),3e3)}catch{m(`error`)}finally{f(!1)}},ye=async()=>{b(!0),C(null);try{if(!h){C({type:`error`,text:`Current password is required`}),b(!1);return}if(!_){C({type:`error`,text:`New password is required`}),b(!1);return}if(_.length<8){C({type:`error`,text:`New password must be at least 8 characters`}),b(!1);return}let e=await r(h,_);e.success&&(C({type:`success`,text:e.message||`Password updated successfully`}),g(``),v(``),setTimeout(()=>C(null),4e3))}catch(e){C({type:`error`,text:e?.response?.data?.error||`Failed to change password`}),g(``),v(``)}finally{b(!1)}},be=async()=>{k(null);try{await he.mutateAsync(w),k(`success`),D(!1),setTimeout(()=>k(null),3e3)}catch{k(`error`)}},xe=async()=>{te(null);try{if(!A.name||!A.name.trim()){te({type:`error`,text:`Company name is required`});return}if(!A.industry){te({type:`error`,text:`Industry is required`});return}await ge.mutateAsync(A),te({type:`success`}),N(!1),setTimeout(()=>te(null),3e3)}catch{te({type:`error`,text:`Failed to save`})}},Se=async()=>{ae(null);try{await _e.mutateAsync(P),ae(`success`),re(!1),setTimeout(()=>ae(null),3e3)}catch{ae(`error`)}},Ce=async()=>{de(null);try{await he.mutateAsync(oe),de(`success`),le(!1),setTimeout(()=>de(null),3e3)}catch{de(`error`)}},we=e=>{T(t=>({...t,[e]:!t[e]})),D(!0)},Te=(e,t)=>{j(n=>({...n,[e]:t})),N(!0)},Ee=(e,t)=>{F(n=>({...n,[e]:t})),re(!0)},De=(e,t)=>{se(n=>({...n,[e]:t})),le(!0)},Oe=[{id:`profile`,label:`Profile`,icon:Nu},{id:`security`,label:`Security`,icon:Nl},{id:`notifications`,label:`Notifications`,icon:Uc},{id:`company`,label:`Company`,icon:Kc},{id:`billing`,label:`Billing`,icon:cl},{id:`team`,label:`Team`,icon:Pu},{id:`integrations`,label:`Integrations`,icon:$l},{id:`data`,label:`Data`,icon:ul},{id:`appearance`,label:`Appearance`,icon:Wl}],ke=`w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,Ae=`w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100 bg-white`,je=`rounded-lg bg-brand-600 py-2 px-4 text-sm font-semibold text-white hover:bg-brand-700 disabled:opacity-50`;return(0,L.jsxs)($,{title:`Settings`,children:[(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Settings`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Manage your account preferences`})]}),(0,L.jsx)(`div`,{className:`mb-6 flex gap-1 rounded-lg bg-surface-100 p-1 overflow-x-auto`,children:Oe.map(e=>(0,L.jsxs)(`button`,{onClick:()=>o(e.id),className:`flex items-center gap-2 rounded-md px-4 py-2 text-sm font-medium transition-colors whitespace-nowrap ${a===e.id?`bg-white text-surface-900 shadow-sm`:`text-surface-600 hover:text-surface-900`}`,children:[(0,L.jsx)(e.icon,{className:`h-4 w-4`}),e.label]},e.id))}),a===`profile`&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-surface-700`,children:`Profile Information`}),(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Full Name`}),(0,L.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),className:ke})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Email`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Fl,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400`}),(0,L.jsx)(`input`,{type:`email`,defaultValue:t?.email||``,disabled:!0,className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2 pl-10 pr-3 text-sm text-surface-500`})]})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:ve,disabled:d||l.trim()===(t?.full_name||``),className:je,children:d?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Saving...`]}):`Save Changes`}),p===`success`&&(0,L.jsx)(`span`,{className:`text-sm text-green-600`,children:`Saved successfully`}),p===`error`&&(0,L.jsx)(`span`,{className:`text-sm text-red-600`,children:`Failed to save`})]})]}),a===`security`&&(0,L.jsxs)(`div`,{"data-testid":`security-content`,className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-surface-700`,children:`Password`}),(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Current Password`}),(0,L.jsx)(`input`,{type:`password`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ye()},className:ke})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`New Password`}),(0,L.jsx)(`input`,{type:`password`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ye()},className:ke}),(0,L.jsx)(D4,{password:_})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:ye,disabled:y||!h||!_,className:je,children:y?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Updating...`]}):`Update Password`}),x&&(0,L.jsx)(`span`,{className:`text-sm ${x.type===`success`?`text-green-600`:`text-red-600`}`,children:x.text})]})]}),(0,L.jsx)(w4,{}),(0,L.jsx)(T4,{}),(0,L.jsx)(h4,{}),(0,L.jsx)(y4,{}),(0,L.jsx)(C4,{})]}),a===`notifications`&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-surface-700`,children:`Notification Preferences`}),(0,L.jsx)(`div`,{className:`space-y-4`,children:[{key:`notifications_email`,label:`Email notifications`,desc:`Receive email updates about your account`},{key:`notifications_org`,label:`Organization updates`,desc:`Get notified about changes in your organizations`},{key:`notifications_commission`,label:`Commission alerts`,desc:`Alerts when commissions are processed`},{key:`notifications_security`,label:`Security alerts`,desc:`Important security and login notifications`}].map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:e.label}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.desc})]}),(0,L.jsxs)(`label`,{className:`relative inline-flex cursor-pointer items-center`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`peer sr-only`,checked:w[e.key],onChange:()=>we(e.key)}),(0,L.jsx)(`div`,{className:`peer h-6 w-11 rounded-full bg-surface-200 after:absolute after:left-0.5 after:top-0.5 after:h-5 after:w-5 after:rounded-full after:bg-white after:transition-colors peer-checked:bg-brand-600 peer-checked:after:translate-x-full`})]})]},e.key))}),(0,L.jsxs)(`div`,{className:`mt-6 flex items-center gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:be,disabled:he.isPending||!E,className:je,children:he.isPending?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Saving...`]}):`Save Preferences`}),O===`success`&&(0,L.jsx)(`span`,{className:`text-sm text-green-600`,children:`Saved successfully`}),O===`error`&&(0,L.jsx)(`span`,{className:`text-sm text-red-600`,children:`Failed to save`})]})]}),a===`company`&&(0,L.jsxs)(`div`,{"data-testid":`company-content`,className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`mb-4 text-sm font-semibold text-surface-700`,children:`Company Information`}),(0,L.jsx)(`p`,{className:`mb-4 text-xs text-surface-500`,children:`Fields marked with * are required`}),(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`sm:col-span-2 lg:col-span-3`,children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Company Name *`}),(0,L.jsx)(`input`,{type:`text`,value:A.name||``,onChange:e=>Te(`name`,e.target.value),className:ke})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Industry *`}),(0,L.jsxs)(`select`,{value:A.industry||``,onChange:e=>Te(`industry`,e.target.value),className:Ae,children:[(0,L.jsx)(`option`,{value:``,children:`Select industry`}),M4.map(e=>(0,L.jsx)(`option`,{value:e.toLowerCase(),children:e},e))]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Size`}),(0,L.jsxs)(`select`,{value:A.size||``,onChange:e=>Te(`size`,e.target.value),className:Ae,children:[(0,L.jsx)(`option`,{value:``,children:`Select size`}),j4.map(e=>(0,L.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Annual Revenue`}),(0,L.jsx)(`input`,{type:`number`,value:A.annual_revenue??``,onChange:e=>Te(`annual_revenue`,e.target.value?Number(e.target.value):null),className:ke,placeholder:`0`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Target Revenue`}),(0,L.jsx)(`input`,{type:`number`,value:A.target_revenue??``,onChange:e=>Te(`target_revenue`,e.target.value?Number(e.target.value):null),className:ke,placeholder:`0`})]}),(0,L.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Address`}),(0,L.jsx)(`input`,{type:`text`,value:A.address||``,onChange:e=>Te(`address`,e.target.value),className:ke})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`City`}),(0,L.jsx)(`input`,{type:`text`,value:A.city||``,onChange:e=>Te(`city`,e.target.value),className:ke})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`State`}),(0,L.jsx)(`input`,{type:`text`,value:A.state||``,onChange:e=>Te(`state`,e.target.value),className:ke})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Zip Code`}),(0,L.jsx)(`input`,{type:`text`,value:A.zip_code||``,onChange:e=>Te(`zip_code`,e.target.value),className:ke})]}),(0,L.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Website`}),(0,L.jsx)(`input`,{type:`url`,value:A.website||``,onChange:e=>Te(`website`,e.target.value),className:ke,placeholder:`https://example.com`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Account Tier`}),(0,L.jsx)(`input`,{type:`text`,value:A.tier||``,disabled:!0,className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2 px-3 text-sm text-surface-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Created`}),(0,L.jsx)(`input`,{type:`text`,value:A.created_at?new Date(A.created_at).toLocaleDateString():``,disabled:!0,className:`w-full rounded-lg border border-surface-200 bg-surface-50 py-2 px-3 text-sm text-surface-500`})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:xe,disabled:ge.isPending||!M,className:je,children:ge.isPending?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Saving...`]}):`Save Company Info`}),ee&&ee.type===`success`&&(0,L.jsx)(`span`,{className:`text-sm text-green-600`,children:`Saved successfully`}),ee&&ee.type===`error`&&(0,L.jsx)(`span`,{className:`text-sm text-red-600`,children:ee.text||`Failed to save`})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-700`,children:`Company Settings`}),(0,L.jsx)(`span`,{className:`rounded-full bg-blue-50 px-2 py-0.5 text-xs font-medium text-blue-700`,children:`Organization-wide`})]}),(0,L.jsx)(`p`,{className:`mb-4 text-xs text-surface-500`,children:`Applies to all users in this organization`}),(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Timezone`}),(0,L.jsx)(`select`,{value:P.timezone,onChange:e=>Ee(`timezone`,e.target.value),className:Ae,children:k4.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Locale`}),(0,L.jsx)(`select`,{value:P.locale,onChange:e=>Ee(`locale`,e.target.value),className:Ae,children:P4.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Currency`}),(0,L.jsx)(`select`,{value:P.currency,onChange:e=>Ee(`currency`,e.target.value),className:Ae,children:F4.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Fiscal Year Start`}),(0,L.jsx)(`select`,{value:P.fiscal_year_start,onChange:e=>Ee(`fiscal_year_start`,e.target.value),className:Ae,children:N4.map(e=>(0,L.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Date Format`}),(0,L.jsx)(`select`,{value:P.date_format,onChange:e=>Ee(`date_format`,e.target.value),className:Ae,children:A4.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:Se,disabled:_e.isPending||!ne,className:je,children:_e.isPending?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Saving...`]}):`Save Settings`}),ie===`success`&&(0,L.jsx)(`span`,{className:`text-sm text-green-600`,children:`Saved successfully`}),ie===`error`&&(0,L.jsx)(`span`,{className:`text-sm text-red-600`,children:`Failed to save`})]})]})]}),a===`billing`&&(0,L.jsx)(U2,{}),a===`team`&&(0,L.jsx)($2,{}),a===`integrations`&&(0,L.jsx)(l4,{}),a===`data`&&(0,L.jsx)(p4,{}),a===`appearance`&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-700`,children:`Appearance & Locale`}),(0,L.jsx)(`span`,{className:`rounded-full bg-green-50 px-2 py-0.5 text-xs font-medium text-green-700`,children:`Personal`})]}),(0,L.jsx)(`p`,{className:`mb-4 text-xs text-surface-500`,children:`These settings only affect your account`}),(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Timezone`}),(0,L.jsx)(`select`,{value:oe.timezone,onChange:e=>De(`timezone`,e.target.value),className:Ae,children:k4.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Date Format`}),(0,L.jsx)(`select`,{value:oe.date_format,onChange:e=>De(`date_format`,e.target.value),className:Ae,children:A4.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Week Starts On`}),(0,L.jsxs)(`select`,{value:oe.week_start,onChange:e=>De(`week_start`,e.target.value),className:Ae,children:[(0,L.jsx)(`option`,{value:`sunday`,children:`Sunday`}),(0,L.jsx)(`option`,{value:`monday`,children:`Monday`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`mb-1.5 block text-sm font-medium text-surface-700`,children:`Locale`}),(0,L.jsx)(`select`,{value:oe.locale,onChange:e=>De(`locale`,e.target.value),className:Ae,children:P4.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:Ce,disabled:he.isPending||!ce,className:je,children:he.isPending?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Saving...`]}):`Save Preferences`}),ue===`success`&&(0,L.jsx)(`span`,{className:`text-sm text-green-600`,children:`Saved successfully`}),ue===`error`&&(0,L.jsx)(`span`,{className:`text-sm text-red-600`,children:`Failed to save`})]})]})]})}function B4(){let e=ci(),[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(``),{data:l,isLoading:u}=R({queryKey:[`portfolios`],queryFn:()=>KQ.getPortfolios()}),d=l?.items??[],f=z({mutationFn:e=>KQ.createPortfolio(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`portfolios`]}),i(!1),o(``),c(``)}}),p=z({mutationFn:e=>KQ.deletePortfolio(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`portfolios`]})}}),m=d.filter(e=>e.name.toLowerCase().includes(t.toLowerCase())||e.description.toLowerCase().includes(t.toLowerCase()));return u?(0,L.jsx)($,{title:`Portfolios`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Portfolios`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Portfolios`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-surface-500`,children:[d.length,` portfolio`,d.length===1?``:`s`,` for PE-backed company groupings`]})]}),(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`Search portfolios...`,className:`w-full rounded-lg border border-surface-300 py-2.5 pl-9 pr-4 text-sm outline-none focus:border-brand-500 sm:w-64 min-h-[44px]`})]}),(0,L.jsxs)(`button`,{onClick:()=>i(!0),className:`flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`New Portfolio`]})]})]}),m.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(vl,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:t?`No portfolios match your search`:`No portfolios yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Create a portfolio to group companies together`})]}):(0,L.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:m.map(e=>(0,L.jsx)(V4,{portfolio:e,onDelete:()=>p.mutate(e.id),isDeleting:p.isPending&&p.variables===e.id},e.id))}),r&&(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-xl bg-white p-6 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-bold text-surface-900`,children:`Create Portfolio`}),(0,L.jsx)(`button`,{onClick:()=>{i(!1),o(``),c(``)},className:`rounded-lg p-1 text-surface-400 hover:bg-surface-100 hover:text-surface-600`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Name`}),(0,L.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`e.g. Northeast HVAC Group`,className:`w-full rounded-lg border border-surface-300 px-3 py-2.5 text-sm outline-none focus:border-brand-500`,autoFocus:!0})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Description`}),(0,L.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`Optional description...`,rows:3,className:`w-full rounded-lg border border-surface-300 px-3 py-2.5 text-sm outline-none focus:border-brand-500 resize-none`})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,L.jsx)(`button`,{onClick:()=>{i(!1),o(``),c(``)},className:`rounded-lg border border-surface-300 px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{onClick:()=>{a.trim()&&f.mutate({name:a.trim(),description:s.trim()})},disabled:!a.trim()||f.isPending,className:`rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:f.isPending?`Creating...`:`Create`})]})]})]})})]})}function V4({portfolio:e,onDelete:t,isDeleting:n}){return(0,L.jsxs)(`a`,{href:`/admin/portfolios/${e.id}`,className:`group relative block rounded-xl border border-surface-200 bg-white p-5 transition-all hover:border-brand-300 hover:shadow-md`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-start justify-between`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-brand-50 text-brand-600`,children:(0,L.jsx)(vl,{className:`h-5 w-5`})}),(0,L.jsx)(`button`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},className:`rounded-lg p-1.5 text-surface-400 opacity-0 transition-opacity hover:bg-red-50 hover:text-red-600 group-hover:opacity-100`,title:`Delete portfolio`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})]}),(0,L.jsx)(`h3`,{className:`font-semibold text-surface-900 group-hover:text-brand-700`,children:e.name}),e.description&&(0,L.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-surface-500`,children:e.description}),(0,L.jsxs)(`div`,{className:`mt-3 flex items-center gap-4 text-xs text-surface-500`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(Kc,{className:`h-3.5 w-3.5`}),e.company_count,` company`,e.company_count===1?``:`ies`]}),(0,L.jsx)(`span`,{children:e.created_by_name||e.created_by_email})]}),n&&(0,L.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-xl bg-white/80`,children:(0,L.jsx)(`div`,{className:`h-5 w-5 animate-spin rounded-full border-2 border-brand-600 border-t-transparent`})})]})}function H4(){let{portfolioId:e}=mt(),t=ci(),[n,r]=(0,S.useState)(``),[i,a]=(0,S.useState)(!1),[o,s]=(0,S.useState)(!1),[c,l]=(0,S.useState)(``),[u,d]=(0,S.useState)(``),{data:f,isLoading:p}=R({queryKey:[`portfolio`,e],queryFn:()=>KQ.getPortfolio(e)}),m=f?.portfolio,h=z({mutationFn:t=>KQ.updatePortfolio(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`portfolio`,e]}),t.invalidateQueries({queryKey:[`portfolios`]}),s(!1)}}),g=z({mutationFn:t=>KQ.removePortfolioCompanies(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`portfolio`,e]})}}),_=()=>{c.trim()&&h.mutate({name:c.trim(),description:u.trim()})};if(p)return(0,L.jsx)($,{title:`Portfolio`,children:(0,L.jsx)(FQ,{})});if(!m)return(0,L.jsx)($,{title:`Portfolio`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`a`,{href:`/admin/portfolios`,className:`text-brand-600 hover:text-brand-700`,children:(0,L.jsx)(Fc,{className:`h-5 w-5`})}),(0,L.jsx)(`p`,{className:`text-surface-500`,children:`Portfolio not found`})]})});let v=m.companies??[],y=v.filter(e=>e.name.toLowerCase().includes(n.toLowerCase())||e.industry.toLowerCase().includes(n.toLowerCase()));return(0,L.jsxs)($,{title:`Portfolio`,children:[(0,L.jsxs)(`a`,{href:`/admin/portfolios`,className:`mb-4 inline-flex items-center gap-1 text-sm text-brand-600 hover:text-brand-700`,children:[(0,L.jsx)(Fc,{className:`h-4 w-4`}),`Back to Portfolios`]}),(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-brand-50 text-brand-600`,children:(0,L.jsx)(vl,{className:`h-5 w-5`})}),o?(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm font-bold text-surface-900 outline-none focus:border-brand-500`,autoFocus:!0}),(0,L.jsx)(`textarea`,{value:u,onChange:e=>d(e.target.value),rows:2,className:`mt-2 w-full rounded-lg border border-surface-300 px-3 py-2 text-xs text-surface-500 outline-none focus:border-brand-500 resize-none`})]}):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:m.name}),m.description&&(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:m.description})]})]}),(0,L.jsxs)(`p`,{className:`mt-2 text-xs text-surface-400`,children:[`Created by `,m.created_by_name||m.created_by_email]})]}),(0,L.jsx)(`div`,{className:`flex gap-2`,children:o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{onClick:_,disabled:!c.trim()||h.isPending,className:`flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(Xc,{className:`h-4 w-4`}),`Save`]}),(0,L.jsxs)(`button`,{onClick:()=>{s(!1),l(m.name),d(m.description)},className:`flex items-center gap-2 rounded-lg border border-surface-300 px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:[(0,L.jsx)(Iu,{className:`h-4 w-4`}),`Cancel`]})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{onClick:()=>{s(!0),l(m.name),d(m.description)},className:`flex items-center gap-2 rounded-lg border border-surface-300 px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:[(0,L.jsx)(Oc,{className:`h-4 w-4`}),`Edit`]}),(0,L.jsxs)(`button`,{onClick:()=>a(!0),className:`flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Add Companies`]})]})})]}),(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,L.jsxs)(`h2`,{className:`text-sm font-semibold text-surface-700`,children:[`Companies (`,v.length,`)`]}),(0,L.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Search companies...`,className:`w-full rounded-lg border border-surface-300 py-2 pl-9 pr-4 text-sm outline-none focus:border-brand-500 min-h-[44px]`})]})]}),y.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-12`,children:[(0,L.jsx)(Kc,{className:`h-10 w-10 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-3 text-sm font-medium text-surface-700`,children:n?`No companies match your search`:`No companies in this portfolio`}),(0,L.jsx)(`button`,{onClick:()=>a(!0),className:`mt-3 text-sm text-brand-600 hover:text-brand-700`,children:`+ Add companies`})]}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 pl-5 text-left font-medium text-surface-500`,children:`Company`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Industry`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500`,children:`Revenue`}),(0,L.jsx)(`th`,{className:`pb-3 pr-5 w-10`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:y.map(e=>(0,L.jsxs)(`tr`,{className:`hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`py-3 pl-5`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-brand-100 text-brand-600`,children:(0,L.jsx)(Kc,{className:`h-4 w-4`})}),(0,L.jsx)(`span`,{className:`font-medium text-surface-900`,children:e.name})]})}),(0,L.jsx)(`td`,{className:`py-3 text-surface-600`,children:e.industry||`—`}),(0,L.jsx)(`td`,{className:`py-3 text-right text-surface-600`,children:e.annual_revenue?`$${e.annual_revenue.toLocaleString()}`:`—`}),(0,L.jsx)(`td`,{className:`py-3 pr-5 text-right`,children:(0,L.jsx)(`button`,{onClick:()=>g.mutate([e.id]),className:`rounded-lg p-1.5 text-surface-400 hover:bg-red-50 hover:text-red-600`,title:`Remove from portfolio`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})})]},e.id))})]})}),i&&(0,L.jsx)(U4,{portfolio:m,onClose:()=>a(!1)})]})}function U4({portfolio:e,onClose:t}){let n=ci(),[r,i]=(0,S.useState)(``),{data:a,isLoading:o}=R({queryKey:[`admin-organizations`],queryFn:()=>KQ.getOrganizations()}),s=z({mutationFn:t=>KQ.addPortfolioCompanies(e.id,t),onSuccess:()=>{n.invalidateQueries({queryKey:[`portfolio`,e.id]}),n.invalidateQueries({queryKey:[`portfolios`]}),t()}}),c=a?.items??[],l=new Set(e.companies?.map(e=>e.id)??[]),u=c.filter(e=>!l.has(String(e.id))).filter(e=>e.name.toLowerCase().includes(r.toLowerCase())),[d,f]=(0,S.useState)(new Set);return(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-lg max-h-[80vh] overflow-y-auto rounded-xl bg-white p-6 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-bold text-surface-900`,children:`Add Companies to Portfolio`}),(0,L.jsx)(`button`,{onClick:t,className:`rounded-lg p-1 text-surface-400 hover:bg-surface-100 hover:text-surface-600`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`div`,{className:`relative mb-4`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`Search companies...`,className:`w-full rounded-lg border border-surface-300 py-2.5 pl-9 pr-4 text-sm outline-none focus:border-brand-500`})]}),o?(0,L.jsx)(FQ,{}):u.length===0?(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:r?`No companies found`:`All companies are already in this portfolio`}):(0,L.jsx)(`div`,{className:`space-y-1`,children:u.map(e=>(0,L.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 rounded-lg px-3 py-2.5 text-sm transition-colors ${d.has(String(e.id))?`bg-brand-50 text-brand-700`:`hover:bg-surface-50 text-surface-700`}`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:d.has(String(e.id)),onChange:t=>{let n=new Set(d);t.target.checked?n.add(String(e.id)):n.delete(String(e.id)),f(n)},className:`h-4 w-4 rounded border-surface-300 text-brand-600 focus:ring-brand-500`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,L.jsx)(`span`,{className:`ml-2 text-xs text-surface-400`,children:e.industry})]})]},e.id))}),(0,L.jsxs)(`div`,{className:`mt-4 flex justify-end gap-3`,children:[(0,L.jsx)(`button`,{onClick:t,className:`rounded-lg border border-surface-300 px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{onClick:()=>s.mutate(Array.from(d)),disabled:d.size===0||s.isPending,className:`rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:s.isPending?`Adding...`:`Add ${d.size} Company${d.size===1?``:`ies`}`})]})]})})}var W4={draft:`bg-surface-100 text-surface-600`,scheduled:`bg-blue-100 text-blue-700`,sending:`bg-brand-100 text-brand-700`,sent:`bg-brand-100 text-brand-700`,completed:`bg-success/10 text-success`,paused:`bg-warning/10 text-warning`,failed:`bg-red-100 text-red-700`},G4={draft:null,scheduled:(0,L.jsx)(vc,{className:`mr-1 h-3 w-3`}),sending:(0,L.jsx)(su,{className:`mr-1 h-3 w-3`}),sent:(0,L.jsx)(su,{className:`mr-1 h-3 w-3`}),completed:(0,L.jsx)(bc,{className:`mr-1 h-3 w-3`}),paused:(0,L.jsx)(vc,{className:`mr-1 h-3 w-3`}),failed:(0,L.jsx)(vc,{className:`mr-1 h-3 w-3`})};function K4(){let e=ci(),[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(``),[l,u]=(0,S.useState)(``),{data:d,isLoading:f}=R({queryKey:[`email-campaigns`],queryFn:()=>KQ.getEmailCampaigns()}),p=d?.items??[],m=z({mutationFn:e=>KQ.createEmailCampaign(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`email-campaigns`]}),i(!1),o(``),c(``),u(``)}}),h=z({mutationFn:e=>KQ.deleteEmailCampaign(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`email-campaigns`]})}}),g=p.filter(e=>e.name.toLowerCase().includes(t.toLowerCase())||e.subject.toLowerCase().includes(t.toLowerCase()));return f?(0,L.jsx)($,{title:`Email Campaigns`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Email Campaigns`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Email Delivery`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-surface-500`,children:[p.length,` campaign`,p.length===1?``:`s`,` tracked`]})]}),(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`Search campaigns...`,className:`w-full rounded-lg border border-surface-300 py-2.5 pl-9 pr-4 text-sm outline-none focus:border-brand-500 sm:w-64 min-h-[44px]`})]}),(0,L.jsxs)(`button`,{onClick:()=>i(!0),className:`flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`New Campaign`]})]})]}),g.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(Fl,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:t?`No campaigns match your search`:`No email campaigns yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Create a campaign to track email delivery metrics`})]}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 pl-5 text-left font-medium text-surface-500`,children:`Campaign`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500`,children:`Sent`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500`,children:`Delivered`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500`,children:`Opened`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500`,children:`Bounced`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500`,children:`Failed`}),(0,L.jsx)(`th`,{className:`pb-3 pr-5 w-10`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:g.map(e=>(0,L.jsx)(q4,{campaign:e,onDelete:()=>h.mutate(e.id),isDeleting:h.isPending&&h.variables===e.id},e.id))})]})}),r&&(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-md rounded-xl bg-white p-6 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-bold text-surface-900`,children:`Create Email Campaign`}),(0,L.jsx)(`button`,{onClick:()=>{i(!1),o(``),c(``),u(``)},className:`rounded-lg p-1 text-surface-400 hover:bg-surface-100 hover:text-surface-600`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Name`}),(0,L.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`e.g. Q3 Newsletter`,className:`w-full rounded-lg border border-surface-300 px-3 py-2.5 text-sm outline-none focus:border-brand-500`,autoFocus:!0})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Subject`}),(0,L.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`Email subject line`,className:`w-full rounded-lg border border-surface-300 px-3 py-2.5 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Recipients (comma-separated emails)`}),(0,L.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),placeholder:`user1@example.com, user2@example.com`,rows:3,className:`w-full rounded-lg border border-surface-300 px-3 py-2.5 text-sm outline-none focus:border-brand-500 resize-none`})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-3`,children:[(0,L.jsx)(`button`,{onClick:()=>{i(!1),o(``),c(``),u(``)},className:`rounded-lg border border-surface-300 px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{onClick:()=>{if(!a.trim())return;let e=l.split(`,`).map(e=>e.trim()).filter(e=>e.includes(`@`)).map(e=>({email:e}));m.mutate({name:a.trim(),subject:s.trim(),recipients:e.length?e:void 0})},disabled:!a.trim()||m.isPending,className:`rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:m.isPending?`Creating...`:`Create`})]})]})]})})]})}function q4({campaign:e,onDelete:t,isDeleting:n}){let r=e.total_sent>0?Math.round(e.delivered/e.total_sent*100):0,i=e.delivered>0?Math.round(e.opened/e.delivered*100):0;return(0,L.jsxs)(`tr`,{className:`group hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`py-3 pl-5`,children:(0,L.jsxs)(`a`,{href:`/admin/email-campaigns/${e.id}`,className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg bg-brand-100 text-brand-600`,children:(0,L.jsx)(Fl,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`font-medium text-surface-900 truncate group-hover:text-brand-700`,children:e.name}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500 truncate`,children:e.subject||`No subject`})]})]})}),(0,L.jsx)(`td`,{className:`py-3`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${W4[e.status]||`bg-surface-200 text-surface-600`}`,children:[G4[e.status],e.status]})}),(0,L.jsx)(`td`,{className:`py-3 text-right font-medium text-surface-900`,children:e.total_sent}),(0,L.jsxs)(`td`,{className:`py-3 text-right`,children:[(0,L.jsx)(`span`,{className:`text-surface-700`,children:e.delivered}),(0,L.jsxs)(`span`,{className:`ml-1 text-xs text-surface-400`,children:[`(`,r,`%)`]})]}),(0,L.jsxs)(`td`,{className:`py-3 text-right`,children:[(0,L.jsx)(`span`,{className:`text-surface-700`,children:e.opened}),(0,L.jsxs)(`span`,{className:`ml-1 text-xs text-surface-400`,children:[`(`,i,`%)`]})]}),(0,L.jsx)(`td`,{className:`py-3 text-right text-surface-600`,children:e.bounced}),(0,L.jsx)(`td`,{className:`py-3 text-right text-red-600`,children:e.failed}),(0,L.jsx)(`td`,{className:`py-3 pr-5 text-right`,children:(0,L.jsx)(`button`,{onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},className:`rounded-lg p-1.5 text-surface-400 opacity-0 transition-opacity hover:bg-red-50 hover:text-red-600 group-hover:opacity-100`,title:`Delete campaign`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})})]})}var J4=[{value:`super_admin`,label:`Super Admin`,color:`bg-red-100 text-red-700`},{value:`admin`,label:`Admin`,color:`bg-orange-100 text-orange-700`},{value:`partner`,label:`Partner`,color:`bg-blue-100 text-blue-700`},{value:`user`,label:`User`,color:`bg-gray-100 text-gray-600`}],Y4=[{value:`owner`,label:`Owner`,color:`bg-purple-100 text-purple-700`},{value:`admin`,label:`Admin`,color:`bg-indigo-100 text-indigo-700`},{value:`manager`,label:`Manager`,color:`bg-emerald-100 text-emerald-700`},{value:`rep`,label:`Rep`,color:`bg-amber-100 text-amber-700`},{value:`viewer`,label:`Viewer`,color:`bg-slate-100 text-slate-600`}];function X4({userId:e,currentRole:t,onRoleChange:n}){let[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(null),s=S.useRef(null),c=ci(),l=z({mutationFn:({userId:e,role:t})=>KQ.updateUserRole(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[`admin-super-admins`]}),i(!1)}});S.useEffect(()=>{r&&s.current&&o(s.current.getBoundingClientRect())},[r]);let u=r=>{r!==t&&(n(e,r),l.mutate({userId:e,role:r}))},d=J4.find(e=>e.value===t),f=(0,L.jsx)(`div`,{className:`w-44 rounded-xl border border-surface-200 bg-white shadow-lg py-1.5`,style:{position:`fixed`,top:a?a.bottom+4:0,left:a?a.right-176:0,zIndex:100},children:J4.map(e=>(0,L.jsxs)(`button`,{onClick:()=>u(e.value),className:`flex w-full items-center gap-2 px-3 py-2 text-sm rounded-lg hover:bg-surface-50 mx-0.5`,children:[t===e.value&&(0,L.jsx)(Xc,{className:`h-3.5 w-3.5 text-brand-600`}),e.value===`super_admin`&&(0,L.jsx)(ll,{className:`h-3.5 w-3.5 text-red-500`}),(0,L.jsx)(`span`,{className:t===e.value?`text-brand-700 font-medium`:`text-surface-700`,children:e.label})]},e.value))});return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`button`,{ref:s,onClick:()=>i(!r),disabled:l.isPending,className:`inline-flex items-center gap-1 px-1.5 py-0.5 hover:bg-surface-100 rounded-lg disabled:opacity-50 min-w-[80px] justify-center`,children:l.isPending?(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${d?.color||`bg-gray-100 text-gray-600`}`,children:d?.label||t}),(0,L.jsx)(Zc,{className:`h-3 w-3 text-surface-400 shrink-0`})]})}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-[99]`,onClick:()=>i(!1)}),(0,yS.createPortal)(f,document.body)]})]})}function Z4({userId:e,currentRole:t,onRoleChange:n}){let[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(null),s=S.useRef(null),c=ci(),{data:l}=R({queryKey:[`admin-organizations`],queryFn:()=>KQ.getOrganizations(),enabled:r&&!t}),u=z({mutationFn:({userId:e,role:t,companyId:n})=>KQ.updateCompanyRole(e,t,n),onSuccess:()=>{c.invalidateQueries({queryKey:[`admin-super-admins`]}),c.invalidateQueries({queryKey:[`admin-organizations`]}),i(!1)}});S.useEffect(()=>{r&&s.current&&o(s.current.getBoundingClientRect())},[r]);let d=(t,r)=>{n(e,t),u.mutate({userId:e,role:t,companyId:r})},f=Y4.find(e=>e.value===t);if(!t){let e=(0,L.jsxs)(`div`,{className:`w-56 max-h-72 overflow-y-auto rounded-xl border border-surface-200 bg-white shadow-lg py-1.5`,style:{position:`fixed`,top:a?a.bottom+4:0,left:a?a.right-224:0,zIndex:100},children:[(0,L.jsx)(`div`,{className:`px-3 py-2 text-[10px] font-semibold uppercase text-surface-400 tracking-wider`,children:`Select Company`}),l?.items&&l.items.length>0?l.items.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`button`,{onClick:()=>i(!1),className:`flex w-full items-center justify-between gap-2 px-3 py-2 text-sm rounded-lg hover:bg-surface-50 mx-0.5`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,L.jsx)(Kc,{className:`h-3.5 w-3.5 text-surface-400 shrink-0`}),(0,L.jsx)(`span`,{className:`text-surface-700 truncate`,children:e.name})]})}),(0,L.jsx)(`div`,{className:`ml-4 border-l-2 border-surface-100`,children:Y4.map(t=>(0,L.jsxs)(`button`,{onClick:()=>d(t.value,e.id),className:`flex w-full items-center gap-2 pl-4 pr-3 py-1.5 text-xs rounded-lg hover:bg-surface-50 mx-0.5`,children:[t.value===`owner`&&(0,L.jsx)(ll,{className:`h-3 w-3 text-amber-500`}),(0,L.jsx)(`span`,{className:`text-surface-600`,children:t.label})]},t.value))})]},e.id)):(0,L.jsx)(`div`,{className:`px-3 py-4 text-xs text-surface-400 text-center`,children:`No companies available`})]});return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`button`,{ref:s,onClick:()=>i(!r),disabled:u.isPending,className:`inline-flex items-center gap-1 rounded-full border border-blue-200 px-3 py-1 text-xs font-medium text-blue-700 hover:bg-blue-50 disabled:opacity-50`,children:u.isPending?(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ju,{className:`h-3 w-3 shrink-0`}),`Assign Company`]})}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-[99]`,onClick:()=>i(!1)}),(0,yS.createPortal)(e,document.body)]})]})}let p=(0,L.jsx)(`div`,{className:`w-40 rounded-xl border border-surface-200 bg-white shadow-lg py-1.5`,style:{position:`fixed`,top:a?a.bottom+4:0,left:a?a.right-160:0,zIndex:100},children:Y4.map(e=>(0,L.jsxs)(`button`,{onClick:()=>d(e.value),className:`flex w-full items-center gap-2 px-3 py-2 text-sm rounded-lg hover:bg-surface-50 mx-0.5`,children:[t===e.value&&(0,L.jsx)(Xc,{className:`h-3.5 w-3.5 text-brand-600`}),(0,L.jsx)(`span`,{className:t===e.value?`text-brand-700 font-medium`:`text-surface-700`,children:e.label})]},e.value))});return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`button`,{ref:s,onClick:()=>i(!r),disabled:u.isPending,className:`inline-flex items-center gap-1 px-1.5 py-0.5 hover:bg-surface-100 rounded-lg disabled:opacity-50 min-w-[80px] justify-center`,children:u.isPending?(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${f?.color||`bg-gray-100 text-gray-600`}`,children:f?.label||t}),(0,L.jsx)(Zc,{className:`h-3 w-3 text-surface-400 shrink-0`})]})}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-[99]`,onClick:()=>i(!1)}),(0,yS.createPortal)(p,document.body)]})]})}function Q4(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(!1),[i,a]=(0,S.useState)(null),{user:o}=W(),s=ci(),{data:c,isLoading:l}=R({queryKey:[`admin-super-admins`],queryFn:()=>KQ.getUsers({role:`super_admin`})}),u=c?.items??[],d=u.filter(t=>t.email.toLowerCase().includes(e.toLowerCase())||t.fullName.toLowerCase().includes(e.toLowerCase())),f=z({mutationFn:e=>KQ.deleteUser(e),onSuccess:()=>{s.invalidateQueries({queryKey:[`admin-super-admins`]}),a(null)}}),p=z({mutationFn:e=>KQ.createUser(e),onSuccess:()=>{s.invalidateQueries({queryKey:[`admin-super-admins`]}),r(!1)}}),m=(0,S.useCallback)((e,t)=>{},[]),h=(0,S.useCallback)((e,t)=>{},[]);return l?(0,L.jsx)($,{title:`Super Admins`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Super Admins`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Super Admins`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-surface-500`,children:[u.length,` super admin`,u.length===1?``:`s`,` with full system access`]}),(0,L.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`flex h-5 w-5 items-center justify-center rounded bg-red-100`,children:(0,L.jsx)(ll,{className:`h-3 w-3 text-red-600`})}),(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:`Super admins have unrestricted access to all organizations, users, and settings`})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search admins...`,className:`w-full border border-surface-300 pl-9 pr-3 py-2.5 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px] w-full sm:w-56`})]}),(0,L.jsxs)(`button`,{onClick:()=>r(!0),className:`inline-flex items-center justify-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px] w-full sm:w-auto`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Add Admin`]})]})]}),(0,L.jsxs)(`div`,{className:`mb-4 flex items-start gap-3 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3`,children:[(0,L.jsx)(jc,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-600`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-amber-800`,children:`Elevated Privileges`}),(0,L.jsx)(`p`,{className:`text-xs text-amber-600 mt-0.5`,children:`Super admins can manage all organizations, users, integrations, and platform settings. Limit this role to trusted operators only.`})]})]}),d.length===0?(0,L.jsx)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-surface-300 bg-surface-50 py-16`,children:u.length===0?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-full bg-surface-100`,children:(0,L.jsx)(ll,{className:`h-8 w-8 text-surface-300`})}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No super admins yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Create a super admin to manage the platform`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-full bg-surface-100`,children:(0,L.jsx)(J,{className:`h-8 w-8 text-surface-300`})}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No admins match your search`})]})}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white`,children:(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 pl-5 text-left font-medium text-surface-500`,children:`Admin`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Platform Role`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Company Role`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500 pr-2`,children:`Last Login`}),(0,L.jsx)(`th`,{className:`pb-3 pr-5 w-10`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:d.map(e=>(0,L.jsxs)(`tr`,{className:`hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`py-3 pl-5 align-middle`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-red-100 text-xs font-semibold text-red-700`,children:e.fullName.charAt(0).toUpperCase()}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900 truncate`,children:e.fullName}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500 truncate`,children:e.email})]})]})}),(0,L.jsx)(`td`,{className:`py-3 px-2 align-middle`,children:(0,L.jsx)(`div`,{className:`flex items-center`,children:(0,L.jsx)(X4,{userId:e.id,currentRole:e.role,onRoleChange:m})})}),(0,L.jsx)(`td`,{className:`py-3 px-2 align-middle`,children:(0,L.jsx)(`div`,{className:`flex items-center`,children:(0,L.jsx)(Z4,{userId:e.id,currentRole:e.companyRole??null,onRoleChange:h})})}),(0,L.jsx)(`td`,{className:`py-3 px-2 align-middle`,children:(0,L.jsx)(`div`,{className:`flex items-center`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${e.status===`active`?`bg-emerald-100 text-emerald-700`:`bg-surface-200 text-surface-600`}`,children:[(0,L.jsx)(`span`,{className:`mr-1 h-1.5 w-1.5 rounded-full shrink-0 bg-current`}),e.status]})})}),(0,L.jsx)(`td`,{className:`py-3 px-2 text-right text-surface-500 align-middle`,children:(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:e.lastLogin?new Date(e.lastLogin).toLocaleDateString():`Never`})}),(0,L.jsx)(`td`,{className:`py-3 pr-5 text-right align-middle`,children:e.id!==o?.id&&(0,L.jsx)(`button`,{onClick:()=>a(e.id),className:`inline-flex items-center justify-center rounded-lg p-1.5 text-surface-400 hover:text-red-600 hover:bg-red-50 transition-colors`,title:`Remove super admin`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})})]},e.id))})]})})}),n&&(0,L.jsx)($4,{onClose:()=>r(!1),onCreate:p.mutate,isPending:p.isPending}),i&&(0,L.jsx)(e3,{user:d.find(e=>e.id===i),onConfirm:()=>f.mutate(i),onClose:()=>a(null),isPending:f.isPending})]})}function $4({onClose:e,onCreate:t,isPending:n}){let[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(``);return(0,yS.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:e}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-md rounded-xl bg-white shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 px-5 py-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(ll,{className:`h-4 w-4 text-red-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Add Super Admin`})]}),(0,L.jsx)(`button`,{onClick:e,className:`rounded-lg p-1.5 text-surface-400 hover:text-surface-600 hover:bg-surface-100 transition-colors`,children:(0,L.jsx)(Iu,{className:`h-4 w-4`})})]}),(0,L.jsx)(`div`,{className:`border-y border-amber-200 bg-amber-50 px-5 py-3`,children:(0,L.jsx)(`p`,{className:`text-xs text-amber-700`,children:`This user will have full platform access including all organizations, users, and settings.`})}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),t({email:r,full_name:a,password:s,role:`super_admin`})},className:`p-5 space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1.5`,children:`Email *`}),(0,L.jsx)(`input`,{type:`email`,required:!0,value:r,onChange:e=>i(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500 focus:ring-1 focus:ring-brand-500`,placeholder:`admin@example.com`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1.5`,children:`Full Name *`}),(0,L.jsx)(`input`,{type:`text`,required:!0,value:a,onChange:e=>o(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500 focus:ring-1 focus:ring-brand-500`,placeholder:`Admin Name`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1.5`,children:`Password *`}),(0,L.jsx)(`input`,{type:`password`,required:!0,minLength:8,value:s,onChange:e=>c(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500 focus:ring-1 focus:ring-brand-500`,placeholder:`Min 8 characters`})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:e,className:`rounded-lg border border-surface-300 px-4 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[40px]`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`submit`,disabled:n,className:`inline-flex items-center gap-2 rounded-lg bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700 disabled:opacity-50 min-h-[40px]`,children:[n&&(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),(0,L.jsx)(ju,{className:`h-4 w-4`}),`Create Admin`]})]})]})]})]}),document.body)}function e3({user:e,onConfirm:t,onClose:n,isPending:r}){return(0,yS.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:n}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-md rounded-xl bg-white shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-surface-200 px-5 py-4`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-red-100`,children:(0,L.jsx)(Mu,{className:`h-5 w-5 text-red-600`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Remove Super Admin`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:e.email})]})]}),(0,L.jsxs)(`div`,{className:`p-5`,children:[(0,L.jsx)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 px-4 py-3 mb-4`,children:(0,L.jsxs)(`p`,{className:`text-sm text-red-700`,children:[`This will permanently delete `,(0,L.jsx)(`strong`,{children:e.fullName}),`'s account and revoke all platform access.`]})}),(0,L.jsx)(`p`,{className:`text-sm text-surface-600`,children:`Consider demoting them to a Partner or User role instead if you want to keep their account.`}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-3 pt-4`,children:[(0,L.jsx)(`button`,{onClick:n,className:`rounded-lg border border-surface-300 px-4 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[40px]`,children:`Cancel`}),(0,L.jsxs)(`button`,{onClick:t,disabled:r,className:`inline-flex items-center gap-2 rounded-lg bg-red-600 px-4 py-2 text-sm font-medium text-white hover:bg-red-700 disabled:opacity-50 min-h-[40px]`,children:[r&&(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),`Delete User`]})]})]})]})]}),document.body)}var t3=async()=>{let e=await fetch(`/api/super-admin/partners`,{credentials:`include`,headers:{"Content-Type":`application/json`}});if(!e.ok)throw Error(`Failed to fetch partners`);let t=await e.json();return t.items??t.partners??[]};function n3(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(!1),i=ci(),{data:a,isLoading:o}=R({queryKey:[`admin-partners`],queryFn:t3}),s=(a??[]).filter(t=>t.name.toLowerCase().includes(e.toLowerCase())||(t.user_email??``).toLowerCase().includes(e.toLowerCase())),c=z({mutationFn:e=>fetch(`/api/super-admin/partners`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:e})}).then(async e=>{if(!e.ok)throw Error(await e.text());return e.json()}),onSuccess:()=>{i.invalidateQueries({queryKey:[`admin-partners`]}),r(!1)}});return o?(0,L.jsx)($,{title:`Partners`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Partners`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Partners`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-surface-500`,children:[a?.length??0,` partner`,a?.length===1?``:`s`,` in your network`]}),(0,L.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`flex h-5 w-5 items-center justify-center rounded bg-blue-100`,children:(0,L.jsx)(xl,{className:`h-3 w-3 text-blue-600`})}),(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:`Partners have their own isolated workspace and cannot access other companies' data`})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:`Search partners...`,className:`w-full border border-surface-300 pl-9 pr-3 py-2.5 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px] w-full sm:w-56`})]}),(0,L.jsxs)(`button`,{onClick:()=>r(!0),className:`inline-flex items-center justify-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px] w-full sm:w-auto`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Add Partner`]})]})]}),(0,L.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100`,children:(0,L.jsx)(Pu,{className:`h-5 w-5 text-blue-600`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:`Active Partners`}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:(a??[]).filter(e=>e.status===`active`).length})]})]})}),(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-green-100`,children:(0,L.jsx)(du,{className:`h-5 w-5 text-green-600`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:`Connected`}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:(a??[]).filter(e=>e.user_id).length})]})]})}),(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-amber-100`,children:(0,L.jsx)(Kc,{className:`h-5 w-5 text-amber-600`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:`Pending`}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:(a??[]).filter(e=>!e.user_id).length})]})]})})]}),(a??[]).length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(xl,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No partners yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Add a partner to start building your network`})]}):s.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(J,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No partners match your search`})]}):(0,L.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:s.map(e=>(0,L.jsxs)(`div`,{className:`group rounded-xl border border-surface-200 bg-white p-5 transition-shadow hover:shadow-md`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100 text-sm font-semibold text-blue-700`,children:e.name.charAt(0).toUpperCase()}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-900`,children:e.name}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-500`,children:[`Partner #`,e.id]})]})]}),(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${e.status===`active`?`bg-success/10 text-success`:`bg-surface-200 text-surface-600`}`,children:e.status})]}),e.user_name&&(0,L.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-full bg-surface-100 text-xs text-surface-600`,children:e.user_name.charAt(0).toUpperCase()}),(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:e.user_name})]}),e.user_email&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:e.user_email}),!e.user_id&&(0,L.jsx)(`div`,{className:`mt-3 rounded-md border border-dashed border-surface-300 bg-surface-50 px-3 py-2`,children:(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`No user assigned yet — create a user and assign them the Partner role`})}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center justify-between border-t border-surface-100 pt-3`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:new Date(e.created_at).toLocaleDateString()}),(0,L.jsxs)(`button`,{className:`inline-flex items-center gap-1 text-xs font-medium text-brand-600 hover:text-brand-700`,children:[`View Details`,(0,L.jsx)(pl,{className:`h-3 w-3`})]})]})]},e.id))}),n&&(0,L.jsx)(r3,{onClose:()=>r(!1),onCreate:c.mutate,isPending:c.isPending})]})}function r3({onClose:e,onCreate:t,isPending:n}){let[r,i]=(0,S.useState)(``);return(0,yS.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:e}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-md rounded-xl bg-white shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 p-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(xl,{className:`h-4 w-4 text-blue-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Add Partner`})]}),(0,L.jsx)(`button`,{onClick:e,className:`rounded-md p-1 text-surface-400 hover:text-surface-600`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),r.trim()&&t(r.trim())},className:`p-5 space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Partner Name *`}),(0,L.jsx)(`input`,{type:`text`,required:!0,value:r,onChange:e=>i(e.target.value),className:`w-full rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,placeholder:`e.g. Acme Marketing Group`})]}),(0,L.jsx)(`div`,{className:`rounded-lg border border-blue-200 bg-blue-50 p-3`,children:(0,L.jsx)(`p`,{className:`text-xs text-blue-700`,children:`This creates a partner workspace. Assign a user with the Partner role to link them to this workspace.`})}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-3 pt-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:e,className:`rounded-lg border border-surface-300 px-4 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`submit`,disabled:n,className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:[n&&(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),(0,L.jsx)(eu,{className:`h-4 w-4`}),`Create Partner`]})]})]})]})]}),document.body)}var i3=async()=>(await(await fetch(`/api/csrf-token`,{credentials:`include`})).json()).csrf_token,a3=async(e,t)=>{let n=await fetch(e,{credentials:`include`,headers:{"Content-Type":`application/json`},...t});if(!n.ok){let e=await n.text();throw Error(e||`HTTP ${n.status}`)}return n.json()};function o3({status:e}){let t={active:{bg:`bg-green-100`,text:`text-green-700`,label:`Active`},terminated:{bg:`bg-red-100`,text:`text-red-700`,label:`Terminated`},calculated:{bg:`bg-blue-100`,text:`text-blue-700`,label:`Calculated`},approved:{bg:`bg-yellow-100`,text:`text-yellow-700`,label:`Approved`},paid:{bg:`bg-green-100`,text:`text-green-700`,label:`Paid`},disputed:{bg:`bg-red-100`,text:`text-red-700`,label:`Disputed`},scheduled:{bg:`bg-purple-100`,text:`text-purple-700`,label:`Scheduled`},completed:{bg:`bg-green-100`,text:`text-green-700`,label:`Completed`},failed:{bg:`bg-red-100`,text:`text-red-700`,label:`Failed`}}[e]||{bg:`bg-gray-100`,text:`text-gray-600`,label:e};return(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${t.bg} ${t.text}`,children:t.label})}function s3({confidence:e}){let t={verified:{bg:`bg-green-50`,text:`text-green-600`,label:`✓ Verified`},self_reported:{bg:`bg-amber-50`,text:`text-amber-600`,label:`~ Self-reported`},estimated:{bg:`bg-gray-100`,text:`text-gray-500`,label:`? Estimated`}},n=t[e]||t.estimated;return(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${n.bg} ${n.text}`,children:n.label})}function c3(e,t=`USD`){return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e)}function l3(e){return`${(e*100).toFixed(1)}%`}function u3(){let[e,t]=(0,S.useState)(`partnerships`),[n,r]=(0,S.useState)(``),[i,a]=(0,S.useState)(!1),[o,s]=(0,S.useState)(!1),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(null),[m,h]=(0,S.useState)(``),[g,_]=(0,S.useState)(null),v=ci(),{data:y,isLoading:b}=R({queryKey:[`admin-commissions-partnerships`],queryFn:()=>a3(`/api/super-admin/commissions/partnerships`).then(e=>e.items)}),{data:x,isLoading:C}=R({queryKey:[`admin-commissions-records`],queryFn:()=>a3(`/api/super-admin/commissions/records`).then(e=>e.items)}),{data:w,isLoading:T}=R({queryKey:[`admin-commissions-payouts`],queryFn:()=>a3(`/api/super-admin/commissions/payouts`).then(e=>e.items)}),{data:E}=R({queryKey:[`admin-commissions-partnerships`],queryFn:()=>a3(`/api/super-admin/commissions/partnerships`).then(e=>e.items)}),D=z({mutationFn:async e=>a3(`/api/super-admin/commissions/partnerships`,{method:`POST`,headers:{"X-CSRFToken":await i3()},body:JSON.stringify(e)}),onSuccess:()=>{v.invalidateQueries({queryKey:[`admin-commissions-partnerships`]}),a(!1)}}),O=z({mutationFn:async({id:e,rate:t})=>{let n=await i3();return a3(`/api/super-admin/commissions/partnerships/${e}`,{method:`PUT`,headers:{"X-CSRFToken":n},body:JSON.stringify({commission_rate:t})})},onSuccess:()=>{v.invalidateQueries({queryKey:[`admin-commissions-partnerships`]}),p(null),h(``)}}),k=z({mutationFn:async e=>{let t=await i3();return a3(`/api/super-admin/commissions/partnerships/${e}`,{method:`PUT`,headers:{"X-CSRFToken":t},body:JSON.stringify({terminate:!0})})},onSuccess:()=>{v.invalidateQueries({queryKey:[`admin-commissions-partnerships`]}),d(null)}}),A=z({mutationFn:async e=>{let t=await i3();return a3(`/api/super-admin/commissions/records/${e}/approve`,{method:`POST`,headers:{"X-CSRFToken":t},body:JSON.stringify({})})},onSuccess:()=>{v.invalidateQueries({queryKey:[`admin-commissions-records`]})}}),j=z({mutationFn:async e=>a3(`/api/super-admin/commissions/calculate`,{method:`POST`,headers:{"X-CSRFToken":await i3()},body:JSON.stringify({period:e})}),onSuccess:()=>{v.invalidateQueries({queryKey:[`admin-commissions-records`]}),v.invalidateQueries({queryKey:[`admin-commissions-partnerships`]}),s(!1)}}),M=z({mutationFn:async e=>a3(`/api/super-admin/commissions/payouts`,{method:`POST`,headers:{"X-CSRFToken":await i3()},body:JSON.stringify(e)}),onSuccess:()=>{v.invalidateQueries({queryKey:[`admin-commissions-payouts`]}),v.invalidateQueries({queryKey:[`admin-commissions-records`]}),l(!1),_(null)}}),N=z({mutationFn:async e=>{let t=await i3();return a3(`/api/super-admin/commissions/payouts/${e}`,{method:`PUT`,headers:{"X-CSRFToken":t},body:JSON.stringify({status:`completed`})})},onSuccess:()=>{v.invalidateQueries({queryKey:[`admin-commissions-payouts`]})}}),ee=(y??[]).filter(e=>e.status===`active`||!0).length,te=(x??[]).reduce((e,t)=>e+t.revenue_amount,0),P=(x??[]).reduce((e,t)=>e+t.commission_amount,0),F=(x??[]).filter(e=>e.status===`approved`).reduce((e,t)=>e+t.commission_amount,0),ne=[{id:`partnerships`,label:`Partnerships`,count:y?.length??0,icon:xl},{id:`records`,label:`Records`,count:x?.length??0,icon:qc},{id:`payouts`,label:`Payouts`,count:w?.length??0,icon:Hc}];return b&&C&&T?(0,L.jsx)($,{title:`Commissions`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Commissions`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Commissions`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Manage partner commission agreements, calculations, and payouts`})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,L.jsxs)(`button`,{onClick:()=>s(!0),disabled:j.isPending,className:`inline-flex items-center justify-center gap-2 rounded-lg bg-amber-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-amber-700 min-h-[44px] w-full sm:w-auto disabled:opacity-50`,children:[j.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(qc,{className:`h-4 w-4`}),`Calculate`]}),(0,L.jsxs)(`button`,{onClick:()=>a(!0),className:`inline-flex items-center justify-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px] w-full sm:w-auto`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`New Partnership`]})]})]}),(0,L.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 lg:grid-cols-4`,children:[(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100`,children:(0,L.jsx)(xl,{className:`h-5 w-5 text-blue-600`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:`Partnerships`}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:ee})]})]})}),(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-green-100`,children:(0,L.jsx)(dl,{className:`h-5 w-5 text-green-600`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:`Total Revenue`}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:c3(te)})]})]})}),(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-purple-100`,children:(0,L.jsx)(Kl,{className:`h-5 w-5 text-purple-600`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:`Total Commissions`}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:c3(P)})]})]})}),(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg bg-amber-100`,children:(0,L.jsx)(al,{className:`h-5 w-5 text-amber-600`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500`,children:`Pending Payout`}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:c3(F)})]})]})})]}),(0,L.jsxs)(`div`,{className:`mb-4 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsx)(`div`,{className:`flex gap-1 rounded-lg bg-surface-100 p-1`,children:ne.map(n=>(0,L.jsxs)(`button`,{onClick:()=>t(n.id),className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors min-h-[38px] ${e===n.id?`bg-white text-surface-900 shadow-sm`:`text-surface-500 hover:text-surface-700`}`,children:[(0,L.jsx)(n.icon,{className:`h-4 w-4`}),n.label,(0,L.jsx)(`span`,{className:`ml-1 rounded-full px-1.5 py-0.5 text-xs ${e===n.id?`bg-surface-200 text-surface-600`:`bg-surface-200 text-surface-500`}`,children:n.count})]},n.id))}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-500`}),(0,L.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Search ${e}...`,className:`w-full border border-surface-300 pl-9 pr-3 py-2.5 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px] w-full sm:w-56`})]})]}),e===`partnerships`&&(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(y??[]).length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16`,children:[(0,L.jsx)(xl,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No partnerships yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Create a partnership to start tracking commissions`}),(0,L.jsxs)(`button`,{onClick:()=>a(!0),className:`mt-4 inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`Create First Partnership`]})]}):(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Partner`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Company`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Rate`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Source`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Effective`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium text-surface-500 uppercase`,children:`Actions`})]})}),(0,L.jsx)(`tbody`,{children:y?.map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 hover:bg-surface-50`,children:[(0,L.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,L.jsx)(`div`,{className:`font-medium text-surface-900`,children:e.partner_name}),(0,L.jsx)(`div`,{className:`text-xs text-surface-500`,children:e.partner_email})]}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-700`,children:e.company_name}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:l3(e.commission_rate)})}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`text-xs capitalize text-surface-500`,children:e.revenue_source.replace(`_`,` `)})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-xs text-surface-500`,children:e.effective_date?new Date(e.effective_date).toLocaleDateString():`—`}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,L.jsx)(`button`,{onClick:()=>{p(e.id),h((e.commission_rate*100).toString())},className:`p-1.5 rounded hover:bg-surface-200 text-surface-500`,title:`Update rate`,children:(0,L.jsx)(Gl,{className:`h-3.5 w-3.5`})}),(0,L.jsx)(`button`,{onClick:()=>d(e.id),className:`p-1.5 rounded hover:bg-red-100 text-surface-400 hover:text-red-600`,title:`Terminate`,children:(0,L.jsx)(Su,{className:`h-3.5 w-3.5`})})]})})]},e.id))})]})}),e===`records`&&(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(x??[]).length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16`,children:[(0,L.jsx)(qc,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No records yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Run commission calculation to generate records`}),(0,L.jsxs)(`button`,{onClick:()=>s(!0),className:`mt-4 inline-flex items-center gap-2 rounded-lg bg-amber-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-amber-700 min-h-[44px]`,children:[(0,L.jsx)(qc,{className:`h-4 w-4`}),`Calculate Commissions`]})]}):(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Period`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Partner`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Company`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium text-surface-500 uppercase`,children:`Revenue`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium text-surface-500 uppercase`,children:`Rate`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium text-surface-500 uppercase`,children:`Commission`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-center text-xs font-medium text-surface-500 uppercase`,children:`Confidence`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-center text-xs font-medium text-surface-500 uppercase`,children:`Status`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium text-surface-500 uppercase`,children:`Actions`})]})}),(0,L.jsx)(`tbody`,{children:x?.filter(e=>e.partner_name.toLowerCase().includes(n.toLowerCase())||e.company_name.toLowerCase().includes(n.toLowerCase())||e.period.includes(n)).map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-mono text-sm`,children:e.period}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-700`,children:e.partner_name}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-700`,children:e.company_name}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-mono text-sm`,children:c3(e.revenue_amount)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-mono text-sm`,children:l3(e.commission_rate)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-mono text-sm font-medium text-green-700`,children:c3(e.commission_amount)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-center`,children:(0,L.jsx)(s3,{confidence:e.revenue_confidence})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-center`,children:(0,L.jsx)(o3,{status:e.status})}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-right`,children:[e.status===`calculated`&&(0,L.jsxs)(`button`,{onClick:()=>A.mutate(e.id),disabled:A.isPending,className:`inline-flex items-center gap-1 rounded bg-green-600 px-2.5 py-1 text-xs font-medium text-white hover:bg-green-700 min-h-[32px]`,children:[A.isPending?(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}):(0,L.jsx)(yc,{className:`h-3 w-3`}),`Approve`]}),e.status!==`calculated`&&(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:`—`})]})]},e.id))})]})}),e===`payouts`&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`div`,{className:`flex justify-end`,children:(0,L.jsxs)(`button`,{onClick:()=>l(!0),disabled:!E?.length,className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px] disabled:opacity-50`,children:[(0,L.jsx)(su,{className:`h-4 w-4`}),`Create Payout`]})}),(w??[]).length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(Hc,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No payouts yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Approve commission records, then create a payout`})]}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Partner`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium text-surface-500 uppercase`,children:`Amount`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-center text-xs font-medium text-surface-500 uppercase`,children:`Records`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-center text-xs font-medium text-surface-500 uppercase`,children:`Method`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Scheduled`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-surface-500 uppercase`,children:`Paid`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-center text-xs font-medium text-surface-500 uppercase`,children:`Status`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium text-surface-500 uppercase`,children:`Actions`})]})}),(0,L.jsx)(`tbody`,{children:w?.filter(e=>e.partner_name.toLowerCase().includes(n.toLowerCase())).map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-700`,children:e.partner_name}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-mono text-sm font-medium`,children:c3(e.amount,e.currency)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-center`,children:(0,L.jsx)(`span`,{className:`inline-flex items-center justify-center h-6 w-6 rounded-full bg-surface-100 text-xs font-medium`,children:e.record_count})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-center text-xs capitalize text-surface-500`,children:e.payment_method.replace(`_`,` `)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-xs text-surface-500`,children:e.scheduled_date?new Date(e.scheduled_date).toLocaleDateString():`—`}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-xs text-surface-500`,children:e.paid_date?new Date(e.paid_date).toLocaleDateString():`—`}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-center`,children:(0,L.jsx)(o3,{status:e.status})}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-right`,children:[e.status===`scheduled`&&(0,L.jsxs)(`button`,{onClick:()=>N.mutate(e.id),disabled:N.isPending,className:`inline-flex items-center gap-1 rounded bg-green-600 px-2.5 py-1 text-xs font-medium text-white hover:bg-green-700 min-h-[32px]`,children:[N.isPending?(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}):(0,L.jsx)(yc,{className:`h-3 w-3`}),`Mark Paid`]}),e.status!==`scheduled`&&(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:`—`})]})]},e.id))})]})})]}),i&&(0,L.jsx)(d3,{onClose:()=>a(!1),title:`Create Partnership`,children:(0,L.jsx)(f3,{onSubmit:e=>D.mutate(e),loading:D.isPending,error:D.error?.message})}),f!==null&&(0,L.jsx)(d3,{onClose:()=>p(null),title:`Update Commission Rate`,children:(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=parseFloat(m)/100;isNaN(t)||O.mutate({id:f,rate:t})},className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Commission Rate (%)`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`input`,{type:`number`,step:`0.1`,value:m,onChange:e=>h(e.target.value),className:`w-full border border-surface-300 px-3 py-2.5 pr-8 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px]`,placeholder:`15`,autoFocus:!0}),(0,L.jsx)(`span`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-surface-400 text-sm`,children:`%`})]})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>p(null),className:`px-4 py-2 text-sm rounded-lg border border-surface-300 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`submit`,disabled:O.isPending||!m,className:`px-4 py-2 text-sm rounded-lg bg-brand-600 text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px] flex items-center gap-2`,children:[O.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):null,`Update Rate`]})]})]})}),u!==null&&(0,L.jsx)(d3,{onClose:()=>d(null),title:`Terminate Partnership`,children:(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg bg-red-50 p-4`,children:[(0,L.jsx)(jc,{className:`h-5 w-5 text-red-600 flex-shrink-0 mt-0.5`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-red-800`,children:`Are you sure?`}),(0,L.jsx)(`p`,{className:`text-xs text-red-600 mt-1`,children:`This will terminate the partnership agreement. Pending commission records will remain but no new records will be calculated.`})]})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(`button`,{onClick:()=>d(null),className:`px-4 py-2 text-sm rounded-lg border border-surface-300 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsxs)(`button`,{onClick:()=>k.mutate(u),disabled:k.isPending,className:`px-4 py-2 text-sm rounded-lg bg-red-600 text-white hover:bg-red-700 disabled:opacity-50 min-h-[44px] flex items-center gap-2`,children:[k.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):null,`Terminate`]})]})]})}),o&&(0,L.jsx)(d3,{onClose:()=>s(!1),title:`Calculate Commissions`,children:(0,L.jsx)(p3,{onSubmit:e=>j.mutate(e),loading:j.isPending,error:j.error?.message,result:j.data})}),c&&(0,L.jsx)(d3,{onClose:()=>l(!1),title:`Create Payout`,children:(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),g&&M.mutate({partner_id:g})},className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Partner`}),(0,L.jsxs)(`select`,{value:g??``,onChange:e=>_(parseInt(e.target.value)),className:`w-full border border-surface-300 px-3 py-2.5 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px]`,required:!0,children:[(0,L.jsx)(`option`,{value:``,children:`Select a partner...`}),E?.map(e=>(0,L.jsx)(`option`,{value:e.partner_id,children:e.partner_name},e.partner_id))]})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{l(!1),_(null)},className:`px-4 py-2 text-sm rounded-lg border border-surface-300 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`submit`,disabled:M.isPending||!g,className:`px-4 py-2 text-sm rounded-lg bg-brand-600 text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px] flex items-center gap-2`,children:[M.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(su,{className:`h-4 w-4`}),`Create Payout`]})]})]})})]})}function d3({children:e,onClose:t,title:n}){return(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,onClick:t,children:(0,L.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-white p-6 shadow-xl mx-4`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:n}),(0,L.jsx)(`button`,{onClick:t,className:`p-1 rounded-lg hover:bg-surface-100 text-surface-400`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),e]})})}function f3({onSubmit:e,loading:t,error:n}){let[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(`15`),[l,u]=(0,S.useState)(`self_reported`),{data:d}=R({queryKey:[`admin-companies`],queryFn:()=>a3(`/api/super-admin/organizations`)});return(0,L.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),e({partner_email:r,company_id:parseInt(a),commission_rate:parseFloat(s)/100,revenue_source:l})},className:`space-y-4`,children:[n&&(0,L.jsx)(`div`,{className:`rounded-lg bg-red-50 p-3 text-sm text-red-700`,children:n}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Partner Email`}),(0,L.jsx)(`input`,{type:`email`,value:r,onChange:e=>i(e.target.value),className:`w-full border border-surface-300 px-3 py-2.5 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px]`,placeholder:`partner@example.com`,required:!0,autoFocus:!0})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Company`}),(0,L.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full border border-surface-300 px-3 py-2.5 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px]`,required:!0,children:[(0,L.jsx)(`option`,{value:``,children:`Select a company...`}),d?.items?.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Commission Rate (%)`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`input`,{type:`number`,step:`0.1`,value:s,onChange:e=>c(e.target.value),className:`w-full border border-surface-300 px-3 py-2.5 pr-8 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px]`,placeholder:`15`,required:!0}),(0,L.jsx)(`span`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-surface-400 text-sm`,children:`%`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Revenue Source`}),(0,L.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`w-full border border-surface-300 px-3 py-2.5 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`self_reported`,children:`Self-reported`}),(0,L.jsx)(`option`,{value:`forecast`,children:`Forecast-based`}),(0,L.jsx)(`option`,{value:`connector`,children:`Connector-synced`})]})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{},className:`px-4 py-2 text-sm rounded-lg border border-surface-300 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`submit`,disabled:t,className:`px-4 py-2 text-sm rounded-lg bg-brand-600 text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px] flex items-center gap-2`,children:[t?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(eu,{className:`h-4 w-4`}),`Create Partnership`]})]})]})}function p3({onSubmit:e,loading:t,error:n,result:r}){let i=new Date,a=i.getMonth()===0?`${i.getFullYear()-1}-12`:`${i.getFullYear()}-${String(i.getMonth()).padStart(2,`0`)}`,[o,s]=(0,S.useState)(a);return r?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-green-50 p-4 text-sm text-green-700`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,L.jsx)(yc,{className:`h-5 w-5`}),`Calculation Complete`]}),(0,L.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,L.jsxs)(`p`,{children:[`Period: `,(0,L.jsx)(`strong`,{children:r.period})]}),(0,L.jsxs)(`p`,{children:[`Records created: `,(0,L.jsx)(`strong`,{children:r.created})]}),(0,L.jsxs)(`p`,{children:[`Records updated: `,(0,L.jsx)(`strong`,{children:r.updated})]}),(0,L.jsxs)(`p`,{children:[`Partnerships processed: `,(0,L.jsx)(`strong`,{children:r.partnerships_processed})]})]})]}),(0,L.jsx)(`div`,{className:`flex justify-end`,children:(0,L.jsx)(`button`,{onClick:()=>e(``),className:`px-4 py-2 text-sm rounded-lg bg-surface-900 text-white hover:bg-surface-800 min-h-[44px]`,children:`Done`})})]}):(0,L.jsxs)(`div`,{className:`space-y-4`,children:[n&&(0,L.jsx)(`div`,{className:`rounded-lg bg-red-50 p-3 text-sm text-red-700`,children:n}),(0,L.jsx)(`div`,{className:`rounded-lg bg-amber-50 p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(jc,{className:`h-5 w-5 text-amber-600 flex-shrink-0 mt-0.5`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-amber-800`,children:`Commission Calculation`}),(0,L.jsx)(`p`,{className:`text-xs text-amber-600 mt-1`,children:`This will calculate commissions for all active partnerships based on their configured revenue source. Revenue pulls from connectors, forecasts, or self-reported values.`})]})]})}),(0,L.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),e(o)},children:[(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Period`}),(0,L.jsx)(`div`,{className:`relative`,children:(0,L.jsx)(`input`,{type:`month`,value:o,onChange:e=>s(e.target.value),className:`w-full border border-surface-300 px-3 py-2.5 text-sm rounded-lg outline-none focus:border-brand-500 min-h-[44px]`,required:!0})}),(0,L.jsxs)(`p`,{className:`mt-1 text-xs text-surface-500`,children:[`Default: previous month (`,a,`)`]})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>e(``),className:`px-4 py-2 text-sm rounded-lg border border-surface-300 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`submit`,disabled:t,className:`px-4 py-2 text-sm rounded-lg bg-amber-600 text-white hover:bg-amber-700 disabled:opacity-50 min-h-[44px] flex items-center gap-2`,children:[t?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsx)(qc,{className:`h-4 w-4`}),`Calculate`]})]})]})]})}var m3=[{name:`Manage All Organizations`,description:`Create, edit, delete any organization`},{name:`Manage All Users`,description:`Add, remove, modify any user account`},{name:`View All Analytics`,description:`Access analytics across all organizations`},{name:`Manage Integrations`,description:`Configure platform-wide integrations`},{name:`View Audit Logs`,description:`Access full audit trail`},{name:`Manage Portfolios`,description:`Create and manage portfolio groups`},{name:`Manage Partners`,description:`Add and configure partner workspaces`},{name:`Manage Email Campaigns`,description:`Create and manage email campaigns`},{name:`Manage Leads`,description:`View and manage all leads platform-wide`},{name:`System Settings`,description:`Modify platform-wide settings`}],h3=[{name:`Edit Company Profile`,description:`Modify company name, details, settings`},{name:`Manage Company Users`,description:`Add/remove users within this company`},{name:`View Company Analytics`,description:`Access company-specific analytics`},{name:`Manage CRM Records`,description:`Create/edit/delete contacts, deals, leads`},{name:`Manage Goals & Forecasts`,description:`Set and modify goals and forecasting data`},{name:`View Company Audit Log`,description:`Access this company audit trail`}],g3=[{id:`super_admin`,label:`Super Admin`,icon:(0,L.jsx)(ll,{className:`h-4 w-4`}),color:`text-red-700`,bgColor:`bg-red-100`,description:`Full platform access across all organizations`,permissions:{"Manage All Organizations":!0,"Manage All Users":!0,"View All Analytics":!0,"Manage Integrations":!0,"View Audit Logs":!0,"Manage Portfolios":!0,"Manage Partners":!0,"Manage Email Campaigns":!0,"Manage Leads":!0,"System Settings":!0}},{id:`admin`,label:`Admin`,icon:(0,L.jsx)(ku,{className:`h-4 w-4`}),color:`text-orange-700`,bgColor:`bg-orange-100`,description:`Full access within their organization`,permissions:{"Manage All Organizations":!1,"Manage All Users":!1,"View All Analytics":!1,"Manage Integrations":!1,"View Audit Logs":!0,"Manage Portfolios":!1,"Manage Partners":!1,"Manage Email Campaigns":!0,"Manage Leads":!0,"System Settings":!1}},{id:`partner`,label:`Partner`,icon:(0,L.jsx)(Pu,{className:`h-4 w-4`}),color:`text-blue-700`,bgColor:`bg-blue-100`,description:`Isolated partner workspace access`,permissions:{"Manage All Organizations":!1,"Manage All Users":!1,"View All Analytics":!1,"Manage Integrations":!1,"View Audit Logs":!1,"Manage Portfolios":!1,"Manage Partners":!1,"Manage Email Campaigns":!1,"Manage Leads":!1,"System Settings":!1}},{id:`user`,label:`User`,icon:(0,L.jsx)(Nu,{className:`h-4 w-4`}),color:`text-gray-600`,bgColor:`bg-gray-100`,description:`Basic access within their organization`,permissions:{"Manage All Organizations":!1,"Manage All Users":!1,"View All Analytics":!1,"Manage Integrations":!1,"View Audit Logs":!1,"Manage Portfolios":!1,"Manage Partners":!1,"Manage Email Campaigns":!1,"Manage Leads":!1,"System Settings":!1}}],_3=[{id:`owner`,label:`Owner`,icon:(0,L.jsx)(ll,{className:`h-4 w-4`}),color:`text-purple-700`,bgColor:`bg-purple-100`,description:`Full ownership with all company permissions`,permissions:{"Edit Company Profile":!0,"Manage Company Users":!0,"View Company Analytics":!0,"Manage CRM Records":!0,"Manage Goals & Forecasts":!0,"View Company Audit Log":!0}},{id:`admin`,label:`Admin`,icon:(0,L.jsx)(ku,{className:`h-4 w-4`}),color:`text-indigo-700`,bgColor:`bg-indigo-100`,description:`Full admin within company except ownership`,permissions:{"Edit Company Profile":!0,"Manage Company Users":!0,"View Company Analytics":!0,"Manage CRM Records":!0,"Manage Goals & Forecasts":!0,"View Company Audit Log":!0}},{id:`manager`,label:`Manager`,icon:(0,L.jsx)(Nu,{className:`h-4 w-4`}),color:`text-emerald-700`,bgColor:`bg-emerald-100`,description:`Can manage CRM and goals but not users`,permissions:{"Edit Company Profile":!1,"Manage Company Users":!1,"View Company Analytics":!0,"Manage CRM Records":!0,"Manage Goals & Forecasts":!0,"View Company Audit Log":!1}},{id:`rep`,label:`Rep`,icon:(0,L.jsx)(hl,{className:`h-4 w-4`}),color:`text-amber-700`,bgColor:`bg-amber-100`,description:`Can manage CRM records only`,permissions:{"Edit Company Profile":!1,"Manage Company Users":!1,"View Company Analytics":!1,"Manage CRM Records":!0,"Manage Goals & Forecasts":!1,"View Company Audit Log":!1}},{id:`viewer`,label:`Viewer`,icon:(0,L.jsx)(hl,{className:`h-4 w-4`}),color:`text-slate-600`,bgColor:`bg-slate-100`,description:`Read-only access to company data`,permissions:{"Edit Company Profile":!1,"Manage Company Users":!1,"View Company Analytics":!1,"Manage CRM Records":!1,"Manage Goals & Forecasts":!1,"View Company Audit Log":!1}}];function v3({has:e}){return e?(0,L.jsx)(`div`,{className:`flex justify-center`,children:(0,L.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded bg-green-100`,children:(0,L.jsx)(Xc,{className:`h-3.5 w-3.5 text-green-600`})})}):(0,L.jsx)(`div`,{className:`flex justify-center`,children:(0,L.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded bg-surface-100`,children:(0,L.jsx)(Bl,{className:`h-3.5 w-3.5 text-surface-400`})})})}function y3({roles:e,permissions:t,title:n}){return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`border-b border-surface-200 px-5 py-4`,children:(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-900`,children:n})}),(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 pl-5 text-left font-medium text-surface-500 min-w-[160px]`,children:`Role`}),t.map(e=>(0,L.jsx)(`th`,{className:`pb-3 px-2 text-center font-medium text-surface-500 whitespace-nowrap min-w-[80px]`,children:e.name},e.name))]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:e.map(e=>(0,L.jsxs)(`tr`,{className:`hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`py-3 pl-5`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center rounded-lg ${e.bgColor} ${e.color}`,children:e.icon}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:e.label}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.description})]})]})}),t.map(t=>(0,L.jsx)(`td`,{className:`py-3 px-2`,children:(0,L.jsx)(v3,{has:e.permissions[t.name]??!1})},t.name))]},e.id))})]})})]})}function b3(){let[e,t]=(0,S.useState)(`platform`);return(0,L.jsxs)($,{title:`Access Levels`,children:[(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Access Levels`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:`Role-based access control configuration for platform and company permissions`}),(0,L.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`flex h-5 w-5 items-center justify-center rounded bg-brand-100`,children:(0,L.jsx)(Dl,{className:`h-3 w-3 text-brand-600`})}),(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:`Roles define what users can see and do. Users inherit permissions from both their Platform Role and Company Role.`})]})]}),(0,L.jsxs)(`div`,{className:`mb-6 flex gap-2`,children:[(0,L.jsxs)(`button`,{onClick:()=>t(`platform`),className:`inline-flex items-center gap-2 rounded-lg px-4 py-2.5 text-sm font-medium min-h-[44px] transition-colors ${e===`platform`?`bg-brand-600 text-white`:`bg-white border border-surface-300 text-surface-700 hover:bg-surface-50`}`,children:[(0,L.jsx)(fu,{className:`h-4 w-4`}),`Platform Roles`]}),(0,L.jsxs)(`button`,{onClick:()=>t(`company`),className:`inline-flex items-center gap-2 rounded-lg px-4 py-2.5 text-sm font-medium min-h-[44px] transition-colors ${e===`company`?`bg-brand-600 text-white`:`bg-white border border-surface-300 text-surface-700 hover:bg-surface-50`}`,children:[(0,L.jsx)(ku,{className:`h-4 w-4`}),`Company Roles`]})]}),(0,L.jsxs)(`div`,{className:`mb-6 flex items-start gap-3 rounded-lg border border-blue-200 bg-blue-50 px-4 py-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-blue-100`,children:(0,L.jsx)(Nl,{className:`h-4 w-4 text-blue-600`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-blue-800`,children:e===`platform`?`Platform roles control cross-organization access`:`Company roles control within-organization permissions`}),(0,L.jsx)(`p`,{className:`text-xs text-blue-600 mt-0.5`,children:e===`platform`?`Super Admins have unrestricted access. Admins are scoped to their organization. Partners have isolated workspaces.`:`Owner has full control. Admin mirrors Owner without ownership rights. Manager handles CRM and goals. Rep manages records only. Viewer is read-only.`})]})]}),(0,L.jsx)(`div`,{className:`space-y-6`,children:e===`platform`?(0,L.jsx)(y3,{roles:g3,permissions:m3,title:`Platform Role Permissions Matrix`}):(0,L.jsx)(y3,{roles:_3,permissions:h3,title:`Company Role Permissions Matrix`})}),(0,L.jsxs)(`div`,{className:`mt-6`,children:[(0,L.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-surface-900`,children:e===`platform`?`Platform Role Summary`:`Company Role Summary`}),(0,L.jsx)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4`,children:(e===`platform`?g3:_3).map(e=>{let t=Object.values(e.permissions).filter(Boolean).length,n=Object.keys(e.permissions).length,r=Math.round(t/n*100);return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,L.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-lg ${e.bgColor} ${e.color}`,children:e.icon}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`text-sm font-semibold text-surface-900`,children:e.label}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500 truncate`,children:e.description})]})]}),(0,L.jsxs)(`div`,{className:`mt-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-surface-500 mb-1`,children:[(0,L.jsx)(`span`,{children:`Permissions`}),(0,L.jsxs)(`span`,{className:`font-medium`,children:[t,`/`,n,` (`,r,`%)`]})]}),(0,L.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full ${e.bgColor.replace(`/10`,``).replace(`bg-`,`bg-`)}`,style:{width:`${r}%`}})})]}),t===0&&(0,L.jsxs)(`div`,{className:`mt-2 flex items-center gap-1`,children:[(0,L.jsx)(Nl,{className:`h-3 w-3 text-surface-400`}),(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:`View-only access`})]}),t===n&&(0,L.jsxs)(`div`,{className:`mt-2 flex items-center gap-1`,children:[(0,L.jsx)(Ec,{className:`h-3 w-3 text-green-500`}),(0,L.jsx)(`span`,{className:`text-xs text-green-600`,children:`Full access`})]})]},e.id)})})]})]})}var x3=`https://js.stripe.com/v3`,S3=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,C3=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,w3=function(){for(var e=document.querySelectorAll(`script[src^="${x3}"]`),t=0;t<e.length;t++){var n=e[t];if(S3.test(n.src))return n}return null},T3=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${x3}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},E3=function(e,t){!e||!e._registerWrapper||e._registerWrapper({name:`stripe-js`,version:`4.6.0`,startTime:t})},D3=null,O3=null,k3=null,A3=function(e){return function(){e(Error(`Failed to load Stripe.js`))}},j3=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},M3=function(e){return D3===null?(D3=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(C3),window.Stripe){t(window.Stripe);return}try{var r=w3();if(r&&e)console.warn(C3);else if(!r)r=T3(e);else if(r&&k3!==null&&O3!==null){var i;r.removeEventListener(`load`,k3),r.removeEventListener(`error`,O3),(i=r.parentNode)==null||i.removeChild(r),r=T3(e)}k3=j3(t,n),O3=A3(n),r.addEventListener(`load`,k3),r.addEventListener(`error`,O3)}catch(e){n(e);return}}),D3.catch(function(e){return D3=null,Promise.reject(e)})):D3},N3=function(e,t,n){if(e===null)return null;var r=e.apply(void 0,t);return E3(r,n),r},P3,F3=!1,I3=function(){return P3||(P3=M3(null).catch(function(e){return P3=null,Promise.reject(e)}),P3)};Promise.resolve().then(function(){return I3()}).catch(function(e){F3||console.warn(e)});var L3=function(){var e=[...arguments];F3=!0;var t=Date.now();return I3().then(function(n){return N3(n,e,t)})},R3={Launch:`launch`,Growth:`growth`,Command:`command`};function z3(){let[e]=Bn(),[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)(!0),[s,c]=(0,S.useState)(null),[l,u]=(0,S.useState)(``),d=e.get(`plan`);(0,S.useEffect)(()=>{Promise.all([fetch(`/api/billing/subscription`).then(e=>e.json()),fetch(`/api/billing/config`).then(e=>e.json())]).then(([e,t])=>{n(e.subscription||null),i(t),o(!1)}).catch(()=>{u(`Failed to load billing info`),o(!1)})},[]);let f=async e=>{c(e),u(``);try{let t=await fetch(`/api/billing/checkout-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({plan:e})}),n=await t.json();if(!t.ok)throw Error(n.error||`Checkout failed`);if(r?.publishableKey){let e=await L3(r.publishableKey);if(e&&n.sessionId){let{error:t}=await e.redirectToCheckout({sessionId:n.sessionId});if(t)throw Error(t.message);return}}window.location.href=n.url}catch(e){u(e instanceof Error?e.message:`Checkout failed. Please try again.`)}finally{c(null)}},p=async()=>{try{let e=await fetch(`/api/billing/portal-session`,{method:`POST`}),t=await e.json();if(!e.ok)throw Error(t.error||`Failed`);window.location.href=t.url}catch{u(`Could not open billing portal`)}};if(a)return(0,L.jsx)(`div`,{className:`flex min-h-screen items-center justify-center`,children:(0,L.jsx)(PQ,{size:`lg`})});let m=t?.plan||`Starter`,h=t?.is_active||!1;return(0,L.jsx)($,{title:`Billing & Subscription`,children:(0,L.jsxs)(`div`,{className:`max-w-4xl mx-auto space-y-8`,children:[(0,L.jsxs)(Mn,{to:`/app/dashboard`,className:`inline-flex items-center gap-2 text-sm text-white/60 hover:text-white/80 transition-colors`,children:[(0,L.jsx)(Fc,{size:16}),` Back to Dashboard`]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold mb-2`,children:`Billing & Subscription`}),(0,L.jsx)(`p`,{className:`text-white/60`,children:`Manage your subscription plan and payment method.`})]}),l&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-red-500/10 p-4 text-sm text-red-400`,children:[(0,L.jsx)(vc,{className:`h-5 w-5 shrink-0`}),(0,L.jsx)(`span`,{children:l})]}),(0,L.jsxs)(`div`,{className:`mb-8 rounded-xl border border-white/10 bg-white/5 p-6`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold mb-4`,children:`Current Plan`}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-xl font-bold capitalize`,children:m}),(0,L.jsxs)(`div`,{className:`text-sm text-white/50 mt-1`,children:[h?(0,L.jsxs)(L.Fragment,{children:[`Active`,` `,t?.cancel_at_period_end&&(0,L.jsx)(`span`,{className:`text-yellow-400`,children:`(cancels at period end)`})]}):`Free trial eligible`,r?.seatUsage&&(0,L.jsxs)(`span`,{className:`ml-3 inline-flex items-center gap-1`,children:[(0,L.jsxs)(`span`,{className:`font-medium text-white/80`,children:[r.seatUsage.used,`/`,r.seatUsage.limit,` seats`]}),r.seatUsage.used>=r.seatUsage.limit*.8&&(0,L.jsxs)(`span`,{className:`text-orange-400 text-xs`,children:[`(`,Math.round((1-r.seatUsage.used/r.seatUsage.limit)*100),`% remaining)`]})]})]})]}),h&&t?.current_period_end&&(0,L.jsxs)(`div`,{className:`text-right text-sm text-white/50`,children:[(0,L.jsx)(`div`,{children:`Renews`}),(0,L.jsx)(`div`,{className:`font-medium text-white/70`,children:new Date(t.current_period_end).toLocaleDateString()})]})]}),h&&(0,L.jsxs)(`button`,{onClick:p,className:`mt-4 text-sm text-brand-400 hover:text-brand-300 flex items-center gap-1`,children:[`Manage billing `,(0,L.jsx)(Lc,{size:14})]})]}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold mb-4`,children:`Available Plans`}),(0,L.jsx)(`div`,{className:`grid md:grid-cols-3 gap-4 mb-8`,children:r?.plans&&Object.entries(r.plans).map(([e,t])=>{let n=R3[t.name]===m;return(0,L.jsxs)(`div`,{className:`rounded-xl border p-6 flex flex-col ${n?`border-green-500/50 bg-green-500/5`:`border-white/10 bg-white/5`}`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,L.jsx)(`h3`,{className:`font-bold text-lg`,children:t.name}),n&&(0,L.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-green-400`,children:[(0,L.jsx)(yc,{size:14}),` Current`]})]}),(0,L.jsx)(`div`,{className:`text-2xl font-bold mb-1`,children:t.price}),(0,L.jsxs)(`p`,{className:`text-xs text-white/50 mb-4 flex-1`,children:[t.name===`Launch`&&`1 market · 5 seats · 3 integrations`,t.name===`Growth`&&`5 markets · 25 seats · 10 integrations`,t.name===`Command`&&`25 markets · 100 seats · 50 integrations`,r?.seatUsage&&(0,L.jsxs)(`span`,{className:`block mt-1 text-white/40`,children:[`Your company: `,r.seatUsage.used,`/`,r.seatUsage.limit,` seats used`]})]}),(0,L.jsx)(`button`,{onClick:()=>f(e),disabled:s!==null,className:`w-full py-2.5 rounded-lg text-sm font-semibold transition-all min-h-[44px] ${n?`bg-white/5 text-white/30 cursor-default`:h?`bg-green-500/10 text-green-400 hover:bg-green-500/20`:`bg-brand-600 text-white hover:bg-brand-500`}`,children:s===e?(0,L.jsx)(K,{size:16,className:`animate-spin mx-auto`}):n?`Current Plan`:h?`Switch to ${t.name}`:`Start 7-day trial`})]},e)})}),d&&r?.plans[d]&&!h&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-brand-500/30 bg-brand-500/5 p-6 text-center`,children:[(0,L.jsxs)(`p`,{className:`text-white/70 mb-3`,children:[`Ready to start your `,(0,L.jsx)(`strong`,{children:r.plans[d].name}),` trial?`]}),(0,L.jsx)(`button`,{onClick:()=>f(d),disabled:s!==null,className:`inline-flex items-center gap-2 px-6 py-3 rounded-lg bg-brand-600 text-white font-semibold hover:bg-brand-500 transition-colors min-h-[44px]`,children:s===d?(0,L.jsx)(K,{size:16,className:`animate-spin`}):(0,L.jsxs)(L.Fragment,{children:[`Start `,r.plans[d].name,` Trial `,(0,L.jsx)(Lc,{size:16})]})})]})]})})}var B3={critical:`bg-red-100 text-red-700 border-red-200`,high:`bg-orange-100 text-orange-700 border-orange-200`,medium:`bg-amber-100 text-amber-700 border-amber-200`,low:`bg-blue-100 text-blue-700 border-blue-200`},V3={critical:`bg-red-500`,high:`bg-orange-500`,medium:`bg-amber-500`,low:`bg-blue-500`},H3=[{key:`leaks`,label:`Leaks`,icon:jc},{key:`recurring`,label:`Recurring`,icon:ru},{key:`locations`,label:`Locations`,icon:Kc},{key:`stats`,label:`Stats`,icon:mc},{key:`settings`,label:`Settings`,icon:cu}];function U3({severity:e,size:t=`md`}){let n=t===`sm`?`px-1.5 py-0 text-[11px]`:`px-2 py-0.5 text-xs`;return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border font-medium ${B3[e]} ${n}`,children:[(0,L.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full ${V3[e]}`}),e.charAt(0).toUpperCase()+e.slice(1)]})}function W3({label:e,value:t,sub:n,color:r}){return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:e}),(0,L.jsx)(`p`,{className:`mt-2 text-3xl font-bold ${r}`,children:t}),n&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-400`,children:n})]})}function G3({icon:e,title:t,description:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(e,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:t}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:n})]})}function K3(e){if(!e)return`—`;let t=new Date(e);return t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})+` `+t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function q3({leak:e,companyId:t,onClose:n,onRefresh:r}){let[i,a]=(0,S.useState)(null),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(null),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(!1),[m,h]=(0,S.useState)(``),[g,_]=(0,S.useState)(!1),v=(0,S.useCallback)(async()=>{try{l(`details`);let[n,r]=await Promise.all([j$(t,e.id),N$(t,e.id)]);a(n),s(r)}catch{}finally{l(null)}},[t,e.id]);(0,S.useEffect)(()=>{v()},[v]);let y=async n=>{try{d(n.index),await M$(t,e.id,n.index),await v()}catch{}finally{d(null)}},b=async()=>{try{p(!0),await k$(t,e.id,m||void 0),r(),n()}catch{}finally{p(!1)}},x={low:`text-emerald-600`,medium:`text-amber-600`,high:`text-red-600`};return(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,role:`dialog`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/30`,onClick:n}),(0,L.jsxs)(`div`,{className:`relative z-10 flex w-full max-w-lg flex-col bg-white shadow-2xl`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(U3,{severity:e.severity}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:e.source})]}),(0,L.jsx)(`button`,{onClick:n,className:`rounded-lg p-1.5 text-surface-400 hover:bg-surface-100`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-4 space-y-6`,children:[(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-700`,children:e.description||`No description.`}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-sm`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Detected:`}),(0,L.jsx)(`p`,{className:`font-medium text-surface-800`,children:K3(e.detected_at)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Est. Loss:`}),(0,L.jsx)(`p`,{className:`font-medium text-red-600`,children:e.estimated_loss?`$${e.estimated_loss.toLocaleString()}`:`Unknown`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Detector:`}),(0,L.jsx)(`p`,{className:`font-mono text-xs text-surface-600`,children:e.metadata_json?.detector_id||`—`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`text-surface-500`,children:`Status:`}),(0,L.jsx)(`p`,{className:`font-medium`,children:e.resolved?(0,L.jsxs)(`span`,{className:`text-emerald-600`,children:[`✓ Resolved `,K3(e.resolved_at)]}):(0,L.jsx)(`span`,{className:`text-red-600`,children:`Active`})})]})]})]}),!e.resolved&&!g&&(0,L.jsxs)(`button`,{onClick:()=>_(!0),className:`flex w-full items-center justify-center gap-2 rounded-lg bg-emerald-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-emerald-700 transition-colors`,children:[(0,L.jsx)(bc,{className:`h-4 w-4`}),`Mark as Resolved`]}),!e.resolved&&g&&(0,L.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-emerald-200 bg-emerald-50 p-4`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Resolution Notes (optional)`}),(0,L.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value),rows:3,className:`w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 resize-none`,placeholder:`What did you do to fix this?`}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{onClick:b,disabled:f,className:`flex-1 rounded-lg bg-emerald-600 px-4 py-2 text-sm font-medium text-white hover:bg-emerald-700 disabled:opacity-50`,children:f?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Saving...`]}):`Confirm Resolve`}),(0,L.jsx)(`button`,{onClick:()=>_(!1),className:`rounded-lg border border-surface-300 px-4 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50`,children:`Cancel`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-surface-800`,children:[(0,L.jsx)(Fu,{className:`h-4 w-4 text-surface-500`}),`Remediation Suggestions`]}),c===`details`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-surface-500`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Loading suggestions...`]}):i?.suggestions&&i.suggestions.length>0?(0,L.jsx)(`div`,{className:`space-y-3`,children:i.suggestions.map(t=>(0,L.jsxs)(`div`,{className:`rounded-lg border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-semibold text-surface-800`,children:t.title}),(0,L.jsxs)(`span`,{className:`shrink-0 text-xs font-medium ${x[t.effort]}`,children:[t.effort,` effort · `,t.impact_score>=0?`+`:``,t.impact_score,`% impact`]})]}),(0,L.jsx)(`p`,{className:`mb-3 text-xs text-surface-600`,children:t.description}),t.impact_score>=0&&(0,L.jsx)(`div`,{className:`mb-3 h-1.5 w-full rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-1.5 rounded-full ${t.impact_score>50?`bg-emerald-500`:t.impact_score>25?`bg-amber-500`:`bg-blue-500`}`,style:{width:`${Math.min(t.impact_score,100)}%`}})}),!e.resolved&&(0,L.jsx)(`button`,{onClick:()=>y(t),disabled:u===t.index,className:`inline-flex items-center gap-1 rounded-md bg-brand-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-brand-700 disabled:opacity-50 transition-colors`,children:u===t.index?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}),` Applying...`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Ru,{className:`h-3 w-3`}),` Apply Fix`]})})]},t.index))}):(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No suggestions available.`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-surface-800`,children:[(0,L.jsx)(al,{className:`h-4 w-4 text-surface-500`}),`Resolution History`]}),c===`details`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-surface-500`,children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Loading history...`]}):o?.resolution_history&&o.resolution_history.length>0?(0,L.jsx)(`div`,{className:`space-y-2`,children:o.resolution_history.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`div`,{className:`mt-0.5 h-2 w-2 rounded-full bg-emerald-500`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-700`,children:e.resolution_notes||`Resolved`}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[K3(e.resolved_at),` · by `,typeof e.resolved_by==`string`?e.resolved_by:`user ${e.resolved_by}`]})]})]},t))}):(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No resolution history.`})]})]})]})]})}function J3({companyId:e}){let[t,n]=(0,S.useState)([]),[r,i]=(0,S.useState)(!0),[a,o]=(0,S.useState)(90),s=(0,S.useCallback)(async()=>{try{i(!0),n((await P$(e,a)).recurring_leaks||[])}catch{n([])}finally{i(!1)}},[e,a]);return(0,S.useEffect)(()=>{s()},[s]),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-700`,children:`Leaks detected multiple times`}),(0,L.jsxs)(`select`,{value:a,onChange:e=>o(Number(e.target.value)),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:30,children:`Last 30 days`}),(0,L.jsx)(`option`,{value:60,children:`Last 60 days`}),(0,L.jsx)(`option`,{value:90,children:`Last 90 days`}),(0,L.jsx)(`option`,{value:180,children:`Last 180 days`})]})]}),r?(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,L.jsx)(K,{className:`h-5 w-5 animate-spin text-brand-600`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading recurring leaks…`})]}):t.length===0?(0,L.jsx)(G3,{icon:ru,title:`No recurring leaks`,description:`Good news — no leaks have been detected repeatedly in this period.`}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Source`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Detector`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-center font-medium text-surface-600`,children:`Count`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Severity`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`Total Loss`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`First / Last`})]})}),(0,L.jsx)(`tbody`,{children:t.map((e,t)=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 last:border-0 hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900`,children:e.source}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`code`,{className:`rounded bg-surface-100 px-1.5 py-0.5 text-xs text-surface-600`,children:e.detector_id})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-center`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center rounded-full bg-red-100 px-2 py-0.5 text-xs font-semibold text-red-700`,children:[e.count,`×`]})}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(U3,{severity:e.severity,size:`sm`})}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-right font-medium text-red-600`,children:[`$`,e.total_loss?.toLocaleString()||`—`]}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-right text-xs text-surface-500`,children:[(0,L.jsx)(`div`,{children:K3(e.first_detected)}),(0,L.jsx)(`div`,{children:K3(e.last_detected)})]})]},t))})]})})]})}function Y3(){let[e,t]=(0,S.useState)(null),[n,r]=(0,S.useState)(null),[i,a]=(0,S.useState)(null),[o,s]=(0,S.useState)(!0),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(90),[f,p]=(0,S.useState)(`rollup`),m=(0,S.useCallback)(async()=>{try{s(!0),t(await B$(u))}catch{t(null)}finally{s(!1)}},[u]),h=(0,S.useCallback)(async()=>{try{s(!0),r(await V$(u))}catch{r(null)}finally{s(!1)}},[u]),g=(0,S.useCallback)(async()=>{try{l(!0),a(await H$({period_days:u}))}catch{a(null)}finally{l(!1)}},[u]);(0,S.useEffect)(()=>{m()},[m]),(0,S.useEffect)(()=>{f===`comparison`&&h()},[f,h]);let _=[{key:`rollup`,label:`Rollup`,icon:Kc},{key:`comparison`,label:`Comparison`,icon:mc},{key:`detector`,label:`Detector`,icon:Dc}];return o?(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,L.jsx)(K,{className:`h-5 w-5 animate-spin text-brand-600`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading location analytics…`})]}):(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-700`,children:`Multi-Location Revenue Analytics`}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500 mt-0.5`,children:`Revenue concentration, variance alerts, and cross-location benchmarks`})]}),(0,L.jsxs)(`select`,{value:u,onChange:e=>{d(Number(e.target.value)),p(`rollup`)},className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:30,children:`Last 30 days`}),(0,L.jsx)(`option`,{value:60,children:`Last 60 days`}),(0,L.jsx)(`option`,{value:90,children:`Last 90 days`}),(0,L.jsx)(`option`,{value:180,children:`Last 180 days`})]})]}),(0,L.jsx)(`div`,{className:`flex gap-1 rounded-lg bg-surface-100 p-1`,children:_.map(({key:e,label:t,icon:n})=>(0,L.jsxs)(`button`,{onClick:()=>p(e),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors min-h-[44px] ${f===e?`bg-white text-surface-900 shadow-sm`:`text-surface-600 hover:text-surface-800`}`,children:[(0,L.jsx)(n,{className:`h-4 w-4`}),t]},e))}),f===`rollup`&&(0,L.jsx)(`div`,{className:`space-y-4`,children:e===null?(0,L.jsx)(G3,{icon:Kc,title:`No location data`,description:`Location revenue data will appear once QuickBooks or other sources are connected.`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,L.jsx)(W3,{label:`Locations`,value:String(e.locations.total_locations),color:`text-surface-800`}),(0,L.jsx)(W3,{label:`Total Revenue`,value:`$${e.locations.total_revenue.toLocaleString()}`,color:`text-emerald-600`}),(0,L.jsx)(W3,{label:`Avg / Location`,value:`$${Math.round(e.locations.avg_revenue_per_location).toLocaleString()}`,color:`text-surface-800`}),(0,L.jsx)(W3,{label:`Max Variance`,value:`${e.locations.max_variance_pct.toFixed(1)}%`,color:e.locations.max_variance_pct>50?`text-red-600`:`text-emerald-600`})]}),e.alerts.length>0&&(0,L.jsx)(`div`,{className:`space-y-2`,children:e.alerts.map((e,t)=>{let n={critical:`bg-red-50 border-red-200 text-red-800`,high:`bg-orange-50 border-orange-200 text-orange-800`,medium:`bg-amber-50 border-amber-200 text-amber-800`,low:`bg-blue-50 border-blue-200 text-blue-800`},r={concentration:Dc,underperformer:Cu,variance:Mc}[e.type]||Dc;return(0,L.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border p-4 ${n[e.severity]}`,children:[(0,L.jsx)(r,{className:`mt-0.5 h-5 w-5 shrink-0`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-black/10 px-2 py-0.5 text-xs font-medium uppercase`,children:e.type}),(0,L.jsx)(U3,{severity:e.severity,size:`sm`})]}),(0,L.jsx)(`p`,{className:`mt-1 text-sm font-medium`,children:e.location_name}),(0,L.jsx)(`p`,{className:`text-sm opacity-90`,children:e.message})]})]},t)})}),e.breakdown.length>0&&(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Location`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`Revenue`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`Transactions`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`Avg Transaction`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`% of Total`})]})}),(0,L.jsx)(`tbody`,{children:e.breakdown.map((e,t)=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 last:border-0 hover:bg-surface-50`,children:[(0,L.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Il,{className:`h-4 w-4 text-surface-400`}),(0,L.jsx)(`span`,{className:`font-medium text-surface-900`,children:e.location_name})]}),(0,L.jsx)(`code`,{className:`text-[10px] text-surface-400`,children:e.location_id})]}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-right font-medium text-emerald-700`,children:[`$`,e.revenue.toLocaleString()]}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-600`,children:e.transaction_count}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-right text-surface-600`,children:[`$`,Math.round(e.avg_transaction).toLocaleString()]}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(`div`,{className:`h-1.5 w-16 rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-1.5 rounded-full ${e.pct_of_total>50?`bg-red-500`:e.pct_of_total>30?`bg-amber-500`:`bg-emerald-500`}`,style:{width:`${Math.min(e.pct_of_total,100)}%`}})}),(0,L.jsxs)(`span`,{className:`text-surface-700 font-medium w-12 text-right`,children:[e.pct_of_total.toFixed(1),`%`]})]})})]},t))})]})})]})}),f===`comparison`&&(0,L.jsx)(`div`,{className:`space-y-4`,children:n===null?(0,L.jsx)(G3,{icon:mc,title:`No comparison data`,description:`Compare your locations side-by-side.`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,L.jsx)(W3,{label:`Locations`,value:String(n.comparison.total_locations),color:`text-surface-800`}),(0,L.jsx)(W3,{label:`Total Revenue`,value:`$${n.comparison.total_revenue.toLocaleString()}`,color:`text-emerald-600`}),(0,L.jsx)(W3,{label:`Avg Revenue`,value:`$${Math.round(n.comparison.avg_revenue).toLocaleString()}`,color:`text-surface-800`}),(0,L.jsx)(W3,{label:`Median Revenue`,value:`$${Math.round(n.comparison.median_revenue).toLocaleString()}`,color:`text-surface-800`})]}),(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-center font-medium text-surface-600 w-16`,children:`#`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Location`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`Revenue`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`vs Average`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`vs Median`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`% of Total`})]})}),(0,L.jsx)(`tbody`,{children:n.locations.map((e,t)=>{let n=e.vs_avg_pct>=100?wu:Cu,r=e.vs_avg_pct>=100?`text-emerald-600`:`text-red-600`,i=n;return(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 last:border-0 hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 text-center`,children:(0,L.jsx)(`span`,{className:`inline-flex h-6 w-6 items-center justify-center rounded-full text-xs font-bold ${e.ranking===1?`bg-amber-100 text-amber-700`:`bg-surface-100 text-surface-600`}`,children:e.ranking})}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Il,{className:`h-4 w-4 text-surface-400`}),(0,L.jsx)(`span`,{className:`font-medium text-surface-900`,children:e.location_name})]})}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-right font-medium text-emerald-700`,children:[`$`,e.revenue.toLocaleString()]}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-medium ${r}`,children:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,L.jsx)(i,{className:`h-3 w-3`}),e.vs_avg_pct-100>=0?`+`:``,(e.vs_avg_pct-100).toFixed(1),`%`]})}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-right font-medium ${e.vs_median_pct>=100?`text-emerald-600`:`text-red-600`}`,children:[e.vs_median_pct-100>=0?`+`:``,(e.vs_median_pct-100).toFixed(1),`%`]}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-right text-surface-700 font-medium`,children:[e.pct_of_total.toFixed(1),`%`]})]},t)})})]})})]})}),f===`detector`&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-600`,children:`Run the multi-location rollup detector to find concentration and variance issues.`}),(0,L.jsx)(`button`,{onClick:g,disabled:c,className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 transition-colors min-h-[44px]`,children:c?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Running...`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Ql,{className:`h-4 w-4`}),` Run Detector`]})})]}),i===null?(0,L.jsx)(G3,{icon:Dc,title:`No detector results yet`,description:`Click 'Run Detector' to analyze location concentration and variance.`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-3`,children:[(0,L.jsx)(W3,{label:`Detector`,value:i.detector,color:`text-surface-800`}),(0,L.jsx)(W3,{label:`Candidates`,value:String(i.candidates_found),color:i.candidates_found>0?`text-red-600`:`text-emerald-600`}),(0,L.jsx)(W3,{label:`Est. Exposure`,value:`$${i.candidates.reduce((e,t)=>e+(t.estimated_loss||0),0).toLocaleString()}`,color:`text-red-600`})]}),i.candidates.length>0?(0,L.jsx)(`div`,{className:`space-y-3`,children:i.candidates.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-lg border p-4 ${{critical:`bg-red-50 border-red-200 text-red-800`,high:`bg-orange-50 border-orange-200 text-orange-800`,medium:`bg-amber-50 border-amber-200 text-amber-800`,low:`bg-blue-50 border-blue-200 text-blue-800`}[e.severity]}`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(U3,{severity:e.severity,size:`sm`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase opacity-70`,children:e.type})]}),e.estimated_loss&&(0,L.jsxs)(`span`,{className:`text-sm font-semibold`,children:[`$`,e.estimated_loss.toLocaleString()]})]}),(0,L.jsx)(`p`,{className:`mt-1 text-sm font-medium`,children:e.location_name}),(0,L.jsx)(`p`,{className:`mt-0.5 text-sm opacity-90`,children:e.message})]},e.dedupe_key))}):(0,L.jsxs)(`div`,{className:`rounded-xl border border-emerald-200 bg-emerald-50 p-6 text-center`,children:[(0,L.jsx)(bc,{className:`mx-auto h-10 w-10 text-emerald-600`}),(0,L.jsx)(`p`,{className:`mt-2 text-sm font-medium text-emerald-800`,children:`No issues found`}),(0,L.jsx)(`p`,{className:`text-sm text-emerald-600`,children:`All locations are performing within expected parameters.`})]})]})]})]})}function X3({companyId:e}){let[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)(!0),[a,o]=(0,S.useState)(30),s=(0,S.useCallback)(async()=>{try{i(!0),n(await F$(e,a))}catch{n(null)}finally{i(!1)}},[e,a]);if((0,S.useEffect)(()=>{s()},[s]),r)return(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,L.jsx)(K,{className:`h-5 w-5 animate-spin text-brand-600`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading stats…`})]});let c=t?.stats;return c?(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-700`,children:`Resolution performance`}),(0,L.jsxs)(`select`,{value:a,onChange:e=>o(Number(e.target.value)),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:7,children:`Last 7 days`}),(0,L.jsx)(`option`,{value:14,children:`Last 14 days`}),(0,L.jsx)(`option`,{value:30,children:`Last 30 days`}),(0,L.jsx)(`option`,{value:90,children:`Last 90 days`})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,L.jsx)(W3,{label:`Resolved`,value:String(c.total_resolved||0),color:`text-emerald-600`}),(0,L.jsx)(W3,{label:`Avg Resolution`,value:`${(c.avg_resolution_time_hours||0).toFixed(1)}h`,color:`text-surface-800`}),(0,L.jsx)(W3,{label:`Recurring`,value:`${c.recurring_count||0}`,sub:`${(c.recurring_pct||0).toFixed(0)}% of total`,color:`text-red-600`}),(0,L.jsx)(W3,{label:`Period`,value:`${t?.days||a}d`,color:`text-surface-800`})]}),c.by_severity&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`h4`,{className:`mb-4 text-sm font-semibold text-surface-800`,children:`Resolutions by Severity`}),(0,L.jsx)(`div`,{className:`space-y-3`,children:[`critical`,`high`,`medium`,`low`].map(e=>{let t=c.by_severity[e]||0,n=c.total_resolved||1,r=Math.round(t/n*100);return(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(U3,{severity:e,size:`sm`}),(0,L.jsx)(`div`,{className:`flex-1`,children:(0,L.jsx)(`div`,{className:`h-2 w-full rounded-full bg-surface-100`,children:(0,L.jsx)(`div`,{className:`h-2 rounded-full transition-all ${V3[e]}`,style:{width:`${r}%`}})})}),(0,L.jsx)(`span`,{className:`w-8 text-right text-sm font-medium text-surface-700`,children:t})]},e)})})]})]}):(0,L.jsx)(G3,{icon:mc,title:`No stats available`,description:`Try connecting your integrations to generate data.`})}function Z3({companyId:e}){let[t,n]=(0,S.useState)(null),[r,i]=(0,S.useState)([]),[a,o]=(0,S.useState)(!0),[s,c]=(0,S.useState)(!1),l=(0,S.useCallback)(async()=>{try{o(!0);let[t,r]=await Promise.all([R$(e),I$(e)]);n(t),i(Array.isArray(r.severity_rules)?r.severity_rules:[])}catch{}finally{o(!1)}},[e]);(0,S.useEffect)(()=>{l()},[l]);let u=async()=>{if(t)try{c(!0),n(await z$(e,t.alert_settings))}catch{}finally{c(!1)}},d=async()=>{try{c(!0);let t=await L$(e,r);i(Array.isArray(t.severity_rules)?t.severity_rules:[])}catch{}finally{c(!1)}},f=(e,t)=>{n(n=>n&&{...n,alert_settings:{...n.alert_settings,[e]:t}})},p=(e,t,n)=>{i(r=>{let i=[...r];return i[e]={...i[e],[t]:n},i})},m=()=>{i(e=>[...e,{min_loss:0,min_recurrence:1,severity:`medium`}])},h=e=>{i(t=>t.filter((t,n)=>n!==e))};return a?(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,L.jsx)(K,{className:`h-5 w-5 animate-spin text-brand-600`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading settings…`})]}):(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`h4`,{className:`mb-4 flex items-center gap-2 text-sm font-semibold text-surface-800`,children:[(0,L.jsx)(Uc,{className:`h-4 w-4 text-surface-500`}),`Slack Alerts`]}),t?.slack_connected===!1&&(0,L.jsxs)(`div`,{className:`mb-4 rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-700`,children:[`No Slack connector found. Connect Slack in `,(0,L.jsx)(`strong`,{children:`Integrations`}),` first.`]}),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-700`,children:`Enable Alerts`}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Send leak alerts to Slack`})]}),(0,L.jsx)(`button`,{onClick:()=>f(`enabled`,!t?.alert_settings.enabled),className:`relative h-6 w-11 rounded-full transition-colors ${t?.alert_settings.enabled?`bg-brand-600`:`bg-surface-300`}`,children:(0,L.jsx)(`span`,{className:`absolute top-0.5 h-5 w-5 rounded-full bg-white shadow transition-transform ${t?.alert_settings.enabled?`translate-x-5`:`translate-x-0.5`}`})})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Slack Channel`}),(0,L.jsx)(`input`,{type:`text`,value:t?.alert_settings.slack_channel||``,onChange:e=>f(`slack_channel`,e.target.value),placeholder:`#revenue-alerts`,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),t?.slack_workspaces&&t.slack_workspaces.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Workspace`}),(0,L.jsxs)(`select`,{value:t.alert_settings.slack_connector_id||``,onChange:e=>f(`slack_connector_id`,e.target.value),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:``,children:`Select workspace...`}),t.slack_workspaces.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.workspace},e.id))]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Minimum Severity Threshold`}),(0,L.jsxs)(`select`,{value:t?.alert_settings.severity_threshold||`high`,onChange:e=>f(`severity_threshold`,e.target.value),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`critical`,children:`Critical only`}),(0,L.jsx)(`option`,{value:`high`,children:`High and above`}),(0,L.jsx)(`option`,{value:`medium`,children:`Medium and above`}),(0,L.jsx)(`option`,{value:`low`,children:`All`})]})]}),(0,L.jsx)(`button`,{onClick:u,disabled:s,className:`rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 transition-colors`,children:s?`Saving...`:`Save Alert Settings`})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsxs)(`h4`,{className:`flex items-center gap-2 text-sm font-semibold text-surface-800`,children:[(0,L.jsx)(fu,{className:`h-4 w-4 text-surface-500`}),`Severity Rules`]}),(0,L.jsx)(`button`,{onClick:m,className:`rounded-lg border border-surface-300 px-3 py-1.5 text-xs font-medium text-surface-700 hover:bg-surface-50`,children:`+ Add Rule`})]}),r.length===0?(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`No custom severity rules. Add one to override default severity assignment.`}):(0,L.jsxs)(`div`,{className:`space-y-3`,children:[r.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-surface-200 p-3`,children:[(0,L.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2 sm:grid-cols-4`,children:[(0,L.jsx)(`input`,{type:`text`,value:e.detector_id||``,onChange:e=>p(t,`detector_id`,e.target.value),placeholder:`Detector ID`,className:`rounded-md border border-surface-300 py-1.5 px-2 text-xs outline-none focus:border-brand-500`}),(0,L.jsx)(`input`,{type:`text`,value:e.source||``,onChange:e=>p(t,`source`,e.target.value),placeholder:`Source`,className:`rounded-md border border-surface-300 py-1.5 px-2 text-xs outline-none focus:border-brand-500`}),(0,L.jsx)(`input`,{type:`number`,value:e.min_loss??``,onChange:e=>p(t,`min_loss`,e.target.value?Number(e.target.value):void 0),placeholder:`Min loss $`,className:`rounded-md border border-surface-300 py-1.5 px-2 text-xs outline-none focus:border-brand-500`}),(0,L.jsxs)(`select`,{value:e.severity,onChange:e=>p(t,`severity`,e.target.value),className:`rounded-md border border-surface-300 py-1.5 px-2 text-xs outline-none focus:border-brand-500 min-h-[32px]`,children:[(0,L.jsx)(`option`,{value:`low`,children:`Low`}),(0,L.jsx)(`option`,{value:`medium`,children:`Medium`}),(0,L.jsx)(`option`,{value:`high`,children:`High`}),(0,L.jsx)(`option`,{value:`critical`,children:`Critical`})]})]}),(0,L.jsx)(`button`,{onClick:()=>h(t),className:`rounded p-1 text-surface-400 hover:bg-red-50 hover:text-red-600`,children:(0,L.jsx)(Iu,{className:`h-4 w-4`})})]},t)),(0,L.jsx)(`button`,{onClick:d,disabled:s,className:`rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 transition-colors`,children:s?`Saving...`:`Save Severity Rules`})]})]})]})}function Q3(){let{user:e}=W(),t=e?.tenantId,[n,r]=(0,S.useState)(`leaks`),[i,a]=(0,S.useState)([]),[o,s]=(0,S.useState)(!0),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(null),[m,h]=(0,S.useState)(``),[g,_]=(0,S.useState)(`all`),[v,y]=(0,S.useState)(`all`),[b,x]=(0,S.useState)(null),C=(0,S.useCallback)(async()=>{if(t)try{s(!0),a(await O$(t)),p(null)}catch(e){p(e instanceof Error?e.message:`Failed to load revenue leaks`)}finally{s(!1)}},[t]);(0,S.useEffect)(()=>{C()},[C]);let w=async()=>{if(t)try{l(!0),p(null),d(await A$(t)),await C(),setTimeout(()=>d(null),5e3)}catch(e){p(e instanceof Error?e.message:`Scan failed`)}finally{l(!1)}},T=i.filter(e=>g===`all`||e.severity===g).filter(e=>v===`active`?!e.resolved:v===`resolved`?e.resolved:!0).filter(e=>m===``||e.source.toLowerCase().includes(m.toLowerCase())||e.description.toLowerCase().includes(m.toLowerCase())),E=i.filter(e=>!e.resolved).length,D=i.filter(e=>!e.resolved&&e.estimated_loss).reduce((e,t)=>e+(t.estimated_loss??0),0);return(0,L.jsx)($,{title:`Revenue Leaks`,children:(0,L.jsxs)(`div`,{"data-testid":`page-content`,className:`space-y-6`,children:[u&&(0,L.jsx)(`div`,{className:`rounded-xl border border-brand-200 bg-brand-50 p-4 animate-pulse`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(Ru,{className:`h-5 w-5 text-brand-600`}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`p`,{className:`text-sm font-semibold text-brand-800`,children:[`Scan complete — `,u.new_leaks,` new leak`,u.new_leaks===1?``:`s`,` found`]}),(0,L.jsxs)(`p`,{className:`text-xs text-brand-600`,children:[u.scanned,` detectors scanned · `,u.total_leaks,` total leaks`]})]}),(0,L.jsx)(`button`,{onClick:()=>d(null),className:`ml-auto text-brand-400 hover:text-brand-600`,children:(0,L.jsx)(Iu,{className:`h-4 w-4`})})]})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,L.jsx)(W3,{label:`Active Leaks`,value:String(E),sub:`${i.length} total`,color:`text-surface-900`}),(0,L.jsx)(W3,{label:`Estimated Monthly Loss`,value:`$${D.toLocaleString()}`,color:`text-red-600`}),(0,L.jsx)(W3,{label:`Resolved`,value:String(i.length-E),color:`text-emerald-600`})]}),(0,L.jsx)(`div`,{className:`flex gap-1 rounded-lg bg-surface-100 p-1`,children:H3.map(({key:e,label:t,icon:i})=>(0,L.jsxs)(`button`,{onClick:()=>r(e),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors min-h-[44px] ${n===e?`bg-white text-surface-900 shadow-sm`:`text-surface-600 hover:text-surface-800`}`,children:[(0,L.jsx)(i,{className:`h-4 w-4`}),t]},e))}),f&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-red-800`,children:f}),(0,L.jsx)(`button`,{onClick:()=>p(null),className:`mt-1 text-sm text-red-600 underline`,children:`Dismiss`})]}),n===`leaks`&&(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 sm:flex-initial`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`Search leaks...`,className:`w-full rounded-lg border border-surface-300 py-2 pl-9 pr-4 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100 sm:w-64`})]}),(0,L.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`all`,children:`All Severities`}),(0,L.jsx)(`option`,{value:`critical`,children:`Critical`}),(0,L.jsx)(`option`,{value:`high`,children:`High`}),(0,L.jsx)(`option`,{value:`medium`,children:`Medium`}),(0,L.jsx)(`option`,{value:`low`,children:`Low`})]}),(0,L.jsxs)(`select`,{value:v,onChange:e=>y(e.target.value),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`all`,children:`All Status`}),(0,L.jsx)(`option`,{value:`active`,children:`Active`}),(0,L.jsx)(`option`,{value:`resolved`,children:`Resolved`})]})]}),(0,L.jsx)(`button`,{onClick:w,disabled:c,className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 transition-colors min-h-[44px]`,children:c?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}),` Scanning...`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Ql,{className:`h-4 w-4`}),` Run Scan`]})})]}),o?(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,L.jsx)(K,{className:`h-5 w-5 animate-spin text-brand-600`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading revenue leaks…`})]}):T.length===0?(0,L.jsx)(G3,{icon:jc,title:m||g!==`all`||v!==`all`?`No leaks match your filters`:`No revenue leaks detected`,description:m||g!==`all`||v!==`all`?`Try adjusting your filters or run a new scan`:`Run a scan to detect revenue leaks from your connected integrations`}):(0,L.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-surface-200 bg-white`,children:[(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Source`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Severity`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`Est. Loss`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Status`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Detected`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600 w-12`})]})}),(0,L.jsx)(`tbody`,{children:T.map(e=>(0,L.jsxs)(`tr`,{onClick:()=>x(e),className:`cursor-pointer border-b border-surface-100 last:border-0 hover:bg-brand-50/50 transition-colors`,children:[(0,L.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,L.jsx)(`div`,{className:`font-medium text-surface-900`,children:e.source}),e.description&&(0,L.jsx)(`div`,{className:`max-w-xs truncate text-xs text-surface-500`,children:e.description}),e.metadata_json?.detector_id&&(0,L.jsx)(`code`,{className:`mt-0.5 block font-mono text-[10px] text-surface-400`,children:e.metadata_json.detector_id})]}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(U3,{severity:e.severity,size:`sm`})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:e.estimated_loss?(0,L.jsxs)(`span`,{className:`font-medium text-red-600`,children:[`$`,e.estimated_loss.toLocaleString()]}):(0,L.jsx)(`span`,{className:`text-surface-400`,children:`—`})}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:e.resolved?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-100 px-2 py-0.5 text-xs font-medium text-emerald-700`,children:[(0,L.jsx)(bc,{className:`h-3 w-3`}),` Resolved`]}):(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-red-100 px-2 py-0.5 text-xs font-medium text-red-700`,children:[(0,L.jsx)(vc,{className:`h-3 w-3`}),` Active`]})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-xs text-surface-500`,children:K3(e.detected_at)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,L.jsx)(el,{className:`h-4 w-4 text-surface-400`})})]},e.id))})]})}),(0,L.jsxs)(`div`,{className:`border-t border-surface-200 bg-surface-50 px-4 py-2 text-xs text-surface-500`,children:[T.length,` of `,i.length,` leaks · Click a row for details`]})]})]}),n===`recurring`&&(0,L.jsx)(J3,{companyId:t}),n===`locations`&&(0,L.jsx)(Y3,{}),n===`stats`&&(0,L.jsx)(X3,{companyId:t}),n===`settings`&&(0,L.jsx)(Z3,{companyId:t}),b&&(0,L.jsx)(q3,{leak:b,companyId:t,onClose:()=>x(null),onRefresh:C})]})})}var $3={recommended:`bg-blue-100 text-blue-700 border-blue-200`,accepted:`bg-emerald-100 text-emerald-700 border-emerald-200`,rejected:`bg-red-100 text-red-700 border-red-200`,implemented:`bg-purple-100 text-purple-700 border-purple-200`},e6={budget_shift:Lc,channel_change:mc,target_audience:yu};function t6(){let{user:e}=W(),t=e?.tenantId,[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)(!0),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(``),[m,h]=(0,S.useState)(`all`),[g,_]=(0,S.useState)(`all`),[v,y]=(0,S.useState)({move_type:`budget_shift`,description:``,source_channel:``,target_channel:``,current_spend:null,recommended_spend:null,expected_impact:null,confidence:null}),b=(0,S.useCallback)(async()=>{if(t)try{a(!0),r(await x$(t)),s(null)}catch(e){s(e instanceof Error?e.message:`Failed to load optimization moves`)}finally{a(!1)}},[t]);(0,S.useEffect)(()=>{b()},[b]);let x=async e=>{if(e.preventDefault(),t)try{u?await C$(t,u.id,v):await S$(t,v),l(!1),d(null),y({move_type:`budget_shift`,description:``,source_channel:``,target_channel:``,current_spend:null,recommended_spend:null,expected_impact:null,confidence:null}),await b()}catch(e){s(e instanceof Error?e.message:`Failed to save optimization move`)}},C=async e=>{if(t)try{await T$(t,e.id),await b()}catch(e){s(e instanceof Error?e.message:`Failed to accept move`)}},w=async e=>{if(t)try{await E$(t,e.id),await b()}catch(e){s(e instanceof Error?e.message:`Failed to reject move`)}},T=async e=>{if(t&&confirm(`Delete this optimization move?`))try{await w$(t,e.id),await b()}catch(e){s(e instanceof Error?e.message:`Failed to delete move`)}},E=e=>{d(e),y({move_type:e.move_type,description:e.description,source_channel:e.source_channel,target_channel:e.target_channel,current_spend:e.current_spend,recommended_spend:e.recommended_spend,expected_impact:e.expected_impact,confidence:e.confidence}),l(!0)},D=n.filter(e=>m===`all`||e.status===m).filter(e=>g===`all`||e.move_type===g).filter(e=>f===``||e.description.toLowerCase().includes(f.toLowerCase())||e.source_channel.toLowerCase().includes(f.toLowerCase())),O=n.filter(e=>e.status===`recommended`).length,k=n.filter(e=>e.expected_impact&&e.status!==`rejected`).reduce((e,t)=>e+(t.expected_impact??0),0);return(0,L.jsx)($,{title:`Optimization Moves`,children:(0,L.jsxs)(`div`,{"data-testid":`page-content`,children:[(0,L.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Recommended`}),(0,L.jsx)(`p`,{className:`mt-2 text-3xl font-bold text-blue-600`,children:O})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Potential Impact`}),(0,L.jsxs)(`p`,{className:`mt-2 text-3xl font-bold text-emerald-600`,children:[`+$`,k.toLocaleString()]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Implemented`}),(0,L.jsx)(`p`,{className:`mt-2 text-3xl font-bold text-purple-600`,children:n.filter(e=>e.status===`implemented`).length})]})]}),(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 sm:flex-initial`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`Search moves...`,className:`w-full rounded-lg border border-surface-300 py-2 pl-9 pr-4 text-sm outline-none focus:border-brand-500 sm:w-64`})]}),(0,L.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`all`,children:`All Status`}),(0,L.jsx)(`option`,{value:`recommended`,children:`Recommended`}),(0,L.jsx)(`option`,{value:`accepted`,children:`Accepted`}),(0,L.jsx)(`option`,{value:`rejected`,children:`Rejected`}),(0,L.jsx)(`option`,{value:`implemented`,children:`Implemented`})]}),(0,L.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`all`,children:`All Types`}),(0,L.jsx)(`option`,{value:`budget_shift`,children:`Budget Shift`}),(0,L.jsx)(`option`,{value:`channel_change`,children:`Channel Change`}),(0,L.jsx)(`option`,{value:`target_audience`,children:`Target Audience`})]})]}),(0,L.jsxs)(`button`,{onClick:()=>{l(!0),d(null),y({move_type:`budget_shift`,description:``,source_channel:``,target_channel:``,current_spend:null,recommended_spend:null,expected_impact:null,confidence:null})},className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),` Add Move`]})]}),o&&(0,L.jsxs)(`div`,{className:`mb-4 rounded-xl border border-red-200 bg-red-50 p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-red-800`,children:o}),(0,L.jsx)(`button`,{onClick:()=>s(null),className:`mt-1 text-sm text-red-600 underline`,children:`Dismiss`})]}),c&&(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-white p-6 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:u?`Edit Move`:`New Optimization Move`}),(0,L.jsx)(`button`,{onClick:()=>l(!1),className:`rounded-lg p-1.5 text-surface-400 hover:bg-surface-100`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:x,className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Type`}),(0,L.jsxs)(`select`,{value:v.move_type,onChange:e=>y({...v,move_type:e.target.value}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`budget_shift`,children:`Budget Shift`}),(0,L.jsx)(`option`,{value:`channel_change`,children:`Channel Change`}),(0,L.jsx)(`option`,{value:`target_audience`,children:`Target Audience`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Confidence (%)`}),(0,L.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:v.confidence??``,onChange:e=>y({...v,confidence:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Description`}),(0,L.jsx)(`textarea`,{value:v.description,onChange:e=>y({...v,description:e.target.value}),rows:2,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 resize-none`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Source Channel`}),(0,L.jsx)(`input`,{type:`text`,value:v.source_channel,onChange:e=>y({...v,source_channel:e.target.value}),placeholder:`e.g. Google Ads`,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Target Channel`}),(0,L.jsx)(`input`,{type:`text`,value:v.target_channel,onChange:e=>y({...v,target_channel:e.target.value}),placeholder:`e.g. Facebook`,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Current Spend ($)`}),(0,L.jsx)(`input`,{type:`number`,value:v.current_spend??``,onChange:e=>y({...v,current_spend:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Recommended ($)`}),(0,L.jsx)(`input`,{type:`number`,value:v.recommended_spend??``,onChange:e=>y({...v,recommended_spend:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Expected Impact ($)`}),(0,L.jsx)(`input`,{type:`number`,value:v.expected_impact??``,onChange:e=>y({...v,expected_impact:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`rounded-lg border border-surface-300 px-4 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,className:`rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:u?`Update`:`Create`})]})]})]})}),i?(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,L.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-brand-600 border-t-transparent`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading optimization moves…`})]}):D.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(Ru,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:f||m!==`all`?`No moves match your filters`:`No optimization moves yet`})]}):(0,L.jsx)(`div`,{className:`space-y-3`,children:D.map(e=>(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:(0,L.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`mt-1 rounded-lg bg-brand-50 p-2 text-brand-600`,children:(0,L.jsx)(e6[e.move_type]||Ru,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`font-semibold text-surface-900`,children:e.description||e.move_type}),(0,L.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium ${$3[e.status]}`,children:e.status})]}),e.source_channel&&e.target_channel&&(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-surface-500`,children:[(0,L.jsx)(`span`,{children:e.source_channel}),(0,L.jsx)(Lc,{className:`h-3 w-3`}),(0,L.jsx)(`span`,{children:e.target_channel})]}),(0,L.jsxs)(`div`,{className:`mt-2 flex items-center gap-4 text-xs text-surface-500`,children:[e.current_spend&&(0,L.jsxs)(`span`,{children:[`Current: $`,e.current_spend.toLocaleString()]}),e.recommended_spend&&(0,L.jsxs)(`span`,{children:[`Recommended: $`,e.recommended_spend.toLocaleString()]}),e.expected_impact&&(0,L.jsxs)(`span`,{className:`text-emerald-600`,children:[`Impact: +$`,e.expected_impact.toLocaleString()]}),e.confidence&&(0,L.jsxs)(`span`,{children:[`Confidence: `,e.confidence,`%`]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.status===`recommended`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{onClick:()=>C(e),className:`rounded-lg p-1.5 text-surface-400 hover:bg-emerald-50 hover:text-emerald-600`,title:`Accept`,children:(0,L.jsx)(bc,{className:`h-4 w-4`})}),(0,L.jsx)(`button`,{onClick:()=>w(e),className:`rounded-lg p-1.5 text-surface-400 hover:bg-red-50 hover:text-red-600`,title:`Reject`,children:(0,L.jsx)(Sc,{className:`h-4 w-4`})})]}),(0,L.jsx)(`button`,{onClick:()=>E(e),className:`rounded-lg p-1.5 text-surface-400 hover:bg-surface-100 hover:text-surface-600`,title:`Edit`,children:(0,L.jsx)(Ac,{className:`h-4 w-4`})}),(0,L.jsx)(`button`,{onClick:()=>T(e),className:`rounded-lg p-1.5 text-surface-400 hover:bg-red-50 hover:text-red-600`,title:`Delete`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})]})]})},e.id))})]})})}var n6={revenue:dl,pipeline:mc,cost:wu},r6={quickbooks_invoices_paid:{label:`QB Invoices`,color:`bg-blue-100 text-blue-700`},quickbooks_transactions:{label:`QB Transactions`,color:`bg-indigo-100 text-indigo-700`},quickbooks_expenses:{label:`QB Expenses`,color:`bg-violet-100 text-violet-700`},crm_weighted_deals:{label:`CRM Deals`,color:`bg-amber-100 text-amber-700`},rolling_3_month_average:{label:`Auto Projection`,color:`bg-slate-100 text-slate-600`},manual:{label:`Manual`,color:`bg-orange-100 text-orange-700`}};function i6(e){if(!e)return null;let t=r6[e];return t?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium ${t.color}`,children:[(0,L.jsx)(ul,{className:`h-2.5 w-2.5`}),t.label]}):null}function a6(){let{user:e}=W(),t=e?.tenantId,[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)(!0),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(``),[m,h]=(0,S.useState)(`all`),[g,_]=(0,S.useState)(!1),[v,y]=(0,S.useState)(null),[b,x]=(0,S.useState)(null),[C,w]=(0,S.useState)({forecast_type:`revenue`,period:`monthly`,period_start:``,period_end:``,projected_value:0,actual_value:null,confidence:null,methodology:``}),T=(0,S.useCallback)(async()=>{if(t)try{a(!0),r(await m$(t)),s(null)}catch(e){s(e instanceof Error?e.message:`Failed to load forecasts`)}finally{a(!1)}},[t]);(0,S.useEffect)(()=>{T(),t&&y$(t).then(e=>x(e.last_sync)).catch(()=>{})},[T,t]);let E=async e=>{if(e.preventDefault(),t)try{u?await g$(t,u.id,C):await h$(t,C),l(!1),d(null),w({forecast_type:`revenue`,period:`monthly`,period_start:``,period_end:``,projected_value:0,actual_value:null,confidence:null,methodology:``}),await T()}catch(e){s(e instanceof Error?e.message:`Failed to save forecast`)}},D=async e=>{if(t&&confirm(`Delete this forecast?`))try{await _$(t,e.id),await T()}catch(e){s(e instanceof Error?e.message:`Failed to delete forecast`)}},O=async()=>{if(t){_(!0),y(null),s(null);try{y(await v$(t)),await T(),x((await y$(t)).last_sync)}catch(e){s(e instanceof Error?e.message:`Sync failed`)}finally{_(!1)}}},k=e=>{d(e),w({forecast_type:e.forecast_type,period:e.period,period_start:e.period_start?.substring(0,10)||``,period_end:e.period_end?.substring(0,10)||``,projected_value:e.projected_value,actual_value:e.actual_value,confidence:e.confidence,methodology:e.methodology}),l(!0)},A=n.filter(e=>m===`all`||e.forecast_type===m).filter(e=>f===``||e.period.toLowerCase().includes(f.toLowerCase())||e.methodology.toLowerCase().includes(f.toLowerCase())),j=n.reduce((e,t)=>e+t.projected_value,0),M=n.filter(e=>e.actual_value!==null).reduce((e,t)=>e+(t.actual_value??0),0),N=j>0?(M-j)/j*100:0;return(0,L.jsx)($,{title:`Forecasts`,children:(0,L.jsxs)(`div`,{"data-testid":`page-content`,children:[v&&(0,L.jsxs)(`div`,{className:`mb-4 rounded-xl border border-emerald-200 bg-emerald-50 p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(yc,{className:`h-5 w-5 text-emerald-600 flex-shrink-0 mt-0.5`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-semibold text-emerald-800`,children:`Sync Complete`}),(0,L.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-4 gap-y-1 text-xs text-emerald-700`,children:[(0,L.jsxs)(`span`,{children:[`Revenue: `,v.revenue_updated,` updated`]}),(0,L.jsxs)(`span`,{children:[`Pipeline: `,v.pipeline_updated,` updated`]}),(0,L.jsxs)(`span`,{children:[`Cost: `,v.cost_updated,` updated`]}),(0,L.jsxs)(`span`,{children:[`Future periods: `,v.future_created,` created`]}),(0,L.jsxs)(`span`,{className:`text-emerald-500`,children:[(v.duration_seconds*1e3).toFixed(0),`ms`]})]})]})]}),(0,L.jsx)(`button`,{onClick:()=>y(null),className:`text-emerald-400 hover:text-emerald-600`,children:(0,L.jsx)(Iu,{className:`h-4 w-4`})})]}),v.errors.length>0&&(0,L.jsxs)(`div`,{className:`mt-2 flex items-start gap-2 rounded-lg bg-amber-50 p-2`,children:[(0,L.jsx)(vc,{className:`h-4 w-4 text-amber-500 flex-shrink-0 mt-0.5`}),(0,L.jsx)(`p`,{className:`text-xs text-amber-700`,children:v.errors.join(`, `)})]})]}),(0,L.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Total Projected`}),(0,L.jsxs)(`p`,{className:`mt-2 text-3xl font-bold text-blue-600`,children:[`$`,j.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Total Actual`}),(0,L.jsxs)(`p`,{className:`mt-2 text-3xl font-bold text-emerald-600`,children:[`$`,M.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Overall Variance`}),(0,L.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 text-3xl font-bold ${N>=0?`text-emerald-600`:`text-red-600`}`,children:[N>=0?(0,L.jsx)(Rc,{className:`h-6 w-6`}):(0,L.jsx)(Nc,{className:`h-6 w-6`}),(0,L.jsxs)(`span`,{children:[Math.abs(N).toFixed(1),`%`]})]})]})]}),(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 sm:flex-initial`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`Search forecasts...`,className:`w-full rounded-lg border border-surface-300 py-2 pl-9 pr-4 text-sm outline-none focus:border-brand-500 sm:w-64`})]}),(0,L.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`all`,children:`All Types`}),(0,L.jsx)(`option`,{value:`revenue`,children:`Revenue`}),(0,L.jsx)(`option`,{value:`pipeline`,children:`Pipeline`}),(0,L.jsx)(`option`,{value:`cost`,children:`Cost`})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b&&(0,L.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-surface-400`,children:[(0,L.jsx)(al,{className:`h-3 w-3`}),`Last sync: `,new Date(b).toLocaleDateString()]}),(0,L.jsxs)(`button`,{onClick:O,disabled:g,className:`inline-flex items-center gap-2 rounded-lg border border-brand-600 px-4 py-2.5 text-sm font-medium text-brand-600 hover:bg-brand-50 disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(nu,{className:`h-4 w-4 ${g?`animate-spin`:``}`}),g?`Syncing…`:`Sync Now`]}),(0,L.jsxs)(`button`,{onClick:()=>{l(!0),d(null),w({forecast_type:`revenue`,period:`monthly`,period_start:``,period_end:``,projected_value:0,actual_value:null,confidence:null,methodology:``})},className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),` Add Forecast`]})]})]}),o&&(0,L.jsxs)(`div`,{className:`mb-4 rounded-xl border border-red-200 bg-red-50 p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-red-800`,children:o}),(0,L.jsx)(`button`,{onClick:()=>s(null),className:`mt-1 text-sm text-red-600 underline`,children:`Dismiss`})]}),c&&(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-white p-6 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:u?`Edit Forecast`:`New Forecast`}),(0,L.jsx)(`button`,{onClick:()=>l(!1),className:`rounded-lg p-1.5 text-surface-400 hover:bg-surface-100`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:E,className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Type`}),(0,L.jsxs)(`select`,{value:C.forecast_type,onChange:e=>w({...C,forecast_type:e.target.value}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`revenue`,children:`Revenue`}),(0,L.jsx)(`option`,{value:`pipeline`,children:`Pipeline`}),(0,L.jsx)(`option`,{value:`cost`,children:`Cost`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Period`}),(0,L.jsx)(`input`,{type:`text`,value:C.period,onChange:e=>w({...C,period:e.target.value}),placeholder:`e.g. monthly, Q1`,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Start Date`}),(0,L.jsx)(`input`,{type:`date`,value:C.period_start,onChange:e=>w({...C,period_start:e.target.value}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`End Date`}),(0,L.jsx)(`input`,{type:`date`,value:C.period_end,onChange:e=>w({...C,period_end:e.target.value}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Projected Value ($)`}),(0,L.jsx)(`input`,{type:`number`,value:C.projected_value,onChange:e=>w({...C,projected_value:Number(e.target.value)}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Actual Value ($)`}),(0,L.jsx)(`input`,{type:`number`,value:C.actual_value??``,onChange:e=>w({...C,actual_value:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Methodology`}),(0,L.jsx)(`input`,{type:`text`,value:C.methodology,onChange:e=>w({...C,methodology:e.target.value}),placeholder:`e.g. Historical average, Moving trend`,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Confidence (%)`}),(0,L.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:C.confidence??``,onChange:e=>w({...C,confidence:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`rounded-lg border border-surface-300 px-4 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,className:`rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:u?`Update`:`Create`})]})]})]})}),i?(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,L.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-brand-600 border-t-transparent`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading forecasts…`})]}):A.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(hc,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:f||m!==`all`?`No forecasts match your filters`:`No forecasts yet`})]}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Period`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Type`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Source`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`Projected`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`Actual`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`Variance`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-surface-600`,children:`Actions`})]})}),(0,L.jsx)(`tbody`,{children:A.map(e=>{let t=n6[e.forecast_type]||hc,n=e.actual_value===null?null:(e.actual_value-e.projected_value)/e.projected_value*100;return(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 last:border-0 hover:bg-surface-50 transition-colors`,children:[(0,L.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 text-surface-700`,children:[(0,L.jsx)(Yc,{className:`h-3 w-3 text-surface-400`}),e.period]}),e.period_start&&(0,L.jsxs)(`div`,{className:`text-xs text-surface-400`,children:[e.period_start.substring(0,10),` – `,e.period_end?.substring(0,10)]})]}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(t,{className:`h-3.5 w-3.5 text-surface-400`}),(0,L.jsx)(`span`,{className:`capitalize text-surface-700`,children:e.forecast_type})]})}),(0,L.jsxs)(`td`,{className:`px-4 py-3`,children:[i6(e.methodology),!e.methodology&&e.actual_value!==null&&(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:`Manual`})]}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-right font-medium text-surface-900`,children:[`$`,e.projected_value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-700`,children:e.actual_value===null?`—`:`$${e.actual_value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:n===null?`—`:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-1 ${n>=0?`text-emerald-600`:`text-red-600`}`,children:[n>=0?(0,L.jsx)(Rc,{className:`h-3 w-3`}):(0,L.jsx)(Nc,{className:`h-3 w-3`}),(0,L.jsxs)(`span`,{children:[Math.abs(n).toFixed(1),`%`]})]})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,L.jsx)(`button`,{onClick:()=>k(e),className:`rounded-lg p-1.5 text-surface-400 hover:bg-surface-100 hover:text-surface-600`,title:`Edit`,children:(0,L.jsx)(Ac,{className:`h-4 w-4`})}),(0,L.jsx)(`button`,{onClick:()=>D(e),className:`rounded-lg p-1.5 text-surface-400 hover:bg-red-50 hover:text-red-600`,title:`Delete`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})]})})]},e.id)})})]})})]})})}var o6={active:`bg-emerald-100 text-emerald-700 border-emerald-200`,completed:`bg-blue-100 text-blue-700 border-blue-200`,cancelled:`bg-red-100 text-red-700 border-red-200`,pending:`bg-amber-100 text-amber-700 border-amber-200`};function s6(){let{user:e}=W(),t=e?.tenantId,[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)(!0),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(``),[m,h]=(0,S.useState)(`all`),[g,_]=(0,S.useState)({coach_id:``,rep_id:``,focus_area:``,description:``,start_date:null,end_date:null,status:`active`}),v=(0,S.useCallback)(async()=>{if(t)try{a(!0),r(await n$(t)),s(null)}catch(e){s(e instanceof Error?e.message:`Failed to load coaching assignments`)}finally{a(!1)}},[t]);(0,S.useEffect)(()=>{v()},[v]);let y=async e=>{if(e.preventDefault(),t)try{u?await i$(t,u.id,g):await r$(t,g),l(!1),d(null),_({coach_id:``,rep_id:``,focus_area:``,description:``,start_date:null,end_date:null,status:`active`}),await v()}catch(e){s(e instanceof Error?e.message:`Failed to save assignment`)}},b=async e=>{if(t&&confirm(`Delete this coaching assignment?`))try{await a$(t,e.id),await v()}catch(e){s(e instanceof Error?e.message:`Failed to delete assignment`)}},x=e=>{d(e),_({coach_id:e.coach_id,rep_id:e.rep_id,focus_area:e.focus_area,description:e.description,start_date:e.start_date,end_date:e.end_date,status:e.status}),l(!0)},C=n.filter(e=>m===`all`||e.status===m).filter(e=>f===``||e.coach_name.toLowerCase().includes(f.toLowerCase())||e.rep_name.toLowerCase().includes(f.toLowerCase())||e.focus_area.toLowerCase().includes(f.toLowerCase())),w=n.filter(e=>e.status===`active`).length;return(0,L.jsxs)($,{title:`Coaching Assignments`,children:[(0,L.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Active Assignments`}),(0,L.jsx)(`p`,{className:`mt-2 text-3xl font-bold text-emerald-600`,children:w})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Total Assignments`}),(0,L.jsx)(`p`,{className:`mt-2 text-3xl font-bold text-surface-900`,children:n.length})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Completed`}),(0,L.jsx)(`p`,{className:`mt-2 text-3xl font-bold text-blue-600`,children:n.filter(e=>e.status===`completed`).length})]})]}),(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 sm:flex-initial`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`Search assignments...`,className:`w-full rounded-lg border border-surface-300 py-2 pl-9 pr-4 text-sm outline-none focus:border-brand-500 sm:w-64`})]}),(0,L.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`all`,children:`All Status`}),(0,L.jsx)(`option`,{value:`active`,children:`Active`}),(0,L.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,L.jsx)(`option`,{value:`cancelled`,children:`Cancelled`}),(0,L.jsx)(`option`,{value:`pending`,children:`Pending`})]})]}),(0,L.jsxs)(`button`,{onClick:()=>{l(!0),d(null),_({coach_id:``,rep_id:``,focus_area:``,description:``,start_date:null,end_date:null,status:`active`})},className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),` New Assignment`]})]}),o&&(0,L.jsxs)(`div`,{className:`mb-4 rounded-xl border border-red-200 bg-red-50 p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-red-800`,children:o}),(0,L.jsx)(`button`,{onClick:()=>s(null),className:`mt-1 text-sm text-red-600 underline`,children:`Dismiss`})]}),c&&(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl bg-white p-6 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:u?`Edit Assignment`:`New Coaching Assignment`}),(0,L.jsx)(`button`,{onClick:()=>l(!1),className:`rounded-lg p-1.5 text-surface-400 hover:bg-surface-100`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:y,className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Coach ID`}),(0,L.jsx)(`input`,{type:`text`,required:!0,value:g.coach_id,onChange:e=>_({...g,coach_id:e.target.value}),placeholder:`User ID`,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Rep ID`}),(0,L.jsx)(`input`,{type:`text`,required:!0,value:g.rep_id,onChange:e=>_({...g,rep_id:e.target.value}),placeholder:`User ID`,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Focus Area`}),(0,L.jsx)(`input`,{type:`text`,value:g.focus_area,onChange:e=>_({...g,focus_area:e.target.value}),placeholder:`e.g. Objection handling, Pipeline management`,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Description`}),(0,L.jsx)(`textarea`,{value:g.description,onChange:e=>_({...g,description:e.target.value}),rows:2,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 resize-none`})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Start Date`}),(0,L.jsx)(`input`,{type:`date`,value:g.start_date??``,onChange:e=>_({...g,start_date:e.target.value||null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`End Date`}),(0,L.jsx)(`input`,{type:`date`,value:g.end_date??``,onChange:e=>_({...g,end_date:e.target.value||null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Status`}),(0,L.jsxs)(`select`,{value:g.status,onChange:e=>_({...g,status:e.target.value}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`active`,children:`Active`}),(0,L.jsx)(`option`,{value:`pending`,children:`Pending`}),(0,L.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,L.jsx)(`option`,{value:`cancelled`,children:`Cancelled`})]})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`rounded-lg border border-surface-300 px-4 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,className:`rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:u?`Update`:`Create`})]})]})]})}),i?(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,L.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-brand-600 border-t-transparent`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading assignments…`})]}):C.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(Pu,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:f||m!==`all`?`No assignments match your filters`:`No coaching assignments yet`})]}):(0,L.jsx)(`div`,{className:`space-y-3`,children:C.map(e=>(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:(0,L.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`mt-1 rounded-lg bg-brand-50 p-2 text-brand-600`,children:(0,L.jsx)(Ou,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-semibold text-surface-900`,children:e.coach_name||e.coach_id}),(0,L.jsx)(Lc,{className:`h-3 w-3 text-surface-400`}),(0,L.jsx)(`span`,{className:`font-semibold text-surface-900`,children:e.rep_name||e.rep_id})]}),e.focus_area&&(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-600`,children:e.focus_area}),e.description&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:e.description}),(0,L.jsx)(`div`,{className:`mt-2 flex items-center gap-4 text-xs text-surface-400`,children:e.start_date&&(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(Yc,{className:`h-3 w-3`}),` `,e.start_date.substring(0,10),` → `,e.end_date?.substring(0,10)]})})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium ${o6[e.status]}`,children:[e.status===`active`||e.status===`completed`?(0,L.jsx)(bc,{className:`h-3 w-3`}):(0,L.jsx)(vc,{className:`h-3 w-3`}),e.status]}),(0,L.jsx)(`button`,{onClick:()=>x(e),className:`rounded-lg p-1.5 text-surface-400 hover:bg-surface-100 hover:text-surface-600`,title:`Edit`,children:(0,L.jsx)(Ac,{className:`h-4 w-4`})}),(0,L.jsx)(`button`,{onClick:()=>b(e),className:`rounded-lg p-1.5 text-surface-400 hover:bg-red-50 hover:text-red-600`,title:`Delete`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})]})]})},e.id))})]})}var c6=e=>e===null?`text-surface-400`:e>=80?`text-emerald-600`:e>=60?`text-amber-600`:`text-red-600`,l6=e=>e===null?``:e>=80?`bg-emerald-100 text-emerald-700`:e>=60?`bg-amber-100 text-amber-700`:`bg-red-100 text-red-700`;function u6(){let{user:e}=W(),t=e?.tenantId,[n,r]=(0,S.useState)([]),[i,a]=(0,S.useState)(!0),[o,s]=(0,S.useState)(null),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(``),[m,h]=(0,S.useState)({assignment_id:``,rep_id:``,evaluation_date:null,overall_score:null,communication_score:null,technical_score:null,closing_score:null,follow_up_score:null,strengths:``,improvement_areas:``,notes:``}),g=(0,S.useCallback)(async()=>{if(t)try{a(!0),r(await s$(t)),s(null)}catch(e){s(e instanceof Error?e.message:`Failed to load coaching scorecards`)}finally{a(!1)}},[t]);(0,S.useEffect)(()=>{g()},[g]);let _=async e=>{if(e.preventDefault(),t)try{u?await l$(t,u.id,m):await c$(t,m),l(!1),d(null),h({assignment_id:``,rep_id:``,evaluation_date:null,overall_score:null,communication_score:null,technical_score:null,closing_score:null,follow_up_score:null,strengths:``,improvement_areas:``,notes:``}),await g()}catch(e){s(e instanceof Error?e.message:`Failed to save scorecard`)}},v=async e=>{if(t&&confirm(`Delete this scorecard?`))try{await u$(t,e.id),await g()}catch(e){s(e instanceof Error?e.message:`Failed to delete scorecard`)}},y=e=>{d(e),h({assignment_id:e.assignment_id,rep_id:e.rep_id,evaluation_date:e.evaluation_date,overall_score:e.overall_score,communication_score:e.communication_score,technical_score:e.technical_score,closing_score:e.closing_score,follow_up_score:e.follow_up_score,strengths:e.strengths,improvement_areas:e.improvement_areas,notes:e.notes}),l(!0)},b=n.filter(e=>f===``||e.rep_name.toLowerCase().includes(f.toLowerCase())),x=n.filter(e=>e.overall_score!==null).length>0?n.filter(e=>e.overall_score!==null).reduce((e,t)=>e+(t.overall_score??0),0)/n.filter(e=>e.overall_score!==null).length:0;return(0,L.jsxs)($,{title:`Coaching Scorecards`,children:[(0,L.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-4 sm:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Total Scorecards`}),(0,L.jsx)(`p`,{className:`mt-2 text-3xl font-bold text-surface-900`,children:n.length})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Average Score`}),(0,L.jsxs)(`p`,{className:`mt-2 text-3xl font-bold text-blue-600`,children:[x.toFixed(1),`%`]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-500`,children:`Evaluations This Month`}),(0,L.jsx)(`p`,{className:`mt-2 text-3xl font-bold text-emerald-600`,children:n.filter(e=>e.evaluation_date&&e.evaluation_date.substring(0,7)===new Date().toISOString().substring(0,7)).length})]})]}),(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 sm:flex-initial`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`Search by rep name...`,className:`w-full rounded-lg border border-surface-300 py-2 pl-9 pr-4 text-sm outline-none focus:border-brand-500 sm:w-64`})]}),(0,L.jsxs)(`button`,{onClick:()=>{l(!0),d(null),h({assignment_id:``,rep_id:``,evaluation_date:null,overall_score:null,communication_score:null,technical_score:null,closing_score:null,follow_up_score:null,strengths:``,improvement_areas:``,notes:``})},className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),` New Scorecard`]})]}),o&&(0,L.jsxs)(`div`,{className:`mb-4 rounded-xl border border-red-200 bg-red-50 p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-red-800`,children:o}),(0,L.jsx)(`button`,{onClick:()=>s(null),className:`mt-1 text-sm text-red-600 underline`,children:`Dismiss`})]}),c&&(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-lg max-h-[90vh] overflow-y-auto rounded-xl bg-white p-6 shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:u?`Edit Scorecard`:`New Coaching Scorecard`}),(0,L.jsx)(`button`,{onClick:()=>l(!1),className:`rounded-lg p-1.5 text-surface-400 hover:bg-surface-100`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:_,className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Assignment ID`}),(0,L.jsx)(`input`,{type:`text`,required:!0,value:m.assignment_id,onChange:e=>h({...m,assignment_id:e.target.value}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Rep ID`}),(0,L.jsx)(`input`,{type:`text`,required:!0,value:m.rep_id,onChange:e=>h({...m,rep_id:e.target.value}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Evaluation Date`}),(0,L.jsx)(`input`,{type:`date`,value:m.evaluation_date??``,onChange:e=>h({...m,evaluation_date:e.target.value||null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-surface-200 p-4`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-700`,children:`Scores (0-100)`}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-xs font-medium text-surface-500`,children:`Overall`}),(0,L.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:m.overall_score??``,onChange:e=>h({...m,overall_score:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-xs font-medium text-surface-500`,children:`Communication`}),(0,L.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:m.communication_score??``,onChange:e=>h({...m,communication_score:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-xs font-medium text-surface-500`,children:`Technical`}),(0,L.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:m.technical_score??``,onChange:e=>h({...m,technical_score:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-xs font-medium text-surface-500`,children:`Closing`}),(0,L.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:m.closing_score??``,onChange:e=>h({...m,closing_score:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-xs font-medium text-surface-500`,children:`Follow-up`}),(0,L.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:m.follow_up_score??``,onChange:e=>h({...m,follow_up_score:e.target.value?Number(e.target.value):null}),className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500`})]})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Strengths`}),(0,L.jsx)(`textarea`,{value:m.strengths,onChange:e=>h({...m,strengths:e.target.value}),rows:2,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 resize-none`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Areas for Improvement`}),(0,L.jsx)(`textarea`,{value:m.improvement_areas,onChange:e=>h({...m,improvement_areas:e.target.value}),rows:2,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 resize-none`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700`,children:`Notes`}),(0,L.jsx)(`textarea`,{value:m.notes,onChange:e=>h({...m,notes:e.target.value}),rows:2,className:`mt-1 w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 resize-none`})]}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`rounded-lg border border-surface-300 px-4 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,className:`rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px]`,children:u?`Update`:`Create`})]})]})]})}),i?(0,L.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,L.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-brand-600 border-t-transparent`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading scorecards…`})]}):b.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(Bc,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:f?`No scorecards match your search`:`No coaching scorecards yet`})]}):(0,L.jsx)(`div`,{className:`space-y-3`,children:b.map(e=>(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:(0,L.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`font-semibold text-surface-900`,children:e.rep_name}),e.evaluation_date&&(0,L.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-surface-400`,children:[(0,L.jsx)(Yc,{className:`h-3 w-3`}),` `,e.evaluation_date.substring(0,10)]})]}),(0,L.jsx)(`div`,{className:`mt-3 grid grid-cols-5 gap-2`,children:[{label:`Overall`,value:e.overall_score,icon:gu},{label:`Comms`,value:e.communication_score,icon:q},{label:`Technical`,value:e.technical_score,icon:Gc},{label:`Closing`,value:e.closing_score,icon:yu},{label:`Follow-up`,value:e.follow_up_score,icon:Zl}].map(({label:e,value:t,icon:n})=>(0,L.jsxs)(`div`,{className:`rounded-lg border border-surface-200 p-2 text-center`,children:[(0,L.jsx)(n,{className:`mx-auto h-3 w-3 text-surface-400`}),(0,L.jsx)(`div`,{className:`mt-1 text-sm font-bold ${c6(t)}`,children:t===null?`—`:`${t}`}),(0,L.jsx)(`div`,{className:`text-[10px] text-surface-400`,children:e})]},e))}),(e.strengths||e.improvement_areas||e.notes)&&(0,L.jsxs)(`div`,{className:`mt-3 space-y-1 text-xs text-surface-500`,children:[e.strengths&&(0,L.jsxs)(`p`,{className:`text-emerald-600`,children:[`✓ `,e.strengths]}),e.improvement_areas&&(0,L.jsxs)(`p`,{className:`text-amber-600`,children:[`→ `,e.improvement_areas]}),e.notes&&(0,L.jsxs)(`p`,{className:`text-surface-500`,children:[`📝 `,e.notes]})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.overall_score!==null&&(0,L.jsxs)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-bold ${l6(e.overall_score)}`,children:[e.overall_score,`%`]}),(0,L.jsx)(`button`,{onClick:()=>y(e),className:`rounded-lg p-1.5 text-surface-400 hover:bg-surface-100 hover:text-surface-600`,title:`Edit`,children:(0,L.jsx)(Ac,{className:`h-4 w-4`})}),(0,L.jsx)(`button`,{onClick:()=>v(e),className:`rounded-lg p-1.5 text-surface-400 hover:bg-red-50 hover:text-red-600`,title:`Delete`,children:(0,L.jsx)(Su,{className:`h-4 w-4`})})]})]})},e.id))})]})}var d6=[{value:`owner`,label:`Owner`,color:`bg-purple-100 text-purple-700`},{value:`admin`,label:`Admin`,color:`bg-indigo-100 text-indigo-700`},{value:`manager`,label:`Manager`,color:`bg-amber-100 text-amber-700`},{value:`rep`,label:`Rep`,color:`bg-emerald-100 text-emerald-700`},{value:`viewer`,label:`Viewer`,color:`bg-slate-100 text-slate-600`}];function f6({memberId:e,currentRole:t,disabled:n}){let[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(null),s=(0,S.useRef)(null),c=ci(),l=z({mutationFn:({userId:e,role:t})=>$Q.updateRole(e,t),onSuccess:()=>{c.invalidateQueries({queryKey:[`team`]}),i(!1)}});(0,S.useEffect)(()=>{r&&s.current&&o(s.current.getBoundingClientRect())},[r]);let u=n=>{n!==t&&l.mutate({userId:e,role:n})},d=d6.find(e=>e.value===t),f=(0,L.jsx)(`div`,{className:`w-40 rounded-lg border border-surface-200 bg-white shadow-lg py-1`,style:{position:`fixed`,top:a?a.bottom+4:0,left:a?a.right-160:0,zIndex:100},children:d6.map(e=>(0,L.jsxs)(`button`,{onClick:()=>u(e.value),disabled:n,className:`flex w-full items-center gap-2 px-3 py-2 text-sm hover:bg-surface-50 disabled:opacity-50 disabled:cursor-not-allowed`,children:[t===e.value&&(0,L.jsx)(Xc,{className:`h-3.5 w-3.5 text-brand-600`}),(0,L.jsx)(`span`,{className:t===e.value?`text-brand-700 font-medium`:`text-surface-700`,children:e.label})]},e.value))});return(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(`button`,{ref:s,onClick:()=>!n&&i(!r),disabled:l.isPending||n,className:`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium disabled:opacity-50 min-w-[80px] justify-center ${n?`cursor-not-allowed`:`hover:opacity-80`}`,children:l.isPending?(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`rounded-full px-2.5 py-0.5 text-xs font-medium ${d?.color||`bg-gray-100 text-gray-600`}`,children:d?.label||t}),!n&&(0,L.jsx)(Zc,{className:`h-3 w-3 text-surface-400`})]})}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-[99]`,onClick:()=>i(!1)}),(0,yS.createPortal)(f,document.body)]})]})}function p6({onClose:e,onInvite:t,isPending:n,currentUserEmail:r}){let[i,a]=(0,S.useState)(``),[o,s]=(0,S.useState)(``),[c,l]=(0,S.useState)(`viewer`),[u,d]=(0,S.useState)(``);return(0,yS.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:e}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-md rounded-xl bg-white shadow-xl`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 p-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(ju,{className:`h-5 w-5 text-brand-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Invite Team Member`})]}),(0,L.jsx)(`button`,{onClick:e,className:`rounded-md p-1 text-surface-400 hover:text-surface-600`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),d(``),!i.trim()){d(`Email is required`);return}if(i.toLowerCase()===r.toLowerCase()){d(`You are already a team member`);return}t({email:i.trim(),name:o.trim(),role:c})},className:`p-5 space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Email *`}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(Fl,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`email`,required:!0,value:i,onChange:e=>{a(e.target.value),d(``)},className:`w-full rounded-lg border border-surface-300 py-2 pl-10 pr-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`colleague@company.com`})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Full Name`}),(0,L.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),className:`w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`Jane Smith`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Role`}),(0,L.jsx)(`select`,{value:c,onChange:e=>l(e.target.value),className:`w-full rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,children:d6.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,L.jsxs)(`p`,{className:`mt-1 text-xs text-surface-500`,children:[c===`viewer`&&`Can view dashboards and reports only.`,c===`rep`&&`Can view and manage their own data.`,c===`manager`&&`Can manage team, view analytics, and edit integrations.`,c===`admin`&&`Full access including team and settings management.`,c===`owner`&&`Complete control over the organization.`]})]}),u&&(0,L.jsx)(`p`,{className:`text-sm text-red-600`,children:u}),(0,L.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:e,disabled:n,className:`flex-1 rounded-lg border border-surface-300 py-2.5 px-4 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,disabled:n,className:`flex-1 rounded-lg bg-brand-600 py-2.5 px-4 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:n?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin mx-auto`}):`Invite Member`})]})]})]})]}),document.body)}function m6({member:e,onConfirm:t,onClose:n,isPending:r,isOwner:i}){return(0,yS.createPortal)((0,L.jsxs)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center p-4`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:n}),(0,L.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl bg-white shadow-xl p-6 text-center`,children:[(0,L.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-red-100`,children:(0,L.jsx)(jc,{className:`h-6 w-6 text-red-600`})}),(0,L.jsx)(`h3`,{className:`text-lg font-semibold text-surface-900 mb-2`,children:`Remove Team Member`}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500 mb-1`,children:[`Are you sure you want to remove`,` `,(0,L.jsx)(`strong`,{className:`text-surface-700`,children:e.name}),`?`]}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400 mb-6`,children:[e.email,` will lose access to the organization.`]}),i&&(0,L.jsxs)(`p`,{className:`text-xs text-amber-600 mb-4 bg-amber-50 rounded-md px-3 py-2`,children:[`This member is an `,(0,L.jsx)(`strong`,{children:`Owner`}),`. They will retain their ownership status but lose access to this organization.`]}),(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsx)(`button`,{onClick:n,disabled:r,className:`flex-1 rounded-lg border border-surface-300 py-2.5 px-4 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-50 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{onClick:t,disabled:r,className:`flex-1 rounded-lg bg-red-600 py-2.5 px-4 text-sm font-medium text-white hover:bg-red-700 disabled:opacity-50 min-h-[44px]`,children:r?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin mx-auto`}):`Remove`})]})]})]}),document.body)}function h6(){let{user:e}=W(),t=ci(),{data:n,isLoading:r,isError:i}=R({queryKey:[`team`],queryFn:()=>$Q.getTeam()}),a=n?.items??[],o=e?.email??``,s=z({mutationFn:e=>$Q.addMember(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`team`]})}}),c=z({mutationFn:e=>$Q.removeMember(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`team`]})}}),[l,u]=(0,S.useState)(!1),[d,f]=(0,S.useState)(null),p=(0,S.useCallback)(t=>e?.companyRole===`owner`?!0:e?.companyRole===`admin`?t.role!==`owner`:e?.companyRole===`manager`?[`rep`,`viewer`].includes(t.role):!1,[e?.companyRole]);return r?(0,L.jsx)($,{title:`Team`,children:(0,L.jsx)(FQ,{})}):(0,L.jsxs)($,{title:`Team`,children:[(0,L.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold text-surface-900`,children:`Team`}),(0,L.jsxs)(`p`,{className:`mt-1 text-sm text-surface-500`,children:[a.length,` team member`,a.length===1?``:`s`,` in your organization`]})]}),(0,L.jsxs)(`button`,{onClick:()=>u(!0),className:`inline-flex items-center justify-center gap-2 rounded-lg bg-brand-600 px-4 py-2.5 text-sm font-medium text-white hover:bg-brand-700 min-h-[44px] w-full sm:w-auto`,children:[(0,L.jsx)(ju,{className:`h-4 w-4`}),`Invite Member`]})]}),i?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(jc,{className:`h-12 w-12 text-red-400`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`Failed to load team members`}),(0,L.jsx)(`button`,{onClick:()=>t.invalidateQueries({queryKey:[`team`]}),className:`mt-3 text-sm text-brand-600 hover:text-brand-700`,children:`Try again`})]}):a.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(Pu,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No team members yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Invite your first team member to get started.`})]}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white`,children:(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`pb-3 pl-5 text-left font-medium text-surface-500`,children:`Member`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Role`}),(0,L.jsx)(`th`,{className:`pb-3 text-left font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`pb-3 text-right font-medium text-surface-500 pr-2`,children:`Last Login`}),(0,L.jsx)(`th`,{className:`pb-3 pr-5 w-10`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:a.map(e=>{let t=e.email===o,n=p(e);return(0,L.jsxs)(`tr`,{className:`hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`py-3 pl-5`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-brand-100 text-xs font-semibold text-brand-700`,children:e.name.charAt(0).toUpperCase()}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`p`,{className:`text-sm font-medium text-surface-900 truncate`,children:[e.name,t&&(0,L.jsx)(`span`,{className:`ml-1.5 text-[10px] font-normal text-surface-400`,children:`(you)`})]}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500 truncate`,children:e.email})]})]})}),(0,L.jsx)(`td`,{className:`py-3`,children:(0,L.jsx)(f6,{memberId:e.id,currentRole:e.role,disabled:!n||e.role===`owner`&&!t})}),(0,L.jsx)(`td`,{className:`py-3`,children:(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${e.status===`active`?`bg-emerald-50 text-emerald-700`:`bg-surface-100 text-surface-500`}`,children:e.status===`active`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Ou,{className:`mr-1 h-3 w-3`}),`Active`]}):e.status})}),(0,L.jsx)(`td`,{className:`py-3 text-right text-surface-500 pr-2`,children:e.lastLogin?new Date(e.lastLogin).toLocaleDateString():`Never`}),(0,L.jsx)(`td`,{className:`py-3 pr-5 text-right`,children:!t&&(0,L.jsx)(`button`,{onClick:()=>f(e),className:`inline-flex items-center justify-center rounded-md p-1.5 text-surface-400 hover:text-red-600 hover:bg-red-50 transition-colors`,title:`Remove member`,children:(0,L.jsx)(Au,{className:`h-4 w-4`})})})]},e.id)})})]})})}),l&&(0,L.jsx)(p6,{onClose:()=>u(!1),onInvite:e=>s.mutate(e),isPending:s.isPending,currentUserEmail:o}),d&&(0,L.jsx)(m6,{member:d,onConfirm:()=>{c.mutate(d.id),f(null)},onClose:()=>f(null),isPending:c.isPending,isOwner:d.role===`owner`})]})}var g6=e=>`/api/company/${e}/angi/leads`,_6={async getAll(e,t){return(await U.get(g6(e),{params:t})).data},async getOne(e,t){return(await U.get(`${g6(e)}/${t}`)).data},async update(e,t,n){return(await U.put(`${g6(e)}/${t}`,n)).data},async respond(e,t,n){return(await U.post(`${g6(e)}/${t}/respond`,n)).data},async accept(e,t){return(await U.post(`${g6(e)}/${t}/accept`)).data},async reject(e,t){return(await U.post(`${g6(e)}/${t}/reject`)).data},async getAnalytics(e){return(await U.get(`${g6(e)}/analytics`)).data},async sync(e){return(await U.post(`${g6(e)}/sync`)).data}};function v6(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);if(r<24)return`${r}h ago`;let i=Math.floor(r/24);return i<30?`${i}d ago`:new Date(e).toLocaleDateString()}function y6(e){return e==null||e===0?`—`:e>=1e3?`$${(e/1e3).toFixed(1)}k`:`$${e}`}function b6(e){return e<=5?`text-emerald-600 bg-emerald-50`:e<=30?`text-amber-600 bg-amber-50`:`text-red-600 bg-red-50`}function x6(e){return e==null||e===0?`—`:e<60?`${e}m`:`${Math.floor(e/60)}h ${e%60}m`}function S6(e){return{new:`bg-blue-100 text-blue-700`,accepted:`bg-indigo-100 text-indigo-700`,responded:`bg-violet-100 text-violet-700`,contacted:`bg-cyan-100 text-cyan-700`,scheduled:`bg-orange-100 text-orange-700`,won:`bg-emerald-100 text-emerald-700`,lost:`bg-red-100 text-red-700`,expired:`bg-slate-100 text-slate-600`,rejected:`bg-gray-100 text-gray-500`}[e]||`bg-gray-100 text-gray-600`}function C6(e){return e.charAt(0).toUpperCase()+e.slice(1)}function w6(e){return{high:`text-red-600 bg-red-50`,medium:`text-amber-600 bg-amber-50`,low:`text-slate-600 bg-slate-50`}[e]||``}function T6(e){return e.charAt(0).toUpperCase()+e.slice(1)}var E6=[`new`,`accepted`,`responded`,`contacted`,`scheduled`,`won`],D6=[`won`,`lost`,`expired`,`rejected`];function O6({lead:e}){let t=E6.indexOf(e.status);return(0,L.jsx)(`div`,{className:`flex items-center gap-1 overflow-x-auto py-2`,children:E6.map((n,r)=>{let i=r<=t&&!D6.includes(n),a=e.status===n,o=D6.includes(e.status)&&D6.includes(n);return(0,L.jsxs)(`div`,{className:`flex items-center`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium whitespace-nowrap ${a?`bg-brand-600 text-white`:i||o?`bg-emerald-100 text-emerald-700`:`bg-surface-100 text-surface-400`}`,children:[(i||o)&&(0,L.jsx)(Xc,{className:`h-3 w-3`}),C6(n)]}),r<E6.length-1&&(0,L.jsx)(Lc,{className:`h-3 w-3 text-surface-300 shrink-0 mx-0.5`})]},n)})})}function k6(e){switch(e){case`received`:return(0,L.jsx)(il,{className:`h-4 w-4 text-blue-500`});case`responded`:return(0,L.jsx)(q,{className:`h-4 w-4 text-violet-500`});case`accepted`:return(0,L.jsx)(yc,{className:`h-4 w-4 text-emerald-500`});case`rejected`:return(0,L.jsx)(Vc,{className:`h-4 w-4 text-red-500`});case`status_change`:return(0,L.jsx)(Lc,{className:`h-4 w-4 text-amber-500`});case`note`:return(0,L.jsx)(vc,{className:`h-4 w-4 text-slate-400`});default:return(0,L.jsx)(vc,{className:`h-4 w-4 text-slate-400`})}}function A6({lead:e,onClose:t,onAction:n}){let{user:r}=W(),i=r?.tenantId,a=ci(),[o,s]=(0,S.useState)(e.internal_notes||``),[c,l]=(0,S.useState)(!1),[u,d]=(0,S.useState)(``),[f,p]=(0,S.useState)(!1),m=z({mutationFn:t=>_6.update(i,e.id,t),onSuccess:()=>{a.invalidateQueries({queryKey:[`angi-leads`]}),n()}}),h=z({mutationFn:()=>_6.accept(i,e.id),onSuccess:()=>{a.invalidateQueries({queryKey:[`angi-leads`]}),n()}}),g=z({mutationFn:()=>_6.reject(i,e.id),onSuccess:()=>{a.invalidateQueries({queryKey:[`angi-leads`]}),n()}}),_=z({mutationFn:t=>_6.respond(i,e.id,{message:t}),onSuccess:()=>{a.invalidateQueries({queryKey:[`angi-leads`]}),p(!1),d(``),n()}}),v=()=>{o!==e.internal_notes&&(m.mutate({internal_notes:o}),l(!1))},y=D6.includes(e.status);return(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/30`,onClick:t}),(0,L.jsxs)(`div`,{className:`relative z-10 flex h-full w-full max-w-lg flex-col overflow-y-auto bg-white shadow-xl border-l border-surface-200`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:[e.first_name,` `,e.last_name]}),e.is_premium&&(0,L.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-full bg-amber-100 px-2 py-0.5 text-xs font-semibold text-amber-700`,children:[(0,L.jsx)(gu,{className:`h-3 w-3`}),` Premium`]}),e.is_duplicate&&(0,L.jsx)(`span`,{className:`rounded-full bg-red-100 px-2 py-0.5 text-xs font-semibold text-red-700`,children:`Duplicate`})]}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:e.project_type})]}),(0,L.jsx)(`button`,{onClick:t,className:`rounded-lg p-2 text-surface-400 hover:bg-surface-100 hover:text-surface-600 min-h-[44px] min-w-[44px] flex items-center justify-center`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-3`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Status Timeline`}),(0,L.jsx)(O6,{lead:e})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Status`}),(0,L.jsx)(`span`,{className:`inline-block mt-1 rounded-full px-2 py-0.5 text-xs font-semibold ${S6(e.status)}`,children:C6(e.status)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Priority`}),(0,L.jsx)(`span`,{className:`inline-block mt-1 rounded-full px-2 py-0.5 text-xs font-semibold ${w6(e.priority)}`,children:T6(e.priority)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Budget`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm font-semibold text-surface-900`,children:e.budget||y6(e.budget_value)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Response Time`}),(0,L.jsx)(`p`,{className:`mt-1 inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${b6(e.response_time_minutes)}`,children:e.responded_at?x6(e.response_time_minutes):`Not responded`})]})]}),(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-3`,children:`Contact Info`}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[e.email&&(0,L.jsxs)(`a`,{href:`mailto:${e.email}`,className:`flex items-center gap-2 text-sm text-surface-700 hover:text-brand-600`,children:[(0,L.jsx)(Fl,{className:`h-4 w-4 text-surface-400`}),e.email]}),e.phone&&(0,L.jsxs)(`a`,{href:`tel:${e.phone}`,className:`flex items-center gap-2 text-sm text-surface-700 hover:text-brand-600`,children:[(0,L.jsx)(Zl,{className:`h-4 w-4 text-surface-400`}),e.phone]}),e.address&&(0,L.jsxs)(`div`,{className:`flex items-start gap-2 text-sm text-surface-700`,children:[(0,L.jsx)(Il,{className:`h-4 w-4 text-surface-400 mt-0.5 shrink-0`}),(0,L.jsxs)(`span`,{children:[e.address,e.city&&`, ${e.city}`,e.state&&` ${e.state}`,e.zip_code&&` ${e.zip_code}`]})]})]})]}),(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-3`,children:`Project Details`}),(0,L.jsxs)(`div`,{className:`space-y-2 text-sm text-surface-700`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(il,{className:`h-4 w-4 text-surface-400`}),(0,L.jsx)(`span`,{className:`font-medium`,children:e.project_type})]}),e.description&&(0,L.jsx)(`p`,{className:`text-surface-600 leading-relaxed`,children:e.description}),e.timeline&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Yc,{className:`h-4 w-4 text-surface-400`}),(0,L.jsxs)(`span`,{children:[`Timeline: `,e.timeline]})]}),e.budget&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(dl,{className:`h-4 w-4 text-surface-400`}),(0,L.jsxs)(`span`,{children:[`Budget: `,e.budget]})]})]})]}),(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-3`,children:`Actions`}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!y&&e.status===`new`&&(0,L.jsxs)(`button`,{onClick:()=>h.mutate(),disabled:h.isPending||m.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-emerald-600 px-3 py-2 text-sm font-medium text-white hover:bg-emerald-700 disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(yc,{className:`h-4 w-4`}),`Accept`]}),!y&&e.status!==`rejected`&&(0,L.jsxs)(`button`,{onClick:()=>p(!0),disabled:_.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(q,{className:`h-4 w-4`}),`Respond`]}),!y&&e.status!==`rejected`&&(0,L.jsxs)(`button`,{onClick:()=>g.mutate(),disabled:g.isPending,className:`inline-flex items-center gap-1.5 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm font-medium text-red-700 hover:bg-red-100 disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(Vc,{className:`h-4 w-4`}),`Reject`]})]}),f&&(0,L.jsxs)(`div`,{className:`mt-3 rounded-lg border border-surface-200 bg-surface-50 p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-700 mb-2`,children:`Send Response`}),(0,L.jsx)(`textarea`,{value:u,onChange:e=>d(e.target.value),placeholder:`Type your response to the lead...`,rows:3,className:`w-full rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500 resize-none`}),(0,L.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,L.jsx)(`button`,{onClick:()=>{p(!1),d(``)},className:`rounded-lg border border-surface-300 px-3 py-1.5 text-sm text-surface-600 hover:bg-surface-100 min-h-[44px]`,children:`Cancel`}),(0,L.jsx)(`button`,{onClick:()=>_.mutate(u),disabled:!u.trim()||_.isPending,className:`rounded-lg bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:`Send`})]})]})]}),(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-3`,children:`Internal Notes`}),(0,L.jsx)(`textarea`,{value:o,onChange:e=>{s(e.target.value),l(!0)},placeholder:`Add internal notes about this lead...`,rows:3,className:`w-full rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500 resize-none`}),c&&(0,L.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,L.jsx)(`button`,{onClick:v,disabled:m.isPending,className:`rounded-lg bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:`Save Notes`})})]}),e.actions&&e.actions.length>0&&(0,L.jsxs)(`div`,{className:`px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-3`,children:`Activity Log`}),(0,L.jsx)(`div`,{className:`space-y-3`,children:[...e.actions].reverse().map(e=>(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-surface-100`,children:k6(e.action_type)}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`p`,{className:`text-sm text-surface-700`,children:e.details}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[e.performed_by,` · `,v6(e.created_at)]}),e.message_content&&(0,L.jsx)(`p`,{className:`mt-1 rounded-lg bg-surface-50 p-2 text-xs text-surface-600`,children:e.message_content})]})]},e.id))})]}),(0,L.jsxs)(`div`,{className:`px-6 py-4 text-center text-xs text-surface-400`,children:[`Received `,v6(e.received_at)]})]})]})}function j6({lead:e,isSelected:t,onSelect:n,onAccept:r,onReject:i,onRespond:a,isActionLoading:o}){let s=D6.includes(e.status);return(0,L.jsxs)(`tr`,{onClick:n,className:`group cursor-pointer border-b border-surface-100 last:border-0 transition-colors ${t?`bg-brand-50`:`hover:bg-surface-50`} ${e.is_premium?`border-l-2 border-l-amber-400`:``}`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-surface-200 text-xs font-semibold text-surface-600`,children:[e.first_name?.[0],e.last_name?.[0]]}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsxs)(`p`,{className:`truncate text-sm font-medium text-surface-900`,children:[e.first_name,` `,e.last_name]}),e.is_premium&&(0,L.jsx)(gu,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}),e.is_duplicate&&(0,L.jsx)(jc,{className:`h-3.5 w-3.5 shrink-0 text-red-400`})]}),(0,L.jsx)(`p`,{className:`truncate text-xs text-surface-500`,children:e.project_type})]})]})}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2.5 py-1 text-xs font-semibold ${S6(e.status)}`,children:C6(e.status)})}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2.5 py-1 text-xs font-semibold ${w6(e.priority)}`,children:T6(e.priority)})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-sm text-surface-700`,children:e.budget||y6(e.budget_value)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-sm text-surface-500`,children:v6(e.received_at)}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:e.responded_at?(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2.5 py-1 text-xs font-semibold ${b6(e.response_time_minutes)}`,children:x6(e.response_time_minutes)}):(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:`—`})}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100`,onClick:e=>e.stopPropagation(),children:[!s&&e.status===`new`&&(0,L.jsx)(`button`,{onClick:r,disabled:o,className:`rounded-lg p-2 text-emerald-600 hover:bg-emerald-50 disabled:opacity-50 min-h-[44px] min-w-[44px] flex items-center justify-center`,title:`Accept lead`,children:(0,L.jsx)(yc,{className:`h-4 w-4`})}),!s&&e.status!==`rejected`&&(0,L.jsx)(`button`,{onClick:a,disabled:o,className:`rounded-lg p-2 text-brand-600 hover:bg-brand-50 disabled:opacity-50 min-h-[44px] min-w-[44px] flex items-center justify-center`,title:`Respond`,children:(0,L.jsx)(q,{className:`h-4 w-4`})}),!s&&e.status!==`rejected`&&(0,L.jsx)(`button`,{onClick:i,disabled:o,className:`rounded-lg p-2 text-red-600 hover:bg-red-50 disabled:opacity-50 min-h-[44px] min-w-[44px] flex items-center justify-center`,title:`Reject`,children:(0,L.jsx)(Vc,{className:`h-4 w-4`})}),(0,L.jsx)(`button`,{onClick:n,className:`rounded-lg p-2 text-surface-400 hover:bg-surface-100 min-h-[44px] min-w-[44px] flex items-center justify-center`,title:`View details`,children:(0,L.jsx)(el,{className:`h-4 w-4`})})]})})]})}function M6(){let{user:e}=W(),t=e?.tenantId,n=ci(),[r,i]=(0,S.useState)(`all`),[a,o]=(0,S.useState)(`all`),[s,c]=(0,S.useState)(`30d`),[l,u]=(0,S.useState)(``),[d,f]=(0,S.useState)(1),[p,m]=(0,S.useState)(!1),[h,g]=(0,S.useState)(null),[_,v]=(0,S.useState)(null),[y,b]=(0,S.useState)(null);(0,S.useEffect)(()=>{if(h){let e=setTimeout(()=>g(null),4e3);return()=>clearTimeout(e)}},[h]);let x=(0,S.useMemo)(()=>{let e={page:d,per_page:25};return r!==`all`&&(e.status=r),a!==`all`&&(e.priority=a),e.date_range=s,l.trim()&&(e.search=l.trim()),e},[r,a,s,l,d]),{data:C,isLoading:w,isFetching:T}=R({queryKey:[`angi-leads`,x],queryFn:()=>_6.getAll(t,x),enabled:!!t,staleTime:15e3}),{data:E}=R({queryKey:[`angi-leads-analytics`],queryFn:()=>_6.getAnalytics(t),enabled:!!t,staleTime:6e4}),D=z({mutationFn:()=>_6.sync(t),onSuccess:()=>{n.invalidateQueries({queryKey:[`angi-leads`]}),n.invalidateQueries({queryKey:[`angi-leads-analytics`]}),g({message:`Angi Leads synced successfully`,type:`success`})},onError:e=>{g({message:e?.response?.data?.error||`Angi Leads sync failed`,type:`error`})}}),O=z({mutationFn:e=>_6.accept(t,e),onSuccess:()=>{n.invalidateQueries({queryKey:[`angi-leads`]}),n.invalidateQueries({queryKey:[`angi-leads-analytics`]}),_&&n.invalidateQueries({queryKey:[`angi-lead-detail`,_.id]})}}),k=z({mutationFn:e=>_6.reject(t,e),onSuccess:()=>{n.invalidateQueries({queryKey:[`angi-leads`]}),n.invalidateQueries({queryKey:[`angi-leads-analytics`]})}}),A=z({mutationFn:({leadId:e,message:n})=>_6.respond(t,e,{message:n}),onSuccess:()=>{n.invalidateQueries({queryKey:[`angi-leads`]}),n.invalidateQueries({queryKey:[`angi-leads-analytics`]})}}),j=(0,S.useCallback)(e=>{b(e),O.mutate(e,{onSettled:()=>b(null)})},[O]),M=(0,S.useCallback)(e=>{b(e),k.mutate(e,{onSettled:()=>b(null)})},[k]);(0,S.useCallback)(e=>{v(C?.data.items.find(t=>t.id===e)||null)},[C]);let N=(0,S.useCallback)(()=>{_&&n.invalidateQueries({queryKey:[`angi-lead-detail`,_.id]})},[n,_]),ee=C?.data.items||[],te=C?.data.total||0,P=Math.ceil(te/25),F=E?.data,ne=(0,S.useCallback)(e=>{let t=prompt(`Quick respond to lead:`);t?.trim()&&(b(e),A.mutate({leadId:e,message:t.trim()},{onSettled:()=>b(null)}))},[A]),re=[{label:`New Leads`,value:F?.new_leads??0,icon:il,color:`text-blue-600 bg-blue-50`},{label:`Responded`,value:F?.responded??0,icon:q,color:`text-violet-600 bg-violet-50`},{label:`Won`,value:F?.won??0,icon:yc,color:`text-emerald-600 bg-emerald-50`},{label:`Lost`,value:F?.lost??0,icon:Vc,color:`text-red-600 bg-red-50`},{label:`Avg Response`,value:F?`${(F.avg_response_time||0).toFixed(0)}m`:`—`,icon:al,color:`text-amber-600 bg-amber-50`},{label:`Conversion Rate`,value:F?`${((F.conversion_rate||0)*100).toFixed(1)}%`:`—`,icon:dl,color:`text-green-600 bg-green-50`}];return(0,S.useEffect)(()=>{f(1)},[r,a,s]),(0,L.jsxs)($,{title:`Angi Leads`,children:[h&&(0,L.jsxs)(`div`,{className:`fixed top-4 right-4 z-[70] flex items-center gap-2 rounded-lg bg-surface-900 px-4 py-3 text-sm text-white shadow-lg`,children:[h.type===`success`?(0,L.jsx)(yc,{className:`h-4 w-4 text-green-400`}):(0,L.jsx)(vc,{className:`h-4 w-4 text-red-400`}),h.message]}),(0,L.jsxs)(`div`,{"data-testid":`page-content`,children:[(0,L.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6`,children:re.map(e=>(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${e.color}`,children:(0,L.jsx)(e.icon,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 truncate`,children:e.label}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:e.value})]})]})},e.label))}),(0,L.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 sm:flex-initial sm:w-72`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`Search leads...`,className:`w-full rounded-lg border border-surface-300 py-2.5 pl-9 pr-4 text-sm outline-none focus:border-brand-500 sm:w-72`})]}),(0,L.jsxs)(`button`,{onClick:()=>m(!p),className:`flex items-center gap-1.5 rounded-lg border border-surface-300 px-3 py-2 text-sm text-surface-600 hover:bg-surface-50 sm:hidden min-h-[44px]`,children:[(0,L.jsx)(wc,{className:`h-4 w-4`}),`Filters`]}),(0,L.jsxs)(`div`,{className:`${p?`flex`:`hidden`} flex-col gap-2 sm:flex sm:flex-row sm:items-center sm:gap-2`,children:[(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`all`,children:`All Statuses`}),(0,L.jsx)(`option`,{value:`new`,children:`New`}),(0,L.jsx)(`option`,{value:`accepted`,children:`Accepted`}),(0,L.jsx)(`option`,{value:`responded`,children:`Responded`}),(0,L.jsx)(`option`,{value:`contacted`,children:`Contacted`}),(0,L.jsx)(`option`,{value:`scheduled`,children:`Scheduled`}),(0,L.jsx)(`option`,{value:`won`,children:`Won`}),(0,L.jsx)(`option`,{value:`lost`,children:`Lost`}),(0,L.jsx)(`option`,{value:`expired`,children:`Expired`}),(0,L.jsx)(`option`,{value:`rejected`,children:`Rejected`})]}),(0,L.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`all`,children:`All Priorities`}),(0,L.jsx)(`option`,{value:`high`,children:`High`}),(0,L.jsx)(`option`,{value:`medium`,children:`Medium`}),(0,L.jsx)(`option`,{value:`low`,children:`Low`})]}),(0,L.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:`rounded-lg border border-surface-300 py-2 px-3 text-sm outline-none focus:border-brand-500 min-h-[44px]`,children:[(0,L.jsx)(`option`,{value:`7d`,children:`Last 7 Days`}),(0,L.jsx)(`option`,{value:`30d`,children:`Last 30 Days`}),(0,L.jsx)(`option`,{value:`90d`,children:`Last 90 Days`}),(0,L.jsx)(`option`,{value:`all`,children:`All Time`})]})]})]}),(0,L.jsxs)(`button`,{onClick:()=>D.mutate(),disabled:D.isPending,className:`inline-flex items-center gap-2 rounded-lg border border-surface-300 px-4 py-2.5 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(nu,{className:`h-4 w-4 ${D.isPending?`animate-spin`:``}`}),`Sync`]})]}),!w&&(0,L.jsxs)(`p`,{className:`mb-3 text-sm text-surface-500`,children:[`Showing `,ee.length,` of `,te,` leads`]}),w?(0,L.jsxs)(`div`,{className:`flex items-center justify-center rounded-xl border border-surface-200 bg-white py-20`,children:[(0,L.jsx)(PQ,{size:`md`}),(0,L.jsx)(`span`,{className:`ml-3 text-sm text-surface-500`,children:`Loading leads…`})]}):ee.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-20`,children:[(0,L.jsx)(il,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:l||r!==`all`||a!==`all`?`No leads match your filters`:`No Angi leads yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-surface-500`,children:l||r!==`all`||a!==`all`?`Try adjusting your search or filters`:`Connect Angi in Integrations to start receiving leads`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200 bg-white`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Lead`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Status`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Priority`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Budget`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Received`}),(0,L.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-surface-600`,children:`Response`}),(0,L.jsx)(`th`,{className:`px-4 py-3 w-24 font-medium text-surface-600`,children:`Actions`})]})}),(0,L.jsx)(`tbody`,{children:ee.map(e=>(0,L.jsx)(j6,{lead:e,isSelected:_?.id===e.id,onSelect:()=>v(e),onAccept:()=>j(e.id),onReject:()=>M(e.id),onRespond:()=>ne(e.id),isActionLoading:y===e.id},e.id))})]})}),P>1&&(0,L.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,L.jsx)(`button`,{onClick:()=>f(e=>Math.max(1,e-1)),disabled:d===1,className:`rounded-lg border border-surface-300 px-3 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-40 min-h-[44px]`,children:`Previous`}),(0,L.jsx)(`div`,{className:`flex items-center gap-1`,children:Array.from({length:Math.min(5,P)},(e,t)=>{let n;return n=P<=5||d<=3?t+1:d>=P-2?P-4+t:d-2+t,(0,L.jsx)(`button`,{onClick:()=>f(n),className:`rounded-lg px-3 py-2 text-sm font-medium min-h-[44px] min-w-[44px] flex items-center justify-center ${d===n?`bg-brand-600 text-white`:`text-surface-600 hover:bg-surface-100`}`,children:n},n)})}),(0,L.jsx)(`button`,{onClick:()=>f(e=>Math.min(P,e+1)),disabled:d===P,className:`rounded-lg border border-surface-300 px-3 py-2 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-40 min-h-[44px]`,children:`Next`})]})]})]}),_&&(0,L.jsx)(A6,{lead:_,onClose:()=>v(null),onAction:N})]})}var N6=e=>`/api/company/${e}/quickbooks`,P6={async getInvoices(e,t){return(await U.get(`${N6(e)}/invoices`,{params:t})).data},async getInvoice(e,t){return(await U.get(`${N6(e)}/invoices/${t}`)).data},async acceptInvoice(e,t){return(await U.post(`${N6(e)}/accept-invoice/${t}`)).data},async getTransactions(e,t){return(await U.get(`${N6(e)}/transactions`,{params:t})).data},async getCustomers(e,t){return(await U.get(`${N6(e)}/customers`,{params:t})).data},async getExpenses(e,t){return(await U.get(`${N6(e)}/expenses`,{params:t})).data},async getAnalytics(e){return(await U.get(`${N6(e)}/analytics`)).data},async sync(e){return(await U.post(`${N6(e)}/sync`)).data}};function F6(e){return e==null?`—`:Math.abs(e)>=1e6?`${e>0?`+`:``}$${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${e>0?`+`:``}$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(2)}`}function I6(e){return{draft:`bg-slate-100 text-slate-700`,sent:`bg-blue-100 text-blue-700`,paid:`bg-emerald-100 text-emerald-700`,partial:`bg-amber-100 text-amber-700`,void:`bg-red-100 text-red-700`,uncollectible:`bg-gray-100 text-gray-500`}[e]||`bg-gray-100 text-gray-600`}function L6(e){return e.charAt(0).toUpperCase()+e.slice(1)}function R6(e){if(!e)return`—`;let t=Date.now(),n=new Date(e).getTime(),r=Math.abs(t-n),i=Math.floor(r/864e5);return i===0?`today`:i===1?`yesterday`:i<30?`${i}d ago`:new Date(e).toLocaleDateString()}function z6({analytics:e}){return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4`,children:[{label:`Outstanding`,value:F6(e.total_outstanding),icon:jc,color:`text-amber-600 bg-amber-50`},{label:`Total Paid`,value:F6(e.total_paid),icon:yc,color:`text-emerald-600 bg-emerald-50`},{label:`Revenue (30d)`,value:F6(e.revenue_last_30d),icon:wu,color:`text-blue-600 bg-blue-50`},{label:`Profit Margin`,value:`${e.profit_margin.toFixed(1)}%`,icon:mc,color:`text-violet-600 bg-violet-50`},{label:`Avg Invoice`,value:F6(e.avg_invoice_amount),icon:_l,color:`text-slate-600 bg-slate-50`},{label:`Collection Days`,value:`${e.avg_collection_days.toFixed(0)}d`,icon:Yc,color:`text-cyan-600 bg-cyan-50`}].map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex rounded-lg p-2 mb-2 ${e.color}`,children:(0,L.jsx)(e.icon,{className:`h-4 w-4`})}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.label}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900 mt-0.5`,children:e.value})]},e.label))}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Revenue`}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Last 30 days`}),(0,L.jsx)(`span`,{className:`font-semibold text-emerald-600`,children:F6(e.revenue_last_30d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Last 90 days`}),(0,L.jsx)(`span`,{className:`font-semibold text-emerald-600`,children:F6(e.revenue_last_90d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Year to date`}),(0,L.jsx)(`span`,{className:`font-semibold text-emerald-600`,children:F6(e.revenue_ytd)})]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Expenses`}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Last 30 days`}),(0,L.jsx)(`span`,{className:`font-semibold text-red-600`,children:F6(e.expenses_last_30d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Last 90 days`}),(0,L.jsx)(`span`,{className:`font-semibold text-red-600`,children:F6(e.expenses_last_90d)})]})]})]})]}),e.invoices_by_status&&e.invoices_by_status.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Invoices by Status`}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3`,children:e.invoices_by_status.map(e=>(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500 capitalize`,children:e.status}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:e.count}),(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:F6(e.total)})]},e.status))})]}),e.top_customers&&e.top_customers.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Top Customers`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:e.top_customers.map(e=>(0,L.jsxs)(`div`,{className:`flex justify-between items-center py-2 border-b border-surface-100 last:border-0`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:e.name}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[e.invoice_count,` invoices`]})]}),(0,L.jsx)(`span`,{className:`font-semibold text-emerald-600`,children:F6(e.total_paid)})]},e.name))})]})]})}function B6({companyId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(null),{data:s,isLoading:c,refetch:l}=R({queryKey:[`quickbooks-invoices`,e,t,r],queryFn:()=>P6.getInvoices(e,{search:t||void 0,status:r||void 0}),staleTime:6e4}),u=s?.data?.items||[];return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search invoices...`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Statuses`}),(0,L.jsx)(`option`,{value:`draft`,children:`Draft`}),(0,L.jsx)(`option`,{value:`sent`,children:`Sent`}),(0,L.jsx)(`option`,{value:`paid`,children:`Paid`}),(0,L.jsx)(`option`,{value:`partial`,children:`Partial`}),(0,L.jsx)(`option`,{value:`void`,children:`Void`})]})]}),c?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Invoice`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Customer`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Amount`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Due`})]})}),(0,L.jsx)(`tbody`,{children:u.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:5,className:`text-center py-8 text-surface-400`,children:`No invoices found`})}):u.map(e=>(0,L.jsxs)(`tr`,{onClick:()=>o(e),className:`border-t border-surface-100 hover:bg-surface-50 cursor-pointer`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900`,children:e.invoice_number}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-600`,children:e.customer_name}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-medium`,children:F6(e.total_amount)}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${I6(e.status)}`,children:L6(e.status)})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500`,children:R6(e.due_date)})]},e.id))})]})}),a&&(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/30`,onClick:()=>o(null)}),(0,L.jsxs)(`div`,{className:`relative z-10 flex h-full w-full max-w-lg flex-col overflow-y-auto bg-white shadow-xl border-l border-surface-200`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:a.invoice_number}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:a.customer_name})]}),(0,L.jsx)(`button`,{onClick:()=>o(null),className:`rounded-lg p-2 text-surface-400 hover:bg-surface-100 min-h-[44px] min-w-[44px] flex items-center justify-center`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:F6(a.total_amount)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Status`}),(0,L.jsx)(`span`,{className:`inline-block mt-1 rounded-full px-2 py-0.5 text-xs font-semibold ${I6(a.status)}`,children:L6(a.status)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Subtotal`}),(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:F6(a.subtotal)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Tax`}),(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:F6(a.tax_amount)})]})]}),(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Dates`}),(0,L.jsxs)(`div`,{className:`space-y-1 text-sm text-surface-600`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`span`,{children:`Issued`}),(0,L.jsx)(`span`,{children:R6(a.issue_date)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`span`,{children:`Due`}),(0,L.jsx)(`span`,{children:R6(a.due_date)})]})]})]}),a.line_items&&a.line_items.length>0&&(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Line Items`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:a.line_items.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,L.jsx)(`span`,{className:`text-surface-600`,children:e.description}),(0,L.jsx)(`span`,{className:`font-medium`,children:F6(e.amount)})]},t))})]}),a.notes&&(0,L.jsxs)(`div`,{className:`px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Notes`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-600`,children:a.notes})]})]})]})]})}function V6({companyId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),{data:a,isLoading:o}=R({queryKey:[`quickbooks-transactions`,e,t,r],queryFn:()=>P6.getTransactions(e,{type:r||void 0}),staleTime:6e4}),s=a?.data?.items||[];return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search transactions...`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Types`}),(0,L.jsx)(`option`,{value:`sale`,children:`Sale`}),(0,L.jsx)(`option`,{value:`payment`,children:`Payment`}),(0,L.jsx)(`option`,{value:`refund`,children:`Refund`}),(0,L.jsx)(`option`,{value:`credit`,children:`Credit`}),(0,L.jsx)(`option`,{value:`debit`,children:`Debit`})]})]}),o?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`space-y-2`,children:s.length===0?(0,L.jsx)(`div`,{className:`text-center py-8 text-surface-400`,children:`No transactions found`}):s.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.amount>=0?(0,L.jsx)(`div`,{className:`rounded-full bg-emerald-100 p-2`,children:(0,L.jsx)(Rc,{className:`h-4 w-4 text-emerald-600`})}):(0,L.jsx)(`div`,{className:`rounded-full bg-red-100 p-2`,children:(0,L.jsx)(Nc,{className:`h-4 w-4 text-red-600`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:e.description}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[R6(e.transaction_date),` · `,e.transaction_type,e.account_name?` · ${e.account_name}`:``]})]})]}),(0,L.jsxs)(`span`,{className:`font-semibold ${e.amount>=0?`text-emerald-600`:`text-red-600`}`,children:[e.amount>=0?`+`:``,F6(e.amount)]})]},e.id))})]})}function H6({companyId:e}){let[t,n]=(0,S.useState)(``),{data:r,isLoading:i}=R({queryKey:[`quickbooks-customers`,e,t],queryFn:()=>P6.getCustomers(e,{search:t||void 0}),staleTime:6e4}),a=r?.data?.items||[];return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search customers...`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-brand-500`})]})}),i?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:a.length===0?(0,L.jsx)(`div`,{className:`col-span-full text-center py-8 text-surface-400`,children:`No customers found`}):a.map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between mb-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-900`,children:e.name}),e.email&&(0,L.jsx)(`p`,{className:`text-xs text-surface-400 mt-0.5`,children:e.email})]}),(0,L.jsx)(`div`,{className:`rounded-full bg-blue-100 p-2`,children:(0,L.jsx)(Pu,{className:`h-4 w-4 text-blue-600`})})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-2`,children:[(0,L.jsx)(`p`,{className:`text-surface-400`,children:`Balance`}),(0,L.jsx)(`p`,{className:`font-medium`,children:F6(e.balance)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-2`,children:[(0,L.jsx)(`p`,{className:`text-surface-400`,children:`Invoices`}),(0,L.jsx)(`p`,{className:`font-medium`,children:e.total_invoices})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-2 col-span-2`,children:[(0,L.jsx)(`p`,{className:`text-surface-400`,children:`Total Paid`}),(0,L.jsx)(`p`,{className:`font-medium text-emerald-600`,children:F6(e.total_paid)})]})]})]},e.id))})]})}function U6({companyId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),{data:a,isLoading:o}=R({queryKey:[`quickbooks-expenses`,e,t,r],queryFn:()=>P6.getExpenses(e,{category:r||void 0}),staleTime:6e4}),s=a?.data?.items||[];return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search expenses...`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Categories`}),(0,L.jsx)(`option`,{value:`supplies`,children:`Supplies`}),(0,L.jsx)(`option`,{value:`labor`,children:`Labor`}),(0,L.jsx)(`option`,{value:`equipment`,children:`Equipment`}),(0,L.jsx)(`option`,{value:`marketing`,children:`Marketing`}),(0,L.jsx)(`option`,{value:`overhead`,children:`Overhead`})]})]}),o?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Vendor`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Description`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Category`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Amount`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Date`})]})}),(0,L.jsx)(`tbody`,{children:s.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:5,className:`text-center py-8 text-surface-400`,children:`No expenses found`})}):s.map(e=>(0,L.jsxs)(`tr`,{className:`border-t border-surface-100`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900`,children:e.vendor_name}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-600 max-w-[200px] truncate`,children:e.description}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full bg-surface-100 px-2 py-0.5 text-xs font-medium text-surface-600 capitalize`,children:e.category})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-medium text-red-600`,children:F6(e.amount)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500`,children:R6(e.expense_date)})]},e.id))})]})})]})}function W6(){let{user:e}=W(),t=e?.tenantId,[n,r]=(0,S.useState)(`overview`),[i,a]=(0,S.useState)(null),o=ci();(0,S.useEffect)(()=>{if(i){let e=setTimeout(()=>a(null),4e3);return()=>clearTimeout(e)}},[i]);let{data:s,isLoading:c}=R({queryKey:[`quickbooks-analytics`,t],queryFn:()=>P6.getAnalytics(t),staleTime:12e4}),l=z({mutationFn:()=>P6.sync(t),onSuccess:()=>{o.invalidateQueries({queryKey:[`quickbooks`]}),a({message:`QuickBooks synced successfully`,type:`success`})},onError:e=>{a({message:e?.response?.data?.error||`QuickBooks sync failed`,type:`error`})}}),u=[{key:`overview`,label:`Overview`,icon:mc},{key:`invoices`,label:`Invoices`,icon:_l},{key:`transactions`,label:`Transactions`,icon:cl},{key:`customers`,label:`Customers`,icon:Pu},{key:`expenses`,label:`Expenses`,icon:pu}];return(0,L.jsxs)($,{children:[i&&(0,L.jsxs)(`div`,{className:`fixed top-4 right-4 z-[70] flex items-center gap-2 rounded-lg bg-surface-900 px-4 py-3 text-sm text-white shadow-lg`,children:[i.type===`success`?(0,L.jsx)(yc,{className:`h-4 w-4 text-green-400`}):(0,L.jsx)(vc,{className:`h-4 w-4 text-red-400`}),i.message]}),(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`QuickBooks`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mt-1`,children:`Financial data synced from QuickBooks Online`})]}),(0,L.jsxs)(`button`,{onClick:()=>l.mutate(),disabled:l.isPending,className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px] self-start`,children:[(0,L.jsx)(nu,{className:`h-4 w-4 ${l.isPending?`animate-spin`:``}`}),l.isPending?`Syncing...`:`Sync Now`]})]}),(0,L.jsx)(`div`,{className:`flex gap-1 overflow-x-auto border-b border-surface-200`,children:u.map(e=>(0,L.jsxs)(`button`,{onClick:()=>r(e.key),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap min-h-[44px] ${n===e.key?`border-brand-600 text-brand-600`:`border-transparent text-surface-500 hover:text-surface-700`}`,children:[(0,L.jsx)(e.icon,{className:`h-4 w-4`}),e.label]},e.key))}),n===`overview`?c?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):s?.data?(0,L.jsx)(z6,{analytics:s.data}):(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-12 text-center`,children:[(0,L.jsx)(dl,{className:`h-12 w-12 text-surface-300 mx-auto mb-4`}),(0,L.jsx)(`h3`,{className:`text-lg font-medium text-surface-700 mb-2`,children:`No QuickBooks data`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mb-4`,children:`Connect your QuickBooks account to see your financial data here.`}),(0,L.jsxs)(`button`,{onClick:()=>l.mutate(),disabled:l.isPending,className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:[(0,L.jsx)(nu,{className:`h-4 w-4`}),`Sync Now`]})]}):n===`invoices`?(0,L.jsx)(B6,{companyId:t}):n===`transactions`?(0,L.jsx)(V6,{companyId:t}):n===`customers`?(0,L.jsx)(H6,{companyId:t}):(0,L.jsx)(U6,{companyId:t})]})]})}var G6=e=>`/api/company/${e}/google_ads`,K6={async getCampaigns(e,t){return(await U.get(`${G6(e)}/campaigns`,{params:t})).data},async getCampaign(e,t){return(await U.get(`${G6(e)}/campaigns/${t}`)).data},async getMetrics(e,t){return(await U.get(`${G6(e)}/metrics`,{params:t})).data},async getAnalytics(e){return(await U.get(`${G6(e)}/analytics`)).data},async sync(e){return(await U.post(`${G6(e)}/sync`)).data}};function q6(e){return e==null?`—`:Math.abs(e)>=1e6?`$${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(2)}`}function J6(e){return e==null?`—`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function Y6(e){return e==null?`—`:`${(e*100).toFixed(2)}%`}function X6(e){return{ENABLED:`bg-emerald-100 text-emerald-700`,PAUSED:`bg-amber-100 text-amber-700`,REMOVED:`bg-gray-100 text-gray-500`}[e]||`bg-gray-100 text-gray-600`}function Z6(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Q6(e){if(!e)return`—`;let t=Date.now(),n=new Date(e).getTime(),r=Math.abs(t-n),i=Math.floor(r/864e5);return i===0?`today`:i===1?`yesterday`:i<30?`${i}d ago`:new Date(e).toLocaleDateString()}function $6(e){return{SEARCH:`Search`,DISPLAY:`Display`,SHOPPING:`Shopping`,VIDEO:`Video`,PERFORMANCE_MAX:`Performance Max`}[e]||e}function e8({analytics:e}){return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4`,children:[{label:`Active Campaigns`,value:e.active_campaigns,icon:Vl,color:`text-emerald-600 bg-emerald-50`},{label:`Spend (30d)`,value:q6(e.total_spend_30d),icon:dl,color:`text-blue-600 bg-blue-50`},{label:`Impressions (30d)`,value:J6(e.total_impressions_30d),icon:hl,color:`text-violet-600 bg-violet-50`},{label:`Clicks (30d)`,value:J6(e.total_clicks_30d),icon:Hl,color:`text-cyan-600 bg-cyan-50`},{label:`Conversions`,value:e.total_conversions_30d.toFixed(0),icon:yu,color:`text-emerald-600 bg-emerald-50`},{label:`Avg CTR`,value:Y6(e.avg_ctr),icon:wu,color:`text-green-600 bg-green-50`},{label:`Avg CPC`,value:q6(e.avg_cpc),icon:dl,color:`text-amber-600 bg-amber-50`},{label:`Avg CPA`,value:q6(e.avg_cpa),icon:Cu,color:`text-red-600 bg-red-50`},{label:`ROAS`,value:e.total_roas?`${e.total_roas.toFixed(2)}x`:`—`,icon:Ru,color:`text-indigo-600 bg-indigo-50`}].map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex rounded-lg p-2 mb-2 ${e.color}`,children:(0,L.jsx)(e.icon,{className:`h-4 w-4`})}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.label}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900 mt-0.5`,children:e.value})]},e.label))}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Spend`}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Last 30 days`}),(0,L.jsx)(`span`,{className:`font-semibold text-blue-600`,children:q6(e.total_spend_30d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Last 90 days`}),(0,L.jsx)(`span`,{className:`font-semibold text-blue-600`,children:q6(e.total_spend_90d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Year to date`}),(0,L.jsx)(`span`,{className:`font-semibold text-blue-600`,children:q6(e.total_spend_ytd)})]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Performance`}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Impressions (30d)`}),(0,L.jsx)(`span`,{className:`font-semibold text-violet-600`,children:J6(e.total_impressions_30d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Clicks (30d)`}),(0,L.jsx)(`span`,{className:`font-semibold text-cyan-600`,children:J6(e.total_clicks_30d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Conversions (30d)`}),(0,L.jsx)(`span`,{className:`font-semibold text-emerald-600`,children:e.total_conversions_30d.toFixed(0)})]})]})]})]}),e.campaigns_by_status&&e.campaigns_by_status.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Campaigns by Status`}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-3`,children:e.campaigns_by_status.map(e=>(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500 capitalize`,children:e.status}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:e.count}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[`Budget: `,q6(e.total_budget)]})]},e.status))})]}),e.campaigns_by_channel&&e.campaigns_by_channel.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Campaigns by Channel`}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-3`,children:e.campaigns_by_channel.map(e=>(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:$6(e.channel_type)}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:e.count}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[`Spend: `,q6(e.total_spend)]})]},e.channel_type))})]}),e.top_campaigns&&e.top_campaigns.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Top Campaigns`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:e.top_campaigns.map(e=>(0,L.jsxs)(`div`,{className:`flex justify-between items-center py-2 border-b border-surface-100 last:border-0`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:e.name}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[e.clicks,` clicks · `,e.conversions?.toFixed(0)||0,` conversions`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${X6(e.status)}`,children:Z6(e.status)}),(0,L.jsx)(`span`,{className:`font-semibold text-blue-600`,children:q6(e.spend)})]})]},e.external_id))})]})]})}function t8({companyId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(null),{data:s,isLoading:c}=R({queryKey:[`google-ads-campaigns`,e,t,r],queryFn:()=>K6.getCampaigns(e,{search:t||void 0,status:r||void 0}),staleTime:6e4}),l=s?.data?.items||[];return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search campaigns...`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Statuses`}),(0,L.jsx)(`option`,{value:`ENABLED`,children:`Enabled`}),(0,L.jsx)(`option`,{value:`PAUSED`,children:`Paused`}),(0,L.jsx)(`option`,{value:`REMOVED`,children:`Removed`})]})]}),c?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Campaign`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Channel`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Budget`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Spend`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Clicks`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Conversions`})]})}),(0,L.jsx)(`tbody`,{children:l.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:7,className:`text-center py-8 text-surface-400`,children:`No campaigns found`})}):l.map(e=>(0,L.jsxs)(`tr`,{onClick:()=>o(e),className:`border-t border-surface-100 hover:bg-surface-50 cursor-pointer`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900`,children:e.name}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${X6(e.status)}`,children:Z6(e.status)})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500`,children:$6(e.channel_type)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-medium`,children:q6(e.budget)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-medium text-blue-600`,children:q6(e.total_spend)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-600`,children:J6(e.total_clicks)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-emerald-600 font-medium`,children:e.total_conversions.toFixed(0)})]},e.id))})]})}),a&&(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/30`,onClick:()=>o(null)}),(0,L.jsxs)(`div`,{className:`relative z-10 flex h-full w-full max-w-lg flex-col overflow-y-auto bg-white shadow-xl border-l border-surface-200`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:a.name}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500`,children:[$6(a.channel_type),` · `,a.budget_type,` budget`]})]}),(0,L.jsx)(`button`,{onClick:()=>o(null),className:`rounded-lg p-2 text-surface-400 hover:bg-surface-100 min-h-[44px] min-w-[44px] flex items-center justify-center`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Status`}),(0,L.jsx)(`span`,{className:`inline-block mt-1 rounded-full px-2 py-0.5 text-xs font-semibold ${X6(a.status)}`,children:Z6(a.status)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Budget`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:q6(a.budget)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Spend`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-blue-600`,children:q6(a.total_spend)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Conversions`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-emerald-600`,children:a.total_conversions.toFixed(0)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Clicks`}),(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:J6(a.total_clicks)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Channel`}),(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:$6(a.channel_type)})]})]}),a.start_date&&(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Dates`}),(0,L.jsxs)(`div`,{className:`space-y-1 text-sm text-surface-600`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`span`,{children:`Start`}),(0,L.jsx)(`span`,{children:Q6(a.start_date)})]}),a.end_date&&(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`span`,{children:`End`}),(0,L.jsx)(`span`,{children:Q6(a.end_date)})]})]})]}),(0,L.jsxs)(`div`,{className:`px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Updated`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-600`,children:Q6(a.updated_at)})]})]})]})]})}function n8({companyId:e}){let[t,n]=(0,S.useState)(``),{data:r,isLoading:i}=R({queryKey:[`google-ads-metrics`,e,t],queryFn:()=>K6.getMetrics(e,{campaign_id:t||void 0,per_page:100}),staleTime:6e4}),a=r?.data?.items||[];return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:(0,L.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:(0,L.jsx)(`option`,{value:``,children:`All Campaigns`})})}),i?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Date`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Spend`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Impressions`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Clicks`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`CTR`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`CPC`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Conversions`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`ROAS`})]})}),(0,L.jsx)(`tbody`,{children:a.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:8,className:`text-center py-8 text-surface-400`,children:`No metrics found`})}):a.map(e=>(0,L.jsxs)(`tr`,{className:`border-t border-surface-100 hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-600`,children:Q6(e.metric_date)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-medium text-blue-600`,children:q6(e.spend)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-600`,children:J6(e.impressions)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-600`,children:J6(e.clicks)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-500`,children:Y6(e.ctr)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-500`,children:q6(e.cpc)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-emerald-600 font-medium`,children:e.conversions.toFixed(0)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-500`,children:e.roas?`${e.roas.toFixed(2)}x`:`—`})]},e.id))})]})})]})}function r8({companyId:e}){let{data:t,isLoading:n}=R({queryKey:[`google-ads-analytics`,e],queryFn:()=>K6.getAnalytics(e),staleTime:6e4}),r=t?.data,i=r?.daily_spend_trend||[],a=(0,S.useMemo)(()=>Math.max(...i.map(e=>e.spend||0),1),[i]);return(0,L.jsx)(`div`,{className:`space-y-6`,children:n?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsxs)(L.Fragment,{children:[i.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Daily Spend Trend`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:i.slice(-30).map(e=>{let t=e.spend/a*100;return(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-400 w-16 flex-shrink-0`,children:new Date(e.date).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}),(0,L.jsx)(`div`,{className:`flex-1 bg-surface-100 rounded-full h-6 overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full bg-blue-500 rounded-full flex items-center justify-end pr-2 transition-all`,style:{width:`${Math.max(t,2)}%`},children:t>15&&(0,L.jsx)(`span`,{className:`text-xs text-white font-medium`,children:q6(e.spend)})})}),t<=15&&(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:q6(e.spend)})]},e.date)})})]}),i.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Daily Conversions Trend`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:i.slice(-30).map(e=>{let t=Math.max(...i.map(e=>e.conversions||0),1),n=e.conversions/t*100;return(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-400 w-16 flex-shrink-0`,children:new Date(e.date).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}),(0,L.jsx)(`div`,{className:`flex-1 bg-surface-100 rounded-full h-6 overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full bg-emerald-500 rounded-full flex items-center justify-end pr-2 transition-all`,style:{width:`${Math.max(n,2)}%`},children:n>15&&(0,L.jsx)(`span`,{className:`text-xs text-white font-medium`,children:e.conversions.toFixed(0)})})}),n<=15&&(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:e.conversions.toFixed(0)})]},e.date)})})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Spend`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-blue-600`,children:q6(r?.total_spend_30d)})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Avg Daily Spend`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-blue-600`,children:i.length>0?q6(r?.total_spend_30d/i.length):`—`})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Conversions`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-emerald-600`,children:r?.total_conversions_30d?.toFixed(0)||`0`})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`ROAS`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-indigo-600`,children:r?.total_roas?`${r.total_roas.toFixed(2)}x`:`—`})]})]})]})})}function i8(){let{user:e}=W(),[t,n]=(0,S.useState)(`overview`),[r,i]=(0,S.useState)(null),a=ci(),o=e?.tenantId?String(e.tenantId):``;(0,S.useEffect)(()=>{if(r){let e=setTimeout(()=>i(null),4e3);return()=>clearTimeout(e)}},[r]);let{data:s,isLoading:c}=R({queryKey:[`google-ads-analytics`,o],queryFn:()=>K6.getAnalytics(o),staleTime:12e4}),l=z({mutationFn:()=>K6.sync(o),onSuccess:()=>{a.invalidateQueries({queryKey:[`google-ads`]}),i({message:`Google Ads synced successfully`,type:`success`})},onError:e=>{i({message:e?.response?.data?.error||`Google Ads sync failed`,type:`error`})}}),u=[{key:`overview`,label:`Overview`,icon:mc},{key:`campaigns`,label:`Campaigns`,icon:Vl},{key:`metrics`,label:`Metrics`,icon:Mc},{key:`trends`,label:`Trends`,icon:wu}];return(0,L.jsxs)($,{children:[r&&(0,L.jsxs)(`div`,{className:`fixed top-4 right-4 z-[70] flex items-center gap-2 rounded-lg bg-surface-900 px-4 py-3 text-sm text-white shadow-lg`,children:[r.type===`success`?(0,L.jsx)(yc,{className:`h-4 w-4 text-green-400`}):(0,L.jsx)(vc,{className:`h-4 w-4 text-red-400`}),r.message]}),(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Google Ads`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mt-1`,children:`Campaign performance and ad analytics`})]}),(0,L.jsxs)(`button`,{onClick:()=>l.mutate(),disabled:l.isPending,className:`inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-brand-600 text-white text-sm font-medium hover:bg-brand-700 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,L.jsx)(nu,{className:`h-4 w-4 ${l.isPending?`animate-spin`:``}`}),l.isPending?`Syncing...`:`Sync Now`]})]}),(0,L.jsx)(`div`,{className:`flex gap-1 border-b border-surface-200`,children:u.map(e=>(0,L.jsxs)(`button`,{onClick:()=>n(e.key),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t===e.key?`border-brand-500 text-brand-600`:`border-transparent text-surface-500 hover:text-surface-700`}`,children:[(0,L.jsx)(e.icon,{className:`h-4 w-4`}),e.label]},e.key))}),c&&t===`overview`?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):t===`overview`&&s?.data?(0,L.jsx)(e8,{analytics:s.data}):t===`campaigns`?(0,L.jsx)(t8,{companyId:o}):t===`metrics`?(0,L.jsx)(n8,{companyId:o}):t===`trends`?(0,L.jsx)(r8,{companyId:o}):null]})]})}function a8(e){return e==null?`—`:Math.abs(e)>=1e6?`$${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(2)}`}function o8(e){return e==null?`—`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function s8(e){return e==null?`—`:`${(e*100).toFixed(2)}%`}function c8(e){return{ACTIVE:`bg-emerald-100 text-emerald-700`,PAUSED:`bg-amber-100 text-amber-700`,DELETED:`bg-gray-100 text-gray-500`}[e]||`bg-gray-100 text-gray-600`}function l8(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function u8(e){if(!e)return`—`;let t=Date.now(),n=new Date(e).getTime(),r=Math.abs(t-n),i=Math.floor(r/864e5);return i===0?`today`:i===1?`yesterday`:i<30?`${i}d ago`:new Date(e).toLocaleDateString()}function d8(e){return{FACEBOOK:`Facebook`,INSTAGRAM:`Instagram`,AUDIENCE_NETWORK:`Audience Network`,MESSENGER:`Messenger`,WHATSAPP:`WhatsApp`}[e]||e}function f8({analytics:e}){return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4`,children:[{label:`Active Campaigns`,value:e.active_campaigns,icon:Vl,color:`text-emerald-600 bg-emerald-50`},{label:`Spend (30d)`,value:a8(e.total_spend_30d),icon:dl,color:`text-blue-600 bg-blue-50`},{label:`Impressions (30d)`,value:o8(e.total_impressions_30d),icon:hl,color:`text-violet-600 bg-violet-50`},{label:`Clicks (30d)`,value:o8(e.total_clicks_30d),icon:Hl,color:`text-cyan-600 bg-cyan-50`},{label:`Conversions`,value:e.total_conversions_30d.toFixed(0),icon:yu,color:`text-emerald-600 bg-emerald-50`},{label:`Avg CTR`,value:s8(e.avg_ctr),icon:wu,color:`text-green-600 bg-green-50`},{label:`Avg CPC`,value:a8(e.avg_cpc),icon:dl,color:`text-amber-600 bg-amber-50`},{label:`Avg CPA`,value:a8(e.avg_cpa),icon:Cu,color:`text-red-600 bg-red-50`},{label:`ROAS`,value:e.total_roas?`${e.total_roas.toFixed(2)}x`:`—`,icon:Ru,color:`text-indigo-600 bg-indigo-50`}].map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex rounded-lg p-2 mb-2 ${e.color}`,children:(0,L.jsx)(e.icon,{className:`h-4 w-4`})}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.label}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900 mt-0.5`,children:e.value})]},e.label))}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Spend`}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Last 30 days`}),(0,L.jsx)(`span`,{className:`font-semibold text-blue-600`,children:a8(e.total_spend_30d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Last 90 days`}),(0,L.jsx)(`span`,{className:`font-semibold text-blue-600`,children:a8(e.total_spend_90d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Year to date`}),(0,L.jsx)(`span`,{className:`font-semibold text-blue-600`,children:a8(e.total_spend_ytd)})]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Performance`}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Impressions (30d)`}),(0,L.jsx)(`span`,{className:`font-semibold text-violet-600`,children:o8(e.total_impressions_30d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Clicks (30d)`}),(0,L.jsx)(`span`,{className:`font-semibold text-cyan-600`,children:o8(e.total_clicks_30d)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Conversions (30d)`}),(0,L.jsx)(`span`,{className:`font-semibold text-emerald-600`,children:e.total_conversions_30d.toFixed(0)})]})]})]})]}),e.campaigns_by_status&&e.campaigns_by_status.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Campaigns by Status`}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-3`,children:e.campaigns_by_status.map(e=>(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500 capitalize`,children:e.status}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:e.count}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[`Budget: `,a8(e.total_budget)]})]},e.status))})]}),e.campaigns_by_channel&&e.campaigns_by_channel.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Campaigns by Channel`}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-3`,children:e.campaigns_by_channel.map(e=>(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:d8(e.channel_type)}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:e.count}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[`Spend: `,a8(e.total_spend)]})]},e.channel_type))})]}),e.top_campaigns&&e.top_campaigns.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Top Campaigns`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:e.top_campaigns.map(e=>(0,L.jsxs)(`div`,{className:`flex justify-between items-center py-2 border-b border-surface-100 last:border-0`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:e.name}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[e.clicks,` clicks · `,e.conversions?.toFixed(0)||0,` conversions`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${c8(e.status)}`,children:l8(e.status)}),(0,L.jsx)(`span`,{className:`font-semibold text-blue-600`,children:a8(e.spend)})]})]},e.external_id))})]})]})}function p8({companyId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(null),{data:s,isLoading:c}=R({queryKey:[`facebook-ads-campaigns`,e,t,r],queryFn:()=>G$.getCampaigns(e,{search:t||void 0,status:r||void 0}),staleTime:6e4}),l=s?.data?.items||[];return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search campaigns...`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Statuses`}),(0,L.jsx)(`option`,{value:`ACTIVE`,children:`Active`}),(0,L.jsx)(`option`,{value:`PAUSED`,children:`Paused`}),(0,L.jsx)(`option`,{value:`DELETED`,children:`Deleted`})]})]}),c?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Campaign`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Channel`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Budget`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Spend`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Clicks`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Conversions`})]})}),(0,L.jsx)(`tbody`,{children:l.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:7,className:`text-center py-8 text-surface-400`,children:`No campaigns found`})}):l.map(e=>(0,L.jsxs)(`tr`,{onClick:()=>o(e),className:`border-t border-surface-100 hover:bg-surface-50 cursor-pointer`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900`,children:e.name}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${c8(e.status)}`,children:l8(e.status)})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500`,children:d8(e.channel_type)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-medium`,children:a8(e.budget)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-medium text-blue-600`,children:a8(e.total_spend)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-600`,children:o8(e.total_clicks)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-emerald-600 font-medium`,children:e.total_conversions.toFixed(0)})]},e.id))})]})}),a&&(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/30`,onClick:()=>o(null)}),(0,L.jsxs)(`div`,{className:`relative z-10 flex h-full w-full max-w-lg flex-col overflow-y-auto bg-white shadow-xl border-l border-surface-200`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:a.name}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500`,children:[d8(a.channel_type),` · `,a.budget_type,` budget`]})]}),(0,L.jsx)(`button`,{onClick:()=>o(null),className:`rounded-lg p-2 text-surface-400 hover:bg-surface-100 min-h-[44px] min-w-[44px] flex items-center justify-center`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Status`}),(0,L.jsx)(`span`,{className:`inline-block mt-1 rounded-full px-2 py-0.5 text-xs font-semibold ${c8(a.status)}`,children:l8(a.status)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Budget`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900`,children:a8(a.budget)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Spend`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-blue-600`,children:a8(a.total_spend)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Conversions`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-emerald-600`,children:a.total_conversions.toFixed(0)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Clicks`}),(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:o8(a.total_clicks)})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Channel`}),(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:d8(a.channel_type)})]})]}),a.start_date&&(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Dates`}),(0,L.jsxs)(`div`,{className:`space-y-1 text-sm text-surface-600`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`span`,{children:`Start`}),(0,L.jsx)(`span`,{children:u8(a.start_date)})]}),a.end_date&&(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`span`,{children:`End`}),(0,L.jsx)(`span`,{children:u8(a.end_date)})]})]})]}),(0,L.jsxs)(`div`,{className:`px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Updated`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-600`,children:u8(a.updated_at)})]})]})]})]})}function m8({companyId:e}){let[t,n]=(0,S.useState)(``),{data:r,isLoading:i}=R({queryKey:[`facebook-ads-metrics`,e,t],queryFn:()=>G$.getMetrics(e,{campaign_id:t||void 0,per_page:100}),staleTime:6e4}),a=r?.data?.items||[];return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:(0,L.jsx)(`select`,{value:t,onChange:e=>n(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:(0,L.jsx)(`option`,{value:``,children:`All Campaigns`})})}),i?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Date`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Spend`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Impressions`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Clicks`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`CTR`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`CPC`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Conversions`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`ROAS`})]})}),(0,L.jsx)(`tbody`,{children:a.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:8,className:`text-center py-8 text-surface-400`,children:`No metrics found`})}):a.map(e=>(0,L.jsxs)(`tr`,{className:`border-t border-surface-100 hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-600`,children:u8(e.metric_date)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-medium text-blue-600`,children:a8(e.spend)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-600`,children:o8(e.impressions)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-600`,children:o8(e.clicks)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-500`,children:s8(e.ctr)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-500`,children:a8(e.cpc)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-emerald-600 font-medium`,children:e.conversions.toFixed(0)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-500`,children:e.roas?`${e.roas.toFixed(2)}x`:`—`})]},e.id))})]})})]})}function h8({companyId:e}){let{data:t,isLoading:n}=R({queryKey:[`facebook-ads-analytics`,e],queryFn:()=>G$.getAnalytics(e),staleTime:6e4}),r=t?.data,i=r?.daily_spend_trend||[],a=(0,S.useMemo)(()=>Math.max(...i.map(e=>e.spend||0),1),[i]);return(0,L.jsx)(`div`,{className:`space-y-6`,children:n?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsxs)(L.Fragment,{children:[i.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Daily Spend Trend`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:i.slice(-30).map(e=>{let t=e.spend/a*100;return(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-400 w-16 flex-shrink-0`,children:new Date(e.date).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}),(0,L.jsx)(`div`,{className:`flex-1 bg-surface-100 rounded-full h-6 overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full bg-[#1877F2] rounded-full flex items-center justify-end pr-2 transition-all`,style:{width:`${Math.max(t,2)}%`},children:t>15&&(0,L.jsx)(`span`,{className:`text-xs text-white font-medium`,children:a8(e.spend)})})}),t<=15&&(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:a8(e.spend)})]},e.date)})})]}),i.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Daily Conversions Trend`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:i.slice(-30).map(e=>{let t=Math.max(...i.map(e=>e.conversions||0),1),n=e.conversions/t*100;return(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-400 w-16 flex-shrink-0`,children:new Date(e.date).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}),(0,L.jsx)(`div`,{className:`flex-1 bg-surface-100 rounded-full h-6 overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full bg-emerald-500 rounded-full flex items-center justify-end pr-2 transition-all`,style:{width:`${Math.max(n,2)}%`},children:n>15&&(0,L.jsx)(`span`,{className:`text-xs text-white font-medium`,children:e.conversions.toFixed(0)})})}),n<=15&&(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:e.conversions.toFixed(0)})]},e.date)})})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Spend`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-blue-600`,children:a8(r?.total_spend_30d)})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Avg Daily Spend`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-blue-600`,children:i.length>0?a8(r?.total_spend_30d/i.length):`—`})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Conversions`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-emerald-600`,children:r?.total_conversions_30d?.toFixed(0)||`0`})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`ROAS`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-indigo-600`,children:r?.total_roas?`${r.total_roas.toFixed(2)}x`:`—`})]})]})]})})}function g8(){let{user:e}=W(),[t,n]=(0,S.useState)(`overview`),[r,i]=(0,S.useState)(null),a=ci(),o=e?.tenantId?String(e.tenantId):``;(0,S.useEffect)(()=>{if(r){let e=setTimeout(()=>i(null),4e3);return()=>clearTimeout(e)}},[r]);let{data:s,isLoading:c}=R({queryKey:[`facebook-ads-analytics`,o],queryFn:()=>G$.getAnalytics(o),staleTime:12e4}),l=z({mutationFn:()=>G$.sync(o),onSuccess:()=>{a.invalidateQueries({queryKey:[`facebook-ads`]}),i({message:`Facebook Ads synced successfully`,type:`success`})},onError:e=>{i({message:e?.response?.data?.error||`Facebook Ads sync failed`,type:`error`})}}),u=[{key:`overview`,label:`Overview`,icon:mc},{key:`campaigns`,label:`Campaigns`,icon:Vl},{key:`metrics`,label:`Metrics`,icon:Mc},{key:`trends`,label:`Trends`,icon:wu}];return(0,L.jsxs)($,{children:[r&&(0,L.jsxs)(`div`,{className:`fixed top-4 right-4 z-[70] flex items-center gap-2 rounded-lg bg-surface-900 px-4 py-3 text-sm text-white shadow-lg`,children:[r.type===`success`?(0,L.jsx)(yc,{className:`h-4 w-4 text-green-400`}):(0,L.jsx)(vc,{className:`h-4 w-4 text-red-400`}),r.message]}),(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Facebook Ads`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mt-1`,children:`Meta Ads Manager — campaigns, metrics, and ROAS`})]}),(0,L.jsxs)(`button`,{onClick:()=>l.mutate(),disabled:l.isPending,className:`inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-[#1877F2] text-white text-sm font-medium hover:bg-[#166fe5] disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,L.jsx)(nu,{className:`h-4 w-4 ${l.isPending?`animate-spin`:``}`}),l.isPending?`Syncing...`:`Sync Now`]})]}),(0,L.jsx)(`div`,{className:`flex gap-1 border-b border-surface-200`,children:u.map(e=>(0,L.jsxs)(`button`,{onClick:()=>n(e.key),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t===e.key?`border-[#1877F2] text-[#1877F2]`:`border-transparent text-surface-500 hover:text-surface-700`}`,children:[(0,L.jsx)(e.icon,{className:`h-4 w-4`}),e.label]},e.key))}),c&&t===`overview`?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):t===`overview`&&s?.data?(0,L.jsx)(f8,{analytics:s.data}):t===`campaigns`?(0,L.jsx)(p8,{companyId:o}):t===`metrics`?(0,L.jsx)(m8,{companyId:o}):t===`trends`?(0,L.jsx)(h8,{companyId:o}):null]})]})}var _8=e=>`/api/company/${e}/slack`,v8={async getWorkspace(e){return(await U.get(`${_8(e)}/workspace`)).data},async getChannels(e,t){return(await U.get(`${_8(e)}/channels`,{params:t})).data},async getMessages(e,t){return(await U.get(`${_8(e)}/messages`,{params:t})).data},async sync(e){return(await U.post(`${_8(e)}/sync`)).data},async sendMessage(e,t){return(await U.post(`${_8(e)}/send-message`,t)).data}},y8=`#4A154B`;function b8(e){return e==null?`—`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function x8(e){if(!e)return`—`;let t=Date.now(),n=new Date(e).getTime(),r=Math.abs(t-n),i=Math.floor(r/6e4);if(i<1)return`just now`;if(i<60)return`${i}m ago`;let a=Math.floor(i/60);if(a<24)return`${a}h ago`;let o=Math.floor(a/24);return o===1?`yesterday`:o<30?`${o}d ago`:new Date(e).toLocaleDateString()}function S8(e){return e?new Date(parseFloat(e)*1e3).toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`}):``}function C8(e){return e?new Date(parseFloat(e)*1e3).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`}):``}function w8({companyId:e,channels:t}){let{data:n,isLoading:r}=R({queryKey:[`slack-workspace`,e],queryFn:()=>v8.getWorkspace(e),staleTime:12e4}),i=n?.data?.workspace,a=n?.data?.channel_count||t.length,o=n?.data?.public_count||t.filter(e=>!e.is_private).length,s=n?.data?.private_count||t.filter(e=>e.is_private).length,c=n?.data?.last_sync_at;return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4`,children:[{label:`Workspace`,value:i?.team_name||`—`,icon:Pu,color:`text-purple-700 bg-purple-50`},{label:`Total Channels`,value:a,icon:Sl,color:`text-blue-600 bg-blue-50`},{label:`Public Channels`,value:o,icon:bl,color:`text-emerald-600 bg-emerald-50`},{label:`Private Channels`,value:s,icon:Nl,color:`text-violet-600 bg-violet-50`},{label:`Last Sync`,value:x8(c),icon:nu,color:`text-amber-600 bg-amber-50`},{label:`URL`,value:i?.url?.replace(`https://`,``).split(`.`)[0]||`—`,icon:bl,color:`text-cyan-600 bg-cyan-50`}].map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex rounded-lg p-2 mb-2 ${e.color}`,children:(0,L.jsx)(e.icon,{className:`h-4 w-4`})}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.label}),(0,L.jsx)(`p`,{className:`text-sm font-bold text-surface-900 mt-0.5 truncate`,children:e.value})]},e.label))}),i&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Workspace Details`}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[i.team_name&&(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Team Name`}),(0,L.jsx)(`span`,{className:`font-semibold text-surface-900`,children:i.team_name})]}),i.url&&(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Workspace URL`}),(0,L.jsxs)(`a`,{href:i.url,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-purple-700 hover:underline flex items-center gap-1`,children:[i.url.replace(`https://`,``),(0,L.jsx)(Rc,{className:`h-3 w-3`})]})]}),i.team_id&&(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Team ID`}),(0,L.jsx)(`span`,{className:`font-mono text-sm text-surface-500`,children:i.team_id})]}),i.enterprise_name&&(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Organization`}),(0,L.jsx)(`span`,{className:`font-semibold text-surface-900`,children:i.enterprise_name})]})]})]}),t.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Recent Channels`}),(0,L.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:t.slice(0,8).map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`div`,{className:`rounded-lg bg-purple-100 p-2`,children:e.is_private?(0,L.jsx)(Nl,{className:`h-4 w-4 text-purple-700`}):(0,L.jsx)(bl,{className:`h-4 w-4 text-purple-700`})}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsxs)(`p`,{className:`text-sm font-medium text-surface-900 truncate`,children:[`#`,e.name]}),(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:e.purpose||`No purpose`})]})]},e.id))})]})]})}function T8({companyId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),{data:a,isLoading:o}=R({queryKey:[`slack-channels`,e,t,r],queryFn:()=>v8.getChannels(e,{search:t||void 0,is_private:r||void 0}),staleTime:6e4}),s=a?.data?.items||[];return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search channels...`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-purple-500`})]}),(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-purple-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Channels`}),(0,L.jsx)(`option`,{value:`false`,children:`Public Only`}),(0,L.jsx)(`option`,{value:`true`,children:`Private Only`})]})]}),o?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white`,children:(0,L.jsx)(`div`,{className:`divide-y divide-surface-100`,children:s.length===0?(0,L.jsx)(`div`,{className:`text-center py-12 text-surface-400`,children:`No channels found`}):s.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center gap-4 px-6 py-4 hover:bg-surface-50`,children:[(0,L.jsx)(`div`,{className:`rounded-lg bg-purple-100 p-2 flex-shrink-0`,children:e.is_private?(0,L.jsx)(Nl,{className:`h-4 w-4 text-purple-700`}):(0,L.jsx)(bl,{className:`h-4 w-4 text-purple-700`})}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`span`,{className:`text-sm font-semibold text-surface-900`,children:[`#`,e.name]}),e.is_private&&(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-violet-100 px-2 py-0.5 text-xs font-medium text-violet-700`,children:`Private`})]}),e.purpose&&(0,L.jsx)(`p`,{className:`text-xs text-surface-400 mt-0.5 truncate`,children:e.purpose})]}),(0,L.jsxs)(`div`,{className:`text-right flex-shrink-0`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:e.external_id.slice(0,9)}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[`Synced `,x8(e.synced_at)]})]})]},e.id))})})]})}function E8({companyId:e,channels:t}){let[n,r]=(0,S.useState)(``),[i,a]=(0,S.useState)(``),[o,s]=(0,S.useState)(null),{data:c,isLoading:l}=R({queryKey:[`slack-messages`,e,n,i],queryFn:()=>v8.getMessages(e,{channel_id:n||void 0,search:i||void 0,limit:100}),staleTime:3e4}),u=c?.data?.items||[],d=(0,S.useMemo)(()=>{let e=new Map;return t.forEach(t=>e.set(t.external_id,t.name)),e},[t]);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search messages...`,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-purple-500`})]}),(0,L.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-purple-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Channels`}),t.map(e=>(0,L.jsxs)(`option`,{value:e.external_id,children:[`#`,e.name]},e.id))]})]}),l?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white divide-y divide-surface-100`,children:u.length===0?(0,L.jsx)(`div`,{className:`text-center py-12 text-surface-400`,children:`No messages found`}):u.map(e=>{let t=e.channel_name||d.get(e.channel_id)||e.channel_id.slice(0,9),n=!!e.thread_ts,r=Array.isArray(e.reactions)?e.reactions.length:0;return(0,L.jsx)(`div`,{onClick:()=>s(e),className:`px-6 py-4 hover:bg-surface-50 cursor-pointer transition-colors`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`rounded-full bg-purple-100 h-8 w-8 flex items-center justify-center flex-shrink-0 text-xs font-semibold text-purple-700`,children:(e.user_id||e.bot_name||`?`).charAt(0).toUpperCase()}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsx)(`span`,{className:`text-sm font-semibold text-surface-900`,children:e.bot_name||e.user_id?.slice(0,8)||`Unknown`}),e.bot_name&&(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-blue-100 px-1.5 py-0.5 text-xs font-medium text-blue-700`,children:`Bot`}),(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:`in`}),(0,L.jsxs)(`span`,{className:`text-xs font-medium text-purple-600`,children:[`#`,t]}),n&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded-full bg-surface-100 px-1.5 py-0.5 text-xs text-surface-500`,children:[(0,L.jsx)(zl,{className:`h-3 w-3`}),`thread`]})]}),(0,L.jsx)(`p`,{className:`text-sm text-surface-700 mt-1 line-clamp-3 whitespace-pre-wrap break-words`,children:e.text||(0,L.jsx)(`span`,{className:`text-surface-300 italic`,children:`No text content`})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-4 mt-2`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-surface-400 flex items-center gap-1`,children:[(0,L.jsx)(al,{className:`h-3 w-3`}),C8(e.ts),` `,S8(e.ts)]}),r>0&&(0,L.jsxs)(`span`,{className:`text-xs text-surface-400 flex items-center gap-1`,children:[(0,L.jsx)(A8,{className:`h-3 w-3`}),r]})]})]})]})},e.id)})}),o&&(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/30`,onClick:()=>s(null)}),(0,L.jsxs)(`div`,{className:`relative z-10 flex h-full w-full max-w-lg flex-col overflow-y-auto bg-white shadow-xl border-l border-surface-200`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Message Details`}),(0,L.jsx)(`button`,{onClick:()=>s(null),className:`rounded-lg p-2 text-surface-400 hover:bg-surface-100 min-h-[44px] min-w-[44px] flex items-center justify-center`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,L.jsx)(`div`,{className:`rounded-full bg-purple-100 h-10 w-10 flex items-center justify-center text-sm font-semibold text-purple-700`,children:(o.user_id||o.bot_name||`?`).charAt(0).toUpperCase()}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`font-medium text-surface-900`,children:o.bot_name||o.user_id?.slice(0,8)||`Unknown`}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[`#`,o.channel_name||o.channel_id.slice(0,9)]})]})]}),(0,L.jsx)(`div`,{className:`rounded-lg bg-surface-50 p-4 text-sm text-surface-700 whitespace-pre-wrap break-words`,children:o.text||(0,L.jsx)(`span`,{className:`text-surface-300 italic`,children:`No text content`})})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Timestamp`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:new Date(parseFloat(o.ts)*1e3).toLocaleString()})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Type`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900 capitalize`,children:o.type||`message`})]}),o.thread_ts&&(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Thread`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:`Replied in thread`})]}),o.reactions&&o.reactions.length>0&&(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Reactions`}),(0,L.jsxs)(`p`,{className:`text-sm font-medium text-surface-900`,children:[o.reactions.length,` reactions`]})]})]}),(0,L.jsxs)(`div`,{className:`px-6 py-4`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`External ID`}),(0,L.jsx)(`p`,{className:`text-xs font-mono text-surface-400 break-all`,children:o.external_id})]})]})]})]})}function D8({companyId:e,messages:t}){let n=ci(),[r,i]=(0,S.useState)(null);(0,S.useEffect)(()=>{if(r){let e=setTimeout(()=>i(null),4e3);return()=>clearTimeout(e)}},[r]);let a=z({mutationFn:()=>v8.sync(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`slack-`]}),i({message:`Slack synced successfully`,type:`success`})},onError:e=>{i({message:e?.response?.data?.error||`Slack sync failed`,type:`error`})}}),o=(0,S.useMemo)(()=>{let e=new Map;return t.forEach(t=>{if(t.ts){let n=C8(t.ts);e.set(n,(e.get(n)||0)+1)}}),Array.from(e.entries()).sort((e,t)=>new Date(e[0]).getTime()-new Date(t[0]).getTime()).slice(-30)},[t]),s=(0,S.useMemo)(()=>{let e=new Map;return t.forEach(t=>{let n=t.channel_name||t.channel_id.slice(0,9);e.set(n,(e.get(n)||0)+1)}),Array.from(e.entries()).sort((e,t)=>t[1]-e[1])},[t]),c=t.filter(e=>!!e.bot_name).length,l=t.length-c,u=t.filter(e=>!!e.thread_ts).length,d=Math.max(...o.map(([,e])=>e),1);return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[r&&(0,L.jsxs)(`div`,{className:`fixed top-4 right-4 z-[70] flex items-center gap-2 rounded-lg bg-surface-900 px-4 py-3 text-sm text-white shadow-lg`,children:[r.type===`success`?(0,L.jsx)(yc,{className:`h-4 w-4 text-green-400`}):(0,L.jsx)(vc,{className:`h-4 w-4 text-red-400`}),r.message]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500`,children:`Activity Overview`}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400 mt-0.5`,children:[`Based on `,t.length,` synced messages`]})]}),(0,L.jsxs)(`button`,{onClick:()=>a.mutate(),disabled:a.isPending,className:`flex items-center gap-2 rounded-lg bg-purple-700 hover:bg-purple-800 text-white px-4 py-2 text-sm font-medium disabled:opacity-50 transition-colors`,children:[(0,L.jsx)(nu,{className:`h-4 w-4 ${a.isPending?`animate-spin`:``}`}),a.isPending?`Syncing...`:`Sync Now`]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex rounded-lg p-2 mb-2 text-purple-700 bg-purple-50`,children:(0,L.jsx)(q,{className:`h-4 w-4`})}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Messages`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900 mt-0.5`,children:b8(t.length)})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex rounded-lg p-2 mb-2 text-blue-600 bg-blue-50`,children:(0,L.jsx)(Pu,{className:`h-4 w-4`})}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`User Messages`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900 mt-0.5`,children:b8(l)})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex rounded-lg p-2 mb-2 text-violet-600 bg-violet-50`,children:(0,L.jsx)(Ru,{className:`h-4 w-4`})}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Bot Messages`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900 mt-0.5`,children:b8(c)})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex rounded-lg p-2 mb-2 text-amber-600 bg-amber-50`,children:(0,L.jsx)(zl,{className:`h-4 w-4`})}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Threads`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900 mt-0.5`,children:b8(u)})]})]}),o.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Messages by Day`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:o.map(([e,t])=>{let n=t/d*100;return(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-400 w-16 flex-shrink-0`,children:e}),(0,L.jsx)(`div`,{className:`flex-1 bg-surface-100 rounded-full h-6 overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full flex items-center justify-end pr-2 transition-all`,style:{width:`${Math.max(n,2)}%`,backgroundColor:y8},children:n>15&&(0,L.jsx)(`span`,{className:`text-xs text-white font-medium`,children:t})})}),n<=15&&(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:t})]},e)})})]}),s.length>0&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4`,children:`Messages by Channel`}),(0,L.jsx)(`div`,{className:`space-y-2`,children:s.slice(0,10).map(([e,t],n)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-3 py-2 border-b border-surface-100 last:border-0`,children:[(0,L.jsxs)(`span`,{className:`text-xs font-bold text-surface-300 w-6 text-right`,children:[`#`,n+1]}),(0,L.jsx)(`div`,{className:`rounded-lg bg-purple-100 p-1.5 flex-shrink-0`,children:(0,L.jsx)(Sl,{className:`h-3 w-3 text-purple-700`})}),(0,L.jsxs)(`span`,{className:`text-sm font-medium text-surface-900 flex-1 truncate`,children:[`#`,e]}),(0,L.jsx)(`span`,{className:`text-sm font-semibold text-purple-700`,children:t})]},e))})]})]})}function O8(){let{user:e}=W(),t=e?.current_company_id||e?.companies?.[0]?.id||``,[n,r]=(0,S.useState)(`overview`),i=[{key:`overview`,label:`Overview`,icon:Mc},{key:`channels`,label:`Channels`,icon:Sl},{key:`messages`,label:`Messages`,icon:q},{key:`activity`,label:`Activity`,icon:k8}],{data:a}=R({queryKey:[`slack-channels`,t],queryFn:()=>v8.getChannels(t),staleTime:12e4}),o=a?.data?.items||[],{data:s}=R({queryKey:[`slack-messages`,t],queryFn:()=>v8.getMessages(t,{limit:200}),staleTime:6e4}),c=s?.data?.items||[];return(0,L.jsxs)($,{children:[(0,L.jsx)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6`,children:(0,L.jsx)(`div`,{children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`rounded-xl p-2.5`,style:{backgroundColor:y8},children:(0,L.jsx)(q,{className:`h-6 w-6 text-white`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Slack`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Workspace communication & channel monitoring`})]})]})})}),(0,L.jsx)(`div`,{className:`flex gap-1 mb-6 bg-surface-100 rounded-xl p-1 w-fit`,children:i.map(e=>(0,L.jsxs)(`button`,{onClick:()=>r(e.key),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors min-h-[44px] ${n===e.key?`bg-white text-surface-900 shadow-sm`:`text-surface-500 hover:text-surface-700`}`,children:[(0,L.jsx)(e.icon,{className:`h-4 w-4`}),e.label]},e.key))}),(0,L.jsxs)(`div`,{className:`space-y-6`,children:[n===`overview`&&(0,L.jsx)(w8,{companyId:t,channels:o}),n===`channels`&&(0,L.jsx)(T8,{companyId:t}),n===`messages`&&(0,L.jsx)(E8,{companyId:t,channels:o}),n===`activity`&&(0,L.jsx)(D8,{companyId:t,messages:c})]})]})}function k8(e){return(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:[(0,L.jsx)(`polyline`,{points:`22 7 13.5 15.5 8.5 10.5 2 17`}),(0,L.jsx)(`polyline`,{points:`16 7 22 7 22 13`})]})}function A8(e){return(0,L.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,...e,children:(0,L.jsx)(`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`})})}var j8={connected:{label:`Connected`,color:`bg-emerald-100 text-emerald-700`,icon:(0,L.jsx)(ql,{className:`h-3 w-3`})},voicemail:{label:`Voicemail`,color:`bg-amber-100 text-amber-700`,icon:(0,L.jsx)(ql,{className:`h-3 w-3`})},no_answer:{label:`No Answer`,color:`bg-red-100 text-red-700`,icon:(0,L.jsx)(Yl,{className:`h-3 w-3`})},busy:{label:`Busy`,color:`bg-orange-100 text-orange-700`,icon:(0,L.jsx)(Yl,{className:`h-3 w-3`})},appointment_set:{label:`Appt Set`,color:`bg-blue-100 text-blue-700`,icon:(0,L.jsx)(Yc,{className:`h-3 w-3`})}},M8={sms:(0,L.jsx)(q,{className:`h-3.5 w-3.5`}),call:(0,L.jsx)(Zl,{className:`h-3.5 w-3.5`}),email:(0,L.jsx)(su,{className:`h-3.5 w-3.5`}),web:(0,L.jsx)(J,{className:`h-3.5 w-3.5`})},N8={STOP:{label:`STOP`,color:`bg-red-100 text-red-700`},YES:{label:`YES`,color:`bg-emerald-100 text-emerald-700`},CALL_ME:{label:`CALL ME`,color:`bg-amber-100 text-amber-700`}};function P8(e){return e?`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`:`—`}function F8(e){return new Date(e).toLocaleString(`en-US`,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0})}function I8({leadId:e}){let{data:t,isLoading:n}=R({queryKey:[`lead-timeline`,e],queryFn:()=>d$.getLeadTimeline(e)});if(n)return(0,L.jsx)(FQ,{});let r=t?.touchpoints??[];return r.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(al,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No activity yet`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Messages, calls, and emails will appear here.`})]}):(0,L.jsx)(`div`,{className:`space-y-6`,children:(0,S.useMemo)(()=>{let e=new Map;for(let t of r){let n=new Date(t.created_at).toLocaleDateString(`en-US`,{weekday:`long`,month:`long`,day:`numeric`});e.has(n)||e.set(n,[]),e.get(n).push(t)}return Array.from(e.entries())},[r]).map(([e,t])=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-surface-400`,children:e}),(0,L.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>{let t=M8[e.touchpoint_type.split(`_`)[0]]??(0,L.jsx)(J,{className:`h-3.5 w-3.5`}),n=e.direction===`outbound`,r=e.direction===`inbound`;return(0,L.jsxs)(`div`,{className:`flex gap-3 rounded-lg border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full ${n?`bg-blue-100 text-blue-600`:r?`bg-emerald-100 text-emerald-600`:`bg-surface-100 text-surface-500`}`,children:t}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold uppercase ${n?`bg-blue-50 text-blue-600`:r?`bg-emerald-50 text-emerald-600`:`bg-surface-100 text-surface-500`}`,children:e.direction}),(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:F8(e.created_at)})]}),e.content&&(0,L.jsx)(`p`,{className:`mt-1.5 text-sm text-surface-700 line-clamp-2`,children:e.content}),(0,L.jsxs)(`p`,{className:`mt-1 text-xs text-surface-400`,children:[e.touchpoint_type.replace(/_/g,` `),e.reference_id&&` · ${e.reference_id.slice(0,8)}`]})]})]},e.id)})})]},e))})}function L8({leadId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),a=ci(),{data:o,isLoading:s}=R({queryKey:[`messages`,e],queryFn:()=>d$.listMessages({lead_id:e})}),c=z({mutationFn:e=>d$.sendSms(e),onSuccess:()=>{a.invalidateQueries({queryKey:[`messages`]}),a.invalidateQueries({queryKey:[`lead-timeline`]}),n(``)}}),l=o?.messages??[];return s?(0,L.jsx)(FQ,{}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsx)(`div`,{className:`flex gap-2`,children:(0,L.jsx)(`input`,{type:`tel`,value:r,onChange:e=>i(e.target.value),placeholder:`Phone number (E.164)`,className:`flex-1 rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})}),l.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(q,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No messages yet`})]}):(0,L.jsx)(`div`,{className:`space-y-3`,children:l.map(e=>{let t=e.direction===`outbound`,n=e.keyword_flag&&N8[e.keyword_flag];return(0,L.jsx)(`div`,{className:`flex ${t?`justify-end`:`justify-start`}`,children:(0,L.jsxs)(`div`,{className:`max-w-md rounded-lg px-4 py-3 ${t?`bg-brand-600 text-white`:`bg-white border border-surface-200 text-surface-800`}`,children:[n&&(0,L.jsx)(`span`,{className:`mb-1 inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold ${n.color}`,children:n.label}),(0,L.jsx)(`p`,{className:`text-sm`,children:e.body}),(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-[10px] ${t?`text-brand-200`:`text-surface-400`}`,children:[(0,L.jsx)(`span`,{children:F8(e.created_at)}),(0,L.jsx)(`span`,{children:`·`}),(0,L.jsx)(`span`,{className:`capitalize`,children:e.status}),e.keyword_flag&&(0,L.jsx)(`span`,{children:`·`})]})]})},e.id)})}),(0,L.jsxs)(`form`,{onSubmit:n=>{n.preventDefault(),!(!t.trim()||!r.trim()||c.isPending)&&c.mutate({to_phone:r,body:t,lead_id:e})},className:`flex gap-2`,children:[(0,L.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`Type a message...`,className:`flex-1 rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100`}),(0,L.jsx)(`button`,{type:`submit`,disabled:!t.trim()||!r.trim()||c.isPending,className:`inline-flex items-center gap-2 rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50 min-h-[44px]`,children:c.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(su,{className:`h-4 w-4`}),`Send`]})})]})]})}function R8({leadId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(!1),l=ci(),{data:u,isLoading:d}=R({queryKey:[`calls`,e],queryFn:()=>d$.listCalls({lead_id:e})}),f=z({mutationFn:({callId:e,disposition:t})=>d$.updateCallDisposition(e,t),onSuccess:()=>{l.invalidateQueries({queryKey:[`calls`]}),l.invalidateQueries({queryKey:[`lead-timeline`]}),i(null),o(``),n(``),c(!1)}}),p=u?.calls??[];return d?(0,L.jsx)(FQ,{}):p.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-surface-200 bg-white py-16`,children:[(0,L.jsx)(Zl,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No calls logged`}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:`Outbound calls will appear here.`})]}):(0,L.jsx)(`div`,{className:`space-y-4`,children:p.map(e=>{let l=j8[e.disposition]??{label:e.disposition||`Unknown`,color:`bg-surface-100 text-surface-500`,icon:(0,L.jsx)(Zl,{className:`h-3 w-3`})};return(0,L.jsxs)(`div`,{className:`rounded-lg border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full ${e.disposition===`connected`?`bg-emerald-100 text-emerald-600`:e.disposition===`voicemail`?`bg-amber-100 text-amber-600`:`bg-red-100 text-red-600`}`,children:e.direction===`outbound`?(0,L.jsx)(Xl,{className:`h-4 w-4`}):(0,L.jsx)(Jl,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-surface-900`,children:e.to_phone}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold ${l.color}`,children:[l.icon,l.label]})]}),(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-3 text-xs text-surface-400`,children:[(0,L.jsx)(`span`,{children:F8(e.created_at)}),(0,L.jsxs)(`span`,{children:[`Duration: `,P8(e.duration_seconds)]}),(0,L.jsx)(`span`,{className:`capitalize`,children:e.direction})]})]})]}),(0,L.jsx)(`button`,{onClick:()=>{i(e.id),o(e.disposition||``),c(!0)},className:`rounded-md p-2 text-surface-400 hover:text-brand-600 hover:bg-brand-50 transition-colors`,title:`Update disposition`,children:(0,L.jsx)(ql,{className:`h-4 w-4`})})]}),s&&r===e.id&&(0,L.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 border-t border-surface-100 pt-3`,children:[(0,L.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`Select disposition...`}),Object.entries(j8).map(([e,t])=>(0,L.jsx)(`option`,{value:e,children:t.label},e))]}),(0,L.jsx)(`textarea`,{value:t,onChange:e=>n(e.target.value),placeholder:`Add notes...`,rows:2,className:`rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500 resize-none`}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{onClick:()=>{f.mutate({callId:e.id,disposition:a})},disabled:f.isPending||!a,className:`rounded-lg bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50`,children:f.isPending?(0,L.jsx)(K,{className:`h-3 w-3 animate-spin`}):`Save`}),(0,L.jsx)(`button`,{onClick:()=>{c(!1),o(``),n(``)},className:`rounded-lg border border-surface-300 px-3 py-1.5 text-sm text-surface-600 hover:bg-surface-50`,children:`Cancel`})]})]})]},e.id)})})}function z8({leadId:e}){let{data:t,isLoading:n}=R({queryKey:[`lead-metrics`,e],queryFn:()=>d$.getLeadMetrics(e)});if(n)return null;let r=t;if(!r)return null;let i=e=>e===null?`—`:e<1?`< 1 min`:e>=60?`${Math.floor(e/60)}h ${e%60}m`:`${e} min`,a=r.time_to_first_contact_minutes!==null&&r.time_to_first_contact_minutes<5,o=r.time_to_first_contact_minutes!==null&&r.time_to_first_contact_minutes>30;return(0,L.jsxs)(`div`,{className:`rounded-lg border p-4 ${o?`border-red-200 bg-red-50`:a?`border-emerald-200 bg-emerald-50`:`border-surface-200 bg-white`}`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(al,{className:`h-4 w-4 ${o?`text-red-500`:a?`text-emerald-500`:`text-surface-400`}`}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-surface-700`,children:`Speed to Lead`})]}),(0,L.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:`First Contact`}),(0,L.jsx)(`p`,{className:`text-sm font-semibold text-surface-700`,children:i(r.time_to_first_contact_minutes)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:`First SMS`}),(0,L.jsx)(`p`,{className:`text-sm font-semibold text-surface-700`,children:i(r.time_to_first_sms_minutes)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:`First Call`}),(0,L.jsx)(`p`,{className:`text-sm font-semibold text-surface-700`,children:i(r.time_to_first_call_minutes)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:`Contact Type`}),(0,L.jsx)(`p`,{className:`text-sm font-semibold text-surface-700 capitalize`,children:r.first_contact_type??`—`})]})]})]})}function B8(){let{leadId:e}=mt(),t=ft(),[n,r]=(0,S.useState)(`timeline`),i=[{key:`timeline`,label:`Timeline`,icon:(0,L.jsx)(al,{className:`h-4 w-4`})},{key:`sms`,label:`Messages`,icon:(0,L.jsx)(q,{className:`h-4 w-4`})},{key:`calls`,label:`Calls`,icon:(0,L.jsx)(Zl,{className:`h-4 w-4`})}];return e?(0,L.jsxs)($,{title:`SMS & Calls`,children:[(0,L.jsxs)(`button`,{onClick:()=>t(-1),className:`mb-4 inline-flex items-center gap-1 text-sm text-surface-500 hover:text-surface-700`,children:[(0,L.jsx)(Fc,{className:`h-4 w-4`}),`Back`]}),(0,L.jsx)(`div`,{className:`mb-6`,children:(0,L.jsx)(z8,{leadId:e})}),(0,L.jsx)(`div`,{className:`mb-6 flex gap-1 rounded-lg bg-surface-100 p-1`,children:i.map(e=>(0,L.jsxs)(`button`,{onClick:()=>r(e.key),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors ${n===e.key?`bg-white text-surface-900 shadow-sm`:`text-surface-500 hover:text-surface-700`}`,children:[e.icon,e.label]},e.key))}),n===`timeline`&&(0,L.jsx)(I8,{leadId:e}),n===`sms`&&(0,L.jsx)(L8,{leadId:e}),n===`calls`&&(0,L.jsx)(R8,{leadId:e})]}):(0,L.jsx)($,{title:`SMS & Calls`,children:(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16`,children:[(0,L.jsx)(Zl,{className:`h-12 w-12 text-surface-300`}),(0,L.jsx)(`p`,{className:`mt-4 text-sm font-medium text-surface-700`,children:`No lead selected`}),(0,L.jsx)(`button`,{onClick:()=>t(-1),className:`mt-3 text-sm text-brand-600 hover:text-brand-700`,children:`← Go back`})]})})}var V8=`/api`,H8={getTemplates:e=>{let t=e?{vertical:e}:void 0;return U.get(`${V8}/lead-gen/templates`,{params:t})},getTemplate:e=>U.get(`${V8}/lead-gen/templates/${e}`),createTemplate:e=>U.post(`${V8}/lead-gen/templates`,e),getDashboard:(e,t=30)=>U.get(`${V8}/company/${e}/lead-gen/dashboard`,{params:{days:t}}),getCreatives:(e,t)=>U.get(`${V8}/company/${e}/lead-gen/creatives`,{params:t}),createCreative:(e,t)=>U.post(`${V8}/company/${e}/lead-gen/creatives`,t),getRules:e=>U.get(`${V8}/company/${e}/lead-gen/rules`),createRule:(e,t)=>U.post(`${V8}/company/${e}/lead-gen/rules`,t),updateRule:(e,t,n)=>U.put(`${V8}/company/${e}/lead-gen/rules/${t}`,n),toggleRuleActive:(e,t,n)=>U.put(`${V8}/company/${e}/lead-gen/rules/${t}`,{is_active:n}),runRule:(e,t)=>U.post(`${V8}/company/${e}/lead-gen/rules/${t}/run`),getOptimizationLog:(e,t=50,n=30)=>U.get(`${V8}/company/${e}/lead-gen/optimization-log`,{params:{limit:t,days:n}}),getAttributions:(e,t)=>U.get(`${V8}/company/${e}/lead-gen/attribution`,{params:t}),createAttribution:(e,t)=>U.post(`${V8}/company/${e}/lead-gen/attribution`,t),updateAttribution:(e,t,n)=>U.put(`${V8}/company/${e}/lead-gen/attribution/${t}`,n),generateCampaign:(e,t)=>U.post(`${V8}/company/${e}/lead-gen/campaigns/generate`,t)};function U8(e){return e==null?`—`:Math.abs(e)>=1e6?`$${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(2)}`}function W8(e){return e==null?`—`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString()}function G8(e){return e==null?`—`:`${e.toFixed(1)}%`}function K8(e){if(!e)return`—`;let t=Date.now(),n=new Date(e).getTime(),r=Math.abs(t-n),i=Math.floor(r/864e5);return i===0?`today`:i===1?`yesterday`:i<30?`${i}d ago`:new Date(e).toLocaleDateString()}function q8(e){return{ENABLED:`bg-emerald-100 text-emerald-700`,ACTIVE:`bg-emerald-100 text-emerald-700`,PAUSED:`bg-amber-100 text-amber-700`,REMOVED:`bg-gray-100 text-gray-500`,success:`bg-emerald-100 text-emerald-700`,error:`bg-red-100 text-red-700`,lead:`bg-blue-100 text-blue-700`,deal:`bg-emerald-100 text-emerald-700`,click:`bg-violet-100 text-violet-700`}[e]||`bg-gray-100 text-gray-600`}function J8(e){return{hvac:`HVAC`,plumbing:`Plumbing`,roofing:`Roofing`}[e.toLowerCase()]||e}function Y8(e){return{google_ads:`Google Ads`,facebook_ads:`Facebook Ads`}[e]||e}function X8({stats:e}){return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4`,children:[{label:`Total Campaigns`,value:e.total_campaigns,icon:mc,color:`text-blue-600 bg-blue-50`},{label:`Active Campaigns`,value:e.active_campaigns,icon:Mc,color:`text-emerald-600 bg-emerald-50`},{label:`Spend (30d)`,value:U8(e.total_spend_30d),icon:dl,color:`text-violet-600 bg-violet-50`},{label:`Leads (30d)`,value:W8(e.total_leads_30d),icon:yu,color:`text-cyan-600 bg-cyan-50`},{label:`Total Attributions`,value:e.total_attributions,icon:Hl,color:`text-amber-600 bg-amber-50`},{label:`Avg Cost / Lead`,value:U8(e.avg_cost_per_lead),icon:Cu,color:`text-orange-600 bg-orange-50`},{label:`Total ROI`,value:G8(e.total_roi),icon:wu,color:`text-green-600 bg-green-50`},{label:`Active Rules`,value:e.active_rules,icon:Ru,color:`text-indigo-600 bg-indigo-50`},{label:`Creatives`,value:e.total_creatives,icon:Wl,color:`text-pink-600 bg-pink-50`}].map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`div`,{className:`inline-flex rounded-lg p-2 mb-2 ${e.color}`,children:(0,L.jsx)(e.icon,{className:`h-4 w-4`})}),(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.label}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900 mt-0.5`,children:e.value})]},e.label))}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4 flex items-center gap-2`,children:[(0,L.jsx)(yu,{className:`h-4 w-4`}),` Campaign Health`]}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Active Rate`}),(0,L.jsx)(`span`,{className:`font-semibold text-emerald-600`,children:e.total_campaigns>0?`${Math.round(e.active_campaigns/e.total_campaigns*100)}%`:`—`})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Cost Per Lead`}),(0,L.jsx)(`span`,{className:`font-semibold text-blue-600`,children:U8(e.avg_cost_per_lead)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`30-Day Spend`}),(0,L.jsx)(`span`,{className:`font-semibold text-violet-600`,children:U8(e.total_spend_30d)})]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`text-sm font-medium text-surface-500 mb-4 flex items-center gap-2`,children:[(0,L.jsx)(Ru,{className:`h-4 w-4`}),` Optimization`]}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Active Rules`}),(0,L.jsx)(`span`,{className:`font-semibold text-indigo-600`,children:e.active_rules})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Total Creatives`}),(0,L.jsx)(`span`,{className:`font-semibold text-pink-600`,children:e.total_creatives})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Total ROI`}),(0,L.jsx)(`span`,{className:`font-semibold text-green-600`,children:G8(e.total_roi)})]})]})]})]}),(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-blue-50 p-6`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(Tl,{className:`h-5 w-5 text-blue-600 mt-0.5 flex-shrink-0`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-blue-900 mb-1`,children:`Lead Gen Dashboard`}),(0,L.jsx)(`p`,{className:`text-sm text-blue-700`,children:`This dashboard tracks your ad creative templates, live campaigns, automated optimization rules, and lead attribution data. Use the tabs above to manage creatives, configure rules, and monitor attribution ROI across Google Ads and Facebook Ads.`})]})]})})]})}function Z8(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)(``),[i,a]=(0,S.useState)(null),{data:o,isLoading:s}=R({queryKey:[`lead-gen-templates`],queryFn:()=>H8.getTemplates(),staleTime:12e4}),c=o?.data?.templates||[],l=(0,S.useMemo)(()=>c.filter(t=>!(n&&t.vertical!==n||e&&!t.name.toLowerCase().includes(e.toLowerCase())&&!t.slug.toLowerCase().includes(e.toLowerCase()))),[c,n,e]);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search templates...`,value:e,onChange:e=>t(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Verticals`}),(0,L.jsx)(`option`,{value:`hvac`,children:`HVAC`}),(0,L.jsx)(`option`,{value:`plumbing`,children:`Plumbing`}),(0,L.jsx)(`option`,{value:`roofing`,children:`Roofing`})]})]}),s?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Template`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Vertical`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Service`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Headline`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Platform`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Created`})]})}),(0,L.jsx)(`tbody`,{children:l.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:6,className:`text-center py-8 text-surface-400`,children:`No templates found`})}):l.map(e=>(0,L.jsxs)(`tr`,{onClick:()=>a(e),className:`border-t border-surface-100 hover:bg-surface-50 cursor-pointer`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900`,children:e.name}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full bg-surface-100 px-2 py-0.5 text-xs font-semibold text-surface-700`,children:J8(e.vertical)})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500`,children:e.service_type}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-600 max-w-[250px] truncate`,children:e.headline_primary}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500`,children:Y8(e.target_platform)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-400`,children:K8(e.created_at)})]},e.id))})]})}),i&&(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/30`,onClick:()=>a(null)}),(0,L.jsxs)(`div`,{className:`relative z-10 flex h-full w-full max-w-lg flex-col overflow-y-auto bg-white shadow-xl border-l border-surface-200`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-surface-200 px-6 py-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:i.name}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500`,children:[J8(i.vertical),` · `,i.service_type]})]}),(0,L.jsx)(`button`,{onClick:()=>a(null),className:`rounded-lg p-2 text-surface-400 hover:bg-surface-100 min-h-[44px] min-w-[44px] flex items-center justify-center`,children:(0,L.jsx)(Iu,{className:`h-5 w-5`})})]}),(0,L.jsxs)(`div`,{className:`px-6 py-4 space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Headline`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-900 font-medium`,children:i.headline_primary}),i.headline_secondary&&(0,L.jsx)(`p`,{className:`text-sm text-surface-600`,children:i.headline_secondary})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Description`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-700`,children:i.description})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Call to Action`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-900`,children:i.call_to_action})]}),i.display_url&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Display URL`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-700`,children:i.display_url})]}),i.sitelinks&&i.sitelinks.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Sitelinks`}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.sitelinks.map((e,t)=>(0,L.jsx)(`span`,{className:`inline-block rounded-full bg-blue-50 px-2.5 py-0.5 text-xs text-blue-700`,children:e},t))})]}),i.callouts&&i.callouts.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-surface-500 uppercase tracking-wide mb-2`,children:`Callouts`}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.callouts.map((e,t)=>(0,L.jsx)(`span`,{className:`inline-block rounded-full bg-violet-50 px-2.5 py-0.5 text-xs text-violet-700`,children:e},t))})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Platform`}),(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:Y8(i.target_platform)})]})]})]})]})]})}function Q8({companyId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),{data:a,isLoading:o}=R({queryKey:[`lead-gen-creatives`,e],queryFn:()=>H8.getCreatives(e),staleTime:6e4}),s=a?.data?.creatives||[],c=(0,S.useMemo)(()=>s.filter(e=>!(r&&e.vertical!==r||t&&!e.headline_primary.toLowerCase().includes(t.toLowerCase()))),[s,r,t]);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search creatives...`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Verticals`}),(0,L.jsx)(`option`,{value:`hvac`,children:`HVAC`}),(0,L.jsx)(`option`,{value:`plumbing`,children:`Plumbing`}),(0,L.jsx)(`option`,{value:`roofing`,children:`Roofing`})]})]}),o?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Headline`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Vertical`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Service`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Platform`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Updated`})]})}),(0,L.jsx)(`tbody`,{children:c.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:6,className:`text-center py-8 text-surface-400`,children:`No creatives found`})}):c.map(e=>(0,L.jsxs)(`tr`,{className:`border-t border-surface-100 hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900 max-w-[250px] truncate`,children:e.headline_primary}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full bg-surface-100 px-2 py-0.5 text-xs font-semibold text-surface-700`,children:J8(e.vertical)})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500`,children:e.service_type}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500`,children:Y8(e.target_platform)}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${e.is_active?`bg-emerald-100 text-emerald-700`:`bg-gray-100 text-gray-500`}`,children:e.is_active?`Active`:`Inactive`})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-400`,children:K8(e.updated_at)})]},e.id))})]})})]})}function $8({companyId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),a=ci(),{data:o,isLoading:s}=R({queryKey:[`lead-gen-rules`,e],queryFn:()=>H8.getRules(e),staleTime:6e4}),c=o?.data?.rules||[],l=z({mutationFn:async({ruleId:t,isActive:n})=>{await H8.updateRule(e,t,{is_active:!n})},onSuccess:()=>a.invalidateQueries({queryKey:[`lead-gen-rules`,e]})}),u=z({mutationFn:async t=>H8.runRule(e,t),onSuccess:()=>{a.invalidateQueries({queryKey:[`lead-gen-rules`,e]}),a.invalidateQueries({queryKey:[`lead-gen-log`,e]})}}),d=(0,S.useMemo)(()=>c.filter(e=>!(r===`active`&&!e.is_active||r===`inactive`&&e.is_active||t&&!e.name.toLowerCase().includes(t.toLowerCase()))),[c,r,t]);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search rules...`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-surface-300 bg-white pl-10 pr-3 py-2 text-sm outline-none focus:border-brand-500`})]}),(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Rules`}),(0,L.jsx)(`option`,{value:`active`,children:`Active`}),(0,L.jsx)(`option`,{value:`inactive`,children:`Inactive`})]})]}),s?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Rule`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Type`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Condition`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Action`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Actions`})]})}),(0,L.jsx)(`tbody`,{children:d.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:6,className:`text-center py-8 text-surface-400`,children:`No rules found`})}):d.map(e=>(0,L.jsxs)(`tr`,{className:`border-t border-surface-100 hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900`,children:e.name}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full bg-indigo-50 px-2 py-0.5 text-xs font-semibold text-indigo-700`,children:e.rule_type})}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-surface-500 max-w-[200px] truncate`,children:[e.condition_field,` `,e.condition_operator,` `,e.condition_value??`—`]}),(0,L.jsxs)(`td`,{className:`px-4 py-3 text-surface-500`,children:[e.action_type,e.action_value?` ${e.action_value}`:``]}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${e.is_active?`bg-emerald-100 text-emerald-700`:`bg-gray-100 text-gray-500`}`,children:e.is_active?`Active`:`Inactive`})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,L.jsxs)(`button`,{onClick:()=>u.mutate(e.id),disabled:u.isPending||!e.is_active,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-indigo-600 hover:bg-indigo-50 disabled:opacity-40 disabled:cursor-not-allowed min-h-[32px]`,title:`Run rule now`,children:[u.isPending?(0,L.jsx)(nu,{className:`h-3 w-3 animate-spin`}):(0,L.jsx)(Ru,{className:`h-3 w-3`}),`Run`]}),(0,L.jsxs)(`button`,{onClick:()=>l.mutate({ruleId:e.id,isActive:e.is_active}),disabled:l.isPending,className:`inline-flex items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium min-h-[32px] disabled:opacity-40 ${e.is_active?`text-amber-600 hover:bg-amber-50`:`text-emerald-600 hover:bg-emerald-50`}`,title:e.is_active?`Deactivate`:`Activate`,children:[e.is_active?(0,L.jsx)(Lu,{className:`h-3 w-3`}):(0,L.jsx)(Ru,{className:`h-3 w-3`}),e.is_active?`Off`:`On`]})]})})]},e.id))})]})})]})}function e5({companyId:e}){let[t,n]=(0,S.useState)(``),{data:r,isLoading:i}=R({queryKey:[`lead-gen-log`,e],queryFn:()=>H8.getOptimizationLog(e,{limit:100}),staleTime:6e4}),a=r?.data?.logs||[],o=(0,S.useMemo)(()=>t?a.filter(e=>e.source_service===t):a,[a,t]);return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:(0,L.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Sources`}),(0,L.jsx)(`option`,{value:`google_ads`,children:`Google Ads`}),(0,L.jsx)(`option`,{value:`facebook_ads`,children:`Facebook Ads`})]})}),i?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Target`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Action`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Source`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Reason`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`When`})]})}),(0,L.jsx)(`tbody`,{children:o.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:6,className:`text-center py-8 text-surface-400`,children:`No optimization logs`})}):o.map(e=>(0,L.jsxs)(`tr`,{className:`border-t border-surface-100 hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900 max-w-[200px] truncate`,children:e.target_id}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${e.action===`pause`?`bg-amber-100 text-amber-700`:e.action===`delete`?`bg-red-100 text-red-700`:e.action===`scaled`?`bg-emerald-100 text-emerald-700`:e.action===`rebudgeted`?`bg-blue-100 text-blue-700`:`bg-gray-100 text-gray-600`}`,children:e.action})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500`,children:Y8(e.source_service)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500 max-w-[200px] truncate`,children:e.reason||`—`}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${e.previous_value?`bg-emerald-100 text-emerald-700`:`bg-gray-100 text-gray-500`}`,children:e.previous_value?`Applied`:`Pending`})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-400`,children:K8(e.created_at)})]},e.id))})]})})]})}function t5({companyId:e}){let[t,n]=(0,S.useState)(``),[r,i]=(0,S.useState)(``),{data:a,isLoading:o}=R({queryKey:[`lead-gen-attribution`,e,t,r],queryFn:()=>H8.getAttributions(e,{source:t||void 0,status:r||void 0}),staleTime:6e4}),s=a?.data?.attributions||[],c=(0,S.useMemo)(()=>s.reduce((e,t)=>e+(t.lead_value||0),0),[s]),l=(0,S.useMemo)(()=>{let e=s.filter(e=>e.estimated_roi!=null);return e.length===0?0:e.reduce((e,t)=>e+(t.estimated_roi||0),0)/e.length},[s]);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-4 mb-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Attributions`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-surface-900 mt-0.5`,children:s.length})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Total Value`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-emerald-600 mt-0.5`,children:U8(c)})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:`Avg ROI`}),(0,L.jsx)(`p`,{className:`text-lg font-bold text-blue-600 mt-0.5`,children:G8(l)})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-4`,children:[(0,L.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Sources`}),(0,L.jsx)(`option`,{value:`google_ads`,children:`Google Ads`}),(0,L.jsx)(`option`,{value:`facebook_ads`,children:`Facebook Ads`}),(0,L.jsx)(`option`,{value:`web_form`,children:`Web Form`}),(0,L.jsx)(`option`,{value:`phone_call`,children:`Phone Call`})]}),(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All Statuses`}),(0,L.jsx)(`option`,{value:`lead`,children:`Lead`}),(0,L.jsx)(`option`,{value:`deal`,children:`Deal`}),(0,L.jsx)(`option`,{value:`click`,children:`Click`})]})]}),o?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Lead ID`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Source`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Campaign`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`UTM`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`Value`}),(0,L.jsx)(`th`,{className:`text-right px-4 py-3 font-medium text-surface-500`,children:`ROI`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`text-left px-4 py-3 font-medium text-surface-500`,children:`When`})]})}),(0,L.jsx)(`tbody`,{children:s.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:8,className:`text-center py-8 text-surface-400`,children:`No attributions found`})}):s.map(e=>(0,L.jsxs)(`tr`,{className:`border-t border-surface-100 hover:bg-surface-50`,children:[(0,L.jsx)(`td`,{className:`px-4 py-3 font-medium text-surface-900 max-w-[120px] truncate`,children:e.external_lead_id}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-500`,children:Y8(e.source_service)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-600 max-w-[150px] truncate`,children:e.utm_campaign||`—`}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-400 text-xs`,children:e.utm_source||`—`}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right font-medium text-emerald-600`,children:U8(e.lead_value)}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-right text-surface-500`,children:G8(e.estimated_roi)}),(0,L.jsx)(`td`,{className:`px-4 py-3`,children:(0,L.jsx)(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${q8(e.lead_status)}`,children:e.lead_status})}),(0,L.jsx)(`td`,{className:`px-4 py-3 text-surface-400`,children:K8(e.created_at)})]},e.id))})]})})]})}function n5(){let{user:e}=W(),t=e?.companyId||``,[n,r]=(0,S.useState)(`overview`),{data:i,isLoading:a}=R({queryKey:[`lead-gen-dashboard`,t],queryFn:()=>H8.getDashboard(t),staleTime:6e4,enabled:!!t}),o=i?.data||{total_campaigns:0,active_campaigns:0,total_spend_30d:0,total_leads_30d:0,total_attributions:0,avg_cost_per_lead:0,total_roi:0,active_rules:0,total_creatives:0},s=[{key:`overview`,label:`Overview`,icon:mc},{key:`templates`,label:`Templates`,icon:Tc},{key:`creatives`,label:`Creatives`,icon:Wl},{key:`rules`,label:`Rules`,icon:lu},{key:`log`,label:`Log`,icon:Mc},{key:`attribution`,label:`Attribution`,icon:yu}];return(0,L.jsx)($,{title:`Lead Gen`,children:(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl font-semibold text-surface-900`,children:`Lead Generation`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mt-1`,children:`Manage ad templates, creatives, optimization rules, and lead attribution.`})]}),(0,L.jsx)(`div`,{className:`border-b border-surface-200`,children:(0,L.jsx)(`div`,{className:`flex overflow-x-auto scrollbar-hide`,children:s.map(e=>(0,L.jsxs)(`button`,{onClick:()=>r(e.key),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap min-h-[48px] ${n===e.key?`border-brand-500 text-brand-700`:`border-transparent text-surface-500 hover:text-surface-700 hover:border-surface-300`}`,children:[(0,L.jsx)(e.icon,{className:`h-4 w-4`}),e.label]},e.key))})}),a&&n===`overview`?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(PQ,{})}):(()=>{switch(n){case`overview`:return(0,L.jsx)(X8,{stats:o});case`templates`:return(0,L.jsx)(Z8,{});case`creatives`:return(0,L.jsx)(Q8,{companyId:t});case`rules`:return(0,L.jsx)($8,{companyId:t});case`log`:return(0,L.jsx)(e5,{companyId:t});case`attribution`:return(0,L.jsx)(t5,{companyId:t});default:return(0,L.jsx)(X8,{stats:o})}})()]})})}function r5(){let e=ft(),{user:t}=W(),n=t?.company_id;ci();let[r,i]=(0,S.useState)(`template`),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(``),[l,u]=(0,S.useState)({city:``,radius_miles:25,daily_budget:100,target_cpa:50,source_service:`google_ads`,campaign_name:``}),{data:d,isLoading:f}=R({queryKey:[`lead-gen-templates`,s],queryFn:()=>H8.getTemplates(s||void 0)}),p=d?.data?.templates||[],m=z({mutationFn:e=>H8.generateCampaign(n,e),onSuccess:t=>{let n=t.data.data.campaign_ids;n.length>0&&e(`/app/lead-gen/campaigns/${n[0]}`)}}),h=e=>{o(e),i(`config`),e.budget_recommendation&&u(t=>({...t,daily_budget:Math.round(e.budget_recommendation/30)})),e.target_cpa&&u(t=>({...t,target_cpa:e.target_cpa})),u(t=>({...t,campaign_name:`${e.name} — ${l.city||`Your City`}`}))},g=()=>{!a||!n||m.mutate({template_id:a.id,source_service:l.source_service,city:l.city,radius_miles:l.radius_miles,daily_budget:l.daily_budget,target_cpa:l.target_cpa,campaign_name:l.campaign_name||`${a.name} — ${l.city}`})},_=l.city.trim()&&l.daily_budget>0&&l.radius_miles>0,v=a?.structure,y=[{key:`template`,label:`Template`},{key:`config`,label:`Config`},{key:`preview`,label:`Preview`},{key:`launch`,label:`Launch`}],b=y.findIndex(e=>e.key===r);return(0,L.jsx)($,{title:`Campaign Builder`,children:(0,L.jsxs)(`div`,{className:`max-w-5xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>e(`/app/lead-gen`),className:`p-2 hover:bg-surface-100 rounded-lg transition-colors`,children:(0,L.jsx)(Fc,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`New Campaign`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Select a template, configure settings, and launch on Google or Facebook Ads.`})]})]}),(0,L.jsx)(`div`,{className:`flex items-center gap-0 mb-8`,children:y.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${t<=b?`bg-brand-50 text-brand-700`:`bg-surface-100 text-surface-400`}`,children:[(0,L.jsx)(`span`,{className:`flex h-6 w-6 items-center justify-center rounded-full text-xs font-bold ${t<b?`bg-brand-600 text-white`:t===b?`bg-brand-200 text-brand-700`:`bg-surface-200 text-surface-500`}`,children:t<b?(0,L.jsx)(Xc,{className:`h-3 w-3`}):t+1}),e.label]}),t<y.length-1&&(0,L.jsx)(el,{className:`h-4 w-4 text-surface-300 mx-1`})]},e.key))}),r===`template`&&(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-6`,children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-2`,children:`Filter by vertical`}),(0,L.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:`w-full sm:w-64 rounded-lg border border-surface-200 bg-white px-3 py-2 text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,children:[(0,L.jsx)(`option`,{value:``,children:`All verticals`}),(0,L.jsx)(`option`,{value:`roofing`,children:`Roofing`}),(0,L.jsx)(`option`,{value:`hvac`,children:`HVAC`}),(0,L.jsx)(`option`,{value:`plumbing`,children:`Plumbing`})]})]}),f?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(K,{className:`h-8 w-8 animate-spin text-brand-500`})}):(0,L.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:p.map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>h(e),className:`group text-left rounded-xl border-2 border-surface-200 p-5 hover:border-brand-300 hover:shadow-md transition-all`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between mb-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(_l,{className:`h-5 w-5 text-brand-500`}),(0,L.jsx)(`h3`,{className:`font-semibold text-surface-900`,children:e.name})]}),(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-surface-100 px-2 py-0.5 text-xs font-medium text-surface-600 capitalize`,children:e.vertical})]}),e.description&&(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mb-3`,children:e.description}),(0,L.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-surface-400`,children:[e.budget_recommendation&&(0,L.jsxs)(`span`,{children:[`~$`,e.budget_recommendation.toLocaleString(),`/mo`]}),e.target_cpa&&(0,L.jsxs)(`span`,{children:[`Target CPA: $`,e.target_cpa]})]}),(0,L.jsx)(`div`,{className:`mt-3 text-sm font-medium text-brand-600 opacity-0 group-hover:opacity-100 transition-opacity`,children:`Select template →`})]},e.id))})]}),r===`config`&&a&&(0,L.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-3`,children:[(0,L.jsxs)(`div`,{className:`lg:col-span-2 space-y-6`,children:[(0,L.jsx)(`div`,{className:`rounded-xl border border-brand-200 bg-brand-50 p-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-semibold text-brand-900`,children:a.name}),(0,L.jsx)(`p`,{className:`text-xs text-brand-600 capitalize`,children:a.vertical})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(`template`),className:`text-xs font-medium text-brand-600 hover:text-brand-800`,children:`Change`})]})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Campaign Name`}),(0,L.jsx)(`input`,{type:`text`,value:l.campaign_name,onChange:e=>u(t=>({...t,campaign_name:e.target.value})),className:`w-full rounded-lg border border-surface-200 px-3 py-2 text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`e.g. Emergency Roof Repair — Austin, TX`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Platform`}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[`google_ads`,`facebook_ads`].map(e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>u(t=>({...t,source_service:e})),className:`rounded-lg border-2 px-4 py-3 text-sm font-medium transition-all ${l.source_service===e?`border-brand-500 bg-brand-50 text-brand-700`:`border-surface-200 text-surface-600 hover:border-surface-300`}`,children:e===`google_ads`?`Google Ads`:`Facebook Ads`},e))})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:[(0,L.jsx)(Il,{className:`h-4 w-4 inline mr-1`}),`City`]}),(0,L.jsx)(`input`,{type:`text`,value:l.city,onChange:e=>u(t=>({...t,city:e.target.value})),className:`w-full rounded-lg border border-surface-200 px-3 py-2 text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-100`,placeholder:`City name`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Radius (miles)`}),(0,L.jsx)(`input`,{type:`number`,min:5,max:100,value:l.radius_miles,onChange:e=>u(t=>({...t,radius_miles:Number(e.target.value)})),className:`w-full rounded-lg border border-surface-200 px-3 py-2 text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:[(0,L.jsx)(dl,{className:`h-4 w-4 inline mr-1`}),`Daily Budget`]}),(0,L.jsx)(`input`,{type:`number`,min:10,max:500,value:l.daily_budget,onChange:e=>u(t=>({...t,daily_budget:Number(e.target.value)})),className:`w-full rounded-lg border border-surface-200 px-3 py-2 text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-100`}),(0,L.jsx)(`p`,{className:`text-xs text-surface-400 mt-1`,children:`Max $500/day (safety cap)`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:[(0,L.jsx)(yu,{className:`h-4 w-4 inline mr-1`}),`Target CPA`]}),(0,L.jsx)(`input`,{type:`number`,min:10,value:l.target_cpa,onChange:e=>u(t=>({...t,target_cpa:Number(e.target.value)})),className:`w-full rounded-lg border border-surface-200 px-3 py-2 text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(`preview`),disabled:!_,className:`w-full sm:w-auto px-6 py-2.5 rounded-lg bg-brand-600 text-white font-medium text-sm hover:bg-brand-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:`Preview Campaign →`})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 p-5 bg-white`,children:[(0,L.jsx)(`h3`,{className:`font-semibold text-surface-900 mb-4`,children:`Summary`}),(0,L.jsxs)(`dl`,{className:`space-y-3 text-sm`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-surface-500`,children:`Daily budget`}),(0,L.jsxs)(`dd`,{className:`font-medium`,children:[`$`,l.daily_budget]})]}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-surface-500`,children:`Monthly est.`}),(0,L.jsxs)(`dd`,{className:`font-medium`,children:[`$`,(l.daily_budget*30).toLocaleString()]})]}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-surface-500`,children:`Target CPA`}),(0,L.jsxs)(`dd`,{className:`font-medium`,children:[`$`,l.target_cpa]})]}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-surface-500`,children:`Target`}),(0,L.jsxs)(`dd`,{className:`font-medium capitalize`,children:[l.city,`, `,l.radius_miles,`mi`]})]}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(`dt`,{className:`text-surface-500`,children:`Platform`}),(0,L.jsx)(`dd`,{className:`font-medium capitalize`,children:l.source_service===`google_ads`?`Google Ads`:`Facebook Ads`})]})]})]})]}),r===`preview`&&a&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`mb-6`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(`config`),className:`text-sm font-medium text-surface-500 hover:text-surface-700`,children:`← Back to config`})}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4 bg-surface-50`,children:[(0,L.jsx)(`h2`,{className:`font-semibold text-surface-900`,children:l.campaign_name||`${a.name} — ${l.city}`}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500`,children:[l.source_service===`google_ads`?`Google Ads`:`Facebook Ads`,` · `,l.city,` · $`,l.daily_budget,`/day`]})]}),v?.ad_groups?.map((e,n)=>(0,L.jsxs)(`div`,{className:`border-b border-surface-200 p-6 last:border-b-0`,children:[(0,L.jsxs)(`h3`,{className:`font-medium text-surface-900 mb-3`,children:[`Ad Group `,n+1,`: `,e.name]}),e.keywords&&e.keywords.length>0&&(0,L.jsxs)(`div`,{className:`mb-4`,children:[(0,L.jsxs)(`p`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400 mb-2`,children:[`Keywords (`,e.keywords.length,`)`]}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.keywords.map((e,t)=>(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-surface-100 px-2.5 py-1 text-xs font-medium text-surface-600`,children:e.replace(/{city}/g,l.city).replace(/{state}/g,``)},t))})]}),e.headlines&&e.headlines.length>0&&(0,L.jsxs)(`div`,{className:`mb-3`,children:[(0,L.jsxs)(`p`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400 mb-2`,children:[`Headlines (`,e.headlines.length,`)`]}),(0,L.jsx)(`ul`,{className:`space-y-1`,children:e.headlines.map((e,n)=>(0,L.jsx)(`li`,{className:`text-sm text-surface-700`,children:e.replace(/{city}/g,l.city).replace(/{company}/g,t?.company_name||`Your Company`)},n))})]}),e.descriptions&&e.descriptions.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`p`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400 mb-2`,children:[`Descriptions (`,e.descriptions.length,`)`]}),(0,L.jsx)(`ul`,{className:`space-y-1`,children:e.descriptions.map((e,n)=>(0,L.jsx)(`li`,{className:`text-sm text-surface-600`,children:e.replace(/{city}/g,l.city).replace(/{company}/g,t?.company_name||`Your Company`)},n))})]})]},n))]}),(0,L.jsxs)(`div`,{className:`mt-6 flex items-start gap-3 rounded-lg bg-amber-50 border border-amber-200 p-4`,children:[(0,L.jsx)(vc,{className:`h-5 w-5 text-amber-600 shrink-0 mt-0.5`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-amber-800`,children:`Safety caps enforced`}),(0,L.jsxs)(`p`,{className:`text-xs text-amber-700 mt-1`,children:[`Daily budget is capped at $500 and monthly at $5,000. This campaign will spend ~$`,(l.daily_budget*30).toLocaleString(),`/month based on the daily budget.`]})]})]}),(0,L.jsxs)(`div`,{className:`mt-6 flex items-center gap-4`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:g,disabled:!_||m.isPending,className:`px-8 py-2.5 rounded-lg bg-brand-600 text-white font-medium text-sm hover:bg-brand-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-2`,children:[m.isPending?(0,L.jsx)(K,{className:`h-4 w-4 animate-spin`}):null,m.isPending?`Launching...`:`Launch Campaign`]}),m.error&&(0,L.jsx)(`p`,{className:`text-sm text-red-600`,children:m.error instanceof Error?m.error.message:`Launch failed`})]})]})]})})}function i5(){let{campaignId:e}=mt(),t=ft(),{user:n}=W(),r=n?.company_id,{data:i,isLoading:a}=R({queryKey:[`lead-gen-dashboard`,r,30],queryFn:()=>H8.getDashboard(r,30),enabled:!!r}),{data:o}=R({queryKey:[`lead-gen-attribution`,r,30],queryFn:()=>H8.getAttributions(r,{days:30}),enabled:!!r}),{data:s}=R({queryKey:[`lead-gen-rules`,r],queryFn:()=>H8.getRules(r),enabled:!!r}),{data:c}=R({queryKey:[`lead-gen-log`,r,50],queryFn:()=>H8.getOptimizationLog(r,50,30),enabled:!!r}),l=i?.data?.data,u=o?.data?.data?.attributions||[],d=o?.data?.data?.summary,f=s?.data?.data?.rules||[],p=c?.data?.data?.logs||[];if(a)return(0,L.jsx)($,{title:`Campaign Detail`,children:(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(K,{className:`h-8 w-8 animate-spin text-brand-500`})})});let m=l?.campaigns?.total_impressions||0,h=l?.campaigns?.total_clicks||0,g=l?.campaigns?.total_conversions||0,_=l?.campaigns?.total_spend||0,v=m>0?(h/m*100).toFixed(2):`0.00`,y=g>0?(_/g).toFixed(2):`—`;return(0,L.jsx)($,{title:`Campaign Detail`,children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>t(`/app/lead-gen`),className:`p-2 hover:bg-surface-100 rounded-lg transition-colors`,children:(0,L.jsx)(Fc,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Campaign Detail`}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500`,children:[`Campaign `,e?.slice(0,8)||`—`,` · Performance overview`]})]})]}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-8`,children:[{label:`Active`,value:l?.campaigns?.active||0,icon:Mc,color:`text-emerald-600`},{label:`Spend`,value:`$${_.toLocaleString(void 0,{maximumFractionDigits:0})}`,icon:dl,color:`text-blue-600`},{label:`Impressions`,value:m.toLocaleString(),icon:hl,color:`text-purple-600`},{label:`Clicks`,value:h.toLocaleString(),icon:Ul,color:`text-orange-600`},{label:`Conversions`,value:g,icon:yu,color:`text-emerald-600`},{label:`CPA`,value:y===`—`?`—`:`$${y}`,icon:dl,color:`text-amber-600`}].map(e=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(e.icon,{className:`h-4 w-4 ${e.color}`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:e.label})]}),(0,L.jsx)(`p`,{className:`text-xl font-bold ${e.color}`,children:e.value})]},e.label))}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-8`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-1`,children:`Click-Through Rate`}),(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,L.jsxs)(`span`,{className:`text-3xl font-bold text-surface-900`,children:[v,`%`]}),(0,L.jsxs)(`span`,{className:`text-sm text-surface-400`,children:[h.toLocaleString(),` / `,m.toLocaleString(),` clicks`]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-surface-500 mb-1`,children:`Return on Ad Spend`}),(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`text-3xl font-bold text-surface-900`,children:d?.overall_roas?`${d.overall_roas.toFixed(1)}x`:`—`}),d&&(0,L.jsxs)(`span`,{className:`text-sm text-surface-400`,children:[`$`,d.total_revenue.toLocaleString(),` / $`,d.total_spend.toLocaleString()]})]})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white mb-8 overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`h2`,{className:`font-semibold text-surface-900`,children:`Lead Attribution`}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500`,children:[d?.attribution_count||0,` leads tracked in last 30 days`]})]}),u.length===0?(0,L.jsxs)(`div`,{className:`px-6 py-12 text-center text-surface-400`,children:[(0,L.jsx)(yu,{className:`h-8 w-8 mx-auto mb-3 opacity-50`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No attribution data yet. Leads will appear here when forms are submitted with UTM params.`})]}):(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Source`}),(0,L.jsx)(`th`,{className:`text-left px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Campaign`}),(0,L.jsx)(`th`,{className:`text-left px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Keyword`}),(0,L.jsx)(`th`,{className:`text-right px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Spend`}),(0,L.jsx)(`th`,{className:`text-right px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Revenue`}),(0,L.jsx)(`th`,{className:`text-right px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`ROAS`}),(0,L.jsx)(`th`,{className:`text-center px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Status`})]})}),(0,L.jsx)(`tbody`,{children:u.map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 last:border-b-0`,children:[(0,L.jsx)(`td`,{className:`px-6 py-3`,children:(0,L.jsx)(`span`,{className:`capitalize text-surface-700`,children:e.utm_source||e.lead_source})}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-surface-700`,children:e.utm_campaign||`—`}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-surface-500`,children:e.utm_term||`—`}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-right tabular-nums text-surface-700`,children:e.total_ad_spend?`$${e.total_ad_spend.toFixed(2)}`:`—`}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-right tabular-nums font-medium text-emerald-600`,children:e.deal_amount?`$${e.deal_amount.toFixed(2)}`:`—`}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-right tabular-nums`,children:e.roas?(0,L.jsxs)(`span`,{className:e.roas>=3?`text-emerald-600 font-medium`:`text-amber-600`,children:[e.roas.toFixed(1),`x`]}):(0,L.jsx)(`span`,{className:`text-surface-400`,children:`—`})}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-center`,children:(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${e.attribution_status===`deal`?`bg-emerald-100 text-emerald-700`:e.attribution_status===`lead`?`bg-blue-100 text-blue-700`:`bg-surface-100 text-surface-600`}`,children:e.attribution_status})})]},e.id))})]})})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`h2`,{className:`font-semibold text-surface-900`,children:`Optimization Actions`}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500`,children:[p.length,` actions in last 30 days · `,f.filter(e=>e.is_active).length,` active rules`]})]}),p.length===0?(0,L.jsxs)(`div`,{className:`px-6 py-12 text-center text-surface-400`,children:[(0,L.jsx)(Mc,{className:`h-8 w-8 mx-auto mb-3 opacity-50`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No optimization actions yet. Rules will trigger based on campaign performance.`})]}):(0,L.jsx)(`div`,{className:`divide-y divide-surface-100`,children:p.slice(0,20).map(e=>(0,L.jsxs)(`div`,{className:`px-6 py-4 flex items-start gap-4`,children:[(0,L.jsx)(`div`,{className:`mt-0.5 shrink-0 h-2 w-2 rounded-full ${e.status===`success`?`bg-emerald-500`:e.status===`failed`?`bg-red-500`:`bg-amber-500`}`}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,L.jsx)(`span`,{className:`font-medium text-sm text-surface-900`,children:e.target_name||e.target_id}),(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-surface-100 px-2 py-0.5 text-xs font-medium text-surface-600 capitalize`,children:e.action}),(0,L.jsx)(`span`,{className:`text-xs text-surface-400 capitalize`,children:e.source_service.replace(`_`,` `)})]}),e.reason&&(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.reason})]}),(0,L.jsx)(`time`,{className:`text-xs text-surface-400 shrink-0 whitespace-nowrap`,children:new Date(e.created_at).toLocaleDateString()})]},e.id))})]})]})})}function a5(){let e=ft(),{user:t}=W(),n=t?.company_id,[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(`ctr`),{data:l,isLoading:u}=R({queryKey:[`lead-gen-creatives`,n,a],queryFn:()=>H8.getCreatives(n,{vertical:a||void 0}),enabled:!!n}),d=l?.data?.data?.creatives||[],f=[...d.filter(e=>{if(!r)return!0;let t=r.toLowerCase();return e.vertical.toLowerCase().includes(t)||e.service_type.toLowerCase().includes(t)||e.headlines.some(e=>e.toLowerCase().includes(t))||e.descriptions.some(e=>e.toLowerCase().includes(t))})].sort((e,t)=>{switch(s){case`ctr`:return(t.avg_ctr||0)-(e.avg_ctr||0);case`clicks`:return t.total_clicks-e.total_clicks;case`conversions`:return t.total_conversions-e.total_conversions;case`date`:return new Date(t.created_at).getTime()-new Date(e.created_at).getTime();default:return 0}}),p=d.reduce((e,t)=>e+t.total_clicks,0),m=d.reduce((e,t)=>e+t.total_conversions,0),h=d.filter(e=>e.is_winner).length;return(0,L.jsx)($,{title:`Creatives Library`,children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-4 mb-8`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>e(`/app/lead-gen`),className:`p-2 hover:bg-surface-100 rounded-lg transition-colors`,children:(0,L.jsx)(Fc,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{className:`flex-1`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Creatives Library`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Ad headlines, descriptions, and performance data`})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4 mb-8`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(mc,{className:`h-4 w-4 text-blue-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Total`})]}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:d.length})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(Tu,{className:`h-4 w-4 text-amber-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Winners`})]}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-amber-600`,children:h})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(Ul,{className:`h-4 w-4 text-orange-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Clicks`})]}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-orange-600`,children:p.toLocaleString()})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(yu,{className:`h-4 w-4 text-emerald-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Conversions`})]}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-emerald-600`,children:m})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-6`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:`Search headlines, descriptions...`,className:`w-full rounded-lg border border-surface-200 pl-10 pr-3 py-2 text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(wc,{className:`h-4 w-4 text-surface-400`}),(0,L.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`rounded-lg border border-surface-200 px-3 py-2 text-sm bg-white focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All verticals`}),(0,L.jsx)(`option`,{value:`roofing`,children:`Roofing`}),(0,L.jsx)(`option`,{value:`hvac`,children:`HVAC`}),(0,L.jsx)(`option`,{value:`plumbing`,children:`Plumbing`})]})]}),(0,L.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:`rounded-lg border border-surface-200 px-3 py-2 text-sm bg-white focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:`ctr`,children:`Sort: CTR`}),(0,L.jsx)(`option`,{value:`clicks`,children:`Sort: Clicks`}),(0,L.jsx)(`option`,{value:`conversions`,children:`Sort: Conversions`}),(0,L.jsx)(`option`,{value:`date`,children:`Sort: Newest`})]})]}),u?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(K,{className:`h-8 w-8 animate-spin text-brand-500`})}):f.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-12 text-center`,children:[(0,L.jsx)(hl,{className:`h-8 w-8 mx-auto mb-3 text-surface-300`}),(0,L.jsx)(`p`,{className:`text-surface-500 font-medium`,children:`No creatives found`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-400 mt-1`,children:`Creatives will appear here as campaigns run and generate performance data.`})]}):(0,L.jsx)(`div`,{className:`space-y-4`,children:f.map(e=>(0,L.jsx)(o5,{creative:e},e.id))})]})})}function o5({creative:e}){let t=e.avg_ctr?`${e.avg_ctr.toFixed(2)}%`:`—`;return(0,L.jsxs)(`div`,{className:`rounded-xl border-2 p-5 transition-all ${e.is_winner?`border-amber-200 bg-amber-50/50`:`border-surface-200 bg-white hover:border-surface-300`}`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between mb-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg ${e.is_winner?`bg-amber-100 text-amber-700`:`bg-brand-50 text-brand-600`}`,children:(0,L.jsx)(`span`,{className:`text-xs font-bold uppercase`,children:e.ad_type.slice(0,2)})}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`font-semibold text-surface-900 capitalize`,children:e.service_type}),e.is_winner&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-700`,children:[(0,L.jsx)(Tu,{className:`h-3 w-3`}),`Winner`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-surface-400`,children:[(0,L.jsx)(`span`,{className:`capitalize`,children:e.vertical}),(0,L.jsx)(`span`,{children:`·`}),(0,L.jsx)(`span`,{className:`capitalize`,children:e.ad_type})]})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-6 text-right`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:`CTR`}),(0,L.jsx)(`p`,{className:`text-sm font-bold ${e.avg_ctr&&e.avg_ctr>3?`text-emerald-600`:`text-surface-700`}`,children:t})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:`Clicks`}),(0,L.jsx)(`p`,{className:`text-sm font-bold text-surface-700`,children:e.total_clicks.toLocaleString()})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:`Conv.`}),(0,L.jsx)(`p`,{className:`text-sm font-bold text-emerald-600`,children:e.total_conversions})]})]})]}),e.headlines.length>0&&(0,L.jsxs)(`div`,{className:`mb-3`,children:[(0,L.jsxs)(`p`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400 mb-2`,children:[`Headlines (`,e.headlines.length,`)`]}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.headlines.map((e,t)=>(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-100 px-2.5 py-1 text-xs text-surface-700`,children:e},t))})]}),e.descriptions.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`p`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400 mb-2`,children:[`Descriptions (`,e.descriptions.length,`)`]}),(0,L.jsx)(`div`,{className:`space-y-1`,children:e.descriptions.map((e,t)=>(0,L.jsx)(`p`,{className:`text-xs text-surface-500 leading-relaxed`,children:e},t))})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-center justify-between border-t border-surface-100 pt-3`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-surface-400`,children:[e.total_impressions.toLocaleString(),` impressions · Created `,new Date(e.created_at).toLocaleDateString()]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-surface-400`,children:[(0,L.jsx)(hl,{className:`h-3 w-3`}),(0,L.jsx)(`span`,{children:e.total_impressions.toLocaleString()})]})]})]})}var s5=[{value:`pause_low_ctr_ad`,label:`Pause Low CTR Ad`,description:`Auto-pause ads with CTR below threshold`,target_level:`ad`,default_params:{min_ctr:.01,days:7}},{value:`scale_winning_ad`,label:`Scale Winning Ad`,description:`Increase budget on high-converting ads`,target_level:`ad`,default_params:{min_conversions:3,budget_increase_pct:.25}},{value:`kill_negative_keywords`,label:`Kill Negative Keywords`,description:`Add low-performing keywords to negatives`,target_level:`keyword`,default_params:{min_clicks:10,max_ctr:.005}},{value:`adjust_bid_up`,label:`Adjust Bid Up`,description:`Raise bids on high-ROAS campaigns`,target_level:`campaign`,default_params:{min_roas:3,bid_increase_pct:.15}},{value:`adjust_bid_down`,label:`Adjust Bid Down`,description:`Lower bids on campaigns exceeding CPA target`,target_level:`campaign`,default_params:{max_cpa:50,bid_decrease_pct:.2}}];function c5(){let e=ft(),{user:t}=W(),n=t?.company_id,r=ci(),[i,a]=(0,S.useState)(!1),[o,s]=(0,S.useState)(!1),{data:c,isLoading:l}=R({queryKey:[`lead-gen-rules`,n],queryFn:()=>H8.getRules(n),enabled:!!n}),{data:u}=R({queryKey:[`lead-gen-log`,n,50],queryFn:()=>H8.getOptimizationLog(n,50,30),enabled:!!n&&o}),d=z({mutationFn:e=>H8.createRule(n,e),onSuccess:()=>{r.invalidateQueries({queryKey:[`lead-gen-rules`]}),a(!1)}}),f=z({mutationFn:({ruleId:e,is_active:t})=>H8.toggleRuleActive(n,e,t),onSuccess:()=>r.invalidateQueries({queryKey:[`lead-gen-rules`]})}),p=z({mutationFn:e=>H8.runRule(n,e),onSuccess:()=>{r.invalidateQueries({queryKey:[`lead-gen-rules`]}),r.invalidateQueries({queryKey:[`lead-gen-log`]})}}),m=c?.data?.data?.rules||[],h=u?.data?.data?.logs||[],g=m.filter(e=>e.is_active).length,_=m.reduce((e,t)=>e+t.total_actions,0);return(0,L.jsx)($,{title:`Optimization Center`,children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-8`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>e(`/app/lead-gen`),className:`p-2 hover:bg-surface-100 rounded-lg transition-colors`,children:(0,L.jsx)(Fc,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Optimization Center`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Automated rules for campaign optimization`})]})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>a(!0),className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-brand-600 text-white font-medium text-sm hover:bg-brand-700 transition-colors`,children:[(0,L.jsx)(eu,{className:`h-4 w-4`}),`New Rule`]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-4 mb-8`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(lu,{className:`h-4 w-4 text-blue-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Total Rules`})]}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:m.length})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(Ru,{className:`h-4 w-4 text-emerald-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Active`})]}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-emerald-600`,children:g})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(Mc,{className:`h-4 w-4 text-purple-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Total Actions`})]}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-purple-600`,children:_})]})]}),i&&(0,L.jsx)(l5,{onClose:()=>a(!1),onSubmit:d.mutate,isPending:d.isPending}),l?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(K,{className:`h-8 w-8 animate-spin text-brand-500`})}):m.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-12 text-center`,children:[(0,L.jsx)(lu,{className:`h-8 w-8 mx-auto mb-3 text-surface-300`}),(0,L.jsx)(`p`,{className:`text-surface-500 font-medium`,children:`No optimization rules yet`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-400 mt-1`,children:`Create a rule to automate campaign adjustments based on performance.`})]}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white overflow-hidden mb-8`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Name`}),(0,L.jsx)(`th`,{className:`text-left px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Type`}),(0,L.jsx)(`th`,{className:`text-left px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Level`}),(0,L.jsx)(`th`,{className:`text-center px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`text-right px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Actions`}),(0,L.jsx)(`th`,{className:`text-right px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Last Run`}),(0,L.jsx)(`th`,{className:`px-6 py-3 w-28`})]})}),(0,L.jsx)(`tbody`,{children:m.map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 last:border-b-0`,children:[(0,L.jsx)(`td`,{className:`px-6 py-4`,children:(0,L.jsx)(`span`,{className:`font-medium text-surface-900`,children:e.name})}),(0,L.jsx)(`td`,{className:`px-6 py-4`,children:(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full bg-surface-100 px-2 py-0.5 text-xs font-medium text-surface-600 capitalize`,children:e.rule_type.replace(/_/g,` `)})}),(0,L.jsx)(`td`,{className:`px-6 py-4`,children:(0,L.jsx)(`span`,{className:`text-xs text-surface-500 capitalize`,children:e.target_level})}),(0,L.jsx)(`td`,{className:`px-6 py-4 text-center`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>f.mutate({ruleId:e.id,is_active:!e.is_active}),className:`inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium transition-colors ${e.is_active?`bg-emerald-100 text-emerald-700 hover:bg-emerald-200`:`bg-surface-100 text-surface-500 hover:bg-surface-200`}`,children:e.is_active?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(yc,{className:`h-3 w-3 mr-1`}),` Active`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Sc,{className:`h-3 w-3 mr-1`}),` Paused`]})})}),(0,L.jsx)(`td`,{className:`px-6 py-4 text-right tabular-nums text-surface-700`,children:e.total_actions}),(0,L.jsx)(`td`,{className:`px-6 py-4 text-right tabular-nums text-surface-400`,children:e.last_run_at?(0,L.jsxs)(`span`,{className:`flex items-center gap-1 justify-end`,children:[(0,L.jsx)(al,{className:`h-3 w-3`}),new Date(e.last_run_at).toLocaleDateString()]}):`Never`}),(0,L.jsx)(`td`,{className:`px-6 py-4`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>p.mutate(e.id),disabled:!e.is_active||p.isPending,className:`flex items-center gap-1 rounded-lg px-2.5 py-1.5 text-xs font-medium text-brand-600 hover:bg-brand-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[(0,L.jsx)(Ql,{className:`h-3 w-3`}),`Run`]})})]},e.id))})]})}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),className:`flex items-center gap-2 text-sm font-medium text-surface-600 hover:text-surface-800 mb-4`,children:[(0,L.jsx)(Mc,{className:`h-4 w-4`}),o?`Hide`:`Show`,` Optimization Log (`,h.length,` entries)`]}),o&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`border-b border-surface-200 px-6 py-4`,children:[(0,L.jsx)(`h3`,{className:`font-semibold text-surface-900`,children:`Optimization Log`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Recent automated actions`})]}),h.length===0?(0,L.jsxs)(`div`,{className:`px-6 py-12 text-center text-surface-400`,children:[(0,L.jsx)(Mc,{className:`h-8 w-8 mx-auto mb-3 opacity-50`}),(0,L.jsx)(`p`,{className:`text-sm`,children:`No optimization actions yet.`})]}):(0,L.jsx)(`div`,{className:`divide-y divide-surface-100 max-h-[400px] overflow-y-auto`,children:h.map(e=>(0,L.jsxs)(`div`,{className:`px-6 py-4 flex items-start gap-4`,children:[(0,L.jsx)(`div`,{className:`mt-0.5 shrink-0 h-2 w-2 rounded-full ${e.status===`success`?`bg-emerald-500`:e.status===`failed`?`bg-red-500`:`bg-amber-500`}`}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,L.jsx)(`span`,{className:`font-medium text-sm text-surface-900`,children:e.target_name}),(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${e.action===`pause`?`bg-red-100 text-red-700`:e.action===`scale`?`bg-emerald-100 text-emerald-700`:`bg-blue-100 text-blue-700`}`,children:e.action}),(0,L.jsx)(`span`,{className:`text-xs text-surface-400 capitalize`,children:e.source_service.replace(`_`,` `)})]}),e.reason&&(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.reason})]}),(0,L.jsxs)(`time`,{className:`text-xs text-surface-400 shrink-0 whitespace-nowrap`,children:[new Date(e.created_at).toLocaleDateString(),` `,new Date(e.created_at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]})]},e.id))})]})]})})}function l5({onClose:e,onSubmit:t,isPending:n}){let[r,i]=(0,S.useState)(`pause_low_ctr_ad`),[a,o]=(0,S.useState)(``),s=s5.find(e=>e.value===r),[c,l]=(0,S.useState)(s.default_params);return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6 mb-8`,children:[(0,L.jsx)(`h2`,{className:`font-semibold text-surface-900 mb-4`,children:`Create Optimization Rule`}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),a.trim()&&t({name:a.trim(),rule_type:s.value,target_level:s.target_level,params:c,is_active:!0})},className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Rule Type`}),(0,L.jsx)(`select`,{value:r,onChange:e=>{i(e.target.value),l(s5.find(t=>t.value===e.target.value).default_params)},className:`w-full sm:w-80 rounded-lg border border-surface-200 px-3 py-2 text-sm focus:border-brand-500`,children:s5.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))}),s&&(0,L.jsx)(`p`,{className:`text-xs text-surface-400 mt-1`,children:s.description})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-1`,children:`Rule Name`}),(0,L.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`e.g. ${s.label} — Campaign`,className:`w-full sm:w-80 rounded-lg border border-surface-200 px-3 py-2 text-sm focus:border-brand-500`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-sm font-medium text-surface-700 mb-2`,children:`Parameters`}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:Object.entries(c).map(([e,t])=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`label`,{className:`block text-xs text-surface-500 mb-1 capitalize`,children:e.replace(/_/g,` `)}),(0,L.jsx)(`input`,{type:`number`,step:`any`,value:t,onChange:t=>l(n=>({...n,[e]:Number(t.target.value)})),className:`w-full rounded-lg border border-surface-200 px-3 py-2 text-sm focus:border-brand-500`})]},e))})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 pt-2`,children:[(0,L.jsx)(`button`,{type:`submit`,disabled:!a.trim()||n,className:`px-4 py-2 rounded-lg bg-brand-600 text-white font-medium text-sm hover:bg-brand-700 disabled:opacity-50 transition-colors`,children:n?`Creating...`:`Create Rule`}),(0,L.jsx)(`button`,{type:`button`,onClick:e,className:`px-4 py-2 rounded-lg text-sm font-medium text-surface-600 hover:bg-surface-100`,children:`Cancel`})]})]})]})}function u5(){let e=ft(),{user:t}=W(),n=t?.company_id,[r,i]=(0,S.useState)(``),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(30),[l,u]=(0,S.useState)(``),{data:d,isLoading:f}=R({queryKey:[`lead-gen-attribution`,n,r,a,s],queryFn:()=>H8.getAttributions(n,{utm_source:r||void 0,status:a||void 0,days:s}),enabled:!!n}),p=d?.data?.data?.attributions||[],m=d?.data?.data?.summary,h=p.filter(e=>{if(!l)return!0;let t=l.toLowerCase();return(e.utm_campaign||``).toLowerCase().includes(t)||(e.utm_source||``).toLowerCase().includes(t)||(e.utm_term||``).toLowerCase().includes(t)||(e.lead_source||``).toLowerCase().includes(t)}),g=new Map;h.forEach(e=>{let t=e.utm_source||`unknown`,n=g.get(t)||{count:0,revenue:0,spend:0,roas:0};n.count+=1,n.revenue+=e.deal_amount||0,n.spend+=e.total_ad_spend||0,n.roas=n.spend>0?n.revenue/n.spend:0,g.set(t,n)});let _=new Map;h.forEach(e=>{_.set(e.attribution_status,(_.get(e.attribution_status)||0)+1)});let v=m?.total_revenue||0,y=m?.total_spend||0,b=m?.overall_roas||0;return(0,L.jsx)($,{title:`Attribution Report`,children:(0,L.jsxs)(`div`,{className:`max-w-6xl mx-auto`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-8`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>e(`/app/lead-gen`),className:`p-2 hover:bg-surface-100 rounded-lg transition-colors`,children:(0,L.jsx)(Fc,{className:`h-5 w-5`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Attribution Report`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500`,children:`Track leads from ad click to closed deal`})]})]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{p5(f5(h),`attribution-report-${new Date().toISOString().slice(0,10)}.csv`)},disabled:h.length===0,className:`flex items-center gap-2 px-4 py-2 rounded-lg border border-surface-200 text-sm font-medium text-surface-700 hover:bg-surface-50 disabled:opacity-50 transition-colors`,children:[(0,L.jsx)(fl,{className:`h-4 w-4`}),`Export CSV`]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4 mb-8`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(yu,{className:`h-4 w-4 text-blue-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Total Leads`})]}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-surface-900`,children:m?.attribution_count||0})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(dl,{className:`h-4 w-4 text-red-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Ad Spend`})]}),(0,L.jsxs)(`p`,{className:`text-xl font-bold text-red-600`,children:[`$`,y.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(wu,{className:`h-4 w-4 text-emerald-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Revenue`})]}),(0,L.jsxs)(`p`,{className:`text-xl font-bold text-emerald-600`,children:[`$`,v.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,L.jsx)(mc,{className:`h-4 w-4 text-purple-600`}),(0,L.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-surface-400`,children:`Overall ROAS`})]}),(0,L.jsxs)(`p`,{className:`text-xl font-bold ${b>=3?`text-emerald-600`:`text-amber-600`}`,children:[b.toFixed(1),`x`]})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8`,children:[(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`font-semibold text-surface-900 mb-4 flex items-center gap-2`,children:[(0,L.jsx)(mc,{className:`h-4 w-4 text-blue-600`}),`Performance by Source`]}),g.size===0?(0,L.jsx)(`p`,{className:`text-sm text-surface-400`,children:`No data available`}):(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.from(g.entries()).map(([e,t])=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900 capitalize`,children:e}),(0,L.jsxs)(`p`,{className:`text-xs text-surface-400`,children:[t.count,` leads`]})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsxs)(`p`,{className:`text-sm font-medium text-emerald-600`,children:[`$`,t.revenue.toLocaleString(void 0,{maximumFractionDigits:0})]}),(0,L.jsxs)(`p`,{className:`text-xs ${t.roas>=3?`text-emerald-600`:`text-amber-600`}`,children:[t.roas.toFixed(1),`x ROAS`]})]})]},e))})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`h3`,{className:`font-semibold text-surface-900 mb-4 flex items-center gap-2`,children:[(0,L.jsx)(_c,{className:`h-4 w-4 text-purple-600`}),`Funnel Status`]}),_.size===0?(0,L.jsx)(`p`,{className:`text-sm text-surface-400`,children:`No data available`}):(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.from(_.entries()).map(([e,t])=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${e===`deal`?`bg-emerald-100 text-emerald-700`:e===`lead`?`bg-blue-100 text-blue-700`:`bg-surface-100 text-surface-600`}`,children:e}),(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:h.length>0?(t/h.length*100).toFixed(0)+`%`:`0%`})]}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-surface-900`,children:t})]},e))})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-6`,children:[(0,L.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`Search campaigns, keywords...`,className:`w-full rounded-lg border border-surface-200 pl-10 pr-3 py-2 text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-100`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(wc,{className:`h-4 w-4 text-surface-400`}),(0,L.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value),className:`rounded-lg border border-surface-200 px-3 py-2 text-sm bg-white focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All sources`}),(0,L.jsx)(`option`,{value:`google`,children:`Google Ads`}),(0,L.jsx)(`option`,{value:`facebook`,children:`Facebook Ads`})]})]}),(0,L.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`rounded-lg border border-surface-200 px-3 py-2 text-sm bg-white focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:``,children:`All statuses`}),(0,L.jsx)(`option`,{value:`click`,children:`Click`}),(0,L.jsx)(`option`,{value:`lead`,children:`Lead`}),(0,L.jsx)(`option`,{value:`deal`,children:`Deal`})]}),(0,L.jsxs)(`select`,{value:s,onChange:e=>c(Number(e.target.value)),className:`rounded-lg border border-surface-200 px-3 py-2 text-sm bg-white focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:7,children:`Last 7 days`}),(0,L.jsx)(`option`,{value:14,children:`Last 14 days`}),(0,L.jsx)(`option`,{value:30,children:`Last 30 days`}),(0,L.jsx)(`option`,{value:60,children:`Last 60 days`}),(0,L.jsx)(`option`,{value:90,children:`Last 90 days`})]})]}),f?(0,L.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,L.jsx)(K,{className:`h-8 w-8 animate-spin text-brand-500`})}):h.length===0?(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-12 text-center`,children:[(0,L.jsx)(yu,{className:`h-8 w-8 mx-auto mb-3 text-surface-300`}),(0,L.jsx)(`p`,{className:`text-surface-500 font-medium`,children:`No attribution data`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-400 mt-1`,children:`Leads will appear here when forms are submitted with UTM tracking parameters.`})]}):(0,L.jsx)(`div`,{className:`rounded-xl border border-surface-200 bg-white overflow-hidden`,children:(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[(0,L.jsx)(`th`,{className:`text-left px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Source`}),(0,L.jsx)(`th`,{className:`text-left px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Campaign`}),(0,L.jsx)(`th`,{className:`text-left px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Keyword`}),(0,L.jsx)(`th`,{className:`text-left px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Lead Source`}),(0,L.jsx)(`th`,{className:`text-right px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Click Cost`}),(0,L.jsx)(`th`,{className:`text-right px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Ad Spend`}),(0,L.jsx)(`th`,{className:`text-right px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Revenue`}),(0,L.jsx)(`th`,{className:`text-right px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`ROAS`}),(0,L.jsx)(`th`,{className:`text-center px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Status`}),(0,L.jsx)(`th`,{className:`text-right px-6 py-3 text-xs font-medium uppercase tracking-wider text-surface-500`,children:`Date`})]})}),(0,L.jsx)(`tbody`,{children:h.map(e=>(0,L.jsx)(d5,{attribution:e},e.id))})]})})})]})})}function d5({attribution:e}){return(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 last:border-b-0 hover:bg-surface-50/50 transition-colors`,children:[(0,L.jsx)(`td`,{className:`px-6 py-3`,children:(0,L.jsx)(`span`,{className:`capitalize font-medium text-surface-900`,children:e.utm_source||e.lead_source})}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-surface-700`,children:e.utm_campaign||`—`}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-surface-500`,children:e.utm_term||`—`}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-surface-500 capitalize`,children:e.lead_source}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-right tabular-nums text-surface-600`,children:e.click_cost?`$${e.click_cost.toFixed(2)}`:`—`}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-right tabular-nums text-surface-600`,children:e.total_ad_spend?`$${e.total_ad_spend.toFixed(2)}`:`—`}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-right tabular-nums font-medium text-emerald-600`,children:e.deal_amount?`$${e.deal_amount.toFixed(2)}`:`—`}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-right tabular-nums`,children:e.roas?(0,L.jsxs)(`span`,{className:e.roas>=3?`text-emerald-600 font-medium`:`text-amber-600`,children:[e.roas.toFixed(1),`x`]}):(0,L.jsx)(`span`,{className:`text-surface-400`,children:`—`})}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-center`,children:(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${e.attribution_status===`deal`?`bg-emerald-100 text-emerald-700`:e.attribution_status===`lead`?`bg-blue-100 text-blue-700`:`bg-surface-100 text-surface-600`}`,children:e.attribution_status})}),(0,L.jsx)(`td`,{className:`px-6 py-3 text-right tabular-nums text-surface-400 text-xs whitespace-nowrap`,children:new Date(e.created_at).toLocaleDateString()})]})}function f5(e){let t=[`Source`,`Campaign`,`Keyword`,`Lead Source`,`Click Cost`,`Ad Spend`,`Revenue`,`ROAS`,`Status`,`Date`],n=e.map(e=>[e.utm_source||``,e.utm_campaign||``,e.utm_term||``,e.lead_source,e.click_cost?.toFixed(2)||``,e.total_ad_spend?.toFixed(2)||``,e.deal_amount?.toFixed(2)||``,e.roas?.toFixed(2)||``,e.attribution_status,new Date(e.created_at).toLocaleDateString()]);return[t.join(`,`),...n.map(e=>e.map(e=>`"${e}"`).join(`,`))].join(`
`)}function p5(e,t){let n=new Blob([e],{type:`text/csv`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}var m5={dashboard:`starter`,forecasting:`starter`,cascading_goals:`launch`,strategic_intelligence:`growth`,scale_optimization:`growth`,multi_market:`growth`,enterprise:`command`},h5={starter:`Starter`,launch:`Launch`,growth:`Growth`,command:`Command`},g5={tier:`starter`,features:[`dashboard`,`forecasting`],limits:{markets:1,seats:2,connectors:1}};function _5(){let{data:e,isLoading:t,isError:n}=R({queryKey:[`billing`,`tier`],queryFn:async()=>(await H.get(`/api/billing/tier`)).data,staleTime:300*1e3,retry:1}),r=e??g5;return{tier:r.tier,tierLabel:h5[r.tier],features:r.features,limits:r.limits,hasFeature:e=>t?!0:r.features.includes(e),requiredTier:e=>m5[e],isLoading:t,isError:n}}var v5={dashboard:`Dashboard`,forecasting:`Forecasting`,cascading_goals:`Cascading Goals`,strategic_intelligence:`Strategic Intelligence`,scale_optimization:`Scale Optimization`,multi_market:`Multi-Market Command`,enterprise:`Enterprise Features`};function y5({feature:e,children:t,fallback:n}){let{hasFeature:r,tierLabel:i,isLoading:a}=_5();if(a)return(0,L.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,L.jsx)(PQ,{size:`lg`})});if(r(e))return(0,L.jsx)(L.Fragment,{children:t});if(n)return(0,L.jsx)(L.Fragment,{children:n});let o=h5[m5[e]];return(0,L.jsx)(`div`,{className:`flex min-h-[60vh] items-center justify-center p-6`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-lg rounded-2xl border border-slate-200 bg-white p-10 text-center shadow-sm`,children:[(0,L.jsx)(`div`,{className:`mx-auto mb-5 flex h-14 w-14 items-center justify-center rounded-full bg-indigo-50`,children:(0,L.jsx)(Nl,{className:`h-7 w-7 text-indigo-600`})}),(0,L.jsxs)(`h2`,{className:`text-xl font-bold text-slate-900`,children:[v5[e],` requires the `,o,` plan`]}),(0,L.jsxs)(`p`,{className:`mt-3 text-sm text-slate-600`,children:[`You're currently on the `,(0,L.jsx)(`span`,{className:`font-semibold`,children:i}),` plan. Upgrade to `,o,` to unlock `,v5[e],` and more.`]}),(0,L.jsxs)(`div`,{className:`mt-6 flex items-center justify-center gap-3`,children:[(0,L.jsxs)(Mn,{to:`/app/billing`,className:`inline-flex items-center gap-2 rounded-lg bg-indigo-600 px-5 py-2.5 text-sm font-semibold text-white transition hover:bg-indigo-700`,children:[(0,L.jsx)(kc,{className:`h-4 w-4`}),`View plans & upgrade`]}),(0,L.jsx)(Mn,{to:`/app`,className:`rounded-lg border border-slate-300 px-5 py-2.5 text-sm font-medium text-slate-700 transition hover:bg-slate-50`,children:`Back to dashboard`})]})]})})}var b5={getEstimates:async(e,t)=>{let{data:n}=await H.get(`/api/company/${e}/estimates`,{params:t});return n},getEstimate:async(e,t)=>{let{data:n}=await H.get(`/api/company/${e}/estimates/${t}`);return n},createEstimate:async(e,t)=>{let{data:n}=await H.post(`/api/company/${e}/estimates`,t);return n},updateEstimate:async(e,t,n)=>{let{data:r}=await H.put(`/api/company/${e}/estimates/${t}`,n);return r},deleteEstimate:async(e,t)=>{let{data:n}=await H.delete(`/api/company/${e}/estimates/${t}`);return n},transitionEstimate:async(e,t,n)=>{let{data:r}=await H.patch(`/api/company/${e}/estimates/${t}/transition`,n);return r},getStageHistory:async(e,t)=>{let{data:n}=await H.get(`/api/company/${e}/estimates/${t}/stage-history`);return n},expireOldEstimates:async(e,t)=>{let{data:n}=await H.patch(`/api/company/${e}/estimates/expired`,{},{params:t?{days_before_expiry:t}:{}});return n},getFunnelAnalytics:async(e,t)=>{let{data:n}=await H.get(`/api/company/${e}/estimates/funnel`,{params:t});return n},getPipelineOverview:async(e,t)=>{let{data:n}=await H.get(`/api/company/${e}/estimates/pipeline`,{params:{days:t??90}});return n},getEstimateStats:async(e,t)=>{let{data:n}=await H.get(`/api/company/${e}/estimates/stats`,{params:{days:t??30}});return n},getEstimatesBySource:async(e,t)=>{let{data:n}=await H.get(`/api/company/${e}/estimates/by-source`,{params:{days:t??90}});return n}},x5=[{key:`draft`,label:`Draft`,color:`text-slate-700`,bgColor:`bg-slate-100`},{key:`delivered`,label:`Delivered`,color:`text-blue-700`,bgColor:`bg-blue-100`},{key:`accepted`,label:`Accepted`,color:`text-emerald-700`,bgColor:`bg-emerald-100`},{key:`scheduled`,label:`Scheduled`,color:`text-amber-700`,bgColor:`bg-amber-100`},{key:`closed`,label:`Closed`,color:`text-green-700`,bgColor:`bg-green-100`}],S5=[{key:`rejected`,label:`Rejected`,color:`text-red-700`,bgColor:`bg-red-100`},{key:`expired`,label:`Expired`,color:`text-gray-700`,bgColor:`bg-gray-100`}];function C5(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(0)}`}function w5(e){return`${e.toFixed(1)}%`}function T5({icon:e,label:t,value:n,subtext:r,trend:i}){return(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-surface-500`,children:t}),(0,L.jsx)(e,{className:`h-4 w-4 ${i===`up`?`text-emerald-600`:i===`down`?`text-red-600`:`text-surface-400`}`})]}),(0,L.jsx)(`p`,{className:`mt-2 text-2xl font-bold text-surface-900`,children:n}),r&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-surface-500`,children:r})]})}function E5({stage:e,count:t,value:n,maxCount:r,conversionRate:i}){let a=r>0?Math.max(t/r*100,8):8;return(0,L.jsxs)(`div`,{className:`group`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`inline-flex rounded-full px-2 py-0.5 text-xs font-semibold ${e.bgColor} ${e.color}`,children:e.label}),(0,L.jsx)(`span`,{className:`text-sm font-bold text-surface-900`,children:t}),(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:C5(n)})]}),i!==void 0&&(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(Lc,{className:`h-3 w-3 text-surface-300`}),(0,L.jsx)(`span`,{className:`text-xs font-semibold ${i>=50?`text-emerald-600`:i>=25?`text-amber-600`:`text-red-600`}`,children:w5(i)})]})]}),(0,L.jsx)(`div`,{className:`h-3 rounded-full bg-surface-100 overflow-hidden`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${e.bgColor.replace(`100`,`400`)}`,style:{width:`${a}%`}})})]})}function D5({data:e}){return e.total_drop_off_count===0?null:(0,L.jsxs)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 p-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,L.jsx)(jc,{className:`h-5 w-5 text-red-600`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-red-900`,children:`Drop-off Analysis`}),(0,L.jsx)(`span`,{className:`ml-auto text-lg font-bold text-red-700`,children:w5(e.drop_off_rate)})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 mb-4`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-white p-3 border border-red-100`,children:[(0,L.jsx)(`p`,{className:`text-xs text-red-600 font-medium`,children:`Rejected`}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-red-700`,children:e.rejected_count})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-white p-3 border border-red-100`,children:[(0,L.jsx)(`p`,{className:`text-xs text-gray-600 font-medium`,children:`Expired`}),(0,L.jsx)(`p`,{className:`text-xl font-bold text-gray-700`,children:e.expired_count})]})]}),Object.keys(e.rejection_reasons).length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-red-800 mb-2`,children:`Rejection Reasons`}),(0,L.jsx)(`div`,{className:`space-y-1.5`,children:Object.entries(e.rejection_reasons).sort(([,e],[,t])=>t-e).map(([e,t])=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,L.jsx)(`span`,{className:`text-red-800`,children:e}),(0,L.jsx)(`span`,{className:`font-semibold text-red-900`,children:t})]},e))})]})]})}function O5({sources:e}){let t=Object.entries(e).sort(([,e],[,t])=>t.total_value-e.total_value);return t.length===0?null:(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,L.jsx)(yu,{className:`h-5 w-5 text-surface-600`}),(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-900`,children:`By Source`})]}),(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200`,children:[(0,L.jsx)(`th`,{className:`text-left py-2 px-3 text-xs font-medium text-surface-500 uppercase`,children:`Source`}),(0,L.jsx)(`th`,{className:`text-right py-2 px-3 text-xs font-medium text-surface-500 uppercase`,children:`Count`}),(0,L.jsx)(`th`,{className:`text-right py-2 px-3 text-xs font-medium text-surface-500 uppercase`,children:`Value`}),(0,L.jsx)(`th`,{className:`text-right py-2 px-3 text-xs font-medium text-surface-500 uppercase`,children:`Avg`}),(0,L.jsx)(`th`,{className:`text-right py-2 px-3 text-xs font-medium text-surface-500 uppercase`,children:`Conv. Rate`})]})}),(0,L.jsx)(`tbody`,{children:t.map(([e,t])=>(0,L.jsxs)(`tr`,{className:`border-b border-surface-100 last:border-0`,children:[(0,L.jsx)(`td`,{className:`py-2 px-3 font-medium text-surface-900 capitalize`,children:e}),(0,L.jsx)(`td`,{className:`py-2 px-3 text-right text-surface-700`,children:t.count}),(0,L.jsx)(`td`,{className:`py-2 px-3 text-right text-surface-700`,children:C5(t.total_value)}),(0,L.jsx)(`td`,{className:`py-2 px-3 text-right text-surface-500`,children:C5(t.avg_value)}),(0,L.jsx)(`td`,{className:`py-2 px-3 text-right font-semibold ${t.conversion_rate>=30?`text-emerald-600`:t.conversion_rate>=15?`text-amber-600`:`text-red-600`}`,children:w5(t.conversion_rate)})]},e))})]})})]})}function k5(){let{user:e}=W(),t=e?.tenantId,[n,r]=(0,S.useState)(90),[i,a]=(0,S.useState)(``),o=n===30?`30 days`:n===90?`90 days`:n===180?`180 days`:n===365?`1 year`:`${n} days`,{data:s,isLoading:c,refetch:l}=R({queryKey:[`estimates-funnel`,t,n,i],queryFn:()=>b5.getFunnelAnalytics(t,{days:n,...i?{source:i}:{}})}),{data:u}=R({queryKey:[`estimates-stats`,t,30],queryFn:()=>b5.getEstimateStats(t,30)}),{data:d}=R({queryKey:[`estimates-by-source`,t,n],queryFn:()=>b5.getEstimatesBySource(t,n)}),f=(0,S.useMemo)(()=>s?.pipeline_summary??null,[s]);if(c)return(0,L.jsx)($,{children:(0,L.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,L.jsx)(PQ,{})})});let p=s?Math.max(...Object.values(s.stage_counts)):1;return(0,L.jsx)($,{children:(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Estimates Funnel`}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500 mt-1`,children:[`Pipeline tracking and conversion analytics — `,o]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`select`,{value:n,onChange:e=>r(Number(e.target.value)),className:`rounded-lg border border-surface-300 bg-white px-3 py-2 text-sm outline-none focus:border-brand-500`,children:[(0,L.jsx)(`option`,{value:30,children:`Last 30 days`}),(0,L.jsx)(`option`,{value:90,children:`Last 90 days`}),(0,L.jsx)(`option`,{value:180,children:`Last 180 days`}),(0,L.jsx)(`option`,{value:365,children:`Last year`})]}),(0,L.jsx)(`button`,{onClick:()=>l(),className:`inline-flex items-center gap-1.5 rounded-lg border border-surface-300 px-3 py-2 text-sm text-surface-600 hover:bg-surface-50 min-h-[44px]`,children:(0,L.jsx)(nu,{className:`h-4 w-4`})})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,L.jsx)(T5,{icon:_l,label:`Total Estimates`,value:String(s?.total_estimates??0),subtext:o}),(0,L.jsx)(T5,{icon:dl,label:`Pipeline Value`,value:C5(f?.total_pipeline_value??0),subtext:`${f?.closed_count??0} closed`}),(0,L.jsx)(T5,{icon:Kl,label:`Win Rate`,value:w5(f?.win_rate??0),subtext:u?`${u.closed_count} won / ${u.total_count} total (30d)`:void 0}),(0,L.jsx)(T5,{icon:al,label:`Avg Deal Size`,value:C5(f?.avg_deal_size??0),subtext:f?.avg_time_to_accept_days?`${f.avg_time_to_accept_days}d to accept`:`No acceptance data yet`})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-6`,children:[(0,L.jsx)(mc,{className:`h-5 w-5 text-surface-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`Conversion Funnel`})]}),(0,L.jsx)(`div`,{className:`space-y-4`,children:x5.map((e,t)=>{let n=s?.stage_counts[e.key]??0,r=s?.stage_values[e.key]??0,i=`${e.key}_to_${x5[t+1]?.key}`,a=s?.conversion_rates[i]?.rate;return(0,L.jsx)(E5,{stage:e,count:n,value:r,maxCount:p,conversionRate:a},e.key)})}),S5.length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`border-t border-surface-200 my-4`}),(0,L.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-surface-500 mb-3`,children:`Terminal Stages`}),(0,L.jsx)(`div`,{className:`space-y-4`,children:S5.map(e=>(0,L.jsx)(E5,{stage:e,count:s?.stage_counts[e.key]??0,value:s?.stage_values[e.key]??0,maxCount:p},e.key))})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[s&&(0,L.jsx)(D5,{data:s.drop_off}),d&&(0,L.jsx)(O5,{sources:d.sources})]}),u&&(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,L.jsx)(wu,{className:`h-5 w-5 text-surface-600`}),(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-surface-900`,children:`30-Day Snapshot`})]}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4`,children:[{label:`New Estimates`,value:String(u.total_count)},{label:`Active`,value:String(u.active_count)},{label:`Closed`,value:String(u.closed_count)},{label:`Total Value`,value:C5(u.total_value)},{label:`Pipeline`,value:C5(u.pipeline_value)},{label:`Closed Value`,value:C5(u.closed_value)}].map(e=>(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-50 p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-500`,children:e.label}),(0,L.jsx)(`p`,{className:`mt-1 text-lg font-bold text-surface-900`,children:e.value})]},e.label))})]})]})})}function A5(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(0)}`}function j5(e){return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}function M5(e){return e.charAt(0).toUpperCase()+e.slice(1)}function N5(e){return{manual:`Manual`,angi:`Angi`,servicetitan:`ServiceTitan`,jobber:`Jobber`,hubspot:`HubSpot`,email:`Email`,referral:`Referral`,website:`Website`}[e]??M5(e)}var P5={draft:{bg:`bg-slate-100`,text:`text-slate-700`,label:`Draft`},delivered:{bg:`bg-blue-100`,text:`text-blue-700`,label:`Delivered`},accepted:{bg:`bg-emerald-100`,text:`text-emerald-700`,label:`Accepted`},scheduled:{bg:`bg-amber-100`,text:`text-amber-700`,label:`Scheduled`},closed:{bg:`bg-green-100`,text:`text-green-700`,label:`Closed`},rejected:{bg:`bg-red-100`,text:`text-red-700`,label:`Rejected`},expired:{bg:`bg-gray-100`,text:`text-gray-700`,label:`Expired`}},F5={draft:[`delivered`],delivered:[`accepted`,`rejected`,`expired`],accepted:[`scheduled`,`rejected`],scheduled:[`closed`,`rejected`],rejected:[],expired:[],closed:[]},I5={field:`created_at`,order:`desc`},L5=[{key:`estimate_number`,label:`Estimate #`},{key:`customer_name`,label:`Customer`},{key:`project_type`,label:`Project Type`},{key:`total_value`,label:`Value`},{key:`stage`,label:`Stage`},{key:`source`,label:`Source`},{key:`created_at`,label:`Created`}],R5={stage:``,source:``,minValue:``,maxValue:``,search:``},z5=[{value:`draft`,label:`Draft`},{value:`delivered`,label:`Delivered`},{value:`accepted`,label:`Accepted`},{value:`scheduled`,label:`Scheduled`},{value:`closed`,label:`Closed`},{value:`rejected`,label:`Rejected`},{value:`expired`,label:`Expired`}],B5=[{value:`manual`,label:`Manual`},{value:`angi`,label:`Angi`},{value:`servicetitan`,label:`ServiceTitan`},{value:`jobber`,label:`Jobber`},{value:`hubspot`,label:`HubSpot`},{value:`email`,label:`Email`},{value:`referral`,label:`Referral`},{value:`website`,label:`Website`}];function V5({estimate:e,onTransition:t,transitioning:n}){let[r,i]=(0,S.useState)(!1),a=P5[e.stage],o=F5[e.stage];return o.length===0?(0,L.jsx)(`span`,{className:`inline-flex rounded-full px-2.5 py-1 text-xs font-semibold ${a.bg} ${a.text} cursor-default`,title:`${a.label} (terminal)`,children:a.label}):(0,L.jsxs)(`div`,{className:`relative inline-block`,children:[(0,L.jsxs)(`button`,{onClick:()=>i(!r),className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-semibold ${a.bg} ${a.text} hover:opacity-80 cursor-pointer min-h-[28px]`,title:`Click to transition stage`,children:[a.label,(0,L.jsx)(Zc,{className:`h-3 w-3 opacity-60`})]}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>i(!1)}),(0,L.jsxs)(`div`,{className:`absolute left-0 top-full mt-1 z-50 w-48 rounded-lg border border-surface-200 bg-white shadow-lg py-1`,children:[(0,L.jsx)(`p`,{className:`px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-surface-400`,children:`Move to…`}),o.map(r=>{let a=P5[r];return(0,L.jsxs)(`button`,{disabled:n,onClick:()=>{t(e.id,r),i(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-surface-50 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,L.jsx)(`span`,{className:`inline-flex rounded-full px-2 py-0.5 text-[10px] font-semibold ${a.bg} ${a.text}`,children:a.label}),(0,L.jsx)(Lc,{className:`h-3 w-3 text-surface-400`})]},r)})]})]})]})}function H5({page:e,perPage:t,total:n,totalPages:r,onPageChange:i}){let a=Math.max(r,1),o=()=>{let t=[];if(a<=7)for(let e=1;e<=a;e++)t.push(e);else{t.push(1),e>3&&t.push(`…`);for(let n=Math.max(2,e-1);n<=Math.min(a-1,e+1);n++)t.push(n);e<a-2&&t.push(`…`),t.push(a)}return t},s=(e-1)*t+1,c=Math.min(e*t,n);return(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center justify-between gap-4 px-4 py-3 border-t border-surface-200`,children:[(0,L.jsxs)(`p`,{className:`text-sm text-surface-500`,children:[`Showing `,(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:s}),` to`,` `,(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:n>0?c:0}),` of`,` `,(0,L.jsx)(`span`,{className:`font-medium text-surface-700`,children:n}),` estimates`]}),a>1&&(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`button`,{onClick:()=>i(e-1),disabled:e<=1,className:`inline-flex items-center justify-center w-8 h-8 rounded-md border border-surface-300 text-sm text-surface-600 hover:bg-surface-50 disabled:opacity-40 disabled:cursor-not-allowed`,title:`Previous page`,children:`‹`}),o().map((t,n)=>typeof t==`string`?(0,L.jsx)(`span`,{className:`w-8 h-8 flex items-center justify-center text-surface-400 text-sm`,children:t},`ellipsis-${n}`):(0,L.jsx)(`button`,{onClick:()=>i(t),className:`inline-flex items-center justify-center w-8 h-8 rounded-md text-sm font-medium ${t===e?`bg-brand-500 text-white`:`border border-surface-300 text-surface-600 hover:bg-surface-50`}`,children:t},t)),(0,L.jsx)(`button`,{onClick:()=>i(e+1),disabled:e>=a,className:`inline-flex items-center justify-center w-8 h-8 rounded-md border border-surface-300 text-sm text-surface-600 hover:bg-surface-50 disabled:opacity-40 disabled:cursor-not-allowed`,title:`Next page`,children:`›`})]})]})}function U5(){let{user:e}=W(),t=ft(),n=ci(),r=e?.tenantId,[i,a]=(0,S.useState)(R5),[o,s]=(0,S.useState)(I5),[c,l]=(0,S.useState)(1),[u,d]=(0,S.useState)(new Set),[f,p]=(0,S.useState)(null),m=(0,S.useCallback)(e=>{a(t=>({...t,...e})),l(1)},[]),h=(0,S.useMemo)(()=>({page:c,per_page:20,sort_by:o.field,sort_order:o.order,...i.stage?{stage:i.stage}:{},...i.source?{source:i.source}:{},...i.minValue?{min_value:Number(i.minValue)}:{},...i.maxValue?{max_value:Number(i.maxValue)}:{},...i.search?{project_type:``}:{}}),[c,20,o,i]),{data:g,isLoading:_,error:v}=R({queryKey:[`estimates-list`,r,h,i.search],queryFn:()=>b5.getEstimates(r,h),keepPreviousData:!0}),y=z({mutationFn:({companyId:e,estimateId:t,stage:n})=>b5.transitionEstimate(e,t,{stage:n}),onSuccess:()=>{n.invalidateQueries({queryKey:[`estimates-list`]}),n.invalidateQueries({queryKey:[`estimates-funnel`]})},onSettled:(e,t,n)=>{d(e=>{let t=new Set(e);return t.delete(n.estimateId),t})}}),b=(0,S.useCallback)((e,t)=>{u.has(e)||(d(t=>new Set(t).add(e)),y.mutate({companyId:r,estimateId:e,stage:t}))},[r,u,y]),x=(0,S.useCallback)(e=>{s(t=>({field:e,order:t.field===e&&t.order===`asc`?`desc`:`asc`}))},[]),C=(0,S.useCallback)(()=>{a(R5),l(1)},[]),w=i.stage||i.source||i.minValue||i.maxValue||i.search,T=({field:e})=>o.field===e?o.order===`asc`?(0,L.jsx)($c,{className:`h-3.5 w-3.5`}):(0,L.jsx)(Zc,{className:`h-3.5 w-3.5`}):(0,L.jsx)(tl,{className:`h-3.5 w-3.5 opacity-40`});if(_)return(0,L.jsx)($,{children:(0,L.jsx)(`div`,{className:`flex items-center justify-center h-96`,children:(0,L.jsx)(PQ,{})})});if(v)return(0,L.jsx)($,{children:(0,L.jsxs)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 p-8 text-center`,children:[(0,L.jsx)(`p`,{className:`text-red-700 font-semibold`,children:`Failed to load estimates`}),(0,L.jsx)(`p`,{className:`text-red-600 text-sm mt-1`,children:v.message}),(0,L.jsxs)(`button`,{onClick:()=>n.invalidateQueries({queryKey:[`estimates-list`]}),className:`mt-4 inline-flex items-center gap-1.5 rounded-lg bg-red-600 px-4 py-2 text-sm text-white hover:bg-red-700`,children:[(0,L.jsx)(au,{className:`h-4 w-4`}),`Retry`]})]})});let E=g?.estimates??[],D=Math.max(g?.total_pages??g?.pages??1,1),O=g?.total??0;return(0,L.jsx)($,{children:(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:`Estimates`}),(0,L.jsxs)(`p`,{className:`text-sm text-surface-500 mt-1`,children:[O,` total estimate`,O===1?``:`s`]})]}),(0,L.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,L.jsxs)(`button`,{onClick:()=>t(`/app/estimates`),className:`inline-flex items-center gap-1.5 rounded-lg border border-surface-300 px-3 py-2 text-sm text-surface-600 hover:bg-surface-50 min-h-[44px]`,children:[(0,L.jsx)(_l,{className:`h-4 w-4`}),`Funnel`]})})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,L.jsx)(wc,{className:`h-4 w-4 text-surface-400`}),(0,L.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-surface-500`,children:`Filters`}),w&&(0,L.jsxs)(`button`,{onClick:C,className:`ml-auto inline-flex items-center gap-1 text-xs text-brand-600 hover:text-brand-700 font-medium`,children:[(0,L.jsx)(Iu,{className:`h-3 w-3`}),`Clear all`]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-3`,children:[(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(J,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-surface-400`}),(0,L.jsx)(`input`,{type:`text`,placeholder:`Search customer…`,value:i.search,onChange:e=>m({search:e.target.value}),className:`w-full rounded-lg border border-surface-300 pl-9 pr-3 py-2 text-sm outline-none focus:border-brand-500 focus:ring-1 focus:ring-brand-500`})]}),(0,L.jsxs)(`select`,{value:i.stage,onChange:e=>m({stage:e.target.value}),className:`rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500 focus:ring-1 focus:ring-brand-500 bg-white`,children:[(0,L.jsx)(`option`,{value:``,children:`All Stages`}),z5.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),(0,L.jsxs)(`select`,{value:i.source,onChange:e=>m({source:e.target.value}),className:`rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500 focus:ring-1 focus:ring-brand-500 bg-white`,children:[(0,L.jsx)(`option`,{value:``,children:`All Sources`}),B5.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),(0,L.jsx)(`input`,{type:`number`,placeholder:`Min value`,value:i.minValue,onChange:e=>m({minValue:e.target.value}),className:`rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500 focus:ring-1 focus:ring-brand-500`}),(0,L.jsx)(`input`,{type:`number`,placeholder:`Max value`,value:i.maxValue,onChange:e=>m({maxValue:e.target.value}),className:`rounded-lg border border-surface-300 px-3 py-2 text-sm outline-none focus:border-brand-500 focus:ring-1 focus:ring-brand-500`})]})]}),(0,L.jsxs)(`div`,{className:`rounded-xl border border-surface-200 bg-white overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-surface-200 bg-surface-50`,children:[L5.map(e=>(0,L.jsx)(`th`,{onClick:()=>x(e.key),className:`text-left py-3 px-4 text-xs font-semibold uppercase tracking-wider text-surface-500 cursor-pointer hover:text-surface-700 select-none whitespace-nowrap`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.label,(0,L.jsx)(T,{field:e.key})]})},e.key)),(0,L.jsx)(`th`,{className:`text-right py-3 px-4 text-xs font-semibold uppercase tracking-wider text-surface-500`,children:`Actions`})]})}),(0,L.jsx)(`tbody`,{children:E.length===0?(0,L.jsx)(`tr`,{children:(0,L.jsxs)(`td`,{colSpan:8,className:`text-center py-12 text-surface-400`,children:[(0,L.jsx)(_l,{className:`h-10 w-10 mx-auto mb-3 opacity-40`}),(0,L.jsx)(`p`,{className:`font-medium`,children:`No estimates found`}),(0,L.jsx)(`p`,{className:`text-xs mt-1`,children:`Try adjusting your filters or create a new estimate`})]})}):E.map(e=>(P5[e.stage],(0,L.jsxs)(`tr`,{onClick:()=>t(`/app/estimates/${e.id}`),className:`border-b border-surface-100 last:border-0 hover:bg-surface-50 cursor-pointer transition-colors`,children:[(0,L.jsx)(`td`,{className:`py-3 px-4 font-mono text-xs font-semibold text-surface-700 whitespace-nowrap`,children:e.estimate_number}),(0,L.jsx)(`td`,{className:`py-3 px-4`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`font-medium text-surface-900`,children:e.customer_name}),(0,L.jsx)(`p`,{className:`text-xs text-surface-400`,children:e.customer_email})]})}),(0,L.jsx)(`td`,{className:`py-3 px-4 text-surface-600 whitespace-nowrap`,children:M5(e.project_type)}),(0,L.jsx)(`td`,{className:`py-3 px-4 font-semibold text-surface-900 whitespace-nowrap`,children:A5(e.total_value)}),(0,L.jsx)(`td`,{className:`py-3 px-4 whitespace-nowrap`,children:(0,L.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,L.jsx)(V5,{estimate:e,onTransition:b,transitioning:u.has(e.id)})})}),(0,L.jsx)(`td`,{className:`py-3 px-4 text-surface-500 whitespace-nowrap capitalize`,children:N5(e.source)}),(0,L.jsx)(`td`,{className:`py-3 px-4 text-surface-500 whitespace-nowrap`,children:j5(e.created_at)}),(0,L.jsx)(`td`,{className:`py-3 px-4 text-right whitespace-nowrap`,children:(0,L.jsxs)(`div`,{className:`relative inline-block`,onClick:e=>e.stopPropagation(),children:[(0,L.jsx)(`button`,{onClick:()=>p(f===e.id?null:e.id),className:`inline-flex items-center justify-center w-8 h-8 rounded-md hover:bg-surface-200 text-surface-400 hover:text-surface-600 min-h-[32px]`,title:`Actions`,children:(0,L.jsx)(Cc,{className:`h-4 w-4`})}),f===e.id&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>p(null)}),(0,L.jsx)(`div`,{className:`absolute right-0 top-full mt-1 z-50 w-44 rounded-lg border border-surface-200 bg-white shadow-lg py-1`,children:(0,L.jsxs)(`button`,{onClick:()=>{t(`/app/estimates/${e.id}`),p(null)},className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-surface-50`,children:[(0,L.jsx)(Lc,{className:`h-3.5 w-3.5 text-surface-400`}),`View Details`]})})]})]})})]},e.id)))})]})}),(0,L.jsx)(H5,{page:c,perPage:20,total:O,totalPages:D,onPageChange:l})]})]})})}var W5={draft:{label:`Draft`,bg:`bg-slate-100`,text:`text-slate-700`,icon:_l},delivered:{label:`Delivered`,bg:`bg-blue-100`,text:`text-blue-700`,icon:il},accepted:{label:`Accepted`,bg:`bg-emerald-100`,text:`text-emerald-700`,icon:yc},scheduled:{label:`Scheduled`,bg:`bg-amber-100`,text:`text-amber-700`,icon:Yc},closed:{label:`Closed`,bg:`bg-green-100`,text:`text-green-700`,icon:yc},rejected:{label:`Rejected`,bg:`bg-red-100`,text:`text-red-700`,icon:Sc},expired:{label:`Expired`,bg:`bg-gray-100`,text:`text-gray-700`,icon:vc}},G5={draft:[`delivered`],delivered:[`accepted`,`rejected`,`expired`],accepted:[`scheduled`,`rejected`],scheduled:[`closed`,`rejected`],rejected:[],expired:[],closed:[]};function K5(e){return Math.abs(e)>=1e6?`$${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toLocaleString()}`}function q5(e){if(!e)return`—`;try{return new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`})}catch{return e}}function J5(e){return e.to_stage?e.to_stage:e.stage?e.stage:`unknown`}function Y5(e){return e.from_stage||null}function X5(){let{estimateId:e}=mt(),t=ft(),{user:n}=W(),[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)(``),s=ci(),c=n?.tenantId||``;if(!e||!c)return(0,L.jsx)($,{children:(0,L.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,L.jsx)(`p`,{className:`text-surface-500`,children:`Invalid estimate ID`})})});let{data:l,isLoading:u,error:d}=R({queryKey:[`estimate-detail`,c,e],queryFn:()=>b5.getEstimate(c,e),enabled:!!c&&!!e}),{data:f}=R({queryKey:[`estimate-history`,c,e],queryFn:()=>b5.getStageHistory(c,e),enabled:!!c&&!!e}),p=z({mutationFn:t=>b5.transitionEstimate(c,e,t),onSuccess:()=>{s.invalidateQueries({queryKey:[`estimate-detail`,c,e]}),s.invalidateQueries({queryKey:[`estimate-history`,c,e]}),i(null),o(``)}}),m=e=>{i(e)},h=()=>{r&&p.mutate({stage:r,notes:a||void 0})};if(u)return(0,L.jsx)($,{children:(0,L.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,L.jsx)(PQ,{})})});if(d||!l)return(0,L.jsx)($,{children:(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,L.jsx)(jc,{className:`h-12 w-12 text-red-400`}),(0,L.jsx)(`p`,{className:`text-surface-700 font-medium`,children:`Failed to load estimate`}),(0,L.jsxs)(`button`,{onClick:()=>t(`/app/estimates`),className:`flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-lg hover:bg-brand-700`,children:[(0,L.jsx)(Fc,{className:`h-4 w-4`}),`Back to Estimates`]})]})});let g=l.estimate,_=g.stage,v=W5[_]||W5.draft,y=v.icon,b=G5[_]||[],x=g.stage_history||[],C=f?.stage_history||x;return(0,L.jsx)($,{children:(0,L.jsxs)(`div`,{className:`space-y-6 max-w-6xl mx-auto`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`button`,{onClick:()=>t(`/app/estimates`),className:`flex items-center gap-2 text-sm text-surface-500 hover:text-surface-700 mb-4`,children:[(0,L.jsx)(Fc,{className:`h-4 w-4`}),`Back to Estimates`]}),(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold text-surface-900`,children:g.estimate_number}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-sm font-semibold ${v.bg} ${v.text}`,children:[(0,L.jsx)(y,{className:`h-4 w-4`}),v.label]})]}),(0,L.jsxs)(`p`,{className:`text-lg text-surface-600`,children:[g.customer_name,` — `,g.project_type]})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsx)(`p`,{className:`text-3xl font-bold text-surface-900`,children:K5(g.total_value)}),(0,L.jsx)(`p`,{className:`text-sm text-surface-500 mt-1`,children:`Total Estimate Value`})]})]})]}),b.length>0&&!r&&(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-surface-200 p-4`,children:[(0,L.jsxs)(`h3`,{className:`text-sm font-semibold text-surface-700 mb-3 flex items-center gap-2`,children:[(0,L.jsx)(el,{className:`h-4 w-4`}),`Transition Estimate`]}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:b.map(e=>{let t=W5[e],n=t.icon;return(0,L.jsxs)(`button`,{onClick:()=>m(e),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-semibold border border-surface-200 hover:border-surface-300 transition-colors ${t.bg} ${t.text}`,children:[(0,L.jsx)(n,{className:`h-4 w-4`}),`→ `,t.label]},e)})})]}),r&&(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border-2 border-brand-200 p-5`,children:[(0,L.jsxs)(`h3`,{className:`text-sm font-semibold text-surface-700 mb-3`,children:[`Confirm: `,v.label,` → `,W5[r].label]}),(0,L.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),placeholder:`Add notes (optional)...`,className:`w-full border border-surface-200 rounded-lg px-3 py-2 text-sm mb-3 focus:outline-none focus:ring-2 focus:ring-brand-500`,rows:2}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`button`,{onClick:h,disabled:p.isPending,className:`px-4 py-2 bg-brand-600 text-white rounded-lg text-sm font-semibold hover:bg-brand-700 disabled:opacity-50`,children:p.isPending?`Transitioning...`:`Confirm`}),(0,L.jsx)(`button`,{onClick:()=>{i(null),o(``)},className:`px-4 py-2 border border-surface-200 rounded-lg text-sm font-medium text-surface-600 hover:bg-surface-50`,children:`Cancel`})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-6`,children:[(0,L.jsxs)(`div`,{className:`lg:col-span-2 space-y-6`,children:[(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-surface-200 p-5`,children:[(0,L.jsxs)(`h3`,{className:`text-sm font-semibold text-surface-700 mb-4 flex items-center gap-2`,children:[(0,L.jsx)(Nu,{className:`h-4 w-4`}),`Customer & Project`]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400 uppercase tracking-wide`,children:`Customer`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:g.customer_name})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400 uppercase tracking-wide`,children:`Project Type`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-surface-900`,children:g.project_type})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400 uppercase tracking-wide`,children:`Email`}),(0,L.jsxs)(`a`,{href:`mailto:${g.customer_email}`,className:`text-sm text-brand-600 hover:underline flex items-center gap-1`,children:[(0,L.jsx)(Fl,{className:`h-3 w-3`}),g.customer_email]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400 uppercase tracking-wide`,children:`Phone`}),(0,L.jsxs)(`a`,{href:`tel:${g.customer_phone}`,className:`text-sm text-brand-600 hover:underline flex items-center gap-1`,children:[(0,L.jsx)(Zl,{className:`h-3 w-3`}),g.customer_phone]})]}),(0,L.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400 uppercase tracking-wide`,children:`Address`}),(0,L.jsxs)(`p`,{className:`text-sm font-medium text-surface-900 flex items-start gap-1`,children:[(0,L.jsx)(Il,{className:`h-3 w-3 mt-0.5 shrink-0`}),g.address,`, `,g.city,`, `,g.state,` `,g.zip_code]})]}),(0,L.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400 uppercase tracking-wide`,children:`Description`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-700`,children:g.description||`—`})]})]})]}),(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-surface-200 p-5`,children:[(0,L.jsxs)(`h3`,{className:`text-sm font-semibold text-surface-700 mb-4 flex items-center gap-2`,children:[(0,L.jsx)(dl,{className:`h-4 w-4`}),`Financial Summary`]}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between items-center py-2 border-b border-surface-100`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Subtotal`}),(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:K5(g.total_value-g.tax_amount-g.discount_amount)})]}),g.discount_amount>0&&(0,L.jsxs)(`div`,{className:`flex justify-between items-center py-2 border-b border-surface-100`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Discount`}),(0,L.jsxs)(`span`,{className:`text-sm font-medium text-red-600`,children:[`-`,K5(g.discount_amount)]})]}),g.tax_amount>0&&(0,L.jsxs)(`div`,{className:`flex justify-between items-center py-2 border-b border-surface-100`,children:[(0,L.jsx)(`span`,{className:`text-sm text-surface-600`,children:`Tax`}),(0,L.jsxs)(`span`,{className:`text-sm font-medium`,children:[`+`,K5(g.tax_amount)]})]}),(0,L.jsxs)(`div`,{className:`flex justify-between items-center py-2`,children:[(0,L.jsx)(`span`,{className:`text-sm font-semibold text-surface-900`,children:`Total`}),(0,L.jsx)(`span`,{className:`text-lg font-bold text-surface-900`,children:K5(g.total_value)})]}),g.deposit>0&&(0,L.jsx)(`div`,{className:`mt-2 p-3 bg-emerald-50 rounded-lg border border-emerald-200`,children:(0,L.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,L.jsx)(`span`,{className:`text-sm text-emerald-700 font-medium`,children:`Deposit`}),(0,L.jsx)(`span`,{className:`text-sm font-bold text-emerald-700`,children:K5(g.deposit)})]})})]}),g.line_items&&g.line_items.length>0&&(0,L.jsxs)(`div`,{className:`mt-4`,children:[(0,L.jsxs)(`h4`,{className:`text-xs font-semibold text-surface-500 uppercase tracking-wide mb-2`,children:[`Line Items (`,g.line_items.length,`)`]}),(0,L.jsx)(`div`,{className:`max-h-48 overflow-y-auto rounded-lg border border-surface-200`,children:(0,L.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,L.jsx)(`thead`,{className:`bg-surface-50 sticky top-0`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:`text-left px-3 py-2 text-xs font-semibold text-surface-500`,children:`Description`}),(0,L.jsx)(`th`,{className:`text-right px-3 py-2 text-xs font-semibold text-surface-500`,children:`Qty`}),(0,L.jsx)(`th`,{className:`text-right px-3 py-2 text-xs font-semibold text-surface-500`,children:`Price`}),(0,L.jsx)(`th`,{className:`text-right px-3 py-2 text-xs font-semibold text-surface-500`,children:`Total`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-surface-100`,children:g.line_items.map((e,t)=>(0,L.jsxs)(`tr`,{className:`bg-white`,children:[(0,L.jsx)(`td`,{className:`px-3 py-2 text-surface-700 max-w-[200px] truncate`,children:e.description}),(0,L.jsx)(`td`,{className:`px-3 py-2 text-right text-surface-600`,children:e.quantity}),(0,L.jsx)(`td`,{className:`px-3 py-2 text-right text-surface-600`,children:K5(e.unit_price)}),(0,L.jsx)(`td`,{className:`px-3 py-2 text-right font-medium text-surface-900`,children:K5(e.total)})]},t))})]})})]})]}),(g.rejection_reason||g.competitor_name)&&(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-red-200 p-5`,children:[(0,L.jsxs)(`h3`,{className:`text-sm font-semibold text-red-700 mb-4 flex items-center gap-2`,children:[(0,L.jsx)(jc,{className:`h-4 w-4`}),`Loss Details`]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[g.rejection_reason&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400 uppercase tracking-wide`,children:`Rejection Reason`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-700`,children:g.rejection_reason})]}),g.competitor_name&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs text-surface-400 uppercase tracking-wide`,children:`Competitor`}),(0,L.jsx)(`p`,{className:`text-sm text-surface-700`,children:g.competitor_name}),g.competitor_price!==null&&(0,L.jsxs)(`p`,{className:`text-xs text-surface-500`,children:[`at `,K5(g.competitor_price||0)]})]})]})]}),g.notes&&(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-surface-200 p-5`,children:[(0,L.jsxs)(`h3`,{className:`text-sm font-semibold text-surface-700 mb-3 flex items-center gap-2`,children:[(0,L.jsx)(_l,{className:`h-4 w-4`}),`Notes`]}),(0,L.jsx)(`p`,{className:`text-sm text-surface-700 whitespace-pre-wrap`,children:g.notes})]})]}),(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-surface-200 p-5`,children:[(0,L.jsxs)(`h3`,{className:`text-sm font-semibold text-surface-700 mb-4 flex items-center gap-2`,children:[(0,L.jsx)(Cl,{className:`h-4 w-4`}),`Stage History`]}),C.length===0?(0,L.jsx)(`p`,{className:`text-sm text-surface-400`,children:`No history recorded`}):(0,L.jsxs)(`div`,{className:`relative space-y-0`,children:[(0,L.jsx)(`div`,{className:`absolute left-3.5 top-2 bottom-2 w-0.5 bg-surface-200`}),C.map((e,t)=>{let n=J5(e),r=Y5(e),i=W5[n]||W5.draft,a=i.icon,o=!r;return(0,L.jsxs)(`div`,{className:`relative flex gap-3 pb-4 last:pb-0`,children:[(0,L.jsx)(`div`,{className:`relative z-10 flex h-7 w-7 shrink-0 items-center justify-center rounded-full border-2 ${i.bg} ${i.text} border-white`,children:(0,L.jsx)(a,{className:`h-3 w-3`})}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0 pt-0.5`,children:[(0,L.jsx)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:o?(0,L.jsx)(`span`,{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${i.bg} ${i.text}`,children:i.label}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-400 line-through`,children:W5[r]?.label||r}),(0,L.jsx)(el,{className:`h-3 w-3 text-surface-300`}),(0,L.jsx)(`span`,{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${i.bg} ${i.text}`,children:i.label})]})}),(0,L.jsx)(`p`,{className:`text-xs text-surface-400 mt-0.5`,children:q5(e.timestamp)}),e.notes&&(0,L.jsx)(`p`,{className:`text-xs text-surface-500 mt-1 bg-surface-50 rounded px-2 py-1`,children:e.notes})]})]},t)})]})]}),(0,L.jsxs)(`div`,{className:`bg-white rounded-xl border border-surface-200 p-5`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold text-surface-700 mb-4`,children:`Details`}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-surface-400 flex items-center gap-1.5`,children:[(0,L.jsx)(vu,{className:`h-3 w-3`}),`Source`]}),(0,L.jsx)(`span`,{className:`text-sm font-medium capitalize`,children:g.source})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-surface-400 flex items-center gap-1.5`,children:[(0,L.jsx)(Kc,{className:`h-3 w-3`}),`Days in Stage`]}),(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:g.days_in_stage??`—`})]}),g.assigned_to&&(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-surface-400 flex items-center gap-1.5`,children:[(0,L.jsx)(Nu,{className:`h-3 w-3`}),`Assigned To`]}),(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:g.assigned_to})]}),g.expires_at&&(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-surface-400 flex items-center gap-1.5`,children:[(0,L.jsx)(vc,{className:`h-3 w-3`}),`Expires`]}),(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:q5(g.expires_at)})]}),g.scheduled_date&&(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-surface-400 flex items-center gap-1.5`,children:[(0,L.jsx)(Yc,{className:`h-3 w-3`}),`Scheduled`]}),(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:q5(g.scheduled_date)})]}),(0,L.jsxs)(`div`,{className:`border-t border-surface-100 pt-3 mt-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:`Created`}),(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:q5(g.created_at)})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-surface-400`,children:`Updated`}),(0,L.jsx)(`span`,{className:`text-xs text-surface-500`,children:q5(g.updated_at)})]})]})]})]})]})]})]})})}var Z5=new Qr({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});function Q5({children:e}){let{isAuthenticated:t,isLoading:n}=W();return n?(0,L.jsx)(`div`,{className:`flex min-h-screen items-center justify-center`,children:(0,L.jsx)(PQ,{size:`lg`})}):t?(0,L.jsx)(L.Fragment,{children:e}):(0,L.jsx)(Rt,{to:`/auth/login`,replace:!0})}function $5({children:e,requireRole:t,requireAnyRole:n}){let{isAuthenticated:r,isLoading:i,isRole:a,hasRole:o}=W();return i?(0,L.jsx)(`div`,{className:`flex min-h-screen items-center justify-center`,children:(0,L.jsx)(PQ,{size:`lg`})}):r?t&&!a(t)||n&&!o(...n)?(0,L.jsx)(Rt,{to:`/app`,replace:!0}):(0,L.jsx)(L.Fragment,{children:e}):(0,L.jsx)(Rt,{to:`/auth/login`,replace:!0})}function e7({children:e,permission:t}){let{isAuthenticated:n,isLoading:r,hasCompanyPermission:i}=W();return r?(0,L.jsx)(`div`,{className:`flex min-h-screen items-center justify-center`,children:(0,L.jsx)(PQ,{size:`lg`})}):n?i(t)?(0,L.jsx)(L.Fragment,{children:e}):(0,L.jsx)(Rt,{to:`/app`,replace:!0}):(0,L.jsx)(Rt,{to:`/auth/login`,replace:!0})}function t7(){return(0,L.jsxs)(Bt,{children:[(0,L.jsx)(I,{path:`/`,element:(0,L.jsx)(ad,{})}),(0,L.jsx)(I,{path:`/industries/:slug`,element:(0,L.jsx)(NQ,{})}),(0,L.jsx)(I,{path:`/auth/login`,element:(0,L.jsx)(IQ,{})}),(0,L.jsx)(I,{path:`/auth/signup`,element:(0,L.jsx)(VQ,{})}),(0,L.jsx)(I,{path:`/auth/forgot-password`,element:(0,L.jsx)(HQ,{})}),(0,L.jsx)(I,{path:`/reset-password`,element:(0,L.jsx)(UQ,{})}),(0,L.jsx)(I,{path:`/app`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(T1,{})})}),(0,L.jsx)(I,{path:`/app/organizations`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(E1,{})})}),(0,L.jsx)(I,{path:`/app/commissions`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(D1,{})})}),(0,L.jsx)(I,{path:`/app/coaching`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(P2,{})})}),(0,L.jsx)(I,{path:`/app/integrations`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(e2,{})})}),(0,L.jsx)(I,{path:`/app/settings`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(z4,{})})}),(0,L.jsx)(I,{path:`/app/billing`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(z3,{})})}),(0,L.jsx)(I,{path:`/app/team`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(e7,{permission:`manage_team`,children:(0,L.jsx)(h6,{})})})}),(0,L.jsx)(I,{path:`/app/revenue-leaks`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(Q3,{})})}),(0,L.jsx)(I,{path:`/app/optimization-moves`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(y5,{feature:`scale_optimization`,children:(0,L.jsx)(t6,{})})})}),(0,L.jsx)(I,{path:`/app/forecasts`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(a6,{})})}),(0,L.jsx)(I,{path:`/app/coaching-assignments`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(s6,{})})}),(0,L.jsx)(I,{path:`/app/coaching-scorecards`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(u6,{})})}),(0,L.jsx)(I,{path:`/app/angi-leads`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(M6,{})})}),(0,L.jsx)(I,{path:`/app/quickbooks`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(W6,{})})}),(0,L.jsx)(I,{path:`/app/google-ads`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(i8,{})})}),(0,L.jsx)(I,{path:`/app/facebook-ads`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(g8,{})})}),(0,L.jsx)(I,{path:`/app/slack`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(O8,{})})}),(0,L.jsx)(I,{path:`/app/estimates`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(k5,{})})}),(0,L.jsx)(I,{path:`/app/estimates/list`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(U5,{})})}),(0,L.jsx)(I,{path:`/app/estimates/:estimateId`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(X5,{})})}),(0,L.jsx)(I,{path:`/app/sms-call`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(B8,{})})}),(0,L.jsx)(I,{path:`/app/sms-call/:leadId`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(B8,{})})}),(0,L.jsx)(I,{path:`/app/lead-gen`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(n5,{})})}),(0,L.jsx)(I,{path:`/app/lead-gen/campaigns/new`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(r5,{})})}),(0,L.jsx)(I,{path:`/app/lead-gen/campaigns/:campaignId`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(i5,{})})}),(0,L.jsx)(I,{path:`/app/lead-gen/creatives`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(a5,{})})}),(0,L.jsx)(I,{path:`/app/lead-gen/optimization`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(c5,{})})}),(0,L.jsx)(I,{path:`/app/lead-gen/attribution`,element:(0,L.jsx)(Q5,{children:(0,L.jsx)(u5,{})})}),(0,L.jsx)(I,{path:`/admin`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(O1,{})})}),(0,L.jsx)(I,{path:`/admin/organizations`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(k1,{})})}),(0,L.jsx)(I,{path:`/admin/organizations/:orgId`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(M1,{})})}),(0,L.jsx)(I,{path:`/admin/users`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(H1,{})})}),(0,L.jsx)(I,{path:`/admin/analytics`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(I1,{})})}),(0,L.jsx)(I,{path:`/admin/audit`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(G1,{})})}),(0,L.jsx)(I,{path:`/admin/crm-analytics`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(Y1,{})})}),(0,L.jsx)(I,{path:`/admin/forecasting`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(a0,{})})}),(0,L.jsx)(I,{path:`/admin/goals`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(y5,{feature:`cascading_goals`,children:(0,L.jsx)(b0,{})})})}),(0,L.jsx)(I,{path:`/admin/strategic-intelligence`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(y5,{feature:`strategic_intelligence`,children:(0,L.jsx)(k0,{})})})}),(0,L.jsx)(I,{path:`/admin/scale-optimization`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(y5,{feature:`scale_optimization`,children:(0,L.jsx)(H0,{})})})}),(0,L.jsx)(I,{path:`/admin/leads`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(K0,{})})}),(0,L.jsx)(I,{path:`/admin/integrations`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(m2,{})})}),(0,L.jsx)(I,{path:`/admin/enterprise`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(y5,{feature:`enterprise`,children:(0,L.jsx)(a2,{})})})}),(0,L.jsx)(I,{path:`/admin/multi-market`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(y5,{feature:`multi_market`,children:(0,L.jsx)(x2,{})})})}),(0,L.jsx)(I,{path:`/admin/coaching`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(P2,{})})}),(0,L.jsx)(I,{path:`/admin/portfolios`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(B4,{})})}),(0,L.jsx)(I,{path:`/admin/portfolios/:portfolioId`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(H4,{})})}),(0,L.jsx)(I,{path:`/admin/email-campaigns`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(K4,{})})}),(0,L.jsx)(I,{path:`/admin/super-admins`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(Q4,{})})}),(0,L.jsx)(I,{path:`/admin/partners`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(n3,{})})}),(0,L.jsx)(I,{path:`/admin/commissions`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(u3,{})})}),(0,L.jsx)(I,{path:`/admin/access-levels`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(b3,{})})}),(0,L.jsx)(I,{path:`/admin/settings`,element:(0,L.jsx)($5,{requireRole:`super_admin`,children:(0,L.jsx)(z4,{})})}),(0,L.jsx)(I,{path:`*`,element:(0,L.jsx)(Rt,{to:`/`,replace:!0})})]})}function n7(){let e=lt(),t=ft(),{user:n}=W();return(0,S.useEffect)(()=>{let r=new URLSearchParams(e.search),i=r.get(`oauth_success`),a=r.get(`oauth_error`);if(r.get(`picker`),(i||a)&&n){let r=e.search;t(`${n.role===`super_admin`?`/admin/integrations`:`/app/integrations`}${r}`,{replace:!0})}},[e.search,t,n]),null}function r7(){return(0,L.jsx)(li,{client:Z5,children:(0,L.jsx)(rc,{children:(0,L.jsx)(An,{children:(0,L.jsxs)(ic,{children:[(0,L.jsx)(n7,{}),(0,L.jsx)(t7,{})]})})})})}qs.createRoot(document.getElementById(`root`)).render((0,L.jsx)(S.StrictMode,{children:(0,L.jsx)(r7,{})}));