vendor: 4,256 bytes, lines 1-9
1var tE=e=>{throw TypeError(e)};var P0=(e,t,n)=>t.has(e)||tE("Cannot "+n);var me=(e,t,n)=>(P0(e,t,"read from private field"),n?n.call(e):t.get(e)),xt=(e,t,n)=>t.has(e)?tE("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(P0(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Ft=(e,t,n)=>(P0(e,t,"access private method"),n);var Gp=(e,t,n,r)=>({set _(s){st(e,t,s,n)},get _(){return me(e,t,r)}});function j9(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var Vo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var q$={exports:{}},jv={},z$={exports:{}},Wt={};/** 2 * @license React 3 * react.production.min.js 4 * 5 * Copyright (c) Facebook, Inc. and its affiliates. 6 * 7 * This source code is licensed under the MIT license found in the 8 * LICENSE file in the root directory of this source tree. 9 */var ip=Symbol.for("react.element"),N9=Symbol.for("react.portal"),S9=Symbol.for("react.fragment"),C9=Symbol.for("react.strict_mode"),k9=Symbol.for("react.profiler"),E9=Symbol.for("react.provider"),P9=Symbol.for("react.context"),O9=Symbol.for("react.forward_ref"),A9=Symbol.for("react.suspense"),T9=Symbol.for("react.memo"),M9=Symbol.for("react.lazy"),nE=Symbol.iterator;function D9(e){return e===null||typeof e!="object"?null:(e=nE&&e[nE]||e["@@iterator"],typeof e=="function"?e:null)}var B$={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},U$=Object.assign,W$={};function Jd(e,t,n){this.props=e,this.context=t,this.refs=W$,this.updater=n||B$}Jd.prototype.isReactComponent={};Jd.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Jd.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function K$(){}K$.prototype=Jd.prototype;function aS(e,t,n){this.props=e,this.context=t,this.refs=W$,this.updater=n||B$}var sS=aS.prototype=new K$;sS.constructor=aS;U$(sS,Jd.prototype);sS.isPureReactComponent=!0;var rE=Array.isArray,H$=Object.prototype.hasOwnProperty,iS={current:null},G$={key:!0,ref:!0,__self:!0,__source:!0};function V$(e,t,n){var r,s={},i=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)H$.call(t,r)&&!G$.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];s.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:ip,type:e,key:i,ref:o,props:s,_owner:iS.current}}function $9(e,t){return{$$typeof:ip,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function oS(e){return typeof e=="object"&&e!==null&&e.$$typeof===ip}function R9(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var aE=/\/+/g;function O0(e,t){return typeof e=="object"&&e!==null&&e.key!=null?R9(""+e.key):t.toString(36)}
vendor: 4,788 bytes, lines 9-17
9function Xg(e,t,n,r,s){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case ip:case N9:o=!0}}if(o)return o=e,s=s(o),e=r===""?"."+O0(o,0):r,rE(s)?(n="",e!=null&&(n=e.replace(aE,"$&/")+"/"),Xg(s,t,n,"",function(u){return u})):s!=null&&(oS(s)&&(s=$9(s,n+(!s.key||o&&o.key===s.key?"":(""+s.key).replace(aE,"$&/")+"/")+e)),t.push(s)),1;if(o=0,r=r===""?".":r+":",rE(e))for(var l=0;l<e.length;l++){i=e[l];var c=r+O0(i,l);o+=Xg(i,t,n,c,s)}else if(c=D9(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=r+O0(i,l++),o+=Xg(i,t,n,c,s);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function Vp(e,t,n){if(e==null)return e;var r=[],s=0;return Xg(e,r,"","",function(i){return t.call(n,i,s++)}),r}function I9(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var la={current:null},Jg={transition:null},L9={ReactCurrentDispatcher:la,ReactCurrentBatchConfig:Jg,ReactCurrentOwner:iS};function Y$(){throw Error("act(...) is not supported in production builds of React.")}Wt.Children={map:Vp,forEach:function(e,t,n){Vp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Vp(e,function(){t++}),t},toArray:function(e){return Vp(e,function(t){return t})||[]},only:function(e){if(!oS(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Wt.Component=Jd;Wt.Fragment=S9;Wt.Profiler=k9;Wt.PureComponent=aS;Wt.StrictMode=C9;Wt.Suspense=A9;Wt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=L9;Wt.act=Y$;Wt.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=U$({},e.props),s=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=iS.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)H$.call(t,c)&&!G$.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}return{$$typeof:ip,type:e.type,key:s,ref:i,props:r,_owner:o}};Wt.createContext=function(e){return e={$$typeof:P9,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:E9,_context:e},e.Consumer=e};Wt.createElement=V$;Wt.createFactory=function(e){var t=V$.bind(null,e);return t.type=e,t};Wt.createRef=function(){return{current:null}};Wt.forwardRef=function(e){return{$$typeof:O9,render:e}};Wt.isValidElement=oS;Wt.lazy=function(e){return{$$typeof:M9,_payload:{_status:-1,_result:e},_init:I9}};Wt.memo=function(e,t){return{$$typeof:T9,type:e,compare:t===void 0?null:t}};Wt.startTransition=function(e){var t=Jg.transition;Jg.transition={};try{e()}finally{Jg.transition=t}};Wt.unstable_act=Y$;Wt.useCallback=function(e,t){return la.current.useCallback(e,t)};Wt.useContext=function(e){return la.current.useContext(e)};Wt.useDebugValue=function(){};Wt.useDeferredValue=function(e){return la.current.useDeferredValue(e)};Wt.useEffect=function(e,t){return la.current.useEffect(e,t)};Wt.useId=function(){return la.current.useId()};Wt.useImperativeHandle=function(e,t,n){return la.current.useImperativeHandle(e,t,n)};Wt.useInsertionEffect=function(e,t){return la.current.useInsertionEffect(e,t)};Wt.useLayoutEffect=function(e,t){return la.current.useLayoutEffect(e,t)};Wt.useMemo=function(e,t){return la.current.useMemo(e,t)};Wt.useReducer=function(e,t,n){return la.current.useReducer(e,t,n)};Wt.useRef=function(e){return la.current.useRef(e)};Wt.useState=function(e){return la.current.useState(e)};Wt.useSyncExternalStore=function(e,t,n){return la.current.useSyncExternalStore(e,t,n)};Wt.useTransition=function(){return la.current.useTransition()};Wt.version="18.3.1";z$.exports=Wt;var y=z$.exports;const ae=dn(y),lS=j9({__proto__:null,default:ae},[y]);/** 10 * @license React 11 * react-jsx-runtime.production.min.js 12 * 13 * Copyright (c) Facebook, Inc. and its affiliates. 14 * 15 * This source code is licensed under the MIT license found in the 16 * LICENSE file in the root directory of this source tree. 17 */var F9=y,q9=Symbol.for("react.element"),z9=Symbol.for("react.fragment"),B9=Object.prototype.hasOwnProperty,U9=F9.__SECRET_INT
vendor: 8,823 bytes, lines 17-33
17ERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,W9={key:!0,ref:!0,__self:!0,__source:!0};function Q$(e,t,n){var r,s={},i=null,o=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)B9.call(t,r)&&!W9.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:q9,type:e,key:i,ref:o,props:s,_owner:U9.current}}jv.Fragment=z9;jv.jsx=Q$;jv.jsxs=Q$;q$.exports=jv;var a=q$.exports,X$={exports:{}},Wa={},J$={exports:{}},Z$={};/** 18 * @license React 19 * scheduler.production.min.js 20 * 21 * Copyright (c) Facebook, Inc. and its affiliates. 22 * 23 * This source code is licensed under the MIT license found in the 24 * LICENSE file in the root directory of this source tree. 25 */(function(e){function t($,M){var B=$.length;$.push(M);e:for(;0<B;){var W=B-1>>>1,A=$[W];if(0<s(A,M))$[W]=M,$[B]=A,B=W;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var M=$[0],B=$.pop();if(B!==M){$[0]=B;e:for(var W=0,A=$.length,K=A>>>1;W<K;){var G=2*(W+1)-1,H=$[G],fe=G+1,te=$[fe];if(0>s(H,B))fe<A&&0>s(te,H)?($[W]=te,$[fe]=B,W=fe):($[W]=H,$[G]=B,W=G);else if(fe<A&&0>s(te,B))$[W]=te,$[fe]=B,W=fe;else break e}}return M}function s($,M){var B=$.sortIndex-M.sortIndex;return B!==0?B:$.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,h=null,m=3,f=!1,x=!1,g=!1,p=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w($){for(var M=n(u);M!==null;){if(M.callback===null)r(u);else if(M.startTime<=$)r(u),M.sortIndex=M.expirationTime,t(c,M);else break;M=n(u)}}function N($){if(g=!1,w($),!x)if(n(c)!==null)x=!0,q(j);else{var M=n(u);M!==null&&I(N,M.startTime-$)}}function j($,M){x=!1,g&&(g=!1,v(P),P=-1),f=!0;var B=m;try{for(w(M),h=n(c);h!==null&&(!(h.expirationTime>M)||$&&!T());){var W=h.callback;if(typeof W=="function"){h.callback=null,m=h.priorityLevel;var A=W(h.expirationTime<=M);M=e.unstable_now(),typeof A=="function"?h.callback=A:h===n(c)&&r(c),w(M)}else r(c);h=n(c)}if(h!==null)var K=!0;else{var G=n(u);G!==null&&I(N,G.startTime-M),K=!1}return K}finally{h=null,m=B,f=!1}}var _=!1,S=null,P=-1,k=5,C=-1;function T(){return!(e.unstable_now()-C<k)}function O(){if(S!==null){var $=e.unstable_now();C=$;var M=!0;try{M=S(!0,$)}finally{M?L():(_=!1,S=null)}}else _=!1}var L;if(typeof b=="function")L=function(){b(O)};else if(typeof MessageChannel<"u"){var E=new MessageChannel,R=E.port2;E.port1.onmessage=O,L=function(){R.postMessage(null)}}else L=function(){p(O,0)};function q($){S=$,_||(_=!0,L())}function I($,M){P=p(function(){$(e.unstable_now())},M)}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($){$.callback=null},e.unstable_continueExecution=function(){x||f||(x=!0,q(j))},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):k=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function($){switch(m){case 1:case 2:case 3:var M=3;break;default:M=m}var B=m;m=M;try{return $()}finally{m=B}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,M){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var B=m;m=$;try{return M()}finally{m=B}},e.unstable_scheduleCallback=function($,M,B){var W=e.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?W+B:W):B=W,$){case 1:var A=-1;break;case 2:A=250;break;case 5:A=1073741823;break;case 4:A=1e4;break;default:A=5e3}return A=B+A,$={id:d++,callback:M,priorityLevel:$,startTime:B,expirationTime:A,sortIndex:-1},B>W?($.sortIndex=B,t(u,$),n(c)===null&&$===n(u)&&(g?(v(P),P=-1):g=!0,I(N,B-W))):($.sortIndex=A,t(c,$),x||f||(x=!0,q(j))),$},e.unstable_shouldYield=T,e.unstable_wrapCallback=function($){var M=m;return function(){var B=m;m=M;try{return $.apply(this,arguments)}finally{m=B}}}})(Z$);J$.exports=Z$;var K9=J$.exports;/** 26 * @license React 27 * react-dom.production.min.js 28 * 29 * Copyright (c) Facebook, Inc. and its affiliates. 30 * 31 * This source code is licensed under the MIT license found in the 32 * LICENSE file in the root directory of this source tree. 33 */var H9=y,qa=K9;function We(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;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."}var eR=new Set,If={};function Uc(e,t){yd(e,t),yd(e+"Capture",t)}function yd(e,t){for(If[e]=t,e=0;e<t.length;e++)eR.add(t[e])}var Zi=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),C_=Object.prototype.hasOwnProperty,G9=/^[: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]*$/,sE={},iE={};function V9(e){return C_.call(iE,e)?!0:C_.call(sE,e)?!1:G9.test(e)?iE[e]=!0:(sE[e]=!0,!1)}function Y9(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Q9(e,t,n,r){if(t===null||typeof t>"u"||Y9(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ca(e,t,n,r,s,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var Ir={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ir[e]=new ca(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ir[t]=new ca(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ir[e]=new ca(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ir[e]=new ca(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Ir[e]=new ca(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ir[e]=new ca(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ir[e]=new ca(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ir[e]=new ca(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ir[e]=new ca(e,5,!1,e.toLowerCase(),null,!1,!1)});var cS=/[\-:]([a-z])/g;function uS(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode
33-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(cS,uS);Ir[t]=new ca(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(cS,uS);Ir[t]=new ca(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(cS,uS);Ir[t]=new ca(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ir[e]=new ca(e,1,!1,e.toLowerCase(),null,!1,!1)});Ir.xlinkHref=new ca("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ir[e]=new ca(e,1,!1,e.toLowerCase(),null,!0,!0)});function dS(e,t,n,r){var s=Ir.hasOwnProperty(t)?Ir[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Q9(t,n,s,r)&&(n=null),r||s===null?V9(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):s.mustUseProperty?e[s.propertyName]=n===null?s.type===3?!1:"":n:(t=s.attributeName,r=s.attributeNamespace,n===null?e.removeAttribute(t):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var fo=H9.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Yp=Symbol.for("react.element"),Pu=Symbol.for("react.portal"),Ou=Symbol.for("react.fragment"),hS=Symbol.for("react.strict_mode"),k_=Symbol.for("react.profiler"),tR=Symbol.for("react.provider"),nR=Symbol.for("react.context"),fS=Symbol.for("react.forward_ref"),E_=Symbol.for("react.suspense"),P_=Symbol.for("react.suspense_list"),mS=Symbol.for("react.memo"),Oo=Symbol.for("react.lazy"),rR=Symbol.for("react.offscreen"),oE=Symbol.iterator;function Ph(e){return e===null||typeof e!="object"?null:(e=oE&&e[oE]||e["@@iterator"],typeof e=="function"?e:null)}var $n=Object.assign,A0;function of(e){if(A0===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);A0=t&&t[1]||""}return` 34`+A0+e}var T0=!1;function M0(e,t){if(!e||T0)return"";T0=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var s=u.stack.split(` 35`),i=r.stack.split(` 36`),o=s.length-1,l=i.length-1;1<=o&&0<=l&&s[o]!==i[l];)l--;for(;1<=o&&0<=l;o--,l--)if(s[o]!==i[l]){if(o!==1||l!==1)do if(o--,l--,0>l||s[o]!==i[l]){var c=` 37`+s[o].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{T0=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?of(e):""}function X9(e){switch(e.tag){case 5:return of(e.type);case 16:return of("Lazy");case 13:return of("Suspense");case 19:return of("SuspenseList");case 0:case 2:case 15:return e=M0(e.type,!1),e;case 11:return e=M0(e.type.render,!1),e;case 1:return e=M0(e.type,!0),e;default:return""}}function O_(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ou:return"Fragment";case Pu:return"Portal";case k_:return"Profiler";case hS:return"StrictMode";case E_:return"Suspense";case P_:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case nR:return(e.displayName||"Context")+".Consumer";case tR:return(e._context.displayName||"Context")+".Provider";case fS:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case mS:return t=e.displayName||null,t!==null?t:O_(e.type)||"Memo";case Oo:t=e._payload,e=e._init;try{return O_(e(t))}catch{}}return null}function J9(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return O_(t);case 8:return t===hS?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function hl(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function aR(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Z9(e){var t=aR(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Qp(e){e._valueTracker||(e._valueTracker=Z9(e))}function sR(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=aR(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function wx(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function A_(e,t){var n=t.checked;return $n({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function lE(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=hl(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}
vendor: 4,658 bytes, line 37
37function iR(e,t){t=t.checked,t!=null&&dS(e,"checked",t,!1)}function T_(e,t){iR(e,t);var n=hl(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?M_(e,t.type,n):t.hasOwnProperty("defaultValue")&&M_(e,t.type,hl(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function cE(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function M_(e,t,n){(t!=="number"||wx(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var lf=Array.isArray;function Ku(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&r&&(e[n].defaultSelected=!0)}else{for(n=""+hl(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function D_(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(We(91));return $n({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function uE(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(We(92));if(lf(n)){if(1<n.length)throw Error(We(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:hl(n)}}function oR(e,t){var n=hl(t.value),r=hl(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function dE(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function lR(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function $_(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?lR(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Xp,cR=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,s){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Xp=Xp||document.createElement("div"),Xp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Xp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Lf(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var yf={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},e7=["Webkit","ms","Moz","O"];Object.keys(yf).forEach(function(e){e7.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),yf[t]=yf[e]})});function uR(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||yf.hasOwnProperty(e)&&yf[e]?(""+t).trim():t+"px"}function dR(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=uR(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var t7=$n({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function R_(e,t){if(t){if(t7[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(We(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(We(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(We(61))}if(t.style!=null&&typeof t.style!="object")throw Error(We(62))}}function I_(e,t){if(e.indexOf("-")===-1)return typeof t.is=="str
37ing";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 L_=null;function pS(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var F_=null,Hu=null,Gu=null;function hE(e){if(e=cp(e)){if(typeof F_!="function")throw Error(We(280));var t=e.stateNode;t&&(t=Ev(t),F_(e.stateNode,e.type,t))}}function hR(e){Hu?Gu?Gu.push(e):Gu=[e]:Hu=e}function fR(){if(Hu){var e=Hu,t=Gu;if(Gu=Hu=null,hE(e),t)for(e=0;e<t.length;e++)hE(t[e])}}function mR(e,t){return e(t)}function pR(){}var D0=!1;function gR(e,t,n){if(D0)return e(t,n);D0=!0;try{return mR(e,t,n)}finally{D0=!1,(Hu!==null||Gu!==null)&&(pR(),fR())}}function Ff(e,t){var n=e.stateNode;if(n===null)return null;var r=Ev(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(We(231,t,typeof n));return n}var q_=!1;if(Zi)try{var Oh={};Object.defineProperty(Oh,"passive",{get:function(){q_=!0}}),window.addEventListener("test",Oh,Oh),window.removeEventListener("test",Oh,Oh)}catch{q_=!1}function n7(e,t,n,r,s,i,o,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(d){this.onError(d)}}var vf=!1,_x=null,jx=!1,z_=null,r7={onError:function(e){vf=!0,_x=e}};function a7(e,t,n,r,s,i,o,l,c){vf=!1,_x=null,n7.apply(r7,arguments)}function s7(e,t,n,r,s,i,o,l,c){if(a7.apply(this,arguments),vf){if(vf){var u=_x;vf=!1,_x=null}else throw Error(We(198));jx||(jx=!0,z_=u)}}function Wc(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 xR(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 fE(e){if(Wc(e)!==e)throw Error(We(188))}function i7(e){var t=e.alternate;if(!t){if(t=Wc(e),t===null)throw Error(We(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var i=s.alternate;if(i===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===n)return fE(s),e;if(i===r)return fE(s),t;i=i.sibling}throw Error(We(188))}if(n.return!==r.return)n=s,r=i;else{for(var o=!1,l=s.child;l;){if(l===n){o=!0,n=s,r=i;break}if(l===r){o=!0,r=s,n=i;break}l=l.sibling}if(!o){for(l=i.child;l;){if(l===n){o=!0,n=i,r=s;break}if(l===r){o=!0,r=i,n=s;break}l=l.sibling}if(!o)throw Error(We(189))}}if(n.alternate!==r)throw Error(We(190))}if(n.tag!==3)throw Error(We(188));return n.stateNode.current===n?e:t}function yR(e){return e=i7(e),e!==null?vR(e):null}function vR(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=vR(e);if(t!==null)return t;e=e.sibling}return null}var bR=qa.unstable_scheduleCallback,mE=qa.unstable_cancelCallback,o7=qa.unstable_shouldYield,l7=qa.unstable_requestPaint,Wn=qa.unstable_now,c7=qa.unstable_getCurrentPriorityLevel,gS=qa.unstable_ImmediatePriority,wR=qa.unstable_UserBlockingPriority,Nx=qa.unstable_NormalPriority,u7=qa.unstable_LowPriority,_R=qa.unstable_IdlePriority,Nv=null,gi=null;function d7(e){if(gi&&typeof gi.onCommitFiberRoot=="function")try{gi.onCommitFiberRoot(Nv,e,void 0,(e.current.flags&128)===128)}catch{}}var Bs=Math.clz32?Math.clz32:m7,h7=Math.log,f7=Math.LN2;function m7(e){return e>>>=0,e===0?32:31-(h7(e)/f7|0)|0}var Jp=64,Zp=4194304;function cf(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Sx(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var l=o&~s;l!==0?r=cf(l):(i&=o,i!==0&&(r=cf(i)))}else o=n&~s,o!==0?r=cf(o):i!==0&&(r=cf(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Bs(t),s=1<<n,r|=e[n],t&=~s;return r}function p7(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function g7(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-Bs(i),l=1<<o,c=s[o];c===-1?(!(l&n)||l&r)&&(s[o]=p7(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function B_(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function jR(){var e=Jp;return Jp<<=1,!(Jp&4194240)&&(Jp=64),e}function $0(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function op(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Bs(t),e[t]=n}function x7(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var s=31-Bs(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function xS(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Bs(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var un=0;function NR(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}
vendor: 13,900 bytes, line 37
37var SR,yS,CR,kR,ER,U_=!1,eg=[],Zo=null,el=null,tl=null,qf=new Map,zf=new Map,Do=[],y7="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function pE(e,t){switch(e){case"focusin":case"focusout":Zo=null;break;case"dragenter":case"dragleave":el=null;break;case"mouseover":case"mouseout":tl=null;break;case"pointerover":case"pointerout":qf.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":zf.delete(t.pointerId)}}function Ah(e,t,n,r,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},t!==null&&(t=cp(t),t!==null&&yS(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function v7(e,t,n,r,s){switch(t){case"focusin":return Zo=Ah(Zo,e,t,n,r,s),!0;case"dragenter":return el=Ah(el,e,t,n,r,s),!0;case"mouseover":return tl=Ah(tl,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return qf.set(i,Ah(qf.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,zf.set(i,Ah(zf.get(i)||null,e,t,n,r,s)),!0}return!1}function PR(e){var t=Zl(e.target);if(t!==null){var n=Wc(t);if(n!==null){if(t=n.tag,t===13){if(t=xR(n),t!==null){e.blockedOn=t,ER(e.priority,function(){CR(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 Zg(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=W_(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);L_=r,n.target.dispatchEvent(r),L_=null}else return t=cp(n),t!==null&&yS(t),e.blockedOn=n,!1;t.shift()}return!0}function gE(e,t,n){Zg(e)&&n.delete(t)}function b7(){U_=!1,Zo!==null&&Zg(Zo)&&(Zo=null),el!==null&&Zg(el)&&(el=null),tl!==null&&Zg(tl)&&(tl=null),qf.forEach(gE),zf.forEach(gE)}function Th(e,t){e.blockedOn===t&&(e.blockedOn=null,U_||(U_=!0,qa.unstable_scheduleCallback(qa.unstable_NormalPriority,b7)))}function Bf(e){function t(s){return Th(s,e)}if(0<eg.length){Th(eg[0],e);for(var n=1;n<eg.length;n++){var r=eg[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Zo!==null&&Th(Zo,e),el!==null&&Th(el,e),tl!==null&&Th(tl,e),qf.forEach(t),zf.forEach(t),n=0;n<Do.length;n++)r=Do[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Do.length&&(n=Do[0],n.blockedOn===null);)PR(n),n.blockedOn===null&&Do.shift()}var Vu=fo.ReactCurrentBatchConfig,Cx=!0;function w7(e,t,n,r){var s=un,i=Vu.transition;Vu.transition=null;try{un=1,vS(e,t,n,r)}finally{un=s,Vu.transition=i}}function _7(e,t,n,r){var s=un,i=Vu.transition;Vu.transition=null;try{un=4,vS(e,t,n,r)}finally{un=s,Vu.transition=i}}function vS(e,t,n,r){if(Cx){var s=W_(e,t,n,r);if(s===null)K0(e,t,r,kx,n),pE(e,r);else if(v7(s,e,t,n,r))r.stopPropagation();else if(pE(e,r),t&4&&-1<y7.indexOf(e)){for(;s!==null;){var i=cp(s);if(i!==null&&SR(i),i=W_(e,t,n,r),i===null&&K0(e,t,r,kx,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else K0(e,t,r,null,n)}}var kx=null;function W_(e,t,n,r){if(kx=null,e=pS(r),e=Zl(e),e!==null)if(t=Wc(e),t===null)e=null;else if(n=t.tag,n===13){if(e=xR(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 kx=e,null}function OR(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(c7()){case gS:return 1;case wR:return 4;case Nx:case u7:return 16;case _R:return 536870912;default:return 16}default:return 16}}var Yo=null,bS=null,ex=null;function AR(){if(ex)return ex;var e,t=bS,n=t.length,r,s="value"in Yo?Yo.value:Yo.textContent,i=s.length;for(e=0;e<n&&t[e]===s[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===s[i-r];r++);return ex=s.slice(e,1<r?1-r:void 0)}function tx(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 tg(){return!0}function xE(){return!1}function Ka(e){function t(n,r,s,i,o){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?tg:xE,this.isPropagationStopped=xE,this}return $n(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=tg)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=tg)},persist:function(){},isPersistent:tg}),t}var Zd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},wS=Ka(Zd),lp=$n({},Zd,{view:0,detail:0}),j7=Ka(lp),R0,I0,Mh,Sv=$n({},lp,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_S,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!==Mh&&(Mh&&e.type==="mousemove"?(R0=e.screenX-Mh.screenX,I0=e.screenY-Mh.screenY):I0=R0=0,Mh=e),R0)},movementY:function(e){return"movementY"in e?e.movementY:I0}}),yE=Ka(Sv),N7=$n({},Sv,{dataTransfer:0}),S7=Ka(N7),C7=$n({},lp,{relatedTarget:0}),L0=Ka(C7),k7=$n({},Zd,{animationName:0,elapsedTime:0,pseudoElement:0}),E7=Ka(k7),P7=$n({},Zd,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),O7=Ka(P7),A7=$n({},Zd,{data:0}),vE=Ka(A7),T7={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},M7={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"},D7={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $7(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=D7[e])?!!t[e]:!1}function _S(){return $7}var R7=$n({},lp,{key:function(e){if(e.key){var t=T7[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=tx(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?M7[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_S,charCode:function(e){return e.type==="keypress"?tx(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?tx(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),I7=Ka(R7),L7=$n({},Sv,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),bE=Ka(L7),F7=$n({},lp,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_S}),q7=Ka(F7),z7=$n({},Zd,{propertyName:0,elapsedTime:0,pseudoElement:0}),B7=Ka(z7),U7=$n({},Sv,{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}),W7=Ka(U7),K7=[9,13,27,32],jS=Zi&&"CompositionEvent"in window,bf=null;Zi&&"documentMode"in document&&(bf=document.documentMode);var H7=Zi&&"TextEvent"in window&&!bf,TR=Zi&&(!jS||bf&&8<bf&&11>=bf),wE=" ",_E=!1;function MR(e,t){switch(e){case"keyup":return K7.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function DR(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Au=!1;function G7(e,t){switch(e){case"compositionend":return DR(t);case"keypress":return t.which!==32?null:(_E=!0,wE);case"textInput":return e=t.data,e===wE&&_E?null:e;default:return null}}function V7(e,t){if(Au)return e==="compositionend"||!jS&&MR(e,t)?(e=AR(),ex=bS=Yo=null,Au=!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 TR&&t.locale!=="ko"?null:t.data;default:return null}}var Y7={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 jE(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Y7[e.type]:t==="textarea"}function $R(e,t,n,r){hR(r),t=Ex(t,"onChange"),0<t.length&&(n=new wS("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var wf=null,Uf=null;function Q7(e){HR(e,0)}function Cv(e){var t=Du(e);if(sR(t))return e}function X7(e,t){if(e==="change")return t}var RR=!1;if(Zi){var F0;if(Zi){var q0="oninput"in document;if(!q0){var NE=document.createElement("div");NE.setAttribute("oninput","return;"),q0=typeof NE.oninput=="function"}F0=q0}else F0=!1;RR=F0&&(!document.documentMode||9<document.documentMode)}function SE(){wf&&(wf.detachEvent("onpropertychange",IR),Uf=wf=null)}function IR(e){if(e.propertyName==="value"&&Cv(Uf)){var t=[];$R(t,Uf,e,pS(e)),gR(Q7,t)}}function J7(e,t,n){e==="focusin"?(SE(),wf=t,Uf=n,wf.attachEvent("onpropertychange",IR)):e==="focusout"&&SE()}function Z7(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Cv(Uf)}function eW(e,t){if(e==="click")return Cv(t)}function tW(e,t){if(e==="input"||e==="change")return Cv(t)}function nW(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ks=typeof Object.is=="function"?Object.is:nW;function Wf(e,t){if(Ks(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)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 s=n[r];if(!C_.call(t,s)||!Ks(e[s],t[s]))return!1}return!0}function CE(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function kE(e,t){var n=CE(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}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=CE(n)}}function LR(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?LR(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function FR(){for(var e=window,t=wx();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=wx(e.document)}return t}function NS(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function rW(e){var t=FR(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&LR(n.ownerDocument.documentElement,n)){if(r!==null&&NS(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=kE(n,i);var o=kE(n,r);s&&o&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var aW=Zi&&"documentMode"in document&&11>=document.documentMode,Tu=null,K_=null,_f=null,H_=!1;function EE(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;H_||Tu==null||Tu!==wx(r)||(r=Tu,"selectionStart"in r&&NS(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focu
vendor: 4,352 bytes, line 37
37sNode:r.focusNode,focusOffset:r.focusOffset}),_f&&Wf(_f,r)||(_f=r,r=Ex(K_,"onSelect"),0<r.length&&(t=new wS("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Tu)))}function ng(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Mu={animationend:ng("Animation","AnimationEnd"),animationiteration:ng("Animation","AnimationIteration"),animationstart:ng("Animation","AnimationStart"),transitionend:ng("Transition","TransitionEnd")},z0={},qR={};Zi&&(qR=document.createElement("div").style,"AnimationEvent"in window||(delete Mu.animationend.animation,delete Mu.animationiteration.animation,delete Mu.animationstart.animation),"TransitionEvent"in window||delete Mu.transitionend.transition);function kv(e){if(z0[e])return z0[e];if(!Mu[e])return e;var t=Mu[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in qR)return z0[e]=t[n];return e}var zR=kv("animationend"),BR=kv("animationiteration"),UR=kv("animationstart"),WR=kv("transitionend"),KR=new Map,PE="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function bl(e,t){KR.set(e,t),Uc(t,[e])}for(var B0=0;B0<PE.length;B0++){var U0=PE[B0],sW=U0.toLowerCase(),iW=U0[0].toUpperCase()+U0.slice(1);bl(sW,"on"+iW)}bl(zR,"onAnimationEnd");bl(BR,"onAnimationIteration");bl(UR,"onAnimationStart");bl("dblclick","onDoubleClick");bl("focusin","onFocus");bl("focusout","onBlur");bl(WR,"onTransitionEnd");yd("onMouseEnter",["mouseout","mouseover"]);yd("onMouseLeave",["mouseout","mouseover"]);yd("onPointerEnter",["pointerout","pointerover"]);yd("onPointerLeave",["pointerout","pointerover"]);Uc("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Uc("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Uc("onBeforeInput",["compositionend","keypress","textInput","paste"]);Uc("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Uc("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Uc("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var uf="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(" "),oW=new Set("cancel close invalid load scroll toggle".split(" ").concat(uf));function OE(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,s7(r,t,void 0,e),e.currentTarget=null}function HR(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var o=r.length-1;0<=o;o--){var l=r[o],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==i&&s.isPropagationStopped())break e;OE(s,l,u),i=c}else for(o=0;o<r.length;o++){if(l=r[o],c=l.instance,u=l.currentTarget,l=l.listener,c!==i&&s.isPropagationStopped())break e;OE(s,l,u),i=c}}}if(jx)throw e=z_,jx=!1,z_=null,e}function Cn(e,t){var n=t[X_];n===void 0&&(n=t[X_]=new Set);var r=e+"__bubble";n.has(r)||(GR(t,e,2,!1),n.add(r))}function W0(e,t,n){var r=0;t&&(r|=4),GR(n,e,r,t)}var rg="_reactListening"+Math.random().toString(36).slice(2);function Kf(e){if(!e[rg]){e[rg]=!0,eR.forEach(function(n){n!=="selectionchange"&&(oW.has(n)||W0(n,!1,e),W0(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[rg]||(t[rg]=!0,W0("selectionchange",!1,t))}}function GR(e,t,n,r){switch(OR(t)){case 1:var s=w7;break;case 4:s=_7;break;default:s=vS}n=s.bind(null,t,n,e),s=void 0,!q_||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}
vendor: 2,676 bytes, line 37
37function K0(e,t,n,r,s){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var l=r.stateNode.containerInfo;if(l===s||l.nodeType===8&&l.parentNode===s)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===s||c.nodeType===8&&c.parentNode===s))return;o=o.return}for(;l!==null;){if(o=Zl(l),o===null)return;if(c=o.tag,c===5||c===6){r=i=o;continue e}l=l.parentNode}}r=r.return}gR(function(){var u=i,d=pS(n),h=[];e:{var m=KR.get(e);if(m!==void 0){var f=wS,x=e;switch(e){case"keypress":if(tx(n)===0)break e;case"keydown":case"keyup":f=I7;break;case"focusin":x="focus",f=L0;break;case"focusout":x="blur",f=L0;break;case"beforeblur":case"afterblur":f=L0;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":f=yE;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=S7;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=q7;break;case zR:case BR:case UR:f=E7;break;case WR:f=B7;break;case"scroll":f=j7;break;case"wheel":f=W7;break;case"copy":case"cut":case"paste":f=O7;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=bE}var g=(t&4)!==0,p=!g&&e==="scroll",v=g?m!==null?m+"Capture":null:m;g=[];for(var b=u,w;b!==null;){w=b;var N=w.stateNode;if(w.tag===5&&N!==null&&(w=N,v!==null&&(N=Ff(b,v),N!=null&&g.push(Hf(b,N,w)))),p)break;b=b.return}0<g.length&&(m=new f(m,x,null,n,d),h.push({event:m,listeners:g}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",f=e==="mouseout"||e==="pointerout",m&&n!==L_&&(x=n.relatedTarget||n.fromElement)&&(Zl(x)||x[eo]))break e;if((f||m)&&(m=d.window===d?d:(m=d.ownerDocument)?m.defaultView||m.parentWindow:window,f?(x=n.relatedTarget||n.toElement,f=u,x=x?Zl(x):null,x!==null&&(p=Wc(x),x!==p||x.tag!==5&&x.tag!==6)&&(x=null)):(f=null,x=u),f!==x)){if(g=yE,N="onMouseLeave",v="onMouseEnter",b="mouse",(e==="pointerout"||e==="pointerover")&&(g=bE,N="onPointerLeave",v="onPointerEnter",b="pointer"),p=f==null?m:Du(f),w=x==null?m:Du(x),m=new g(N,b+"leave",f,n,d),m.target=p,m.relatedTarget=w,N=null,Zl(d)===u&&(g=new g(v,b+"enter",x,n,d),g.target=w,g.relatedTarget=p,N=g),p=N,f&&x)t:{for(g=f,v=x,b=0,w=g;w;w=nu(w))b++;for(w=0,N=v;N;N=nu(N))w++;for(;0<b-w;)g=nu(g),b--;for(;0<w-b;)v=nu(v),w--;for(;b--;){if(g===v||v!==null&&g===v.alternate)break t;g=nu(g),v=nu(v)}g=null}else g=null;f!==null&&AE(h,m,f,g,!1),x!==null&&p!==null&&AE(h,p,x,g,!0)}}
vendor: 5,577 bytes, lines 37-38
37e:{if(m=u?Du(u):window,f=m.nodeName&&m.nodeName.toLowerCase(),f==="select"||f==="input"&&m.type==="file")var j=X7;else if(jE(m))if(RR)j=tW;else{j=Z7;var _=J7}else(f=m.nodeName)&&f.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(j=eW);if(j&&(j=j(e,u))){$R(h,j,n,d);break e}_&&_(e,m,u),e==="focusout"&&(_=m._wrapperState)&&_.controlled&&m.type==="number"&&M_(m,"number",m.value)}switch(_=u?Du(u):window,e){case"focusin":(jE(_)||_.contentEditable==="true")&&(Tu=_,K_=u,_f=null);break;case"focusout":_f=K_=Tu=null;break;case"mousedown":H_=!0;break;case"contextmenu":case"mouseup":case"dragend":H_=!1,EE(h,n,d);break;case"selectionchange":if(aW)break;case"keydown":case"keyup":EE(h,n,d)}var S;if(jS)e:{switch(e){case"compositionstart":var P="onCompositionStart";break e;case"compositionend":P="onCompositionEnd";break e;case"compositionupdate":P="onCompositionUpdate";break e}P=void 0}else Au?MR(e,n)&&(P="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(P="onCompositionStart");P&&(TR&&n.locale!=="ko"&&(Au||P!=="onCompositionStart"?P==="onCompositionEnd"&&Au&&(S=AR()):(Yo=d,bS="value"in Yo?Yo.value:Yo.textContent,Au=!0)),_=Ex(u,P),0<_.length&&(P=new vE(P,e,null,n,d),h.push({event:P,listeners:_}),S?P.data=S:(S=DR(n),S!==null&&(P.data=S)))),(S=H7?G7(e,n):V7(e,n))&&(u=Ex(u,"onBeforeInput"),0<u.length&&(d=new vE("onBeforeInput","beforeinput",null,n,d),h.push({event:d,listeners:u}),d.data=S))}HR(h,t)})}function Hf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ex(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=Ff(e,n),i!=null&&r.unshift(Hf(e,i,s)),i=Ff(e,t),i!=null&&r.push(Hf(e,i,s))),e=e.return}return r}function nu(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function AE(e,t,n,r,s){for(var i=t._reactName,o=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,s?(c=Ff(n,i),c!=null&&o.unshift(Hf(n,c,l))):s||(c=Ff(n,i),c!=null&&o.push(Hf(n,c,l)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var lW=/\r\n?/g,cW=/\u0000|\uFFFD/g;function TE(e){return(typeof e=="string"?e:""+e).replace(lW,` 38`).replace(cW,"")}function ag(e,t,n){if(t=TE(t),TE(e)!==t&&n)throw Error(We(425))}function Px(){}var G_=null,V_=null;function Y_(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Q_=typeof setTimeout=="function"?setTimeout:void 0,uW=typeof clearTimeout=="function"?clearTimeout:void 0,ME=typeof Promise=="function"?Promise:void 0,dW=typeof queueMicrotask=="function"?queueMicrotask:typeof ME<"u"?function(e){return ME.resolve(null).then(e).catch(hW)}:Q_;function hW(e){setTimeout(function(){throw e})}function H0(e,t){var n=t,r=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){e.removeChild(s),Bf(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Bf(t)}function nl(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function DE(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var eh=Math.random().toString(36).slice(2),ui="__reactFiber$"+eh,Gf="__reactProps$"+eh,eo="__reactContainer$"+eh,X_="__reactEvents$"+eh,fW="__reactListeners$"+eh,mW="__reactHandles$"+eh;function Zl(e){var t=e[ui];if(t)return t;for(var n=e.parentNode;n;){if(t=n[eo]||n[ui]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=DE(e);e!==null;){if(n=e[ui])return n;e=DE(e)}return t}e=n,n=e.parentNode}return null}function cp(e){return e=e[ui]||e[eo],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Du(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(We(33))}function Ev(e){return e[Gf]||null}var J_=[],$u=-1;function wl(e){return{current:e}}function Pn(e){0>$u||(e.current=J_[$u],J_[$u]=null,$u--)}function wn(e,t){$u++,J_[$u]=e.current,e.current=t}var fl={},Hr=wl(fl),ba=wl(!1),Nc=fl;function vd(e,t){var n=e.type.contextTypes;if(!n)return fl;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function wa(e){return e=e.childContextTypes,e!=null}function Ox(){Pn(ba),Pn(Hr)}function $E(e,t,n){if(Hr.current!==fl)throw Error(We(168));wn(Hr,t),wn(ba,n)}function VR(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(We(108,J9(e)||"Unknown",s));return $n({},n,r)}function Ax(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||fl,Nc=Hr.current,wn(Hr,e),wn(ba,ba.current),!0}function RE(e,t,n){var r=e.stateNode;if(!r)throw Error(We(169));n?(e=VR(e,t,Nc),r.__reactInternalMemoizedMergedChildContext=e,Pn(ba),Pn(Hr),wn(Hr,e)):Pn(ba),wn(ba,n)}var Ri=null,Pv=!1,G0=!1;function YR(e){Ri===null?Ri=[e]:Ri.push(e)}function pW(e){Pv=!0,YR(e)}function _l(){if(!G0&&Ri!==null){G0=!0;var e=0,t=un;try{var n=Ri;for(un=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Ri=null,Pv=!1}catch(s){throw Ri!==null&&(Ri=Ri.slice(e+1)),bR(gS,_l),s}finally{un=t,G0=!1}}return null}
vendor: 13,805 bytes, line 38
38var Ru=[],Iu=0,Tx=null,Mx=0,ts=[],ns=0,Sc=null,Fi=1,qi="";function Wl(e,t){Ru[Iu++]=Mx,Ru[Iu++]=Tx,Tx=e,Mx=t}function QR(e,t,n){ts[ns++]=Fi,ts[ns++]=qi,ts[ns++]=Sc,Sc=e;var r=Fi;e=qi;var s=32-Bs(r)-1;r&=~(1<<s),n+=1;var i=32-Bs(t)+s;if(30<i){var o=s-s%5;i=(r&(1<<o)-1).toString(32),r>>=o,s-=o,Fi=1<<32-Bs(t)+s|n<<s|r,qi=i+e}else Fi=1<<i|n<<s|r,qi=e}function SS(e){e.return!==null&&(Wl(e,1),QR(e,1,0))}function CS(e){for(;e===Tx;)Tx=Ru[--Iu],Ru[Iu]=null,Mx=Ru[--Iu],Ru[Iu]=null;for(;e===Sc;)Sc=ts[--ns],ts[ns]=null,qi=ts[--ns],ts[ns]=null,Fi=ts[--ns],ts[ns]=null}var La=null,Ia=null,An=!1,Is=null;function XR(e,t){var n=ss(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function IE(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,La=e,Ia=nl(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,La=e,Ia=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Sc!==null?{id:Fi,overflow:qi}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=ss(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,La=e,Ia=null,!0):!1;default:return!1}}function Z_(e){return(e.mode&1)!==0&&(e.flags&128)===0}function ej(e){if(An){var t=Ia;if(t){var n=t;if(!IE(e,t)){if(Z_(e))throw Error(We(418));t=nl(n.nextSibling);var r=La;t&&IE(e,t)?XR(r,n):(e.flags=e.flags&-4097|2,An=!1,La=e)}}else{if(Z_(e))throw Error(We(418));e.flags=e.flags&-4097|2,An=!1,La=e}}}function LE(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;La=e}function sg(e){if(e!==La)return!1;if(!An)return LE(e),An=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Y_(e.type,e.memoizedProps)),t&&(t=Ia)){if(Z_(e))throw JR(),Error(We(418));for(;t;)XR(e,t),t=nl(t.nextSibling)}if(LE(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(We(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Ia=nl(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Ia=null}}else Ia=La?nl(e.stateNode.nextSibling):null;return!0}function JR(){for(var e=Ia;e;)e=nl(e.nextSibling)}function bd(){Ia=La=null,An=!1}function kS(e){Is===null?Is=[e]:Is.push(e)}var gW=fo.ReactCurrentBatchConfig;function Dh(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(We(309));var r=n.stateNode}if(!r)throw Error(We(147,e));var s=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(o){var l=s.refs;o===null?delete l[i]:l[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error(We(284));if(!n._owner)throw Error(We(290,e))}return e}function ig(e,t){throw e=Object.prototype.toString.call(t),Error(We(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function FE(e){var t=e._init;return t(e._payload)}function ZR(e){function t(v,b){if(e){var w=v.deletions;w===null?(v.deletions=[b],v.flags|=16):w.push(b)}}function n(v,b){if(!e)return null;for(;b!==null;)t(v,b),b=b.sibling;return null}function r(v,b){for(v=new Map;b!==null;)b.key!==null?v.set(b.key,b):v.set(b.index,b),b=b.sibling;return v}function s(v,b){return v=il(v,b),v.index=0,v.sibling=null,v}function i(v,b,w){return v.index=w,e?(w=v.alternate,w!==null?(w=w.index,w<b?(v.flags|=2,b):w):(v.flags|=2,b)):(v.flags|=1048576,b)}function o(v){return e&&v.alternate===null&&(v.flags|=2),v}function l(v,b,w,N){return b===null||b.tag!==6?(b=ew(w,v.mode,N),b.return=v,b):(b=s(b,w),b.return=v,b)}function c(v,b,w,N){var j=w.type;return j===Ou?d(v,b,w.props.children,N,w.key):b!==null&&(b.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===Oo&&FE(j)===b.type)?(N=s(b,w.props),N.ref=Dh(v,b,w),N.return=v,N):(N=lx(w.type,w.key,w.props,null,v.mode,N),N.ref=Dh(v,b,w),N.return=v,N)}function u(v,b,w,N){return b===null||b.tag!==4||b.stateNode.containerInfo!==w.containerInfo||b.stateNode.implementation!==w.implementation?(b=tw(w,v.mode,N),b.return=v,b):(b=s(b,w.children||[]),b.return=v,b)}function d(v,b,w,N,j){return b===null||b.tag!==7?(b=yc(w,v.mode,N,j),b.return=v,b):(b=s(b,w),b.return=v,b)}function h(v,b,w){if(typeof b=="string"&&b!==""||typeof b=="number")return b=ew(""+b,v.mode,w),b.return=v,b;if(typeof b=="object"&&b!==null){switch(b.$$typeof){case Yp:return w=lx(b.type,b.key,b.props,null,v.mode,w),w.ref=Dh(v,null,b),w.return=v,w;case Pu:return b=tw(b,v.mode,w),b.return=v,b;case Oo:var N=b._init;return h(v,N(b._payload),w)}if(lf(b)||Ph(b))return b=yc(b,v.mode,w,null),b.return=v,b;ig(v,b)}return null}function m(v,b,w,N){var j=b!==null?b.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return j!==null?null:l(v,b,""+w,N);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Yp:return w.key===j?c(v,b,w,N):null;case Pu:return w.key===j?u(v,b,w,N):null;case Oo:return j=w._init,m(v,b,j(w._payload),N)}if(lf(w)||Ph(w))return j!==null?null:d(v,b,w,N,null);ig(v,w)}return null}function f(v,b,w,N,j){if(typeof N=="string"&&N!==""||typeof N=="number")return v=v.get(w)||null,l(b,v,""+N,j);if(typeof N=="object"&&N!==null){switch(N.$$typeof){case Yp:return v=v.get(N.key===null?w:N.key)||null,c(b,v,N,j);case Pu:return v=v.get(N.key===null?w:N.key)||null,u(b,v,N,j);case Oo:var _=N._init;return f(v,b,w,_(N._payload),j)}if(lf(N)||Ph(N))return v=v.get(w)||null,d(b,v,N,j,null);ig(b,N)}return null}function x(v,b,w,N){for(var j=null,_=null,S=b,P=b=0,k=null;S!==null&&P<w.length;P++){S.index>P?(k=S,S=null):k=S.sibling;var C=m(v,S,w[P],N);if(C===null){S===null&&(S=k);break}e&&S&&C.alternate===null&&t(v,S),b=i(C,b,P),_===null?j=C:_.sibling=C,_=C,S=k}if(P===w.length)return n(v,S),An&&Wl(v,P),j;if(S===null){for(;P<w.length;P++)S=h(v,w[P],N),S!==null&&(b=i(S,b,P),_===null?j=S:_.sibling=S,_=S);return An&&Wl(v,P),j}for(S=r(v,S);P<w.length;P++)k=f(S,v,P,w[P],N),k!==null&&(e&&k.alternate!==null&&S.delete(k.key===null?P:k.key),b=i(k,b,P),_===null?j=k:_.sibling=k,_=k);return e&&S.forEach(function(T){return t(v,T)}),An&&Wl(v,P),j}function g(v,b,w,N){var j=Ph(w);if(typeof j!="function")throw Error(We(150));if(w=j.call(w),w==null)throw Error(We(151));for(var _=j=null,S=b,P=b=0,k=null,C=w.next();S!==null&&!C.done;P++,C=w.next()){S.index>P?(k=S,S=null):k=S.sibling;var T=m(v,S,C.value,N);if(T===null){S===null&&(S=k);break}e&&S&&T.alternate===null&&t(v,S),b=i(T,b,P),_===null?j=T:_.sibling=T,_=T,S=k}if(C.done)return n(v,S),An&&Wl(v,P),j;if(S===null){for(;!C.done;P++,C=w.next())C=h(v,C.value,N),C!==null&&(b=i(C,b,P),_===null?j=C:_.sibling=C,_=C);return An&&Wl(v,P),j}for(S=r(v,S);!C.done;P++,C=w.next())C=f(S,v,P,C.value,N),C!==null&&(e&&C.alternate!==null&&S.delete(C.key===null?P:C.key),b=i(C,b,P),_===null?j=C:_.sibling=C,_=C);return e&&S.forEach(function(O){return t(v,O)}),An&&Wl(v,P),j}function p(v,b,w,N){if(typeof w=="object"&&w!==null&&w.type===Ou&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Yp:e:{for(var j=w.key,_=b;_!==null;){if(_.key===j){if(j=w.type,j===Ou){if(_.tag===7){n(v,_.sibling),b=s(_,w.props.children),b.return=v,v=b;break e}}else if(_.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===Oo&&FE(j)===_.type){n(v,_.sibling),b=s(_,w.props),b.ref=Dh(v,_,w),b.return=v,v=b;break e}n(v,_);break}else t(v,_);_=_.sibling}w.type===Ou?(b=yc(w.props.children,v.mode,N,w.key),b.return=v,v=b):(N=lx(w.type,w.key,w.props,null,v.mode,N),N.ref=Dh(v,b,w),N.return=v,v=N)}return o(v);case Pu:e:{for(_=w.key;b!==null;){if(b.key===_)if(b.tag===4&&b.stateNode.containerInfo===w.containerInfo&&b.stateNode.implementation===w.implementation){n(v,b.sibling),b=s(b,w.children||[]),b.return=v,v=b;break e}else{n(v,b);break}else t(v,b);b=b.sibling}b=tw(w,v.mode,N),b.return=v,v=b}return o(v);case Oo:return _=w._init,p(v,b,_(w._payload),N)}if(lf(w))return x(v,b,w,N);if(Ph(w))return g(v,b,w,N);ig(v,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,b!==null&&b.tag===6?(n(v,b.sibling),b=s(b,w),b.return=v,v=b):(n(v,b),b=ew(w,v.mode,N),b.return=v,v=b),o(v)):n(v,b)}return p}var wd=ZR(!0),eI=ZR(!1),Dx=wl(null),$x=null,Lu=null,ES=null;function PS(){ES=Lu=$x=null}function OS(e){var t=Dx.current;Pn(Dx),e._currentValue=t}function tj(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Yu(e,t){$x=e,ES=Lu=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(xa=!0),e.firstContext=null)}function ds(e){var t=e._currentValue;if(ES!==e)if(e={context:e,memoizedValue:t,next:null},Lu===null){if($x===null)throw Error(We(308));Lu=e,$x.dependencies={lanes:0,firstContext:e}}else Lu=Lu.next=e;return t}var ec=null;function AS(e){ec===null?ec=[e]:ec.push(e)}function tI(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,AS(t)):(n.next=s.next,s.next=n),t.interleaved=n,to(e,r)}function to(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Ao=!1;function TS(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function nI(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ki(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function rl(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Jt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,to(e,n)}return s=r.interleaved,s===null?(t.next=t,AS(r)):(t.next=s.next,s.next=t),r.interleaved=t,to(e,n)}function nx(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xS(e,n)}}function qE(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Rx(e,t,n,r){var s=e.updateQueue;Ao=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,u=c.next;c.next=null,o===null?i=u:o.next=u,o=c;var d=e.alternate;d!==null&&(d=d.updateQueue,l=d.lastBaseUpdate,l!==o&&(l===null?d.firstBaseUpdate=u:l.next=u,d.lastBaseUpdate=c))}if(i!==null){var h=s.baseState;o=0,d=u=c=null,l=i;do{var m=l.lane,f=l.eventTime;if((r&m)===m){d!==null&&(d=d.next={eventTime:f,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var x=e,g=l;switch(m=t,f=n,g.tag){case 1:if(x=g.payload,typeof x=="function"){h=x.call(f,h,m);break e}h=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=g.payload,m=typeof x=="function"?x.call(f,h,m):x,m==null)break e;h=$n({},h,m);break e;case 2:Ao=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[l]:m.push(l))}else f={eventTime:f,lane:m,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(u=d=f,c=h):d=d.next=f,o|=m;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;m=l,l=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(d===null&&(c=h),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do o|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);kc|=o,e.lanes=o,e.memoizedState=h}}function zE(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(We(191,s));s.call(r)}}}var up={},xi=wl(up),Vf=wl(up),Yf=wl(up);function tc(e){if(e===up)throw Error(We(174));return e}function MS(e,t){switch(wn(Yf,t),wn(Vf,e),wn(xi,up),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:$_(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=$_(t,e)}Pn(xi),wn(xi,t)}function _d(){Pn(xi),Pn(Vf),Pn(Yf)}function rI(e){tc(Yf.current);var t=tc(xi.current),n=$_(t,e.type);t!==n&&(wn(Vf,e),wn(xi,n))}function DS(e){Vf.current===e&&(Pn(xi),Pn(Vf))}var Mn=wl(0);function Ix(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var V0=[];function $S(){for(var e=0;e<V0.length;e++)V0[e]._workInProgressVersionPrimary=null;V0.length=0}var rx=fo.ReactCurrentDispatcher,Y0=fo.ReactCurrentBatchConfig,Cc=0,Dn=null,or=null,yr=null,Lx=!1,jf=!1,Qf=0,xW=0;function Lr(){throw Error(We(321))}function RS(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ks(e[n],t[n]))return!1;return!0}function IS(e,t,n,r,s,i){if(Cc=i,Dn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,rx.current=e===null||e.memoizedState===null?wW:_W,e=n(r,s),jf){i=0;do{if(jf=!1,Qf=0,25<=i)throw Error(We(301));i+=1,yr=or=null,t.updateQueue=null,rx.current=jW,e=n(r,s)}while(jf)}if(rx.current=Fx,t=or!==null&&or.next!==null,Cc=0,yr=or=Dn=null,
vendor: 6,422 bytes, line 38
38Lx=!1,t)throw Error(We(300));return e}function LS(){var e=Qf!==0;return Qf=0,e}function si(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return yr===null?Dn.memoizedState=yr=e:yr=yr.next=e,yr}function hs(){if(or===null){var e=Dn.alternate;e=e!==null?e.memoizedState:null}else e=or.next;var t=yr===null?Dn.memoizedState:yr.next;if(t!==null)yr=t,or=e;else{if(e===null)throw Error(We(310));or=e,e={memoizedState:or.memoizedState,baseState:or.baseState,baseQueue:or.baseQueue,queue:or.queue,next:null},yr===null?Dn.memoizedState=yr=e:yr=yr.next=e}return yr}function Xf(e,t){return typeof t=="function"?t(e):t}function Q0(e){var t=hs(),n=t.queue;if(n===null)throw Error(We(311));n.lastRenderedReducer=e;var r=or,s=r.baseQueue,i=n.pending;if(i!==null){if(s!==null){var o=s.next;s.next=i.next,i.next=o}r.baseQueue=s=i,n.pending=null}if(s!==null){i=s.next,r=r.baseState;var l=o=null,c=null,u=i;do{var d=u.lane;if((Cc&d)===d)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var h={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=h,o=r):c=c.next=h,Dn.lanes|=d,kc|=d}u=u.next}while(u!==null&&u!==i);c===null?o=r:c.next=l,Ks(r,t.memoizedState)||(xa=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do i=s.lane,Dn.lanes|=i,kc|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function X0(e){var t=hs(),n=t.queue;if(n===null)throw Error(We(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,i=t.memoizedState;if(s!==null){n.pending=null;var o=s=s.next;do i=e(i,o.action),o=o.next;while(o!==s);Ks(i,t.memoizedState)||(xa=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function aI(){}function sI(e,t){var n=Dn,r=hs(),s=t(),i=!Ks(r.memoizedState,s);if(i&&(r.memoizedState=s,xa=!0),r=r.queue,FS(lI.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||yr!==null&&yr.memoizedState.tag&1){if(n.flags|=2048,Jf(9,oI.bind(null,n,r,s,t),void 0,null),vr===null)throw Error(We(349));Cc&30||iI(n,t,s)}return s}function iI(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Dn.updateQueue,t===null?(t={lastEffect:null,stores:null},Dn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function oI(e,t,n,r){t.value=n,t.getSnapshot=r,cI(t)&&uI(e)}function lI(e,t,n){return n(function(){cI(t)&&uI(e)})}function cI(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ks(e,n)}catch{return!0}}function uI(e){var t=to(e,1);t!==null&&Us(t,e,1,-1)}function BE(e){var t=si();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Xf,lastRenderedState:e},t.queue=e,e=e.dispatch=bW.bind(null,Dn,e),[t.memoizedState,e]}function Jf(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Dn.updateQueue,t===null?(t={lastEffect:null,stores:null},Dn.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function dI(){return hs().memoizedState}function ax(e,t,n,r){var s=si();Dn.flags|=e,s.memoizedState=Jf(1|t,n,void 0,r===void 0?null:r)}function Ov(e,t,n,r){var s=hs();r=r===void 0?null:r;var i=void 0;if(or!==null){var o=or.memoizedState;if(i=o.destroy,r!==null&&RS(r,o.deps)){s.memoizedState=Jf(t,n,i,r);return}}Dn.flags|=e,s.memoizedState=Jf(1|t,n,i,r)}function UE(e,t){return ax(8390656,8,e,t)}function FS(e,t){return Ov(2048,8,e,t)}function hI(e,t){return Ov(4,2,e,t)}function fI(e,t){return Ov(4,4,e,t)}function mI(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function pI(e,t,n){return n=n!=null?n.concat([e]):null,Ov(4,4,mI.bind(null,t,e),n)}function qS(){}function gI(e,t){var n=hs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&RS(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function xI(e,t){var n=hs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&RS(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function yI(e,t,n){return Cc&21?(Ks(n,t)||(n=jR(),Dn.lanes|=n,kc|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,xa=!0),e.memoizedState=n)}function yW(e,t){var n=un;un=n!==0&&4>n?n:4,e(!0);var r=Y0.transition;Y0.transition={};try{e(!1),t()}finally{un=n,Y0.transition=r}}function vI(){return hs().memoizedState}function vW(e,t,n){var r=sl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},bI(e))wI(t,n);else if(n=tI(e,t,n,r),n!==null){var s=sa();Us(n,e,r,s),_I(n,t,r)}}function bW(e,t,n){var r=sl(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(bI(e))wI(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,l=i(o,n);if(s.hasEagerState=!0,s.eagerState=l,Ks(l,o)){var c=t.interleaved;c===null?(s.next=s,AS(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=tI(e,t,s,r),n!==null&&(s=sa(),Us(n,e,r,s),_I(n,t,r))}}function bI(e){var t=e.alternate;return e===Dn||t!==null&&t===Dn}function wI(e,t){jf=Lx=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function _I(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xS(e,n)}}var Fx={readContext:ds,useCallback:Lr,useContext:Lr,useEffect:Lr,useImperativeHandle:Lr,useInsertionEffect:Lr,useLayoutEffect:Lr,useMemo:Lr,useReducer:Lr,useRef:Lr,useState:Lr,useDebugValue:Lr,useDeferredValue:Lr,useTransition:Lr,useMutableSource:Lr,useSyncExternalStore:Lr,useId:Lr,unstable_isNewReconciler:!1},wW={readContext:ds,useCallback:function(e,t){return si().memoizedState=[e,t===void 0?null:t],e},useContext:ds,useEffect:UE,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ax(4194308,4,mI.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ax(4194308,4,e,t)},useInsertionEffect:function(e,t){return ax(4,2,e,t)},useMemo:function(e,t){var n=si();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=si();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=vW.bind(null,Dn,e),[r.memoizedState,e]}
vendor: 4,246 bytes, line 38
38,useRef:function(e){var t=si();return e={current:e},t.memoizedState=e},useState:BE,useDebugValue:qS,useDeferredValue:function(e){return si().memoizedState=e},useTransition:function(){var e=BE(!1),t=e[0];return e=yW.bind(null,e[1]),si().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Dn,s=si();if(An){if(n===void 0)throw Error(We(407));n=n()}else{if(n=t(),vr===null)throw Error(We(349));Cc&30||iI(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,UE(lI.bind(null,r,i,e),[e]),r.flags|=2048,Jf(9,oI.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=si(),t=vr.identifierPrefix;if(An){var n=qi,r=Fi;n=(r&~(1<<32-Bs(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Qf++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=xW++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},_W={readContext:ds,useCallback:gI,useContext:ds,useEffect:FS,useImperativeHandle:pI,useInsertionEffect:hI,useLayoutEffect:fI,useMemo:xI,useReducer:Q0,useRef:dI,useState:function(){return Q0(Xf)},useDebugValue:qS,useDeferredValue:function(e){var t=hs();return yI(t,or.memoizedState,e)},useTransition:function(){var e=Q0(Xf)[0],t=hs().memoizedState;return[e,t]},useMutableSource:aI,useSyncExternalStore:sI,useId:vI,unstable_isNewReconciler:!1},jW={readContext:ds,useCallback:gI,useContext:ds,useEffect:FS,useImperativeHandle:pI,useInsertionEffect:hI,useLayoutEffect:fI,useMemo:xI,useReducer:X0,useRef:dI,useState:function(){return X0(Xf)},useDebugValue:qS,useDeferredValue:function(e){var t=hs();return or===null?t.memoizedState=e:yI(t,or.memoizedState,e)},useTransition:function(){var e=X0(Xf)[0],t=hs().memoizedState;return[e,t]},useMutableSource:aI,useSyncExternalStore:sI,useId:vI,unstable_isNewReconciler:!1};function Es(e,t){if(e&&e.defaultProps){t=$n({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function nj(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:$n({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Av={isMounted:function(e){return(e=e._reactInternals)?Wc(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=sa(),s=sl(e),i=Ki(r,s);i.payload=t,n!=null&&(i.callback=n),t=rl(e,i,s),t!==null&&(Us(t,e,s,r),nx(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=sa(),s=sl(e),i=Ki(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=rl(e,i,s),t!==null&&(Us(t,e,s,r),nx(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=sa(),r=sl(e),s=Ki(n,r);s.tag=2,t!=null&&(s.callback=t),t=rl(e,s,r),t!==null&&(Us(t,e,r,n),nx(t,e,r))}};function WE(e,t,n,r,s,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,o):t.prototype&&t.prototype.isPureReactComponent?!Wf(n,r)||!Wf(s,i):!0}function jI(e,t,n){var r=!1,s=fl,i=t.contextType;return typeof i=="object"&&i!==null?i=ds(i):(s=wa(t)?Nc:Hr.current,r=t.contextTypes,i=(r=r!=null)?vd(e,s):fl),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Av,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function KE(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&&Av.enqueueReplaceState(t,t.state,null)}function rj(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},TS(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=ds(i):(i=wa(t)?Nc:Hr.current,s.context=vd(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(nj(e,t,i,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&Av.enqueueReplaceState(s,s.state,null),Rx(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}
vendor: 11,369 bytes, lines 38-40
38function jd(e,t){try{var n="",r=t;do n+=X9(r),r=r.return;while(r);var s=n}catch(i){s=` 39Error generating stack: `+i.message+` 40`+i.stack}return{value:e,source:t,stack:s,digest:null}}function J0(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function aj(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var NW=typeof WeakMap=="function"?WeakMap:Map;function NI(e,t,n){n=Ki(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){zx||(zx=!0,mj=r),aj(e,t)},n}function SI(e,t,n){n=Ki(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var s=t.value;n.payload=function(){return r(s)},n.callback=function(){aj(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){aj(e,t),typeof r!="function"&&(al===null?al=new Set([this]):al.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function HE(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new NW;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(n)||(s.add(n),e=LW.bind(null,e,t,n),t.then(e,e))}function GE(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function VE(e,t,n,r,s){return e.mode&1?(e.flags|=65536,e.lanes=s,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Ki(-1,1),t.tag=2,rl(n,t,1))),n.lanes|=1),e)}var SW=fo.ReactCurrentOwner,xa=!1;function Jr(e,t,n,r){t.child=e===null?eI(t,null,n,r):wd(t,e.child,n,r)}function YE(e,t,n,r,s){n=n.render;var i=t.ref;return Yu(t,s),r=IS(e,t,n,r,i,s),n=LS(),e!==null&&!xa?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,no(e,t,s)):(An&&n&&SS(t),t.flags|=1,Jr(e,t,r,s),t.child)}function QE(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!VS(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,CI(e,t,i,r,s)):(e=lx(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:Wf,n(o,r)&&e.ref===t.ref)return no(e,t,s)}return t.flags|=1,e=il(i,r),e.ref=t.ref,e.return=t,t.child=e}function CI(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(Wf(i,r)&&e.ref===t.ref)if(xa=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(xa=!0);else return t.lanes=e.lanes,no(e,t,s)}return sj(e,t,n,r,s)}function kI(e,t,n){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},wn(qu,Ta),Ta|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,wn(qu,Ta),Ta|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,wn(qu,Ta),Ta|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,wn(qu,Ta),Ta|=r;return Jr(e,t,s,n),t.child}function EI(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function sj(e,t,n,r,s){var i=wa(n)?Nc:Hr.current;return i=vd(t,i),Yu(t,s),n=IS(e,t,n,r,i,s),r=LS(),e!==null&&!xa?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,no(e,t,s)):(An&&r&&SS(t),t.flags|=1,Jr(e,t,n,s),t.child)}function XE(e,t,n,r,s){if(wa(n)){var i=!0;Ax(t)}else i=!1;if(Yu(t,s),t.stateNode===null)sx(e,t),jI(t,n,r),rj(t,n,r,s),r=!0;else if(e===null){var o=t.stateNode,l=t.memoizedProps;o.props=l;var c=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=ds(u):(u=wa(n)?Nc:Hr.current,u=vd(t,u));var d=n.getDerivedStateFromProps,h=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==r||c!==u)&&KE(t,o,r,u),Ao=!1;var m=t.memoizedState;o.state=m,Rx(t,r,o,s),c=t.memoizedState,l!==r||m!==c||ba.current||Ao?(typeof d=="function"&&(nj(t,n,d,r),c=t.memoizedState),(l=Ao||WE(t,n,l,r,m,c,u))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=u,r=l):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,nI(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:Es(t.type,l),o.props=u,h=t.pendingProps,m=o.context,c=n.contextType,typeof c=="object"&&c!==null?c=ds(c):(c=wa(n)?Nc:Hr.current,c=vd(t,c));var f=n.getDerivedStateFromProps;(d=typeof f=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==h||m!==c)&&KE(t,o,r,c),Ao=!1,m=t.memoizedState,o.state=m,Rx(t,r,o,s);var x=t.memoizedState;l!==h||m!==x||ba.current||Ao?(typeof f=="function"&&(nj(t,n,f,r),x=t.memoizedState),(u=Ao||WE(t,n,u,r,m,x,c)||!1)?(d||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,x,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,x,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=x),o.props=r,o.state=x,o.context=c,r=u):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return ij(e,t,n,r,i,s)}function ij(e,t,n,r,s,i){EI(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return s&&RE(t,n,!1),no(e,t,i);r=t.stateNode,SW.current=t;var l=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=wd(t,e.child,null,i),t.child=wd(t,null,l,i)):Jr(e,t,l,i),t.memoizedState=r.state,s&&RE(t,n,!0),t.child}function PI(e){var t=e.stateNode;t.pendingContext?$E(e,t.pendingContext,t.pendingContext!==t.context):t.context&&$E(e,t.context,!1),MS(e,t.containerInfo)}function JE(e,t,n,r,s){return bd(),kS(s),t.flags|=256,Jr(e,t,n,r),t.child}var oj={dehydrated:null,treeContext:null,retryLane:0};function lj(e){return{baseLanes:e,cachePool:null,transitions:null}}function OI(e,t,n){var r=t.pendingProps,s=Mn.current,i=!1,o=(t.flags&128)!==0,l;if((l=o)||(l=e!==null&&e.memoizedState===null?!1:(s&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),wn(Mn,s&1),e===null)return ej(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,i?(r=t.mode,i=t.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Dv(o,r,0,null),e=yc(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=lj(n),t.memoizedState=oj,e):zS(t,o));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return CW(e,t,o,r,l,s,n);if(i){i=r.fallback,o=t.mode,s=e.child,l=s.sibling;var c={mode:"hidden",children:r.children};return!(o&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=il(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=il(l,i):(i=yc(i,o,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,o=e.child.memoizedState,o=o===null?lj(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=oj,r}return i=e.child,e=i.sibling,r=il(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function zS(e,t){return t=Dv({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function og(e,t,n,r){return r!==null&&kS(r),wd(t,e.child,null,n),e=zS(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function CW(e,t,n,r,s,i,o){if(n)return t.flags&256?(t.flags&=-257,r=J0(Error(We(422))),og(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Dv({mode:"visible",children:r.children},s,0,null),i=yc(i,s,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&wd(t,e.child,null,o),t.child.memoizedState=lj(o),t.memoizedState=oj,i);if(!(t.mode&1))return og(e,t,o,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(We(419)),r=J0(i,r,void 0),og(e,t,o,r)}if(l=(o&e.childLanes)!==0,xa||l){if(r=vr,r!==null){switch(o&-o){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|o)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,to(e,s),Us(r,e,s,-1))}return GS(),r=J0(Error(We(421))),og(e,t,o,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=FW.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,Ia=nl(s.nextSibling),La=t,An=!0,Is=null,e!==null&&(ts[ns++]=Fi,ts[ns++]=qi,ts[ns++]=Sc,Fi=e.id,qi=e.overflow,Sc=t),t=zS(t,r.children),t.flags|=4096,t)}function ZE(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),tj(e.return,t,n)}function Z0(e,t,n,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function AI(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(Jr(e,t,r.children,n),r=Mn.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ZE(e,n,t);else if(e.tag===19)ZE(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(wn(Mn,r),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&Ix(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Z0(t,!1,s,n,i);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&Ix(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Z0(t,!0,n,null,i);break;case"together":Z0(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function sx(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function no(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),kc|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(We(153));
vendor: 5,452 bytes, line 40
40if(t.child!==null){for(e=t.child,n=il(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=il(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function kW(e,t,n){switch(t.tag){case 3:PI(t),bd();break;case 5:rI(t);break;case 1:wa(t.type)&&Ax(t);break;case 4:MS(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;wn(Dx,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(wn(Mn,Mn.current&1),t.flags|=128,null):n&t.child.childLanes?OI(e,t,n):(wn(Mn,Mn.current&1),e=no(e,t,n),e!==null?e.sibling:null);wn(Mn,Mn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return AI(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),wn(Mn,Mn.current),r)break;return null;case 22:case 23:return t.lanes=0,kI(e,t,n)}return no(e,t,n)}var TI,cj,MI,DI;TI=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};cj=function(){};MI=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,tc(xi.current);var i=null;switch(n){case"input":s=A_(e,s),r=A_(e,r),i=[];break;case"select":s=$n({},s,{value:void 0}),r=$n({},r,{value:void 0}),i=[];break;case"textarea":s=D_(e,s),r=D_(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Px)}R_(n,r);var o;n=null;for(u in s)if(!r.hasOwnProperty(u)&&s.hasOwnProperty(u)&&s[u]!=null)if(u==="style"){var l=s[u];for(o in l)l.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(If.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var c=r[u];if(l=s!=null?s[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(o in l)!l.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in c)c.hasOwnProperty(o)&&l[o]!==c[o]&&(n||(n={}),n[o]=c[o])}else n||(i||(i=[]),i.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(If.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&Cn("scroll",e),i||l===c||(i=[])):(i=i||[]).push(u,c))}n&&(i=i||[]).push("style",n);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};DI=function(e,t,n,r){n!==r&&(t.flags|=4)};function $h(e,t){if(!An)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 Fr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function EW(e,t,n){var r=t.pendingProps;switch(CS(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Fr(t),null;case 1:return wa(t.type)&&Ox(),Fr(t),null;case 3:return r=t.stateNode,_d(),Pn(ba),Pn(Hr),$S(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(sg(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Is!==null&&(xj(Is),Is=null))),cj(e,t),Fr(t),null;case 5:DS(t);var s=tc(Yf.current);if(n=t.type,e!==null&&t.stateNode!=null)MI(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(We(166));return Fr(t),null}if(e=tc(xi.current),sg(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[ui]=t,r[Gf]=i,e=(t.mode&1)!==0,n){case"dialog":Cn("cancel",r),Cn("close",r);break;case"iframe":case"object":case"embed":Cn("load",r);break;case"video":case"audio":for(s=0;s<uf.length;s++)Cn(uf[s],r);break;case"source":Cn("error",r);break;case"img":case"image":case"link":Cn("error",r),Cn("load",r);break;case"details":Cn("toggle",r);break;case"input":lE(r,i),Cn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Cn("invalid",r);break;case"textarea":uE(r,i),Cn("invalid",r)}R_(n,i),s=null;for(var o in i)if(i.hasOwnProperty(o)){var l=i[o];o==="children"?typeof l=="string"?r.textContent!==l&&(i.suppressHydrationWarning!==!0&&ag(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&ag(r.textContent,l,e),s=["children",""+l]):If.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&Cn("scroll",r)}switch(n){case"input":Qp(r),cE(r,i,!0);break;case"textarea":Qp(r),dE(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Px)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=lR(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>
40",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[ui]=t,e[Gf]=r,TI(e,t,!1,!1),t.stateNode=e;e:{switch(o=I_(n,r),n){case"dialog":Cn("cancel",e),Cn("close",e),s=r;break;case"iframe":case"object":case"embed":Cn("load",e),s=r;break;case"video":case"audio":for(s=0;s<uf.length;s++)Cn(uf[s],e);s=r;break;case"source":Cn("error",e),s=r;break;case"img":case"image":case"link":Cn("error",e),Cn("load",e),s=r;break;case"details":Cn("toggle",e),s=r;break;case"input":lE(e,r),s=A_(e,r),Cn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=$n({},r,{value:void 0}),Cn("invalid",e);break;case"textarea":uE(e,r),s=D_(e,r),Cn("invalid",e);break;default:s=r}R_(n,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?dR(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&cR(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Lf(e,c):typeof c=="number"&&Lf(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(If.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Cn("scroll",e):c!=null&&dS(e,i,c,o))}switch(n){case"input":Qp(e),cE(e,r,!1);break;case"textarea":Qp(e),dE(e);break;case"option":r.value!=null&&e.setAttribute("value",""+hl(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?Ku(e,!!r.multiple,i,!1):r.defaultValue!=null&&Ku(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Px)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Fr(t),null;case 6:if(e&&t.stateNode!=null)DI(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(We(166));if(n=tc(Yf.current),tc(xi.current),sg(t)){if(r=t.stateNode,n=t.memoizedProps,r[ui]=t,(i=r.nodeValue!==n)&&(e=La,e!==null))switch(e.tag){case 3:ag(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&ag(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[ui]=t,t.stateNode=r}return Fr(t),null;case 13:if(Pn(Mn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(An&&Ia!==null&&t.mode&1&&!(t.flags&128))JR(),bd(),t.flags|=98560,i=!1;else if(i=sg(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(We(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(We(317));i[ui]=t}else bd(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Fr(t),i=!1}else Is!==null&&(xj(Is),Is=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Mn.current&1?cr===0&&(cr=3):GS())),t.updateQueue!==null&&(t.flags|=4),Fr(t),null);case 4:return _d(),cj(e,t),e===null&&Kf(t.stateNode.containerInfo),Fr(t),null;case 10:return OS(t.type._context),Fr(t),null;case 17:return wa(t.type)&&Ox(),Fr(t),null;case 19:if(Pn(Mn),i=t.memoizedState,i===null)return Fr(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)$h(i,!1);else{if(cr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Ix(e),o!==null){for(t.flags|=128,$h(i,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return wn(Mn,Mn.current&1|2),t.child}e=e.sibling}i.tail!==null&&Wn()>Nd&&(t.flags|=128,r=!0,$h(i,!1),t.lanes=4194304)}else{if(!r)if(e=Ix(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),$h(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!An)return Fr(t),null}else 2*Wn()-i.renderingStartTime>Nd&&n!==1073741824&&(t.flags|=128,r=!0,$h(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Wn(),t.sibling=null,n=Mn.current,wn(Mn,r?n&1|2:n&1),t):(Fr(t),null);case 22:case 23:return HS(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ta&1073741824&&(Fr(t),t.subtreeFlags&6&&(t.flags|=8192)):Fr(t),null;case 24:return null;case 25:return null}throw Error(We(156,t.tag))}function PW(e,t){switch(CS(t),t.tag){case 1:return wa(t.type)&&Ox(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;
vendor: 26,035 bytes, line 40
40case 3:return _d(),Pn(ba),Pn(Hr),$S(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return DS(t),null;case 13:if(Pn(Mn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(We(340));bd()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Pn(Mn),null;case 4:return _d(),null;case 10:return OS(t.type._context),null;case 22:case 23:return HS(),null;case 24:return null;default:return null}}var lg=!1,Br=!1,OW=typeof WeakSet=="function"?WeakSet:Set,dt=null;function Fu(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Fn(e,t,r)}else n.current=null}function uj(e,t,n){try{n()}catch(r){Fn(e,t,r)}}var eP=!1;function AW(e,t){if(G_=Cx,e=FR(),NS(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,l=-1,c=-1,u=0,d=0,h=e,m=null;t:for(;;){for(var f;h!==n||s!==0&&h.nodeType!==3||(l=o+s),h!==i||r!==0&&h.nodeType!==3||(c=o+r),h.nodeType===3&&(o+=h.nodeValue.length),(f=h.firstChild)!==null;)m=h,h=f;for(;;){if(h===e)break t;if(m===n&&++u===s&&(l=o),m===i&&++d===r&&(c=o),(f=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=f}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(V_={focusedElem:e,selectionRange:n},Cx=!1,dt=t;dt!==null;)if(t=dt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,dt=e;else for(;dt!==null;){t=dt;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var g=x.memoizedProps,p=x.memoizedState,v=t.stateNode,b=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:Es(t.type,g),p);v.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(We(163))}}catch(N){Fn(t,t.return,N)}if(e=t.sibling,e!==null){e.return=t.return,dt=e;break}dt=t.return}return x=eP,eP=!1,x}function Nf(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&uj(t,n,i)}s=s.next}while(s!==r)}}function Tv(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function dj(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function $I(e){var t=e.alternate;t!==null&&(e.alternate=null,$I(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ui],delete t[Gf],delete t[X_],delete t[fW],delete t[mW])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function RI(e){return e.tag===5||e.tag===3||e.tag===4}function tP(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||RI(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function hj(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Px));else if(r!==4&&(e=e.child,e!==null))for(hj(e,t,n),e=e.sibling;e!==null;)hj(e,t,n),e=e.sibling}function fj(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&&(e=e.child,e!==null))for(fj(e,t,n),e=e.sibling;e!==null;)fj(e,t,n),e=e.sibling}var Or=null,Ms=!1;function jo(e,t,n){for(n=n.child;n!==null;)II(e,t,n),n=n.sibling}function II(e,t,n){if(gi&&typeof gi.onCommitFiberUnmount=="function")try{gi.onCommitFiberUnmount(Nv,n)}catch{}switch(n.tag){case 5:Br||Fu(n,t);case 6:var r=Or,s=Ms;Or=null,jo(e,t,n),Or=r,Ms=s,Or!==null&&(Ms?(e=Or,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Or.removeChild(n.stateNode));break;case 18:Or!==null&&(Ms?(e=Or,n=n.stateNode,e.nodeType===8?H0(e.parentNode,n):e.nodeType===1&&H0(e,n),Bf(e)):H0(Or,n.stateNode));break;case 4:r=Or,s=Ms,Or=n.stateNode.containerInfo,Ms=!0,jo(e,t,n),Or=r,Ms=s;break;case 0:case 11:case 14:case 15:if(!Br&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&uj(n,t,o),s=s.next}while(s!==r)}jo(e,t,n);break;case 1:if(!Br&&(Fu(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Fn(n,t,l)}jo(e,t,n);break;case 21:jo(e,t,n);break;case 22:n.mode&1?(Br=(r=Br)||n.memoizedState!==null,jo(e,t,n),Br=r):jo(e,t,n);break;default:jo(e,t,n)}}function nP(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new OW),t.forEach(function(r){var s=qW.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function _s(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=e,o=t,l=o;e:for(;l!==null;){switch(l.tag){case 5:Or=l.stateNode,Ms=!1;break e;case 3:Or=l.stateNode.containerInfo,Ms=!0;break e;case 4:Or=l.stateNode.containerInfo,Ms=!0;break e}l=l.return}if(Or===null)throw Error(We(160));II(i,o,s),Or=null,Ms=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){Fn(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)LI(t,e),t=t.sibling}function LI(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(_s(t,e),ti(e),r&4){try{Nf(3,e,e.return),Tv(3,e)}catch(g){Fn(e,e.return,g)}try{Nf(5,e,e.return)}catch(g){Fn(e,e.return,g)}}break;case 1:_s(t,e),ti(e),r&512&&n!==null&&Fu(n,n.return);break;case 5:if(_s(t,e),ti(e),r&512&&n!==null&&Fu(n,n.return),e.flags&32){var s=e.stateNode;try{Lf(s,"")}catch(g){Fn(e,e.return,g)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,o=n!==null?n.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&iR(s,i),I_(l,o);var u=I_(l,i);for(o=0;o<c.length;o+=2){var d=c[o],h=c[o+1];d==="style"?dR(s,h):d==="dangerouslySetInnerHTML"?cR(s,h):d==="children"?Lf(s,h):dS(s,d,h,u)}switch(l){case"input":T_(s,i);break;case"textarea":oR(s,i);break;case"select":var m=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var f=i.value;f!=null?Ku(s,!!i.multiple,f,!1):m!==!!i.multiple&&(i.defaultValue!=null?Ku(s,!!i.multiple,i.defaultValue,!0):Ku(s,!!i.multiple,i.multiple?[]:"",!1))}s[Gf]=i}catch(g){Fn(e,e.return,g)}}break;case 6:if(_s(t,e),ti(e),r&4){if(e.stateNode===null)throw Error(We(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(g){Fn(e,e.return,g)}}break;case 3:if(_s(t,e),ti(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Bf(t.containerInfo)}catch(g){Fn(e,e.return,g)}break;case 4:_s(t,e),ti(e);break;case 13:_s(t,e),ti(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(WS=Wn())),r&4&&nP(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(Br=(u=Br)||d,_s(t,e),Br=u):_s(t,e),ti(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(dt=e,d=e.child;d!==null;){for(h=dt=d;dt!==null;){switch(m=dt,f=m.child,m.tag){case 0:case 11:case 14:case 15:Nf(4,m,m.return);break;case 1:Fu(m,m.return);var x=m.stateNode;if(typeof x.componentWillUnmount=="function"){r=m,n=m.return;try{t=r,x.props=t.memoizedProps,x.state=t.memoizedState,x.componentWillUnmount()}catch(g){Fn(r,n,g)}}break;case 5:Fu(m,m.return);break;case 22:if(m.memoizedState!==null){aP(h);continue}}f!==null?(f.return=m,dt=f):aP(h)}d=d.sibling}e:for(d=null,h=e;;){if(h.tag===5){if(d===null){d=h;try{s=h.stateNode,u?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=h.stateNode,c=h.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=uR("display",o))}catch(g){Fn(e,e.return,g)}}}else if(h.tag===6){if(d===null)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(g){Fn(e,e.return,g)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;d===h&&(d=null),h=h.return}d===h&&(d=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:_s(t,e),ti(e),r&4&&nP(e);break;case 21:break;default:_s(t,e),ti(e)}}function ti(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(RI(n)){var r=n;break e}n=n.return}throw Error(We(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Lf(s,""),r.flags&=-33);var i=tP(e);fj(e,i,s);break;case 3:case 4:var o=r.stateNode.containerInfo,l=tP(e);hj(e,l,o);break;default:throw Error(We(161))}}catch(c){Fn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function TW(e,t,n){dt=e,FI(e)}function FI(e,t,n){for(var r=(e.mode&1)!==0;dt!==null;){var s=dt,i=s.child;if(s.tag===22&&r){var o=s.memoizedState!==null||lg;if(!o){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Br;l=lg;var u=Br;if(lg=o,(Br=c)&&!u)for(dt=s;dt!==null;)o=dt,c=o.child,o.tag===22&&o.memoizedState!==null?sP(s):c!==null?(c.return=o,dt=c):sP(s);for(;i!==null;)dt=i,FI(i),i=i.sibling;dt=s,lg=l,Br=u}rP(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,dt=i):rP(e)}}function rP(e){for(;dt!==null;){var t=dt;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Br||Tv(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Br)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Es(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&zE(t,i,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}zE(t,o,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var h=d.dehydrated;h!==null&&Bf(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(We(163))}Br||t.flags&512&&dj(t)}catch(m){Fn(t,t.return,m)}}if(t===e){dt=null;break}if(n=t.sibling,n!==null){n.return=t.return,dt=n;break}dt=t.return}}function aP(e){for(;dt!==null;){var t=dt;if(t===e){dt=null;break}var n=t.sibling;if(n!==null){n.return=t.return,dt=n;break}dt=t.return}}function sP(e){for(;dt!==null;){var t=dt;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Tv(4,t)}catch(c){Fn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Fn(t,s,c)}}var i=t.return;try{dj(t)}catch(c){Fn(t,i,c)}break;case 5:var o=t.return;try{dj(t)}catch(c){Fn(t,o,c)}}}catch(c){Fn(t,t.return,c)}if(t===e){dt=null;break}var l=t.sibling;if(l!==null){l.return=t.return,dt=l;break}dt=t.return}}var MW=Math.ceil,qx=fo.ReactCurrentDispatcher,BS=fo.ReactCurrentOwner,os=fo.ReactCurrentBatchConfig,Jt=0,vr=null,Jn=null,$r=0,Ta=0,qu=wl(0),cr=0,Zf=null,kc=0,Mv=0,US=0,Sf=null,ga=null,WS=0,Nd=1/0,Di=null,zx=!1,mj=null,al=null,cg=!1,Qo=null,Bx=0,Cf=0,pj=null,ix=-1,ox=0;function sa(){return Jt&6?Wn():ix!==-1?ix:ix=Wn()}function sl(e){return e.mode&1?Jt&2&&$r!==0?$r&-$r:gW.transition!==null?(ox===0&&(ox=jR()),ox):(e=un,e!==0||(e=window.event,e=e===void 0?16:OR(e.type)),e):1}function Us(e,t,n,r){if(50<Cf)throw Cf=0,pj=null,Error(We(185));op(e,n,r),(!(Jt&2)||e!==vr)&&(e===vr&&(!(Jt&2)&&(Mv|=n),cr===4&&$o(e,$r)),_a(e,r),n===1&&Jt===0&&!(t.mode&1)&&(Nd=Wn()+500,Pv&&_l()))}function _a(e,t){var n=e.callbackNode;g7(e,t);var r=Sx(e,e===vr?$r:0);if(r===0)n!==null&&mE(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&mE(n),t===1)e.tag===0?pW(iP.bind(null,e)):YR(iP.bind(null,e)),dW(function(){!(Jt&6)&&_l()}),n=null;else{switch(NR(r)){case 1:n=gS;break;case 4:n=wR;break;case 16:n=Nx;break;case 536870912:n=_R;break;default:n=Nx}n=GI(n,qI.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function qI(e,t){if(ix=-1,ox=0,Jt&6)throw Error(We(327));var n=e.callbackNode;if(Qu()&&e.callbackNode!==n)return null;var r=Sx(e,e===vr?$r:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Ux(e,r);else{t=r;var s=Jt;Jt|=2;var i=BI();(vr!==e||$r!==t)&&(Di=null,Nd=Wn()+500,xc(e,t));do try{RW();break}catch(l){zI(e,l)}while(!0);PS(),qx.current=i,Jt=s,Jn!==null?t=0:(vr=null,$r=0,t=cr)}if(t!==0){if(t===2&&(s=B_(e),s!==0&&(r=s,t=gj(e,s))),t===1)throw n=Zf,xc(e,0),$o(e,r),_a(e,Wn()),n;if(t===6)$o(e,r);else{if(s=e.current.alternate,!(r&30)&&!DW(s)&&(t=Ux(e,r),t===2&&(i=B_(e),i!==0&&(r=i,t=gj(e,i))),t===1))throw n=Zf,xc(e,0),$o(e,r),_a(e,Wn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(We(345));case 2:Kl(e,ga,Di);break;case 3:if($o(e,r),(r&130023424)===r&&(t=WS+500-Wn(),10<t)){if(Sx(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){sa(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Q_(Kl.bind(null,e,ga,Di),t);break}Kl(e,ga,Di);break;case 4:if($o(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var o=31-Bs(r);i=1<<o,o=t[o],o>s&&(s=o),r&=~i}if(r=s,r=Wn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*MW(r/1960))-r,10<r){e.timeoutHandle=Q_(Kl.bind(null,e,ga,Di),r);break}Kl(e,ga,Di);break;case 5:Kl(e,ga,Di);break;default:throw Error(We(329))}}}return _a(e,Wn()),e.callbackNode===n?qI.bind(null,e):null}function gj(e,t){var n=Sf;return e.current.memoizedState.isDehydrated&&(xc(e,t).flags|=256),e=Ux(e,t),e!==2&&(t=ga,ga=n,t!==null&&xj(t)),e}function xj(e){ga===null?ga=e:ga.push.apply(ga,e)}function DW(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],i=s.getSnapshot;s=s.value;try{if(!Ks(i(),s))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 $o(e,t){for(t&=~US,t&=~Mv,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Bs(t),r=1<<n;e[n]=-1,t&=~r}}function iP(e){if(Jt&6)throw Error(We(327));Qu();var t=Sx(e,0);if(!(t&1))return _a(e,Wn()),null;var n=Ux(e,t);if(e.tag!==0&&n===2){var r=B_(e);r!==0&&(t=r,n=gj(e,r))}if(n===1)throw n=Zf,xc(e,0),$o(e,t),_a(e,Wn()),n;if(n===6)throw Error(We(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Kl(e,ga,Di),_a(e,Wn()),null}function KS(e,t){var n=Jt;Jt|=1;try{return e(t)}finally{Jt=n,Jt===0&&(Nd=Wn()+500,Pv&&_l())}}function Ec(e){Qo!==null&&Qo.tag===0&&!(Jt&6)&&Qu();var t=Jt;Jt|=1;var n=os.transition,r=un;try{if(os.transition=null,un=1,e)return e()}finally{un=r,os.transition=n,Jt=t,!(Jt&6)&&_l()}}function HS(){Ta=qu.current,Pn(qu)}function xc(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,uW(n)),Jn!==null)for(n=Jn.return;n!==null;){var r=n;switch(CS(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Ox();break;case 3:_d(),Pn(ba),Pn(Hr),$S();break;case 5:DS(r);break;case 4:_d();break;case 13:Pn(Mn);break;case 19:Pn(Mn);break;case 10:OS(r.type._context);break;case 22:case 23:HS()}n=n.return}if(vr=e,Jn=e=il(e.current,null),$r=Ta=t,cr=0,Zf=null,US=Mv=kc=0,ga=Sf=null,ec!==null){for(t=0;t<ec.length;t++)if(n=ec[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,i=n.pending;if(i!==null){var o=i.next;i.next=s,r.next=o}n.pending=r}ec=null}return e}function zI(e,t){do{var n=Jn;try{if(PS(),rx.current=Fx,Lx){for(var r=Dn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Lx=!1}if(Cc=0,yr=or=Dn=null,jf=!1,Qf=0,BS.current=null,n===null||n.return===null){cr=1,Zf=t,Jn=null;break}e:{var i=e,o=n.return,l=n,c=t;if(t=$r,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,d=l,h=d.tag;if(!(d.mode&1)&&(h===0||h===11||h===15)){var m=d.alternate;m?(d.updateQueue=m.updateQueue,d.memoizedState=m.memoizedState,d.lanes=m.lanes):(d.updateQueue=null,d.memoizedState=null)}var f=GE(o);if(f!==null){f.flags&=-257,VE(f,o,l,i,t),f.mode&1&&HE(i,u,t),t=f,c=u;var x=t.updateQueue;if(x===null){var g=new Set;g.add(c),t.updateQueue=g}else x.add(c);break e}else{if(!(t&1)){HE(i,u,t),GS();break e}c=Error(We(426))}}else if(An&&l.mode&1){var p=GE(o);if(p!==null){!(p.flags&65536)&&(p.flags|=256),VE(p,o,l,i,t),kS(jd(c,l));break e}}i=c=jd(c,l),cr!==4&&(cr=2),Sf===null?Sf=[i]:Sf.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var v=NI(i,c,t);qE(i,v);break e;case 1:l=c;var b=i.type,w=i.stateNode;if(!(i.flags&128)&&(typeof b.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(al===null||!al.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var N=SI(i,l,t);qE(i,N);break e}}i=i.return}while(i!==null)}WI(n)}catch(j){t=j,Jn===n&&n!==null&&(Jn=n=n.return);continue}break}while(!0)}function BI(){var e=qx.current;return qx.current=Fx,e===null?Fx:e}function GS(){(cr===0||cr===3||cr===2)&&(cr=4),vr===null||!(kc&268435455)&&!(Mv&268435455)||$o(vr,$r)}function Ux(e,t){var n=Jt;Jt|=2;var r=BI();(vr!==e||$r!==t)&&(Di=null,xc(e,t));do try{$W();break}catch(s){zI(e,s)}while(!0);if(PS(),Jt=n,qx.current=r,Jn!==null)throw Error(We(261));return vr=null,$r=0,cr}function $W(){for(;Jn!==null;)UI(Jn)}function RW(){for(;Jn!==null&&!o7();)UI(Jn)}function UI(e){var t=HI(e.alternate,e,Ta);e.memoizedProps=e.pendingProps,t===null?WI(e):Jn=t,BS.current=null}function WI(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=PW(n,t),n!==null){n.flags&=32767,Jn=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{cr=6,Jn=null;return}}else if(n=EW(n,t,Ta),n!==null){Jn=n;return}if(t=t.sibling,t!==null){Jn=t;return}Jn=t=e}while(t!==null);cr===0&&(cr=5)}function Kl(e,t,n){var r=un,s=os.transition;try{os.transition=null,un=1,IW(e,t,n,r)}finally{os.transition=s,un=r}return null}function IW(e,t,n,r){do Qu();while(Qo!==null);if(Jt&6)throw Error(We(327));n=e.finishedWork;var s=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(We(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(x7(e,i),e===vr&&(Jn=vr=null,$r=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||cg||(cg=!0,GI(Nx,function(){return Qu(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=os.transition,os.transition=null;var o=un;un=1;var l=Jt;Jt|=4,BS.current=null,AW(e,n),LI(n,e),rW(V_),Cx=!!G_,V_=G_=null,e.current=n,TW(n),l7(),Jt=l,un=o,os.transition=i}else e.current=n;if(cg&&(cg=!1,Qo=e,Bx=s),i=e.pendingLanes,i===0&&(al=null),d7(n.stateNode),_a(e,Wn()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(zx)throw zx=!1,e=mj,mj=null,e;return Bx&1&&e.tag!==0&&Qu(),i=e.pendingLanes,i&1?e===pj?Cf++:(Cf=0,pj=e):Cf=0,_l(),null}function Qu(){if(Qo!==null){var e=NR(Bx),t=os.transition,n=un;try{if(os.transition=null,un=16>e?16:e,Qo===null)var r=!1;else{if(e=Qo,Qo=null,Bx=0,Jt&6)throw Error(We(331));var s=Jt;for(Jt|=4,dt=e.current;dt!==null;){var i=dt,o=i.child;if(dt.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(dt=u;dt!==null;){var d=dt;switch(d.tag){case 0:case 11:case 15:Nf(8,d,i)}var h=d.child;if(h!==null)h.return=d,dt=h;else for(;dt!==null;){d=dt;var m=d.sibling,f=d.return;if($I(d),d===u){dt=null;break}if(m!==null){m.return=f,dt=m;break}dt=f}}}var x=i.alternate;if(x!==null){var g=x.child;if(g!==null){x.child=null;do{var p=g.sibling;g.sibling=null,g=p}while(g!==null)}}dt=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,dt=o;else e:for(;dt!==null;){if(i=dt,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Nf(9,i,i.return)}var v=i.sibling;if(v!==null){v.return=i.return,dt=v;break e}dt=i.return}}var b=e.current;for(dt=b;dt!==null;){o=dt;var w=o.child;if(o.subtreeFlags&2064&&w!==null)w.return=o,dt=w;else e:for(o=b;dt!==null;){if(l=dt,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Tv(9,l)}}catch(j){Fn(l,l.return,j)}if(l===o){dt=null;break e}var N=l.sibling;if(N!==null){N.return=l.return,dt=N;break e}dt=l.return}}if(Jt=s,_l(),gi&&typeof gi.onPostCommitFiberRoot=="function")try{gi.onPostCommitFiberRoot(Nv,e)}catch{}r=!0}return r}finally{un=n,os.transition=t}}return!1}function oP(e,t,n){t=jd(n,t),t=NI(e,t,1),e=rl(e,t,1),t=sa(),e!==null&&(op(e,1,t),_a(e,t))}function Fn(e,t,n){if(e.tag===3)oP(e,e,n);else for(;t!==null;){if(t.tag===3){oP(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(al===null||!al.has(r))){e=jd(n,e),e=SI(t,e,1),t=rl(t,e,1),e=sa(),t!==null&&(op(t,1,e),_a(t,e));break}}t=t.return}}function LW(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=sa(),e.pingedLanes|=e.suspendedLanes&n,vr===e&&($r&n)===n&&(cr===4||cr===3&&($r&130023424)===$r&&500>Wn()-WS?xc(e,0):US|=n),_a(e,t)}function KI(e,t){t===0&&(e.mode&1?(t=Zp,Zp<<=1,!(Zp&130023424)&&(Zp=4194304)):t=1);var n=sa();e=to(e,t),e!==null&&(op(e,t,n),_a(e,n))}function FW(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),KI(e,n)}function qW(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(We(314))}r!==null&&r.delete(t),KI(e,n)}var HI;HI=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ba.current)xa=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return xa=!1,kW(e,t,n);xa=!!(e.flags&131072)}else xa=!1,An&&t.flags&1048576&&QR(t,Mx,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;sx(e,t),e=t.pendingProps;var s=vd(t,Hr.current);Yu(t,n),s=IS(null,t,r,e,s,n);var i=LS();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,wa(r)?(i=!0,Ax(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,TS(t),s.updater=Av,t.stateNode=s,s._reactInternals=t,rj(t,r,e,n),t=ij(null,t,r,!0,i,n)):(t.tag=0,An&&i&&SS(t),Jr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(sx(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=BW(r),e=Es(r,e),s){case 0:t=sj(null,t,r,e,n);break e;case 1:t=XE(null,t,r,e,n);break e;case 11:t=YE(null,t,r,e,n);break e;case 14:t=QE(null,t,r,Es(r.type,e),n);break e}throw Error(We(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Es(r,s),sj(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Es(r,s),XE(e,t,r,s,n);case 3:e:{if(PI(t),e===null)throw Error(We(387));r=t.pendingProps,i=t.memoizedState,s=i.element,nI(e,t),Rx(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=jd(Error(We(423)),t),t=JE(e,t,r,n,s);break e}else if(r!==s){s=jd(Error(We(424)),t),t=JE(e,t,r,n,s);break e}else for(Ia=nl(t.stateNode.containerInfo.firstChild),La=t,An=!0,Is=null,n=eI(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(bd(),r===s){t=no(e,t,n);break e}Jr(e,t,r,n)}t=t.child}return t;case 5:return rI(t),e===null&&ej(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,o=s.children,Y_(r,s)?o=null:i!==null&&Y_(r,i)&&(t.flags|=32),EI(e,t),Jr(e,t,o,n),t.child;case 6:return e===null&&ej(t),null;case 13:return OI(e,t,n);case 4:return MS(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=wd(t,null,r,n):Jr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Es(r,s),YE(e,t,r,s,n);case 7:return Jr(e,t,t.pendingProps,n),t.child;case 8:return Jr(e,t,t.pendingProps.children,n),t.child;case 12:return Jr(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,o=s.value,wn(Dx,r._currentValue),r._currentValue=o,i!==null)if(Ks(i.value,o)){if(i.children===s.children&&!ba.current){t=no(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){o=i.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Ki(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),tj(i.return,n,t),l.lanes|=n;break}c=c.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(We(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),tj(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Jr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Yu(t,n),s=ds(s),r=r(s),t.flags|=1,Jr(e,t,r,n),t.child;case 14:return r=t.type,s=Es(r,t.pendingProps),s=Es(r.type,s),QE(e,t,r,s,n);case 15:return CI(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Es(r,s),sx(e,t),t.tag=1,wa(r)?(e=!0,Ax(t)):e=!1,Yu(t,n),jI(t,r,s),rj(t,r,s,n),ij(null,t,r,!0,e,n);case 19:return AI(e,t,n);case 22:return kI(e,t,n)}throw Error(We(156,t.tag))};function GI(e,t){return bR(e,t)}function zW(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.t
vendor: 5,067 bytes, line 40
40ype=this.elementType=null,this.index=0,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 ss(e,t,n,r){return new zW(e,t,n,r)}function VS(e){return e=e.prototype,!(!e||!e.isReactComponent)}function BW(e){if(typeof e=="function")return VS(e)?1:0;if(e!=null){if(e=e.$$typeof,e===fS)return 11;if(e===mS)return 14}return 2}function il(e,t){var n=e.alternate;return n===null?(n=ss(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&14680064,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}function lx(e,t,n,r,s,i){var o=2;if(r=e,typeof e=="function")VS(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Ou:return yc(n.children,s,i,t);case hS:o=8,s|=8;break;case k_:return e=ss(12,n,t,s|2),e.elementType=k_,e.lanes=i,e;case E_:return e=ss(13,n,t,s),e.elementType=E_,e.lanes=i,e;case P_:return e=ss(19,n,t,s),e.elementType=P_,e.lanes=i,e;case rR:return Dv(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case tR:o=10;break e;case nR:o=9;break e;case fS:o=11;break e;case mS:o=14;break e;case Oo:o=16,r=null;break e}throw Error(We(130,e==null?e:typeof e,""))}return t=ss(o,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function yc(e,t,n,r){return e=ss(7,e,r,t),e.lanes=n,e}function Dv(e,t,n,r){return e=ss(22,e,r,t),e.elementType=rR,e.lanes=n,e.stateNode={isHidden:!1},e}function ew(e,t,n){return e=ss(6,e,null,t),e.lanes=n,e}function tw(e,t,n){return t=ss(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function UW(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=$0(0),this.expirationTimes=$0(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$0(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function YS(e,t,n,r,s,i,o,l,c){return e=new UW(e,t,n,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ss(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},TS(i),e}function WW(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Pu,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function VI(e){if(!e)return fl;e=e._reactInternals;e:{if(Wc(e)!==e||e.tag!==1)throw Error(We(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(wa(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(We(171))}if(e.tag===1){var n=e.type;if(wa(n))return VR(e,n,t)}return t}function YI(e,t,n,r,s,i,o,l,c){return e=YS(n,r,!0,e,s,i,o,l,c),e.context=VI(null),n=e.current,r=sa(),s=sl(n),i=Ki(r,s),i.callback=t??null,rl(n,i,s),e.current.lanes=s,op(e,s,r),_a(e,r),e}function $v(e,t,n,r){var s=t.current,i=sa(),o=sl(s);return n=VI(n),t.context===null?t.context=n:t.pendingContext=n,t=Ki(i,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=rl(s,t,o),e!==null&&(Us(e,s,o,i),nx(e,s,o)),o}function Wx(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function lP(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function QS(e,t){lP(e,t),(e=e.alternate)&&lP(e,t)}function KW(){return null}var QI=typeof reportError=="function"?reportError:function(e){console.error(e)};function XS(e){this._internalRoot=e}Rv.prototype.render=XS.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(We(409));$v(e,t,null,null)};Rv.prototype.unmount=XS.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ec(function(){$v(null,e,null,null)}),t[eo]=null}};function Rv(e){this._internalRoot=e}Rv.prototype.unstable_scheduleHydration=function(e){if(e){var t=kR();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Do.length&&t!==0&&t<Do[n].priority;n++);Do.splice(n,0,e),n===0&&PR(e)}};function JS(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Iv(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function cP(){}
vendor: 5,386 bytes, line 40
40function HW(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var u=Wx(o);i.call(u)}}var o=YI(t,r,e,0,null,!1,!1,"",cP);return e._reactRootContainer=o,e[eo]=o.current,Kf(e.nodeType===8?e.parentNode:e),Ec(),o}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var u=Wx(c);l.call(u)}}var c=YS(e,0,!1,null,null,!1,!1,"",cP);return e._reactRootContainer=c,e[eo]=c.current,Kf(e.nodeType===8?e.parentNode:e),Ec(function(){$v(t,c,n,r)}),c}function Lv(e,t,n,r,s){var i=n._reactRootContainer;if(i){var o=i;if(typeof s=="function"){var l=s;s=function(){var c=Wx(o);l.call(c)}}$v(t,o,e,s)}else o=HW(n,t,e,s,r);return Wx(o)}SR=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=cf(t.pendingLanes);n!==0&&(xS(t,n|1),_a(t,Wn()),!(Jt&6)&&(Nd=Wn()+500,_l()))}break;case 13:Ec(function(){var r=to(e,1);if(r!==null){var s=sa();Us(r,e,1,s)}}),QS(e,1)}};yS=function(e){if(e.tag===13){var t=to(e,134217728);if(t!==null){var n=sa();Us(t,e,134217728,n)}QS(e,134217728)}};CR=function(e){if(e.tag===13){var t=sl(e),n=to(e,t);if(n!==null){var r=sa();Us(n,e,t,r)}QS(e,t)}};kR=function(){return un};ER=function(e,t){var n=un;try{return un=e,t()}finally{un=n}};F_=function(e,t,n){switch(t){case"input":if(T_(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var s=Ev(r);if(!s)throw Error(We(90));sR(r),T_(r,s)}}}break;case"textarea":oR(e,n);break;case"select":t=n.value,t!=null&&Ku(e,!!n.multiple,t,!1)}};mR=KS;pR=Ec;var GW={usingClientEntryPoint:!1,Events:[cp,Du,Ev,hR,fR,KS]},Rh={findFiberByHostInstance:Zl,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},VW={bundleType:Rh.bundleType,version:Rh.version,rendererPackageName:Rh.rendererPackageName,rendererConfig:Rh.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:fo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=yR(e),e===null?null:e.stateNode},findFiberByHostInstance:Rh.findFiberByHostInstance||KW,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ug=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ug.isDisabled&&ug.supportsFiber)try{Nv=ug.inject(VW),gi=ug}catch{}}Wa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=GW;Wa.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!JS(t))throw Error(We(200));return WW(e,t,null,n)};Wa.createRoot=function(e,t){if(!JS(e))throw Error(We(299));var n=!1,r="",s=QI;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=YS(e,1,!1,null,null,n,!1,r,s),e[eo]=t.current,Kf(e.nodeType===8?e.parentNode:e),new XS(t)};Wa.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(We(188)):(e=Object.keys(e).join(","),Error(We(268,e)));return e=yR(t),e=e===null?null:e.stateNode,e};Wa.flushSync=function(e){return Ec(e)};Wa.hydrate=function(e,t,n){if(!Iv(t))throw Error(We(200));return Lv(null,e,t,!0,n)};Wa.hydrateRoot=function(e,t,n){if(!JS(e))throw Error(We(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",o=QI;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=YI(t,null,e,1,n??null,s,!1,i,o),e[eo]=t.current,Kf(e),r)for(e=0;e<r.length;e++)n=r[e],s=n._getVersion,s=s(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,s]:t.mutableSourceEagerHydrationData.push(n,s);return new Rv(t)};Wa.render=function(e,t,n){if(!Iv(t))throw Error(We(200));return Lv(null,e,t,!1,n)};Wa.unmountComponentAtNode=function(e){if(!Iv(e))throw Error(We(40));return e._reactRootContainer?(Ec(function(){Lv(null,null,e,!1,function(){e._reactRootContainer=null,e[eo]=null})}),!0):!1};Wa.unstable_batchedUpdates=KS;Wa.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Iv(n))throw Error(We(200));if(e==null||e._reactInternals===void 0)throw Error(We(38));return Lv(e,t,n,!1,r)};Wa.version="18.3.1-next-f1338f8080-20240426";function XI(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(XI)}catch(e){console.error(e)}}XI(),X$.exports=Wa;var Kc=X$.exports;const JI=dn(Kc);var ZI,uP=Kc;ZI=uP.createRoot,uP.hydrateRoot;const YW=1,QW=1e6;let nw=0;function XW(){return nw=(nw+1)%Number.MAX_SAFE_INTEGER,nw.toString()}const rw=new Map,dP=e=>{if(rw.has(e))return;const t=setTimeout(()=>{rw.delete(e),kf({type:"REMOVE_TOAST",toastId:e})},QW);rw.set(e,t)},JW=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,YW)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;
vendor: 13,989 bytes, line 40
40return n?dP(n):e.toasts.forEach(r=>{dP(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},cx=[];let ux={toasts:[]};function kf(e){ux=JW(ux,e),cx.forEach(t=>{t(ux)})}function nc({...e}){const t=XW(),n=s=>kf({type:"UPDATE_TOAST",toast:{...s,id:t}}),r=()=>kf({type:"DISMISS_TOAST",toastId:t});return kf({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:s=>{s||r()}}}),{id:t,dismiss:r,update:n}}function mt(){const[e,t]=y.useState(ux);return y.useEffect(()=>(cx.push(t),()=>{const n=cx.indexOf(t);n>-1&&cx.splice(n,1)}),[e]),{...e,toast:nc,dismiss:n=>kf({type:"DISMISS_TOAST",toastId:n})}}function Fe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}function hP(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ro(...e){return t=>{let n=!1;const r=e.map(s=>{const i=hP(s,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let s=0;s<r.length;s++){const i=r[s];typeof i=="function"?i():hP(e[s],null)}}}}function Ct(...e){return y.useCallback(ro(...e),e)}function ZW(e,t){const n=y.createContext(t),r=i=>{const{children:o,...l}=i,c=y.useMemo(()=>l,Object.values(l));return a.jsx(n.Provider,{value:c,children:o})};r.displayName=e+"Provider";function s(i){const o=y.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[r,s]}function jr(e,t=[]){let n=[];function r(i,o){const l=y.createContext(o),c=n.length;n=[...n,o];const u=h=>{var v;const{scope:m,children:f,...x}=h,g=((v=m==null?void 0:m[e])==null?void 0:v[c])||l,p=y.useMemo(()=>x,Object.values(x));return a.jsx(g.Provider,{value:p,children:f})};u.displayName=i+"Provider";function d(h,m){var g;const f=((g=m==null?void 0:m[e])==null?void 0:g[c])||l,x=y.useContext(f);if(x)return x;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[u,d]}const s=()=>{const i=n.map(o=>y.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return y.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return s.scopeName=e,[r,eK(s,...t)]}function eK(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(i){const o=r.reduce((l,{useScope:c,scopeName:u})=>{const h=c(i)[`__scope${u}`];return{...l,...h}},{});return y.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}function ml(e){const t=nK(e),n=y.forwardRef((r,s)=>{const{children:i,...o}=r,l=y.Children.toArray(i),c=l.find(rK);if(c){const u=c.props.children,d=l.map(h=>h===c?y.Children.count(u)>1?y.Children.only(null):y.isValidElement(u)?u.props.children:null:h);return a.jsx(t,{...o,ref:s,children:y.isValidElement(u)?y.cloneElement(u,void 0,d):null})}return a.jsx(t,{...o,ref:s,children:i})});return n.displayName=`${e}.Slot`,n}var tK=ml("Slot");function nK(e){const t=y.forwardRef((n,r)=>{const{children:s,...i}=n;if(y.isValidElement(s)){const o=sK(s),l=aK(i,s.props);return s.type!==y.Fragment&&(l.ref=r?ro(r,o):o),y.cloneElement(s,l)}return y.Children.count(s)>1?y.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var e3=Symbol("radix.slottable");function t3(e){const t=({children:n})=>a.jsx(a.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=e3,t}function rK(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===e3}function aK(e,t){const n={...t};for(const r in t){const s=e[r],i=t[r];/^on[A-Z]/.test(r)?s&&i?n[r]=(...l)=>{const c=i(...l);return s(...l),c}:s&&(n[r]=s):r==="style"?n[r]={...s,...i}:r==="className"&&(n[r]=[s,i].filter(Boolean).join(" "))}return{...e,...n}}function sK(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function dp(e){const t=e+"CollectionProvider",[n,r]=jr(t),[s,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=g=>{const{scope:p,children:v}=g,b=ae.useRef(null),w=ae.useRef(new Map).current;return a.jsx(s,{scope:p,itemMap:w,collectionRef:b,children:v})};o.displayName=t;const l=e+"CollectionSlot",c=ml(l),u=ae.forwardRef((g,p)=>{const{scope:v,children:b}=g,w=i(l,v),N=Ct(p,w.collectionRef);return a.jsx(c,{ref:N,children:b})});u.displayName=l;const d=e+"CollectionItemSlot",h="data-radix-collection-item",m=ml(d),f=ae.forwardRef((g,p)=>{const{scope:v,children:b,...w}=g,N=ae.useRef(null),j=Ct(p,N),_=i(d,v);return ae.useEffect(()=>(_.itemMap.set(N,{ref:N,...w}),()=>void _.itemMap.delete(N))),a.jsx(m,{[h]:"",ref:j,children:b})});f.displayName=d;function x(g){const p=i(e+"CollectionConsumer",g);return ae.useCallback(()=>{const b=p.collectionRef.current;if(!b)return[];const w=Array.from(b.querySelectorAll(`[${h}]`));return Array.from(p.itemMap.values()).sort((_,S)=>w.indexOf(_.ref.current)-w.indexOf(S.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:o,Slot:u,ItemSlot:f},x,r]}var iK=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],tt=iK.reduce((e,t)=>{const n=ml(`Primitive.${t}`),r=y.forwardRef((s,i)=>{const{asChild:o,...l}=s,c=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),a.jsx(c,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ZS(e,t){e&&Kc.flushSync(()=>e.dispatchEvent(t))}function Kn(e){const t=y.useRef(e);return y.useEffect(()=>{t.current=e}),y.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function oK(e,t=globalThis==null?void 0:globalThis.document){const n=Kn(e);y.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var lK="DismissableLayer",yj="dismissableLayer.update",cK="dismissableLayer.pointerDownOutside",uK="dismissableLayer.focusOutside",fP,n3=y.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),jl=y.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...c}=e,u=y.useContext(n3),[d,h]=y.useState(null),m=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=y.useState({}),x=Ct(t,S=>h(S)),g=Array.from(u.layers),[p]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(p),b=d?g.indexOf(d):-1,w=u.layersWithOutsidePointerEventsDisabled.size>0,N=b>=v,j=hK(S=>{const P=S.target,k=[...u.branches].some(C=>C.contains(P));!N||k||(s==null||s(S),o==null||o(S),S.defaultPrevented||l==null||l())},m),_=fK(S=>{const P=S.target;[...u.branches].some(C=>C.contains(P))||(i==null||i(S),o==null||o(S),S.defaultPrevented||l==null||l())},m);return oK(S=>{b===u.layers.size-1&&(r==null||r(S),!S.defaultPrevented&&l&&(S.preventDefault(),l()))},m),y.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(fP=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),mP(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=fP)}},[d,m,n,u]),y.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),mP())},[d,u]),y.useEffect(()=>{const S=()=>f({});return document.addEventListener(yj,S),()=>document.removeEventListener(yj,S)},[]),a.jsx(tt.div,{...c,ref:x,style:{pointerEvents:w?N?"auto":"none":void 0,...e.style},onFocusCapture:Fe(e.onFocusCapture,_.onFocusCapture),onBlurCapture:Fe(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Fe(e.onPointerDownCapture,j.onPointerDownCapture)})});jl.displayName=lK;var dK="DismissableLayerBranch",r3=y.forwardRef((e,t)=>{const n=y.useContext(n3),r=y.useRef(null),s=Ct(t,r);return y.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),a.jsx(tt.div,{...e,ref:s})});r3.displayName=dK;function hK(e,t=globalThis==null?void 0:globalThis.document){const n=Kn(e),r=y.useRef(!1),s=y.useRef(()=>{});return y.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let c=function(){a3(cK,n,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=c,t.addEventListener("click",s.current,{once:!0})):c()}else t.removeEventListener("click",s.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",i),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function fK(e,t=globalThis==null?void 0:globalThis.document){const n=Kn(e),r=y.useRef(!1);return y.useEffect(()=>{const s=i=>{i.target&&!r.current&&a3(uK,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function mP(){const e=new CustomEvent(yj);document.dispatchEvent(e)}function a3(e,t,n,{discrete:r}){const s=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?ZS(s,i):s.dispatchEvent(i)}var mK=jl,pK=r3,dr=globalThis!=null&&globalThis.document?y.useLayoutEffect:()=>{},gK="Portal",th=y.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[s,i]=y.useState(!1);dr(()=>i(!0),[]);const o=n||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return o?JI.createPortal(a.jsx(tt.div,{...r,ref:t}),o):null});th.displayName=gK;function xK(e,t){return y.useReducer((n,r)=>t[n][r]??n,e)}var tr=e=>{const{present:t,children:n}=e,r=yK(t),s=typeof n=="function"?n({present:r.isPresent}):y.Children.only(n),i=Ct(r.ref,vK(s));return typeof n=="function"||r.isPresent?y.cloneElement(s,{ref:i}):null};tr.displayName="Presence";function yK(e){const[t,n]=y.useState(),r=y.useRef(null),s=y.useRef(e),i=y.useRef("none"),o=e?"mounted":"unmounted",[l,c]=xK(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return y.useEffect(()=>{const u=dg(r.current);i.current=l==="mounted"?u:"none"},[l]),dr(()=>{const u=r.current,d=s.current;if(d!==e){const m=i.current,f=dg(u);e?c("MOUNT"):f==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&m!==f?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,c]),dr(()=>{if(t){let u;const d=t.ownerDocument.defaultView??window,h=f=>{const g=dg(r.current).includes(f.animationName);if(f.target===t&&g&&(c("ANIMATION_END"),!s.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",u=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)})}},m=f=>{f.target===t&&(i.current=dg(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{d.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:y.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function dg(e){return(e==null?void 0:e.animationName)||"none"}function vK(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var bK=lS[" useInsertionEffect ".trim().toString()]||dr;function oa({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,i,o]=wK({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:s;{const d=y.useRef(e!==void 0);y.useEffect(()=>{const h=d.current;h!==l&&console.warn(`${r} is changing from ${h?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=l},[l,r])}const u=y.useCallback(d=>{var h;if(l){const m=_K(d)?d(e):d;m!==e&&((h=o.current)==null||h.call(o,m))}else i(d)},[l,e,i,o]);return[c,u]}function wK({defaultProp:e,onChange:t}){const[n,r]=y.useState(e),s=y.useRef(n),i=y.useRef(t);return bK(()=>{i.current=t},[t]),y.useEffect(()=>{var o;s.current!==n&&((o=i.current)==null||o.call(i,n),s.current=n)},[n,s]),[n,r,i]}function _K(e){return typeof e=="function"}var s3=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),jK="VisuallyHidden",Fv=y.forwardRef((e,t)=>a.jsx(tt.span,{...e,ref:t,style:{...s3,...e.style}}));Fv.displayName=jK;var NK=Fv,eC="ToastProvider",[tC,SK,CK]=dp("Toast"),[i3,u3e]=jr("Toast",[CK]),[kK,qv]=i3(eC),o3=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:s="right",swipeThreshold:i=50,children:o}=e,[l,c]=y.useState(null),[u,d]=y.useState(0),h=y.useRef(!1),m=y.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${eC}\`. Expected non-empty \`string\`.`),a.jsx(tC.Provider,{scope:t,children:a.jsx(kK,{scope:t,label:n,duration:r,swipeDirection:s,swipeThreshold:i,toastCount:u,viewport:l,onViewportChange:c,onToastAdd:y.useCallback(()=>d(f=>f+1),[]),onToastRemove:y.useCallback(()=>d(f=>f-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:m,children:o})})};o3.displayName=eC;var l3="ToastViewport",EK=["F8"],vj="toast.viewportPause",bj="toast.viewportResume",c3=y.forwardRef((e,t)=>
40{const{__scopeToast:n,hotkey:r=EK,label:s="Notifications ({hotkey})",...i}=e,o=qv(l3,n),l=SK(n),c=y.useRef(null),u=y.useRef(null),d=y.useRef(null),h=y.useRef(null),m=Ct(t,h,o.onViewportChange),f=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),x=o.toastCount>0;y.useEffect(()=>{const p=v=>{var w;r.length!==0&&r.every(N=>v[N]||v.code===N)&&((w=h.current)==null||w.focus())};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[r]),y.useEffect(()=>{const p=c.current,v=h.current;if(x&&p&&v){const b=()=>{if(!o.isClosePausedRef.current){const _=new CustomEvent(vj);v.dispatchEvent(_),o.isClosePausedRef.current=!0}},w=()=>{if(o.isClosePausedRef.current){const _=new CustomEvent(bj);v.dispatchEvent(_),o.isClosePausedRef.current=!1}},N=_=>{!p.contains(_.relatedTarget)&&w()},j=()=>{p.contains(document.activeElement)||w()};return p.addEventListener("focusin",b),p.addEventListener("focusout",N),p.addEventListener("pointermove",b),p.addEventListener("pointerleave",j),window.addEventListener("blur",b),window.addEventListener("focus",w),()=>{p.removeEventListener("focusin",b),p.removeEventListener("focusout",N),p.removeEventListener("pointermove",b),p.removeEventListener("pointerleave",j),window.removeEventListener("blur",b),window.removeEventListener("focus",w)}}},[x,o.isClosePausedRef]);const g=y.useCallback(({tabbingDirection:p})=>{const b=l().map(w=>{const N=w.ref.current,j=[N,...zK(N)];return p==="forwards"?j:j.reverse()});return(p==="forwards"?b.reverse():b).flat()},[l]);return y.useEffect(()=>{const p=h.current;if(p){const v=b=>{var j,_,S;const w=b.altKey||b.ctrlKey||b.metaKey;if(b.key==="Tab"&&!w){const P=document.activeElement,k=b.shiftKey;if(b.target===p&&k){(j=u.current)==null||j.focus();return}const O=g({tabbingDirection:k?"backwards":"forwards"}),L=O.findIndex(E=>E===P);aw(O.slice(L+1))?b.preventDefault():k?(_=u.current)==null||_.focus():(S=d.current)==null||S.focus()}};return p.addEventListener("keydown",v),()=>p.removeEventListener("keydown",v)}},[l,g]),a.jsxs(pK,{ref:c,role:"region","aria-label":s.replace("{hotkey}",f),tabIndex:-1,style:{pointerEvents:x?void 0:"none"},children:[x&&a.jsx(wj,{ref:u,onFocusFromOutsideViewport:()=>{const p=g({tabbingDirection:"forwards"});aw(p)}}),a.jsx(tC.Slot,{scope:n,children:a.jsx(tt.ol,{tabIndex:-1,...i,ref:m})}),x&&a.jsx(wj,{ref:d,onFocusFromOutsideViewport:()=>{const p=g({tabbingDirection:"backwards"});aw(p)}})]})});c3.displayName=l3;var u3="ToastFocusProxy",wj=y.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...s}=e,i=qv(u3,n);return a.jsx(Fv,{"aria-hidden":!0,tabIndex:0,...s,ref:t,style:{position:"fixed"},onFocus:o=>{var u;const l=o.relatedTarget;!((u=i.viewport)!=null&&u.contains(l))&&r()}})});wj.displayName=u3;var hp="Toast",PK="toast.swipeStart",OK="toast.swipeMove",AK="toast.swipeCancel",TK="toast.swipeEnd",d3=y.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:s,onOpenChange:i,...o}=e,[l,c]=oa({prop:r,defaultProp:s??!0,onChange:i,caller:hp});return a.jsx(tr,{present:n||l,children:a.jsx($K,{open:l,...o,ref:t,onClose:()=>c(!1),onPause:Kn(e.onPause),onResume:Kn(e.onResume),onSwipeStart:Fe(e.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Fe(e.onSwipeMove,u=>{const{x:d,y:h}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:Fe(e.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Fe(e.onSwipeEnd,u=>{const{x:d,y:h}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),c(!1)})})})});d3.displayName=hp;var[MK,DK]=i3(hp,{onClose(){}}),$K=y.forwardRef((e,t)=>
40{const{__scopeToast:n,type:r="foreground",duration:s,open:i,onClose:o,onEscapeKeyDown:l,onPause:c,onResume:u,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:m,onSwipeEnd:f,...x}=e,g=qv(hp,n),[p,v]=y.useState(null),b=Ct(t,E=>v(E)),w=y.useRef(null),N=y.useRef(null),j=s||g.duration,_=y.useRef(0),S=y.useRef(j),P=y.useRef(0),{onToastAdd:k,onToastRemove:C}=g,T=Kn(()=>{var R;(p==null?void 0:p.contains(document.activeElement))&&((R=g.viewport)==null||R.focus()),o()}),O=y.useCallback(E=>{!E||E===1/0||(window.clearTimeout(P.current),_.current=new Date().getTime(),P.current=window.setTimeout(T,E))},[T]);y.useEffect(()=>{const E=g.viewport;if(E){const R=()=>{O(S.current),u==null||u()},q=()=>{const I=new Date().getTime()-_.current;S.current=S.current-I,window.clearTimeout(P.current),c==null||c()};return E.addEventListener(vj,q),E.addEventListener(bj,R),()=>{E.removeEventListener(vj,q),E.removeEventListener(bj,R)}}},[g.viewport,j,c,u,O]),y.useEffect(()=>{i&&!g.isClosePausedRef.current&&O(j)},[i,j,g.isClosePausedRef,O]),y.useEffect(()=>(k(),()=>C()),[k,C]);const L=y.useMemo(()=>p?y3(p):null,[p]);return g.viewport?a.jsxs(a.Fragment,{children:[L&&a.jsx(RK,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:L}),a.jsx(MK,{scope:n,onClose:T,children:Kc.createPortal(a.jsx(tC.ItemSlot,{scope:n,children:a.jsx(mK,{asChild:!0,onEscapeKeyDown:Fe(l,()=>{g.isFocusedToastEscapeKeyDownRef.current||T(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:a.jsx(tt.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":g.swipeDirection,...x,ref:b,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:Fe(e.onKeyDown,E=>{E.key==="Escape"&&(l==null||l(E.nativeEvent),E.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,T()))}),onPointerDown:Fe(e.onPointerDown,E=>{E.button===0&&(w.current={x:E.clientX,y:E.clientY})}),onPointerMove:Fe(e.onPointerMove,E=>{if(!w.current)return;const R=E.clientX-w.current.x,q=E.clientY-w.current.y,I=!!N.current,$=["left","right"].includes(g.swipeDirection),M=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,B=$?M(0,R):0,W=$?0:M(0,q),A=E.pointerType==="touch"?10:2,K={x:B,y:W},G={originalEvent:E,delta:K};I?(N.current=K,hg(OK,h,G,{discrete:!1})):pP(K,g.swipeDirection,A)?(N.current=K,hg(PK,d,G,{discrete:!1}),E.target.setPointerCapture(E.pointerId)):(Math.abs(R)>A||Math.abs(q)>A)&&(w.current=null)}),onPointerUp:Fe(e.onPointerUp,E=>{const R=N.current,q=E.target;if(q.hasPointerCapture(E.pointerId)&&q.releasePointerCapture(E.pointerId),N.current=null,w.current=null,R){const I=E.currentTarget,$={originalEvent:E,delta:R};pP(R,g.swipeDirection,g.swipeThreshold)?hg(TK,f,$,{discrete:!0}):hg(AK,m,$,{discrete:!0}),I.addEventListener("click",M=>M.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),RK=e=>{const{__scopeToast:t,children:n,...r}=e,s=qv(hp,t),[i,o]=y.useState(!1),[l,c]=y.useState(!1);return FK(()=>o(!0)),y.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),l?null:a.jsx(th,{asChild:!0,children:a.jsx(Fv,{...r,children:i&&a.jsxs(a.Fragment,{children:[s.label," ",n]})})})},IK="ToastTitle",h3=y.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return a.jsx(tt.div,{...r,ref:t})});h3.displayName=IK;var LK="ToastDescription",f3=y.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return a.jsx(tt.div,{...r,ref:t})});f3.displayName=LK;var m3="ToastAction",p3=y.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?a.jsx(x3,{altText:n,asChild:!0,children:a.jsx(nC,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${m3}\`. Expected non-empty \`string\`.`),null)});p3.displayName=m3;var g3="ToastClose",nC=y.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,s=DK(g3,n);return a.jsx(x3,{asChild:!0,children:a.jsx(tt.button,{type:"button",...r,ref:t,onClick:Fe(e.onClick,s.onClose)})})});nC.displayName=g3;var x3=y.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...s}=e;return a.jsx(tt.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...s,ref:t})});function y3(e){const t=[];
vendor: 6,316 bytes, lines 40-95
40return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),qK(r)){const s=r.ariaHidden||r.hidden||r.style.display==="none",i=r.dataset.radixToastAnnounceExclude==="";if(!s)if(i){const o=r.dataset.radixToastAnnounceAlt;o&&t.push(o)}else t.push(...y3(r))}}),t}function hg(e,t,n,{discrete:r}){const s=n.originalEvent.currentTarget,i=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?ZS(s,i):s.dispatchEvent(i)}var pP=(e,t,n=0)=>{const r=Math.abs(e.x),s=Math.abs(e.y),i=r>s;return t==="left"||t==="right"?i&&r>n:!i&&s>n};function FK(e=()=>{}){const t=Kn(e);dr(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function qK(e){return e.nodeType===e.ELEMENT_NODE}function zK(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function aw(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var BK=o3,v3=c3,b3=d3,w3=h3,_3=f3,j3=p3,N3=nC;function S3(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=S3(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Qt(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=S3(e))&&(r&&(r+=" "),r+=t);return r}const gP=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,xP=Qt,nh=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return xP(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:i}=t,o=Object.keys(s).map(u=>{const d=n==null?void 0:n[u],h=i==null?void 0:i[u];if(d===null)return null;const m=gP(d)||gP(h);return s[u][m]}),l=n&&Object.entries(n).reduce((u,d)=>{let[h,m]=d;return m===void 0||(u[h]=m),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:h,className:m,...f}=d;return Object.entries(f).every(x=>{let[g,p]=x;return Array.isArray(p)?p.includes({...i,...l}[g]):{...i,...l}[g]===p})?[...u,h,m]:u},[]);return xP(e,o,c,n==null?void 0:n.class,n==null?void 0:n.className)};/** 41 * @license lucide-react v0.462.0 - ISC 42 * 43 * This source code is licensed under the ISC license. 44 * See the LICENSE file in the root directory of this source tree. 45 */const UK=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),C3=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/** 46 * @license lucide-react v0.462.0 - ISC 47 * 48 * This source code is licensed under the ISC license. 49 * See the LICENSE file in the root directory of this source tree. 50 */var WK={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** 51 * @license lucide-react v0.462.0 - ISC 52 * 53 * This source code is licensed under the ISC license. 54 * See the LICENSE file in the root directory of this source tree. 55 */const KK=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:i,iconNode:o,...l},c)=>y.createElement("svg",{ref:c,...WK,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:C3("lucide",s),...l},[...o.map(([u,d])=>y.createElement(u,d)),...Array.isArray(i)?i:[i]]));/** 56 * @license lucide-react v0.462.0 - ISC 57 * 58 * This source code is licensed under the ISC license. 59 * See the LICENSE file in the root directory of this source tree. 60 */const Re=(e,t)=>{const n=y.forwardRef(({className:r,...s},i)=>y.createElement(KK,{ref:i,iconNode:t,className:C3(`lucide-${UK(e)}`,r),...s}));return n.displayName=`${e}`,n};/** 61 * @license lucide-react v0.462.0 - ISC 62 * 63 * This source code is licensed under the ISC license. 64 * See the LICENSE file in the root directory of this source tree. 65 */const HK=Re("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** 66 * @license lucide-react v0.462.0 - ISC 67 * 68 * This source code is licensed under the ISC license. 69 * See the LICENSE file in the root directory of this source tree. 70 */const k3=Re("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** 71 * @license lucide-react v0.462.0 - ISC 72 * 73 * This source code is licensed under the ISC license. 74 * See the LICENSE file in the root directory of this source tree. 75 */const GK=Re("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/** 76 * @license lucide-react v0.462.0 - ISC 77 * 78 * This source code is licensed under the ISC license. 79 * See the LICENSE file in the root directory of this source tree. 80 */const yP=Re("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** 81 * @license lucide-react v0.462.0 - ISC 82 * 83 * This source code is licensed under the ISC license. 84 * See the LICENSE file in the root directory of this source tree. 85 */const VK=Re("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** 86 * @license lucide-react v0.462.0 - ISC 87 * 88 * This source code is licensed under the ISC license. 89 * See the LICENSE file in the root directory of this source tree. 90 */const E3=Re("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** 91 * @license lucide-react v0.462.0 - ISC 92 * 93 * This source code is licensed under the ISC license. 94 * See the LICENSE file in the root directory of this source tree. 95 */const rC=Re("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}
95],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** 96 * @license lucide-react v0.462.0 - ISC 97 * 98 * This source code is licensed under the ISC license. 99 * See the LICENSE file in the root directory of this source tree. 100 */const YK=Re("Cake",[["path",{d:"M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8",key:"1w3rig"}],["path",{d:"M4 16s.5-1 2-1 2.5 2 4 2 2.5-2 4-2 2.5 2 4 2 2-1 2-1",key:"n2jgmb"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M7 8v3",key:"1qtyvj"}],["path",{d:"M12 8v3",key:"hwp4zt"}],["path",{d:"M17 8v3",key:"1i6e5u"}],["path",{d:"M7 4h.01",key:"1bh4kh"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M17 4h.01",key:"1upcoc"}]]);/** 101 * @license lucide-react v0.462.0 - ISC 102 * 103 * This source code is licensed under the ISC license. 104 * See the LICENSE file in the root directory of this source tree. 105 */const _j=Re("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"}]]);/** 106 * @license lucide-react v0.462.0 - ISC 107 * 108 * This source code is licensed under the ISC license. 109 * See the LICENSE file in the root directory of this source tree. 110 */const Kx=Re("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/** 111 * @license lucide-react v0.462.0 - ISC 112 * 113 * This source code is licensed under the ISC license. 114 * See the LICENSE file in the root directory of this source tree. 115 */const jj=Re("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);/** 116 * @license lucide-react v0.462.0 - ISC 117 * 118 * This source code is licensed under the ISC license. 119 * See the LICENSE file in the root directory of this source tree. 120 */const rs=Re("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"}]]);/** 121 * @license lucide-react v0.462.0 - ISC 122 * 123 * This source code is licensed under the ISC license. 124 * See the LICENSE file in the root directory of this source tree. 125 */const On=Re("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** 126 * @license lucide-react v0.462.0 - ISC 127 * 128 * This source code is licensed under the ISC license. 129 * See the LICENSE file in the root directory of this source tree. 130 */const _n=Re("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** 131 * @license lucide-react v0.462.0 - ISC 132 * 133 * This source code is licensed under the ISC license. 134 * See the LICENSE file in the root directory of this source tree. 135 */const P3=Re("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** 136 * @license lucide-react v0.462.0 - ISC 137 * 138 * This source code is licensed under the ISC license. 139 * See the LICENSE file in the root directory of this source tree. 140 */const fp=Re("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** 141 * @license lucide-react v0.462.0 - ISC 142 * 143 * This source code is licensed under the ISC license. 144 * See the LICENSE file in the root directory of this source tree. 145 */const _r=Re("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** 146 * @license lucide-react v0.462.0 - ISC 147 * 148 * This source code is licensed under the ISC license. 149 * See the LICENSE file in the root directory of this source tree. 150 */const O3=Re("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** 151 * @license lucide-react v0.462.0 - ISC 152 * 153 * This source code is licensed under the ISC license. 154 * See the LICENSE file in the root directory of this source tree. 155 */const QK=Re("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** 156 * @license lucide-react v0.462.0 - ISC 157 * 158 * This source code is licensed under the ISC license. 159 * See the LICENSE file in the root directory of this source tree. 160 */const XK=Re("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** 161 * @license lucide-react v0.462.0 - ISC 162 * 163 * This source code is licensed under the ISC license. 164 * See the LICENSE file in the root directory of this source tree. 165 */const Mr=Re("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 166 * @license lucide-react v0.462.0 - ISC 167 * 168 * This source code is licensed under the ISC license. 169 * See the LICENSE file in the root directory of this source tree. 170 */const JK=Re("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** 171 * @license lucide-react v0.462.0 - ISC 172 * 173 * This source code is licensed under the ISC license. 174 * See the LICENSE file in the root directory of this source tree. 175 */const A3=Re("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** 176 * @license lucide-react v0.462.0 - ISC 177 * 178 * This source code is licensed under the ISC license. 179 * See the LICENSE file in the root directory of this source tree. 180 */const T3=Re("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** 181 * @license lucide-react v0.462.0 - ISC 182 * 183 * This source code is licensed under the ISC license. 184 * See the LICENSE file in the root directory of this source tree.
185 */const ZK=Re("ClipboardCheck",[["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:"m9 14 2 2 4-4",key:"df797q"}]]);/** 186 * @license lucide-react v0.462.0 - ISC 187 * 188 * This source code is licensed under the ISC license. 189 * See the LICENSE file in the root directory of this source tree. 190 */const em=Re("ClipboardList",[["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"}]]);/** 191 * @license lucide-react v0.462.0 - ISC 192 * 193 * This source code is licensed under the ISC license. 194 * See the LICENSE file in the root directory of this source tree. 195 */const pl=Re("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** 196 * @license lucide-react v0.462.0 - ISC 197 * 198 * This source code is licensed under the ISC license. 199 * See the LICENSE file in the root directory of this source tree. 200 */const aC=Re("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** 201 * @license lucide-react v0.462.0 - ISC 202 * 203 * This source code is licensed under the ISC license. 204 * See the LICENSE file in the root directory of this source tree. 205 */const zv=Re("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"}]]);/** 206 * @license lucide-react v0.462.0 - ISC 207 * 208 * This source code is licensed under the ISC license. 209 * See the LICENSE file in the root directory of this source tree. 210 */const pa=Re("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** 211 * @license lucide-react v0.462.0 - ISC 212 * 213 * This source code is licensed under the ISC license. 214 * See the LICENSE file in the root directory of this source tree. 215 */const Hi=Re("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** 216 * @license lucide-react v0.462.0 - ISC 217 * 218 * This source code is licensed under the ISC license. 219 * See the LICENSE file in the root directory of this source tree. 220 */const ja=Re("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** 221 * @license lucide-react v0.462.0 - ISC 222 * 223 * This source code is licensed under the ISC license. 224 * See the LICENSE file in the root directory of this source tree. 225 */const eH=Re("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** 226 * @license lucide-react v0.462.0 - ISC 227 * 228 * This source code is licensed under the ISC license. 229 * See the LICENSE file in the root directory of this source tree. 230 */const M3=Re("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** 231 * @license lucide-react v0.462.0 - ISC 232 * 233 * This source code is licensed under the ISC license. 234 * See the LICENSE file in the root directory of this source tree. 235 */const D3=Re("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"}]]);/** 236 * @license lucide-react v0.462.0 - ISC 237 * 238 * This source code is licensed under the ISC license. 239 * See the LICENSE file in the root directory of this source tree. 240 */const $3=Re("FileChartColumnIncreasing",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]]);/** 241 * @license lucide-react v0.462.0 - ISC 242 * 243 * This source code is licensed under the ISC license. 244 * See the LICENSE file in the root directory of this source tree. 245 */const tH=Re("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** 246 * @license lucide-react v0.462.0 - ISC 247 * 248 * This source code is licensed under the ISC license. 249 * See the LICENSE file in the root directory of this source tree. 250 */const Hs=Re("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** 251 * @license lucide-react v0.462.0 - ISC 252 * 253 * This source code is licensed under the ISC license. 254 * See the LICENSE file in the root directory of this source tree. 255 */const nH=Re("FileUp",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/** 256 * @license lucide-react v0.462.0 - ISC 257 * 258 * This source code is licensed under the ISC license. 259 * See the LICENSE file in the root directory of this source tree. 260 */const R3=Re("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** 261 * @license lucide-react v0.462.0 - ISC 262 * 263 * This source code is licensed under the ISC license. 264 * See the LICENSE file in the root directory of this source tree. 265 */const rH=Re("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** 266 * @license lucide-react v0.462.0 - ISC 267 * 268 * This source code is licensed under the ISC license. 269 * See the LICENSE file in the root directory of this source tree. 270 */const vP=Re("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"}]]);/** 271 * @license lucide-react v0.462.0 - ISC 272 * 273 * This source code is licensed under the ISC license. 274 * See the LICENSE file in the root directory of this source tree. 275 */const sC=Re("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** 276 * @license lucide-react v0.462.0 - ISC 277 * 278 * This source code is licensed under the ISC license. 279 * See the LICENSE file in the root directory of this source tree. 280 */const iC=Re("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** 281 * @license lucide-react v0.462.0 - ISC 282 * 283 * This source code is licensed under the ISC license. 284 * See the LICENSE file in the root directory of this source tree. 285 */const aH=Re("HandHelping",[["path",{d:"M11 12h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 14",key:"1j4xps"}],["path",{d:"m7 18 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"uospg8"}],["path",{d:"m2 13 6 6",key:"16e5sb"}]]);/** 286 * @license lucide-react v0.462.0 - ISC 287 * 288 * This source code is licensed under the ISC license. 289 * See the LICENSE file in the root directory of this source tree. 290 */const oC=Re("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** 291 * @license lucide-react v0.462.0 - ISC 292 * 293 * This source code is licensed under the ISC license. 294 * See the LICENSE file in the root directory of this source tree. 295 */const tm=Re("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** 296 * @license lucide-react v0.462.0 - ISC 297 * 298 * This source code is licensed under the ISC license. 299 * See the LICENSE file in the root directory of this source tree. 300 */const sH=Re("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/** 301 * @license lucide-react v0.462.0 - ISC 302 * 303 * This source code is licensed under the ISC license. 304 * See the LICENSE file in the root directory of this source tree.
305 */const Nl=Re("Link2",[["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"}]]);/** 306 * @license lucide-react v0.462.0 - ISC 307 * 308 * This source code is licensed under the ISC license. 309 * See the LICENSE file in the root directory of this source tree. 310 */const iH=Re("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/** 311 * @license lucide-react v0.462.0 - ISC 312 * 313 * This source code is licensed under the ISC license. 314 * See the LICENSE file in the root directory of this source tree. 315 */const I3=Re("ListPlus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** 316 * @license lucide-react v0.462.0 - ISC 317 * 318 * This source code is licensed under the ISC license. 319 * See the LICENSE file in the root directory of this source tree. 320 */const oH=Re("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** 321 * @license lucide-react v0.462.0 - ISC 322 * 323 * This source code is licensed under the ISC license. 324 * See the LICENSE file in the root directory of this source tree. 325 */const vt=Re("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** 326 * @license lucide-react v0.462.0 - ISC 327 * 328 * This source code is licensed under the ISC license. 329 * See the LICENSE file in the root directory of this source tree. 330 */const lH=Re("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"}]]);/** 331 * @license lucide-react v0.462.0 - ISC 332 * 333 * This source code is licensed under the ISC license. 334 * See the LICENSE file in the root directory of this source tree. 335 */const cH=Re("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** 336 * @license lucide-react v0.462.0 - ISC 337 * 338 * This source code is licensed under the ISC license. 339 * See the LICENSE file in the root directory of this source tree. 340 */const fs=Re("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** 341 * @license lucide-react v0.462.0 - ISC 342 * 343 * This source code is licensed under the ISC license. 344 * See the LICENSE file in the root directory of this source tree. 345 */const zi=Re("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** 346 * @license lucide-react v0.462.0 - ISC 347 * 348 * This source code is licensed under the ISC license. 349 * See the LICENSE file in the root directory of this source tree. 350 */const uH=Re("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"}]]);/** 351 * @license lucide-react v0.462.0 - ISC 352 * 353 * This source code is licensed under the ISC license. 354 * See the LICENSE file in the root directory of this source tree. 355 */const dH=Re("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);/** 356 * @license lucide-react v0.462.0 - ISC 357 * 358 * This source code is licensed under the ISC license. 359 * See the LICENSE file in the root directory of this source tree. 360 */const hH=Re("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** 361 * @license lucide-react v0.462.0 - ISC 362 * 363 * This source code is licensed under the ISC license. 364 * See the LICENSE file in the root directory of this source tree. 365 */const L3=Re("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** 366 * @license lucide-react v0.462.0 - ISC 367 * 368 * This source code is licensed under the ISC license. 369 * See the LICENSE file in the root directory of this source tree. 370 */const Nj=Re("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** 371 * @license lucide-react v0.462.0 - ISC 372 * 373 * This source code is licensed under the ISC license. 374 * See the LICENSE file in the root directory of this source tree. 375 */const vc=Re("Mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]);/** 376 * @license lucide-react v0.462.0 - ISC 377 * 378 * This source code is licensed under the ISC license. 379 * See the LICENSE file in the root directory of this source tree. 380 */const F3=Re("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}
380],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/** 381 * @license lucide-react v0.462.0 - ISC 382 * 383 * This source code is licensed under the ISC license. 384 * See the LICENSE file in the root directory of this source tree. 385 */const q3=Re("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/** 386 * @license lucide-react v0.462.0 - ISC 387 * 388 * This source code is licensed under the ISC license. 389 * See the LICENSE file in the root directory of this source tree. 390 */const fH=Re("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** 391 * @license lucide-react v0.462.0 - ISC 392 * 393 * This source code is licensed under the ISC license. 394 * See the LICENSE file in the root directory of this source tree. 395 */const Rn=Re("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"}]]);/** 396 * @license lucide-react v0.462.0 - ISC 397 * 398 * This source code is licensed under the ISC license. 399 * See the LICENSE file in the root directory of this source tree. 400 */const mH=Re("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"}]]);/** 401 * @license lucide-react v0.462.0 - ISC 402 * 403 * This source code is licensed under the ISC license. 404 * See the LICENSE file in the root directory of this source tree. 405 */const lC=Re("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** 406 * @license lucide-react v0.462.0 - ISC 407 * 408 * This source code is licensed under the ISC license. 409 * See the LICENSE file in the root directory of this source tree. 410 */const zt=Re("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** 411 * @license lucide-react v0.462.0 - ISC 412 * 413 * This source code is licensed under the ISC license. 414 * See the LICENSE file in the root directory of this source tree. 415 */const Hx=Re("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** 416 * @license lucide-react v0.462.0 - ISC 417 * 418 * This source code is licensed under the ISC license. 419 * See the LICENSE file in the root directory of this source tree. 420 */const pH=Re("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** 421 * @license lucide-react v0.462.0 - ISC 422 * 423 * This source code is licensed under the ISC license. 424 * See the LICENSE file in the root directory of this source tree. 425 */const z3=Re("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"}]]);/** 426 * @license lucide-react v0.462.0 - ISC 427 * 428 * This source code is licensed under the ISC license. 429 * See the LICENSE file in the root directory of this source tree. 430 */const B3=Re("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}
430],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/** 431 * @license lucide-react v0.462.0 - ISC 432 * 433 * This source code is licensed under the ISC license. 434 * See the LICENSE file in the root directory of this source tree. 435 */const U3=Re("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** 436 * @license lucide-react v0.462.0 - ISC 437 * 438 * This source code is licensed under the ISC license. 439 * See the LICENSE file in the root directory of this source tree. 440 */const Bv=Re("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** 441 * @license lucide-react v0.462.0 - ISC 442 * 443 * This source code is licensed under the ISC license. 444 * See the LICENSE file in the root directory of this source tree. 445 */const cC=Re("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"}]]);/** 446 * @license lucide-react v0.462.0 - ISC 447 * 448 * This source code is licensed under the ISC license. 449 * See the LICENSE file in the root directory of this source tree. 450 */const gH=Re("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** 451 * @license lucide-react v0.462.0 - ISC 452 * 453 * This source code is licensed under the ISC license. 454 * See the LICENSE file in the root directory of this source tree. 455 */const xH=Re("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** 456 * @license lucide-react v0.462.0 - ISC 457 * 458 * This source code is licensed under the ISC license. 459 * See the LICENSE file in the root directory of this source tree. 460 */const W3=Re("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** 461 * @license lucide-react v0.462.0 - ISC 462 * 463 * This source code is licensed under the ISC license. 464 * See the LICENSE file in the root directory of this source tree. 465 */const yH=Re("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]);/** 466 * @license lucide-react v0.462.0 - ISC 467 * 468 * This source code is licensed under the ISC license. 469 * See the LICENSE file in the root directory of this source tree. 470 */const Gx=Re("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 471 * @license lucide-react v0.462.0 - ISC 472 * 473 * This source code is licensed under the ISC license. 474 * See the LICENSE file in the root directory of this source tree. 475 */const vH=Re("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/** 476 * @license lucide-react v0.462.0 - ISC 477 * 478 * This source code is licensed under the ISC license. 479 * See the LICENSE file in the root directory of this source tree. 480 */const Uv=Re("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** 481 * @license lucide-react v0.462.0 - ISC 482 * 483 * This source code is licensed under the ISC license. 484 * See the LICENSE file in the root directory of this source tree. 485 */const bH=Re("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** 486 * @license lucide-react v0.462.0 - ISC 487 * 488 * This source code is licensed under the ISC license. 489 * See the LICENSE file in the root directory of this source tree. 490 */const bP=Re("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"}]]);/** 491 * @license lucide-react v0.462.0 - ISC 492 * 493 * This source code is licensed under the ISC license. 494 * See the LICENSE file in the root directory of this source tree. 495 */const wH=Re("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/** 496 * @license lucide-react v0.462.0 - ISC 497 * 498 * This source code is licensed under the ISC license. 499 * See the LICENSE file in the root directory of this source tree.
500 */const Wv=Re("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"}]]);/** 501 * @license lucide-react v0.462.0 - ISC 502 * 503 * This source code is licensed under the ISC license. 504 * See the LICENSE file in the root directory of this source tree. 505 */const _H=Re("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"}]]);/** 506 * @license lucide-react v0.462.0 - ISC 507 * 508 * This source code is licensed under the ISC license. 509 * See the LICENSE file in the root directory of this source tree. 510 */const pn=Re("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** 511 * @license lucide-react v0.462.0 - ISC 512 * 513 * This source code is licensed under the ISC license. 514 * See the LICENSE file in the root directory of this source tree. 515 */const K3=Re("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** 516 * @license lucide-react v0.462.0 - ISC 517 * 518 * This source code is licensed under the ISC license. 519 * See the LICENSE file in the root directory of this source tree. 520 */const za=Re("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** 521 * @license lucide-react v0.462.0 - ISC 522 * 523 * This source code is licensed under the ISC license. 524 * See the LICENSE file in the root directory of this source tree. 525 */const jH=Re("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** 526 * @license lucide-react v0.462.0 - ISC 527 * 528 * This source code is licensed under the ISC license. 529 * See the LICENSE file in the root directory of this source tree. 530 */const NH=Re("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** 531 * @license lucide-react v0.462.0 - ISC 532 * 533 * This source code is licensed under the ISC license. 534 * See the LICENSE file in the root directory of this source tree. 535 */const SH=Re("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** 536 * @license lucide-react v0.462.0 - ISC 537 * 538 * This source code is licensed under the ISC license. 539 * See the LICENSE file in the root directory of this source tree. 540 */const ao=Re("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** 541 * @license lucide-react v0.462.0 - ISC 542 * 543 * This source code is licensed under the ISC license. 544 * See the LICENSE file in the root directory of this source tree. 545 */const Kv=Re("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** 546 * @license lucide-react v0.462.0 - ISC 547 * 548 * This source code is licensed under the ISC license. 549 * See the LICENSE file in the root directory of this source tree. 550 */const dx=Re("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** 551 * @license lucide-react v0.462.0 - ISC 552 * 553 * This source code is licensed under the ISC license. 554 * See the LICENSE file in the root directory of this source tree. 555 */const Ws=Re("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"}]]);/** 556 * @license lucide-react v0.462.0 - ISC 557 * 558 * This source code is licensed under the ISC license. 559 * See the LICENSE file in the root directory of this source tree. 560 */const Hc=Re("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** 561 * @license lucide-react v0.462.0 - ISC 562 * 563 * This source code is licensed under the ISC license. 564 * See the LICENSE file in the root directory of this source tree. 565 */const CH=Re("UtensilsCrossed",[["path",{d:"m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8",key:"n7qcjb"}],["path",{d:"M15 15 3.3 3.3a4.2 4.2 0 0 0 0 6l7.3 7.3c.7.7 2 .7 2.8 0L15 15Zm0 0 7 7",key:"d0u48b"}],["path",{d:"m2.1 21.8 6.4-6.3",key:"yn04lh"}],["path",{d:"m19 5-7 7",key:"194lzd"}]]);/** 566 * @license lucide-react v0.462.0 - ISC 567 * 568 * This source code is licensed under the ISC license. 569 * See the LICENSE file in the root directory of this source tree. 570 */const nm=Re("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** 571 * @license lucide-react v0.462.0 - ISC 572 * 573 * This source code is licensed under the ISC license. 574 * See the LICENSE file in the root directory of this source tree. 575 */const H3=Re("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/** 576 * @license lucide-react v0.462.0 - ISC 577 * 578 * This source code is licensed under the ISC license. 579 * See the LICENSE file in the root directory of this source tree. 580 */const Ht=Re("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}
vendor: 6,290 bytes, lines 580-585
580],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** 581 * @license lucide-react v0.462.0 - ISC 582 * 583 * This source code is licensed under the ISC license. 584 * See the LICENSE file in the root directory of this source tree. 585 */const kH=Re("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"}]]),uC="-",EH=e=>{const t=OH(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(uC);return l[0]===""&&l.length!==1&&l.shift(),G3(l,t)||PH(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},G3=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),s=r?G3(e.slice(1),r):void 0;if(s)return s;if(t.validators.length===0)return;const i=e.join(uC);return(o=t.validators.find(({validator:l})=>l(i)))==null?void 0:o.classGroupId},wP=/^\[(.+)\]$/,PH=e=>{if(wP.test(e)){const t=wP.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},OH=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return TH(Object.entries(e.classGroups),n).forEach(([i,o])=>{Sj(o,r,i,t)}),r},Sj=(e,t,n,r)=>{e.forEach(s=>{if(typeof s=="string"){const i=s===""?t:_P(t,s);i.classGroupId=n;return}if(typeof s=="function"){if(AH(s)){Sj(s(r),t,n,r);return}t.validators.push({validator:s,classGroupId:n});return}Object.entries(s).forEach(([i,o])=>{Sj(o,_P(t,i),n,r)})})},_P=(e,t)=>{let n=e;return t.split(uC).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},AH=e=>e.isThemeGetter,TH=(e,t)=>t?e.map(([n,r])=>{const s=r.map(i=>typeof i=="string"?t+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,l])=>[t+o,l])):i);return[n,s]}):e,MH=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const s=(i,o)=>{n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(i){let o=n.get(i);if(o!==void 0)return o;if((o=r.get(i))!==void 0)return s(i,o),o},set(i,o){n.has(i)?n.set(i,o):s(i,o)}}},V3="!",DH=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,s=t[0],i=t.length,o=l=>{const c=[];let u=0,d=0,h;for(let p=0;p<l.length;p++){let v=l[p];if(u===0){if(v===s&&(r||l.slice(p,p+i)===t)){c.push(l.slice(d,p)),d=p+i;continue}if(v==="/"){h=p;continue}}v==="["?u++:v==="]"&&u--}const m=c.length===0?l:l.substring(d),f=m.startsWith(V3),x=f?m.substring(1):m,g=h&&h>d?h-d:void 0;return{modifiers:c,hasImportantModifier:f,baseClassName:x,maybePostfixModifierPosition:g}};return n?l=>n({className:l,parseClassName:o}):o},$H=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},RH=e=>({cache:MH(e.cacheSize),parseClassName:DH(e),...EH(e)}),IH=/\s+/,LH=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s}=t,i=[],o=e.trim().split(IH);let l="";for(let c=o.length-1;c>=0;c-=1){const u=o[c],{modifiers:d,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:f}=n(u);let x=!!f,g=r(x?m.substring(0,f):m);if(!g){if(!x){l=u+(l.length>0?" "+l:l);continue}if(g=r(m),!g){l=u+(l.length>0?" "+l:l);continue}x=!1}const p=$H(d).join(":"),v=h?p+V3:p,b=v+g;if(i.includes(b))continue;i.push(b);const w=s(g,x);for(let N=0;N<w.length;++N){const j=w[N];i.push(v+j)}l=u+(l.length>0?" "+l:l)}return l};function FH(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Y3(t))&&(r&&(r+=" "),r+=n);return r}const Y3=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Y3(e[r]))&&(n&&(n+=" "),n+=t);return n};function qH(e,...t){let n,r,s,i=o;function o(c){const u=t.reduce((d,h)=>h(d),e());return n=RH(u),r=n.cache.get,s=n.cache.set,i=l,l(c)}function l(c){const u=r(c);if(u)return u;const d=LH(c,n);return s(c,d),d}return function(){return i(FH.apply(null,arguments))}}const Sn=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Q3=/^\[(?:([a-z-]+):)?(.+)\]$/i,zH=/^\d+\/\d+$/,BH=new Set(["px","full","screen"]),UH=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,WH=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,KH=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,HH=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,GH=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ei=e=>Xu(e)||BH.has(e)||zH.test(e),No=e=>rh(e,"length",tG),Xu=e=>!!e&&!Number.isNaN(Number(e)),sw=e=>rh(e,"number",Xu),Ih=e=>!!e&&Number.isInteger(Number(e)),VH=e=>e.endsWith("%")&&Xu(e.slice(0,-1)),Rt=e=>Q3.test(e),So=e=>UH.test(e),YH=new Set(["length","size","percentage"]),QH=e=>rh(e,YH,X3),XH=e=>rh(e,"position",X3),JH=new Set(["image","url"]),ZH=e=>rh(e,JH,rG),eG=e=>rh(e,"",nG),Lh=()=>!0,rh=(e,t,n)=>{const r=Q3.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},tG=e=>WH.test(e)&&!KH.test(e),X3=()=>!1,nG=e=>HH.test(e),rG=e=>GH.test(e),aG=()=>{const e=Sn("colors"),t=Sn("spacing"),n=Sn("blur"),r=Sn("brightness"),s=Sn("borderColor"),i=Sn("borderRadius"),o=Sn("borderSpacing"),l=Sn("borderWidth"),c=Sn("contrast"),u=Sn("grayscale"),d=Sn("hueRotate"),h=Sn("invert"),m=Sn("gap"),f=Sn("gradientColorStops"),x=Sn("gradientColorStopPositions"),g=Sn("inset"),p=Sn("margin"),v=Sn("opacity"),b=Sn("padding"),w=Sn("saturate"),N=Sn("scale"),j=Sn("sepia"),_=Sn("skew"),S=Sn("space"),P=Sn("translate"),k=()=>["auto","contain","none"],C=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto",Rt,t],O=()=>[Rt,t],L=()=>["",Ei,No],E=()=>["auto",Xu,Rt],R=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],q=()=>["solid","dashed","dotted","double","none"],I=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>["start","end","center","between","around","evenly","stretch"],M=()=>["","0",Rt],B=()=>["auto","avoid","all","avoid-page","page","left","right","column"],W=()=>[Xu,Rt];return{cacheSize:500,separator:":",theme:{colors:[Lh],spacing:[Ei,No],blur:["none","",So,Rt],brightness:W(),borderColor:[e],borderRadius:["n
585one","","full",So,Rt],borderSpacing:O(),borderWidth:L(),contrast:W(),grayscale:M(),hueRotate:W(),invert:M(),gap:O(),gradientColorStops:[e],gradientColorStopPositions:[VH,No],inset:T(),margin:T(),opacity:W(),padding:O(),saturate:W(),scale:W(),sepia:M(),skew:W(),space:O(),translate:O()},classGroups:{aspect:[{aspect:["auto","square","video",Rt]}],container:["container"],columns:[{columns:[So]}],"break-after":[{"break-after":B()}],"break-before":[{"break-before":B()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...R(),Rt]}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Ih,Rt]}],basis:[{basis:T()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Rt]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",Ih,Rt]}],"grid-cols":[{"grid-cols":[Lh]}],"col-start-end":[{col:["auto",{span:["full",Ih,Rt]},Rt]}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":[Lh]}],"row-start-end":[{row:["auto",{span:[Ih,Rt]},Rt]}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Rt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Rt]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...$()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...$(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...$(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[p]}],mx:[{mx:[p]}],my:[{my:[p]}],ms:[{ms:[p]}],me:[{me:[p]}],mt:[{mt:[p]}],mr:[{mr:[p]}],mb:[{mb:[p]}],ml:[{ml:[p]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Rt,t]}],"min-w":[{"min-w":[Rt,t,"min","max","fit"]}],"max-w":[{"max-w":[Rt,t,"none","full","min","max","fit","prose",{screen:[So]},So]}],h:[{h:[Rt,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Rt,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Rt,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Rt,t,"auto","min","max","fit"]}],"font-size":[{text:["base",So,No]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",sw]}],"font-family":[{font:[Lh]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Rt]}],"line-clamp":[{"line-clamp":["none",Xu,sw]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ei,Rt]}],"list-image":[{"list-image":["none",Rt]}],"list-style-type":[{list:["none","disc","decimal",Rt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...q(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Ei,No]}],"underline-offset":[{"underline-offset":["auto",Ei,Rt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Rt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Rt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...R(),XH]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",QH]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},ZH]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}
vendor: 4,885 bytes, line 585
585],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[f]}],"gradient-via":[{via:[f]}],"gradient-to":[{to:[f]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:[...q(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:q()}],"border-color":[{border:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-s":[{"border-s":[s]}],"border-color-e":[{"border-e":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:["",...q()]}],"outline-offset":[{"outline-offset":[Ei,Rt]}],"outline-w":[{outline:[Ei,No]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[Ei,No]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",So,eG]}],"shadow-color":[{shadow:[Lh]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":[...I(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":I()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",So,Rt]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[w]}],sepia:[{sepia:[j]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[j]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Rt]}],duration:[{duration:W()}],ease:[{ease:["linear","in","out","in-out",Rt]}],delay:[{delay:W()}],animate:[{animate:["none","spin","ping","pulse","bounce",Rt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[N]}],"scale-x":[{"scale-x":[N]}],"scale-y":[{"scale-y":[N]}],rotate:[{rotate:[Ih,Rt]}],"translate-x":[{"translate-x":[P]}],"translate-y":[{"translate-y":[P]}],"skew-x":[{"skew-x":[_]}],"skew-y":[{"skew-y":[_]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Rt]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Rt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}
vendor: 4,226 bytes, line 585
585],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Rt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Ei,No,sw]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},sG=qH(aG);function Se(...e){return sG(Qt(e))}const iG=BK,J3=y.forwardRef(({className:e,...t},n)=>a.jsx(v3,{ref:n,className:Se("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));J3.displayName=v3.displayName;const oG=nh("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Z3=y.forwardRef(({className:e,variant:t,...n},r)=>a.jsx(b3,{ref:r,className:Se(oG({variant:t}),e),...n}));Z3.displayName=b3.displayName;const lG=y.forwardRef(({className:e,...t},n)=>
585a.jsx(j3,{ref:n,className:Se("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",e),...t}));lG.displayName=j3.displayName;const e5=y.forwardRef(({className:e,...t},n)=>a.jsx(N3,{ref:n,className:Se("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:a.jsx(Ht,{className:"h-4 w-4"})}));e5.displayName=N3.displayName;const t5=y.forwardRef(({className:e,...t},n)=>a.jsx(w3,{ref:n,className:Se("text-sm font-semibold",e),...t}));t5.displayName=w3.displayName;const n5=y.forwardRef(({className:e,...t},n)=>a.jsx(_3,{ref:n,className:Se("text-sm opacity-90",e),...t}));n5.displayName=_3.displayName;function cG(){const{toasts:e}=mt();return a.jsxs(iG,{children:[e.map(function({id:t,title:n,description:r,action:s,...i}){return a.jsxs(Z3,{...i,children:[a.jsxs("div",{className:"grid gap-1",children:[n&&a.jsx(t5,{children:n}),r&&a.jsx(n5,{children:r})]}),s,a.jsx(e5,{})]},t)}),a.jsx(J3,{})]})}var jP=["light","dark"],uG="(prefers-color-scheme: dark)",dG=y.createContext(void 0),hG={setTheme:e=>{},themes:[]},fG=()=>{var e;return(e=y.useContext(dG))!=null?e:hG};y.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:s,defaultTheme:i,value:o,attrs:l,nonce:c})=>{let u=i==="system",d=n==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${l.map(x=>`'${x}'`).join(",")})`};`:`var d=document.documentElement,n='${n}',s='setAttribute';`,h=s?jP.includes(i)&&i?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${i}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",m=(x,g=!1,p=!0)=>{let v=o?o[x]:x,b=g?x+"|| ''":`'${v}'`,w="";return s&&p&&!g&&jP.includes(x)&&(w+=`d.style.colorScheme = '${x}';`),n==="class"?g||v?w+=`c.add(${b})`:w+="null":v&&(w+=`d[s](n,${b})`),w},f=e?`!function(){${d}${m(e)}}()`:r?`!function(){try{${d}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${u})){var t='${uG}',m=window.matchMedia(t);if(m.media!==t||m.matches){${m("dark")}}else{${m("light")}}}else if(e){${o?`var x=${JSON.stringify(o)};`:""}${m(o?"x[e]":"e",!0)}}${u?"":"else{"+m(i,!1,!1)+"}"}${h}}catch(e){}}()`:`!function(){try{${d}var e=localStorage.getItem('${t}');if(e){${o?`var x=${JSON.stringify(o)};`:""}${m(o?"x[e]":"e",!0)}}else{${m(i,!1,!1)};}${h}}catch(t){}}();`;return y.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:f}})});var mG=e=>{switch(e){case"success":return xG;case"info":return vG;case"warning":return yG;case"error":return bG;default:return null}},pG=Array(12).fill(0),gG=({visible:e,className:t})=>ae.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ae.createElement("div",{className:"sonner-spinner"},pG.map((n,r)=>ae.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),xG=ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ae.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),yG=ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ae.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),vG=ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ae.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),bG=ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ae.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),wG=ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ae.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ae.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),_G=()=>{let[e,t]=ae.useState(document.hidden);return ae.useEffect(()=>{let n=()=>{t(document.hidden)};
585return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Cj=1,jG=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,s=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Cj++,i=this.toasts.find(l=>l.id===s),o=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),i?this.toasts=this.toasts.map(l=>l.id===s?(this.publish({...l,...e,id:s,title:n}),{...l,...e,id:s,dismissible:o,title:n}):l):this.addToast({title:n,...r,dismissible:o,id:s}),s},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>
585this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),s=n!==void 0,i,o=r.then(async c=>{if(i=["resolve",c],ae.isValidElement(c))s=!1,this.create({id:n,type:"default",message:c});else if(SG(c)&&!c.ok){s=!1;let u=typeof t.error=="function"?await t.error(`HTTP error! status: ${c.status}`):t.error,d=typeof t.description=="function"?await t.description(`HTTP error! status: ${c.status}`):t.description;this.create({id:n,type:"error",message:u,description:d})}else if(t.success!==void 0){s=!1;let u=typeof t.success=="function"?await t.success(c):t.success,d=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"success",message:u,description:d})}}).catch(async c=>{if(i=["reject",c],t.error!==void 0){s=!1;let u=typeof t.error=="function"?await t.error(c):t.error,d=typeof t.description=="function"?await t.description(c):t.description;this.create({id:n,type:"error",message:u,description:d})}}).finally(()=>{var c;s&&(this.dismiss(n),n=void 0),(c=t.finally)==null||c.call(t)}),l=()=>new Promise((c,u)=>o.then(()=>i[0]==="reject"?u(i[1]):c(i[1])).catch(u));return typeof n!="string"&&typeof n!="number"?{unwrap:l}:Object.assign(n,{unwrap:l})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Cj++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},ma=new jG,NG=(e,t)=>{let n=(t==null?void 0:t.id)||Cj++;return ma.addToast({title:e,...t,id:n}),n},SG=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",CG=NG,kG=()=>ma.toasts,EG=()=>ma.getActiveToasts(),Mt=Object.assign(CG,{success:ma.success,info:ma.info,warning:ma.warning,error:ma.error,custom:ma.custom,message:ma.message,promise:ma.promise,dismiss:ma.dismiss,loading:ma.loading},{getHistory:kG,getToasts:EG});function PG(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}PG(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;
585left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}
585:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);
585--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} 586`);function fg(e){return e.label!==void 0}var OG=3,AG="32px",TG="16px",NP=4e3,MG=356,DG=14,$G=20,RG=200;function js(...e){return e.filter(Boolean).join(" ")}function IG(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var LG=e=>{var t,n,r,s,i,o,l,c,u,d,h;let{invert:m,toast:f,unstyled:x,interacting:g,setHeights:p,visibleToasts:v,heights:b,index:w,toasts:N,expanded:j,removeToast:_,defaultRichColors:S,closeButton:P,style:k,cancelButtonStyle:C,actionButtonStyle:T,className:O="",descriptionClassName:L="",duration:E,position:R,gap:q,loadingIcon:I,expandByDefault:$,classNames:M,icons:B,closeButtonAriaLabel:W="Close toast",pauseWhenPageIsHidden:A}=e,[K,G]=ae.useState(null),[H,fe]=ae.useState(null),[te,J]=ae.useState(!1),[re,pe]=ae.useState(!1),[ye,X]=ae.useState(!1),[he,D]=ae.useState(!1),[le,V]=ae.useState(!1),[U,z]=ae.useState(0),[Z,ve]=ae.useState(0),ee=ae.useRef(f.duration||E||NP),de=ae.useRef(null),je=ae.useRef(null),Q=w===0,oe=w+1<=v,Pe=f.type,ze=f.dismissible!==!1,Je=f.className||"",Ae=f.descriptionClassName||"",et=ae.useMemo(()=>b.findIndex(ge=>ge.toastId===f.id)||0,[b,f.id]),Ne=ae.useMemo(()=>{var ge;return(ge=f.closeButton)!=null?ge:P},[f.closeButton,P]),be=ae.useMemo(()=>f.duration||E||NP,[f.duration,E]),Ue=ae.useRef(0),Ze=ae.useRef(0),nt=ae.useRef(0),rt=ae.useRef(null),[kt,jt]=R.split("-"),Et=ae.useMemo(()=>b.reduce((ge,$e,Ke)=>Ke>=et?ge:ge+$e.height,0),[b,et]),Nt=_G(),ue=f.invert||m,we=Pe==="loading";Ze.current=ae.useMemo(()=>et*q+Et,[et,Et]),ae.useEffect(()=>{ee.current=be},[be]),ae.useEffect(()=>{J(!0)},[]),ae.useEffect(()=>{let ge=je.current;if(ge){let $e=ge.getBoundingClientRect().height;return ve($e),p(Ke=>[{toastId:f.id,height:$e,position:f.position}
586,...Ke]),()=>p(Ke=>Ke.filter(Qe=>Qe.toastId!==f.id))}},[p,f.id]),ae.useLayoutEffect(()=>{if(!te)return;let ge=je.current,$e=ge.style.height;ge.style.height="auto";let Ke=ge.getBoundingClientRect().height;ge.style.height=$e,ve(Ke),p(Qe=>Qe.find(He=>He.toastId===f.id)?Qe.map(He=>He.toastId===f.id?{...He,height:Ke}:He):[{toastId:f.id,height:Ke,position:f.position},...Qe])},[te,f.title,f.description,p,f.id]);let Ie=ae.useCallback(()=>{pe(!0),z(Ze.current),p(ge=>ge.filter($e=>$e.toastId!==f.id)),setTimeout(()=>{_(f)},RG)},[f,_,p,Ze]);ae.useEffect(()=>{if(f.promise&&Pe==="loading"||f.duration===1/0||f.type==="loading")return;let ge;return j||g||A&&Nt?(()=>{if(nt.current<Ue.current){let $e=new Date().getTime()-Ue.current;ee.current=ee.current-$e}nt.current=new Date().getTime()})():ee.current!==1/0&&(Ue.current=new Date().getTime(),ge=setTimeout(()=>{var $e;($e=f.onAutoClose)==null||$e.call(f,f),Ie()},ee.current)),()=>clearTimeout(ge)},[j,g,f,Pe,A,Nt,Ie]),ae.useEffect(()=>{f.delete&&Ie()},[Ie,f.delete]);function se(){var ge,$e,Ke;return B!=null&&B.loading?ae.createElement("div",{className:js(M==null?void 0:M.loader,(ge=f==null?void 0:f.classNames)==null?void 0:ge.loader,"sonner-loader"),"data-visible":Pe==="loading"},B.loading):I?ae.createElement("div",{className:js(M==null?void 0:M.loader,($e=f==null?void 0:f.classNames)==null?void 0:$e.loader,"sonner-loader"),"data-visible":Pe==="loading"},I):ae.createElement(gG,{className:js(M==null?void 0:M.loader,(Ke=f==null?void 0:f.classNames)==null?void 0:Ke.loader),visible:Pe==="loading"})}return ae.createElement("li",{tabIndex:0,ref:je,className:js(O,Je,M==null?void 0:M.toast,(t=f==null?void 0:f.classNames)==null?void 0:t.toast,M==null?void 0:M.default,M==null?void 0:M[Pe],(n=f==null?void 0:f.classNames)==null?void 0:n[Pe]),"data-sonner-toast":"","data-rich-colors":(r=f.richColors)!=null?r:S,"data-styled":!(f.jsx||f.unstyled||x),"data-mounted":te,"data-promise":!!f.promise,"data-swiped":le,"data-removed":re,"data-visible":oe,"data-y-position":kt,"data-x-position":jt,"data-index":w,"data-front":Q,"data-swiping":ye,"data-dismissible":ze,"data-type":Pe,"data-invert":ue,"data-swipe-out":he,"data-swipe-direction":H,"data-expanded":!!(j||$&&te),style:{"--index":w,"--toasts-before":w,"--z-index":N.length-w,"--offset":`${re?U:Ze.current}px`,"--initial-height":$?"auto":`${Z}px`,...k,...f.style},onDragEnd:()=>{X(!1),G(null),rt.current=null},onPointerDown:ge=>{we||!ze||(de.current=new Date,z(Ze.current),ge.target.setPointerCapture(ge.pointerId),ge.target.tagName!=="BUTTON"&&(X(!0),rt.current={x:ge.clientX,y:ge.clientY}))},onPointerUp:()=>{var ge,$e,Ke,Qe;if(he||!ze)return;rt.current=null;let He=Number(((ge=je.current)==null?void 0:ge.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Tt=Number((($e=je.current)==null?void 0:$e.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),fn=new Date().getTime()-((Ke=de.current)==null?void 0:Ke.getTime()),Xt=K==="x"?He:Tt,_e=Math.abs(Xt)/fn;if(Math.abs(Xt)>=$G||_e>.11){z(Ze.current),(Qe=f.onDismiss)==null||Qe.call(f,f),fe(K==="x"?He>0?"right":"left":Tt>0?"down":"up"),Ie(),D(!0),V(!1);return}X(!1),G(null)},onPointerMove:ge=>{var $e,Ke,Qe,He;if(!rt.current||!ze||(($e=window.getSelection())==null?void 0:$e.toString().length)>0)return;let Tt=ge.clientY-rt.current.y,fn=ge.clientX-rt.current.x,Xt=(Ke=e.swipeDirections)!=null?Ke:IG(R);!K&&(Math.abs(fn)>1||Math.abs(Tt)>1)&&G(Math.abs(fn)>Math.abs(Tt)?"x":"y");let _e={x:0,y:0};K==="y"?(Xt.includes("top")||Xt.includes("bottom"))&&(Xt.includes("top")&&Tt<0||Xt.includes("bottom")&&Tt>0)&&(_e.y=Tt):K==="x"&&(Xt.includes("left")||Xt.includes("right"))&&(Xt.includes("left")&&fn<0||Xt.includes("right")&&fn>0)&&(_e.x=fn),(Math.abs(_e.x)>0||Math.abs(_e.y)>0)&&V(!0),(Qe=je.current)==null||Qe.style.setProperty("--swipe-amount-x",`${_e.x}px`),(He=je.current)==null||He.style.setProperty("--swipe-amount-y",`${_e.y}px`)}},Ne&&!f.jsx?ae.createElement("button",{"aria-label":W,"data-disabled":we,"data-close-button":!0,onClick:we||!ze?()=>{}:()=>{var ge;Ie(),(ge=f.onDismiss)==null||ge.call(f,f)},className:js(M==null?void 0:M.closeButton,(s=f==null?void 0:f.classNames)==null?void 0:s.closeButton)},(i=B==null?void 0:B.close)!=null?i:wG):null,f.jsx||y.isValidElement(f.title)?f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title:ae.createElement(ae.Fragment,null,Pe||f.icon||f.promise?ae.createElement("div",{"data-icon":"",className:js(M==null?void 0:M.icon,(o=f==null?void 0:f.classNames)==null?void 0:o.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||se():null,f.type!=="loading"?f.icon||(B==null?void 0:B[Pe])||mG(Pe):null):null,ae.createElement("div",{"data-content":"",className:js(M==null?void 0:M.content,(l=f==null?void 0:f.classNames)==null?void 0:l.content)},ae.createElement("div",{"data-title":"",className:js(M==null?void 0:M.title,(c=f==null?void 0:f.classNames)==null?void 0:c.title)},typeof f.title=="function"?f.title():f.title),f.description?ae.createElement("div",{"data-description":"",className:js(L,Ae,M==null?void 0:M.description,(u=f==null?void 0:f.classNames)==null?void 0:u.description)},typeof f.description=="function"?f.description():f.description):null),y.isValidElement(f.cancel)?f.cancel:f.cancel&&fg(f.cancel)?ae.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||C,onClick:ge=>{var $e,Ke;fg(f.cancel)&&ze&&((Ke=($e=f.cancel).onClick)==null||Ke.call($e,ge),Ie())},className:js(M==null?void 0:M.cancelButton,(d=f==null?void 0:f.classNames)==null?void 0:d.cancelButton)},f.cancel.label):null,y.isValidElement(f.action)?f.action:f.action&&fg(f.action)?ae.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||T,onClick:ge=>{var $e,Ke;fg(f.action)&&((Ke=($e=f.action).onClick)==null||Ke.call($e,ge),!ge.defaultPrevented&&Ie())},className:js(M==null?void 0:M.actionButton,(h=f==null?void 0:f.classNames)==null?void 0:h.actionButton)},f.action.label):null))};function SP(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function FG(e,t){let n={};return[e,t].forEach((r,s)=>{let i=s===1,o=i?"--mobile-offset":"--offset",l=i?TG:AG;function c(u){["top","right","bottom","left"].forEach(d=>{n[`${o}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(u=>{r[u]===void 0?n[`${o}-${u}`]=l:n[`${o}-${u}`]=typeof r[u]=="number"?`${r[u]}px`:r[u]}):c(l)}),n}var qG=y.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:s=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:c,mobileOffset:u,theme:d="light",richColors:h,duration:m,style:f,visibleToasts:x=OG,toastOptions:g,dir:p=SP(),gap:v=DG,loadingIcon:b,icons:w,containerAriaLabel:N="Notifications",pauseWhenPageIsHidden:j}=e,[_,S]=ae.useState([]),P=ae.useMemo(()=>Array.from(new Set([r].concat(_.filter(A=>A.position).map(A=>A.position)))),[_,r]),[k,C]=ae.useState([]),[T,O]=ae.useState(!1),[L,E]=ae.useState(!1),[R,q]=ae.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dar
586k":"light"),I=ae.useRef(null),$=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=ae.useRef(null),B=ae.useRef(!1),W=ae.useCallback(A=>{S(K=>{var G;return(G=K.find(H=>H.id===A.id))!=null&&G.delete||ma.dismiss(A.id),K.filter(({id:H})=>H!==A.id)})},[]);return ae.useEffect(()=>ma.subscribe(A=>{if(A.dismiss){S(K=>K.map(G=>G.id===A.id?{...G,delete:!0}:G));return}setTimeout(()=>{JI.flushSync(()=>{S(K=>{let G=K.findIndex(H=>H.id===A.id);return G!==-1?[...K.slice(0,G),{...K[G],...A},...K.slice(G+1)]:[A,...K]})})})}),[]),ae.useEffect(()=>{if(d!=="system"){q(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;let A=window.matchMedia("(prefers-color-scheme: dark)");try{A.addEventListener("change",({matches:K})=>{q(K?"dark":"light")})}catch{A.addListener(({matches:G})=>{try{q(G?"dark":"light")}catch(H){console.error(H)}})}},[d]),ae.useEffect(()=>{_.length<=1&&O(!1)},[_]),ae.useEffect(()=>{let A=K=>{var G,H;s.every(fe=>K[fe]||K.code===fe)&&(O(!0),(G=I.current)==null||G.focus()),K.code==="Escape"&&(document.activeElement===I.current||(H=I.current)!=null&&H.contains(document.activeElement))&&O(!1)};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[s]),ae.useEffect(()=>{if(I.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,B.current=!1)}},[I.current]),ae.createElement("section",{ref:t,"aria-label":`${N} ${$}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},P.map((A,K)=>{var G;let[H,fe]=A.split("-");return _.length?ae.createElement("ol",{key:A,dir:p==="auto"?SP():p,tabIndex:-1,ref:I,className:l,"data-sonner-toaster":!0,"data-theme":R,"data-y-position":H,"data-lifted":T&&_.length>1&&!i,"data-x-position":fe,style:{"--front-toast-height":`${((G=k[0])==null?void 0:G.height)||0}px`,"--width":`${MG}px`,"--gap":`${v}px`,...f,...FG(c,u)},onBlur:te=>{B.current&&!te.currentTarget.contains(te.relatedTarget)&&(B.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:te=>{te.target instanceof HTMLElement&&te.target.dataset.dismissible==="false"||B.current||(B.current=!0,M.current=te.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{L||O(!1)},onDragEnd:()=>O(!1),onPointerDown:te=>{te.target instanceof HTMLElement&&te.target.dataset.dismissible==="false"||E(!0)},onPointerUp:()=>E(!1)},_.filter(te=>!te.position&&K===0||te.position===A).map((te,J)=>{var re,pe;return ae.createElement(LG,{key:te.id,icons:w,index:J,toast:te,defaultRichColors:h,duration:(re=g==null?void 0:g.duration)!=null?re:m,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:x,closeButton:(pe=g==null?void 0:g.closeButton)!=null?pe:o,interacting:L,position:A,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:W,toasts:_.filter(ye=>ye.position==te.position),heights:k.filter(ye=>ye.position==te.position),setHeights:C,expandByDefault:i,gap:v,loadingIcon:b,expanded:T,pauseWhenPageIsHidden:j,swipeDirections:e.swipeDirections})})):null}))});const zG=({...e})=>{const{theme:t="system"}=fG();return a.jsx(qG,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})};var BG=lS[" useId ".trim().toString()]||(()=>{}),UG=0;function Zn(e){const[t,n]=y.useState(BG());return dr(()=>{n(r=>r??String(UG++))},[e]),t?`radix-${t}`:""}const WG=["top","right","bottom","left"],gl=Math.min,Da=Math.max,Vx=Math.round,mg=Math.floor,yi=e=>({x:e,y:e}
vendor: 11,921 bytes, line 586
586),KG={left:"right",right:"left",bottom:"top",top:"bottom"},HG={start:"end",end:"start"};function kj(e,t,n){return Da(e,gl(t,n))}function so(e,t){return typeof e=="function"?e(t):e}function io(e){return e.split("-")[0]}function ah(e){return e.split("-")[1]}function dC(e){return e==="x"?"y":"x"}function hC(e){return e==="y"?"height":"width"}const GG=new Set(["top","bottom"]);function hi(e){return GG.has(io(e))?"y":"x"}function fC(e){return dC(hi(e))}function VG(e,t,n){n===void 0&&(n=!1);const r=ah(e),s=fC(e),i=hC(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(o=Yx(o)),[o,Yx(o)]}function YG(e){const t=Yx(e);return[Ej(e),t,Ej(t)]}function Ej(e){return e.replace(/start|end/g,t=>HG[t])}const CP=["left","right"],kP=["right","left"],QG=["top","bottom"],XG=["bottom","top"];function JG(e,t,n){switch(e){case"top":case"bottom":return n?t?kP:CP:t?CP:kP;case"left":case"right":return t?QG:XG;default:return[]}}function ZG(e,t,n,r){const s=ah(e);let i=JG(io(e),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),t&&(i=i.concat(i.map(Ej)))),i}function Yx(e){return e.replace(/left|right|bottom|top/g,t=>KG[t])}function eV(e){return{top:0,right:0,bottom:0,left:0,...e}}function r5(e){return typeof e!="number"?eV(e):{top:e,right:e,bottom:e,left:e}}function Qx(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function EP(e,t,n){let{reference:r,floating:s}=e;const i=hi(t),o=fC(t),l=hC(o),c=io(t),u=i==="y",d=r.x+r.width/2-s.width/2,h=r.y+r.height/2-s.height/2,m=r[l]/2-s[l]/2;let f;switch(c){case"top":f={x:d,y:r.y-s.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:h};break;case"left":f={x:r.x-s.width,y:h};break;default:f={x:r.x,y:r.y}}switch(ah(t)){case"start":f[o]-=m*(n&&u?-1:1);break;case"end":f[o]+=m*(n&&u?-1:1);break}return f}const tV=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=i.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t));let u=await o.getElementRects({reference:e,floating:t,strategy:s}),{x:d,y:h}=EP(u,r,c),m=r,f={},x=0;for(let g=0;g<l.length;g++){const{name:p,fn:v}=l[g],{x:b,y:w,data:N,reset:j}=await v({x:d,y:h,initialPlacement:r,placement:m,strategy:s,middlewareData:f,rects:u,platform:o,elements:{reference:e,floating:t}});d=b??d,h=w??h,f={...f,[p]:{...f[p],...N}},j&&x<=50&&(x++,typeof j=="object"&&(j.placement&&(m=j.placement),j.rects&&(u=j.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:s}):j.rects),{x:d,y:h}=EP(u,m,c)),g=-1)}return{x:d,y:h,placement:m,strategy:s,middlewareData:f}};async function rm(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:m=!1,padding:f=0}=so(t,e),x=r5(f),p=l[m?h==="floating"?"reference":"floating":h],v=Qx(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(p)))==null||n?p:p.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:u,rootBoundary:d,strategy:c})),b=h==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),N=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},j=Qx(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:w,strategy:c}):b);return{top:(v.top-j.top+x.top)/N.y,bottom:(j.bottom-v.bottom+x.bottom)/N.y,left:(v.left-j.left+x.left)/N.x,right:(j.right-v.right+x.right)/N.x}}const nV=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:i,platform:o,elements:l,middlewareData:c}=t,{element:u,padding:d=0}=so(e,t)||{};if(u==null)return{};const h=r5(d),m={x:n,y:r},f=fC(s),x=hC(f),g=await o.getDimensions(u),p=f==="y",v=p?"top":"left",b=p?"bottom":"right",w=p?"clientHeight":"clientWidth",N=i.reference[x]+i.reference[f]-m[f]-i.floating[x],j=m[f]-i.reference[f],_=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let S=_?_[w]:0;(!S||!await(o.isElement==null?void 0:o.isElement(_)))&&(S=l.floating[w]||i.floating[x]);const P=N/2-j/2,k=S/2-g[x]/2-1,C=gl(h[v],k),T=gl(h[b],k),O=C,L=S-g[x]-T,E=S/2-g[x]/2+P,R=kj(O,E,L),q=!c.arrow&&ah(s)!=null&&E!==R&&i.reference[x]/2-(E<O?C:T)-g[x]/2<0,I=q?E<O?E-O:E-L:0;return{[f]:m[f]+I,data:{[f]:R,centerOffset:E-R-I,...q&&{alignmentOffset:I}},reset:q}}}),rV=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:g=!0,...p}=so(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const v=io(s),b=hi(l),w=io(l)===l,N=await(c.isRTL==null?void 0:c.isRTL(u.floating)),j=m||(w||!g?[Yx(l)]:YG(l)),_=x!=="none";!m&&_&&j.push(...ZG(l,g,x,N));const S=[l,...j],P=await rm(t,p),k=[];let C=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&k.push(P[v]),h){const E=VG(s,o,N);k.push(P[E[0]],P[E[1]])}if(C=[...C,{placement:s,overflows:k}],!k.every(E=>E<=0)){var T,O;const E=(((T=i.flip)==null?void 0:T.index)||0)+1,R=S[E];if(R&&(!(h==="alignment"?b!==hi(R):!1)||C.every($=>$.overflows[0]>0&&hi($.placement)===b)))return{data:{index:E,overflows:C},reset:{placement:R}};let q=(O=C.filter(I=>I.overflows[0]<=0).sort((I,$)=>I.overflows[1]-$.overflows[1])[0])==null?void 0:O.placement;if(!q)switch(f){case"bestFit":{var L;const I=(L=C.filter($=>{if(_){const M=hi($.placement);return M===b||M==="y"}return!0}).map($=>[$.placement,$.overflows.filter(M=>M>0).reduce((M,B)=>M+B,0)]).sort(($,M)=>$[1]-M[1])[0])==null?void 0:L[0];I&&(q=I);break}case"initialPlacement":q=l;break}if(s!==q)return{reset:{placement:q}}}return{}}}};function PP(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function OP(e){return WG.some(t=>e[t]>=0)}const aV=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...s}=so(e,t);switch(r){case"referenceHidden":{const i=await rm(t,{...s,elementContext:"reference"}),o=PP(i,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:OP(o)}}}case"escaped":{const i=await rm(t,{...s,altBoundary:!0}),o=PP(i,n.floating);return{data:{escapedOffsets:o,escaped:OP(o)}}}default:return{}}}}},a5=new Set(["left","top"]);async function sV(e,t){const{placement:n,platform:r,elements:s}=e,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=io(n),l=ah(n),c=hi(n)==="y",u=a5.has(o)?-1:1,d=i&&c?-1:1,h=so(t,e);let{mainAxis:m,crossAxis:f,alignmentAxis:x}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof x=="number"&&(f=l==="end"?x*-1:x),c?{x:f*d,y:m*u}:{x:m*u,y:f*d}}const iV=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=t,c=await sV(t,e);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:i+c.y,data:{...c,placement:o}}}}},oV=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s}=t,{mainAxis:i=!0,crossAxis:o=!1,limiter:l={fn:p=>{let{x:v,y:b}=p;return{x:v,y:b}}},...c}=so(e,t),u={x:n,y:r},d=await rm(t,c),h=hi(io(s)),m=dC(h);let f=u[m],x=u[h];if(i){const p=m==="y"?"top":"left",v=m==="y"?"bottom":"right",b=f+d[p],w=f-d[v];f=kj(b,f,w)}if(o){const p=h==="y"?"top":"left",v=h==="y"?"bottom":"right",b=x+d[p],w=x-d[v];x=kj(b,x,w)}const g=l.fn({...t,[m]:f,[h]:x});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[m]:i,[h]:o}}}}}},lV=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:i,middlewareData:o}=t,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=so(e,t),d={x:n,y:r},h=hi(s),m=dC(h);let f=d[m],x=d[h];const g=so(l,t),p=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const w=m==="y"?"height":"width",N=i.reference[m]-i.floating[w]+p.mainAxis,j=i.reference[m]+i.reference[w]-p.mainAxis;f<N?f=N:f>j&&(f=j)}if(u){var v,b;const w=m==="y"?"width":"height",N=a5.has(io(s)),j=i.reference[h]-i.floating[w]+(N&&((v=o.offset)==null?void 0:v[h])||0)+(N?0:p.crossAxis),_=i.reference[h]+i.reference[w]+(N?0:((b=o.offset)==null?void 0:b[h])||0)-(N?p.crossAxis:0);x<j?x=j:x>_&&(x=_)}return{[m]:f,[h]:x}}}},cV=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:i,platform:o,elements:l}=t,{apply:c=()=>{},...u}=so(e,t),d=await rm(t,u),h=io(s),m=ah(s),f=hi(s)==="y",{width:x,height:g}=i.floating;let p,v;h==="top"||h==="bottom"?(p=h,v=m===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(v=h,p=m==="end"?"top":"bottom");const b=g-d.top-d.bottom,w=x-d.left-d.right,N=gl(g-d[p],b),j=gl(x-d[v],w),_=!t.middlewareData.shift;let S=N,P=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(S=b),_&&!m){const C=Da(d.left,0),T=Da(d.right,0),O=Da(d.top,0),L=Da(d.bottom,0);f?P=x-2*(C!==0||T!==0?C+T:Da(d.left,d.right)):S=g-2*(O!==0||L!==0?O+L:Da(d.top,d.bottom))}await c({...t,availableWidth:P,availableHeight:S});const k=await o.getDimensions(l.floating);return x!==k.width||g!==k.height?{reset:{rects:!0}}:{}}}};function Hv(){return typeof window<"u"}function sh(e){return s5(e)?(e.nodeName||"").toLowerCase():"#document"}function Fa(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ni(e){var t;return(t=(s5(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function s5(e){return Hv()?e instanceof Node||e instanceof Fa(e).Node:!1}function Gs(e){return Hv()?e instanceof Element||e instanceof Fa(e).Element:!1}function wi(e){return Hv()?e instanceof HTMLElement||e instanceof Fa(e).HTMLElement:!1}function AP(e){return!Hv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Fa(e).ShadowRoot}const uV=new Set(["inline","contents"]);function mp(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=Vs(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!uV.has(s)}const dV=new Set(["table","td","th"]);function hV(e){return dV.has(sh(e))}const fV=[":popover-open",":modal"];function Gv(e){return fV.some(t=>{try{return e.matches(t)}catch{return!1}})}const mV=["transform","translate","scale","rotate","perspective"],pV=["transform","translate","scale","rotate","perspective","filter"],gV=["paint","layout","strict","content"];function mC(e){const t=pC(),n=Gs(e)?Vs(e):e;return mV.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||pV.some(r=>(n.willChange||"").includes(r))||gV.some(r=>(n.contain||"").includes(r))}function xV(e){let t=xl(e);for(;wi(t)&&!Sd(t);){if(mC(t))return t;if(Gv(t))return null;t=xl(t)}return null}function pC(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const yV=new Set(["html","body","#document"]);function Sd(e){return yV.has(sh(e))}function Vs(e){return Fa(e).getComputedStyle(e)}function Vv(e){return Gs(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function xl(e){if(sh(e)==="html")return e;const t=e.assignedSlot||e.parentNode||AP(e)&&e.host||Ni(e);return AP(t)?t.host:t}function i5(e){const t=xl(e);return Sd(t)?e.ownerDocument?e.ownerDocument.body:e.body:wi(t)&&mp(t)?t:i5(t)}function am(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=i5(e),i=s===((r=e.ownerDocument)==null?void 0:r.body),o=Fa(s);if(i){const l=Pj(o);
vendor: 4,127 bytes, line 586
586return t.concat(o,o.visualViewport||[],mp(s)?s:[],l&&n?am(l):[])}return t.concat(s,am(s,[],n))}function Pj(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function o5(e){const t=Vs(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=wi(e),i=s?e.offsetWidth:n,o=s?e.offsetHeight:r,l=Vx(n)!==i||Vx(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function gC(e){return Gs(e)?e:e.contextElement}function Ju(e){const t=gC(e);if(!wi(t))return yi(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:i}=o5(t);let o=(i?Vx(n.width):n.width)/r,l=(i?Vx(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const vV=yi(0);function l5(e){const t=Fa(e);return!pC()||!t.visualViewport?vV:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function bV(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Fa(e)?!1:t}function Pc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),i=gC(e);let o=yi(1);t&&(r?Gs(r)&&(o=Ju(r)):o=Ju(e));const l=bV(i,n,r)?l5(i):yi(0);let c=(s.left+l.x)/o.x,u=(s.top+l.y)/o.y,d=s.width/o.x,h=s.height/o.y;if(i){const m=Fa(i),f=r&&Gs(r)?Fa(r):r;let x=m,g=Pj(x);for(;g&&r&&f!==x;){const p=Ju(g),v=g.getBoundingClientRect(),b=Vs(g),w=v.left+(g.clientLeft+parseFloat(b.paddingLeft))*p.x,N=v.top+(g.clientTop+parseFloat(b.paddingTop))*p.y;c*=p.x,u*=p.y,d*=p.x,h*=p.y,c+=w,u+=N,x=Fa(g),g=Pj(x)}}return Qx({width:d,height:h,x:c,y:u})}function xC(e,t){const n=Vv(e).scrollLeft;return t?t.left+n:Pc(Ni(e)).left+n}function c5(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),s=r.left+t.scrollLeft-(n?0:xC(e,r)),i=r.top+t.scrollTop;return{x:s,y:i}}function wV(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const i=s==="fixed",o=Ni(r),l=t?Gv(t.floating):!1;if(r===o||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=yi(1);const d=yi(0),h=wi(r);if((h||!h&&!i)&&((sh(r)!=="body"||mp(o))&&(c=Vv(r)),wi(r))){const f=Pc(r);u=Ju(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const m=o&&!h&&!i?c5(o,c,!0):yi(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+m.x,y:n.y*u.y-c.scrollTop*u.y+d.y+m.y}}function _V(e){return Array.from(e.getClientRects())}function jV(e){const t=Ni(e),n=Vv(e),r=e.ownerDocument.body,s=Da(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Da(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+xC(e);const l=-n.scrollTop;return Vs(r).direction==="rtl"&&(o+=Da(t.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:l}}function NV(e,t){const n=Fa(e),r=Ni(e),s=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,l=0,c=0;if(s){i=s.width,o=s.height;const u=pC();(!u||u&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}return{width:i,height:o,x:l,y:c}}const SV=new Set(["absolute","fixed"]);function CV(e,t){const n=Pc(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,i=wi(e)?Ju(e):yi(1),o=e.clientWidth*i.x,l=e.clientHeight*i.y,c=s*i.x,u=r*i.y;return{width:o,height:l,x:c,y:u}}function TP(e,t,n){let r;if(t==="viewport")r=NV(e,n);else if(t==="document")r=jV(Ni(e));else if(Gs(t))r=CV(t,n);else{const s=l5(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Qx(r)}function u5(e,t){const n=xl(e);return n===t||!Gs(n)||Sd(n)?!1:Vs(n).position==="fixed"||u5(n,t)}function kV(e,t){const n=t.get(e);if(n)return n;let r=am(e,[],!1).filter(l=>Gs(l)&&sh(l)!=="body"),s=null;const i=Vs(e).position==="fixed";let o=i?xl(e):e;for(;Gs(o)&&!Sd(o);){const l=Vs(o),c=mC(o);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&SV.has(s.position)||mp(o)&&!c&&u5(e,o))?r=r.filter(d=>d!==o):s=l,o=xl(o)}return t.set(e,r),r}function EV(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const o=[...n==="clippingAncestors"?Gv(t)?[]:kV(t,this._c):[].concat(n),r],l=o[0],c=o.reduce((u,d)=>{const h=TP(t,d,s);return u.top=Da(h.top,u.top),u.right=gl(h.right,u.right),u.bottom=gl(h.bottom,u.bottom),u.left=Da(h.left,u.left),u},TP(t,l,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function PV(e){const{width:t,height:n}=o5(e);return{width:t,height:n}}
vendor: 8,842 bytes, line 586
586function OV(e,t,n){const r=wi(t),s=Ni(t),i=n==="fixed",o=Pc(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=yi(0);function u(){c.x=xC(s)}if(r||!r&&!i)if((sh(t)!=="body"||mp(s))&&(l=Vv(t)),r){const f=Pc(t,!0,i,t);c.x=f.x+t.clientLeft,c.y=f.y+t.clientTop}else s&&u();i&&!r&&s&&u();const d=s&&!r&&!i?c5(s,l):yi(0),h=o.left+l.scrollLeft-c.x-d.x,m=o.top+l.scrollTop-c.y-d.y;return{x:h,y:m,width:o.width,height:o.height}}function iw(e){return Vs(e).position==="static"}function MP(e,t){if(!wi(e)||Vs(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ni(e)===n&&(n=n.ownerDocument.body),n}function d5(e,t){const n=Fa(e);if(Gv(e))return n;if(!wi(e)){let s=xl(e);for(;s&&!Sd(s);){if(Gs(s)&&!iw(s))return s;s=xl(s)}return n}let r=MP(e,t);for(;r&&hV(r)&&iw(r);)r=MP(r,t);return r&&Sd(r)&&iw(r)&&!mC(r)?n:r||xV(e)||n}const AV=async function(e){const t=this.getOffsetParent||d5,n=this.getDimensions,r=await n(e.floating);return{reference:OV(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function TV(e){return Vs(e).direction==="rtl"}const MV={convertOffsetParentRelativeRectToViewportRelativeRect:wV,getDocumentElement:Ni,getClippingRect:EV,getOffsetParent:d5,getElementRects:AV,getClientRects:_V,getDimensions:PV,getScale:Ju,isElement:Gs,isRTL:TV};function h5(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function DV(e,t){let n=null,r;const s=Ni(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const u=e.getBoundingClientRect(),{left:d,top:h,width:m,height:f}=u;if(l||t(),!m||!f)return;const x=mg(h),g=mg(s.clientWidth-(d+m)),p=mg(s.clientHeight-(h+f)),v=mg(d),w={rootMargin:-x+"px "+-g+"px "+-p+"px "+-v+"px",threshold:Da(0,gl(1,c))||1};let N=!0;function j(_){const S=_[0].intersectionRatio;if(S!==c){if(!N)return o();S?o(!1,S):r=setTimeout(()=>{o(!1,1e-7)},1e3)}S===1&&!h5(u,e.getBoundingClientRect())&&o(),N=!1}try{n=new IntersectionObserver(j,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(j,w)}n.observe(e)}return o(!0),i}function $V(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=gC(e),d=s||i?[...u?am(u):[],...am(t)]:[];d.forEach(v=>{s&&v.addEventListener("scroll",n,{passive:!0}),i&&v.addEventListener("resize",n)});const h=u&&l?DV(u,n):null;let m=-1,f=null;o&&(f=new ResizeObserver(v=>{let[b]=v;b&&b.target===u&&f&&(f.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var w;(w=f)==null||w.observe(t)})),n()}),u&&!c&&f.observe(u),f.observe(t));let x,g=c?Pc(e):null;c&&p();function p(){const v=Pc(e);g&&!h5(g,v)&&n(),g=v,x=requestAnimationFrame(p)}return n(),()=>{var v;d.forEach(b=>{s&&b.removeEventListener("scroll",n),i&&b.removeEventListener("resize",n)}),h==null||h(),(v=f)==null||v.disconnect(),f=null,c&&cancelAnimationFrame(x)}}const RV=iV,IV=oV,LV=rV,FV=cV,qV=aV,DP=nV,zV=lV,BV=(e,t,n)=>{const r=new Map,s={platform:MV,...n},i={...s.platform,_c:r};return tV(e,t,{...s,platform:i})};var UV=typeof document<"u",WV=function(){},hx=UV?y.useLayoutEffect:WV;function Xx(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Xx(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&e.$$typeof)&&!Xx(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function f5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $P(e,t){const n=f5(e);return Math.round(t*n)/n}function ow(e){const t=y.useRef(e);return hx(()=>{t.current=e}),t}function KV(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[d,h]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,f]=y.useState(r);Xx(m,r)||f(r);const[x,g]=y.useState(null),[p,v]=y.useState(null),b=y.useCallback($=>{$!==_.current&&(_.current=$,g($))},[]),w=y.useCallback($=>{$!==S.current&&(S.current=$,v($))},[]),N=i||x,j=o||p,_=y.useRef(null),S=y.useRef(null),P=y.useRef(d),k=c!=null,C=ow(c),T=ow(s),O=ow(u),L=y.useCallback(()=>{if(!_.current||!S.current)return;const $={placement:t,strategy:n,middleware:m};T.current&&($.platform=T.current),BV(_.current,S.current,$).then(M=>{const B={...M,isPositioned:O.current!==!1};E.current&&!Xx(P.current,B)&&(P.current=B,Kc.flushSync(()=>{h(B)}))})},[m,t,n,T,O]);hx(()=>{u===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,h($=>({...$,isPositioned:!1})))},[u]);const E=y.useRef(!1);hx(()=>(E.current=!0,()=>{E.current=!1}),[]),hx(()=>{if(N&&(_.current=N),j&&(S.current=j),N&&j){if(C.current)return C.current(N,j,L);L()}},[N,j,L,C,k]);const R=y.useMemo(()=>({reference:_,floating:S,setReference:b,setFloating:w}),[b,w]),q=y.useMemo(()=>({reference:N,floating:j}),[N,j]),I=y.useMemo(()=>{const $={position:n,left:0,top:0};if(!q.floating)return $;const M=$P(q.floating,d.x),B=$P(q.floating,d.y);return l?{...$,transform:"translate("+M+"px, "+B+"px)",...f5(q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:B}},[n,l,q.floating,d.x,d.y]);return y.useMemo(()=>({...d,update:L,refs:R,elements:q,floatingStyles:I}),[d,L,R,q,I])}const HV=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?DP({element:r.current,padding:s}).fn(n):{}:r?DP({element:r,padding:s}).fn(n):{}}}},GV=(e,t)=>({...RV(e),options:[e,t]}),VV=(e,t)=>({...IV(e),options:[e,t]}),YV=(e,t)=>({...zV(e),options:[e,t]}),QV=(e,t)=>({...LV(e),options:[e,t]}),XV=(e,t)=>({...FV(e),options:[e,t]}),JV=(e,t)=>({...qV(e),options:[e,t]}),ZV=(e,t)=>({...HV(e),options:[e,t]});var eY="Arrow",m5=y.forwardRef((e,t)=>{const{children:n,width:r=10,height:s=5,...i}=e;return a.jsx(tt.svg,{...i,ref:t,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:a.jsx("polygon",{points:"0,0 30,0 15,10"})})});m5.displayName=eY;var tY=m5;function yC(e){const[t,n]=y.useState(void 0);return dr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let o,l;if("borderBoxSize"in i){const c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;o=u.inlineSize,l=u.blockSize}else o=e.offsetWidth,l=e.offsetHeight;n({width:o,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var vC="Popper",[p5,Si]=jr(vC),[nY,g5]=p5(vC),x5=e=>{const{__scopePopper:t,children:n}=e,[r,s]=y.useState(null);return a.jsx(nY,{scope:t,anchor:r,onAnchorChange:s,children:n})};x5.displayName=vC;var y5="PopperAnchor",v5=y.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,i=g5(y5,n),o=y.useRef(null),l=Ct(t,o);return y.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:a.jsx(tt.div,{...s,ref:l})});v5.displayName=y5;var bC="PopperContent",[rY,aY]=p5(bC),b5=y.forwardRef((e,t)=>{var te,J,re,pe,ye,X;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:i="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:m=!1,updatePositionStrategy:f="optimized",onPlaced:x,...g}=e,p=g5(bC,n),[v,b]=y.useState(null),w=Ct(t,he=>b(he)),[N,j]=y.useState(null),_=yC(N),S=(_==null?void 0:_.width)??0,P=(_==null?void 0:_.height)??0,k=r+(i!=="center"?"-"+i:""),C=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},T=Array.isArray(u)?u:[u],O=T.length>0,L={padding:C,boundary:T.filter(iY),altBoundary:O},{refs:E,floatingStyles:R,placement:q,isPositioned:I,middlewareData:$}=KV({strategy:"fixed",placement:k,whileElementsMounted:(...he)=>$V(...he,{animationFrame:f==="always"}),elements:{reference:p.anchor},middleware:[GV({mainAxis:s+P,alignmentAxis:o}),c&&VV({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?YV():void 0,...L}),c&&QV({...L}),XV({...L,apply:({elements:he,rects:D,availableWidth:le,availableHeight:V})=>{const{width:U,height:z}=D.reference,Z=he.floating.style;Z.setProperty("--radix-popper-available-width",`${le}px`),Z.setProperty("--radix-popper-available-height",`${V}px`),Z.setProperty("--radix-popper-anchor-width",`${U}px`),Z.setProperty("--radix-popper-anchor-height",`${z}px`)}}),N&&ZV({element:N,padding:l}),oY({arrowWidth:S,arrowHeight:P}),m&&JV({strategy:"referenceHidden",...L})]}),[M,B]=j5(q),W=Kn(x);
vendor: 4,246 bytes, line 586
586dr(()=>{I&&(W==null||W())},[I,W]);const A=(te=$.arrow)==null?void 0:te.x,K=(J=$.arrow)==null?void 0:J.y,G=((re=$.arrow)==null?void 0:re.centerOffset)!==0,[H,fe]=y.useState();return dr(()=>{v&&fe(window.getComputedStyle(v).zIndex)},[v]),a.jsx("div",{ref:E.setFloating,"data-radix-popper-content-wrapper":"",style:{...R,transform:I?R.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:H,"--radix-popper-transform-origin":[(pe=$.transformOrigin)==null?void 0:pe.x,(ye=$.transformOrigin)==null?void 0:ye.y].join(" "),...((X=$.hide)==null?void 0:X.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:a.jsx(rY,{scope:n,placedSide:M,onArrowChange:j,arrowX:A,arrowY:K,shouldHideArrow:G,children:a.jsx(tt.div,{"data-side":M,"data-align":B,...g,ref:w,style:{...g.style,animation:I?void 0:"none"}})})})});b5.displayName=bC;var w5="PopperArrow",sY={top:"bottom",right:"left",bottom:"top",left:"right"},_5=y.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,i=aY(w5,r),o=sY[i.placedSide];return a.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:a.jsx(tY,{...s,ref:n,style:{...s.style,display:"block"}})})});_5.displayName=w5;function iY(e){return e!==null}var oY=e=>({name:"transformOrigin",options:e,fn(t){var p,v,b;const{placement:n,rects:r,middlewareData:s}=t,o=((p=s.arrow)==null?void 0:p.centerOffset)!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[u,d]=j5(n),h={start:"0%",center:"50%",end:"100%"}[d],m=(((v=s.arrow)==null?void 0:v.x)??0)+l/2,f=(((b=s.arrow)==null?void 0:b.y)??0)+c/2;let x="",g="";return u==="bottom"?(x=o?h:`${m}px`,g=`${-c}px`):u==="top"?(x=o?h:`${m}px`,g=`${r.floating.height+c}px`):u==="right"?(x=`${-c}px`,g=o?h:`${f}px`):u==="left"&&(x=`${r.floating.width+c}px`,g=o?h:`${f}px`),{data:{x,y:g}}}});function j5(e){const[t,n="center"]=e.split("-");return[t,n]}var pp=x5,ih=v5,gp=b5,xp=_5,[Yv,d3e]=jr("Tooltip",[Si]),Qv=Si(),N5="TooltipProvider",lY=700,Oj="tooltip.open",[cY,wC]=Yv(N5),S5=e=>{const{__scopeTooltip:t,delayDuration:n=lY,skipDelayDuration:r=300,disableHoverableContent:s=!1,children:i}=e,o=y.useRef(!0),l=y.useRef(!1),c=y.useRef(0);return y.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),a.jsx(cY,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:y.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:y.useCallback(u=>{l.current=u},[]),disableHoverableContent:s,children:i})};S5.displayName=N5;var sm="Tooltip",[uY,Xv]=Yv(sm),C5=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:s,onOpenChange:i,disableHoverableContent:o,delayDuration:l}=e,c=wC(sm,e.__scopeTooltip),u=Qv(t),[d,h]=y.useState(null),m=Zn(),f=y.useRef(0),x=o??c.disableHoverableContent,g=l??c.delayDuration,p=y.useRef(!1),[v,b]=oa({prop:r,defaultProp:s??!1,onChange:S=>{S?(c.onOpen(),document.dispatchEvent(new CustomEvent(Oj))):c.onClose(),i==null||i(S)},caller:sm}),w=y.useMemo(()=>v?p.current?"delayed-open":"instant-open":"closed",[v]),N=y.useCallback(()=>{window.clearTimeout(f.current),f.current=0,p.current=!1,b(!0)},[b]),j=y.useCallback(()=>{window.clearTimeout(f.current),f.current=0,b(!1)},[b]),_=y.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{p.current=!0,b(!0),f.current=0},g)},[g,b]);return y.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),a.jsx(pp,{...u,children:a.jsx(uY,{scope:t,contentId:m,open:v,stateAttribute:w,trigger:d,onTriggerChange:h,onTriggerEnter:y.useCallback(()=>{c.isOpenDelayedRef.current?_():N()},[c.isOpenDelayedRef,_,N]),onTriggerLeave:y.useCallback(()=>{x?j():(window.clearTimeout(f.current),f.current=0)},[j,x]),onOpen:N,onClose:j,disableHoverableContent:x,children:n})})};C5.displayName=sm;var Aj="TooltipTrigger",k5=y.forwardRef((e,t)=>
vendor: 4,427 bytes, line 586
586{const{__scopeTooltip:n,...r}=e,s=Xv(Aj,n),i=wC(Aj,n),o=Qv(n),l=y.useRef(null),c=Ct(t,l,s.onTriggerChange),u=y.useRef(!1),d=y.useRef(!1),h=y.useCallback(()=>u.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),a.jsx(ih,{asChild:!0,...o,children:a.jsx(tt.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...r,ref:c,onPointerMove:Fe(e.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(s.onTriggerEnter(),d.current=!0)}),onPointerLeave:Fe(e.onPointerLeave,()=>{s.onTriggerLeave(),d.current=!1}),onPointerDown:Fe(e.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Fe(e.onFocus,()=>{u.current||s.onOpen()}),onBlur:Fe(e.onBlur,s.onClose),onClick:Fe(e.onClick,s.onClose)})})});k5.displayName=Aj;var dY="TooltipPortal",[h3e,hY]=Yv(dY,{forceMount:void 0}),Cd="TooltipContent",E5=y.forwardRef((e,t)=>{const n=hY(Cd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:s="top",...i}=e,o=Xv(Cd,e.__scopeTooltip);return a.jsx(tr,{present:r||o.open,children:o.disableHoverableContent?a.jsx(P5,{side:s,...i,ref:t}):a.jsx(fY,{side:s,...i,ref:t})})}),fY=y.forwardRef((e,t)=>{const n=Xv(Cd,e.__scopeTooltip),r=wC(Cd,e.__scopeTooltip),s=y.useRef(null),i=Ct(t,s),[o,l]=y.useState(null),{trigger:c,onClose:u}=n,d=s.current,{onPointerInTransitChange:h}=r,m=y.useCallback(()=>{l(null),h(!1)},[h]),f=y.useCallback((x,g)=>{const p=x.currentTarget,v={x:x.clientX,y:x.clientY},b=yY(v,p.getBoundingClientRect()),w=vY(v,b),N=bY(g.getBoundingClientRect()),j=_Y([...w,...N]);l(j),h(!0)},[h]);return y.useEffect(()=>()=>m(),[m]),y.useEffect(()=>{if(c&&d){const x=p=>f(p,d),g=p=>f(p,c);return c.addEventListener("pointerleave",x),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",x),d.removeEventListener("pointerleave",g)}}},[c,d,f,m]),y.useEffect(()=>{if(o){const x=g=>{const p=g.target,v={x:g.clientX,y:g.clientY},b=(c==null?void 0:c.contains(p))||(d==null?void 0:d.contains(p)),w=!wY(v,o);b?m():w&&(m(),u())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,d,o,u,m]),a.jsx(P5,{...e,ref:i})}),[mY,pY]=Yv(sm,{isInside:!1}),gY=t3("TooltipContent"),P5=y.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":s,onEscapeKeyDown:i,onPointerDownOutside:o,...l}=e,c=Xv(Cd,n),u=Qv(n),{onClose:d}=c;return y.useEffect(()=>(document.addEventListener(Oj,d),()=>document.removeEventListener(Oj,d)),[d]),y.useEffect(()=>{if(c.trigger){const h=m=>{const f=m.target;f!=null&&f.contains(c.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,d]),a.jsx(jl,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:a.jsxs(gp,{"data-state":c.stateAttribute,...u,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[a.jsx(gY,{children:r}),a.jsx(mY,{scope:n,isInside:!0,children:a.jsx(NK,{id:c.contentId,role:"tooltip",children:s||r})})]})})});E5.displayName=Cd;var O5="TooltipArrow",xY=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,s=Qv(n);return pY(O5,n).isInside?null:a.jsx(xp,{...s,...r,ref:t})});xY.displayName=O5;function yY(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),s=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,s,i)){case i:return"left";case s:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function vY(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function bY(e){const{top:t,right:n,bottom:r,left:s}=e;return[{x:s,y:t},{x:n,y:t},{x:n,y:r},{x:s,y:r}]}function wY(e,t){const{x:n,y:r}=e;let s=!1;for(let i=0,o=t.length-1;i<t.length;
586o=i++){const l=t[i],c=t[o],u=l.x,d=l.y,h=c.x,m=c.y;d>r!=m>r&&n<(h-u)*(r-d)/(m-d)+u&&(s=!s)}return s}function _Y(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),jY(t)}function jY(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const s=e[r];for(;t.length>=2;){const i=t[t.length-1],o=t[t.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))t.pop();else break}t.push(s)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const s=e[r];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))n.pop();else break}n.push(s)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var NY=S5,SY=C5,CY=k5,A5=E5;const kY=NY,T5=SY,M5=CY,_C=y.forwardRef(({className:e,sideOffset:t=4,...n},r)=>a.jsx(A5,{ref:r,sideOffset:t,className:Se("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));_C.displayName=A5.displayName;var oh=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(){}},Oc=typeof window>"u"||"Deno"in globalThis;function ea(){}function EY(e,t){return typeof e=="function"?e(t):e}function Tj(e){return typeof e=="number"&&e>=0&&e!==1/0}function D5(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ol(e,t){return typeof e=="function"?e(t):e}function es(e,t){return typeof e=="function"?e(t):e}function RP(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:o,stale:l}=e;if(o){if(r){if(t.queryHash!==jC(o,t.options))return!1}else if(!im(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||s&&s!==t.state.fetchStatus||i&&!i(t))}function IP(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(Ac(t.options.mutationKey)!==Ac(i))return!1}else if(!im(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function jC(e,t){return((t==null?void 0:t.queryKeyHashFn)||Ac)(e)}function Ac(e){return JSON.stringify(e,(t,n)=>Mj(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function im(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>im(e[n],t[n])):!1}function $5(e,t){if(e===t)return e;const n=LP(e)&&LP(t);if(n||Mj(e)&&Mj(t)){const r=n?e:Object.keys(e),s=r.length,i=n?t:Object.keys(t),o=i.length,l=n?[]:{},c=new Set(r);let u=0;for(let d=0;d<o;d++){const h=n?d:i[d];(!n&&c.has(h)||n)&&e[h]===void 0&&t[h]===void 0?(l[h]=void 0,u++):(l[h]=$5(e[h],t[h]),l[h]===e[h]&&e[h]!==void 0&&u++)}return s===o&&u===s?e:l}return t}function Jx(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function LP(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Mj(e){if(!FP(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!FP(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function FP(e){return Object.prototype.toString.call(e)==="[object Object]"}function PY(e){return new Promise(t=>{setTimeout(t,e)})}function Dj(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?$5(e,t):t}function OY(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function AY(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var NC=Symbol();function R5(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===NC?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function I5(e,t){return typeof e=="function"?e(...t):!!e}var lc,Lo,id,O$,TY=(O$=class extends oh{constructor(){super();xt(this,lc);xt(this,Lo);xt(this,id);st(this,id,t=>{if(!Oc&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){me(this,Lo)||this.setEventListener(me(this,id))}onUnsubscribe(){var t;
vendor: 5,267 bytes, line 586
586this.hasListeners()||((t=me(this,Lo))==null||t.call(this),st(this,Lo,void 0))}setEventListener(t){var n;st(this,id,t),(n=me(this,Lo))==null||n.call(this),st(this,Lo,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){me(this,lc)!==t&&(st(this,lc,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof me(this,lc)=="boolean"?me(this,lc):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},lc=new WeakMap,Lo=new WeakMap,id=new WeakMap,O$),SC=new TY,od,Fo,ld,A$,MY=(A$=class extends oh{constructor(){super();xt(this,od,!0);xt(this,Fo);xt(this,ld);st(this,ld,t=>{if(!Oc&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){me(this,Fo)||this.setEventListener(me(this,ld))}onUnsubscribe(){var t;this.hasListeners()||((t=me(this,Fo))==null||t.call(this),st(this,Fo,void 0))}setEventListener(t){var n;st(this,ld,t),(n=me(this,Fo))==null||n.call(this),st(this,Fo,t(this.setOnline.bind(this)))}setOnline(t){me(this,od)!==t&&(st(this,od,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return me(this,od)}},od=new WeakMap,Fo=new WeakMap,ld=new WeakMap,A$),Zx=new MY;function $j(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}function DY(e){return Math.min(1e3*2**e,3e4)}function L5(e){return(e??"online")==="online"?Zx.isOnline():!0}var F5=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function lw(e){return e instanceof F5}function q5(e){let t=!1,n=0,r=!1,s;const i=$j(),o=g=>{var p;r||(m(new F5(g)),(p=e.abort)==null||p.call(e))},l=()=>{t=!0},c=()=>{t=!1},u=()=>SC.isFocused()&&(e.networkMode==="always"||Zx.isOnline())&&e.canRun(),d=()=>L5(e.networkMode)&&e.canRun(),h=g=>{var p;r||(r=!0,(p=e.onSuccess)==null||p.call(e,g),s==null||s(),i.resolve(g))},m=g=>{var p;r||(r=!0,(p=e.onError)==null||p.call(e,g),s==null||s(),i.reject(g))},f=()=>new Promise(g=>{var p;s=v=>{(r||u())&&g(v)},(p=e.onPause)==null||p.call(e)}).then(()=>{var g;s=void 0,r||(g=e.onContinue)==null||g.call(e)}),x=()=>{if(r)return;let g;const p=n===0?e.initialPromise:void 0;try{g=p??e.fn()}catch(v){g=Promise.reject(v)}Promise.resolve(g).then(h).catch(v=>{var _;if(r)return;const b=e.retry??(Oc?0:3),w=e.retryDelay??DY,N=typeof w=="function"?w(n,v):w,j=b===!0||typeof b=="number"&&n<b||typeof b=="function"&&b(n,v);if(t||!j){m(v);return}n++,(_=e.onFail)==null||_.call(e,n,v),PY(N).then(()=>u()?void 0:f()).then(()=>{t?m(v):x()})})};return{promise:i,cancel:o,continue:()=>(s==null||s(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():f().then(x),i)}}var $Y=e=>setTimeout(e,0);function RY(){let e=[],t=0,n=l=>{l()},r=l=>{l()},s=$Y;const i=l=>{t?e.push(l):s(()=>{n(l)})},o=()=>{const l=e;e=[],l.length&&s(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{s=l}}}var lr=RY(),cc,T$,z5=(T$=class{constructor(){xt(this,cc)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Tj(this.gcTime)&&st(this,cc,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Oc?1/0:5*60*1e3))}clearGcTimeout(){me(this,cc)&&(clearTimeout(me(this,cc)),st(this,cc,void 0))}},cc=new WeakMap,T$),cd,uc,Za,dc,qr,np,hc,As,Mi,M$,IY=(M$=class extends z5{constructor(t){super();xt(this,As);xt(this,cd);xt(this,uc);xt(this,Za);xt(this,dc);xt(this,qr);xt(this,np);xt(this,hc);st(this,hc,!1),st(this,np,t.defaultOptions),this.setOptions(t.options),this.observers=[],st(this,dc,t.client),st(this,Za,me(this,dc).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,st(this,cd,LY(this.options)),this.state=t.state??me(this,cd),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=me(this,qr))==null?void 0:t.promise}setOptions(t){this.options={...me(this,np),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&me(this,Za).remove(this)}setData(t,n){const r=Dj(this.state.data,t,this.options);return Ft(this,As,Mi).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Ft(this,As,Mi).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=me(this,qr))==null?void 0:r.promise;return(s=me(this,qr))==null||s.cancel(t),n?n.then(ea).catch(ea):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(me(this,cd))}isActive(){return this.observers.some(t=>es(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===NC||this.state.dataUpdateCount+this.state.errorUpdate
vendor: 1,282 bytes, line 586
586Count===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>ol(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!D5(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=me(this,qr))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=me(this,qr))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),me(this,Za).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(me(this,qr)&&(me(this,hc)?me(this,qr).cancel({revert:!0}):me(this,qr).cancelRetry()),this.scheduleGc()),me(this,Za).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ft(this,As,Mi).call(this,{type:"invalidate"})}
vendor: 8,872 bytes, line 586
586fetch(t,n){var u,d,h;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(me(this,qr))return me(this,qr).continueRetry(),me(this,qr).promise}if(t&&this.setOptions(t),!this.options.queryFn){const m=this.observers.find(f=>f.options.queryFn);m&&this.setOptions(m.options)}const r=new AbortController,s=m=>{Object.defineProperty(m,"signal",{enumerable:!0,get:()=>(st(this,hc,!0),r.signal)})},i=()=>{const m=R5(this.options,n),x=(()=>{const g={client:me(this,dc),queryKey:this.queryKey,meta:this.meta};return s(g),g})();return st(this,hc,!1),this.options.persister?this.options.persister(m,x,this):m(x)},l=(()=>{const m={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:me(this,dc),state:this.state,fetchFn:i};return s(m),m})();(u=this.options.behavior)==null||u.onFetch(l,this),st(this,uc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&Ft(this,As,Mi).call(this,{type:"fetch",meta:(h=l.fetchOptions)==null?void 0:h.meta});const c=m=>{var f,x,g,p;lw(m)&&m.silent||Ft(this,As,Mi).call(this,{type:"error",error:m}),lw(m)||((x=(f=me(this,Za).config).onError)==null||x.call(f,m,this),(p=(g=me(this,Za).config).onSettled)==null||p.call(g,this.state.data,m,this)),this.scheduleGc()};return st(this,qr,q5({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,abort:r.abort.bind(r),onSuccess:m=>{var f,x,g,p;if(m===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(m)}catch(v){c(v);return}(x=(f=me(this,Za).config).onSuccess)==null||x.call(f,m,this),(p=(g=me(this,Za).config).onSettled)==null||p.call(g,m,this.state.error,this),this.scheduleGc()},onError:c,onFail:(m,f)=>{Ft(this,As,Mi).call(this,{type:"failed",failureCount:m,error:f})},onPause:()=>{Ft(this,As,Mi).call(this,{type:"pause"})},onContinue:()=>{Ft(this,As,Mi).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0})),me(this,qr).start()}},cd=new WeakMap,uc=new WeakMap,Za=new WeakMap,dc=new WeakMap,qr=new WeakMap,np=new WeakMap,hc=new WeakMap,As=new WeakSet,Mi=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...B5(r.data,this.options),fetchMeta:t.meta??null};case"success":return st(this,uc,void 0),{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const s=t.error;return lw(s)&&s.revert&&me(this,uc)?{...me(this,uc),fetchStatus:"idle"}:{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),lr.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),me(this,Za).notify({query:this,type:"updated",action:t})})},M$);function B5(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:L5(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function LY(e){const 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 oi,D$,FY=(D$=class extends oh{constructor(t={}){super();xt(this,oi);this.config=t,st(this,oi,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??jC(s,n);let o=this.get(i);return o||(o=new IY({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){me(this,oi).has(t.queryHash)||(me(this,oi).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=me(this,oi).get(t.queryHash);n&&(t.destroy(),n===t&&me(this,oi).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){lr.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return me(this,oi).get(t)}getAll(){return[...me(this,oi).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>RP(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>RP(t,r)):n}notify(t){lr.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){lr.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){lr.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},oi=new WeakMap,D$),li,Yr,fc,ci,Eo,$$,qY=($$=class extends z5{constructor(t){super();xt(this,ci);xt(this,li);xt(this,Yr);xt(this,fc);this.mutationId=t.mutationId,st(this,Yr,t.mutationCache),st(this,li,[]),this.state=t.state||U5(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){me(this,li).includes(t)||(me(this,li).push(t),this.clearGcTimeout(),me(this,Yr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){st(this,li,me(this,li).filter(n=>n!==t)),this.scheduleGc(),me(this,Yr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){me(this,li).length||(this.state.status==="pending"?this.scheduleGc():me(this,Yr).remove(this))}continue(){var t;return((t=me(this,fc))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,o,l,c,u,d,h,m,f,x,g,p,v,b,w,N,j,_,S,P;const n=()=>{Ft(this,ci,Eo).call(this,{type:"continue"})};st(this,fc,q5({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(k,C)=>{Ft(this,ci,Eo).call(this,{type:"failed",failureCount:k,error:C})},onPause:()=>{Ft(this,ci,Eo).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>me(this,Yr).canRun(this)}));const r=this.state.status==="pending",s=!me(this,fc).canStart();try{if(r)n();else{Ft(this,ci,Eo).call(this,{type:"pending",variables:t,isPaused:s}),await((o=(i=me(this,Yr).config).onMutate)==null?void 0:o.call(i,t,this));const C=await((c=(l=this.options).onMutate)==null?void 0:c.call(l,t));C!==this.state.context&&Ft(this,ci,Eo).call(this,{type:"pending",context:C,variables:t,isPaused:s})}const k=await me(this,fc).start();return await((d=(u=me(this,Yr).config).onSuccess)==null?void 0:d.call(u,k,t,this.state.context,this)),await((m=(h=this.options).onSuccess)==null?void 0:m.call(h,k,t,this.state.context)),await((x=(f=me(this,Yr).config).onSettled)==null?void 0:x.call(f,k,null,this.state.variables,this.state.context,this)),await((p=(g=this.options).onSettled)==null?void 0:p.call(g,k,null,t,this.state.context)),Ft(this,ci,Eo).call(this,{type:"success",data:k}),k}catch(k){try{throw await((b=(v=me(this,Yr).config).onError)==null?void 0:b.call(v,k,t,this.state.context,this)),await((N=(w=this.options).onError)==null?void 0:N.call(w,k,t,this.state.context)),await((_=(j=me(this,Yr).config).onSettled)==null?void 0:_.call(j,void 0,k,this.state.variables,this.state.context,this)),await((P=(S=this.options).onSettled)==null?void 0:P.call(S,void 0,k,t,this.state.context)),k}finally{Ft(this,ci,Eo).call(this,{type:"error",error:k})}}finally{me(this,Yr).runNext(this)}}},li=new WeakMap,Yr=new WeakMap,fc=new WeakMap,ci=new WeakSet,Eo=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),lr.batch(()=>{me(this,li).forEach(r=>{r.onMutationUpdate(t)}),me(this,Yr).notify({mutation:this,type:"updated",action:t})})},$$);function U5(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ii,Ts,rp,R$,zY=(R$=class extends oh{constructor(t={}){super();xt(this,Ii);xt(this,Ts);xt(this,rp);this.config=t,st(this,Ii,new Set),st(this,Ts,new Map),st(this,rp,
5860)}build(t,n,r){const s=new qY({mutationCache:this,mutationId:++Gp(this,rp)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){me(this,Ii).add(t);const n=pg(t);if(typeof n=="string"){const r=me(this,Ts).get(n);r?r.push(t):me(this,Ts).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(me(this,Ii).delete(t)){const n=pg(t);if(typeof n=="string"){const r=me(this,Ts).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&me(this,Ts).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=pg(t);if(typeof n=="string"){const r=me(this,Ts).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=pg(t);if(typeof n=="string"){const s=(r=me(this,Ts).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){lr.batch(()=>{me(this,Ii).forEach(t=>{this.notify({type:"removed",mutation:t})}),me(this,Ii).clear(),me(this,Ts).clear()})}getAll(){return Array.from(me(this,Ii))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>IP(n,r))}findAll(t={}){return this.getAll().filter(n=>IP(t,n))}notify(t){lr.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return lr.batch(()=>Promise.all(t.map(n=>n.continue().catch(ea))))}},Ii=new WeakMap,Ts=new WeakMap,rp=new WeakMap,R$);function pg(e){var t;return(t=e.options.scope)==null?void 0:t.id}function qP(e){return{onFetch:(t,n)=>{var d,h,m,f,x;const r=t.options,s=(m=(h=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:h.fetchMore)==null?void 0:m.direction,i=((f=t.state.data)==null?void 0:f.pages)||[],o=((x=t.state.data)==null?void 0:x.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let g=!1;const p=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(t.signal.aborted?g=!0:t.signal.addEventListener("abort",()=>{g=!0}),t.signal)})},v=R5(t.options,t.fetchOptions),b=async(w,N,j)=>{if(g)return Promise.reject();if(N==null&&w.pages.length)return Promise.resolve(w);const S=(()=>{const T={client:t.client,queryKey:t.queryKey,pageParam:N,direction:j?"backward":"forward",meta:t.options.meta};return p(T),T})(),P=await v(S),{maxPages:k}=t.options,C=j?AY:OY;return{pages:C(w.pages,P,k),pageParams:C(w.pageParams,N,k)}};if(s&&i.length){const w=s==="backward",N=w?BY:zP,j={pages:i,pageParams:o},_=N(r,j);l=await b(j,_,w)}else{const w=e??i.length;do{const N=c===0?o[0]??r.initialPageParam:zP(r,l);if(c>0&&N==null)break;l=await b(l,N),c++}while(c<w)}return l};t.options.persister?t.fetchFn=()=>{var g,p;return(p=(g=t.options).persister)==null?void 0:p.call(g,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function zP(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function BY(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var In,qo,zo,ud,dd,Bo,hd,fd,I$,UY=(I$=class{constructor(e={}){xt(this,In);xt(this,qo);xt(this,zo);xt(this,ud);xt(this,dd);xt(this,Bo);xt(this,hd);xt(this,fd);st(this,In,e.queryCache||new FY),st(this,qo,e.mutationCache||new zY),st(this,zo,e.defaultOptions||{}),st(this,ud,new Map),st(this,dd,new Map),st(this,Bo,0)}mount(){Gp(this,Bo)._++,me(this,Bo)===1&&(st(this,hd,SC.subscribe(async e=>{e&&(await this.resumePausedMutations(),me(this,In).onFocus())})),st(this,fd,Zx.subscribe(async e=>{e&&(await this.resumePausedMutations(),me(this,In).onOnline())})))}unmount(){var e,t;Gp(this,Bo)._--,me(this,Bo)===0&&((e=me(this,hd))==null||e.call(this),st(this,hd,void 0),(t=me(this,fd))==null||t.call(this),st(this,fd,void 0))}isFetching(e){return me(this,In).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return me(this,qo).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=me(this,In).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=me(this,In).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ol(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return me(this,In).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=me(this,In).get(r.queryHash),i=s==null?void 0:s.state.data,o=EY(t,i);if(o!==void 0)return me(this,In).build(this,r).setData(o,{...n,manual:!0})}
vendor: 13,221 bytes, line 586
586setQueriesData(e,t,n){return lr.batch(()=>me(this,In).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=me(this,In).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=me(this,In);lr.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=me(this,In);return lr.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=lr.batch(()=>me(this,In).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(ea).catch(ea)}invalidateQueries(e,t={}){return lr.batch(()=>(me(this,In).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=lr.batch(()=>me(this,In).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(ea)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(ea)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=me(this,In).build(this,t);return n.isStaleByTime(ol(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ea).catch(ea)}fetchInfiniteQuery(e){return e.behavior=qP(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ea).catch(ea)}ensureInfiniteQueryData(e){return e.behavior=qP(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Zx.isOnline()?me(this,qo).resumePausedMutations():Promise.resolve()}getQueryCache(){return me(this,In)}getMutationCache(){return me(this,qo)}getDefaultOptions(){return me(this,zo)}setDefaultOptions(e){st(this,zo,e)}setQueryDefaults(e,t){me(this,ud).set(Ac(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...me(this,ud).values()],n={};return t.forEach(r=>{im(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){me(this,dd).set(Ac(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...me(this,dd).values()],n={};return t.forEach(r=>{im(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...me(this,zo).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=jC(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===NC&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...me(this,zo).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){me(this,In).clear(),me(this,qo).clear()}},In=new WeakMap,qo=new WeakMap,zo=new WeakMap,ud=new WeakMap,dd=new WeakMap,Bo=new WeakMap,hd=new WeakMap,fd=new WeakMap,I$),da,Vt,ap,Qr,mc,md,Uo,Wo,sp,pd,gd,pc,gc,Ko,xd,an,df,Rj,Ij,Lj,Fj,qj,zj,Bj,W5,L$,WY=(L$=class extends oh{constructor(t,n){super();xt(this,an);xt(this,da);xt(this,Vt);xt(this,ap);xt(this,Qr);xt(this,mc);xt(this,md);xt(this,Uo);xt(this,Wo);xt(this,sp);xt(this,pd);xt(this,gd);xt(this,pc);xt(this,gc);xt(this,Ko);xt(this,xd,new Set);this.options=n,st(this,da,t),st(this,Wo,null),st(this,Uo,$j()),this.options.experimental_prefetchInRender||me(this,Uo).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(me(this,Vt).addObserver(this),BP(me(this,Vt),this.options)?Ft(this,an,df).call(this):this.updateResult(),Ft(this,an,Fj).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Uj(me(this,Vt),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Uj(me(this,Vt),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ft(this,an,qj).call(this),Ft(this,an,zj).call(this),me(this,Vt).removeObserver(this)}setOptions(t){const n=this.options,r=me(this,Vt);if(this.options=me(this,da).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof es(this.options.enabled,me(this,Vt))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ft(this,an,Bj).call(this),me(this,Vt).setOptions(this.options),n._defaulted&&!Jx(this.options,n)&&me(this,da).getQueryCache().notify({type:"observerOptionsUpdated",query:me(this,Vt),observer:this});const s=this.hasListeners();s&&UP(me(this,Vt),r,this.options,n)&&Ft(this,an,df).call(this),this.updateResult(),s&&(me(this,Vt)!==r||es(this.options.enabled,me(this,Vt))!==es(n.enabled,me(this,Vt))||ol(this.options.staleTime,me(this,Vt))!==ol(n.staleTime,me(this,Vt)))&&Ft(this,an,Rj).call(this);const i=Ft(this,an,Ij).call(this);s&&(me(this,Vt)!==r||es(this.options.enabled,me(this,Vt))!==es(n.enabled,me(this,Vt))||i!==me(this,Ko))&&Ft(this,an,Lj).call(this,i)}getOptimisticResult(t){const n=me(this,da).getQueryCache().build(me(this,da),t),r=this.createResult(n,t);return HY(this,r)&&(st(this,Qr,r),st(this,md,this.options),st(this,mc,me(this,Vt).state)),r}getCurrentResult(){return me(this,Qr)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),Reflect.get(r,s))})}trackProp(t){me(this,xd).add(t)}getCurrentQuery(){return me(this,Vt)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=me(this,da).defaultQueryOptions(t),r=me(this,da).getQueryCache().build(me(this,da),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Ft(this,an,df).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),me(this,Qr)))}createResult(t,n){var k;const r=me(this,Vt),s=this.options,i=me(this,Qr),o=me(this,mc),l=me(this,md),u=t!==r?t.state:me(this,ap),{state:d}=t;let h={...d},m=!1,f;if(n._optimisticResults){const C=this.hasListeners(),T=!C&&BP(t,n),O=C&&UP(t,r,n,s);(T||O)&&(h={...h,...B5(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:x,errorUpdatedAt:g,status:p}=h;f=h.data;let v=!1;if(n.placeholderData!==void 0&&f===void 0&&p==="pending"){let C;i!=null&&i.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(C=i.data,v=!0):C=typeof n.placeholderData=="function"?n.placeholderData((k=me(this,gd))==null?void 0:k.state.data,me(this,gd)):n.placeholderData,C!==void 0&&(p="success",f=Dj(i==null?void 0:i.data,C,n),m=!0)}if(n.select&&f!==void 0&&!v)if(i&&f===(o==null?void 0:o.data)&&n.select===me(this,sp))f=me(this,pd);else try{st(this,sp,n.select),f=n.select(f),f=Dj(i==null?void 0:i.data,f,n),st(this,pd,f),st(this,Wo,null)}catch(C){st(this,Wo,C)}me(this,Wo)&&(x=me(this,Wo),f=me(this,pd),g=Date.now(),p="error");const b=h.fetchStatus==="fetching",w=p==="pending",N=p==="error",j=w&&b,_=f!==void 0,P={status:p,fetchStatus:h.fetchStatus,isPending:w,isSuccess:p==="success",isError:N,isInitialLoading:j,isLoading:j,data:f,dataUpdatedAt:h.dataUpdatedAt,error:x,errorUpdatedAt:g,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:b,isRefetching:b&&!w,isLoadingError:N&&!_,isPaused:h.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:N&&_,isStale:CC(t,n),refetch:this.refetch,promise:me(this,Uo),isEnabled:es(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const C=L=>{P.status==="error"?L.reject(P.error):P.data!==void 0&&L.resolve(P.data)},T=()=>{const L=st(this,Uo,P.promise=$j());C(L)},O=me(this,Uo);switch(O.status){case"pending":t.queryHash===r.queryHash&&C(O);break;case"fulfilled":(P.status==="error"||P.data!==O.value)&&T();break;case"rejected":(P.status!=="error"||P.error!==O.reason)&&T();break}}return P}updateResult(){const t=me(this,Qr),n=this.createResult(me(this,Vt),this.options);if(st(this,mc,me(this,Vt).state),st(this,md,this.options),me(this,mc).data!==void 0&&st(this,gd,me(this,Vt)),Jx(n,t))return;st(this,Qr,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!me(this,xd).size)return!0;const o=new Set(i??me(this,xd));return this.options.throwOnError&&o.add("error"),Object.keys(me(this,Qr)).some(l=>{const c=l;return me(this,Qr)[c]!==t[c]&&o.has(c)})};Ft(this,an,W5).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ft(this,an,Fj).call(this)}},da=new WeakMap,Vt=new WeakMap,ap=new WeakMap,Qr=new WeakMap,mc=new WeakMap,md=new WeakMap,Uo=new WeakMap,Wo=new WeakMap,sp=new WeakMap,pd=new WeakMap,gd=new WeakMap,pc=new WeakMap,gc=new WeakMap,Ko=new WeakMap,xd=new WeakMap,an=new WeakSet,df=function(t){Ft(this,an,Bj).call(this);let n=me(this,Vt).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(ea)),n},Rj=function(){Ft(this,an,qj).call(this);const t=ol(this.options.staleTime,me(this,Vt));if(Oc||me(this,Qr).isStale||!Tj(t))return;const r=D5(me(this,Qr).dataUpdatedAt,t)+1;st(this,pc,setTimeout(()=>{me(this,Qr).isStale||this.updateResult()},r))},Ij=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(me(this,Vt)):this.options.refetchInterval)??!1},Lj=function(t){Ft(this,an,zj).call(this),st(this,Ko,t),!(Oc||es(this.options.enabled,me(this,Vt))===!1||!Tj(me(this,Ko))||me(this,Ko)===0)&&st(this,gc,setInterval(()=>{(this.options.refetchIntervalInBackground||SC.isFocused())&&Ft(this,an,df).call(this)},me(this,Ko)))},Fj=function(){Ft(this,an,Rj).call(this),Ft(this,an,Lj).call(this,Ft(this,an,Ij).call(this))},qj=function(){me(this,pc)&&(clearTimeout(me(this,pc)),st(this,pc,void 0))},zj=function(){me(this,gc)&&(clearInterval(me(this,gc)),st(this,gc,void 0))},Bj=function(){const t=me(this,da).getQueryCache().build(me(this,da),this.options);if(t===me(this,Vt))return;const n=me(this,Vt);st(this,Vt,t),st(this,ap,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},W5=function(t){lr.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(me(this,Qr))}),me(this,da).getQueryCache().notify({query:me(this,Vt),type:"observerResultsUpdated"})})},L$);function KY(e,t){return es(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function BP(e,t){return KY(e,t)||e.state.data!==void 0&&Uj(e,t,t.refetchOnMount)}function Uj(e,t,n){if(es(t.enabled,e)!==!1&&ol(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&CC(e,t)}return!1}function UP(e,t,n,r){return(e!==t||es(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&CC(e,n)}function CC(e,t){return es(t.enabled,e)!==!1&&e.isStaleByTime(ol(t.staleTime,e))}function HY(e,t){return!Jx(e.getCurrentResult(),t)}var Ho,Go,ha,Li,Ji,fx,Wj,F$,GY=(F$=class extends oh{constructor(n,r){super();xt(this,Ji);xt(this,Ho);xt(this,Go);xt(this,ha);xt(this,Li);st(this,Ho,n),this.setOptions(r),this.bindMethods(),Ft(this,Ji,fx).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=me(this,Ho).defaultMutationOptions(n),Jx(this.options,r)||me(this,Ho).getMutationCache().notify({type:"observerOptionsUpdated",mutation:me(this,ha),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Ac(r.mutationKey)!==Ac(this.options.mutationKey)?this.reset():((s=me(this,ha))==null?void 0:s.state.status)==="pending"&&me(this,ha).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=me(this,ha))==null||n.removeObserver(this)}onMutationUpdate(n){Ft(this,Ji,fx).call(this),Ft(this,Ji,Wj).call(this,n)}getCurrentResult(){return me(this,Go)}reset(){var n;(n=me(this,ha))==null||n.removeObserver(this),st(this,ha,void 0),Ft(this,Ji,fx).call(this),Ft(this,Ji,Wj).call(this)}mutate(n,r){var s;return st(this,Li,r),(s=me(this,ha))==null||s.removeObserver(this),st(this,ha,me(this,Ho).getMutationCache().build(me(this,Ho),this.options)),me(this,ha).addObserver(this),me(this,ha).execute(n)}},Ho=new WeakMap,Go=new WeakMap,ha=new WeakMap,Li=new WeakMap,Ji=new WeakSet,fx=function(){var r;const n=((r=me(this,ha))==null?void 0:r.state)??U5();st(this,Go,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Wj=function(n){lr.batch(()=>{var r,s,i,o,l,c,u,d;if(me(this,Li)&&this.hasListeners()){const h=me(this,Go).variables,m=me(this,Go).context;(n==null?void 0:n.type)==="success"?((s=(r=me(this,Li)).onSuccess)==null||s.call(r,n.data,h,m),(o=(i=me(this,Li)).onSettled)==null||o.call(i,n.data,null,h,m)):(n==null?void 0:n.type)==="error"&&((c=(l=me(this,Li)).onError)==null||c.call(l,n.error,h,m),(d=(u=me(this,Li)).onSettled)==null||d.call(u,void 0,n.error,h,m))}
586this.listeners.forEach(h=>{h(me(this,Go))})})},F$),K5=y.createContext(void 0),at=e=>{const t=y.useContext(K5);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},VY=({client:e,children:t})=>(y.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),a.jsx(K5.Provider,{value:e,children:t})),H5=y.createContext(!1),YY=()=>y.useContext(H5);H5.Provider;function QY(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var XY=y.createContext(QY()),JY=()=>y.useContext(XY),ZY=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},eQ=e=>{y.useEffect(()=>{e.clearReset()},[e])},tQ=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||I5(n,[e.error,r])),nQ=e=>{if(e.suspense){const t=r=>r==="static"?r:Math.max(r??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...r)=>t(n(...r)):t(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},rQ=(e,t)=>e.isLoading&&e.isFetching&&!t,aQ=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,WP=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function sQ(e,t,n){var h,m,f,x,g;const r=YY(),s=JY(),i=at(),o=i.defaultQueryOptions(e);(m=(h=i.getDefaultOptions().queries)==null?void 0:h._experimental_beforeQuery)==null||m.call(h,o),o._optimisticResults=r?"isRestoring":"optimistic",nQ(o),ZY(o,s),eQ(s);const l=!i.getQueryCache().get(o.queryHash),[c]=y.useState(()=>new t(i,o)),u=c.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(y.useSyncExternalStore(y.useCallback(p=>{const v=d?c.subscribe(lr.batchCalls(p)):ea;return c.updateResult(),v},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),y.useEffect(()=>{c.setOptions(o)},[o,c]),aQ(o,u))throw WP(o,c,s);if(tQ({result:u,errorResetBoundary:s,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;if((x=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||x.call(f,o,u),o.experimental_prefetchInRender&&!Oc&&rQ(u,r)){const p=l?WP(o,c,s):(g=i.getQueryCache().get(o.queryHash))==null?void 0:g.promise;p==null||p.catch(ea).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?u:c.trackResult(u)}function Ee(e,t){return sQ(e,WY)}function Me(e,t){const n=at(),[r]=y.useState(()=>new GY(n,e));y.useEffect(()=>{r.setOptions(e)},[r,e]);const s=y.useSyncExternalStore(y.useCallback(o=>r.subscribe(lr.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=y.useCallback((o,l)=>{r.mutate(o,l).catch(ea)},[r]);if(s.error&&I5(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}/** 587 * @remix-run/router v1.23.0 588 * 589 * Copyright (c) Remix Software Inc. 590 * 591 * This source code is licensed under the MIT license found in the 592 * LICENSE.md file in the root directory of this source tree. 593 * 594 * @license MIT 595 */function om(){return om=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},om.apply(this,arguments)}var Xo;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(Xo||(Xo={}));const KP="popstate";function iQ(e){e===void 0&&(e={});function t(r,s){let{pathname:i,search:o,hash:l}=r.location;return Kj("",{pathname:i,search:o,hash:l},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function n(r,s){return typeof s=="string"?s:ey(s)}return lQ(t,n,null,e)}function Gn(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function G5(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function oQ(){return Math.random().toString(36).substr(2,8)}function HP(e,t){return{usr:e.state,key:e.key,idx:t}}function Kj(e,t,n,r){return n===void 0&&(n=null),om({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?lh(t):t,{state:n,key:t&&t.key||r||oQ()})}function ey(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function lh(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function lQ(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:i=!1}=r,o=s.history,l=Xo.Pop,c=null,u=d();u==null&&(u=0,o.replaceState(om({},o.state,{idx:u}),""));function d(){return(o.state||{idx:null}).idx}function h(){l=Xo.Pop;let p=d(),v=p==null?null:p-u;u=p,c&&c({action:l,location:g.location,delta:v})}function m(p,v){l=Xo.Push;let b=Kj(g.location,p,v);u=d()+1;let w=HP(b,u),N=g.createHref(b);try{o.pushState(w,"",N)}catch(j){if(j instanceof DOMException&&j.name==="DataCloneError")throw j;s.location.assign(N)}i&&c&&c({action:l,location:g.location,delta:1})}function f(p,v){l=Xo.Replace;let b=Kj(g.location,p,v);u=d();let w=HP(b,u),N=g.createHref(b);o.replaceState(w,"",N),i&&c&&c({action:l,location:g.location,delta:0})}function x(p){let v=s.location.origin!=="null"?s.location.origin:s.location.href,b=typeof p=="string"?p:ey(p);return b=b.replace(/ $/,"%20"),Gn(v,"No window.location.(origin|href) available to create URL for href: "+b),new URL(b,v)}let g={get action(){return l},get location(){return e(s,o)},listen(p){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(KP,h),c=p,()=>{s.removeEventListener(KP,h),c=null}},createHref(p){return t(s,p)},createURL:x,encodeLocation(p){let v=x(p);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:f,go(p){return o.go(p)}};return g}var GP;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(GP||(GP={}));
vendor: 9,121 bytes, lines 595-604
595function cQ(e,t,n){return n===void 0&&(n="/"),uQ(e,t,n,!1)}function uQ(e,t,n,r){let s=typeof t=="string"?lh(t):t,i=kC(s.pathname||"/",n);if(i==null)return null;let o=V5(e);dQ(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=_Q(i);l=bQ(o[c],u,r)}return l}function V5(e,t,n,r){t===void 0&&(t=[]),n===void 0&&(n=[]),r===void 0&&(r="");let s=(i,o,l)=>{let c={relativePath:l===void 0?i.path||"":l,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};c.relativePath.startsWith("/")&&(Gn(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 u=ll([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(Gn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),V5(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:yQ(u,i.index),routesMeta:d})};return e.forEach((i,o)=>{var l;if(i.path===""||!((l=i.path)!=null&&l.includes("?")))s(i,o);else for(let c of Y5(i.path))s(i,o,c)}),t}function Y5(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let o=Y5(r.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),s&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function dQ(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:vQ(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const hQ=/^:[\w-]+$/,fQ=3,mQ=2,pQ=1,gQ=10,xQ=-2,VP=e=>e==="*";function yQ(e,t){let n=e.split("/"),r=n.length;return n.some(VP)&&(r+=xQ),t&&(r+=mQ),n.filter(s=>!VP(s)).reduce((s,i)=>s+(hQ.test(i)?fQ:i===""?pQ:gQ),r)}function vQ(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function bQ(e,t,n){let{routesMeta:r}=e,s={},i="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=i==="/"?t:t.slice(i.length)||"/",h=YP({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),m=c.route;if(!h&&u&&n&&!r[r.length-1].route.index&&(h=YP({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(s,h.params),o.push({params:s,pathname:ll([i,h.pathname]),pathnameBase:CQ(ll([i,h.pathnameBase])),route:m}),h.pathnameBase!=="/"&&(i=ll([i,h.pathnameBase]))}return o}function YP(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=wQ(e.path,e.caseSensitive,e.end),s=t.match(n);if(!s)return null;let i=s[0],o=i.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:r.reduce((u,d,h)=>{let{paramName:m,isOptional:f}=d;if(m==="*"){let g=l[h]||"";o=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const x=l[h];return f&&!x?u[m]=void 0:u[m]=(x||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:o,pattern:e}}function wQ(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),G5(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=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function _Q(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return G5(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function kC(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 jQ(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?lh(e):e;return{pathname:n?n.startsWith("/")?n:NQ(n,t):t,search:kQ(r),hash:EQ(s)}}function NQ(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function cw(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 SQ(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function EC(e,t){let n=SQ(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function PC(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=lh(e):(s=om({},e),Gn(!s.pathname||!s.pathname.includes("?"),cw("?","pathname","search",s)),Gn(!s.pathname||!s.pathname.includes("#"),cw("#","pathname","hash",s)),Gn(!s.search||!s.search.includes("#"),cw("#","search","hash",s)));let i=e===""||s.pathname==="",o=i?"/":s.pathname,l;if(o==null)l=n;else{let h=t.length-1;if(!r&&o.startsWith("..")){let m=o.split("/");for(;m[0]==="..";)m.shift(),h-=1;s.pathname=m.join("/")}l=h>=0?t[h]:"/"}let c=jQ(s,l),u=o&&o!=="/"&&o.endsWith("/"),d=(i||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const ll=e=>e.join("/").replace(/\/\/+/g,"/"),CQ=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),kQ=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,EQ=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function PQ(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Q5=["post","put","patch","delete"];new Set(Q5);const OQ=["get",...Q5];new Set(OQ);/** 596 * React Router v6.30.1 597 * 598 * Copyright (c) Remix Software Inc. 599 * 600 * This source code is licensed under the MIT license found in the 601 * LICENSE.md file in the root directory of this source tree. 602 * 603 * @license MIT 604 */function lm(){return lm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lm.apply(this,arguments)}const OC=y.createContext(null),AQ=y.createContext(null),Sl=y.createContext(null),Jv=y.createContext(null),Cl=y.createContext({outlet:null,matches:[],isDataRoute:!1}),X5=y.createContext(null);function TQ(e,t){let{relative:n}=t===void 0?{}:t;ch()||Gn(!1);let{basename:r,navigator:s}=y.useContext(Sl),{hash:i,pathname:o,search:l}=Z5(e,{relative:n}),c=o;return r!=="/"&&(c=o==="/"?r:ll([r,o])),s.createHref({pathname:c,search:l,hash:i})}function ch(){return y.useContext(Jv)!=null}function kl(){return ch()||Gn(!1),y.useContext(Jv).location}function J5(e){y.useContext(Sl).static||y.useLayoutEffect(e)}function Zv(){let{isDataRoute:e}=y.useContext(Cl);return e?KQ():MQ()}function MQ(){ch()||Gn(!1);let e=y.useContext(OC),{basename:t,future:n,navigator:r}=y.useContext(Sl),{matches:s}=y.useContext(Cl),{pathname:i}=kl(),o=JSON.stringify(EC(s,n.v7_relativeSplatPath)),l=y.useRef(!1);return J5(()=>{l.current=!0}),y.useCallback(function(u,d){if(d===void 0&&(d={}),!l.current)return;if(typeof u=="number"){r.go(u);return}let h=PC(u,JSON.parse(o),i,d.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:ll([t,h.pathname])),(d.replace?r.replace:r.push)(h,d.state,d)},[t,r,o,i,e])}function Z5(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=y.useContext(Sl),{matches:s}=y.useContext(Cl),{pathname:i}=kl(),o=JSON.stringify(EC(s,r.v7_relativeSplatPath));return y.useMemo(()=>PC(e,JSON.parse(o),i,n==="path"),[e,o,i,n])}function DQ(e,t){return $Q(e,t)}function $Q(e,t,n,r){ch()||Gn(!1);let{navigator:s}=y.useContext(Sl),{matches:i}=y.useContext(Cl),o=i[i.length-1],l=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:"/";o&&o.route;let u=kl(),d;if(t){var h;let p=typeof t=="string"?lh(t):t;c==="/"||(h=p.pathname)!=null&&h.startsWith(c)||Gn(!1),d=p}else d=u;let m=d.pathname||"/",f=m;if(c!=="/"){let p=c.replace(/^\//,"").split("/");f="/"+m.replace(/^\//,"").split("/").slice(p.length).join("/")}let x=cQ(e,{pathname:f}),g=qQ(x&&x.map(p=>Object.assign({},p,{params:Object.assign({},l,p.params),pathname:ll([c,s.encodeLocation?s.encodeLocation(p.pathname).pathname:p.pathname]),pathnameBase:p.pathnameBase==="/"?c:ll([c,s.encodeLocation?s.encodeLocation(p.pathnameBase).pathname:p.pathnameBase])})),i,n,r);return t&&g?y.createElement(Jv.Provider,{value:{location:lm({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:Xo.Pop}},g):g}function RQ(){let e=WQ(),t=PQ(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application
604Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},t),n?y.createElement("pre",{style:s},n):null,null)}const IQ=y.createElement(RQ,null);class LQ extends y.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?y.createElement(Cl.Provider,{value:this.props.routeContext},y.createElement(X5.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function FQ(e){let{routeContext:t,match:n,children:r}=e,s=y.useContext(OC);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),y.createElement(Cl.Provider,{value:t},r)}function qQ(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,l=(s=n)==null?void 0:s.errors;if(l!=null){let d=o.findIndex(h=>h.route.id&&(l==null?void 0:l[h.route.id])!==void 0);d>=0||Gn(!1),o=o.slice(0,Math.min(o.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d<o.length;d++){let h=o[d];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(u=d),h.route.id){let{loaderData:m,errors:f}=n,x=h.route.loader&&m[h.route.id]===void 0&&(!f||f[h.route.id]===void 0);if(h.route.lazy||x){c=!0,u>=0?o=o.slice(0,u+1):o=[o[0]];break}}}return o.reduceRight((d,h,m)=>{let f,x=!1,g=null,p=null;n&&(f=l&&h.route.id?l[h.route.id]:void 0,g=h.route.errorElement||IQ,c&&(u<0&&m===0?(x=!0,p=null):u===m&&(x=!0,p=h.route.hydrateFallbackElement||null)));let v=t.concat(o.slice(0,m+1)),b=()=>{let w;return f?w=g:x?w=p:h.route.Component?w=y.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=d,y.createElement(FQ,{match:h,routeContext:{outlet:d,matches:v,isDataRoute:n!=null},children:w})};return n&&(h.route.ErrorBoundary||h.route.errorElement||m===0)?y.createElement(LQ,{location:n.location,revalidation:n.revalidation,component:g,error:f,children:b(),routeContext:{outlet:null,matches:v,isDataRoute:!0}}):b()},null)}var e4=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(e4||{}),ty=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(ty||{});function zQ(e){let t=y.useContext(OC);return t||Gn(!1),t}function BQ(e){let t=y.useContext(AQ);return t||Gn(!1),t}function UQ(e){let t=y.useContext(Cl);return t||Gn(!1),t}function t4(e){let t=UQ(),n=t.matches[t.matches.length-1];return n.route.id||Gn(!1),n.route.id}function WQ(){var e;let t=y.useContext(X5),n=BQ(ty.UseRouteError),r=t4(ty.UseRouteError);return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function KQ(){let{router:e}=zQ(e4.UseNavigateStable),t=t4(ty.UseNavigateStable),n=y.useRef(!1);return J5(()=>{n.current=!0}),y.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,lm({fromRouteId:t},i)))},[e,t])}function HQ(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function ju(e){let{to:t,replace:n,state:r,relative:s}=e;ch()||Gn(!1);let{future:i,static:o}=y.useContext(Sl),{matches:l}=y.useContext(Cl),{pathname:c}=kl(),u=Zv(),d=PC(t,EC(l,i.v7_relativeSplatPath),c,s==="path"),h=JSON.stringify(d);return y.useEffect(()=>u(JSON.parse(h),{replace:n,state:r,relative:s}),[u,h,s,n,r]),null}function ir(e){Gn(!1)}function GQ(e){let{basename:t="/",children:n=null,location:r,navigationType:s=Xo.Pop,navigator:i,static:o=!1,future:l}=e;ch()&&Gn(!1);let c=t.replace(/^\/*/,"/"),u=y.useMemo(()=>({basename:c,navigator:i,static:o,future:lm({v7_relativeSplatPath:!1},l)}),[c,l,i,o]);typeof r=="string"&&(r=lh(r));
604let{pathname:d="/",search:h="",hash:m="",state:f=null,key:x="default"}=r,g=y.useMemo(()=>{let p=kC(d,c);return p==null?null:{location:{pathname:p,search:h,hash:m,state:f,key:x},navigationType:s}},[c,d,h,m,f,x,s]);return g==null?null:y.createElement(Sl.Provider,{value:u},y.createElement(Jv.Provider,{children:n,value:g}))}function n4(e){let{children:t,location:n}=e;return DQ(Hj(t),n)}new Promise(()=>{});function Hj(e,t){t===void 0&&(t=[]);let n=[];return y.Children.forEach(e,(r,s)=>{if(!y.isValidElement(r))return;let i=[...t,s];if(r.type===y.Fragment){n.push.apply(n,Hj(r.props.children,i));return}r.type!==ir&&Gn(!1),!r.props.index||!r.props.children||Gn(!1);let o={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=Hj(r.props.children,i)),n.push(o)}),n}/** 605 * React Router DOM v6.30.1 606 * 607 * Copyright (c) Remix Software Inc. 608 * 609 * This source code is licensed under the MIT license found in the 610 * LICENSE.md file in the root directory of this source tree. 611 * 612 * @license MIT 613 */function Gj(){return Gj=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Gj.apply(this,arguments)}function VQ(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,i;for(i=0;i<r.length;i++)s=r[i],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function YQ(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function QQ(e,t){return e.button===0&&(!t||t==="_self")&&!YQ(e)}function Vj(e){return e===void 0&&(e=""),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(s=>[n,s]):[[n,r]])},[]))}function XQ(e,t){let n=Vj(e);return t&&t.forEach((r,s)=>{n.has(s)||t.getAll(s).forEach(i=>{n.append(s,i)})}),n}const JQ=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],ZQ="6";try{window.__reactRouterVersion=ZQ}catch{}const eX="startTransition",QP=lS[eX];function tX(e){let{basename:t,children:n,future:r,window:s}=e,i=y.useRef();i.current==null&&(i.current=iQ({window:s,v5Compat:!0}));let o=i.current,[l,c]=y.useState({action:o.action,location:o.location}),{v7_startTransition:u}=r||{},d=y.useCallback(h=>{u&&QP?QP(()=>c(h)):c(h)},[c,u]);return y.useLayoutEffect(()=>o.listen(d),[o,d]),y.useEffect(()=>HQ(r),[r]),y.createElement(GQ,{basename:t,children:n,location:l.location,navigationType:l.action,navigator:o,future:r})}const nX=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",rX=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Na=y.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:h}=t,m=VQ(t,JQ),{basename:f}=y.useContext(Sl),x,g=!1;if(typeof u=="string"&&rX.test(u)&&(x=u,nX))try{let w=new URL(window.location.href),N=u.startsWith("//")?new URL(w.protocol+u):new URL(u),j=kC(N.pathname,f);N.origin===w.origin&&j!=null?u=j+N.search+N.hash:g=!0}catch{}let p=TQ(u,{relative:s}),v=aX(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:s,viewTransition:h});function b(w){r&&r(w),w.defaultPrevented||v(w)}return y.createElement("a",Gj({},m,{href:x||p,onClick:g||i?r:b,ref:n,target:c}))});var XP;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(XP||(XP={}));var JP;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(JP||(JP={}));function aX(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:o,viewTransition:l}=t===void 0?{}:t,c=Zv(),u=kl(),d=Z5(e,{relative:o});return y.useCallback(h=>{if(QQ(h,n)){h.preventDefault();let m=r!==void 0?r:ey(u)===ey(d);c(e,{replace:m,state:s,preventScrollReset:i,relative:o,viewTransition:l})}},[u,c,d,r,s,n,e,i,o,l])}function El(e){let t=y.useRef(Vj(e)),n=y.useRef(!1),r=kl(),s=y.useMemo(()=>XQ(r.search,n.current?null:t.current),[r.search]),i=Zv(),o=y.useCallback((l,c)=>{const u=Vj(typeof l=="function"?l(s):l);n.current=!0,i("?"+u,c)},[i,s]);return[s,o]}var di=function(){return di=Object.assign||function(t){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},di.apply(this,arguments)};function uh(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}function sX(e,t,n,r){function s(i){return i instanceof n?i:new n(function(o){o(i)})}
613return new(n||(n=Promise))(function(i,o){function l(d){try{u(r.next(d))}catch(h){o(h)}}function c(d){try{u(r.throw(d))}catch(h){o(h)}}function u(d){d.done?i(d.value):s(d.value).then(l,c)}u((r=r.apply(e,t||[])).next())})}function iX(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}const oX=e=>e?(...t)=>e(...t):(...t)=>fetch(...t);class AC extends Error{constructor(t,n="FunctionsError",r){super(t),this.name=n,this.context=r}}class lX extends AC{constructor(t){super("Failed to send a request to the Edge Function","FunctionsFetchError",t)}}class ZP extends AC{constructor(t){super("Relay Error invoking the Edge Function","FunctionsRelayError",t)}}class eO extends AC{constructor(t){super("Edge Function returned a non-2xx status code","FunctionsHttpError",t)}}var Yj;(function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"})(Yj||(Yj={}));class cX{constructor(t,{headers:n={},customFetch:r,region:s=Yj.Any}={}){this.url=t,this.headers=n,this.region=s,this.fetch=oX(r)}setAuth(t){this.headers.Authorization=`Bearer ${t}`}invoke(t){return sX(this,arguments,void 0,function*(n,r={}){var s;let i,o;try{const{headers:l,method:c,body:u,signal:d,timeout:h}=r;let m={},{region:f}=r;f||(f=this.region);const x=new URL(`${this.url}/${n}`);f&&f!=="any"&&(m["x-region"]=f,x.searchParams.set("forceFunctionRegion",f));let g;u&&(l&&!Object.prototype.hasOwnProperty.call(l,"Content-Type")||!l)?typeof Blob<"u"&&u instanceof Blob||u instanceof ArrayBuffer?(m["Content-Type"]="application/octet-stream",g=u):typeof u=="string"?(m["Content-Type"]="text/plain",g=u):typeof FormData<"u"&&u instanceof FormData?g=u:(m["Content-Type"]="application/json",g=JSON.stringify(u)):u&&typeof u!="string"&&!(typeof Blob<"u"&&u instanceof Blob)&&!(u instanceof ArrayBuffer)&&!(typeof FormData<"u"&&u instanceof FormData)?g=JSON.stringify(u):g=u;let p=d;h&&(o=new AbortController,i=setTimeout(()=>o.abort(),h),d?(p=o.signal,d.addEventListener("abort",()=>o.abort())):p=o.signal);const v=yield this.fetch(x.toString(),{method:c||"POST",headers:Object.assign(Object.assign(Object.assign({},m),this.headers),l),body:g,signal:p}).catch(j=>{throw new lX(j)}),b=v.headers.get("x-relay-error");if(b&&b==="true")throw new ZP(v);if(!v.ok)throw new eO(v);let w=((s=v.headers.get("Content-Type"))!==null&&s!==void 0?s:"text/plain").split(";")[0].trim(),N;return w==="application/json"?N=yield v.json():w==="application/octet-stream"||w==="application/pdf"?N=yield v.blob():w==="text/event-stream"?N=v:w==="multipart/form-data"?N=yield v.formData():N=yield v.text(),{data:N,error:null,response:v}}catch(l){return{data:null,error:l,response:l instanceof eO||l instanceof ZP?l.context:void 0}}finally{i&&clearTimeout(i)}})}}var uX=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.co
613de=e.code}},dX=class{constructor(e){var t,n,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=(t=e.shouldThrowOnError)!==null&&t!==void 0?t:!1,this.signal=e.signal,this.isMaybeSingle=(n=e.isMaybeSingle)!==null&&n!==void 0?n:!1,this.urlLengthLimit=(r=e.urlLengthLimit)!==null&&r!==void 0?r:8e3,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}then(e,t){var n=this;this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const r=this.fetch;let s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{let o=null,l=null,c=null,u=i.status,d=i.statusText;if(i.ok){var h,m;if(n.method!=="HEAD"){var f;const v=await i.text();v===""||(n.headers.get("Accept")==="text/csv"||n.headers.get("Accept")&&(!((f=n.headers.get("Accept"))===null||f===void 0)&&f.includes("application/vnd.pgrst.plan+text"))?l=v:l=JSON.parse(v))}const g=(h=n.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),p=(m=i.headers.get("content-range"))===null||m===void 0?void 0:m.split("/");g&&p&&p.length>1&&(c=parseInt(p[1])),n.isMaybeSingle&&n.method==="GET"&&Array.isArray(l)&&(l.length>1?(o={code:"PGRST116",details:`Results contain ${l.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},l=null,c=null,u=406,d="Not Acceptable"):l.length===1?l=l[0]:l=null)}else{var x;const g=await i.text();try{o=JSON.parse(g),Array.isArray(o)&&i.status===404&&(l=[],o=null,u=200,d="OK")}catch{i.status===404&&g===""?(u=204,d="No Content"):o={message:g}}if(o&&n.isMaybeSingle&&(!(o==null||(x=o.details)===null||x===void 0)&&x.includes("0 rows"))&&(o=null,u=200,d="OK"),o&&n.shouldThrowOnError)throw new uX(o)}return{error:o,data:l,count:c,status:u,statusText:d}});return this.shouldThrowOnError||(s=s.catch(i=>{var o;let l="",c="",u="";const d=i==null?void 0:i.cause;if(d){var h,m,f,x;const v=(h=d==null?void 0:d.message)!==null&&h!==void 0?h:"",b=(m=d==null?void 0:d.code)!==null&&m!==void 0?m:"";l=`${(f=i==null?void 0:i.name)!==null&&f!==void 0?f:"FetchError"}: ${i==null?void 0:i.message}`,l+=` 614 615Caused by: ${(x=d==null?void 0:d.name)!==null&&x!==void 0?x:"Error"}: ${v}`,b&&(l+=` (${b})`),d!=null&&d.stack&&(l+=` 616${d.stack}`)}else{var g;l=(g=i==null?void 0:i.stack)!==null&&g!==void 0?g:""}const p=this.url.toString().length;return(i==null?void 0:i.name)==="AbortError"||(i==null?void 0:i.code)==="ABORT_ERR"?(u="",c="Request was aborted (timeout or manual cancellation)",p>this.urlLengthLimit&&(c+=`. Note: Your request URL is ${p} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):((d==null?void 0:d.name)==="HeadersOverflowError"||(d==null?void 0:d.code)==="UND_ERR_HEADERS_OVERFLOW")&&(u="",c="HTTP headers exceeded server limits (typically 16KB)",p>this.urlLengthLimit&&(c+=`. Your request URL is ${p} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{error:{message:`${(o=i==null?void 0:i.name)!==null&&o!==void 0?o:"FetchError"}: ${i==null?void 0:i.message}`,details:l,hint:c,code:u},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}returns(){return this}overrideTypes(){return this}},hX=class extends dX{select(e){let t=!1;const n=(e??"*").split("").map(r=>/\s/.test(r)&&!t?"":(r==='"'&&(t=!t),r)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:r,referencedTable:s=r}={}){const i=s?`${s}.order`:"order",o=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${o?`${o},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){const r=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:r=n}={}){const s=typeof r>"u"?"offset":`${r}.offset`,i=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}
616explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:r=!1,wal:s=!1,format:i="text"}={}){var o;const l=[e?"analyze":null,t?"verbose":null,n?"settings":null,r?"buffers":null,s?"wal":null].filter(Boolean).join("|"),c=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${c}"; options=${l};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};const tO=new RegExp("[,()]");var Nu=class extends hX{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}regexMatch(e,t){return this.url.searchParams.append(e,`match.${t}`),this}regexIMatch(e,t){return this.url.searchParams.append(e,`imatch.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}isDistinct(e,t){return this.url.searchParams.append(e,`isdistinct.${t}`),this}in(e,t){const n=Array.from(new Set(t)).map(r=>typeof r=="string"&&tO.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}notIn(e,t){const n=Array.from(new Set(t)).map(r=>typeof r=="string"&&tO.test(r)?`"${r}"`:`${r}`).join(",");return this.url.searchParams.append(e,`not.in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:r}={}){let s="";r==="plain"?s="pl":r==="phrase"?s="ph":r==="websearch"&&(s="w");const i=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${s}fts${i}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){const r=n?`${n}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}},fX=class{constructor(e,{headers:t={},schema:n,fetch:r,urlLengthLimit:s=8e3}){this.url=e,this.headers=new Headers(t),this.schema=n,this.fetch=r,this.urlLengthLimit=s}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(e,t){const{head:n=!1,count:r}=t??{},s=n?"HEAD":"GET";let i=!1;const o=(e??"*").split("").map(u=>/\s/.test(u)&&!i?"":(u==='"'&&(i=!i),u)).join(""),{url:l,headers:c}=this.cloneRequestState();return l.searchParams.set("select",o),r&&c.append("Prefer",`count=${r}`),new Nu({method:s,url:l,headers:c,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}insert(e,{count:t,defaultToNull:n=!0}={}){var r;const s="POST",{url:i,headers:o}=this.cloneRequestState();if(t&&o.append("Prefer",`count=${t}`),n||o.append("Prefer","missing=default"),Array.isArray(e)){const l=e.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(l.length>0){const c=[...new Set(l)].map(u=>`"${u}"`);i.searchParams.set("columns",c.join(","))}}return new Nu({method:s,url:i,headers:o,schema:this.schema,body:e,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch,urlLengthLimit:this.urlLengthLimit})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:r,defaultToNull:s=!0}={}){var i;const o="POST",{url:l,headers:c}=this.cloneRequestState();if(c.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),t!==void 0&&l.searchParams.set("on_conflict",t),r&&c.append("Prefer",`count=${r}`),s||c.append("Prefer","missing=default"),Array.isArray(e)){const u=e.reduce((d,h)=>d.concat(Object.keys(h)),[]);if(u.length>0){const d=[...new Set(u)].map(h=>`"${h}"`);l.searchParams.set("columns",d.join(","))}}return new Nu({method:o,url:l,headers:c,schema:this.schema,body:e,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit})}update(e,{count:t}={}){var n;const r="PATCH",{url:s,headers:i}=this.cloneRequestState();return t&&i.append("Prefer",`count=${t}`),new Nu({method:r,url:s,headers:i,schema:this.schema,body:e,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch,urlLengthLimit:this.urlLengthLimit})}delete({count:e}={}){var t;const n="DELETE",{url:r,headers:s}=this.cloneRequestState();return e&&s.append("Prefer",`count=${e}`),new Nu({method:n,url:r,headers:s,schema:this.schema,fetch:(t=this.fetch)!==null&&t!==void 0?t:fetch,urlLengthLimit:this.urlLengthLimit})}};function cm(e){"@babel/helpers - typeof";return cm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cm(e)}function mX(e,t){if(cm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(cm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function pX(e){var t=mX(e,"string");return cm(t)=="symbol"?t:t+""}
616function gX(e,t,n){return(t=pX(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nO(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function gg(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?nO(Object(n),!0).forEach(function(r){gX(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nO(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var xX=class r4{constructor(t,{headers:n={},schema:r,fetch:s,timeout:i,urlLengthLimit:o=8e3}={}){this.url=t,this.headers=new Headers(n),this.schemaName=r,this.urlLengthLimit=o;const l=s??globalThis.fetch;i!==void 0&&i>0?this.fetch=(c,u)=>{const d=new AbortController,h=setTimeout(()=>d.abort(),i),m=u==null?void 0:u.signal;if(m){if(m.aborted)return clearTimeout(h),l(c,u);const f=()=>{clearTimeout(h),d.abort()};return m.addEventListener("abort",f,{once:!0}),l(c,gg(gg({},u),{},{signal:d.signal})).finally(()=>{clearTimeout(h),m.removeEventListener("abort",f)})}return l(c,gg(gg({},u),{},{signal:d.signal})).finally(()=>clearTimeout(h))}:this.fetch=l}from(t){if(!t||typeof t!="string"||t.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new fX(new URL(`${this.url}/${t}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}schema(t){return new r4(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}rpc(t,n={},{head:r=!1,get:s=!1,count:i}={}){var o;let l;const c=new URL(`${this.url}/rpc/${t}`);let u;const d=f=>f!==null&&typeof f=="object"&&(!Array.isArray(f)||f.some(d)),h=r&&Object.values(n).some(d);h?(l="POST",u=n):r||s?(l=r?"HEAD":"GET",Object.entries(n).filter(([f,x])=>x!==void 0).map(([f,x])=>[f,Array.isArray(x)?`{${x.join(",")}}`:`${x}`]).forEach(([f,x])=>{c.searchParams.append(f,x)})):(l="POST",u=n);const m=new Headers(this.headers);return h?m.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&m.set("Prefer",`count=${i}`),new Nu({method:l,url:c,headers:m,schema:this.schemaName,body:u,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit})}};class yX{constructor(){}static detectEnvironment(){var t;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((t=navigator.userAgent)===null||t===void 0)&&t.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const n=globalThis.process;if(n){const r=n.versions;if(r&&r.node){const s=r.node,i=parseInt(s.replace(/^v/,"").split(".")[0]);return i>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${i} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${i} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: 617import ws from "ws" 618new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const t=this.detectEnvironment();if(t.constructor)return t.constructor;let n=t.error||"WebSocket not supported in this environment.";throw t.workaround&&(n+=` 619 620Suggested solution: ${t.workaround}`),new Error(n)}static createWebSocket(t,n){const r=this.getWebSocketConstructor();return new r(t,n)}static isWebSocketSupported(){try{const t=this.detectEnvironment();return t.type==="native"||t.type==="ws"}catch{return!1}}}const vX="2.95.3",bX=`realtime-js/${vX}`,wX="1.0.0",a4="2.0.0",rO=a4,Qj=1e4,_X=1e3,jX=100;var To;(function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"})(To||(To={}));var sr;(function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"})(sr||(sr={}));var Ds;(function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"})(Ds||(Ds={}));var Xj;(function(e){e.websocket="websocket"})(Xj||(Xj={}));var Xl;(function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"})(Xl||(Xl={}));class NX{constructor(t){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=t??[]}encode(t,n){if(t.event===this.BROADCAST_EVENT&&!(t.payload instanceof ArrayBuffer)&&typeof t.payload.event=="string")return n(this._binaryEncodeUserBroadcastPush(t));let r=[t.join_ref,t.ref,t.topic,t.event,t.payload];return n(JSON.stringify(r))}_binaryEncodeUserBroadcastPush(t){var n;return this._isArrayBuffer((n=t.payload)===null||n===void 0?void 0:n.payload)?this._encodeBinaryUserBroadcastPush(t):this._encodeJsonUserBroadcastPush(t)}_encodeBinaryUserBroadcastPush(t){var n,r;const s=(r=(n=t.payload)===null||n===void 0?void 0:n.payload)!==null&&r!==void 0?r:new ArrayBuffer(0);return this._encodeUserBroadcastPush(t,this.BINARY_ENCODING,s)}_encodeJsonUserBroadcastPush(t){var n,r;const s=(r=(n=t.payload)===null||n===void 0?void 0:n.payload)!==null&&r!==void 0?r:{},o=new TextEncoder().encode(JSON.stringify(s)).buffer;return this._encodeUserBroadcastPush(t,this.JSON_ENCODING,o)}_encodeUserBroadcastPush(t,n,r){var s,i;const o=t.topic,l=(s=t.ref)!==null&&s!==void 0?s:"",c=(i=t.join_ref)!==null&&i!==void 0?i:"",u=t.payload.event,d=this.allowedMetadataKeys?this._pick(t.payload,this.allowedMetadataKeys):{},h=Object.keys(d).length===0?"":JSON.stringify(d);if(c.length>255)throw new Error(`joinRef length ${c.length} exceeds maximum of 255`);if(l.length>255)throw new Error(`ref length ${l.length} exceeds maximum of 255`);if(o.length>255)throw new Error(`topic length ${o.length} exceeds maximum of 255`);if(u.length>255)throw new Error(`userEvent length ${u.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`metadata length ${h.length} exceeds maximum of 255`);const m=this.USER_BROADCAST_PUSH_META_LENGTH+c.length+l.length+o.length+u.length+h.length,f=new ArrayBuffer(this.HEADER_LENGTH+m);let x=new DataView(f),g=0;x.setUint8(g++,this.KINDS.userBroadcastPush),x.setUint8(g++,c.length),x.setUint8(g++,l.length),x.setUint8(g++,o.length),x.setUint8(g++,u.length),x.setUint8(g++,h.length),x.setUint8(g++,n),Array.from(c,v=>x.setUint8(g++,v.charCodeAt(0))),Array.from(l,v=>x.setUint8(g++,v.charCodeAt(0))),Array.from(o,v=>
620x.setUint8(g++,v.charCodeAt(0))),Array.from(u,v=>x.setUint8(g++,v.charCodeAt(0))),Array.from(h,v=>x.setUint8(g++,v.charCodeAt(0)));var p=new Uint8Array(f.byteLength+r.byteLength);return p.set(new Uint8Array(f),0),p.set(new Uint8Array(r),f.byteLength),p.buffer}decode(t,n){if(this._isArrayBuffer(t)){let r=this._binaryDecode(t);return n(r)}if(typeof t=="string"){const r=JSON.parse(t),[s,i,o,l,c]=r;return n({join_ref:s,ref:i,topic:o,event:l,payload:c})}return n({})}_binaryDecode(t){const n=new DataView(t),r=n.getUint8(0),s=new TextDecoder;switch(r){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(t,n,s)}}_decodeUserBroadcast(t,n,r){const s=n.getUint8(1),i=n.getUint8(2),o=n.getUint8(3),l=n.getUint8(4);let c=this.HEADER_LENGTH+4;const u=r.decode(t.slice(c,c+s));c=c+s;const d=r.decode(t.slice(c,c+i));c=c+i;const h=r.decode(t.slice(c,c+o));c=c+o;const m=t.slice(c,t.byteLength),f=l===this.JSON_ENCODING?JSON.parse(r.decode(m)):m,x={type:this.BROADCAST_EVENT,event:d,payload:f};return o>0&&(x.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:u,event:this.BROADCAST_EVENT,payload:x}}_isArrayBuffer(t){var n;return t instanceof ArrayBuffer||((n=t==null?void 0:t.constructor)===null||n===void 0?void 0:n.name)==="ArrayBuffer"}_pick(t,n){return!t||typeof t!="object"?{}:Object.fromEntries(Object.entries(t).filter(([r])=>n.includes(r)))}}class s4{constructor(t,n){this.callback=t,this.timerCalc=n,this.timer=void 0,this.tries=0,this.callback=t,this.timerCalc=n}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var yn;(function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"})(yn||(yn={}));const aO=(e,t,n={})=>{var r;const s=(r=n.skipTypes)!==null&&r!==void 0?r:[];return t?Object.keys(t).reduce((i,o)=>(i[o]=SX(o,e,t,s),i),{}):{}},SX=(e,t,n,r)=>{const s=t.find(l=>
620l.name===e),i=s==null?void 0:s.type,o=n[e];return i&&!r.includes(i)?i4(i,o):Jj(o)},i4=(e,t)=>{if(e.charAt(0)==="_"){const n=e.slice(1,e.length);return PX(t,n)}switch(e){case yn.bool:return CX(t);case yn.float4:case yn.float8:case yn.int2:case yn.int4:case yn.int8:case yn.numeric:case yn.oid:return kX(t);case yn.json:case yn.jsonb:return EX(t);case yn.timestamp:return OX(t);case yn.abstime:case yn.date:case yn.daterange:case yn.int4range:case yn.int8range:case yn.money:case yn.reltime:case yn.text:case yn.time:case yn.timestamptz:case yn.timetz:case yn.tsrange:case yn.tstzrange:return Jj(t);default:return Jj(t)}},Jj=e=>e,CX=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},kX=e=>{if(typeof e=="string"){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},EX=e=>{if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e},PX=(e,t)=>{if(typeof e!="string")return e;const n=e.length-1,r=e[n];if(e[0]==="{"&&r==="}"){let i;const o=e.slice(1,n);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(l=>i4(t,l))}return e},OX=e=>typeof e=="string"?e.replace(" ","T"):e,o4=e=>{const t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),t.pathname===""||t.pathname==="/"?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};class uw{constructor(t,n,r={},s=Qj){this.channel=t,this.event=n,this.payload=r,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(t){this.timeout=t,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(t){this.payload=Object.assign(Object.assign({},this.payload),t)}receive(t,n){var r;return this._hasReceived(t)&&n((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:t,callback:n}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const t=n=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=n,this._matchReceive(n)};this.channel._on(this.refEvent,{},t),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(t,n){this.refEvent&&this.channel._trigger(this.refEvent,{status:t,response:n})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:t,response:n}){this.recHooks.filter(r=>r.status===t).forEach(r=>r.callback(n))}_hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}}var sO;(function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"})(sO||(sO={}));class Ef{constructor(t,n){this.channel=t,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=(n==null?void 0:n.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},s=>{const{onJoin:i,onLeave:o,onSync:l}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Ef.syncState(this.state,s,i,o),this.pendingDiffs.forEach(c=>{this.state=Ef.syncDiff(this.state,c,i,o)}),this.pendingDiffs=[],l()}),this.channel._on(r.diff,{},s=>{const{onJoin:i,onLeave:o,onSync:l}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=Ef.syncDiff(this.state,s,i,o),l())}),this.onJoin((s,i,o)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:i,newPresences:o})}),this.onLeave((s,i,o)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:i,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(t,n,r,s){const i=this.cloneDeep(t),o=this.transformState(n),l={},c={};return this.map(i,(u,d)=>{o[u]||(c[u]=d)}),this.map(o,(u,d)=>{const h=i[u];if(h){const m=d.map(p=>p.presence_ref),f=h.map(p=>p.presence_ref),x=d.filter(p=>f.indexOf(p.presence_ref)<0),g=h.filter(p=>m.indexOf(p.presence_ref)<0);x.length>0&&(l[u]=x),g.length>0&&(c[u]=g)}else l[u]=d}),this.syncDiff(i,{joins:l,leaves:c},r,s)}static syncDiff(t,n,r,s){const{joins:i,leaves:o}={joins:this.transformState(n.joins),leaves:this.transformState(n.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(i,(l,c)=>{var u;
620const d=(u=t[l])!==null&&u!==void 0?u:[];if(t[l]=this.cloneDeep(c),d.length>0){const h=t[l].map(f=>f.presence_ref),m=d.filter(f=>h.indexOf(f.presence_ref)<0);t[l].unshift(...m)}r(l,d,c)}),this.map(o,(l,c)=>{let u=t[l];if(!u)return;const d=c.map(h=>h.presence_ref);u=u.filter(h=>d.indexOf(h.presence_ref)<0),t[l]=u,s(l,u,c),u.length===0&&delete t[l]}),t}static map(t,n){return Object.getOwnPropertyNames(t).map(r=>n(r,t[r]))}static transformState(t){return t=this.cloneDeep(t),Object.getOwnPropertyNames(t).reduce((n,r)=>{const s=t[r];return"metas"in s?n[r]=s.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):n[r]=s,n},{})}static cloneDeep(t){return JSON.parse(JSON.stringify(t))}onJoin(t){this.caller.onJoin=t}onLeave(t){this.caller.onLeave=t}onSync(t){this.caller.onSync=t}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var iO;(function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"})(iO||(iO={}));var Pf;(function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"})(Pf||(Pf={}));var $i;(function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"})($i||($i={}));class zu{constructor(t,n={config:{}},r){var s,i;if(this.topic=t,this.params=n,this.socket=r,this.bindings={},this.state=sr.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=t.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config),this.timeout=this.socket.timeout,this.joinPush=new uw(this,Ds.join,this.params,this.timeout),this.rejoinTimer=new s4(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=sr.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(o=>o.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=sr.closed,this.socket._remove(this)}),this._onError(o=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,o),this.state=sr.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=sr.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",o=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,o),this.state=sr.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Ds.reply,{},(o,l)=>{this._trigger(this._replyEventName(l),o)}),this.presence=new Ef(this),this.broadcastEndpointURL=o4(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((i=(s=this.params.config)===null||s===void 0?void 0:s.broadcast)===null||i===void 0)&&i.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(t,n=this.timeout){var r,s,i;if(this.socket.isConnected()||this.socket.connect(),this.state==sr.closed){const{config:{broadcast:o,presence:l,private:c}}=this.params,u=(s=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(f=>f.filter))!==null&&s!==void 0?s:[],d=!!this.bindings[Pf.PRESENCE]&&this.bindings[Pf.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,h={},m={broadcast:o,presence:Object.assign(Object.assign({},l),{enabled:d}),postgres_changes:u,private:c};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(f=>t==null?void 0:t($i.CHANNEL_ERROR,f)),this._onClose(()=>t==null?void 0:t($i.CLOSED)),this.updateJoinPayload(Object.assign({config:m},h)),this.joinedOnce=!0,this._rejoin(n),this.joinPush.receive("ok",async({postgres_changes:f})=>{var x;if(this.socket._isManualToken()||this.socket.setAuth(),f===void 0){t==null||t($i.SUBSCRIBED);return}else{const g=this.bindings.postgres_changes,p=(x=g==null?void 0:g.length)!==null&&x!==void 0?x:0,v=[];for(let b=0;b<p;
620b++){const w=g[b],{filter:{event:N,schema:j,table:_,filter:S}}=w,P=f&&f[b];if(P&&P.event===N&&zu.isFilterValueEqual(P.schema,j)&&zu.isFilterValueEqual(P.table,_)&&zu.isFilterValueEqual(P.filter,S))v.push(Object.assign(Object.assign({},w),{id:P.id}));else{this.unsubscribe(),this.state=sr.errored,t==null||t($i.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=v,t&&t($i.SUBSCRIBED);return}}).receive("error",f=>{this.state=sr.errored,t==null||t($i.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(f).join(", ")||"error")))}).receive("timeout",()=>{t==null||t($i.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(t,n={}){return await this.send({type:"presence",event:"track",payload:t},n.timeout||this.timeout)}async untrack(t={}){return await this.send({type:"presence",event:"untrack"},t)}on(t,n,r){return this.state===sr.joined&&t===Pf.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(async()=>await this.subscribe())),this._on(t,n,r)}async httpSend(t,n,r={}){var s;if(n==null)return Promise.reject("Payload is required for httpSend()");const i={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(i.Authorization=`Bearer ${this.socket.accessTokenValue}`);const o={method:"POST",headers:i,body:JSON.stringify({messages:[{topic:this.subTopic,event:t,payload:n,private:this.private}]})},l=await this._fetchWithTimeout(this.broadcastEndpointURL,o,(s=r.timeout)!==null&&s!==void 0?s:this.timeout);if(l.status===202)return{success:!0};let c=l.statusText;try{const u=await l.json();c=u.error||u.message||c}catch{}return Promise.reject(new Error(c))}async send(t,n={}){var r,s;if(!this._canPush()&&t.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated
620in the future. Please use httpSend() explicitly for REST delivery.");const{event:i,payload:o}=t,l={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(l.Authorization=`Bearer ${this.socket.accessTokenValue}`);const c={method:"POST",headers:l,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(r=n.timeout)!==null&&r!==void 0?r:this.timeout);return await((s=u.body)===null||s===void 0?void 0:s.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var o,l,c;const u=this._push(t.type,t,n.timeout||this.timeout);t.type==="broadcast"&&!(!((c=(l=(o=this.params)===null||o===void 0?void 0:o.config)===null||l===void 0?void 0:l.broadcast)===null||c===void 0)&&c.ack)&&i("ok"),u.receive("ok",()=>i("ok")),u.receive("error",()=>i("error")),u.receive("timeout",()=>i("timed out"))})}updateJoinPayload(t){this.joinPush.updatePayload(t)}unsubscribe(t=this.timeout){this.state=sr.leaving;const n=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Ds.close,"leave",this._joinRef())};this.joinPush.destroy();let r=null;return new Promise(s=>{r=new uw(this,Ds.leave,{},t),r.receive("ok",()=>{n(),s("ok")}).receive("timeout",()=>{n(),s("timed out")}).receive("error",()=>{s("error")}),r.send(),this._canPush()||r.trigger("ok",{})}).finally(()=>{r==null||r.destroy()})}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=sr.closed,this.bindings={}}async _fetchWithTimeout(t,n,r){const s=new AbortController,i=setTimeout(()=>s.abort(),r),o=await this.socket.fetch(t,Object.assign(Object.assign({},n),{signal:s.signal}));return clearTimeout(i),o}_push(t,n,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${t}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new uw(this,t,n,r);return this._canPush()?s.send():this._addToPushBuffer(s),s}_addToPushBuffer(t){if(t.startTimeout(),this.pushBuffer.push(t),this.pushBuffer.length>jX){const n=this.pushBuffer.shift();n&&(n.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${n.event}`,n.payload))}}_onMessage(t,n,r){return n}_isMember(t){return this.topic===t}_joinRef(){return this.joinPush.ref}_trigger(t,n,r){var s,i;const o=t.toLocaleLowerCase(),{close:l,error:c,leave:u,join:d}=Ds;if(r&&[l,c,u,d].indexOf(o)>=0&&r!==this._joinRef())return;let m=this._onMessage(o,n,r);if(n&&!m)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(f=>{var x,g,p;return((x=f.filter)===null||x===void 0?void 0:x.event)==="*"||((p=(g=f.filter)===null||g===void 0?void 0:g.event)===null||p===void 0?void 0:p.toLocaleLowerCase())===o}).map(f=>f.callback(m,r)):(i=this.bindings[o])===null||i===void 0||i.filter(f=>{var x,g,p,v,b,w;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in f){const N=f.id,j=(x=f.filter)===null||x===void 0?void 0:x.event;return N&&((g=n.ids)===null||g===void 0?void 0:g.includes(N))&&(j==="*"||(j==null?void 0:j.toLocaleLowerCase())===((p=n.data)===null||p===void 0?void 0:p.type.toLocaleLowerCase()))}else{const N=(b=(v=f==null?void 0:f.filter)===null||v===void 0?void 0:v.event)===null||b===void 0?void 0:b.toLocaleLowerCase();return N==="*"||N===((w=n==null?void 0:n.event)===null||w===void 0?void 0:w.toLocaleLowerCase())}else return f.type.toLocaleLowerCase()===o}).map(f=>{if(typeof m=="object"&&"ids"in m){const x=m.data,{schema:g,table:p,commit_timestamp:v,type:b,errors:w}=x;m=Object.assign(Object.assign({},{schema:g,table:p,commit_timestamp:v,eventType:b,new:{},old:{},errors:w}),this._getPayloadRecords(x))}f.callback(m,r)})}_isClosed(){return this.state===sr.closed}_isJoined(){return this.state===sr.joined}_isJoining(){return this.state===sr.joining}_isLeaving(){return this.state===sr.leaving}_replyEventName(t){return`chan_reply_${t}`}_on(t,n,r){const s=t.toLocaleLowerCase(),i={type:s,filter:n,callback:r};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],this}_off(t,n){const r=t.toLocaleLowerCase();return this.bindings[r]&&(this.bindings[r]=this.bindings[r].filter(s=>{var i;return!(((i=s.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===r&&zu.isEqual(s.filter,n))})),this}static isEqual(t,n){if(Object.keys(t).length!==Object.keys(n).length)return!1;for(const r in t)if(t[r]!==n[r])return!1;return!0}static isFilterValueEqual(t,n){return(t??void 0)===(n??void 0)}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(t){this._on(Ds.close,{},t)}_onError(t){this._on(Ds.error,{},n=>t(n))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(t=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=sr.joining,this.joinPush.resend(t))}_getPayloadRecords(t){const n={new:{},old:{}};return(t.type==="INSERT"||t.type==="UPDATE")&&(n.new=aO(t.columns,t.record)),(t.type==="UPDATE"||t.type==="DELETE")&&(n.old=aO(t.columns,t.old_record)),n}}const dw=()=>{},xg={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},AX=[1e3,2e3,5e3,1e4],TX=1e4,MX=` 621 addEventListener("message", (e) => { 622 if (e.data.event === "start") { 623 setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); 624 } 625 });`;class DX{constructor(t,n){var r;if(this.accessTokenValue=null,this.apiKey=null,this._manuallySetToken=!1,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=Qj,this.transport=null,this.heartbeatIntervalMs=xg.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=dw,this.ref=0,this.reconnectTimer=null,this.vsn=rO,this.logger=
625dw,this.conn=null,this.sendBuffer=[],this.serializer=new NX,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._heartbeatSentAt=null,this._resolveFetch=s=>s?(...i)=>s(...i):(...i)=>fetch(...i),!(!((r=n==null?void 0:n.params)===null||r===void 0)&&r.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=n.params.apikey,this.endPoint=`${t}/${Xj.websocket}`,this.httpEndpoint=o4(t),this._initializeOptions(n),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(n==null?void 0:n.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=yX.createWebSocket(this.endpointURL())}catch(t){this._setConnectionState("disconnected");const n=t.message;throw n.includes("Node.js")?new Error(`${n} 626 627To use Realtime in Node.js, you need to provide a WebSocket implementation: 628 629Option 1: Use Node.js 22+ which has native WebSocket support 630Option 2: Install and provide the "ws" package: 631 632 npm install ws 633 634 import ws from "ws" 635 const client = new RealtimeClient(url, { 636 ...options, 637 transport: ws 638 })`):new Error(`WebSocket not available: ${n}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:this.vsn}))}disconnect(t,n){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const r=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(r),this._setConnectionState("disconnected")},typeof this.conn.close=="function"&&(t?this.conn.close(t,n??""):this.conn.close()),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(t){const n=await t.unsubscribe();return n==="ok"&&this._remove(t),this.channels.length===0&&this.disconnect(),n}async removeAllChannels(){const t=await Promise.all(this.channels.map(n=>n.unsubscribe()));return this.channels=[],this.disconnect(),t}log(t,n,r){this.logger(t,n,r)}connectionState(){switch(this.conn&&this.conn.readyState){case To.connecting:return Xl.Connecting;case To.open:return Xl.Open;case To.closing:return Xl.Closing;default:return Xl.Closed}}isConnected(){return this.connectionState()===Xl.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(t,n={config:{}}){const r=`realtime:${t}`,s=this.getChannels().find(i=>i.topic===r);if(s)return s;{const i=new zu(`realtime:${t}`,n,this);return this.channels.push(i),i}}push(t){const{topic:n,event:r,payload:s,ref:i}=t,o=()=>{this.encode(t,l=>{var c;(c=this.conn)===null||c===void 0||c.send(l)})};this.log("push",`${n} ${r} (${i})`,s),this.isConnected()?o():this.sendBuffer.push(o)}async setAuth(t=null){this._authPromise=this._performAuth(t);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){var t;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(n){this.log("error","error in heartbeat callback",n)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this._heartbeatSentAt=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(n){this.log("error","error in heartbeat callback",n)}this._wasManualDisconnect=!1,(t=this.conn)===null||t===void 0||t.close(_X,"heartbeat timeout"),setTimeout(()=>{var n;this.isConnected()||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout()},xg.HEARTBEAT_TIMEOUT_FALLBACK);return}this._heartbeatSentAt=Date.now(),this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(n){this.log("error","error in heartbeat callback",n)}this._setAuthSafely("heartbeat")}onHeartbeat(t){this.heartbeatCallback=t}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}_makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}_leaveOpenTopic(t){let n=this.channels.find(r=>r.topic===t&&(r._isJoined()||r._isJoining()));n&&(this.log("transport",`leaving duplicate topic "${t}"`),n.unsubscribe())}_remove(t){this.channels=this.channels.filter(n=>n.topic!==t.topic)}_onConnMessage(t){this.decode(t.data,n=>
638{if(n.topic==="phoenix"&&n.event==="phx_reply"&&n.ref&&n.ref===this.pendingHeartbeatRef){const u=this._heartbeatSentAt?Date.now()-this._heartbeatSentAt:void 0;try{this.heartbeatCallback(n.payload.status==="ok"?"ok":"error",u)}catch(d){this.log("error","error in heartbeat callback",d)}this._heartbeatSentAt=null,this.pendingHeartbeatRef=null}const{topic:r,event:s,payload:i,ref:o}=n,l=o?`(${o})`:"",c=i.status||"";this.log("receive",`${c} ${r} ${s} ${l}`.trim(),i),this.channels.filter(u=>u._isMember(r)).forEach(u=>u._trigger(s,i,o)),this._triggerStateCallbacks("message",n)})}_clearTimer(t){var n;t==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):t==="reconnect"&&((n=this.reconnectTimer)===null||n===void 0||n.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=t=>this._onConnError(t),this.conn.onmessage=t=>this._onConnMessage(t),this.conn.onclose=t=>this._onConnClose(t),this.conn.readyState===To.open&&this._onConnOpen())}_teardownConnection(){if(this.conn){if(this.conn.readyState===To.open||this.conn.readyState===To.connecting)try{this.conn.close()}catch(t){this.log("error","Error closing connection",t)}this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null}this._clearAllTimers(),this._terminateWorker(),this.channels.forEach(t=>t.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).then(()=>{this.flushSendBuffer()}).catch(n=>{this.log("error","error waiting for auth on connect",n),this.flushSendBuffer()}),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const t=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(t),this.workerRef.onerror=n=>{this.log("worker","worker error",n.message),this._terminateWorker()},this.workerRef.onmessage=n=>{n.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_onConnClose(t){var n;this._setConnectionState("disconnected"),this.log("transport","close",t),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(n=this.reconnectTimer)===null||n===void 0||n.scheduleTimeout(),this._triggerStateCallbacks("close",t)}_onConnError(t){this._setConnectionState("disconnected"),this.log("transport",`${t}`),this._triggerChanError(),this._triggerStateCallbacks("error",t);try{this.heartbeatCallback("error")}catch(n){this.log("error","error in heartbeat callback",n)}}_triggerChanError(){this.channels.forEach(t=>t._trigger(Ds.error))}_appendParams(t,n){if(Object.keys(n).length===0)return t;const r=t.match(/\?/)?"&":"?",s=new URLSearchParams(n);return`${t}${r}${s}`}_workerObjectUrl(t){let n;if(t)n=t;else{const r=new Blob([MX],{type:"application/javascript"});n=URL.createObjectURL(r)}return n}_setConnectionState(t,n=!1){this._connectionState=t,t==="connecting"?this._wasManualDisconnect=!1:t==="disconnecting"&&(this._wasManualDisconnect=n)}async _performAuth(t=null){let n,r=!1;if(t)n=t,r=!0;else if(this.accessToken)try{n=await this.accessToken()}catch(s){this.log("error","Error fetching access token from callback",s),n=this.accessTokenValue}else n=this.accessTokenValue;r?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=n&&(this.accessTokenValue=n,this.channels.forEac
638h(s=>{const i={access_token:n,version:bX};n&&s.updateJoinPayload(i),s.joinedOnce&&s._isJoined()&&s._push(Ds.access_token,{access_token:n})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(t="general"){this._isManualToken()||this.setAuth().catch(n=>{this.log("error",`Error setting auth in ${t}`,n)})}_triggerStateCallbacks(t,n){try{this.stateChangeCallbacks[t].forEach(r=>{try{r(n)}catch(s){this.log("error",`error in ${t} callback`,s)}})}catch(r){this.log("error",`error triggering ${t} callbacks`,r)}}_setupReconnectionTimer(){this.reconnectTimer=new s4(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},xg.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(t){var n,r,s,i,o,l,c,u,d,h,m,f;switch(this.transport=(n=t==null?void 0:t.transport)!==null&&n!==void 0?n:null,this.timeout=(r=t==null?void 0:t.timeout)!==null&&r!==void 0?r:Qj,this.heartbeatIntervalMs=(s=t==null?void 0:t.heartbeatIntervalMs)!==null&&s!==void 0?s:xg.HEARTBEAT_INTERVAL,this.worker=(i=t==null?void 0:t.worker)!==null&&i!==void 0?i:!1,this.accessToken=(o=t==null?void 0:t.accessToken)!==null&&o!==void 0?o:null,this.heartbeatCallback=(l=t==null?void 0:t.heartbeatCallback)!==null&&l!==void 0?l:dw,this.vsn=(c=t==null?void 0:t.vsn)!==null&&c!==void 0?c:rO,t!=null&&t.params&&(this.params=t.params),t!=null&&t.logger&&(this.logger=t.logger),(t!=null&&t.logLevel||t!=null&&t.log_level)&&(this.logLevel=t.logLevel||t.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(u=t==null?void 0:t.reconnectAfterMs)!==null&&u!==void 0?u:x=>AX[x-1]||TX,this.vsn){case wX:this.encode=(d=t==null?void 0:t.encode)!==null&&d!==void 0?d:(x,g)=>g(JSON.stringify(x)),this.decode=(h=t==null?void 0:t.decode)!==null&&h!==void 0?h:(x,g)=>g(JSON.parse(x));break;case a4:this.encode=(m=t==null?void 0:t.encode)!==null&&m!==void 0?m:this.serializer.encode.bind(this.serializer),this.decode=(f=t==null?void 0:t.decode)!==null&&f!==void 0?f:this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${this.vsn}`)}if(this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=t==null?void 0:t.workerUrl}}}var um=class extends Error{constructor(e,t){var n;super(e),this.name="IcebergError",this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown=t.icebergType==="CommitStateUnknownException"||[500,502,504].includes(t.status)&&((n=t.icebergType)==null?void 0:n.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function $X(e,t,n){const r=new URL(t,e);if(n)for(const[s,i]of Object.entries(n))i!==void 0&&r.searchParams.set(s,i);return r.toString()}async function RX(e){return!e||e.type==="none"?{}:e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:e.type==="header"?{[e.name]:e.value}:e.type==="custom"?await e.getHeaders():{}}function IX(e){const t=e.fetchImpl??globalThis.fetch;return{async request({method:n,path:r,query:s,body:i,headers:o}){const l=$X(e.baseUrl,r,s),c=await RX(e.auth),u=await t(l,{method:n,headers:{...i?{"Content-Type":"application/json"}:{},...c,...o},body:i?JSON.stringify(i):void 0}),d=await u.text(),h=(u.headers.get("content-type")||"").includes("application/json"),m=h&&d?JSON.parse(d):d;if(!u.ok){const f=h?m:void 0,x=f==null?void 0:f.error;throw new um((x==null?void 0:x.message)??`Request failed with status ${u.status}`,{status:u.status,icebergType:x==null?void 0:x.type,icebergCode:x==null?void 0:x.code,details:f})}return{status:u.status,headers:u.headers,data:m}}}}function yg(e){return e.join("�")}var LX=class{constructor(e,t=""){this.client=e,this.prefix=t}async listNamespaces(e){const t=e?{parent:yg(e.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:t})).data.namespaces.map(r=>({namespace:r}))}async createNamespace(e,t){const n={namespace:e.namespace,properties:t==null?void 0:t.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:n})).data}async dropNamespace(e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${yg(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${yg(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${yg(e.namespace)}`}),!0}catch(t){if(t instanceof um&&t.status===404)return!1;throw t}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(n){if(n instanceof um&&n.status===409)return;throw n}}};function ru(e){return e.join("�")}var FX=class{constructor(e,t="",n){this.client=e,this.prefix=t,this.accessDelegation=n}async listTables(e){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${ru(e.namespace)}/tables`})).data.identifiers}async createTable(e,t){const n={};return this.accessDelegation&&(n["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${ru(e.namespace)}/tables`,body:t,headers:n})).data.metadata}async updateTable(e,t){const n=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${ru(e.namespace)}/tables/${e.name}`,body:t});return{"metadata-location":n.data["metadata-location"],metadata:n.data.metadata}}async dropTable(e,t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${ru(e.namespace)}/tables/${e.name}`,query:{purgeRequested:String((t==null?void 0:t.purge)??!1)}})}async loadTable(e){const t={};return this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${ru(e.namespace)}/tables/${e.name}`,headers:t})).data.metadata}async tableExists(e){const t={};this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${ru(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(n){if(n instanceof um&&n.status===404)return!1;throw n}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(n){if(n instanceof um&&n.status===409)return await this.loadTable({namespace:e.namespace,name:t.name});throw n}}},qX=class{constructor(e){var r;let t="v1";e.catalogName&&(t+=`/${e.catalogName}`);const n=e.baseUrl.endsWith("/")?e.baseUrl:`${e.baseUrl}/`;this.client=IX({baseUrl:n,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=(r=e.accessDelegation)==null?void 0:r.join(","),this.namespaceOps=new LX(this.client,t),this.tableOps=new FX(this.client,t,this.accessDelegation)}async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}
638async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}},eb=class extends Error{constructor(e,t="storage",n,r){super(e),this.__isStorageError=!0,this.namespace=t,this.name=t==="vectors"?"StorageVectorsError":"StorageError",this.status=n,this.statusCode=r}};function tb(e){return typeof e=="object"&&e!==null&&"__isStorageError"in e}var vg=class extends eb{constructor(e,t,n,r="storage"){super(e,r,t,n),this.name=r==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=t,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},l4=class extends eb{constructor(e,t,n="storage"){super(e,n),this.name=n==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=t}};const zX=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),BX=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Zj=e=>{if(Array.isArray(e))return e.map(n=>Zj(n));if(typeof e=="function"||e!==Object(e))return e;const t={};return Object.entries(e).forEach(([n,r])=>{const s=n.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));t[s]=Zj(r)}),t},UX=e=>!e||typeof e!="string"||e.length===0||e.length>100||e.trim()!==e||e.includes("/")||e.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(e);function dm(e){"@babel/helpers - typeof";return dm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dm(e)}function WX(e,t){if(dm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(dm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function KX(e){var t=WX(e,"string");return dm(t)=="symbol"?t:t+""}function HX(e,t,n){return(t=KX(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oO(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function _t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?oO(Object(n),!0).forEach(function(r){HX(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oO(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const lO=e=>{var t;return e.msg||e.message||e.error_description||(typeof e.error=="string"?e.error:(t=e.error)===null||t===void 0?void 0:t.message)||JSON.stringify(e)},GX=async(e,t,n,r)=>{if(e&&typeof e=="object"&&"status"in e&&"ok"in e&&typeof e.status=="number"&&!(n!=null&&n.noResolveJson)){const s=e,i=s.status||500;if(typeof s.json=="function")s.json().then(o=>{const l=(o==null?void 0:o.statusCode)||(o==null?void 0:o.code)||i+"";t(new vg(lO(o),i,l,r))}).catch(()=>{if(r==="vectors"){const o=i+"";t(new vg(s.statusText||`HTTP ${i} error`,i,o,r))}else{const o=i+"";t(new vg(s.statusText||`HTTP ${i} error`,i,o,r))}});else{const o=i+"";t(new vg(s.statusText||`HTTP ${i} error`,i,o,r))}}else t(new l4(lO(e),e,r))},VX=(e,t,n,r)=>{const s={method:e,headers:(t==null?void 0:t.headers)||{}};return e==="GET"||e==="HEAD"||!r?_t(_t({},s),n):(BX(r)?(s.headers=_t({"Content-Type":"application/json"},t==null?void 0:t.headers),s.body=JSON.stringify(r)):s.body=r,t!=null&&t.duplex&&(s.duplex=t.duplex),_t(_t({},s),n))};async function Fh(e,t,n,r,s,i,o){return new Promise((l,c)=>{e(n,VX(t,r,s,i)).then(u=>{if(!u.ok)throw u;if(r!=null&&r.noResolveJson)return u;if(o==="vectors"){const d=u.headers.get("content-type");if(u.headers.get("content-length")==="0"||u.status===204)return{};if(!d||!d.includes("application/json"))return{}}return u.json()}).then(u=>l(u)).catch(u=>GX(u,c,r,o))})}function c4(e="storage"){return{get:async(t,n,r,s)=>
638Fh(t,"GET",n,r,s,void 0,e),post:async(t,n,r,s,i)=>Fh(t,"POST",n,s,i,r,e),put:async(t,n,r,s,i)=>Fh(t,"PUT",n,s,i,r,e),head:async(t,n,r,s)=>Fh(t,"HEAD",n,_t(_t({},r),{},{noResolveJson:!0}),s,void 0,e),remove:async(t,n,r,s,i)=>Fh(t,"DELETE",n,s,i,r,e)}}const YX=c4("storage"),{get:hm,post:Ps,put:e1,head:QX,remove:TC}=YX,$a=c4("vectors");var dh=class{constructor(e,t={},n,r="storage"){this.shouldThrowOnError=!1,this.url=e,this.headers=t,this.fetch=zX(n),this.namespace=r}throwOnError(){return this.shouldThrowOnError=!0,this}async handleOperation(e){var t=this;try{return{data:await e(),error:null}}catch(n){if(t.shouldThrowOnError)throw n;if(tb(n))return{data:null,error:n};throw n}}},XX=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t}then(e,t){return this.execute().then(e,t)}async execute(){var e=this;try{return{data:(await e.downloadFn()).body,error:null}}catch(t){if(e.shouldThrowOnError)throw t;if(tb(t))return{data:null,error:t};throw t}}};let u4;u4=Symbol.toStringTag;var JX=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[u4]="BlobDownloadBuilder",this.promise=null}asStream(){return new XX(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var e=this;try{return{data:await(await e.downloadFn()).blob(),error:null}}catch(t){if(e.shouldThrowOnError)throw t;if(tb(t))return{data:null,error:t};throw t}}};const ZX={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},cO={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var eJ=class extends dh{constructor(e,t={},n,r){super(e,t,r,"storage"),this.bucketId=n}async uploadOrUpdate(e,t,n,r){var s=this;return s.handleOperation(async()=>{let i;const o=_t(_t({},cO),r);let l=_t(_t({},s.headers),e==="POST"&&{"x-upsert":String(o.upsert)});const c=o.metadata;typeof Blob<"u"&&n instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),c&&i.append("metadata",s.encodeMetadata(c)),i.append("",n)):typeof FormData<"u"&&n instanceof FormData?(i=n,i.has("cacheControl")||i.append("cacheControl",o.cacheControl),c&&!i.has("metadata")&&i.append("metadata",s.encodeMetadata(c))):(i=n,l["cache-control"]=`max-age=${o.cacheControl}`,l["content-type"]=o.contentType,c&&(l["x-metadata"]=s.toBase64(s.encodeMetadata(c))),(typeof ReadableStream<"u"&&i instanceof ReadableStream||i&&typeof i=="object"&&"pipe"in i&&typeof i.pipe=="function")&&!o.duplex&&(o.duplex="half")),r!=null&&r.headers&&(l=_t(_t({},l),r.headers));const u=s._removeEmptyFolders(t),d=s._getFinalPath(u),h=await(e=="PUT"?e1:Ps)(s.fetch,`${s.url}/object/${d}`,i,_t({headers:l},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{path:u,id:h.Id,fullPath:h.Key}})}async upload(e,t,n){return this.uploadOrUpdate("POST",e,t,n)}async uploadToSignedUrl(e,t,n,r){var s=this;const i=s._removeEmptyFolders(e),o=s._getFinalPath(i),l=new URL(s.url+`/object/upload/sign/${o}`);return l.searchParams.set("token",t),s.handleOperation(async()=>{let c;const u=_t({upsert:cO.upsert},r),d=_t(_t({},s.headers),{"x-upsert":String(u.upsert)});return typeof Blob<"u"&&n instanceof Blob?(c=new FormData,c.append("cacheControl",u.cacheControl),c.append("",n)):typeof FormData<"u"&&n instanceof FormData?(c=n,c.append("cacheControl",u.cacheControl)):(c=n,d["cache-control"]=`max-age=${u.cacheControl}`,d["content-type"]=u.contentType),{path:i,fullPath:(await e1(s.fetch,l.toString(),c,{headers:d})).Key}})}async createSignedUploadUrl(e,t){var n=this;return n.handleOperation(async()=>{let r=n._getFinalPath(e);const s=_t({},n.headers);t!=null&&t.upsert&&(s["x-upsert"]="true");const i=await Ps(n.fetch,`${n.url}/object/upload/sign/${r}`,{},{headers:s}),o=new URL(n.url+i.url),l=o.searchParams.get("token");if(!l)throw new eb("No token returned by API");return{signedUrl:o.toString(),path:e,token:l}})}async update(e,t,n){return this.uploadOrUpdate("PUT",e,t,n)}async move(e,t,n){var r=this;return r.handleOperation(async()=>await Ps(r.fetch,`${r.url}/object/move`,{bucketId:r.bucketId,sourceKey:e,destinationKey:t,de
638stinationBucket:n==null?void 0:n.destinationBucket},{headers:r.headers}))}async copy(e,t,n){var r=this;return r.handleOperation(async()=>({path:(await Ps(r.fetch,`${r.url}/object/copy`,{bucketId:r.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:r.headers})).Key}))}async createSignedUrl(e,t,n){var r=this;return r.handleOperation(async()=>{let s=r._getFinalPath(e),i=await Ps(r.fetch,`${r.url}/object/sign/${s}`,_t({expiresIn:t},n!=null&&n.transform?{transform:n.transform}:{}),{headers:r.headers});const o=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{signedUrl:encodeURI(`${r.url}${i.signedURL}${o}`)}})}async createSignedUrls(e,t,n){var r=this;return r.handleOperation(async()=>{const s=await Ps(r.fetch,`${r.url}/object/sign/${r.bucketId}`,{expiresIn:t,paths:e},{headers:r.headers}),i=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return s.map(o=>_t(_t({},o),{},{signedUrl:o.signedURL?encodeURI(`${r.url}${o.signedURL}${i}`):null}))})}download(e,t,n){const r=typeof(t==null?void 0:t.transform)<"u"?"render/image/authenticated":"object",s=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),i=s?`?${s}`:"",o=this._getFinalPath(e),l=()=>hm(this.fetch,`${this.url}/${r}/${o}${i}`,{headers:this.headers,noResolveJson:!0},n);return new JX(l,this.shouldThrowOnError)}async info(e){var t=this;const n=t._getFinalPath(e);return t.handleOperation(async()=>Zj(await hm(t.fetch,`${t.url}/object/info/${n}`,{headers:t.headers})))}async exists(e){var t=this;const n=t._getFinalPath(e);try{return await QX(t.fetch,`${t.url}/object/${n}`,{headers:t.headers}),{data:!0,error:null}}catch(r){if(t.shouldThrowOnError)throw r;if(tb(r)&&r instanceof l4){const s=r.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:r}}throw r}}getPublicUrl(e,t){const n=this._getFinalPath(e),r=[],s=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";s!==""&&r.push(s);const i=typeof(t==null?void 0:t.transform)<"u"?"render/image":"object",o=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});o!==""&&r.push(o);let l=r.join("&");return l!==""&&(l=`?${l}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}${l}`)}}}async remove(e){var t=this;return t.handleOperation(async()=>await TC(t.fetch,`${t.url}/object/${t.bucketId}`,{prefixes:e},{headers:t.headers}))}async list(e,t,n){var r=this;return r.handleOperation(async()=>{const s=_t(_t(_t({},ZX),t),{},{prefix:e||""});return await Ps(r.fetch,`${r.url}/object/list/${r.bucketId}`,s,{headers:r.headers},n)})}async listV2(e,t){var n=this;return n.handleOperation(async()=>{const r=_t({},e);return await Ps(n.fetch,`${n.url}/object/list-v2/${n.bucketId}`,r,{headers:n.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}};const tJ="2.95.3",yp={"X-Client-Info":`storage-js/${tJ}`};var nJ=class extends dh{constructor(e,t={},n,r){const s=new URL(e);r!=null&&r.useNewHostname&&/supabase\.(co|in|red)$/.test(s.hostname)&&!s.hostname.includes("storage.supabase.")&&(s.hostname=s.hostname.replace("supabase.","storage.supabase."));const i=s.href.replace(/\/$/,""),o=_t(_t({},yp),t);super(i,o,n,"storage")}async listBuckets(e){var t=this;return t.handleOperation(async()=>{const n=t.listBucketOptionsToQueryString(e);return await hm(t.fetch,`${t.url}/bucket${n}`,{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await hm(t.fetch,`${t.url}/bucket/${e}`,{headers:t.headers}))}async createBucket(e,t={public:!1}){var n=this;return n.handleOperation(async()=>await Ps(n.fetch,`${n.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:n.headers}))}async updateBucket(e,t){var n=this;return n.handleOperation(async()=>await e1(n.fetch,`${n.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:n.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await Ps(t.fetch,`${t.url}/bucket/${e}/empty`,{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await TC(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}listBucketOptionsToQueryString(e){const t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}},rJ=class extends dh{constructor(e,t={},n){const r=e.replace(/\/$/,""),s=_t(_t({},yp),t);super(r,s,n,"storage")}async createBucket(e){var t=this;return t.handleOperation(async()=>await Ps(t.fetch,`${t.url}/bucket`,{name:e},{headers:t.headers}))}async listBuckets(e){var t=this;return t.handleOperation(async()=>{const n=new URLSearchParams;(e==null?void 0:e.limit)!==void 0&&n.set("limit",e.limit.toString()),(e==null?void 0:e.offset)!==void 0&&n.set("offset",e.offset.toString()),e!=null&&e.sortColumn&&n.set("sortColumn",e.sortColumn),e!=null&&e.sortOrder&&n.set("sortOrder",e.sortOrder),e!=null&&e.search&&n.set("search",e.search);const r=n.toString(),s=r?`${t.url}/bucket?${r}`:`${t.url}/bucket`;return await hm(t.fetch,s,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await TC(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}from(e){var t=this;if(!UX(e))throw new eb("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const n=new qX({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:async()=>t.headers},fetch:this.fetch}
638),r=this.shouldThrowOnError;return new Proxy(n,{get(s,i){const o=s[i];return typeof o!="function"?o:async(...l)=>{try{return{data:await o.apply(s,l),error:null}}catch(c){if(r)throw c;return{data:null,error:c}}}}})}},aJ=class extends dh{constructor(e,t={},n){const r=e.replace(/\/$/,""),s=_t(_t({},yp),{},{"Content-Type":"application/json"},t);super(r,s,n,"vectors")}async createIndex(e){var t=this;return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/CreateIndex`,e,{headers:t.headers})||{})}async getIndex(e,t){var n=this;return n.handleOperation(async()=>await $a.post(n.fetch,`${n.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:n.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/ListIndexes`,e,{headers:t.headers}))}async deleteIndex(e,t){var n=this;return n.handleOperation(async()=>await $a.post(n.fetch,`${n.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:n.headers})||{})}},sJ=class extends dh{constructor(e,t={},n){const r=e.replace(/\/$/,""),s=_t(_t({},yp),{},{"Content-Type":"application/json"},t);super(r,s,n,"vectors")}async putVectors(e){var t=this;if(e.vectors.length<1||e.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/PutVectors`,e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/GetVectors`,e,{headers:t.headers}))}async listVectors(e){var t=this;if(e.segmentCount!==void 0){if(e.segmentCount<1||e.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(e.segmentIndex!==void 0&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw new Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/ListVectors`,e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/QueryVectors`,e,{headers:t.headers}))}async deleteVectors(e){var t=this;if(e.keys.length<1||e.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/DeleteVectors`,e,{headers:t.headers})||{})}},iJ=class extends dh{constructor(e,t={},n){const r=e.replace(/\/$/,""),s=_t(_t({},yp),{},{"Content-Type":"application/json"},t);super(r,s,n,"vectors")}async createBucket(e){var t=this;return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/GetVectorBucket`,{vectorBucketName:e},{headers:t.headers}))}async listBuckets(e={}){var t=this;return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/ListVectorBuckets`,e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await $a.post(t.fetch,`${t.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}},oJ=class extends iJ{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new lJ(this.url,this.headers,e,this.fetch)}async createBucket(e){var t=()=>super.createBucket,n=this;return t().call(n,e)}async getBucket(e){var t=()=>super.getBucket,n=this;return t().call(n,e)}async listBuckets(e={}){var t=()=>super.listBuckets,n=this;return t().call(n,e)}async deleteBucket(e){var t=()=>super.deleteBucket,n=this;return t().call(n,e)}},lJ=class extends aJ{constructor(e,t,n,r){super(e,t,r),this.vectorBucketName=n}async createIndex(e){var t=()=>super.createIndex,n=this;return t().call(n,_t(_t({},e),{},{vectorBucketName:n.vectorBucketName}))}async listIndexes(e={}){var t=()=>super.listIndexes,n=this;return t().call(n,_t(_t({},e),{},{vectorBucketName:n.vectorBucketName}))}async getIndex(e){var t=()=>super.getIndex,n=this;return t().call(n,n.vectorBucketName,e)}async deleteIndex(e){var t=()=>super.deleteIndex,n=this;return t().call(n,n.vectorBucketName,e)}index(e){return new cJ(this.url,this.headers,this.vectorBucketName,e,this.fetch)}}
638,cJ=class extends sJ{constructor(e,t,n,r,s){super(e,t,s),this.vectorBucketName=n,this.indexName=r}async putVectors(e){var t=()=>super.putVectors,n=this;return t().call(n,_t(_t({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async getVectors(e){var t=()=>super.getVectors,n=this;return t().call(n,_t(_t({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async listVectors(e={}){var t=()=>super.listVectors,n=this;return t().call(n,_t(_t({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async queryVectors(e){var t=()=>super.queryVectors,n=this;return t().call(n,_t(_t({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async deleteVectors(e){var t=()=>super.deleteVectors,n=this;return t().call(n,_t(_t({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}},uJ=class extends nJ{constructor(e,t={},n,r){super(e,t,n,r)}from(e){return new eJ(this.url,this.headers,e,this.fetch)}get vectors(){return new oJ(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new rJ(this.url+"/iceberg",this.headers,this.fetch)}};const d4="2.95.3",Su=30*1e3,t1=3,hw=t1*Su,dJ="http://localhost:9999",hJ="supabase.auth.token",fJ={"X-Client-Info":`gotrue-js/${d4}`},n1="X-Supabase-Api-Version",h4={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},mJ=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,pJ=10*60*1e3;class fm extends Error{constructor(t,n,r){super(t),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=r}}function ft(e){return typeof e=="object"&&e!==null&&"__isAuthError"in e}class gJ extends fm{constructor(t,n,r){super(t,n,r),this.name="AuthApiError",this.status=n,this.code=r}}function xJ(e){return ft(e)&&e.name==="AuthApiError"}class Jl extends fm{constructor(t,n){super(t),this.name="AuthUnknownError",this.originalError=n}}class mo extends fm{constructor(t,n,r,s){super(t,r,s),this.name=n,this.status=r}}class Pa extends mo{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function fw(e){return ft(e)&&e.name==="AuthSessionMissingError"}class au extends mo{constructor(){super("Auth session or user missing","AuthInvalidToken
638ResponseError",500,void 0)}}class bg extends mo{constructor(t){super(t,"AuthInvalidCredentialsError",400,void 0)}}class wg extends mo{constructor(t,n=null){super(t,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function yJ(e){return ft(e)&&e.name==="AuthImplicitGrantRedirectError"}class uO extends mo{constructor(t,n=null){super(t,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=n}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class vJ extends mo{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class r1 extends mo{constructor(t,n){super(t,"AuthRetryableFetchError",n,void 0)}}function mw(e){return ft(e)&&e.name==="AuthRetryableFetchError"}class dO extends mo{constructor(t,n,r){super(t,"AuthWeakPasswordError",n,"weak_password"),this.reasons=r}}class a1 extends mo{constructor(t){super(t,"AuthInvalidJwtError",400,"invalid_jwt")}}const ny="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),hO=` 639\r=`.split(""),bJ=(()=>{const e=new Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<hO.length;t+=1)e[hO[t].charCodeAt(0)]=-2;for(let t=0;t<ny.length;t+=1)e[ny[t].charCodeAt(0)]=t;return e})();function fO(e,t,n){if(e!==null)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;){const r=t.queue>>t.queuedBits-6&63;n(ny[r]),t.queuedBits-=6}else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;){const r=t.queue>>t.queuedBits-6&63;n(ny[r]),t.queuedBits-=6}}function f4(e,t,n){const r=bJ[e];if(r>-1)for(t.queue=t.queue<<6|r,t.queuedBits+=6;t.queuedBits>=8;)n(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else{if(r===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}}function mO(e){const t=[],n=o=>{t.push(String.fromCodePoint(o))},r={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=o=>{jJ(o,r,n)};for(let o=0;o<e.length;o+=1)f4(e.charCodeAt(o),s,i);return t.join("")}function wJ(e,t){if(e<=127){t(e);return}else if(e<=2047){t(192|e>>6),t(128|e&63);return}else if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|e&63);return}else if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|e&63);return}throw new Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}function _J(e,t){for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);if(r>55295&&r<=56319){const s=(r-55296)*1024&65535;r=(e.charCodeAt(n+1)-56320&65535|s)+65536,n+=1}wJ(r,t)}}function jJ(e,t,n){if(t.utf8seq===0){if(e<=127){n(e);return}for(let r=1;r<6;r+=1)if(!(e>>7-r&1)){t.utf8seq=r;break}if(t.utf8seq===2)t.codepoint=e&31;else if(t.utf8seq===3)t.codepoint=e&15;else if(t.utf8seq===4)t.codepoint=e&7;else throw new Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw new Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|e&63,t.utf8seq-=1,t.utf8seq===0&&n(t.codepoint)}}function Zu(e){const t=[],n={queue:0,queuedBits:0},r=s=>{t.push(s)};for(let s=0;s<e.length;s+=1)f4(e.charCodeAt(s),n,r);return new Uint8Array(t)}function NJ(e){const t=[];return _J(e,n=>t.push(n)),new Uint8Array(t)}function rc(e){const t=[],n={queue:0,queuedBits:0},r=s=>{t.push(s)};return e.forEach(s=>fO(s,n,r)),fO(null,n,r),t.join("")}function SJ(e){return Math.round(Date.now()/1e3)+e}function CJ(){return Symbol("auth-callback")}const Er=()=>typeof window<"u"&&typeof document<"u",zl={tested:!1,writable:!1},m4=()=>{if(!Er())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(zl.tested)return zl.writable;const e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),zl.tested=!0,zl.writable=!0}catch{zl.tested=!0,zl.writable=!1}return zl.writable};function kJ(e){const t={},n=new URL(e);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEac
639h((s,i)=>{t[i]=s})}catch{}return n.searchParams.forEach((r,s)=>{t[s]=r}),t}const p4=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),EJ=e=>typeof e=="object"&&e!==null&&"status"in e&&"ok"in e&&"json"in e&&typeof e.json=="function",Cu=async(e,t,n)=>{await e.setItem(t,JSON.stringify(n))},Bl=async(e,t)=>{const n=await e.getItem(t);if(!n)return null;try{return JSON.parse(n)}catch{return n}},Cr=async(e,t)=>{await e.removeItem(t)};class nb{constructor(){this.promise=new nb.promiseConstructor((t,n)=>{this.resolve=t,this.reject=n})}}nb.promiseConstructor=Promise;function _g(e){const t=e.split(".");if(t.length!==3)throw new a1("Invalid JWT structure");for(let r=0;r<t.length;r++)if(!mJ.test(t[r]))throw new a1("JWT not in base64url format");return{header:JSON.parse(mO(t[0])),payload:JSON.parse(mO(t[1])),signature:Zu(t[2]),raw:{header:t[0],payload:t[1]}}}async function PJ(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function OJ(e,t){return new Promise((r,s)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await e(i);if(!t(i,null,o)){r(o);return}}catch(o){if(!t(i,o)){s(o);return}}})()})}function AJ(e){return("0"+e.toString(16)).substr(-2)}function TJ(){const t=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=n.length;let s="";for(let i=0;i<56;i++)s+=n.charAt(Math.floor(Math.random()*r));return s}return crypto.getRandomValues(t),Array.from(t,AJ).join("")}async function MJ(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n),s=new Uint8Array(r);return Array.from(s).map(i=>String.fromCharCode(i)).join("")}async function DJ(e){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e;const n=await MJ(e);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function su(e,t,n=!1){const r=TJ();let s=r;n&&(s+="/PASSWORD_RECOVERY"),await Cu(e,`${t}-code-verifier`,s);const i=await DJ(r);return[i,r===i?"plain":"s256"]}const $J=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function RJ(e){const t=e.headers.get(n1);if(!t||!t.match($J))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch{return null}}function IJ(e){if(!e)throw new Error("Missing exp claim");const t=Math.floor(Date.now()/1e3);if(e<=t)throw new Error("JWT has expired")}function LJ(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const FJ=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function iu(e){if(!FJ.test(e))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function pw(){const e={};return new Proxy(e,{get:(t,n)=>{if(n==="__isUserNotAvailableProxy")return!0;if(typeof n=="symbol"){const r=n.toString();if(r==="Symbol(Symbol.toPrimitive)"||r==="Symbol(Symbol.toStringTag)"||r==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${n}" property of the session object is not supported. Please use getUser() instead.`)},set:(t,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(t,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function qJ(e,t){return new Proxy(e,{get:(n,r,s)=>{if(r==="__isInsecureUserWarningProxy")return!0;if(typeof r=="symbol"){const i=r.toString();if(i==="Symbol(Symbol.toPrimitive)"||i==="Symbol(Symbol.toStringTag)"||i==="Symbol(util.inspect.custom)"||i==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(n,r,s)}return!t.value&&typeof r=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),t.value=!0),Reflect.get(n,r,s)}})}function pO(e){return JSON.parse(JSON.stringify(e))}const Hl=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),zJ=[502,503,504];async function gO(e){var t;if(!EJ(e))throw new r1(Hl(e),0);if(zJ.includes(e.status))throw new r1(Hl(e),e.status);let n;try{n=await e.json()}catch(i){throw new Jl(Hl(i),i)}let r;const s=RJ(e);if(s&&s.getTime()>=h4["2024-01-01"].timestamp&&typeof n=="object"&&n&&typeof n.code=="string"?r=n.code:typeof n=="object"&&n&&typeof n.error_code=="string"&&(r=n.error_code),r){if(r==="weak_password")throw new dO(Hl(n),e.status,((t=n.weak_password)===null||t===void 0?void 0:t.reasons)||[]);if(r==="session_not_found")throw new Pa}else if(typeof n=="object"&&n&&typeof n.weak_password=="object"&&n.weak_password&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.reasons.reduce((i,o)=>
639i&&typeof o=="string",!0))throw new dO(Hl(n),e.status,n.weak_password.reasons);throw new gJ(Hl(n),e.status||500,r)}const BJ=(e,t,n,r)=>{const s={method:e,headers:(t==null?void 0:t.headers)||{}};return e==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},t==null?void 0:t.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),n))};async function wt(e,t,n,r){var s;const i=Object.assign({},r==null?void 0:r.headers);i[n1]||(i[n1]=h4["2024-01-01"].name),r!=null&&r.jwt&&(i.Authorization=`Bearer ${r.jwt}`);const o=(s=r==null?void 0:r.query)!==null&&s!==void 0?s:{};r!=null&&r.redirectTo&&(o.redirect_to=r.redirectTo);const l=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",c=await UJ(e,t,n+l,{headers:i,noResolveJson:r==null?void 0:r.noResolveJson},{},r==null?void 0:r.body);return r!=null&&r.xform?r==null?void 0:r.xform(c):{data:Object.assign({},c),error:null}}async function UJ(e,t,n,r,s,i){const o=BJ(t,r,s,i);let l;try{l=await e(n,Object.assign({},o))}catch(c){throw console.error(c),new r1(Hl(c),0)}if(l.ok||await gO(l),r!=null&&r.noResolveJson)return l;try{return await l.json()}catch(c){await gO(c)}}function Ss(e){var t;let n=null;HJ(e)&&(n=Object.assign({},e),e.expires_at||(n.expires_at=SJ(e.expires_in)));const r=(t=e.user)!==null&&t!==void 0?t:e;return{data:{session:n,user:r},error:null}}function xO(e){const t=Ss(e);return!t.error&&e.weak_password&&typeof e.weak_password=="object"&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&typeof e.weak_password.message=="string"&&e.weak_password.reasons.reduce((n,r)=>n&&typeof r=="string",!0)&&(t.data.weak_password=e.weak_password),t}function Ro(e){var t;return{data:{user:(t=e.user)!==null&&t!==void 0?t:e},error:null}}function WJ(e){return{data:e,error:null}}function KJ(e){const{action_link:t,email_otp:n,hashed_token:r,redirect_to:s,verification_type:i}=e,o=uh(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),l={action_link:t,email_otp:n,hashed_token:r,redirect_to:s,verification_type:i},c=Object.assign({},o);return{data:{properties:l,user:c},error:null}}function yO(e){return e}function HJ(e){return e.access_token&&e.refresh_token&&e.expires_in}const gw=["global","local","others"];class GJ{constructor({url:t="",headers:n={},fetch:r}){this.url=t,this.headers=n,this.fetch=p4(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}
vendor: 4,780 bytes, line 639
639async signOut(t,n=gw[0]){if(gw.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${gw.join(", ")}`);try{return await wt(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:t,noResolveJson:!0}),{data:null,error:null}}catch(r){if(ft(r))return{data:null,error:r};throw r}}async inviteUserByEmail(t,n={}){try{return await wt(this.fetch,"POST",`${this.url}/invite`,{body:{email:t,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:Ro})}catch(r){if(ft(r))return{data:{user:null},error:r};throw r}}async generateLink(t){try{const{options:n}=t,r=uh(t,["options"]),s=Object.assign(Object.assign({},r),n);return"newEmail"in r&&(s.new_email=r==null?void 0:r.newEmail,delete s.newEmail),await wt(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:KJ,redirectTo:n==null?void 0:n.redirectTo})}catch(n){if(ft(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(t){try{return await wt(this.fetch,"POST",`${this.url}/admin/users`,{body:t,headers:this.headers,xform:Ro})}catch(n){if(ft(n))return{data:{user:null},error:n};throw n}}async listUsers(t){var n,r,s,i,o,l,c;try{const u={nextPage:null,lastPage:0,total:0},d=await wt(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=t==null?void 0:t.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(i=(s=t==null?void 0:t.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:yO});if(d.error)throw d.error;const h=await d.json(),m=(o=d.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(c=(l=d.headers.get("link"))===null||l===void 0?void 0:l.split(","))!==null&&c!==void 0?c:[];return f.length>0&&(f.forEach(x=>{const g=parseInt(x.split(";")[0].split("=")[1].substring(0,1)),p=JSON.parse(x.split(";")[1].split("=")[1]);u[`${p}Page`]=g}),u.total=parseInt(m)),{data:Object.assign(Object.assign({},h),u),error:null}}catch(u){if(ft(u))return{data:{users:[]},error:u};throw u}}async getUserById(t){iu(t);try{return await wt(this.fetch,"GET",`${this.url}/admin/users/${t}`,{headers:this.headers,xform:Ro})}catch(n){if(ft(n))return{data:{user:null},error:n};throw n}}async updateUserById(t,n){iu(t);try{return await wt(this.fetch,"PUT",`${this.url}/admin/users/${t}`,{body:n,headers:this.headers,xform:Ro})}catch(r){if(ft(r))return{data:{user:null},error:r};throw r}}async deleteUser(t,n=!1){iu(t);try{return await wt(this.fetch,"DELETE",`${this.url}/admin/users/${t}`,{headers:this.headers,body:{should_soft_delete:n},xform:Ro})}catch(r){if(ft(r))return{data:{user:null},error:r};throw r}}async _listFactors(t){iu(t.userId);try{const{data:n,error:r}=await wt(this.fetch,"GET",`${this.url}/admin/users/${t.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:n,error:r}}catch(n){if(ft(n))return{data:null,error:n};throw n}}async _deleteFactor(t){iu(t.userId),iu(t.id);try{return{data:await wt(this.fetch,"DELETE",`${this.url}/admin/users/${t.userId}/factors/${t.id}`,{headers:this.headers}),error:null}}catch(n){if(ft(n))return{data:null,error:n};throw n}}async _listOAuthClients(t){var n,r,s,i,o,l,c;try{const u={nextPage:null,lastPage:0,total:0},d=await wt(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(n=t==null?void 0:t.page)===null||n===void 0?void 0:n.toString())!==null&&r!==void 0?r:"",per_page:(i=(s=t==null?void 0:t.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:yO});if(d.error)throw d.error;const h=await d.json(),m=(o=d.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(c=(l=d.headers.get("link"))===null||l===void 0?void 0:l.split(","))!==null&&c!==void 0?c:[];return f.length>0&&(f.forEach(x=>{const g=parseInt(x.split(";")[0].split("=")[1].substring(0,1)),p=JSON.parse(x.split(";")[1].split("=")[1]);u[`${p}Page`]=g}),u.total=parseInt(m)),{data:Object.assign(Object.assign({},h),u),error:null}}catch(u){if(ft(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(t){try{return await wt(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:t,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ft(n))return{data:null,error:n};throw n}}async _getOAuthClient(t){try{return await wt(this.fetch,"GET",`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ft(n))return{data:null,error:n};throw n}}async _updateOAuthClient(t,n){try{return await wt(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${t}`,{body:n,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(ft(r))return{data:null,error:r};throw r}}async _deleteOAuthClient(t){try{return await wt(this.fetch,"DELET
639E",`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ft(n))return{data:null,error:n};throw n}}async _regenerateOAuthClientSecret(t){try{return await wt(this.fetch,"POST",`${this.url}/admin/oauth/clients/${t}/regenerate_secret`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ft(n))return{data:null,error:n};throw n}}}function vO(e={}){return{getItem:t=>e[t]||null,setItem:(t,n)=>{e[t]=n},removeItem:t=>{delete e[t]}}}const ou={debug:!!(globalThis&&m4()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class g4 extends Error{constructor(t){super(t),this.isAcquireTimeout=!0}}class VJ extends g4{}async function YJ(e,t,n){ou.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);const r=new globalThis.AbortController;return t>0&&setTimeout(()=>{r.abort(),ou.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,t===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:r.signal},async s=>{if(s){ou.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,s.name);try{return await n()}finally{ou.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,s.name)}}else{if(t===0)throw ou.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new VJ(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(ou.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null," "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await n()}}))}function QJ(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function x4(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw new Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}function XJ(e){return parseInt(e,16)}function JJ(e){const t=new TextEncoder().encode(e);return"0x"+Array.from(t,r=>r.toString(16).padStart(2,"0")).join("")}function ZJ(e){var t;const{chainId:n,domain:r,expirationTime:s,issuedAt:i=new Date,nonce:o,notBefore:l,requestId:c,resources:u,scheme:d,uri:h,version:m}=e;{if(!Number.isInteger(n))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${n}`);if(!r)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${o}`);if(!h)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(m!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${m}`);if(!((t=e.statement)===null||t===void 0)&&t.includes(` 640`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`)}const f=x4(e.address),x=d?`${d}://${r}
640`:r,g=e.statement?`${e.statement} 641`:"",p=`${x} wants you to sign in with your Ethereum account: 642${f} 643 644${g}`;let v=`URI: ${h} 645Version: ${m} 646Chain ID: ${n}${o?` 647Nonce: ${o}`:""} 648Issued At: ${i.toISOString()}`;if(s&&(v+=` 649Expiration Time: ${s.toISOString()}`),l&&(v+=` 650Not Before: ${l.toISOString()}`),c&&(v+=` 651Request ID: ${c}`),u){let b=` 652Resources:`;for(const w of u){if(!w||typeof w!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${w}`);b+=` 653- ${w}`}v+=b}return`${p} 654${v}`}class Qn extends Error{constructor({message:t,code:n,cause:r,name:s}){var i;super(t,{cause:r}),this.__isWebAuthnError=!0,this.name=(i=s??(r instanceof Error?r.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=n}}class ry extends Qn{constructor(t,n){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n,message:t}),this.name="WebAuthnUnknownError",this.originalError=n}}function eZ({error:e,options:t}){var n,r,s;const{publicKey:i}=t;if(!i)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new Qn({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if(e.name==="ConstraintError"){if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.requireResidentKey)===!0)return new Qn({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if(t.mediation==="conditional"&&((r=i.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new Qn({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if(((s=i.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new Qn({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if(e.name==="InvalidStateError")return new Qn({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if(e.name==="NotAllowedError")return new Qn({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="NotSupportedError")return i.pubKeyCredParams.filter(l=>l.type==="public-key").length===0?new Qn({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new Qn({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if(e.name==="SecurityError"){const o=window.location.hostname;if(y4(o)){if(i.rp.id!==o)return new Qn({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new Qn({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new Qn({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if(e.name==="UnknownError")return new Qn({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new Qn({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}function tZ({error:e,options:t}){const{publicKey:n}=t;if(!n)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new Qn({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if(e.name==="NotAllowedError")return new Qn({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="SecurityError"){const r=window.location.hostname;if(y4(r)){if(n.rpId!==r)return new Qn({message:`The RP ID "${n.rpId}
654" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new Qn({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="UnknownError")return new Qn({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new Qn({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}class nZ{createNewAbortSignal(){if(this.controller){const n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n)}const t=new AbortController;return this.controller=t,t.signal}cancelCeremony(){if(this.controller){const t=new Error("Manually cancelling existing WebAuthn API call");t.name="AbortError",this.controller.abort(t),this.controller=void 0}}}const rZ=new nZ;function aZ(e){if(!e)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(e);const{challenge:t,user:n,excludeCredentials:r}=e,s=uh(e,["challenge","user","excludeCredentials"]),i=Zu(t).buffer,o=Object.assign(Object.assign({},n),{id:Zu(n.id).buffer}),l=Object.assign(Object.assign({},s),{challenge:i,user:o});if(r&&r.length>0){l.excludeCredentials=new Array(r.length);for(let c=0;c<r.length;c++){const u=r[c];l.excludeCredentials[c]=Object.assign(Object.assign({},u),{id:Zu(u.id).buffer,type:u.type||"public-key",transports:u.transports})}}return l}function sZ(e){if(!e)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(e);const{challenge:t,allowCredentials:n}=e,r=uh(e,["challenge","allowCredentials"]),s=Zu(t).buffer,i=Object.assign(Object.assign({},r),{challenge:s});if(n&&n.length>0){i.allowCredentials=new Array(n.length);for(let o=0;o<n.length;o++){const l=n[o];i.allowCredentials[o]=Object.assign(Object.assign({},l),{id:Zu(l.id).buffer,type:l.type||"public-key",transports:l.transports})}}return i}function iZ(e){var t;if("toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();const n=e;return{id:e.id,rawId:e.id,response:{attestationObject:rc(new Uint8Array(e.response.attestationObject)),clientDataJSON:rc(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:(t=n.authenticatorAttachment)!==null&&t!==void 0?t:void 0}}function oZ(e){var t;if("toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();const n=e,r=e.getClientExtensionResults(),s=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:rc(new Uint8Array(s.authenticatorData)),clientDataJSON:rc(new Uint8Array(s.clientDataJSON)),signature:rc(new Uint8Array(s.signature)),userHandle:s.userHandle?rc(new Uint8Array(s.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:(t=n.authenticatorAttachment)!==null&&t!==void 0?t:void 0}}function y4(e){return e==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function bO(){var e,t;return!!(Er()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((e=navigator==null?void 0:navigator.credentials)===null||e===void 0?void 0:e.create)=="function"&&typeof((t=navigator==null?void 0:navigator.credentials)===null||t===void 0?void 0:t.get)=="function")}async function lZ(e){try{const t=await navigator.credentials.create(e);return t?t instanceof PublicKeyCredential?{data:t,error:null}:{data:null,error:new ry("Browser returned unexpected credential type",t)}:{data:null,error:new ry("Empty credential response",t)}}catch(t){return{data:null,error:eZ({error:t,options:e})}}}async function cZ(e){try{const t=await navigator.credentials.get(e);return t?t instanceof PublicKeyCredential?{data:t,error:null}:{data:null,error:new ry("Browser returned unexpected credential type",t)}:{data:null,error:new ry("Empty credential response",t)}}
654catch(t){return{data:null,error:tZ({error:t,options:e})}}}const uZ={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},dZ={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function ay(...e){const t=s=>s!==null&&typeof s=="object"&&!Array.isArray(s),n=s=>s instanceof ArrayBuffer||ArrayBuffer.isView(s),r={};for(const s of e)if(s)for(const i in s){const o=s[i];if(o!==void 0)if(Array.isArray(o))r[i]=o;else if(n(o))r[i]=o;else if(t(o)){const l=r[i];t(l)?r[i]=ay(l,o):r[i]=ay(o)}else r[i]=o}return r}function hZ(e,t){return ay(uZ,e,t||{})}function fZ(e,t){return ay(dZ,e,t||{})}class mZ{constructor(t){this.client=t,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(t){return this.client.mfa.enroll(Object.assign(Object.assign({},t),{factorType:"webauthn"}))}async _challenge({factorId:t,webauthn:n,friendlyName:r,signal:s},i){var o;try{const{data:l,error:c}=await this.client.mfa.challenge({factorId:t,webauthn:n});if(!l)return{data:null,error:c};const u=s??rZ.createNewAbortSignal();if(l.webauthn.type==="create"){const{user:d}=l.webauthn.credential_options.publicKey;if(!d.name){const h=r;if(h)d.name=`${d.id}:${h}`;else{const f=(await this.client.getUser()).data.user,x=((o=f==null?void 0:f.user_metadata)===null||o===void 0?void 0:o.name)||(f==null?void 0:f.email)||(f==null?void 0:f.id)||"User";d.name=`${d.id}:${x}`}}d.displayName||(d.displayName=d.name)}switch(l.webauthn.type){case"create":{const d=hZ(l.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:h,error:m}=await lZ({publicKey:d,signal:u});return h?{data:{factorId:t,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:h}},error:null}:{data:null,error:m}}case"request":{const d=fZ(l.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:h,error:m}=await cZ(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:d,signal:u}));return h?{data:{factorId:t,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:h}},error:null}:{data:null,error:m}}}}catch(l){return ft(l)?{data:null,error:l}:{data:null,error:new Jl("Unexpected error in challenge",l)}}}async _verify({challengeId:t,factorId:n,webauthn:r}){return this.client.mfa.verify({factorId:n,challengeId:t,webauthn:r})}async _authenticate({factorId:t,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:s}={}},i){if(!n)return{data:null,error:new fm("rpId is required for WebAuthn authentication")};try{if(!bO())return{data:null,error:new Jl("Browser does not support WebAuthn",null)};const{data:o,error:l}=await this.challenge({factorId:t,webauthn:{rpId:n,rpOrigins:r},signal:s},{request:i});if(!o)return{data:null,error:l};const{webauthn:c}=o;return this._verify({factorId:t,challengeId:o.challengeId,webauthn:{type:c.type,rpId:n,rpOrigins:r,credential_response:c.credential_response}})}catch(o){return ft(o)?{data:null,error:o}:{data:null,error:new Jl("Unexpected error in authenticate",o)}}}async _register({friendlyName:t,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:r=typeof window<"u"?[window.location.origin]:void 0,signal:s}={}},i){if(!n)return{data:null,error:new fm("rpId is required for WebAuthn registration")};try{if(!bO())return{data:null,error:new Jl("Browser does not support WebAuthn",null)};const{data:o,error:l}=await this._enroll({friendlyName:t});if(!o)return await this.client.mfa.listFactors().then(d=>{var h;return(h=d.data)===null||h===void 0?void 0:h.all.find(m=>m.factor_type==="webauthn"&&m.friendly_name===t&&m.status!=="unverified")}).then(d=>d?this.client.mfa.unenroll({factorId:d==null?void 0:d.id}):void 0),{data:null,error:l};const{data:c,error:u}=await this._challenge({factorId:o.id,friendlyName:o.friendly_name,webauthn:{rpId:n,rpOrigins:r},signal:s},{create:i});return c?this._verify({factorId:o.id,challengeId:c.challengeId,webauthn:{rpId:n,rpOrigins:r,type:c.webauthn.type,credential_response:c.webauthn.credential_response}}):{data:null,error:u}}
654catch(o){return ft(o)?{data:null,error:o}:{data:null,error:new Jl("Unexpected error in register",o)}}}}QJ();const pZ={url:dJ,storageKey:hJ,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:fJ,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:1e4};async function wO(e,t,n){return await n()}const lu={};class mm{get jwks(){var t,n;return(n=(t=lu[this.storageKey])===null||t===void 0?void 0:t.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(t){lu[this.storageKey]=Object.assign(Object.assign({},lu[this.storageKey]),{jwks:t})}get jwks_cached_at(){var t,n;return(n=(t=lu[this.storageKey])===null||t===void 0?void 0:t.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(t){lu[this.storageKey]=Object.assign(Object.assign({},lu[this.storageKey]),{cachedAt:t})}constructor(t){var n,r,s;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const i=Object.assign(Object.assign({},pZ),t);if(this.storageKey=i.storageKey,this.instanceID=(n=mm.nextInstanceID[this.storageKey])!==null&&n!==void 0?n:0,mm.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!i.debug,typeof i.debug=="function"&&(this.logger=i.debug),this.instanceID>0&&Er()){const o=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(o),this.logDebugMessages&&console.trace(o)}if(this.persistSession=i.persistSession,this.autoRefreshToken=i.autoRefreshToken,this.admin=new GJ({url:i.url,headers:i.headers,fetch:i.fetch}),this.url=i.url,this.headers=i.headers,this.fetch=p4(i.fetch),this.lock=i.lock||wO,this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,this.throwOnError=i.throwOnError,this.lockAcquireTimeout=i.lockAcquireTimeout,i.lock?this.lock=i.lock:this.persistSession&&Er()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=YJ:this.lock=wO,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new mZ(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession?(i.storage?this.storage=i.storage:m4()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=vO(this.memoryStorage)),i.userStorage&&(this.userStorage=i.userStorage)):(this.memoryStorage={},this.storage=vO(this.memoryStorage)),Er()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(s=this.broadcastChannel)===null||s===void 0||s.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o);try{await this._notifyAllSubscribers(o.data.event,o.data.session,!1)}catch(l){this._debug("#broadcastChannel","error",l)}})}this.initialize().catch(o=>{this._debug("#initialize()","error",o)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(t){if(this.throwOnError&&t&&t.error)throw t.error;return t}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${d4}) ${new Date().toISOString()}`}_debug(...t){return this.logDebugMessages&&this.logger(this._logPrefix(),...t),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var t;try{let n={},r="none";if(Er()&&(n=kJ(window.location.href),this._isImplicitGrantCallback(n)?r="implicit":await this._isPKCECallback(n)&&(r="pkce")),Er()&&this.detectSessionInUrl&&r!=="none"){const{data:s,error:i}=await this._getSessionFromURL(n,r);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),yJ(i)){const c=(t=i.details)===null||t===void 0?void 0:t.code;if(c==="identity_already_exists"||c==="identity_not_found"||c==="single_identity_not_deletable")return{error:i}}return{error:i}}const{session:o,redirectType:l}=s;return this._debug("#_initialize()","detected session in URL",o,"redirect type",l),await this._saveSession(o),setTimeout(async()=>{l==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(n){return ft(n)?this._returnResult({error:n}):this._returnResult({error:new Jl("Unexpected error during initialization",n)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(t){var n,r,s;try{const i=await wt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(r=(n=t==null?void 0:t.options)===null||n===void 0?void 0:n.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:(s=t==null?void 0:t.options)===null||s===void 0?void 0:s.captchaToken}},xform:Ss}),{data:o,error:l}=i;if(l||!o)return this._returnResult({data:{user:null,session:null},error:l});const c=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),this._returnResult({data:{user:u,session:c},error:null})}catch(i){if(ft(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signUp(t){var n,r,s;try{let i;if("email"in t){const{email:d,password:h,options:m}=t;let f=null,x=null;this.flowType==="pkce"&&([f,x]=await su(this.storage,this.storageKey)),i=await wt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:m==null?void 0:m.emailRedirectTo,body:{email:d,password:h,data:(n=m==null?void 0:m.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:m==null?void 0:m.captchaToken},code_challenge:f,code_challenge_method:x},xform:Ss})}else if("phone"in t){const{phone:d,password:h,options:m}=t;i=await wt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:d,password:h,data:(r=m==null?void 0:m.data)!==null&&r!==void 0?r:{},channel:(s=m==null?void 0:m.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:m==null?void 0:m.captchaToken}},xform:Ss})}else throw new bg("You must provide either an email or phone number and a password");const{data:o,error:l}=i;if(l||!o)return await Cr(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:l});const c=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),this._returnResult({data:{user:u,session:c},error:null})}catch(i){if(await Cr(this.storage,`${this.storageKey}-code-verifier`),ft(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signInWithPassword(t){try{let n;if("email"in t){const{email:i,password:o,options:l}=t;n=await wt(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:xO})}else if("phone"in t){const{phone:i,password:o,options:l}=t;n=await wt(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:xO})}else throw new bg("You must provide either an email or phone number and a password");const{data:r,error:s}=n;if(s)return this._returnResult({data:{user:null,session:null},error:s});if(!r||!r.session||!r.user){const i=new au;return this._returnResult({data:{user:null,session:null},error:i})}return r.session&&(await this._saveSession(r.session),await this._notifyAllSubscribers("SIGNED_IN",r.session)),this._returnResult({data:Object.assign({user:r.user,session:r.session},r.weak_password?{weakPassword:r.weak_password}:null),error:s})}catch(n){if(ft(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOAuth(t){var n,r,s,i;return await this._handleProviderSignIn(t.provider,{redirectTo:(n=t.options)===null||n===void 0?void 0:n.redirectTo,scopes:(r=t.options)===null||r===void 0?void 0:r.scopes,queryParams:(s=t.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(i=t.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(t){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(t))}async signInWithWeb3(t){const{chain:n}=t;switch(n){case"ethereum":return await this.signInWithEthereum(t);case"solana":return await this.signInWithSolana(t);default:throw new Error(`@supabase/auth-js: Unsupported chain "${n}"`)}}async signInWithEthereum(t){var n,r,s,i,o,l,c,u,d,h,m;let f,x;if("message"in t)f=t.message,x=t.signature;else{const{chain:g,wallet:p,statement:v,options:b}=t;let w;if(Er())if(typeof p=="object")w=p;
654else{const k=window;if("ethereum"in k&&typeof k.ethereum=="object"&&"request"in k.ethereum&&typeof k.ethereum.request=="function")w=k.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof p!="object"||!(b!=null&&b.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");w=p}const N=new URL((n=b==null?void 0:b.url)!==null&&n!==void 0?n:window.location.href),j=await w.request({method:"eth_requestAccounts"}).then(k=>k).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!j||j.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const _=x4(j[0]);let S=(r=b==null?void 0:b.signInWithEthereum)===null||r===void 0?void 0:r.chainId;if(!S){const k=await w.request({method:"eth_chainId"});S=XJ(k)}const P={domain:N.host,address:_,statement:v,uri:N.href,version:"1",chainId:S,nonce:(s=b==null?void 0:b.signInWithEthereum)===null||s===void 0?void 0:s.nonce,issuedAt:(o=(i=b==null?void 0:b.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(l=b==null?void 0:b.signInWithEthereum)===null||l===void 0?void 0:l.expirationTime,notBefore:(c=b==null?void 0:b.signInWithEthereum)===null||c===void 0?void 0:c.notBefore,requestId:(u=b==null?void 0:b.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(d=b==null?void 0:b.signInWithEthereum)===null||d===void 0?void 0:d.resources};f=ZJ(P),x=await w.request({method:"personal_sign",params:[JJ(f),_]})}try{const{data:g,error:p}=await wt(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:x},!((h=t.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(m=t.options)===null||m===void 0?void 0:m.captchaToken}}:null),xform:Ss});if(p)throw p;if(!g||!g.session||!g.user){const v=new au;return this._returnResult({data:{user:null,session:null},error:v})}return g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("SIGNED_IN",g.session)),this._returnResult({data:Object.assign({},g),error:p})}catch(g){if(ft(g))return this._returnResult({data:{user:null,session:null},error:g});throw g}}async signInWithSolana(t){var n,r,s,i,o,l,c,u,d,h,m,f;let x,g;if("message"in t)x=t.message,g=t.signature;else{const{chain:p,wallet:v,statement:b,options:w}=t;let N;if(Er())if(typeof v=="object")N=v;else{const _=window;if("solana"in _&&typeof _.solana=="object"&&("signIn"in _.solana&&typeof _.solana.signIn=="function"||"signMessage"in _.solana&&typeof _.solana.signMessage=="function"))N=_.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof v!="object"||!(w!=null&&w.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");N=v}const j=new URL((n=w==null?void 0:w.url)!==null&&n!==void 0?n:window.location.href);if("signIn"in N&&N.signIn){const _=await N.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},w==null?void 0:w.signInWithSolana),{version:"1",domain:j.host,uri:j.href}),b?{statement:b}:null));let S;if(Array.isArray(_)&&_[0]&&typeof _[0]=="object")S=_[0];else if(_&&typeof _=="object"&&"signedMessage"in _&&"signature"in _)S=_;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in S&&"signature"in S&&(typeof S.signedMessage=="string"||S.signedMessage instanceof Uint8Array)&&S.signature instanceof Uint8Array)x=typeof S.signedMessage=="string"?S.signedMessage:new TextDecoder().decode(S.signedMessage),g=S.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in N)||typeof N.signMessage!="function"||!("publicKey"in N)||typeof N!="object"||!N.publicKey||!("toBase58"in N.publicKey)||typeof N.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");x=[`${j.host} wants you to sign in with your Solana account:`,N.publicKey.toBase58(),...b?["",b,""]:[""],"Version: 1",`URI: ${j.href}`,`Issued At: ${(s=(r=w==null?void 0:w.signInWithSolana)===null||r===void 0?void 0:r.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((i=w==null?void 0:w.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${w.signInWithSolana.notBefore}`]:[],...!((o=w==null?void 0:w.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${w.signInWithSolana.expirationTime}`]:[],...!((l=w==null?void 0:w.signInWithSolana)===null||l===void 0)&&l.chainId?[`Chain ID: ${w.signInWithSolana.chainId}`]:[],...!((c=w==null?void 0:w.signInWithSolana)===null||c===void 0)&&c.nonce?[`Nonce: ${w.signInWithSolana.nonce}`]:[],...!((u=w==null?void 0:w.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${w.signInWithSolana.requestId}`]:[],...!((h=(d=w==null?void 0:w.signInWithSolana)===null||d===void 0?void 0:d.resources)===null||h===void 0)&&h.length?["Resources",...w.sign
654InWithSolana.resources.map(S=>`- ${S}`)]:[]].join(` 655`);const _=await N.signMessage(new TextEncoder().encode(x),"utf8");if(!_||!(_ instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");g=_}}try{const{data:p,error:v}=await wt(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:x,signature:rc(g)},!((m=t.options)===null||m===void 0)&&m.captchaToken?{gotrue_meta_security:{captcha_token:(f=t.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:Ss});if(v)throw v;if(!p||!p.session||!p.user){const b=new au;return this._returnResult({data:{user:null,session:null},error:b})}return p.session&&(await this._saveSession(p.session),await this._notifyAllSubscribers("SIGNED_IN",p.session)),this._returnResult({data:Object.assign({},p),error:v})}catch(p){if(ft(p))return this._returnResult({data:{user:null,session:null},error:p});throw p}}async _exchangeCodeForSession(t){const n=await Bl(this.storage,`${this.storageKey}-code-verifier`),[r,s]=(n??"").split("/");try{if(!r&&this.flowType==="pkce")throw new vJ;const{data:i,error:o}=await wt(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:t,code_verifier:r},xform:Ss});if(await Cr(this.storage,`${this.storageKey}-code-verifier`),o)throw o;if(!i||!i.session||!i.user){const l=new au;return this._returnResult({data:{user:null,session:null,redirectType:null},error:l})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),this._returnResult({data:Object.assign(Object.assign({},i),{redirectType:s??null}),error:o})}catch(i){if(await Cr(this.storage,`${this.storageKey}-code-verifier`),ft(i))return this._returnResult({data:{user:null,session:null,redirectType:null},error:i});throw i}}async signInWithIdToken(t){try{const{options:n,provider:r,token:s,access_token:i,nonce:o}=t,l=await wt(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:n==null?void 0:n.captchaToken}},xform:Ss}),{data:c,error:u}=l;if(u)return this._returnResult({data:{user:null,session:null},error:u});if(!c||!c.session||!c.user){const d=new au;return this._returnResult({data:{user:null,session:null},error:d})}return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),this._returnResult({data:c,error:u})}catch(n){if(ft(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOtp(t){var n,r,s,i,o;try{if("email"in t){const{email:l,options:c}=t;let u=null,d=null;this.flowType==="pkce"&&([u,d]=await su(this.storage,this.storageKey));const{error:h}=await wt(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:l,data:(n=c==null?void 0:c.data)!==null&&n!==void 0?n:{},create_user:(r=c==null?void 0:c.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},code_challenge:u,code_challenge_method:d},redirectTo:c==null?void 0:c.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:h})}if("phone"in t){const{phone:l,options:c}=t,{data:u,error:d}=await wt(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:l,data:(s=c==null?void 0:c.data)!==null&&s!==void 0?s:{},create_user:(i=c==null?void 0:c.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(o=c==null?void 0:c.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:d})}throw new bg("You must provide either an email or phone number.")}catch(l){if(await Cr(this.storage,`${this.storageKey}-code-verifier`),ft(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async verifyOtp(t){var n,r;try{let s,i;"options"in t&&(s=(n=t.options)===null||n===void 0?void 0:n.redirectTo,i=(r=t.options)===null||r===void 0?void 0:r.captchaToken);const{data:o,error:l}=await wt(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},t),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:Ss});if(l)throw l;if(!o)throw new Error("An error occurred on token verification.");const c=o.session,u=o.user;return c!=null&&c.access_token&&(await this._saveSession(c),await this._notifyAllSubscribers(t.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c)),this._returnResult({data:{user:u,session:c},error:null})}catch(s){if(ft(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithSSO(t){var n,r,s,i,o;try{let l=null,c=null;this.flowType==="pkce"&&([l,c]=await su(this.storage,this.storageKey));const u=await wt(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in t?{provider_id:t.providerId}:null),"domain"in t?{domain:t.domain}:null),{redirect_to:(r=(n=t.options)===null||n===void 0?void 0:n.redirectTo)!==null&&r!==void 0?r:void 0}),!((s=t==null?void 0:t.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:t.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:l,code_challenge_method:c}),headers:this.headers,xform:WJ});return!((i=u.data)===null||i===void 0)&&i.url&&Er()&&!(!((o=t.options)===null||o===void 0)&&o.skipBrowserRedirect)&&window.location.assign(u.data.url),this._returnResult(u)}catch(l){if(await Cr(this.storage,`${this.storageKey}-code-verifier`),ft(l))return this._returnResult({data:null,error:l});throw l}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async t=>{const{data:{session:n},error:r}=t;if(r)throw r;if(!n)throw new Pa;const{error:s}=await wt(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return this._returnResult({data:{user:null,session:null},error:s})})}catch(t){if(ft(t))return this._returnResult({data:{user:null,session:null},error:t});throw t}}async resend(t){try{const n=`${this.url}/resend`;if("email"in t){const{email:r,type:s,options:i}=t,{error:o}=await wt(this.fetch,"POST",n,{headers:this.headers,body:{email:r,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:o})}else if("phone"in t){const{phone:r,type:s,options:i}=t,{data:o,error:l}=await wt(this.fetch,"POST",n,{headers:this.headers,body:{phone:r,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:l})}throw new bg("You must provide either an email or phone number and a type")}catch(n){if(ft(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async n=>n))}async _acquireLock(t,n){this._debug("#_acquireLock","begin",t);try{if(this.lockAcquired){const r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await r,await n()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,t,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const r=n();for(this.pendingInLock.push((async()=>{try{await r}catch{}})()),await r;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await r}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(t){this._debug("#_useSession","begin");try{const n=await this.__loadSession();return await t(n)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let t=null;const n=await Bl(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?t=n:(this._debug("#getSession()","session from storage is not val
655id"),await this._removeSession())),!t)return{data:{session:null},error:null};const r=t.expires_at?t.expires_at*1e3-Date.now()<hw:!1;if(this._debug("#__loadSession()",`session has${r?"":" not"} expired`,"expires_at",t.expires_at),!r){if(this.userStorage){const o=await Bl(this.userStorage,this.storageKey+"-user");o!=null&&o.user?t.user=o.user:t.user=pw()}if(this.storage.isServer&&t.user&&!t.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};t.user=qJ(t.user,o),o.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:t},error:null}}const{data:s,error:i}=await this._callRefreshToken(t.refresh_token);return i?this._returnResult({data:{session:null},error:i}):this._returnResult({data:{session:s},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(t){if(t)return await this._getUser(t);await this.initializePromise;const n=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return n.data.user&&(this.suppressGetSessionWarning=!0),n}async _getUser(t){try{return t?await wt(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:t,xform:Ro}):await this._useSession(async n=>{var r,s,i;const{data:o,error:l}=n;if(l)throw l;return!(!((r=o.session)===null||r===void 0)&&r.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Pa}:await wt(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(s=o.session)===null||s===void 0?void 0:s.access_token)!==null&&i!==void 0?i:void 0,xform:Ro})})}catch(n){if(ft(n))return fw(n)&&(await this._removeSession(),await Cr(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:n});throw n}}async updateUser(t,n={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(t,n))}async _updateUser(t,n={}){try{return await this._useSession(async r=>{const{data:s,error:i}=r;if(i)throw i;if(!s.session)throw new Pa;const o=s.session;let l=null,c=null;this.flowType==="pkce"&&t.email!=null&&([l,c]=await su(this.storage,this.storageKey));const{data:u,error:d}=await wt(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:n==null?void 0:n.emailRedirectTo,body:Object.assign(Object.assign({},t),{code_challenge:l,code_challenge_method:c}),jwt:o.access_token,xform:Ro});if(d)throw d;return o.user=u.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),this._returnResult({data:{user:o.user},error:null})})}catch(r){if(await Cr(this.storage,`${this.storageKey}-code-verifier`),ft(r))return this._returnResult({data:{user:null},error:r});throw r}}async setSession(t){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(t))}async _setSession(t){try{if(!t.access_token||!t.refresh_token)throw new Pa;const n=Date.now()/1e3;let r=n,s=!0,i=null;const{payload:o}=_g(t.access_token);if(o.exp&&(r=o.exp,s=r<=n),s){const{data:l,error:c}=await this._callRefreshToken(t.refresh_token);if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l)return{data:{user:null,session:null},error:null};i=l}else{const{data:l,error:c}=await this._getUser(t.access_token);if(c)return this._returnResult({data:{user:null,session:null},error:c});i={access_token:t.access_token,refresh_token:t.refresh_token,user:l.user,token_type:"bearer",expires_in:r-n,expires_at:r},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(n){if(ft(n))return this._returnResult({data:{session:null,user:null},error:n});throw n}}async refreshSession(t){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(t))}async _refreshSession(t){try{return await this._useSession(async n=>{var r;if(!t){const{data:o,error:l}=n;if(l)throw l;t=(r=o.session)!==null&&r!==void 0?r:void 0}if(!(t!=null&&t.refresh_token))throw new Pa;const{data:s,error:i}=await this._callRefreshToken(t.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):s?this._returnResult({data:{user:s.user,session:s},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(n){if(ft(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async _getSessionFromURL(t,n){try{if(!Er())throw new wg("No browser detected.");
655if(t.error||t.error_description||t.error_code)throw new wg(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});switch(n){case"implicit":if(this.flowType==="pkce")throw new uO("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new wg("Not a valid implicit grant flow url.");break;default:}if(n==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!t.code)throw new uO("No code detected.");const{data:b,error:w}=await this._exchangeCodeForSession(t.code);if(w)throw w;const N=new URL(window.location.href);return N.searchParams.delete("code"),window.history.replaceState(window.history.state,"",N.toString()),{data:{session:b.session,redirectType:null},error:null}}const{provider_token:r,provider_refresh_token:s,access_token:i,refresh_token:o,expires_in:l,expires_at:c,token_type:u}=t;if(!i||!l||!o||!u)throw new wg("No session defined in URL");const d=Math.round(Date.now()/1e3),h=parseInt(l);let m=d+h;c&&(m=parseInt(c));const f=m-d;f*1e3<=Su&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${f}s, should have been closer to ${h}s`);const x=m-h;d-x>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",x,m,d):d-x<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",x,m,d);const{data:g,error:p}=await this._getUser(i);if(p)throw p;const v={provider_token:r,provider_refresh_token:s,access_token:i,expires_in:h,expires_at:m,refresh_token:o,token_type:u,user:g.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:v,redirectType:t.type},error:null})}catch(r){if(ft(r))return this._returnResult({data:{session:null,redirectType:null},error:r});throw r}}_isImplicitGrantCallback(t){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),t):!!(t.access_token||t.error_description)}async _isPKCECallback(t){const n=await Bl(this.storage,`${this.storageKey}-code-verifier`);return!!(t.code&&n)}async signOut(t={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(t))}async _signOut({scope:t}={scope:"global"}){return await this._useSession(async n=>{var r;const{data:s,error:i}=n;if(i&&!fw(i))return this._returnResult({error:i});const o=(r=s.session)===null||r===void 0?void 0:r.access_token;if(o){const{error:l}=await this.admin.signOut(o,t);if(l&&!(xJ(l)&&(l.status===404||l.status===401||l.status===403)||fw(l)))return this._returnResult({error:l})}return t!=="others"&&(await this._removeSession(),await Cr(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(t){const n=CJ(),r={id:n,callback:t,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",n),this.stateChangeEmitters.delete(n)}};return this._debug("#onAuthStateChange()","registered callback with id",n),this.stateChangeEmitters.set(n,r),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(n)})))(),{data:{subscription:r}}}async _emitInitialSession(t){return await this._useSession(async n=>{var r,s;try{const{data:{session:i},error:o}=n;if(o)throw o;await((r=this.stateChangeEmitters.get(t))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",t,"session",i)}catch(i){await((s=this.stateChangeEmitters.get(t))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",t,"error",i),console.error(i)}})}async resetPasswordForEmail(t,n={}){let r=null,s=null;this.flowType==="pkce"&&([r,s]=await su(this.storage,this.storageKey,!0));try{return await wt(this.fetch,"POST",`${this.url}/recover`,{body:{email:t,code_challenge:r,code_challenge_method:s,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:n.redirectTo})}catch(i){if(await Cr(this.storage,`${this.storageKey}-code-verifier`),ft(i))return this._returnResult({data:null,error:i});throw i}}async getUserIdentities(){var t;try{const{data:n,error:r}=await this.getUser();if(r)throw r;return this._returnResult({data:{identities:(t=n.user.identities)!==null&&t!==void 0?t:[]},error:null})}catch(n){if(ft(n))return this._returnResult({data:null,error:n});throw n}}async linkIdentity(t){return"token"in t?this.linkIdentityIdToken(t):this.linkIdentityOAuth(t)}async linkIdentityOAuth(t){var n;try{const{data:r,error:s}=await this._useSession(async i=>{var o,l,c,u,d;const{data:h,error:m}=i;if(m)throw m;const f=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,t.provider,{redirectTo:(o=t.options)===null||o===void 0?void 0:o.redirectTo,scopes:(l=t.options)===null||l===void 0?void 0:l.scopes,queryParams:(c=t.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await wt(this.fetch,"GET",f,{headers:this.headers,jwt:(d=(u=h.session)===null||u===void 0?void 0:u.access_token)!==null&&d!==void 0?d:void 0})});if(s)throw s;return Er()&&!(!((n=t.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),this._returnResult({data:{provider:t.provider,url:r==null?void 0:r.url},error:null})}catch(r){if(ft(r))return this._returnResult({data:{provider:t.provider,url:null},error:r});throw r}}async linkIdentityIdToken(t){return await this._useSession(async n=>{var r;try{const{error:s,data:{session:i}}=n;
655if(s)throw s;const{options:o,provider:l,token:c,access_token:u,nonce:d}=t,h=await wt(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(r=i==null?void 0:i.access_token)!==null&&r!==void 0?r:void 0,body:{provider:l,id_token:c,access_token:u,nonce:d,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:Ss}),{data:m,error:f}=h;return f?this._returnResult({data:{user:null,session:null},error:f}):!m||!m.session||!m.user?this._returnResult({data:{user:null,session:null},error:new au}):(m.session&&(await this._saveSession(m.session),await this._notifyAllSubscribers("USER_UPDATED",m.session)),this._returnResult({data:m,error:f}))}catch(s){if(await Cr(this.storage,`${this.storageKey}-code-verifier`),ft(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}})}async unlinkIdentity(t){try{return await this._useSession(async n=>{var r,s;const{data:i,error:o}=n;if(o)throw o;return await wt(this.fetch,"DELETE",`${this.url}/user/identities/${t.identity_id}`,{headers:this.headers,jwt:(s=(r=i.session)===null||r===void 0?void 0:r.access_token)!==null&&s!==void 0?s:void 0})})}catch(n){if(ft(n))return this._returnResult({data:null,error:n});throw n}}async _refreshAccessToken(t){const n=`#_refreshAccessToken(${t.substring(0,5)}...)`;this._debug(n,"begin");try{const r=Date.now();return await OJ(async s=>(s>0&&await PJ(200*Math.pow(2,s-1)),this._debug(n,"refreshing attempt",s),await wt(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:t},headers:this.headers,xform:Ss})),(s,i)=>{const o=200*Math.pow(2,s);return i&&mw(i)&&Date.now()+o-r<Su})}catch(r){if(this._debug(n,"error",r),ft(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}finally{this._debug(n,"end")}}_isValidSession(t){return typeof t=="object"&&t!==null&&"access_token"in t&&"refresh_token"in t&&"expires_at"in t}async _handleProviderSignIn(t,n){const r=await this._getUrlForProvider(`${this.url}/authorize`,t,{redirectTo:n.redirectTo,scopes:n.scopes,queryParams:n.queryParams});return this._debug("#_handleProviderSignIn()","provider",t,"options",n,"url",r),Er()&&!n.skipBrowserRedirect&&window.location.assign(r),{data:{provider:t,url:r},error:null}}async _recoverAndRefresh(){var t,n;const r="#_recoverAndRefresh()";this._debug(r,"begin");try{const s=await Bl(this.storage,this.storageKey);if(s&&this.userStorage){let o=await Bl(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:s.user},await Cu(this.userStorage,this.storageKey+"-user",o)),s.user=(t=o==null?void 0:o.user)!==null&&t!==void 0?t:pw()}else if(s&&!s.user&&!s.user){const o=await Bl(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(s.user=o.user,await Cr(this.storage,this.storageKey+"-user"),await Cu(this.storage,this.storageKey,s)):s.user=pw()}if(this._debug(r,"session from storage",s),!this._isValidSession(s)){this._debug(r,"session is not valid"),s!==null&&await this._removeSession();return}const i=((n=s.expires_at)!==null&&n!==void 0?n:1/0)*1e3-Date.now()<hw;if(this._debug(r,`session has${i?"":" not"} expired with margin of ${hw}
655s`),i){if(this.autoRefreshToken&&s.refresh_token){const{error:o}=await this._callRefreshToken(s.refresh_token);o&&(console.error(o),mw(o)||(this._debug(r,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else if(s.user&&s.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:l}=await this._getUser(s.access_token);!l&&(o!=null&&o.user)?(s.user=o.user,await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)):this._debug(r,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(r,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",s)}catch(s){this._debug(r,"error",s),console.error(s);return}finally{this._debug(r,"end")}}async _callRefreshToken(t){var n,r;if(!t)throw new Pa;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const s=`#_callRefreshToken(${t.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new nb;const{data:i,error:o}=await this._refreshAccessToken(t);if(o)throw o;if(!i.session)throw new Pa;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const l={data:i.session,error:null};return this.refreshingDeferred.resolve(l),l}catch(i){if(this._debug(s,"error",i),ft(i)){const o={data:null,error:i};return mw(i)||await this._removeSession(),(n=this.refreshingDeferred)===null||n===void 0||n.resolve(o),o}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(i),i}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(t,n,r=!0){const s=`#_notifyAllSubscribers(${t})`;this._debug(s,"begin",n,`broadcast = ${r}`);try{this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:t,session:n});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async l=>{try{await l.callback(t,n)}catch(c){i.push(c)}});if(await Promise.all(o),i.length>0){for(let l=0;l<i.length;l+=1)console.error(i[l]);throw i[0]}}finally{this._debug(s,"end")}}async _saveSession(t){this._debug("#_saveSession()",t),this.suppressGetSessionWarning=!0,await Cr(this.storage,`${this.storageKey}-code-verifier`);const n=Object.assign({},t),r=n.user&&n.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!r&&n.user&&await Cu(this.userStorage,this.storageKey+"-user",{user:n.user});const s=Object.assign({},n);delete s.user;const i=pO(s);await Cu(this.storage,this.storageKey,i)}else{const s=pO(n);await Cu(this.storage,this.storageKey,s)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await Cr(this.storage,this.storageKey),await Cr(this.storage,this.storageKey+"-code-verifier"),await Cr(this.storage,this.storageKey+"-user"),this.userStorage&&await Cr(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const t=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{t&&Er()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",t)}catch(n){console.error("removing visibilitychange callback failed",n)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const t=setInterval(()=>this._autoRefreshTokenTick(),Su);this.autoRefreshTicker=t,t&&typeof t=="object"&&typeof t.unref=="function"?t.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(t);const n=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=n,n&&typeof n=="object"&&typeof n.unref=="function"?n.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(n)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const t=this.autoRefreshTicker;this.autoRefreshTicker=null,t&&clearInterval(t);const n=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,n&&clearTimeout(n)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const t=Date.now();try{return await this._useSession(async n=>{const{data:{session:r}}=n;if(!r||!r.refresh_token||!r.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((r.expires_at*1e3-t)/Su);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${Su}ms, refresh threshold is ${t1} ticks`),s<=t1&&await this._callRefreshToken(r.refresh_token)})}catch(n){console.error("Auto refresh tick failed with error. This is likely a transient error.",n)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(t){if(t.isAcquireTimeout||t instanceof g4)this._debug("auto refresh token tick lock not available");else throw t}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Er()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(t){this._debug("#visibilityChangedCallback","error",t)}},window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(t){console.error("_handleVisibilityChange",t)}}async _onVisibilityChanged(t){const n=`#_onVisibilityChanged(${t})`;this._debug(n,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),t||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>
655{if(document.visibilityState!=="visible"){this._debug(n,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(t,n,r){const s=[`provider=${encodeURIComponent(n)}`];if(r!=null&&r.redirectTo&&s.push(`redirect_to=${encodeURIComponent(r.redirectTo)}`),r!=null&&r.scopes&&s.push(`scopes=${encodeURIComponent(r.scopes)}`),this.flowType==="pkce"){const[i,o]=await su(this.storage,this.storageKey),l=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});s.push(l.toString())}if(r!=null&&r.queryParams){const i=new URLSearchParams(r.queryParams);s.push(i.toString())}return r!=null&&r.skipBrowserRedirect&&s.push(`skip_http_redirect=${r.skipBrowserRedirect}`),`${t}?${s.join("&")}`}async _unenroll(t){try{return await this._useSession(async n=>{var r;const{data:s,error:i}=n;return i?this._returnResult({data:null,error:i}):await wt(this.fetch,"DELETE",`${this.url}/factors/${t.factorId}`,{headers:this.headers,jwt:(r=s==null?void 0:s.session)===null||r===void 0?void 0:r.access_token})})}catch(n){if(ft(n))return this._returnResult({data:null,error:n});throw n}}async _enroll(t){try{return await this._useSession(async n=>{var r,s;const{data:i,error:o}=n;if(o)return this._returnResult({data:null,error:o});const l=Object.assign({friendly_name:t.friendlyName,factor_type:t.factorType},t.factorType==="phone"?{phone:t.phone}:t.factorType==="totp"?{issuer:t.issuer}:{}),{data:c,error:u}=await wt(this.fetch,"POST",`${this.url}/factors`,{body:l,headers:this.headers,jwt:(r=i==null?void 0:i.session)===null||r===void 0?void 0:r.access_token});return u?this._returnResult({data:null,error:u}):(t.factorType==="totp"&&c.type==="totp"&&(!((s=c==null?void 0:c.totp)===null||s===void 0)&&s.qr_code)&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),this._returnResult({data:c,error:null}))})}catch(n){if(ft(n))return this._returnResult({data:null,error:n});throw n}}async _verify(t){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async n=>{var r;const{data:s,error:i}=n;if(i)return this._returnResult({data:null,error:i});const o=Object.assign({challenge_id:t.challengeId},"webauthn"in t?{webauthn:Object.assign(Object.assign({},t.webauthn),{credential_response:t.webauthn.type==="create"?iZ(t.webauthn.credential_response):oZ(t.webauthn.credential_response)})}:{code:t.code}),{data:l,error:c}=await wt(this.fetch,"POST",`${this.url}/factors/${t.factorId}/verify`,{body:o,headers:this.headers,jwt:(r=s==null?void 0:s.session)===null||r===void 0?void 0:r.access_token});return c?this._returnResult({data:null,error:c}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+l.expires_in},l)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",l),this._returnResult({data:l,error:c}))})}catch(n){if(ft(n))return this._returnResult({data:null,error:n});throw n}})}async _challenge(t){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async n=>{var r;const{data:s,error:i}=n;if(i)return this._returnResult({data:null,error:i});const o=await wt(this.fetch,"POST",`${this.url}/factors/${t.factorId}/challenge`,{body:t,headers:this.headers,jwt:(r=s==null?void 0:s.session)===null||r===void 0?void 0:r.access_token});if(o.error)return o;const{data:l}=o;if(l.type!=="webauthn")return{data:l,error:null};switch(l.webauthn.type){case"create":return{data:Object.assign(Object.assign({},l),{webauthn:Object.assign(Object.assign({},l.webauthn),{credential_options:Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:aZ(l.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},l),{webauthn:Object.assign(Object.assign({},l.webauthn),{credential_options:Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:sZ(l.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(n){if(ft(n))return this._returnResult({data:null,error:n});throw n}})}async _challengeAndVerify(t){const{data:n,error:r}=await this._challenge({factorId:t.factorId});return r?this._returnResult({data:null,error:r}):await this._verify({factorId:t.factorId,challengeId:n.id,code:t.code})}async _listFactors(){var t;const{data:{user:n},error:r}=await this.getUser();if(r)return{data:null,error:r};const s={all:[],phone:[],totp:[],webauthn:[]};for(const i of(t=n==null?void 0:n.factors)!==null&&t!==void 0?t:[])s.all.push(i),i.status==="verified"&&s[i.factor_type].push(i);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(t){var n,r,s,i;if(t)try{const{payload:f}=_g(t);let x=null;f.aal&&(x=f.aal);let g=x;const{data:{user:p},error:v}=await this.getUser(t);if(v)return this._returnResult({data:null,error:v});((r=(n=p==null?void 0:p.factors)===null||n===void 0?void 0:n.filter(N=>N.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(g="aal2");const w=f.amr||[];return{data:{currentLevel:x,nextLevel:g,currentAuthenticationMethods:w},error:null}}catch(f){if(ft(f))return this._returnResult({data:null,error:f});throw f}const{data:{session:o},error:l}
655=await this.getSession();if(l)return this._returnResult({data:null,error:l});if(!o)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:c}=_g(o.access_token);let u=null;c.aal&&(u=c.aal);let d=u;((i=(s=o.user.factors)===null||s===void 0?void 0:s.filter(f=>f.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(d="aal2");const m=c.amr||[];return{data:{currentLevel:u,nextLevel:d,currentAuthenticationMethods:m},error:null}}async _getAuthorizationDetails(t){try{return await this._useSession(async n=>{const{data:{session:r},error:s}=n;return s?this._returnResult({data:null,error:s}):r?await wt(this.fetch,"GET",`${this.url}/oauth/authorizations/${t}`,{headers:this.headers,jwt:r.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new Pa})})}catch(n){if(ft(n))return this._returnResult({data:null,error:n});throw n}}async _approveAuthorization(t,n){try{return await this._useSession(async r=>{const{data:{session:s},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new Pa});const o=await wt(this.fetch,"POST",`${this.url}/oauth/authorizations/${t}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"approve"},xform:l=>({data:l,error:null})});return o.data&&o.data.redirect_url&&Er()&&!(n!=null&&n.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(ft(r))return this._returnResult({data:null,error:r});throw r}}async _denyAuthorization(t,n){try{return await this._useSession(async r=>{const{data:{session:s},error:i}=r;if(i)return this._returnResult({data:null,error:i});if(!s)return this._returnResult({data:null,error:new Pa});const o=await wt(this.fetch,"POST",`${this.url}/oauth/authorizations/${t}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"deny"},xform:l=>({data:l,error:null})});return o.data&&o.data.redirect_url&&Er()&&!(n!=null&&n.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(r){if(ft(r))return this._returnResult({data:null,error:r});throw r}}async _listOAuthGrants(){try{return await this._useSession(async t=>{const{data:{session:n},error:r}=t;return r?this._returnResult({data:null,error:r}):n?await wt(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,xform:s=>({data:s,error:null})}):this._returnResult({data:null,error:new Pa})})}catch(t){if(ft(t))return this._returnResult({data:null,error:t});throw t}}async _revokeOAuthGrant(t){try{return await this._useSession(async n=>{const{data:{session:r},error:s}=n;return s?this._returnResult({data:null,error:s}):r?(await wt(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,query:{client_id:t.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new Pa})})}catch(n){if(ft(n))return this._returnResult({data:null,error:n});throw n}}async fetchJwk(t,n={keys:[]}){let r=n.keys.find(l=>l.kid===t);if(r)return r;const s=Date.now();if(r=this.jwks.keys.find(l=>l.kid===t),r&&this.jwks_cached_at+pJ>s)return r;const{data:i,error:o}=await wt(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=s,r=i.keys.find(l=>l.kid===t),!r)?null:r}async getClaims(t,n={}){try{let r=t;if(!r){const{data:f,error:x}
655=await this.getSession();if(x||!f.session)return this._returnResult({data:null,error:x});r=f.session.access_token}const{header:s,payload:i,signature:o,raw:{header:l,payload:c}}=_g(r);n!=null&&n.allowExpired||IJ(i.exp);const u=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,n!=null&&n.keys?{keys:n.keys}:n==null?void 0:n.jwks);if(!u){const{error:f}=await this.getUser(r);if(f)throw f;return{data:{claims:i,header:s,signature:o},error:null}}const d=LJ(s.alg),h=await crypto.subtle.importKey("jwk",u,d,!0,["verify"]);if(!await crypto.subtle.verify(d,h,o,NJ(`${l}.${c}`)))throw new a1("Invalid JWT signature");return{data:{claims:i,header:s,signature:o},error:null}}catch(r){if(ft(r))return this._returnResult({data:null,error:r});throw r}}}mm.nextInstanceID={};const gZ=mm,xZ="2.95.3";let hf="";typeof Deno<"u"?hf="deno":typeof document<"u"?hf="web":typeof navigator<"u"&&navigator.product==="ReactNative"?hf="react-native":hf="node";const yZ={"X-Client-Info":`supabase-js-${hf}/${xZ}`},vZ={headers:yZ},bZ={schema:"public"},wZ={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},_Z={};function pm(e){"@babel/helpers - typeof";return pm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pm(e)}function jZ(e,t){if(pm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(pm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function NZ(e){var t=jZ(e,"string");return pm(t)=="symbol"?t:t+""}function SZ(e,t,n){return(t=NZ(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Ln(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?_O(Object(n),!0).forEach(function(r){SZ(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_O(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const CZ=e=>e?(...t)=>e(...t):(...t)=>fetch(...t),kZ=()=>Headers,EZ=(e,t,n)=>{const r=CZ(n),s=kZ();return async(i,o)=>{var l;const c=(l=await t())!==null&&l!==void 0?l:e;let u=new s(o==null?void 0:o.headers);return u.has("apikey")||u.set("apikey",e),u.has("Authorization")||u.set("Authorization",`Bearer ${c}`),r(i,Ln(Ln({},o),{},{headers:u}))}};function PZ(e){return e.endsWith("/")?e:e+"/"}function OZ(e,t){var n,r;const{db:s,auth:i,realtime:o,global:l}=e,{db:c,auth:u,realtime:d,global:h}=t,m={db:Ln(Ln({},c),s),auth:Ln(Ln({},u),i),realtime:Ln(Ln({},d),o),storage:{},global:Ln(Ln(Ln({},h),l),{},{headers:Ln(Ln({},(n=h==null?void 0:h.headers)!==null&&n!==void 0?n:{}),(r=l==null?void 0:l.headers)!==null&&r!==void 0?r:{})}),accessToken:async()=>""};return e.accessToken?m.accessToken=e.accessToken:delete m.accessToken,m}function AZ(e){const t=e==null?void 0:e.trim();if(!t)throw new Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(PZ(t))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var TZ=class extends gZ{constructor(e){super(e)}},MZ=class{constructor(e,t,n){var r,s;this.supabaseUrl=e,this.supabaseKey=t;const i=AZ(e);if(!t)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const o=`sb-${i.hostname.split(".")[0]}-auth-token`,l={db:bZ,realtime:_Z,auth:Ln(Ln({},wZ),{},{storageKey:o}),global:vZ},c=OZ(n??{},l);if(this.storageKey=(r=c.auth.storageKey)!==null&&r!==void 0?r:"",this.headers=(s=c.global.headers)!==null&&s!==void 0?s:{},c.accessToken)this.accessToken=c.accessToken,this.auth=new Proxy({},{get:(d,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}});else{var u;this.auth=this._initSupabaseAuthClient((u=c.auth)!==null&&u!==void 0?u:{},this.headers,c.global.fetch)}this.fetch=EZ(t,this._getAccessToken.bind(this),c.global.fetch),this.realtime=this._initRealtimeClient(Ln({headers:this.headers,accessToken:this._getAccessToken.bind(this)},c.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(d=>this.realtime.setAuth(d)).catch(d=>console.warn("Failed to set initial Realtime auth token:",d)),this.rest=new xX(new URL("rest/v1",i).href,{headers:this.headers,schema:c.db.schema,fetch:this.fetch,timeout:c.db.timeout,urlLengthLimit:c.db.urlLengthLimit}),this.storage=new uJ(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),c.accessToken||this._listenForAuthEvents()}get functions(){return new cX(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(e,t,n)}
655channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var e=this,t,n;if(e.accessToken)return await e.accessToken();const{data:r}=await e.auth.getSession();return(t=(n=r.session)===null||n===void 0?void 0:n.access_token)!==null&&t!==void 0?t:e.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:r,userStorage:s,storageKey:i,flowType:o,lock:l,debug:c,throwOnError:u},d,h){const m={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new TZ({url:this.authUrl.href,headers:Ln(Ln({},m),d),storageKey:i,autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:r,userStorage:s,flowType:o,lock:l,debug:c,throwOnError:u,fetch:h,hasCustomAuthorizationHeader:Object.keys(this.headers).some(f=>f.toLowerCase()==="authorization")})}_initRealtimeClient(e){return new DX(this.realtimeUrl.href,Ln(Ln({},e),{},{params:Ln(Ln({},{apikey:this.supabaseKey}),e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",t==null?void 0:t.access_token)})}_handleTokenChanged(e,t,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):e==="SIGNED_OUT"&&(this.realtime.setAuth(),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const DZ=(e,t,n)=>new MZ(e,t,n);function $Z(){if(typeof window<"u")return!1;const e=globalThis.process;if(!e)return!1;const t=e.version;if(t==null)return!1;const n=t.match(/^v(\d+)\./);return n?parseInt(n[1],10)<=18:!1}$Z()&&console.warn("â ï¸ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");function RZ(){var p,v;if(typeof window>"u")return;const e=location.hostname,n=["lovableproject.com","lovableproject-dev.com","lovable.app","gpt-eng.com","gptengineer.run"].some(b=>e===b||e.endsWith("."+b)),r="[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}",s=n?((p=e.match(new RegExp("^(?:id-preview(?:-[a-z0-9]+)?|project)--("+r+")(?:-dev)?(?=\\.|$)","i")))==null?void 0:p[1])??((v=e.match(new RegExp("^("+r+")(?=[.-])","i")))==null?void 0:v[1]):void 0,i=window.parent&&window.parent!==window;if(!s||!i)return localStorage;const o=e.endsWith(".lovableproject-dev.com")||e.endsWith(".gpt-eng.com"),l=o?/^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$|^http:\/\/localhost:3000$/:/^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$/,c=location.ancestorOrigins&&location.ancestorOrigins[0]||(document.referrer?new URL(document.referrer).origin:""),u=c&&l.test(c)?[c]:o?["https://lovable.dev","http://localhost:3000"]:["https://lovable.dev"],d="lovable-preview-auth:result",h=2e3,m=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),f=(b,w,N)=>new Promise(j=>{const _=m();let S=!1,P;const k=O=>{S||(S=!0,clearTimeout(P),window.removeEventListener("message",C),j(O))},C=O=>{if(u.indexOf(O.origin)<0)return;const L=O.data;L&&L.type===d&&L.requestId===_&&k(L)};window.addEventListener("message",C);const T={type:b,requestId:_,projectId:s,key:w};N!==void 0&&(T.value=N);for(const O of u)window.parent.postMessage(T,O);P=setTimeout(()=>k(null),h)});let x=!0;const g=250;return{getItem:async b=>{let w=await f("lovable-preview-auth:get",b);return!w&&x&&(await new Promise(N=>setTimeout(N,g)),w=await f("lovable-preview-auth:get",b)),x=!1,w&&w.ok&&typeof w.value=="string"?w.value===""?(localStorage.removeItem(b),null):w.value:localStorage.getItem(b)},setItem:(b,w)=>(localStorage.setItem(b,w),f("lovable-preview-auth:set",b,w).then(N=>{N&&N.ok&&typeof N.value=="string"&&localStorage.getItem(b)===w&&(N.value===""?localStorage.removeItem(b):localStorage.setItem(b,N.value))})),removeItem:b=>(localStorage.removeItem(b),f("lovable-preview-auth:remove",b).then(()=>{}))}}const IZ="https://wjxhtbmgykpxnrfoxcqz.supabase.co",LZ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM",F=DZ(IZ,LZ,{auth:{storage:RZ(),persistSession:!0,autoRefreshToken:!0}}),FZ=Object.freeze(Object.defineProperty({__proto__:null,supabase:F},Symbol.toStringTag,{value:"Module"})),v4=y.createContext({session:null,user:null,loading:!0,signOut:async()=>{}}),MC=()=>y.useContext(v4);function qZ({children:e}){const[t,n]=y.useState(null),[r,s]=y.useState(!0);y.useEffect(()=>{F.auth.getSession().then(({data:{session:l}})=>{n(l),s(!1)});const{data:{subscription:o}}=F.auth.onAuthStateChange((l,c)=>{n(c),s(!1)});return()=>o.unsubscribe()},[]);const i=async()=>{await F.auth.signOut()};return a.jsx(v4.Provider,{value:{session:t,user:(t==null?void 0:t.user)??null,loading:r,signOut:i},children:e})}const gm=nh("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Y=y.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...s},i)=>{const o=r?tK:"button";return a.jsx(o,{className:Se(gm({variant:t,size:n,className:e})),ref:i,...s})});Y.displayName="Button";function Qs(){return Ee({queryKey:["current-user-is-admin"],queryFn:async()=>{const{data:e}=await F.rpc("is_admin");return e===!0}})}function vp(){return Ee({queryKey:["financial-access"],queryFn:async()=>{const[e,t]=await Promise.all([F.rpc("is_admin"),F.rpc("is_employee_generator")]);return e.data===!0||t.data===!0}})}function cu({to:e,children:t,icon:n}){const s=kl().pathname===e;return a.jsxs(Na,{to:e,className:Se("flex items-center gap-1 sm:gap-1.5 rounded-md px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium transition-colors whitespace-nowrap",s?"bg-secondary text-foreground":"text-muted-foreground hover:text-foreground hover:bg-secondary/50"),children:[n,t]})}const zZ=1,BZ="a56b3e66-eb7c-4583-b8c0-c3efeab20635",UZ="d4a00433-86df-49a5-a2fb-fb92bc1c1656",WZ="/__l5e/assets-v1/a56b3e66-eb7c-4583-b8c0-c3efeab20635/FourCorners-Primary-Midnight.png",KZ="a/v1/d4a00433-86df-49a5-a2fb-fb92bc1c1656/a56b3e66-eb7c-4583-b8c0-c3efeab20635/FourCorners-Primary-Midnight.png",HZ="FourCorners-Primary-Midnight.png",GZ=22841,VZ="image/png",YZ="2026-07-03T17:09:20Z",rb={version:zZ,asset_id:BZ,project_id:UZ,url:WZ,r2_key:KZ,original_filename:HZ,size:GZ,content_type:VZ,created_at:YZ},jO=y.createContext(!1),QZ=rb.url;function Rr({children:e}){const{signOut:t,user:n}=MC();Qs();const{data:r}=vp();return y.useContext(jO)?a.jsx(a.Fragment,{children:e}):a.jsxs("div",{className:"flex min-h-screen flex-col bg-background",children:[a.jsx("header",{className:"border-b border-border bg-popover",children:a.jsxs("div",{className:"mx-auto flex min-h-14 max-w-6xl items-center justify-between gap-3 px-4 py-2",children:[a.jsxs("div",{className:"flex items-center gap-4 sm:gap-6 min-w-0 flex-1",children:[a.jsx("img",{src:QZ,alt:"Four Corners Exploration",className:"h-8 flex-shrink-0"}),a.jsxs("nav",{className:"flex flex-wrap items-center gap-0.5 sm:gap-1 min-w-0",children:[a.jsx(cu,{to:"/",icon:a.jsx(bH,{className:"h-4 w-4"}),children:"Tasks"}),a.jsx(cu,{to:"/contacts",icon:a.jsx(Hc,{className:"h-4 w-4"}),children:"Contacts"}),a.jsx(cu,{to:"/generators",icon:a.jsx(kH,{className:"h-4 w-4"}),children:"Team"}),a.jsx(cu,{to:"/experiences",icon:a.jsx(aC,{className:"h-4 w-4"}),children:"Experiences"}),a.jsx(cu,{to:"/coaching",icon:a.jsx(aH,{className:"h-4 w-4"}),children:"Coaching"}),r&&a.jsx(cu,{to:"/forecast",icon:a.jsx(K3,{className:"h-4 w-4"}),children:"Reports"})]})]}),a.jsxs("div",{className:"flex flex-shrink-0 items-center gap-3",children:[a.jsx("span",{className:"text-xs text-muted-foreground hidden xl:inline",children:n==null?void 0:n.email}),a.jsx(Y,{variant:"ghost",size:"sm",onClick:t,children:a.jsx(cH,{className:"h-4 w-4"})})]})]})}),a.jsx("main",{className:"mx-auto w-full max-w-6xl flex-1 px-4 py-6",children:a.jsx(jO.Provider,{value:!0,children:e})})]})}const XZ=nh("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ge({className:e,variant:t,...n}){return a.jsx("div",{className:Se(XZ({variant:t}),e),...n})}function DC(e){const t=y.useRef({value:e,previous:e});return y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var ab="Checkbox",[JZ,m3e]=jr(ab),[ZZ,$C]=JZ(ab);function eee(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:s,disabled:i,form:o,name:l,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:h}=e,[m,f]=oa({prop:n,defaultProp:s??!1,onChange:c,caller:ab}),[x,g]=y.useState(null),[p,v]=y.useState(null),b=y.useRef(!1),w=x?!!o||!!x.closest("form"):!0,N={checked:m,disabled:i,setChecked:f,control:x,setControl:g,name:l,form:o,value:d,hasConsumerStoppedPropagationRef:b,required:u,defaultChecked:cl(s)?!1:s,isFormControl:w,bubbleInput:p,setBubbleInput:v};return a.jsx(ZZ,{scope:t,...N,children:tee(h)?h(N):r})}var b4="CheckboxTrigger",w4=y.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},s)=>{const{control:i,value:o,disabled:l,checked:c,required:u,setControl:d,setChecked:h,hasConsumerStoppedPropagationRef:m,isFormControl:f,bubbleInput:x}=$C(b4,e),g=Ct(s,d),p=y.useRef(c);return y.useEffect(()=>{const v=i==null?void 0:i.form;if(v){const b=()=>h(p.current);return v.addEventListener("reset",b),()=>v.removeEventListener("reset",b)}},[i,h]),a.jsx(tt.button,{type:"button",role:"checkbox","aria-checked":cl(c)?"mixed":c,"aria-required":u,"data-state":C4(c),"data-disabled":l?"":void 0,disabled:l,value:o,...r,ref:g,onKeyDown:Fe(t,v=>{v.key==="Enter"&&v.preventDefault()}),onClick:Fe(n,v=>{h(b=>cl(b)?!0:!b),x&&f&&(m.current=v.isPropagationStopped(),m.current||v.stopPropagation())})})});w4.displayName=b4;var RC=y.forwardRef((e,t)=>
655{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:i,required:o,disabled:l,value:c,onCheckedChange:u,form:d,...h}=e;return a.jsx(eee,{__scopeCheckbox:n,checked:s,defaultChecked:i,disabled:l,required:o,onCheckedChange:u,name:r,form:d,value:c,internal_do_not_use_render:({isFormControl:m})=>a.jsxs(a.Fragment,{children:[a.jsx(w4,{...h,ref:t,__scopeCheckbox:n}),m&&a.jsx(S4,{__scopeCheckbox:n})]})})});RC.displayName=ab;var _4="CheckboxIndicator",j4=y.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...s}=e,i=$C(_4,n);return a.jsx(tr,{present:r||cl(i.checked)||i.checked===!0,children:a.jsx(tt.span,{"data-state":C4(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});j4.displayName=_4;var N4="CheckboxBubbleInput",S4=y.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:i,defaultChecked:o,required:l,disabled:c,name:u,value:d,form:h,bubbleInput:m,setBubbleInput:f}=$C(N4,e),x=Ct(n,f),g=DC(i),p=yC(r);y.useEffect(()=>{const b=m;if(!b)return;const w=window.HTMLInputElement.prototype,j=Object.getOwnPropertyDescriptor(w,"checked").set,_=!s.current;if(g!==i&&j){const S=new Event("click",{bubbles:_});b.indeterminate=cl(i),j.call(b,cl(i)?!1:i),b.dispatchEvent(S)}},[m,g,i,s]);const v=y.useRef(cl(i)?!1:i);return a.jsx(tt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??v.current,required:l,disabled:c,name:u,value:d,form:h,...t,tabIndex:-1,ref:x,style:{...t.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});S4.displayName=N4;function tee(e){return typeof e=="function"}function cl(e){return e==="indeterminate"}function C4(e){return cl(e)?"indeterminate":e?"checked":"unchecked"}const gt=y.forwardRef(({className:e,...t},n)=>a.jsx(RC,{ref:n,className:Se("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:a.jsx(j4,{className:Se("flex items-center justify-center text-current"),children:a.jsx(On,{className:"h-4 w-4"})})}));gt.displayName=RC.displayName;function nee({className:e,...t}){return a.jsx("div",{className:Se("animate-pulse rounded-md bg-muted",e),...t})}const ree={prospect:"Prospect",contacted:"Contacted",engaged:"Engaged",active:"Active",alumni:"Alumni"};function aee({contacts:e,loading:t,onSelect:n,selectedId:r,generators:s=[],bulkMode:i=!1,selectedIds:o=new Set,onToggleSelect:l,contactExperiences:c={}}){if(t)return a.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((d,h)=>a.jsx(nee,{className:"h-16 w-full rounded-md"},h))});if(e.length===0)return a.jsx("div",{className:"flex h-48 items-center justify-center rounded-md border border-dashed border-border",children:a.jsx("p",{className:"text-sm text-muted-foreground",children:"No contacts yet. Add your first one."})});const u=e.length>0&&e.every(d=>o.has(d.id));return a.jsxs("div",{className:"space-y-1",children:[i&&e.length>0&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-1",children:[a.jsx("button",{type:"button",onClick:()=>{u?e.forEach(d=>l==null?void 0:l(d.id)):e.forEach(d=>{o.has(d.id)||l==null||l(d.id)})},className:"text-xs text-primary hover:underline",children:u?"Deselect all":"Select all"}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.length," contacts"]})]}),e.map(d=>{const h=s.find(f=>f.id===d.generator_id),m=c[d.id]||[];return a.jsxs("div",{className:Se("flex w-full items-center gap-2 rounded-md px-4 py-3 text-left transition-colors",r===d.id?"bg-secondary border border-border":"hover:bg-secondary/50"),children:[i&&a.jsx(gt,{checked:o.has(d.id),onCheckedChange:()=>l==null?void 0:l(d.id),className:"flex-shrink-0",onClick:f=>f.stopPropagation()}),a.jsx("button",{onClick:()=>n(d),className:"flex w-full items-center justify-between text-left min-w-0",children:a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium text-sm text-foreground truncate",children:d.name}),a.jsx("span",{className:"text-xs text-muted-foreground",children:ree[d.status]||d.status})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[d.email&&a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:d.email}),d.company&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",d.company]}),h&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",h.name]})]}),m.length>0&&a.jsxs("div",{className:"flex items-center gap-1 mt-1 flex-wrap",children:[a.jsx(vc,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),m.map((f,x)=>a.jsx(Ge,{variant:"outline",className:Se("text-[10px] px-1.5 py-0",f.status==="accepted"?"bg-success/15 text-success border-success/30":f.status==="gen_guide"?"bg-violet-100 text-violet-800 dark:bg-violet-900 dark:text-violet-200 border-violet-300 dark:border-violet-700":f.status==="considering"?"bg-warning/15 text-warning border-warning/30":f.status==="declined"?"bg-destructive/15 text-destructive border-destructive/30":f.status==="waitlist"?"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200 border-orange-300 dark:border-orange-700":f.status==="future"?"bg-primary/10 text-primary border-primary/20":"bg-muted text-muted-foreground border-border"),children:f.name},x))]})]})})]},d.id)})]})}var xw="focusScope.autoFocusOnMount",yw="focusScope.autoFocusOnUnmount",NO={bubbles:!1,cancelable:!0},see="FocusScope",bp=y.forwardRef((e,t)=>
vendor: 4,277 bytes, line 655
655{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:i,...o}=e,[l,c]=y.useState(null),u=Kn(s),d=Kn(i),h=y.useRef(null),m=Ct(t,g=>c(g)),f=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let g=function(w){if(f.paused||!l)return;const N=w.target;l.contains(N)?h.current=N:Po(h.current,{select:!0})},p=function(w){if(f.paused||!l)return;const N=w.relatedTarget;N!==null&&(l.contains(N)||Po(h.current,{select:!0}))},v=function(w){if(document.activeElement===document.body)for(const j of w)j.removedNodes.length>0&&Po(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",p);const b=new MutationObserver(v);return l&&b.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",p),b.disconnect()}}},[r,l,f.paused]),y.useEffect(()=>{if(l){CO.add(f);const g=document.activeElement;if(!l.contains(g)){const v=new CustomEvent(xw,NO);l.addEventListener(xw,u),l.dispatchEvent(v),v.defaultPrevented||(iee(dee(k4(l)),{select:!0}),document.activeElement===g&&Po(l))}return()=>{l.removeEventListener(xw,u),setTimeout(()=>{const v=new CustomEvent(yw,NO);l.addEventListener(yw,d),l.dispatchEvent(v),v.defaultPrevented||Po(g??document.body,{select:!0}),l.removeEventListener(yw,d),CO.remove(f)},0)}}},[l,u,d,f]);const x=y.useCallback(g=>{if(!n&&!r||f.paused)return;const p=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,v=document.activeElement;if(p&&v){const b=g.currentTarget,[w,N]=oee(b);w&&N?!g.shiftKey&&v===N?(g.preventDefault(),n&&Po(w,{select:!0})):g.shiftKey&&v===w&&(g.preventDefault(),n&&Po(N,{select:!0})):v===b&&g.preventDefault()}},[n,r,f.paused]);return a.jsx(tt.div,{tabIndex:-1,...o,ref:m,onKeyDown:x})});bp.displayName=see;function iee(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Po(r,{select:t}),document.activeElement!==n)return}function oee(e){const t=k4(e),n=SO(t,e),r=SO(t.reverse(),e);return[n,r]}function k4(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function SO(e,t){for(const n of e)if(!lee(n,{upTo:t}))return n}function lee(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function cee(e){return e instanceof HTMLInputElement&&"select"in e}function Po(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&cee(e)&&t&&e.select()}}var CO=uee();function uee(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=kO(e,t),e.unshift(t)},remove(t){var n;e=kO(e,t),(n=e[0])==null||n.resume()}}}function kO(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function dee(e){return e.filter(t=>t.tagName!=="A")}var vw=0;function sb(){y.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??EO()),document.body.insertAdjacentElement("beforeend",e[1]??EO()),vw++,()=>{vw===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),vw--}},[])}function EO(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var mx="right-scroll-bar-position",px="width-before-scroll-bar",hee="with-scroll-bars-hidden",fee="--removed-body-scroll-bar-size";function bw(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function mee(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=t,n.facade}var pee=typeof window<"u"?y.useLayoutEffect:y.useEffect,PO=new WeakMap;function gee(e,t){var n=mee(null,function(r){return e.forEach(function(s){return bw(s,r)})});return pee(function(){var r=PO.get(n);if(r){var s=new Set(r),i=new Set(e),o=n.current;
vendor: 4,224 bytes, lines 655-670
655s.forEach(function(l){i.has(l)||bw(l,null)}),i.forEach(function(l){s.has(l)||bw(l,o)})}PO.set(n,e)},[e]),n}function xee(e){return e}function yee(e,t){t===void 0&&(t=xee);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var o=t(i,r);return n.push(o),function(){n=n.filter(function(l){return l!==o})}},assignSyncMedium:function(i){for(r=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var o=[];if(n.length){var l=n;n=[],l.forEach(i),o=n}var c=function(){var d=o;o=[],d.forEach(i)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){o.push(d),u()},filter:function(d){return o=o.filter(d),n}}}};return s}function vee(e){e===void 0&&(e={});var t=yee(null);return t.options=di({async:!0,ssr:!1},e),t}var E4=function(e){var t=e.sideCar,n=uh(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return y.createElement(r,di({},n))};E4.isSideCarExport=!0;function bee(e,t){return e.useMedium(t),E4}var P4=vee(),ww=function(){},ib=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:ww,onWheelCapture:ww,onTouchMoveCapture:ww}),s=r[0],i=r[1],o=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,h=e.shards,m=e.sideCar,f=e.noRelative,x=e.noIsolation,g=e.inert,p=e.allowPinchZoom,v=e.as,b=v===void 0?"div":v,w=e.gapMode,N=uh(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=m,_=gee([n,t]),S=di(di({},N),s);return y.createElement(y.Fragment,null,d&&y.createElement(j,{sideCar:P4,removeScrollBar:u,shards:h,noRelative:f,noIsolation:x,inert:g,setCallbacks:i,allowPinchZoom:!!p,lockRef:n,gapMode:w}),o?y.cloneElement(y.Children.only(l),di(di({},S),{ref:_})):y.createElement(b,di({},S,{className:c,ref:_}),l))});ib.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ib.classNames={fullWidth:px,zeroRight:mx};var wee=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function _ee(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=wee();return t&&e.setAttribute("nonce",t),e}function jee(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Nee(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var See=function(){var e=0,t=null;return{add:function(n){e==0&&(t=_ee())&&(jee(t,n),Nee(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Cee=function(){var e=See();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},O4=function(){var e=Cee(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},kee={left:0,top:0,right:0,gap:0},_w=function(e){return parseInt(e||"",10)||0},Eee=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[_w(n),_w(r),_w(s)]},Pee=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return kee;var t=Eee(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Oee=O4(),ed="data-scroll-locked",Aee=function(e,t,n,r){var s=e.left,i=e.top,o=e.right,l=e.gap;return n===void 0&&(n="margin"),` 656 .`.concat(hee,` { 657 overflow: hidden `).concat(r,`; 658 padding-right: `).concat(l,"px ").concat(r,`; 659 } 660 body[`).concat(ed,`] { 661 overflow: hidden `).concat(r,`; 662 overscroll-behavior: contain; 663 `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&` 664 padding-left: `.concat(s,`px; 665 padding-top: `).concat(i,`px; 666 padding-right: `).concat(o,`px; 667 margin-left:0; 668 margin-top:0; 669 margin-right: `).concat(l,"px ").concat(r,`; 670 `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";
670")].filter(Boolean).join(""),` 671 } 672 673 .`).concat(mx,` { 674 right: `).concat(l,"px ").concat(r,`; 675 } 676 677 .`).concat(px,` { 678 margin-right: `).concat(l,"px ").concat(r,`; 679 } 680 681 .`).concat(mx," .").concat(mx,` { 682 right: 0 `).concat(r,`; 683 } 684 685 .`).concat(px," .").concat(px,` { 686 margin-right: 0 `).concat(r,`; 687 } 688 689 body[`).concat(ed,`] { 690 `).concat(fee,": ").concat(l,`px; 691 } 692`)},OO=function(){var e=parseInt(document.body.getAttribute(ed)||"0",10);return isFinite(e)?e:0},Tee=function(){y.useEffect(function(){return document.body.setAttribute(ed,(OO()+1).toString()),function(){var e=OO()-1;e<=0?document.body.removeAttribute(ed):document.body.setAttribute(ed,e.toString())}},[])},Mee=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,s=r===void 0?"margin":r;Tee();var i=y.useMemo(function(){return Pee(s)},[s]);return y.createElement(Oee,{styles:Aee(i,!t,s,n?"":"!important")})},s1=!1;if(typeof window<"u")try{var jg=Object.defineProperty({},"passive",{get:function(){return s1=!0,!0}});window.addEventListener("test",jg,jg),window.removeEventListener("test",jg,jg)}catch{s1=!1}var uu=s1?{passive:!1}:!1,Dee=function(e){return e.tagName==="TEXTAREA"},A4=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Dee(e)&&n[t]==="visible")},$ee=function(e){return A4(e,"overflowY")},Ree=function(e){return A4(e,"overflowX")},AO=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var s=T4(e,r);if(s){var i=M4(e,r),o=i[1],l=i[2];if(o>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Iee=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},Lee=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},T4=function(e,t){return e==="v"?$ee(t):Ree(t)},M4=function(e,t){return e==="v"?Iee(t):Lee(t)},Fee=function(e,t){return e==="h"&&t==="rtl"?-1:1},qee=function(e,t,n,r,s){var i=Fee(e,window.getComputedStyle(t).direction),o=i*r,l=n.target,c=t.contains(l),u=!1,d=o>0,h=0,m=0;do{if(!l)break;var f=M4(e,l),x=f[0],g=f[1],p=f[2],v=g-p-i*x;(x||v)&&T4(e,l)&&(h+=v,m+=x);var b=l.parentNode;l=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(d&&(Math.abs(h)<1||!s)||!d&&(Math.abs(m)<1||!s))&&(u=!0),u},Ng=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},TO=function(e){return[e.deltaX,e.deltaY]},MO=function(e){return e&&"current"in e?e.current:e},zee=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Bee=function(e){return` 693 .block-interactivity-`.concat(e,` {pointer-events: none;} 694 .allow-interactivity-`).concat(e,` {pointer-events: all;} 695`)},Uee=0,du=[];function Wee(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),s=y.useState(Uee++)[0],i=y.useState(O4)[0],o=y.useRef(e);y.useEffect(function(){o.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var g=iX([e.lockRef.current],(e.shards||[]).map(MO),!0).filter(Boolean);return g.forEach(function(p){return p.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),g.forEach(function(p){return p.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var l=y.useCallback(function(g,p){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!o.current.allowPinchZoom;var v=Ng(g),b=n.current,w="deltaX"in g?g.deltaX:b[0]-v[0],N="deltaY"in g?g.deltaY:b[1]-v[1],j,_=g.target,S=Math.abs(w)>Math.abs(N)?"h":"v";if("touches"in g&&S==="h"&&_.type==="range")return!1;var P=AO(S,_);if(!P)return!0;if(P?j=S:(j=S==="v"?"h":"v",P=AO(S,_)),!P)return!1;if(!r.current&&"changedTouches"in g&&(w||N)&&(r.current=j),!j)return!0;var k=r.current||j;return qee(k,p,g,k==="h"?w:N,!0)},[]),c=y.useCallback(function(g){var p=g;if(!(!du.length||du[du.length-1]!==i)){var v="deltaY"in p?TO(p):Ng(p),b=t.current.filter(function(j){return j.name===p.type&&(j.target===p.target||p.target===j.shadowParent)&&zee(j.delta,v)}
vendor: 4,155 bytes, line 695
695)[0];if(b&&b.should){p.cancelable&&p.preventDefault();return}if(!b){var w=(o.current.shards||[]).map(MO).filter(Boolean).filter(function(j){return j.contains(p.target)}),N=w.length>0?l(p,w[0]):!o.current.noIsolation;N&&p.cancelable&&p.preventDefault()}}},[]),u=y.useCallback(function(g,p,v,b){var w={name:g,delta:p,target:v,should:b,shadowParent:Kee(v)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(N){return N!==w})},1)},[]),d=y.useCallback(function(g){n.current=Ng(g),r.current=void 0},[]),h=y.useCallback(function(g){u(g.type,TO(g),g.target,l(g,e.lockRef.current))},[]),m=y.useCallback(function(g){u(g.type,Ng(g),g.target,l(g,e.lockRef.current))},[]);y.useEffect(function(){return du.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:m}),document.addEventListener("wheel",c,uu),document.addEventListener("touchmove",c,uu),document.addEventListener("touchstart",d,uu),function(){du=du.filter(function(g){return g!==i}),document.removeEventListener("wheel",c,uu),document.removeEventListener("touchmove",c,uu),document.removeEventListener("touchstart",d,uu)}},[]);var f=e.removeScrollBar,x=e.inert;return y.createElement(y.Fragment,null,x?y.createElement(i,{styles:Bee(s)}):null,f?y.createElement(Mee,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Kee(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Hee=bee(P4,Wee);var wp=y.forwardRef(function(e,t){return y.createElement(ib,di({},e,{ref:t,sideCar:Hee}))});wp.classNames=ib.classNames;var Gee=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},hu=new WeakMap,Sg=new WeakMap,Cg={},jw=0,D4=function(e){return e&&(e.host||D4(e.parentNode))},Vee=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=D4(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Yee=function(e,t,n,r){var s=Vee(t,Array.isArray(e)?e:[e]);Cg[n]||(Cg[n]=new WeakMap);var i=Cg[n],o=[],l=new Set,c=new Set(s),u=function(h){!h||l.has(h)||(l.add(h),u(h.parentNode))};s.forEach(u);var d=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(m){if(l.has(m))d(m);else try{var f=m.getAttribute(r),x=f!==null&&f!=="false",g=(hu.get(m)||0)+1,p=(i.get(m)||0)+1;hu.set(m,g),i.set(m,p),o.push(m),g===1&&x&&Sg.set(m,!0),p===1&&m.setAttribute(n,"true"),x||m.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",m,v)}})};return d(t),l.clear(),jw++,function(){o.forEach(function(h){var m=hu.get(h)-1,f=i.get(h)-1;hu.set(h,m),i.set(h,f),m||(Sg.has(h)||h.removeAttribute(r),Sg.delete(h)),f||h.removeAttribute(n)}),jw--,jw||(hu=new WeakMap,hu=new WeakMap,Sg=new WeakMap,Cg={})}},ob=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),s=Gee(e);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live]"))),Yee(r,s,n,"aria-hidden")):function(){return null}},lb="Dialog",[$4,R4]=jr(lb),[Qee,Xs]=$4(lb),I4=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:s,onOpenChange:i,modal:o=!0}=e,l=y.useRef(null),c=y.useRef(null),[u,d]=oa({prop:r,defaultProp:s??!1,onChange:i,caller:lb});return a.jsx(Qee,{scope:t,triggerRef:l,contentRef:c,contentId:Zn(),titleId:Zn(),descriptionId:Zn(),open:u,onOpenChange:d,onOpenToggle:y.useCallback(()=>d(h=>!h),[d]),modal:o,children:n})};I4.displayName=lb;var L4="DialogTrigger",F4=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Xs(L4,n),i=Ct(t,s.triggerRef);return a.jsx(tt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":FC(s.open),...r,ref:i,onClick:Fe(e.onClick,s.onOpenToggle)})});F4.displayName=L4;var IC="DialogPortal",[Xee,q4]=$4(IC,{forceMount:void 0}),z4=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:s}=e,i=Xs(IC,t);return a.jsx(Xee,{scope:t,forceMount:n,children:y.Children.map(r,o=>a.jsx(tr,{present:n||i.open,children:a.jsx(th,{asChild:!0,container:s,children:o})}))})};z4.displayName=IC;var sy="DialogOverlay",B4=y.forwardRef((e,t)=>
vendor: 4,914 bytes, lines 695-699
695{const n=q4(sy,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,i=Xs(sy,e.__scopeDialog);return i.modal?a.jsx(tr,{present:r||i.open,children:a.jsx(Zee,{...s,ref:t})}):null});B4.displayName=sy;var Jee=ml("DialogOverlay.RemoveScroll"),Zee=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Xs(sy,n);return a.jsx(wp,{as:Jee,allowPinchZoom:!0,shards:[s.contentRef],children:a.jsx(tt.div,{"data-state":FC(s.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Tc="DialogContent",U4=y.forwardRef((e,t)=>{const n=q4(Tc,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,i=Xs(Tc,e.__scopeDialog);return a.jsx(tr,{present:r||i.open,children:i.modal?a.jsx(ete,{...s,ref:t}):a.jsx(tte,{...s,ref:t})})});U4.displayName=Tc;var ete=y.forwardRef((e,t)=>{const n=Xs(Tc,e.__scopeDialog),r=y.useRef(null),s=Ct(t,n.contentRef,r);return y.useEffect(()=>{const i=r.current;if(i)return ob(i)},[]),a.jsx(W4,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Fe(e.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Fe(e.onPointerDownOutside,i=>{const o=i.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&i.preventDefault()}),onFocusOutside:Fe(e.onFocusOutside,i=>i.preventDefault())})}),tte=y.forwardRef((e,t)=>{const n=Xs(Tc,e.__scopeDialog),r=y.useRef(!1),s=y.useRef(!1);return a.jsx(W4,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,i),i.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=i.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),W4=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,...o}=e,l=Xs(Tc,n),c=y.useRef(null),u=Ct(t,c);return sb(),a.jsxs(a.Fragment,{children:[a.jsx(bp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:a.jsx(jl,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":FC(l.open),...o,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),a.jsxs(a.Fragment,{children:[a.jsx(rte,{titleId:l.titleId}),a.jsx(ste,{contentRef:c,descriptionId:l.descriptionId})]})]})}),LC="DialogTitle",K4=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Xs(LC,n);return a.jsx(tt.h2,{id:s.titleId,...r,ref:t})});K4.displayName=LC;var H4="DialogDescription",G4=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Xs(H4,n);return a.jsx(tt.p,{id:s.descriptionId,...r,ref:t})});G4.displayName=H4;var V4="DialogClose",Y4=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Xs(V4,n);return a.jsx(tt.button,{type:"button",...r,ref:t,onClick:Fe(e.onClick,()=>s.onOpenChange(!1))})});Y4.displayName=V4;function FC(e){return e?"open":"closed"}var Q4="DialogTitleWarning",[nte,X4]=ZW(Q4,{contentName:Tc,titleName:LC,docsSlug:"dialog"}),rte=({titleId:e})=>{const t=X4(Q4),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. 696 697If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component. 698 699For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return y.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ate="DialogDescriptionWarning",ste=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${X4(ate).contentName}}.`;return y.useEffect(()=>{var i;const s=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},cb=I4,J4=F4,ub=z4,hh=B4,fh=U4,_p=K4,jp=G4,db=Y4;const Dt=cb,qC=J4,ite=ub,Z4=y.forwardRef(({className:e,...t},n)=>a.jsx(hh,{ref:n,className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Z4.displayName=hh.displayName;const Pt=y.forwardRef(({className:e,children:t,...n},r)=>a.jsxs(ite,{children:[a.jsx(Z4,{}),a.jsxs(fh,{ref:r,className:Se("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rou
699nded-lg",e),...n,children:[t,a.jsxs(db,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[a.jsx(Ht,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Pt.displayName=fh.displayName;const Ot=({className:e,...t})=>a.jsx("div",{className:Se("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ot.displayName="DialogHeader";const br=({className:e,...t})=>a.jsx("div",{className:Se("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});br.displayName="DialogFooter";const At=y.forwardRef(({className:e,...t},n)=>a.jsx(_p,{ref:n,className:Se("text-lg font-semibold leading-none tracking-tight",e),...t}));At.displayName=_p.displayName;const wr=y.forwardRef(({className:e,...t},n)=>a.jsx(jp,{ref:n,className:Se("text-sm text-muted-foreground",e),...t}));wr.displayName=jp.displayName;const ce=y.forwardRef(({className:e,type:t,...n},r)=>a.jsx("input",{type:t,className:Se("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));ce.displayName="Input";var ote="Label",eL=y.forwardRef((e,t)=>a.jsx(tt.label,{...e,ref:t,onMouseDown:n=>{var s;n.target.closest("button, input, select, textarea")||((s=e.onMouseDown)==null||s.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));eL.displayName=ote;var tL=eL;const lte=nh("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),xe=y.forwardRef(({className:e,...t},n)=>a.jsx(tL,{ref:n,className:Se(lte(),e),...t}));xe.displayName=tL.displayName;const qt=y.forwardRef(({className:e,...t},n)=>a.jsx("textarea",{className:Se("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
699ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));qt.displayName="Textarea";function i1(e,[t,n]){return Math.min(n,Math.max(t,e))}var cte=y.createContext(void 0);function mh(e){const t=y.useContext(cte);return e||t||"ltr"}var ute=[" ","Enter","ArrowUp","ArrowDown"],dte=[" ","Enter"],Mc="Select",[hb,fb,hte]=dp(Mc),[ph,p3e]=jr(Mc,[hte,Si]),mb=Si(),[fte,Pl]=ph(Mc),[mte,pte]=ph(Mc),nL=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:s,onOpenChange:i,value:o,defaultValue:l,onValueChange:c,dir:u,name:d,autoComplete:h,disabled:m,required:f,form:x}=e,g=mb(t),[p,v]=y.useState(null),[b,w]=y.useState(null),[N,j]=y.useState(!1),_=mh(u),[S,P]=oa({prop:r,defaultProp:s??!1,onChange:i,caller:Mc}),[k,C]=oa({prop:o,defaultProp:l,onChange:c,caller:Mc}),T=y.useRef(null),O=p?x||!!p.closest("form"):!0,[L,E]=y.useState(new Set),R=Array.from(L).map(q=>q.props.value).join(";");return a.jsx(pp,{...g,children:a.jsxs(fte,{required:f,scope:t,trigger:p,onTriggerChange:v,valueNode:b,onValueNodeChange:w,valueNodeHasChildren:N,onValueNodeHasChildrenChange:j,contentId:Zn(),value:k,onValueChange:C,open:S,onOpenChange:P,dir:_,triggerPointerDownPosRef:T,disabled:m,children:[a.jsx(hb.Provider,{scope:t,children:a.jsx(mte,{scope:e.__scopeSelect,onNativeOptionAdd:y.useCallback(q=>{E(I=>new Set(I).add(q))},[]),onNativeOptionRemove:y.useCallback(q=>{E(I=>{const $=new Set(I);return $.delete(q),$})},[]),children:n})}),O?a.jsxs(CL,{"aria-hidden":!0,required:f,tabIndex:-1,name:d,autoComplete:h,value:k,onChange:q=>C(q.target.value),disabled:m,form:x,children:[k===void 0?a.jsx("option",{value:""}):null,Array.from(L)]},R):null]})})};nL.displayName=Mc;var rL="SelectTrigger",aL=y.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...s}=e,i=mb(n),o=Pl(rL,n),l=o.disabled||r,c=Ct(t,o.onTriggerChange),u=fb(n),d=y.useRef("touch"),[h,m,f]=EL(g=>{const p=u().filter(w=>!w.disabled),v=p.find(w=>w.value===o.value),b=PL(p,g,v);b!==void 0&&o.onValueChange(b.value)}),x=g=>{l||(o.onOpenChange(!0),f()),g&&(o.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return a.jsx(ih,{asChild:!0,...i,children:a.jsx(tt.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":kL(o.value)?"":void 0,...s,ref:c,onClick:Fe(s.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&x(g)}),onPointerDown:Fe(s.onPointerDown,g=>{d.current=g.pointerType;const p=g.target;p.hasPointerCapture(g.pointerId)&&p.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(x(g),g.preventDefault())}),onKeyDown:Fe(s.onKeyDown,g=>{const p=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&m(g.key),!(p&&g.key===" ")&&ute.includes(g.key)&&(x(),g.preventDefault())})})})});aL.displayName=rL;var sL="SelectValue",iL=y.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,children:i,placeholder:o="",...l}=e,c=Pl(sL,n),{onValueNodeHasChildrenChange:u}=c,d=i!==void 0,h=Ct(t,c.onValueNodeChange);return dr(()=>{u(d)},[u,d]),a.jsx(tt.span,{...l,ref:h,style:{pointerEvents:"none"},children:kL(c.value)?a.jsx(a.Fragment,{children:o}):i})});iL.displayName=sL;var gte="SelectIcon",oL=y.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...s}=e;return a.jsx(tt.span,{"aria-hidden":!0,...s,ref:t,children:r||"â¼"})});oL.displayName=gte;var xte="SelectPortal",lL=e=>a.jsx(th,{asChild:!0,...e});lL.displayName=xte;var Dc="SelectContent",cL=y.forwardRef((e,t)=>{const n=Pl(Dc,e.__scopeSelect),[r,s]=y.useState();if(dr(()=>{s(new DocumentFragment)},[]),!n.open){const i=r;return i?Kc.createPortal(a.jsx(uL,{scope:e.__scopeSelect,children:a.jsx(hb.Slot,{scope:e.__scopeSelect,children:a.jsx("div",{children:e.children})})}),i):null}return a.jsx(dL,{...e,ref:t})});cL.displayName=Dc;var Cs=10,[uL,Ol]=ph(Dc),yte="SelectContentImpl",vte=ml("SelectContent.RemoveScroll"),dL=y.forwardRef((e,t)=>
vendor: 14,501 bytes, line 699
699{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:i,onPointerDownOutside:o,side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:x,hideWhenDetached:g,avoidCollisions:p,...v}=e,b=Pl(Dc,n),[w,N]=y.useState(null),[j,_]=y.useState(null),S=Ct(t,te=>N(te)),[P,k]=y.useState(null),[C,T]=y.useState(null),O=fb(n),[L,E]=y.useState(!1),R=y.useRef(!1);y.useEffect(()=>{if(w)return ob(w)},[w]),sb();const q=y.useCallback(te=>{const[J,...re]=O().map(X=>X.ref.current),[pe]=re.slice(-1),ye=document.activeElement;for(const X of te)if(X===ye||(X==null||X.scrollIntoView({block:"nearest"}),X===J&&j&&(j.scrollTop=0),X===pe&&j&&(j.scrollTop=j.scrollHeight),X==null||X.focus(),document.activeElement!==ye))return},[O,j]),I=y.useCallback(()=>q([P,w]),[q,P,w]);y.useEffect(()=>{L&&I()},[L,I]);const{onOpenChange:$,triggerPointerDownPosRef:M}=b;y.useEffect(()=>{if(w){let te={x:0,y:0};const J=pe=>{var ye,X;te={x:Math.abs(Math.round(pe.pageX)-(((ye=M.current)==null?void 0:ye.x)??0)),y:Math.abs(Math.round(pe.pageY)-(((X=M.current)==null?void 0:X.y)??0))}},re=pe=>{te.x<=10&&te.y<=10?pe.preventDefault():w.contains(pe.target)||$(!1),document.removeEventListener("pointermove",J),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",J),document.addEventListener("pointerup",re,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",re,{capture:!0})}}},[w,$,M]),y.useEffect(()=>{const te=()=>$(!1);return window.addEventListener("blur",te),window.addEventListener("resize",te),()=>{window.removeEventListener("blur",te),window.removeEventListener("resize",te)}},[$]);const[B,W]=EL(te=>{const J=O().filter(ye=>!ye.disabled),re=J.find(ye=>ye.ref.current===document.activeElement),pe=PL(J,te,re);pe&&setTimeout(()=>pe.ref.current.focus())}),A=y.useCallback((te,J,re)=>{const pe=!R.current&&!re;(b.value!==void 0&&b.value===J||pe)&&(k(te),pe&&(R.current=!0))},[b.value]),K=y.useCallback(()=>w==null?void 0:w.focus(),[w]),G=y.useCallback((te,J,re)=>{const pe=!R.current&&!re;(b.value!==void 0&&b.value===J||pe)&&T(te)},[b.value]),H=r==="popper"?o1:hL,fe=H===o1?{side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:m,collisionPadding:f,sticky:x,hideWhenDetached:g,avoidCollisions:p}:{};return a.jsx(uL,{scope:n,content:w,viewport:j,onViewportChange:_,itemRefCallback:A,selectedItem:P,onItemLeave:K,itemTextRefCallback:G,focusSelectedItem:I,selectedItemText:C,position:r,isPositioned:L,searchRef:B,children:a.jsx(wp,{as:vte,allowPinchZoom:!0,children:a.jsx(bp,{asChild:!0,trapped:b.open,onMountAutoFocus:te=>{te.preventDefault()},onUnmountAutoFocus:Fe(s,te=>{var J;(J=b.trigger)==null||J.focus({preventScroll:!0}),te.preventDefault()}),children:a.jsx(jl,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:te=>te.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:a.jsx(H,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:te=>te.preventDefault(),...v,...fe,onPlaced:()=>E(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:Fe(v.onKeyDown,te=>{const J=te.ctrlKey||te.altKey||te.metaKey;if(te.key==="Tab"&&te.preventDefault(),!J&&te.key.length===1&&W(te.key),["ArrowUp","ArrowDown","Home","End"].includes(te.key)){let pe=O().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(te.key)&&(pe=pe.slice().reverse()),["ArrowUp","ArrowDown"].includes(te.key)){const ye=te.target,X=pe.indexOf(ye);pe=pe.slice(X+1)}setTimeout(()=>q(pe)),te.preventDefault()}})})})})})})});dL.displayName=yte;var bte="SelectItemAlignedPosition",hL=y.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...s}=e,i=Pl(Dc,n),o=Ol(Dc,n),[l,c]=y.useState(null),[u,d]=y.useState(null),h=Ct(t,S=>d(S)),m=fb(n),f=y.useRef(!1),x=y.useRef(!0),{viewport:g,selectedItem:p,selectedItemText:v,focusSelectedItem:b}=o,w=y.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&u&&g&&p&&v){const S=i.trigger.getBoundingClientRect(),P=u.getBoundingClientRect(),k=i.valueNode.getBoundingClientRect(),C=v.getBoundingClientRect();if(i.dir!=="rtl"){const ye=C.left-P.left,X=k.left-ye,he=S.left-X,D=S.width+he,le=Math.max(D,P.width),V=window.innerWidth-Cs,U=i1(X,[Cs,Math.max(Cs,V-le)]);l.style.minWidth=D+"px",l.style.left=U+"px"}else{const ye=P.right-C.right,X=window.innerWidth-k.right-ye,he=window.innerWidth-S.right-X,D=S.width+he,le=Math.max(D,P.width),V=window.innerWidth-Cs,U=i1(X,[Cs,Math.max(Cs,V-le)]);l.style.minWidth=D+"px",l.style.right=U+"px"}const T=m(),O=window.innerHeight-Cs*2,L=g.scrollHeight,E=window.getComputedStyle(u),R=parseInt(E.borderTopWidth,10),q=parseInt(E.paddingTop,10),I=parseInt(E.borderBottomWidth,10),$=parseInt(E.paddingBottom,10),M=R+q+L+$+I,B=Math.min(p.offsetHeight*5,M),W=window.getComputedStyle(g),A=parseInt(W.paddingTop,10),K=parseInt(W.paddingBottom,10),G=S.top+S.height/2-Cs,H=O-G,fe=p.offsetHeight/2,te=p.offsetTop+fe,J=R+q+te,re=M-J;if(J<=G){const ye=T.length>0&&p===T[T.length-1].ref.current;l.style.bottom="0px";const X=u.clientHeight-g.offsetTop-g.offsetHeight,he=Math.max(H,fe+(ye?K:0)+X+I),D=J+he;l.style.height=D+"px"}else{const ye=T.length>0&&p===T[0].ref.current;l.style.top="0px";const he=Math.max(G,R+g.offsetTop+(ye?A:0)+fe)+re;l.style.height=he+"px",g.scrollTop=J-G+g.offsetTop}l.style.margin=`${Cs}px 0`,l.style.minHeight=B+"px",l.style.maxHeight=O+"px",r==null||r(),requestAnimationFrame(()=>f.current=!0)}},[m,i.trigger,i.valueNode,l,u,g,p,v,i.dir,r]);dr(()=>w(),[w]);const[N,j]=y.useState();dr(()=>{u&&j(window.getComputedStyle(u).zIndex)},[u]);const _=y.useCallback(S=>{S&&x.current===!0&&(w(),b==null||b(),x.current=!1)},[w,b]);return a.jsx(_te,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:f,onScrollButtonChange:_,children:a.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:a.jsx(tt.div,{...s,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});hL.displayName=bte;var wte="SelectPopperPosition",o1=y.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:s=Cs,...i}=e,o=mb(n);return a.jsx(gp,{...o,...i,ref:t,align:r,collisionPadding:s,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});o1.displayName=wte;var[_te,zC]=ph(Dc,{}),l1="SelectViewport",fL=y.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...s}=e,i=Ol(l1,n),o=zC(l1,n),l=Ct(t,i.onViewportChange),c=y.useRef(0);return a.jsxs(a.Fragment,{children:[a.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),a.jsx(hb.Slot,{scope:n,children:a.jsx(tt.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Fe(s.onScroll,u=>{const d=u.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:m}=o;if(m!=null&&m.current&&h){const f=Math.abs(c.current-d.scrollTop);if(f>0){const x=window.innerHeight-Cs*2,g=parseFloat(h.style.minHeight),p=parseFloat(h.style.height),v=Math.max(g,p);if(v<x){const b=v+f,w=Math.min(x,b),N=b-w;h.style.height=w+"px",h.style.bottom==="0px"&&(d.scrollTop=N>0?N:0,h.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});fL.displayName=l1;var mL="SelectGroup",[jte,Nte]=ph(mL),Ste=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Zn();return a.jsx(jte,{scope:n,id:s,children:a.jsx(tt.div,{role:"group","aria-labelledby":s,...r,ref:t})})});Ste.displayName=mL;var pL="SelectLabel",gL=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Nte(pL,n);return a.jsx(tt.div,{id:s.id,...r,ref:t})});gL.displayName=pL;var iy="SelectItem",[Cte,xL]=ph(iy),yL=y.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:s=!1,textValue:i,...o}=e,l=Pl(iy,n),c=Ol(iy,n),u=l.value===r,[d,h]=y.useState(i??""),[m,f]=y.useState(!1),x=Ct(t,b=>{var w;return(w=c.itemRefCallback)==null?void 0:w.call(c,b,r,s)}),g=Zn(),p=y.useRef("touch"),v=()=>{s||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return a.jsx(Cte,{scope:n,value:r,disabled:s,textId:g,isSelected:u,onItemTextChange:y.useCallback(b=>{h(w=>w||((b==null?void 0:b.textContent)??"").trim())},[]),children:a.jsx(hb.ItemSlot,{scope:n,value:r,disabled:s,textValue:d,children:a.jsx(tt.div,{role:"option","aria-labelledby":g,"data-highlighted":m?"":void 0,"aria-selected":u&&m,"data-state":u?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...o,ref:x,onFocus:Fe(o.onFocus,()=>f(!0)),onBlur:Fe(o.onBlur,()=>f(!1)),onClick:Fe(o.onClick,()=>{p.current!=="mouse"&&v()}),onPointerUp:Fe(o.onPointerUp,()=>{p.current==="mouse"&&v()}),onPointerDown:Fe(o.onPointerDown,b=>{p.current=b.pointerType}),onPointerMove:Fe(o.onPointerMove,b=>{var w;p.current=b.pointerType,s?(w=c.onItemLeave)==null||w.call(c):p.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Fe(o.onPointerLeave,b=>{var w;b.currentTarget===document.activeElement&&((w=c.onItemLeave)==null||w.call(c))}),onKeyDown:Fe(o.onKeyDown,b=>{var N;((N=c.searchRef)==null?void 0:N.current)!==""&&b.key===" "||(dte.includes(b.key)&&v(),b.key===" "&&b.preventDefault())})})})})});yL.displayName=iy;var ff="SelectItemText",vL=y.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,...i}=e,o=Pl(ff,n),l=Ol(ff,n),c=xL(ff,n),u=pte(ff,n),[d,h]=y.useState(null),m=Ct(t,v=>h(v),c.onItemTextChange,v=>{var b;return(b=l.itemTextRefCallback)==null?void 0:b.call(l,v,c.value,c.disabled)}),f=d==null?void 0:d.textContent,x=y.useMemo(()=>a.jsx("option",{value:c.value,disabled:c.disabled,children:f},c.value),[c.disabled,c.value,f]),{onNativeOptionAdd:g,onNativeOptionRemove:p}=u;return dr(()=>(g(x),()=>p(x)),[g,p,x]),a.jsxs(a.Fragment,{children:[a.jsx(tt.span,{id:c.textId,...i,ref:m}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Kc.createPortal(i.children,o.valueNode):null]})});vL.displayName=ff;var bL="SelectItemIndicator",wL=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return xL(bL,n).isSelected?a.jsx(tt.span,{"aria-hidden":!0,...r,ref:t}):null});wL.displayName=bL;var c1="SelectScrollUpButton",_L=y.forwardRef((e,t)=>{const n=Ol(c1,e.__scopeSelect),r=zC(c1,e.__scopeSelect),[s,i]=y.useState(!1),o=Ct(t,r.onScrollButtonChange);return dr(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollTop>0;i(u)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?a.jsx(NL,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});_L.displayName=c1;var u1="SelectScrollDownButton",jL=y.forwardRef((e,t)=>{const n=Ol(u1,e.__scopeSelect),r=zC(u1,e.__scopeSelect),[s,i]=y.useState(!1),o=Ct(t,r.onScrollButtonChange);return dr(()=>{if(n.viewport&&n.isPositioned){let l=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;i(d)};const c=n.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?a.jsx(NL,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=n;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});jL.displayName=u1;var NL=y.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...s}=e,i=Ol("SelectScrollButton",n),o=y.useRef(null),l=fb(n),c=y.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return y.useEffect(()=>()=>c(),[c]),dr(()=>{var d;const u=l().find(h=>h.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[l]),a.jsx(tt.div,{"aria-hidden":!0,...s,ref:t,style:{flexShrink:0,...s.style},onPointerDown:Fe(s.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Fe(s.onPointerMove,()=>{var u;(u=i.onItemLeave)==null||u.call(i),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Fe(s.onPointerLeave,()=>{c()})})}),kte="SelectSeparator",SL=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return a.jsx(tt.div,{"aria-hidden":!0,...r,ref:t})});SL.displayName=kte;var d1="SelectArrow",Ete=y.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=mb(n),i=Pl(d1,n),o=Ol(d1,n);return i.open&&o.position==="popper"?a.jsx(xp,{...s,...r,ref:t}):null});Ete.displayName=d1;var Pte="SelectBubbleInput",CL=y.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const s=y.useRef(null),i=Ct(r,s),o=DC(t);return y.useEffect(()=>{const l=s.current;if(!l)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==t&&d){const h=new Event("change",{bubbles:!0});d.call(l,t),l.dispatchEvent(h)}},[o,t]),a.jsx(tt.select,{...n,style:{...s3,...n.style},ref:i,defaultValue:t})});CL.displayName=Pte;function kL(e){return e===""||e===void 0}function EL(e){const t=Kn(e),n=y.useRef(""),r=y.useRef(0),s=y.useCallback(o=>{const l=n.current+o;t(l),function c(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>c(""),1e3))}(l)},[t]),i=y.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return y.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,s,i]}function PL(e,t,n){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=Ote(e,Math.max(i,0));s.length===1&&(o=o.filter(u=>u!==n));const c=o.find(u=>u.textValue.toLowerCase().startsWith(s.toLowerCase()));return c!==n?c:void 0}function Ote(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ate=nL,OL=aL,Tte=iL,Mte=oL,Dte=lL,AL=cL,$te=fL,TL=gL,ML=yL,Rte=vL,Ite=wL,DL=_L,$L=jL,RL=SL;const lt=Ate,ct=Tte,it=y.forwardRef(({className:e,children:t,...n},r)=>a.jsxs(OL,{ref:r,className:Se("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm r
699ing-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,a.jsx(Mte,{asChild:!0,children:a.jsx(_n,{className:"h-4 w-4 opacity-50"})})]}));it.displayName=OL.displayName;const IL=y.forwardRef(({className:e,...t},n)=>a.jsx(DL,{ref:n,className:Se("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(_r,{className:"h-4 w-4"})}));IL.displayName=DL.displayName;const LL=y.forwardRef(({className:e,...t},n)=>a.jsx($L,{ref:n,className:Se("flex cursor-default items-center justify-center py-1",e),...t,children:a.jsx(_n,{className:"h-4 w-4"})}));LL.displayName=$L.displayName;const ot=y.forwardRef(({className:e,children:t,position:n="popper",...r},s)=>a.jsx(Dte,{children:a.jsxs(AL,{ref:s,className:Se("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[a.jsx(IL,{}),a.jsx($te,{className:Se("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),a.jsx(LL,{})]})}));ot.displayName=AL.displayName;const Lte=y.forwardRef(({className:e,...t},n)=>a.jsx(TL,{ref:n,className:Se("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Lte.displayName=TL.displayName;const Oe=y.forwardRef(({className:e,children:t,...n},r)=>a.jsxs(ML,{ref:r,className:Se("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Ite,{children:a.jsx(On,{className:"h-4 w-4"})})}),a.jsx(Rte,{children:t})]}));Oe.displayName=ML.displayName;const Fte=y.forwardRef(({className:e,...t},n)=>a.jsx(RL,{ref:n,className:Se("-mx-1 my-1 h-px bg-muted",e),...t}));Fte.displayName=RL.displayName;var DO=1,qte=.9,zte=.8,Bte=.17,Nw=.1,Sw=.999,Ute=.9999,Wte=.99,Kte=/[\\\/_+.#"@\[\(\{&]/,Hte=/[\\\/_+.#"@\[\(\{&]/g,Gte=/[\s-]/,FL=/[\s-]/g;function h1(e,t,n,r,s,i,o){if(i===t.length)return s===e.length?DO:Wte;var l=`${s},${i}`;if(o[l]!==void 0)return o[l];for(var c=r.charAt(i),u=n.indexOf(c,s),d=0,h,m,f,x;u>=0;)h=h1(e,t,n,r,u+1,i+1,o),h>d&&(u===s?h*=DO:Kte.test(e.charAt(u-1))?(h*=zte,f=e.slice(s,u-1).match(Hte),f&&s>0&&(h*=Math.pow(Sw,f.length))):Gte.test(e.charAt(u-1))?(h*=qte,x=e.slice(s,u-1).match(FL),x&&s>0&&(h*=Math.pow(Sw,x.length))):(h*=Bte,s>0&&(h*=Math.pow(Sw,u-s))),e.charAt(u)!==t.charAt(i)&&(h*=Ute)),(h<Nw&&n.charAt(u-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(u-1)!==r.charAt(i))&&(m=h1(e,t,n,r,u+1,i+2,o),m*Nw>h&&(h=m*Nw)),h>d&&(d=h),u=n.indexOf(c,u+1);return o[l]=d,d}function $O(e){return e.toLowerCase().replace(FL," ")}function Vte(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,h1(e,t,$O(e),$O(t),0,0,{})}var qh='[cmdk-group=""]',Cw='[cmdk-group-items=""]',Yte='[cmdk-group-heading=""]',qL='[cmdk-item=""]',RO=`${qL}:not([aria-disabled="true"])`,f1="cmdk-item-select",ku="data-value",Qte=(e,t,n)=>Vte(e,t,n),zL=y.createContext(void 0),Np=()=>y.useContext(zL),BL=y.createContext(void 0),BC=()=>y.useContext(BL),UL=y.createContext(void 0),WL=y.forwardRef((e,t)=>{let n=Eu(()=>{var A,K;return{search:"",value:(K=(A=e.value)!=null?A:e.defaultValue)!=null?K:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Eu(()=>new Set),s=Eu(()=>new Map),i=Eu(()=>new Map),o=Eu(()=>new Set),l=KL(e),{label:c,children:u,value:d,onValueChange:h,filter:m,shouldFilter:f,loop:x,disablePointerSelection:g=!1,vimBindings:p=!0,...v}=e,b=Zn(),w=Zn(),N=Zn(),j=y.useRef(null),_=one();$c(()=>
vendor: 13,501 bytes, line 699
699{if(d!==void 0){let A=d.trim();n.current.value=A,S.emit()}},[d]),$c(()=>{_(6,L)},[]);let S=y.useMemo(()=>({subscribe:A=>(o.current.add(A),()=>o.current.delete(A)),snapshot:()=>n.current,setState:(A,K,G)=>{var H,fe,te,J;if(!Object.is(n.current[A],K)){if(n.current[A]=K,A==="search")O(),C(),_(1,T);else if(A==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let re=document.getElementById(N);re?re.focus():(H=document.getElementById(b))==null||H.focus()}if(_(7,()=>{var re;n.current.selectedItemId=(re=E())==null?void 0:re.id,S.emit()}),G||_(5,L),((fe=l.current)==null?void 0:fe.value)!==void 0){let re=K??"";(J=(te=l.current).onValueChange)==null||J.call(te,re);return}}S.emit()}},emit:()=>{o.current.forEach(A=>A())}}),[]),P=y.useMemo(()=>({value:(A,K,G)=>{var H;K!==((H=i.current.get(A))==null?void 0:H.value)&&(i.current.set(A,{value:K,keywords:G}),n.current.filtered.items.set(A,k(K,G)),_(2,()=>{C(),S.emit()}))},item:(A,K)=>(r.current.add(A),K&&(s.current.has(K)?s.current.get(K).add(A):s.current.set(K,new Set([A]))),_(3,()=>{O(),C(),n.current.value||T(),S.emit()}),()=>{i.current.delete(A),r.current.delete(A),n.current.filtered.items.delete(A);let G=E();_(4,()=>{O(),(G==null?void 0:G.getAttribute("id"))===A&&T(),S.emit()})}),group:A=>(s.current.has(A)||s.current.set(A,new Set),()=>{i.current.delete(A),s.current.delete(A)}),filter:()=>l.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:b,inputId:N,labelId:w,listInnerRef:j}),[]);function k(A,K){var G,H;let fe=(H=(G=l.current)==null?void 0:G.filter)!=null?H:Qte;return A?fe(A,n.current.search,K):0}function C(){if(!n.current.search||l.current.shouldFilter===!1)return;let A=n.current.filtered.items,K=[];n.current.filtered.groups.forEach(H=>{let fe=s.current.get(H),te=0;fe.forEach(J=>{let re=A.get(J);te=Math.max(re,te)}),K.push([H,te])});let G=j.current;R().sort((H,fe)=>{var te,J;let re=H.getAttribute("id"),pe=fe.getAttribute("id");return((te=A.get(pe))!=null?te:0)-((J=A.get(re))!=null?J:0)}).forEach(H=>{let fe=H.closest(Cw);fe?fe.appendChild(H.parentElement===fe?H:H.closest(`${Cw} > *`)):G.appendChild(H.parentElement===G?H:H.closest(`${Cw} > *`))}),K.sort((H,fe)=>fe[1]-H[1]).forEach(H=>{var fe;let te=(fe=j.current)==null?void 0:fe.querySelector(`${qh}[${ku}="${encodeURIComponent(H[0])}"]`);te==null||te.parentElement.appendChild(te)})}function T(){let A=R().find(G=>G.getAttribute("aria-disabled")!=="true"),K=A==null?void 0:A.getAttribute(ku);S.setState("value",K||void 0)}function O(){var A,K,G,H;if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let fe=0;for(let te of r.current){let J=(K=(A=i.current.get(te))==null?void 0:A.value)!=null?K:"",re=(H=(G=i.current.get(te))==null?void 0:G.keywords)!=null?H:[],pe=k(J,re);n.current.filtered.items.set(te,pe),pe>0&&fe++}for(let[te,J]of s.current)for(let re of J)if(n.current.filtered.items.get(re)>0){n.current.filtered.groups.add(te);break}n.current.filtered.count=fe}function L(){var A,K,G;let H=E();H&&(((A=H.parentElement)==null?void 0:A.firstChild)===H&&((G=(K=H.closest(qh))==null?void 0:K.querySelector(Yte))==null||G.scrollIntoView({block:"nearest"})),H.scrollIntoView({block:"nearest"}))}function E(){var A;return(A=j.current)==null?void 0:A.querySelector(`${qL}[aria-selected="true"]`)}function R(){var A;return Array.from(((A=j.current)==null?void 0:A.querySelectorAll(RO))||[])}function q(A){let K=R()[A];K&&S.setState("value",K.getAttribute(ku))}function I(A){var K;let G=E(),H=R(),fe=H.findIndex(J=>J===G),te=H[fe+A];(K=l.current)!=null&&K.loop&&(te=fe+A<0?H[H.length-1]:fe+A===H.length?H[0]:H[fe+A]),te&&S.setState("value",te.getAttribute(ku))}function $(A){let K=E(),G=K==null?void 0:K.closest(qh),H;for(;G&&!H;)G=A>0?sne(G,qh):ine(G,qh),H=G==null?void 0:G.querySelector(RO);H?S.setState("value",H.getAttribute(ku)):I(A)}let M=()=>q(R().length-1),B=A=>{A.preventDefault(),A.metaKey?M():A.altKey?$(1):I(1)},W=A=>{A.preventDefault(),A.metaKey?q(0):A.altKey?$(-1):I(-1)};return y.createElement(tt.div,{ref:t,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:A=>{var K;(K=v.onKeyDown)==null||K.call(v,A);let G=A.nativeEvent.isComposing||A.keyCode===229;if(!(A.defaultPrevented||G))switch(A.key){case"n":case"j":{p&&A.ctrlKey&&B(A);break}case"ArrowDown":{B(A);break}case"p":case"k":{p&&A.ctrlKey&&W(A);break}case"ArrowUp":{W(A);break}case"Home":{A.preventDefault(),q(0);break}case"End":{A.preventDefault(),M();break}case"Enter":{A.preventDefault();let H=E();if(H){let fe=new Event(f1);H.dispatchEvent(fe)}}}}},y.createElement("label",{"cmdk-label":"",htmlFor:P.inputId,id:P.labelId,style:cne},c),pb(e,A=>y.createElement(BL.Provider,{value:S},y.createElement(zL.Provider,{value:P},A))))}),Xte=y.forwardRef((e,t)=>{var n,r;let s=Zn(),i=y.useRef(null),o=y.useContext(UL),l=Np(),c=KL(e),u=(r=(n=c.current)==null?void 0:n.forceMount)!=null?r:o==null?void 0:o.forceMount;$c(()=>{if(!u)return l.item(s,o==null?void 0:o.id)},[u]);let d=HL(s,i,[e.value,e.children,i],e.keywords),h=BC(),m=yl(_=>_.value&&_.value===d.current),f=yl(_=>u||l.filter()===!1?!0:_.search?_.filtered.items.get(s)>0:!0);y.useEffect(()=>{let _=i.current;if(!(!_||e.disabled))return _.addEventListener(f1,x),()=>_.removeEventListener(f1,x)},[f,e.onSelect,e.disabled]);function x(){var _,S;g(),(S=(_=c.current).onSelect)==null||S.call(_,d.current)}function g(){h.setState("value",d.current,!0)}if(!f)return null;let{disabled:p,value:v,onSelect:b,forceMount:w,keywords:N,...j}=e;return y.createElement(tt.div,{ref:ro(i,t),...j,id:s,"cmdk-item":"",role:"option","aria-disabled":!!p,"aria-selected":!!m,"data-disabled":!!p,"data-selected":!!m,onPointerMove:p||l.getDisablePointerSelection()?void 0:g,onClick:p?void 0:x},e.children)}),Jte=y.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:s,...i}=e,o=Zn(),l=y.useRef(null),c=y.useRef(null),u=Zn(),d=Np(),h=yl(f=>s||d.filter()===!1?!0:f.search?f.filtered.groups.has(o):!0);$c(()=>d.group(o),[]),HL(o,l,[e.value,e.heading,c]);let m=y.useMemo(()=>({id:o,forceMount:s}),[s]);return y.createElement(tt.div,{ref:ro(l,t),...i,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},n&&y.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),pb(e,f=>y.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},y.createElement(UL.Provider,{value:m},f))))}),Zte=y.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,s=y.useRef(null),i=yl(o=>!o.search);return!n&&!i?null:y.createElement(tt.div,{ref:ro(s,t),...r,"cmdk-separator":"",role:"separator"})}),ene=y.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,s=e.value!=null,i=BC(),o=yl(u=>u.search),l=yl(u=>u.selectedItemId),c=Np();return y.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),y.createElement(tt.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:s?e.value:o,onChange:u=>{s||i.setState("search",u.target.value),n==null||n(u.target.value)}})}),tne=y.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...s}=e,i=y.useRef(null),o=y.useRef(null),l=yl(u=>u.selectedItemId),c=Np();return y.useEffect(()=>{if(o.current&&i.current){let u=o.current,d=i.current,h,m=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let f=u.offsetHeight;d.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return m.observe(u),()=>{cancelAnimationFrame(h),m.unobserve(u)}}},[]),y.createElement(tt.div,{ref:ro(i,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:c.listId},pb(e,u=>y.createElement("div",{ref:ro(o,c.listInnerRef),"cmdk-list-sizer":""},u)))}),nne=y.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:s,contentClassName:i,container:o,...l}=e;return y.createElement(cb,{open:n,onOpenChange:r},y.createElement(ub,{container:o},y.createElement(hh,{"cmdk-overlay":"",className:s}),y.createElement(fh,{"aria-label":e.label,"cmdk-dialog":"",className:i},y.createElement(WL,{ref:t,...l}))))}),rne=y.forwardRef((e,t)=>yl(n=>n.filtered.count===0)?y.createElement(tt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),ane=y.forwardRef((e,t)=>{let{progress:n,children:r,label:s="Loading...",...i}=e;return y.createElement(tt.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},pb(e,o=>y.createElement("div",{"aria-hidden":!0},o)))}),Ca=Object.assign(WL,{List:tne,Item:Xte,Input:ene,Group:Jte,Separator:Zte,Dialog:nne,Empty:rne,Loading:ane});function sne(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ine(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function KL(e){let t=y.useRef(e);return $c(()=>{t.current=e}),t}var $c=typeof window>"u"?y.useEffect:y.useLayoutEffect;function Eu(e){let t=y.useRef();return t.current===void 0&&(t.current=e()),t}function yl(e){let t=BC(),n=()=>e(t.snapshot());return y.useSyncExternalStore(t.subscribe,n,n)}function HL(e,t,n,r=[]){let s=y.useRef(),i=Np();return $c(()=>{var o;let l=(()=>{var u;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(u=d.current.textContent)==null?void 0:u.trim():s.current}})(),c=r.map(u=>u.trim());i.value(e,l,c),(o=t.current)==null||o.setAttribute(ku,l),s.current=l}),s}var one=()=>{let[e,t]=y.useState(),n=Eu(()=>new Map);return $c(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,s)=>{n.current.set(r,s),t({})}};function lne(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function pb({asChild:e,children:t},n){return e&&y.isValidElement(t)?y.cloneElement(lne(t),{ref:t.ref},n(t.props.children)):n(t)}var cne={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const UC=y.forwardRef(({className:e,...t},n)=>a.jsx(Ca,{ref:n,className:Se("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));UC.displayName=Ca.displayName;const WC=y.forwardRef(({className:e,...t},n)=>a.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[a.jsx(Bv,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),a.jsx(Ca.Input,{ref:n,className:Se("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));WC.displayName=Ca.Input.displayName;const KC=y.forwardRef(({className:e,...t},n)=>a.jsx(Ca.List,{ref:n,className:Se("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));KC.displayName=Ca.List.displayName;const HC=y.forwardRef((e,t)=>a.jsx(Ca.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));HC.displayName=Ca.Empty.displayName;const Of=y.forwardRef(({className:e,...t},n)=>a.jsx(Ca.Group,{ref:n,className:Se("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));Of.displayName=Ca.Group.displayName;const une=y.forwardRef(({className:e,...t},n)=>a.jsx(Ca.Separator,{ref:n,className:Se("-mx-1 h-px bg-border",e),...t}));une.displayName=Ca.Separator.displayName;const GC=y.forwardRef(({className:e,...t},n)=>a.jsx(Ca.Item,{ref:n,className:Se("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));GC.displayName=Ca.Item.displayName;var gb="Popover",[GL,g3e]=jr(gb,[Si]),Sp=Si(),[dne,Al]=GL(gb),VL=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:s,onOpenChange:i,modal:o=!1}=e,l=Sp(t),c=y.useRef(null),[u,d]=y.useState(!1),[h,m]=oa({prop:r,defaultProp:s??!1,onChange:i,caller:gb});return a.jsx(pp,{...l,children:a.jsx(dne,{scope:t,contentId:Zn(),triggerRef:c,open:h,onOpenChange:m,onOpenToggle:y.useCallback(()=>m(f=>!f),[m]),hasCustomAnchor:u,onCustomAnchorAdd:y.useCallback(()=>d(!0),[]),onCustomAnchorRemove:y.useCallback(()=>d(!1),[]),modal:o,children:n})})};VL.displayName=gb;var YL="PopoverAnchor",hne=y.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Al(YL,n),i=Sp(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=s;return y.useEffect(()=>(o(),()=>l()),[o,l]),a.jsx(ih,{...i,...r,ref:t})});hne.displayName=YL;var QL="PopoverTrigger",XL=y.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Al(QL,n),i=Sp(n),o=Ct(t,s.triggerRef),l=a.jsx(tt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":nF(s.open),...r,ref:o,onClick:Fe(e.onClick,s.onOpenToggle)});return s.hasCustomAnchor?l:a.jsx(ih,{asChild:!0,...i,children:l})});XL.displayName=QL;var VC="PopoverPortal",[fne,mne]=GL(VC,{forceMount:void 0}),JL=e=>{const{__scopePopover:t,forceMount:n,children:r,container:s}=e,i=Al(VC,t);return a.jsx(fne,{scope:t,forceMount:n,children:a.jsx(tr,{present:n||i.open,children:a.jsx(th,{asChild:!0,container:s,children:r})})})};JL.displayName=VC;var kd="PopoverContent",ZL=y.forwardRef((e,t)=>
699{const n=mne(kd,e.__scopePopover),{forceMount:r=n.forceMount,...s}=e,i=Al(kd,e.__scopePopover);return a.jsx(tr,{present:r||i.open,children:i.modal?a.jsx(gne,{...s,ref:t}):a.jsx(xne,{...s,ref:t})})});ZL.displayName=kd;var pne=ml("PopoverContent.RemoveScroll"),gne=y.forwardRef((e,t)=>{const n=Al(kd,e.__scopePopover),r=y.useRef(null),s=Ct(t,r),i=y.useRef(!1);return y.useEffect(()=>{const o=r.current;if(o)return ob(o)},[]),a.jsx(wp,{as:pne,allowPinchZoom:!0,children:a.jsx(eF,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Fe(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),i.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Fe(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Fe(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),xne=y.forwardRef((e,t)=>{const n=Al(kd,e.__scopePopover),r=y.useRef(!1),s=y.useRef(!1);return a.jsx(eF,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,i),i.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var c,u;(c=e.onInteractOutside)==null||c.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=i.target;((u=n.triggerRef.current)==null?void 0:u.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),eF=y.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:d,...h}=e,m=Al(kd,n),f=Sp(n);return sb(),a.jsx(bp,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:a.jsx(jl,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:d,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>m.onOpenChange(!1),children:a.jsx(gp,{"data-state":nF(m.open),role:"dialog",id:m.contentId,...f,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),tF="PopoverClose",yne=y.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Al(tF,n);return a.jsx(tt.button,{type:"button",...r,ref:t,onClick:Fe(e.onClick,()=>s.onOpenChange(!1))})});yne.displayName=tF;var vne="PopoverArrow",bne=y.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,s=Sp(n);return a.jsx(xp,{...s,...r,ref:t})});bne.displayName=vne;function nF(e){return e?"open":"closed"}var wne=VL,_ne=XL,jne=JL,rF=ZL;const na=wne,ra=_ne,Kr=y.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},s)=>a.jsx(jne,{children:a.jsx(rF,{ref:s,align:t,sideOffset:n,className:Se("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));Kr.displayName=rF.displayName;function Nne(e){return e.length>0&&"options"in e[0]}function Kt({value:e,onValueChange:t,options:n,placeholder:r="Selectâ¦",emptyText:s="No results found.",className:i,allowNone:o=!1,noneLabel:l="None"}){var g;const[c,u]=y.useState(!1),d=Nne(n),h=d?n.flatMap(p=>p.options):n,f=(g=(o?[{value:"none",label:l},...h]:h).find(p=>p.value===e))==null?void 0:g.label,x=p=>a.jsxs(GC,{value:p.label,onSelect:()=>{t(p.value===e?"":p.value),u(!1)},className:"text-xs",children:[a.jsx(On,{className:Se("mr-2 h-3.5 w-3.5",e===p.value?"opacity-100":"opacity-0")}),p.label]},p.value);return a.jsxs(na,{open:c,onOpenChange:u,children:[a.jsx(ra,{asChild:!0,children:a.jsxs(Y,{variant:"outline",role:"combobox","aria-expanded":c,className:Se("justify-between font-normal",!f&&"text-muted-foreground",i),children:[a.jsx("span",{className:"truncate",children:f||r}),a.jsx(O3,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),a.jsx(Kr,{className:"w-[--radix-popover-trigger-width] p-0 bg-popover z-50",align:"start",children:a.jsxs(UC,{children:[a.jsx(WC,{placeholder:"Searchâ¦",className:"h-8 text-xs"}),a.jsxs(KC,{children:[a.jsx(HC,{className:"text-xs py-2 text-center",children:s}),o&&a.jsx(Of,{children:x({value:"none",label:l})}),d?n.map(p=>a.jsx(Of,{heading:p.label,children:p.options.map(x)},p.label)):a.jsx(Of,{children:n.map(x)})]})]})})]})}let kg=null;function Sne(){var n,r;if(typeof window>"u")return Promise.reject(new Error("window unavailable"));if((r=(n=window.google)==null?void 0:n.maps)!=null&&r.places)return Promise.resolve(window.google);if(kg)return kg;const e="AIzaSyBmvJph4LmrbtW7skeczzpBIyb9WWzFKo4",t="48a700400f037f853399a39cca4a1c28";return kg=new Promise((s,i)=>{window.__lovableInitGoogleMaps=()=>{var c;(c=window.google)!=null&&c.maps?s(window.google):i(new Error("Google Maps failed to initialise"))};const o=document.createElement("script"),l=new URLSearchParams({key:e,v:"weekly",libraries:"places",loading:"async",callback:"__lovableInitGoogleMaps"});
699l.set("channel",t),o.src=`https://maps.googleapis.com/maps/api/js?${l.toString()}`,o.async=!0,o.defer=!0,o.onerror=()=>i(new Error("Failed to load Google Maps script")),document.head.appendChild(o)}),kg}function Cne(e){const t=(i,o=!1)=>{const l=e.find(c=>{var u;return(u=c.types)==null?void 0:u.includes(i)});return l?o?l.short_name??l.shortText??"":l.long_name??l.longText??"":""},n=t("street_number"),r=t("route");return{street:[n,r].filter(Boolean).join(" "),city:t("locality")||t("postal_town")||t("sublocality")||t("administrative_area_level_2"),state:t("administrative_area_level_1",!0),postal_code:t("postal_code"),country:t("country")}}function aF({defaultValue:e="",placeholder:t,isSaving:n,onChangeText:r,onPlaceParsed:s}){const i=y.useRef(null),[o,l]=y.useState(!1),[c,u]=y.useState(!1);return y.useEffect(()=>{let d=!1,h,m;return Sne().then(async f=>{if(!(d||!i.current))try{const{PlaceAutocompleteElement:x}=await f.maps.importLibrary("places");if(h=new x({}),h.style.width="100%",h.classList.add("lovable-place-autocomplete"),t&&h.setAttribute("placeholder",t),e)try{h.value=e}catch{}i.current.innerHTML="",i.current.appendChild(h),m=async g=>{const p=g==null?void 0:g.placePrediction;if(!p)return;const v=p.toPlace();await v.fetchFields({fields:["addressComponents","formattedAddress"]});const w=(v.addressComponents??[]).map(j=>({long_name:j.longText,short_name:j.shortText,types:j.types})),N=Cne(w);s(N)},h.addEventListener("gmp-select",m),l(!0)}catch(x){console.error("PlaceAutocompleteElement init failed",x),u(!0)}}).catch(f=>{console.error("Google Maps load failed",f),u(!0)}),()=>{d=!0,h&&m&&h.removeEventListener("gmp-select",m)}},[]),c?a.jsxs("div",{className:"flex gap-2",children:[a.jsx(ce,{defaultValue:e,placeholder:t||"Street address",className:"h-9 text-sm flex-1",maxLength:500,onBlur:d=>{d.target.value!==e&&r(d.target.value)}}),n&&a.jsx(vt,{className:"h-4 w-4 animate-spin self-center"})]}):a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("div",{ref:i,className:"address-autocomplete-wrapper min-h-9"}),!o&&a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Loading address suggestionsâ¦"})]}),n&&a.jsx(vt,{className:"h-4 w-4 animate-spin self-center"})]})}function sF(e){const t=(e==null?void 0:e.message)||"Something went wrong";return(e==null?void 0:e.code)==="23505"||/duplicate key value/i.test(t)?/email/i.test(t)?"Another contact already uses this email address. Open Find Duplicates to merge the two records, or change the email.":"A record with these details already exists.":t}function ps(){return Ee({queryKey:["generators"],queryFn:async()=>{const{data:e,error:t}=await F.from("generators").select("*").order("name");if(t)throw t;return e}})}const kne=["Trips","Peer Groups","Coaching","Custom"],Ene=[{value:"prospect",label:"Prospect"},{value:"contacted",label:"Contacted"},{value:"engaged",label:"Engaged"},{value:"active",label:"Active"},{value:"alumni",label:"Alumni"}];function Pne({open:e,onOpenChange:t,contact:n}){const[r,s]=y.useState(""),[i,o]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState(""),[h,m]=y.useState(""),[f,x]=y.useState(""),[g,p]=y.useState("prospect"),[v,b]=y.useState([]),[w,N]=y.useState(""),[j,_]=y.useState(""),[S,P]=y.useState(""),[k,C]=y.useState(""),[T,O]=y.useState(""),[L,E]=y.useState(""),[R,q]=y.useState(""),[I,$]=y.useState(""),[M,B]=y.useState(""),[W,A]=y.useState(""),[K,G]=y.useState(""),[H,fe]=y.useState(""),[te,J]=y.useState("person"),[re,pe]=y.useState(""),[ye,X]=y.useState(""),[he,D]=y.useState("Net 30"),[le,V]=y.useState(""),U=te==="organization",z=at(),{toast:Z}=mt(),{data:ve=[]}=ps(),{data:ee=[]}=Ee({queryKey:["contacts-list-for-referral"],queryFn:async()=>{const{data:Q,error:oe}=await F.from("contacts").select("id, name").order("name");if(oe)throw oe;return Q}});y.useEffect(()=>{n?(s(n.name),o(n.email||""),c(n.phone||""),d(n.company||""),m(n.linkedin_url||""),x(n.instagram_handle||""),p(n.status),b(n.offering_interest||[]),N(n.notes||""),_(n.generator_id||""),P(n.birthdate||""),C(n.dietary_restrictions||""),O(n.tshirt_size||""),E(n.passport_number||""),q(n.address_street||""),$(n.address_city||""),B(n.address_state||""),A(n.address_postal_code||""),G(n.address_country||""),fe(n.referred_by||""),J(n.contact_type||"person"),pe(n.billing_contact_name||""),X(n.billing_email||""),D(n.payment_terms||"Net 30"),V(n.qbo_customer_name||"")):(J("person"),pe(""),X(""),D("Net 30"),V(""),s(""),o(""),c(""),d(""),m(""),x(""),p("prospect"),b([]),N(""),_(""),fe(""),P(""),C(""),O(""),E(""),q(""),$(""),B(""),A(""),G(""))},[n,e]);const de=Me({mutationFn:async()=>
699{if(U&&(!re.trim()||!ye.trim()||!he.trim()||!le.trim()))throw new Error("Organizations need a billing contact, billing email, payment terms and QuickBooks customer name.");const Q={contact_type:te,billing_contact_name:U?re.trim():null,billing_email:U?ye.trim():null,payment_terms:U?he.trim():null,qbo_customer_name:U?le.trim():null,name:r.trim(),email:i.trim()||null,phone:l.trim()||null,company:u.trim()||null,linkedin_url:h.trim()||null,instagram_handle:f.trim()||null,status:g,offering_interest:v,notes:w.trim()||null,generator_id:j&&j!=="none"?j:null,birthdate:S||null,dietary_restrictions:k.trim()||null,tshirt_size:T.trim()||null,passport_number:L.trim()||null,address_street:R.trim()||null,address_city:I.trim()||null,address_state:M.trim()||null,address_postal_code:W.trim()||null,address_country:K.trim()||null,referred_by:H&&H!=="none"?H:null};if(n){const{error:oe}=await F.from("contacts").update(Q).eq("id",n.id);if(oe)throw oe}else{const{error:oe}=await F.from("contacts").insert(Q);if(oe)throw oe}},onSuccess:()=>{z.invalidateQueries({queryKey:["contacts"]}),z.invalidateQueries({queryKey:["experience-contacts"]}),t(!1),Z({title:n?"Contact updated":"Contact created"})},onError:Q=>{Z({title:"Error",description:sF(Q),variant:"destructive"})}}),je=Q=>{b(oe=>oe.includes(Q)?oe.filter(Pe=>Pe!==Q):[...oe,Q])};return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsx(Pt,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden p-0",children:a.jsxs("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-2rem)]",children:[a.jsx(Ot,{className:"mb-4",children:a.jsx(At,{className:"font-display text-xl",children:n?"Edit Contact":"New Contact"})}),a.jsxs("form",{onSubmit:Q=>{Q.preventDefault(),de.mutate()},className:"space-y-4",children:[a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{children:"Type"}),a.jsxs(lt,{value:te,onValueChange:J,children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"person",children:"Person"}),a.jsx(Oe,{value:"organization",children:"Organization (pays for seats; can't be a participant)"})]})]})]}),U&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Billing contact *"}),a.jsx(ce,{value:re,onChange:Q=>pe(Q.target.value),maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Billing email *"}),a.jsx(ce,{type:"email",value:ye,onChange:Q=>X(Q.target.value),maxLength:255})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Payment terms *"}),a.jsx(ce,{value:he,onChange:Q=>D(Q.target.value),placeholder:"Net 30",maxLength:30})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"QuickBooks customer name *"}),a.jsx(ce,{value:le,onChange:Q=>V(Q.target.value),maxLength:100})]})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{htmlFor:"name",children:"Name *"}),a.jsx(ce,{id:"name",value:r,onChange:Q=>s(Q.target.value),required:!0,maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs(xe,{htmlFor:"email",children:["Email ",!n&&"*"]}),a.jsx(ce,{id:"email",type:"email",value:i,onChange:Q=>o(Q.target.value),maxLength:255,required:!n&&!U})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"phone",children:"Phone"}),a.jsx(ce,{id:"phone",value:l,onChange:Q=>c(Q.target.value),maxLength:30})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"company",children:"Company"}),a.jsx(ce,{id:"company",value:u,onChange:Q=>d(Q.target.value),maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"linkedin",children:"LinkedIn URL"}),a.jsx(ce,{id:"linkedin",value:h,onChange:Q=>m(Q.target.value),placeholder:"https://linkedin.com/in/...",maxLength:200})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"instagram",children:"Instagram Handle"}),a.jsx(ce,{id:"instagram",value:f,onChange:Q=>x(Q.target.value),placeholder:"@yourhandle",maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"status",children:"Status"}),a.jsxs(lt,{value:g,onValueChange:p,children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsx(ot,{children:Ene.map(Q=>a.jsx(Oe,{value:Q.value,children:Q.label},Q.value))})]})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{children:"Generator (Owner)"}),a.jsx(Kt,{value:j,onValueChange:_,options:ve.map(Q=>({value:Q.id,label:Q.name})),placeholder:"Select generatorâ¦",allowNone:!0,className:"w-full"})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{children:"Referred By"}),a.jsx(Kt,{value:H,onValueChange:fe,options:ee.filter(Q=>Q.id!==(n==null?void 0:n.id)).map(Q=>({value:Q.id,label:Q.name})),placeholder:"Select referring contactâ¦",allowNone:!0,className:"w-full"})]})]}),a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"birthdate",children:"Birthdate"}),a.jsx(ce,{id:"birthdate",type:"date",value:S,onChange:Q=>P(Q.target.value)})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"tshirt_size",children:"T-Shirt Size"}),a.jsxs(lt,{value:T||"none",onValueChange:Q=>O(Q==="none"?"":Q),children:[a.jsx(it,{children:a.jsx(ct,{placeholder:"Select sizeâ¦"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"none",children:"â"}),["XS","S","M","L","XL","XXL","XXXL"].map(Q=>a.jsx(Oe,{value:Q,children:Q},Q))]})]})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{htmlFor:"dietary",children:"Dietary Restrictions"}),a.jsx(ce,{id:"dietary",value:k,onChange:Q=>C(Q.target.value),maxLength:500,placeholder:"e.g. Vegetarian, Gluten-free"})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{htmlFor:"passport",children:"Passport / ID Number"}),a.jsx(ce,{id:"passport",value:L,onChange:Q=>E(Q.target.value),maxLength:50})]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx(xe,{className:"text-sm font-medium",children:"Mailing Address"}),a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsxs(xe,{htmlFor:"addr-street",className:"text-xs text-muted-foreground",children:["Street Address ",a.jsx("span",{className:"text-muted-foreground
699/70",children:"(search to auto-fill all fields)"})]}),a.jsx(aF,{defaultValue:R,placeholder:"Start typing an addressâ¦",onChangeText:Q=>q(Q),onPlaceParsed:Q=>{q(Q.street),$(Q.city),B(Q.state),A(Q.postal_code),G(Q.country)}},(n==null?void 0:n.id)||"new"),a.jsx(ce,{id:"addr-street",value:R,onChange:Q=>q(Q.target.value),maxLength:200,placeholder:"Street address (manual)",className:"mt-1"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"addr-city",className:"text-xs text-muted-foreground",children:"City"}),a.jsx(ce,{id:"addr-city",value:I,onChange:Q=>$(Q.target.value),maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"addr-state",className:"text-xs text-muted-foreground",children:"State / Province"}),a.jsx(ce,{id:"addr-state",value:M,onChange:Q=>B(Q.target.value),maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"addr-postal",className:"text-xs text-muted-foreground",children:"Postal Code"}),a.jsx(ce,{id:"addr-postal",value:W,onChange:Q=>A(Q.target.value),maxLength:20})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"addr-country",className:"text-xs text-muted-foreground",children:"Country"}),a.jsx(ce,{id:"addr-country",value:K,onChange:Q=>G(Q.target.value),maxLength:100})]})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Interested In (Next)"}),a.jsx("div",{className:"flex flex-wrap gap-3",children:kne.map(Q=>a.jsxs("label",{className:"flex items-center gap-1.5 text-sm cursor-pointer",children:[a.jsx(gt,{checked:v.includes(Q),onCheckedChange:()=>je(Q)}),Q]},Q))})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"notes",children:"Notes"}),a.jsx(qt,{id:"notes",value:w,onChange:Q=>N(Q.target.value),rows:3,maxLength:2e3})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Y,{type:"button",variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),a.jsx(Y,{type:"submit",disabled:de.isPending||!r.trim()||!n&&!i.trim(),children:de.isPending?"Savingâ¦":n?"Update":"Create"})]})]})]})})})}function Gt(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Sa(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function Tr(e,t){const n=Gt(e);return isNaN(t)?Sa(e,NaN):(t&&n.setDate(n.getDate()+t),n)}function Ba(e,t){const n=Gt(e);if(isNaN(t))return Sa(e,NaN);if(!t)return n;const r=n.getDate(),s=Sa(e,n.getTime());s.setMonth(n.getMonth()+t+1,0);const i=s.getDate();return r>=i?s:(n.setFullYear(s.getFullYear(),s.getMonth(),r),n)}function One(e,t){const n=+Gt(e);return Sa(e,n+t)}const YC=6048e5,Ane=864e5,iF=6e4,QC=36e5;function Tne(e,t){return One(e,t*QC)}let Mne={};function Cp(){return Mne}function _i(e,t){var l,c,u,d;const n=Cp(),r=(t==null?void 0:t.weekStartsOn)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,s=Gt(e),i=s.getDay(),o=(i<r?7:0)+i-r;return s.setDate(s.getDate()-o),s.setHours(0,0,0,0),s}function Rc(e){return _i(e,{weekStartsOn:1})}function oF(e){const t=Gt(e),n=t.getFullYear(),r=Sa(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const s=Rc(r),i=Sa(e,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);const o=Rc(i);return t.getTime()>=s.getTime()?n+1:t.getTime()>=o.getTime()?n:n-1}function vl(e){const t=Gt(e);return t.setHours(0,0,0,0),t}function oy(e){const t=Gt(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function fi(e,t){const n=vl(e),r=vl(t),s=+n-oy(n),i=+r-oy(r);return Math.round((s-i)/Ane)}function Dne(e){const t=oF(e),n=Sa(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),Rc(n)}function td(e,t){const n=t*7;return Tr(e,n)}function $ne(e,t){return Ba(e,t*12)}function Rne(e){let t;return e.forEach(function(n){const r=Gt(n);(t===void 0||t<r||isNaN(Number(r)))&&(t=r)}),t||new Date(NaN)}function Ine(e){let t;return e.forEach(n=>{const r=Gt(n);(!t||t>r||isNaN(+r))&&(t=r)}),t||new Date(NaN)}function ya(e,t){const n=vl(e),r=vl(t);return+n==+r}function XC(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Lne(e){if(!XC(e)&&typeof e!="number")return!1;const t=Gt(e);return!isNaN(Number(t))}function xm(e,t){const n=Gt(e),r=Gt(t),s=n.getFullYear()-r.getFullYear(),i=n.getMonth()-r.getMonth();return s*12+i}function Fne(e,t,n){const r=_i(e,n),s=_i(t,n),i=+r-oy(r),o=+s-oy(s);return Math.round((i-o)/YC)}function JC(e){const t=Gt(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function ia(e){const t=Gt(e);return t.setDate(1),t.setHours(0,0,0,0),t}function lF(e){const t=Gt(e),n=Sa(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function ZC(e,t){var l,c,u,d;const n=Cp(),r=(t==null?void 0:t.weekStartsOn)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,s=Gt(e),i=s.getDay(),o=(i<r?-7:0)+6-(i-r);return s.setDate(s.getDate()+o),s.setHours(23,59,59,999),s}function cF(e){return ZC(e,{weekStartsOn:1}
vendor: 13,791 bytes, line 699
699)}const qne={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},zne=(e,t,n)=>{let r;const s=qne[e];return typeof s=="string"?r=s:t===1?r=s.one:r=s.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function kw(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Bne={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Une={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Wne={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Kne={date:kw({formats:Bne,defaultWidth:"full"}),time:kw({formats:Une,defaultWidth:"full"}),dateTime:kw({formats:Wne,defaultWidth:"full"})},Hne={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Gne=(e,t,n,r)=>Hne[e];function zh(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let s;if(r==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,l=n!=null&&n.width?String(n.width):o;s=e.formattingValues[l]||e.formattingValues[o]}else{const o=e.defaultWidth,l=n!=null&&n.width?String(n.width):e.defaultWidth;s=e.values[l]||e.values[o]}const i=e.argumentCallback?e.argumentCallback(t):t;return s[i]}}const Vne={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Yne={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Qne={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Xne={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Jne={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Zne={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ere=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},tre={ordinalNumber:ere,era:zh({values:Vne,defaultWidth:"wide"}),quarter:zh({values:Yne,defaultWidth:"wide",argumentCallback:e=>e-1}),month:zh({values:Qne,defaultWidth:"wide"}),day:zh({values:Xne,defaultWidth:"wide"}),dayPeriod:zh({values:Jne,defaultWidth:"wide",formattingValues:Zne,defaultFormattingWidth:"wide"})};function Bh(e){return(t,n={})=>{const r=n.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],i=t.match(s);if(!i)return null;const o=i[0],l=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(l)?rre(l,h=>h.test(o)):nre(l,h=>h.test(o));let u;u=e.valueCallback?e.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const d=t.slice(o.length);return{value:u,rest:d}}}function nre(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function rre(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function are(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const s=r[0],i=t.match(e.parsePattern);if(!i)return null;let o=e.valueCallback?e.valueCallback(i[0]):i[0];o=n.valueCallback?n.valueCallback(o):o;const l=t.slice(s.length);return{value:o,rest:l}}}const sre=/^(\d+)(th|st|nd|rd)?/i,ire=/\d+/i,ore={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},lre={any:[/^b/i,/^(a|c)/i]},cre={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ure={any:[/1/i,/2/i,/3/i,/4/i]},dre={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},hre={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},fre={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},mre={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},pre={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},gre={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},xre={ordinalNumber:are({matchPattern:sre,parsePattern:ire,valueCallback:e=>parseInt(e,10)}),era:Bh({matchPatterns:ore,defaultMatchWidth:"wide",parsePatterns:lre,defaultParseWidth:"any"}),quarter:Bh({matchPatterns:cre,defaultMatchWidth:"wide",parsePatterns:ure,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Bh({matchPatterns:dre,defaultMatchWidth:"wide",parsePatterns:hre,defaultParseWidth:"any"}),day:Bh({matchPatterns:fre,defaultMatchWidth:"wide",parsePatterns:mre,defaultParseWidth:"any"}),dayPeriod:Bh({matchPatterns:pre,defaultMatchWidth:"any",parsePatterns:gre,defaultParseWidth:"any"})},uF={code:"en-US",formatDistance:zne,formatLong:Kne,formatRelative:Gne,localize:tre,match:xre,options:{weekStartsOn:0,firstWeekContainsDate:1}};function yre(e){const t=Gt(e);return fi(t,lF(t))+1}function dF(e){const t=Gt(e),n=+Rc(t)-+Dne(t);return Math.round(n/YC)+1}function hF(e,t){var d,h,m,f;const n=Gt(e),r=n.getFullYear(),s=Cp(),i=(t==null?void 0:t.firstWeekContainsDate)??((h=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:h.firstWeekContainsDate)??s.firstWeekContainsDate??((f=(m=s.locale)==null?void 0:m.options)==null?void 0:f.firstWeekContainsDate)??1,o=Sa(e,0);o.setFullYear(r+1,0,i),o.setHours(0,0,0,0);const l=_i(o,t),c=Sa(e,0);c.setFullYear(r,0,i),c.setHours(0,0,0,0);const u=_i(c,t);return n.getTime()>=l.getTime()?r+1:n.getTime()>=u.getTime()?r:r-1}function vre(e,t){var l,c,u,d;const n=Cp(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,s=hF(e,t),i=Sa(e,0);return i.setFullYear(s,0,r),i.setHours(0,0,0,0),_i(i,t)}function fF(e,t){const n=Gt(e),r=+_i(n,t)-+vre(n,t);return Math.round(r/YC)+1}function cn(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Co={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return cn(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):cn(n+1,2)},d(e,t){return cn(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return cn(e.getHours()%12||12,t.length)},H(e,t){return cn(e.getHours(),t.length)},m(e,t){return cn(e.getMinutes(),t.length)},s(e,t){return cn(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),s=Math.trunc(r*Math.pow(10,n-3));return cn(s,t.length)}},fu={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},IO={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),s=r>0?r:1-r;return n.ordinalNumber(s,{unit:"year"})}return Co.y(e,t)},Y:function(e,t,n,r){const s=hF(e,r),i=s>0?s:1-s;if(t==="YY"){const o=i%100;return cn(o,2)}return t==="Yo"?n.ordinalNumber(i,{unit:"year"}):cn(i,t.length)},R:function(e,t){const n=oF(e);return cn(n,t.length)},u:function(e,t){const n=e.getFullYear();return cn(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return cn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return cn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Co.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return cn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const s=fF(e,r);return t==="wo"?n.ordinalNumber(s,{unit:"week"}):cn(s,t.length)},I:function(e,t,n){const r=dF(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):cn(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Co.d(e,t)},D:function(e,t,n){const r=yre(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):cn(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const s=e.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return cn(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(s,{width:"short",context:"formatting"});case"eeee":default:return n.day(s,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const s=e.getDay(),i=(s-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return cn(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(s,{width:"narrow",context:"standalone"});case"cccccc":return n.day(s,{width:"short",context:"standalone"});case"cccc":default:return n.day(s,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),s=r===0?7:r;switch(t){case"i":return String(s);case"ii":return cn(s,t.length);case"io":return n.ordinalNumber(s,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let s;switch(r===12?s=fu.noon:r===0?s=fu.midnight:s=r/12>
vendor: 4,717 bytes, line 699
699=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let s;switch(r>=17?s=fu.evening:r>=12?s=fu.afternoon:r>=4?s=fu.morning:s=fu.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Co.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Co.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):cn(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):cn(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Co.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Co.s(e,t)},S:function(e,t){return Co.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return FO(r);case"XXXX":case"XX":return Gl(r);case"XXXXX":case"XXX":default:return Gl(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return FO(r);case"xxxx":case"xx":return Gl(r);case"xxxxx":case"xxx":default:return Gl(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+LO(r,":");case"OOOO":default:return"GMT"+Gl(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+LO(r,":");case"zzzz":default:return"GMT"+Gl(r,":")}},t:function(e,t,n){const r=Math.trunc(e.getTime()/1e3);return cn(r,t.length)},T:function(e,t,n){const r=e.getTime();return cn(r,t.length)}};function LO(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=Math.trunc(r/60),i=r%60;return i===0?n+String(s):n+String(s)+t+cn(i,2)}function FO(e,t){return e%60===0?(e>0?"-":"+")+cn(Math.abs(e)/60,2):Gl(e,t)}function Gl(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),s=cn(Math.trunc(r/60),2),i=cn(r%60,2);return n+s+t+i}const qO=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},mF=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},bre=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],s=n[2];if(!s)return qO(e,t);let i;switch(r){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",qO(r,t)).replace("{{time}}",mF(s,t))},wre={p:mF,P:bre},_re=/^D+$/,jre=/^Y+$/,Nre=["D","DD","YY","YYYY"];function Sre(e){return _re.test(e)}function Cre(e){return jre.test(e)}function kre(e,t,n){const r=Ere(e,t,n);if(console.warn(r),Nre.includes(e))throw new RangeError(r)}function Ere(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Pre=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ore=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Are=/^'([^]*?)'?$/,Tre=/''/g,Mre=/[a-zA-Z]/;function Ye(e,t,n){var d,h,m,f,x,g,p,v;const r=Cp(),s=(n==null?void 0:n.locale)??r.locale??uF,i=(n==null?void 0:n.firstWeekContainsDate)??((h=(d=n==null?void 0:n.locale)==null?void 0:d.options)==null?void 0:h.firstWeekContainsDate)??r.firstWeekContainsDate??((f=(m=r.locale)==null?void 0:m.options)==null?void 0:f.firstWeekContainsDate)??1,o=(n==null?void 0:n.weekStartsOn)??((g=(x=n==null?void 0:n.locale)==null?void 0:x.options)==null?void 0:g.weekStartsOn)??r.weekStartsOn??((v=(p=r.locale)==null?void 0:p.options)==null?void 0:v.weekStartsOn)??0,l=Gt(e);if(!Lne(l))throw new RangeError("Invalid time value");let c=t.match(Ore).map(b=>{const w=b[0];if(w==="p"||w==="P"){const N=wre[w];return N(b,s.formatLong)}return b}).join("").match(Pre).map(b=>{if(b==="''")return{isToken:!1,value:"'"};const w=b[0];if(w==="'")return{isToken:!1,value:Dre(b)};if(IO[w])return{isToken:!0,value:b};
699if(w.match(Mre))throw new RangeError("Format string contains an unescaped latin alphabet character `"+w+"`");return{isToken:!1,value:b}});s.localize.preprocessor&&(c=s.localize.preprocessor(l,c));const u={firstWeekContainsDate:i,weekStartsOn:o,locale:s};return c.map(b=>{if(!b.isToken)return b.value;const w=b.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&Cre(w)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&Sre(w))&&kre(w,t,String(e));const N=IO[w[0]];return N(l,w,s.localize,u)}).join("")}function Dre(e){const t=e.match(Are);return t?t[1].replace(Tre,"'"):e}function zO(e){return Gt(e).getDay()}function $re(e){const t=Gt(e),n=t.getFullYear(),r=t.getMonth(),s=Sa(e,0);return s.setFullYear(n,r+1,0),s.setHours(0,0,0,0),s.getDate()}function Rre(e){return Math.trunc(+Gt(e)/1e3)}function Ire(e){const t=Gt(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(0,0,0,0),t}function Lre(e,t){return Fne(Ire(e),ia(e),t)+1}function m1(e,t){const n=Gt(e),r=Gt(t);return n.getTime()>r.getTime()}function pF(e,t){const n=Gt(e),r=Gt(t);return+n<+r}function Fre(e,t,n){const r=n==null?void 0:n.weekStartsOn,s=Gt(e),i=s.getDay(),l=(t%7+7)%7,c=7-r,u=t<0||t>6?t-(i+c)%7:(l+c)%7-(i+c)%7;return Tr(s,u)}function ek(e,t){const n=Gt(e),r=Gt(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()}function qre(e,t){const n=Gt(e),r=Gt(t);return n.getFullYear()===r.getFullYear()}function Af(e,t){return Tr(e,-t)}function zre(e,t){const r=Kre(e);let s;if(r.date){const c=Hre(r.date,2);s=Gre(c.restDateString,c.year)}if(!s||isNaN(s.getTime()))return new Date(NaN);const i=s.getTime();let o=0,l;if(r.time&&(o=Vre(r.time),isNaN(o)))return new Date(NaN);if(r.timezone){if(l=Yre(r.timezone),isNaN(l))return new Date(NaN)}else{const c=new Date(i+o),u=new Date(0);return u.setFullYear(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()),u.setHours(c.getUTCHours(),c.getUTCMinutes(),c.getUTCSeconds(),c.getUTCMilliseconds()),u}return new Date(i+o+l)}const Eg={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Bre=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Ure=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Wre=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Kre(e){const t={},n=e.split(Eg.dateTimeDelimiter);let r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],Eg.timeZoneDelimiter.test(t.date)&&(t.date=e.split(Eg.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){const s=Eg.timezone.exec(r);s?(t.time=r.replace(s[1],""),t.timezone=s[1]):t.time=r}return t}function Hre(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(n);if(!r)return{year:NaN,restDateString:""};const s=r[1]?parseInt(r[1]):null,i=r[2]?parseInt(r[2]):null;return{year:i===null?s:i*100,restDateString:e.slice((r[1]||r[2]).length)}}function Gre(e,t){if(t===null)return new Date(NaN);const n=e.match(Bre);if(!n)return new Date(NaN);const r=!!n[4],s=Uh(n[1]),i=Uh(n[2])-1,o=Uh(n[3]),l=Uh(n[4]),c=Uh(n[5])-1;if(r)return eae(t,l,c)?Qre(t,l,c):new Date(NaN);{const u=new Date(0);return!Jre(t,i,o)||!Zre(t,s)?new Date(NaN):(u.setUTCFullYear(t,i,Math.max(s,o)),u)}}function Uh(e){return e?parseInt(e):1}function Vre(e){const t=e.match(Ure);if(!t)return NaN;const n=Ew(t[1]),r=Ew(t[2]),s=Ew(t[3]);return tae(n,r,s)?n*QC+r*iF+s*1e3:NaN}function Ew(e){return e&&parseFloat(e.replace(",","."))||0}function Yre(e){if(e==="Z")return 0;const t=e.match(Wre);if(!t)return 0;const n=t[1]==="+"?-1:1,r=parseInt(t[2]),s=t[3]&&parseInt(t[3])||0;return nae(r,s)?n*(r*QC+s*iF):NaN}function Qre(e,t,n){const r=new Date(0);r.setUTCFullYear(e,0,4);const s=r.getUTCDay()||7,i=(t-1)*7+n+1-s;return r.setUTCDate(r.getUTCDate()+i),r}const Xre=[31,null,31,30,31,30,31,31,30,31,30,31];function gF(e){return e%400===0||e%4===0&&e%100!==0}function Jre(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Xre[t]||(gF(e)?29:28))}function Zre(e,t){return t>=1&&t<=(gF(e)?366:365)}function eae(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function tae(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function nae(e,t){return t>=0&&t<=59}function Pw(e,t){const n=Gt(e),r=n.getFullYear(),s=n.getDate(),i=Sa(e,0);i.setFullYear(r,t,15),i.setHours(0,0,0,0);const o=$re(i);return n.setMonth(t,Math.min(s,o)),n}function BO(e,t){const n=Gt(e);return isNaN(+n)?Sa(e,NaN):(n.setFullYear(t),n)}function rae(e,t){return Tne(e,-t)}function po(){return Ee({queryKey:["experiences"],queryFn:async()=>{const{data:e,error:t}=await F.from("experiences").select("*").order("target_start_date",{ascending:!0,nullsFirst:!1});if(t)throw t;return e}})}function go(){const{user:e}=MC();return Ee({queryKey:["current-generator",e==null?void 0:e.email],enabled:!!(e!=null&&e.email),queryFn:async()=>{const{data:t,error:n}=await F.from("generators").select("id, name, type").ilike("email",e.email).eq("active",!0).maybeSingle();if(n)throw n;return t}})}function oo(e,t){if(!t)return e;try{return`${e} (${Ye(zre(t),"MMM d, yyyy")})`}catch{return e}}const aae=[{value:"note",label:"Note"},{value:"email",label:"Email"},{value:"call",label:"Call"},{value:"meeting",label:"Meeting"},{value:"follow-up",label:"Follow-up"}];function sae({contactId:e}){const[t,n]=y.useState(!1),[r,s]=y.useState(""),[i,o]=y.useState("note"),[l,c]=y.useState(""),[u,d]=y.useState(""),[h,m]=y.useState(""),f=at(),{toast:x}=mt(),{data:g=[]}=ps(),{data:p=[]}=po(),{data:v}=go(),b=y.useMemo(()=>{const _=vl(new Date);return p.filter(S=>S.target_start_date?vl(new Date(S.target_start_date+"T00:00:00"))>=_:!0)},[p]),{data:w=[]}=Ee({queryKey:["activities",e],queryFn:async()=>{const{data:_,error:S}=await F.from("activities").select("*").eq("contact_id",e).order("due_date",{ascending:!0,nullsFirst:!1});if(S)throw S;return _}}),N=Me({mutationFn:async()=>{const{error:_}=await F.from("activities").insert({contact_id:e,description:r.trim(),type:i,due_date:l||null,generator_id:u&&u!=="none"?u:null,experience_id:h&&h!=="none"?h:null});if(_)throw _},onSuccess:()=>{f.invalidateQueries({queryKey:["activities",e]}),f.invalidateQueries({queryKey:["all-activities"]}),s(""),c(""),d((v==null?void 0:v.id)||""),m(""),n(!1),x({title:"Task created"})},onError:_=>{x({title:"Could not save task",description:(_==null?void 0:_.message)||"Unknown error",variant:"destructive"})}}),j=Me({mutationFn:async({id:_,completed:S}
699)=>{const{error:P}=await F.from("activities").update({completed:S,completed_at:S?new Date().toISOString():null}).eq("id",_);if(P)throw P},onSuccess:()=>{f.invalidateQueries({queryKey:["activities",e]})}});return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Tasks"}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{d((v==null?void 0:v.id)||""),n(!t)},children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add"]})]}),t&&a.jsxs("div",{className:"mb-3 space-y-2 rounded-md border border-border bg-background p-2",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(lt,{value:i,onValueChange:o,children:[a.jsx(it,{className:"w-28 h-8 text-xs",children:a.jsx(ct,{})}),a.jsx(ot,{children:aae.map(_=>a.jsx(Oe,{value:_.value,children:_.label},_.value))})]}),a.jsx(ce,{placeholder:"Descriptionâ¦",value:r,onChange:_=>s(_.target.value),className:"h-8 text-xs",maxLength:500})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(ce,{type:"date",value:l,onChange:_=>c(_.target.value),className:"h-8 text-xs flex-1",placeholder:"Due date"}),a.jsxs(lt,{value:u,onValueChange:d,children:[a.jsx(it,{className:"h-8 text-xs flex-1",children:a.jsx(ct,{placeholder:"Generator"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"none",children:"None"}),g.map(_=>a.jsx(Oe,{value:_.id,children:_.name},_.id))]})]}),a.jsxs(lt,{value:h,onValueChange:m,children:[a.jsx(it,{className:"h-8 text-xs flex-1",children:a.jsx(ct,{placeholder:"Experience"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"none",children:"None"}),b.map(_=>a.jsx(Oe,{value:_.id,children:oo(_.name,_.target_start_date)},_.id))]})]})]}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>n(!1),children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>N.mutate(),disabled:!r.trim(),children:"Save"})]})]}),w.length===0&&!t?a.jsx("p",{className:"text-xs text-muted-foreground",children:"No tasks recorded."}):a.jsx("div",{className:"space-y-1.5",children:w.map(_=>{const S=g.find(k=>k.id===_.generator_id),P=p.find(k=>k.id===_.experience_id);return a.jsxs("div",{className:"flex items-start gap-2 text-xs group",children:[a.jsx("button",{onClick:()=>j.mutate({id:_.id,completed:!_.completed}),className:"mt-0.5 flex-shrink-0",children:_.completed?a.jsx(Mr,{className:"h-3.5 w-3.5 text-success"}):a.jsx(T3,{className:"h-3.5 w-3.5 text-muted-foreground group-hover:text-foreground transition-colors"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:Se("text-foreground",_.completed&&"line-through text-muted-foreground"),children:_.description}),a.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground mt-0.5 flex-wrap",children:[a.jsx("span",{className:"capitalize",children:_.type}),_.due_date&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsxs("span",{children:["Due ",Ye(new Date(_.due_date+(_.due_date.length===10?"T00:00:00":"")),"MMM d")]})]}),S&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:S.name})]}),P&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:P.public_name||P.name})]}),a.jsx("span",{children:"·"}),a.jsx("span",{children:Ye(new Date(_.created_at),"MMM d")})]})]})]},_.id)})})]})}function iae({open:e,onOpenChange:t,contactId:n,source:r,destinations:s}){const[i,o]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState(""),h=at(),{toast:m}=mt(),f=Number((r==null?void 0:r.amountPaid)||0),x=Number(l),g=!!i&&x>0&&x<=f+.001,p=()=>{o(""),c(""),d("")},v=Me({mutationFn:async()=>{if(!r)throw new Error("No source record");const b=s.find($=>$.id===i);if(!b)throw new Error("Select a destination experience");const w=`Transfer ${crypto.randomUUID().slice(0,8)}`,N=u.trim()?` â ${u.trim()}`:"",{error:j}=await F.from("manual_payments").insert({contact_experience_id:r.id,amount:-x,payment_method:"transfer",note:`${w}: moved to ${b.experienceName}${N}`});if(j)throw j;const{error:_}=await F.from("manual_payments").insert({contact_experience_id:b.id,amount:x,payment_method:"transfer",note:`${w}: moved from ${r.experienceName}${N}`});if(_)throw _;const S=Math.max(0,Number((f-x).toFixed(2))),P={amount_paid:S};S===0&&(P.deposit_paid=!1,P.price_paid=!1);const{error:k}=await F.from("contact_experiences").update(P).eq("id",r.id);if(k)throw k;const{data:C,error:T}=await F.from("contact_experiences").select("amount_paid, custom_price, deposit_paid, price_paid, experiences(price, deposit)").eq("id",b.id).single();if(T)throw T;const O=Number((Number((C==null?void 0:C.amount_paid)||0)+x).toFixed(2)),L=C==null?void 0:C.experiences,E=Number((C==null?void 0:C.custom_price)??(L==null?void 0:L.price)??0),R=Number((L==null?void 0:L.deposit)??0),q={amount_paid:O};R>0&&O>=R-.001&&(q.deposit_paid=!0),E>0&&O>=E-.001&&(q.price_paid=!0,q.deposit_paid=!0);const{error:I}=await F.from("contact_experiences").update(q).eq("id",b.id);if(I)throw I;return b.experienceName},onSuccess:b=>{h.invalidateQueries({queryKey:["contact-experiences",n]}),h.invalidateQueries({queryKey:["manual-payments"]}),h.invalidateQueries({queryKey:["stripe-payments"]}
699),m({title:`Transferred $${x.toLocaleString()} to ${b}`}),p(),t(!1)},onError:b=>m({title:"Transfer failed",description:b.message,variant:"destructive"})});return a.jsx(Dt,{open:e,onOpenChange:b=>{b||p(),t(b)},children:a.jsxs(Pt,{className:"max-w-md",children:[a.jsxs(Ot,{children:[a.jsx(At,{children:"Transfer payment"}),a.jsxs(wr,{children:["Move paid dollars from ",(r==null?void 0:r.experienceName)??"this experience"," to another of this contact's experiences. Both sides are logged in payment history."]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"rounded-md border border-border bg-muted/40 p-2 text-xs text-muted-foreground",children:["Available to transfer:"," ",a.jsxs("span",{className:"font-medium text-foreground",children:["$",f.toLocaleString()]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{className:"text-xs",children:"Transfer to"}),a.jsx(Kt,{value:i,onValueChange:o,options:s.map(b=>({value:b.id,label:b.experienceName})),placeholder:s.length?"Select experienceâ¦":"No other experiences",className:"h-9 text-sm"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{className:"text-xs",children:"Amount"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"$"}),a.jsx(ce,{type:"text",inputMode:"decimal",placeholder:"0.00",value:l,onChange:b=>c(b.target.value.replace(/[^0-9.]/g,"")),className:"h-9 text-sm pl-5"})]}),x>f&&a.jsx("p",{className:"text-[11px] text-destructive",children:"Amount exceeds what's paid on this record."})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{className:"text-xs",children:"Note (optional)"}),a.jsx(qt,{value:u,onChange:b=>d(b.target.value),placeholder:"Reason for the transferâ¦",className:"text-sm min-h-[60px]"})]})]}),a.jsxs(br,{children:[a.jsx(Y,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),a.jsx(Y,{disabled:!g||v.isPending,onClick:()=>v.mutate(),children:v.isPending?"Transferringâ¦":"Transfer"})]})]})})}async function ly(e){if(!e)return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="-1000px",t.style.opacity="0",document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}const UO=[{value:"candidate",label:"Candidate"},{value:"expressed_interest",label:"Expressed Interest"},{value:"invited",label:"Invited"},{value:"considering",label:"Considering"},{value:"accepted",label:"Accepted"},{value:"declined",label:"Declined"},{value:"dropped",label:"Dropped"},{value:"future",label:"Future"},{value:"waitlist",label:"Waitlist"}];function oae({contactId:e,contactName:t}){const[n,r]=y.useState(!1),[s,i]=y.useState(""),[o,l]=y.useState("candidate"),[c,u]=y.useState(null),[d,h]=y.useState(""),[m,f]=y.useState(!1),[x,g]=y.useState(!1),[p,v]=y.useState(null),[b,w]=y.useState(null),N=at(),{data:j=[]}=po(),{toast:_}=mt(),{data:S=[]}=Ee({queryKey:["contact-experiences",e],queryFn:async()=>{const{data:E,error:R}=await F.from("contact_experiences").select("*, experiences(name, public_name, type, project_manager_id)").eq("contact_id",e);if(R)throw R;return E}}),P=Me({mutationFn:async()=>{const{error:E}=await F.from("contact_experiences").insert({contact_id:e,experience_id:s,status:o});if(E)throw E},onSuccess:()=>{N.invalidateQueries({queryKey:["contact-experiences",e]}),r(!1),i(""),l("candidate")}}),k=Me({mutationFn:async E=>{await F.from("manual_payments").delete().eq("contact_experience_id",E),await F.from("contact_experience_addons").delete().eq("contact_experience_id",E),await F.from("survey_responses").delete().eq("contact_experience_id",E),await F.from("activity_responses").delete().eq("contact_experience_id",E);const{error:R}=await F.from("contact_experiences").delete().eq("id",E);if(R)throw R},onSuccess:()=>{N.invalidateQueries({queryKey:["contact-experiences",e]}),N.invalidateQueries({queryKey:["experience-status-counts"]}),_({title:"Removed from experience"})},onError:E=>_({title:"Error",description:E.message,variant:"destructive"})}),C=Me({mutationFn:async({id:E,status:R})=>{const{error:q}=await F.from("contact_experiences").update({status:R}).eq("id",E);if(q)throw q},onSuccess:()=>{N.invalidateQueries({queryKey:["contact-experiences",e]})}}),T=Me({mutationFn:async({ceId:E,amount:R,depositPaid:q,pricePaid:I,currentAmountPaid:$})=>{const M=Math.max(0,Number(($+R).toFixed(2))),B={amount_paid:M};q&&(B.deposit_paid=!0),I&&(B.price_paid=!0),R<0&&M===0?(B.deposit_paid=!1,B.price_paid=!1):R<0&&(B.price_paid=!1);const{error:W}=await F.from("contact_experiences").update(B).eq("id",E);if(W)throw W;if(R!==0){const{error:A}=await F.from("manual_payments").insert({contact_experience_id:E,amount:R,payment_method:R<0?"refund":null,note:R<0?"Refund":null});if(A)throw A}},onSuccess:()=>{N.invalidateQueries({queryKey:["contact-experiences",e]}),N.invalidateQueries({queryKey:["stripe-payments"]}),N.invalidateQueries({queryKey:["manual-payments"]}),u(null),h(""),f(!1),g(!1),_({title:"Payment recorded"})},onError:E=>_({title:"Error",description:E.message,variant:"destructive"})}),O=S.map(E=>E.experience_id),L=j.filter(E=>!O.includes(E.id));return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Experiences"}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>r(!n),children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add"]})]}),n&&L.length>0&&a.jsxs("div",{className:"mb-3 space-y-2 rounded-md border border-border bg-background p-2",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Kt,{value:s,onValueChange:i,options:L.map(E=>({value:E.id,label:oo(E.name,E.target_start_date)})),placeholder:"Select experienceâ¦",className:"h-8 text-xs flex-1"}),a.jsxs(lt,{value:o,onValueChange:l,children:[a.jsx(it,{className:"w-28 h-8 text-xs",children:a.jsx(ct,{})}),a.jsx(ot,{children:UO.map(E=>a.jsx(Oe,{value:E.value,children:E.label},E.value))})]})]}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>r(!1),children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>P.mutate(),disabled:!s,children:"Save"})]})]}),S.length===0&&!n?a.jsx("p",{className:"text-xs text-muted-foreground",children:"No experiences assigned."}):a.jsx("div",{className:"space-y-1.5",children:S.map(E=>{var R,q;return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs group",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"text-foreground truncate",children:((R=E.experiences)==null?void 0:R.public_name)||((q=E.experiences)==null?void 0:q.name)}
699),a.jsxs(lt,{value:E.status,onValueChange:I=>C.mutate({id:E.id,status:I}),children:[a.jsx(it,{className:"h-5 w-24 text-[10px] border-0 bg-transparent p-0",children:a.jsx(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0 capitalize cursor-pointer",children:E.status})}),a.jsx(ot,{children:UO.map(I=>a.jsx(Oe,{value:I.value,children:I.label},I.value))})]})]}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("button",{onClick:async()=>{if(!E.public_token){_({title:"No personalized link yet",description:"This record has no link token.",variant:"destructive"});return}const I=`${window.location.origin}/experience?token=${E.public_token}`,$=await ly(I);_($?{title:"Payment link copied to clipboard"}:{title:"Copy blocked by browser",description:I})},title:"Copy payment link",children:a.jsx(Nl,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})}),a.jsx("button",{onClick:()=>{c===E.id?u(null):(u(E.id),h(""),f(!1),g(!1))},title:"Record manual payment",children:a.jsx(Hi,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})}),Number(E.amount_paid||0)>0&&S.length>1&&a.jsx("button",{onClick:()=>w(E.id),title:"Transfer payment to another experience",children:a.jsx(GK,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})}),!E.deposit_paid&&a.jsx("button",{onClick:async()=>{try{const{data:I,error:$}=await F.functions.invoke("create-experience-payment",{body:{token:E.public_token,payment_type:"deposit"}});if($)throw $;I!=null&&I.url&&(navigator.clipboard.writeText(I.url),_({title:"Deposit payment link copied"}))}catch(I){_({title:"Error",description:I.message,variant:"destructive"})}},title:"Generate deposit payment link",children:a.jsx(pa,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})}),p===E.id?a.jsxs("div",{className:"flex items-center gap-0.5",children:[a.jsx("span",{className:"text-[10px] text-destructive font-medium whitespace-nowrap",children:Number(E.amount_paid||0)>0?`Remove? ($${Number(E.amount_paid).toLocaleString()} paid)`:"Remove?"}),a.jsx("button",{onClick:()=>{k.mutate(E.id),v(null)},children:a.jsx(On,{className:"h-3 w-3 text-destructive"})}),a.jsx("button",{onClick:()=>v(null),children:a.jsx(Ht,{className:"h-3 w-3 text-muted-foreground"})})]}):a.jsx("button",{onClick:()=>v(E.id),className:"opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(Ht,{className:"h-3 w-3 text-muted-foreground hover:text-destructive"})})]})]}),c===E.id&&a.jsxs("div",{className:"mt-1.5 mb-1 rounded-md border border-border bg-background p-2 space-y-2",children:[a.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:"Record Manual Payment or Refund"}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:"$"}),a.jsx(ce,{type:"number",step:"0.01",placeholder:"0.00 (use a negative amount for a refund)",value:d,onChange:I=>h(I.target.value),className:"h-7 text-xs pl-5"})]})}),a.jsxs("div",{className:"flex flex-col gap-1.5",children:[!E.deposit_paid&&a.jsxs("label",{className:"flex items-center gap-2 text-xs text-foreground cursor-pointer",children:[a.jsx(gt,{checked:m,onCheckedChange:I=>f(!!I),className:"h-3.5 w-3.5"}),"Mark deposit as paid"]}),!E.price_paid&&a.jsxs("label",{className:"flex items-center gap-2 text-xs text-foreground cursor-pointer",children:[a.jsx(gt,{checked:x,onCheckedChange:I=>g(!!I),className:"h-3.5 w-3.5"}),"Mark paid in full"]})]}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>u(null),children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",disabled:(!d||Number(d)===0||Number.isNaN(Number(d)))&&!m&&!x,onClick:()=>T.mutate({ceId:E.id,amount:Number(d)||0,depositPaid:m,pricePaid:x,currentAmountPaid:Number(E.amount_paid)||0}),children:"Record"})]})]})]},E.id)})}),a.jsx(iae,{open:!!b,onOpenChange:E=>!E&&w(null),contactId:e,source:(()=>{var R,q;
699const E=S.find(I=>I.id===b);return E?{id:E.id,experienceName:((R=E.experiences)==null?void 0:R.public_name)||((q=E.experiences)==null?void 0:q.name)||"this experience",amountPaid:Number(E.amount_paid||0)}:null})(),destinations:S.filter(E=>E.id!==b).map(E=>{var R,q;return{id:E.id,experienceName:((R=E.experiences)==null?void 0:R.public_name)||((q=E.experiences)==null?void 0:q.name)||"Experience"}})})]})}function xF({email:e,contactId:t}){const n=at(),{toast:r}=mt(),[s,i]=y.useState(null),[o,l]=y.useState(""),[c,u]=y.useState(""),[d,h]=y.useState(""),[m,f]=y.useState(""),{data:x=[],isLoading:g}=Ee({queryKey:["stripe-payments",e],enabled:!!e,queryFn:async()=>{const{data:_,error:S}=await F.functions.invoke("stripe-payment-history",{body:{email:e}});if(S)throw S;return(_==null?void 0:_.payments)||[]}}),{data:p=[],isLoading:v}=Ee({queryKey:["manual-payments",t],enabled:!!t,queryFn:async()=>{const{data:_,error:S}=await F.from("contact_experiences").select("id").eq("contact_id",t);if(S)throw S;if(!_||_.length===0)return[];const P=_.map(T=>T.id),{data:k,error:C}=await F.from("manual_payments").select("id, contact_experience_id, amount, note, payment_method, recorded_at, contact_experiences(experience_id, experiences(name, public_name))").in("contact_experience_id",P).order("recorded_at",{ascending:!1});if(C)throw C;return k||[]}}),b=Me({mutationFn:async({id:_,amount:S,note:P,recordedAt:k,paymentMethod:C})=>{const T=p.find(E=>E.id===_);if(!T)throw new Error("Payment not found");const O=S-Number(T.amount),{error:L}=await F.from("manual_payments").update({amount:S,note:P||null,payment_method:C||null,recorded_at:k?new Date(k+"T12:00:00").toISOString():void 0}).eq("id",_);if(L)throw L;if(O!==0){const{data:E,error:R}=await F.from("contact_experiences").select("amount_paid").eq("id",T.contact_experience_id).single();if(R)throw R;const{error:q}=await F.from("contact_experiences").update({amount_paid:Number(E.amount_paid)+O}).eq("id",T.contact_experience_id);if(q)throw q}},onSuccess:()=>{n.invalidateQueries({queryKey:["manual-payments",t]}),n.invalidateQueries({queryKey:["contact-experiences"]}),i(null),r({title:"Payment updated"})},onError:_=>r({title:"Error",description:_.message,variant:"destructive"})}),w=Me({mutationFn:async _=>{const{data:S,error:P}=await F.from("contact_experiences").select("amount_paid").eq("id",_.contact_experience_id).single();if(P)throw P;const{error:k}=await F.from("contact_experiences").update({amount_paid:Math.max(0,Number(S.amount_paid)-Number(_.amount))}).eq("id",_.contact_experience_id);if(k)throw k;const{error:C}=await F.from("manual_payments").delete().eq("id",_.id);if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["manual-payments",t]}),n.invalidateQueries({queryKey:["contact-experiences"]}),r({title:"Payment deleted"})},onError:_=>r({title:"Error",description:_.message,variant:"destructive"})});if(!e&&!t)return null;const N=g||v,j=x.length>0||p.length>0;return a.jsxs("div",{children:[a.jsxs("h4",{className:"text-sm font-medium text-foreground mb-2 flex items-center gap-1.5",children:[a.jsx(pa,{className:"h-3.5 w-3.5"})," Experience Payment History"]}),N?a.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-2",children:[a.jsx(vt,{className:"h-3.5 w-3.5 animate-spin"})," Loading paymentsâ¦"]}):j?a.jsxs("div",{className:"space-y-2",children:[p.map(_=>{var S,P;return a.jsx("div",{className:"flex items-center justify-between text-xs rounded-md border border-border bg-background px-3 py-2",children:s===_.id?a.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full",children:[a.jsxs("div",{className:"relative w-20",children:[a.jsx("span",{className:"absolute left-1.5 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:"$"}),a.jsx(ce,{type:"text",inputMode:"decimal",value:o,onChange:k=>l(k.target.value),className:"h-6 text-[10px] pl-4 pr-1"})]}),a.jsxs("select",{value:m,onChange:k=>f(k.target.value),className:"h-6 text-[10px] rounded-md border border-input bg-background px-1.5",children:[a.jsx("option",{value:"",children:"Methodâ¦"}),a.jsx("option",{value:"Stripe",children:"Stripe"}),a.jsx("option",{value:"Check",children:"Check"}),a.jsx("option",{value:"Other",children:"Other"})]}),a.jsx(ce,{type:"text",value:c,onChange:k=>u(k.target.value),placeholder:"Noteâ¦",className:"h-6 text-[10px] flex-1 min-w-[60px]"}),a.jsx(ce,{type:"date",value:d,onChange:k=>h(k.target.value),className:"h-6 text-[10px] w-[110px]"}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>b.mutate({id:_.id,amount:Number(o)||0,note:c,recordedAt:d,paymentMethod:m}),disabled:b.isPending,children:a.jsx(On,{className:"h-3 w-3 text-emerald-600"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>i(null),children:a.jsx(Ht,{className:"h-3 w-3"})})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("span",{className:"font-medium text-foreground",children:["$",Number(_.amount).toLocaleStr
699ing(void 0,{minimumFractionDigits:2})]}),a.jsx(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:_.payment_method||"Manual"}),((P=(S=_.contact_experiences)==null?void 0:S.experiences)==null?void 0:P.name)&&a.jsx("span",{className:"text-muted-foreground truncate text-[10px]",children:_.contact_experiences.experiences.public_name||_.contact_experiences.experiences.name}),_.note&&a.jsx("span",{className:"text-muted-foreground truncate text-[10px] italic",children:_.note}),a.jsxs("span",{className:"text-muted-foreground flex items-center gap-0.5",children:[a.jsx(Kx,{className:"h-2.5 w-2.5"}),Ye(new Date(_.recorded_at),"MMM d, yyyy")]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Ge,{className:"bg-emerald-100 text-emerald-800 border-0 text-[10px] px-1.5 py-0",children:"Paid"}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{i(_.id),l(String(_.amount)),u(_.note||""),h(Ye(new Date(_.recorded_at),"yyyy-MM-dd")),f(_.payment_method||"")},children:a.jsx(Rn,{className:"h-3 w-3 text-muted-foreground"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>w.mutate(_),disabled:w.isPending,children:a.jsx(pn,{className:"h-3 w-3 text-destructive"})})]})]})},`manual-${_.id}`)}),x.map(_=>a.jsxs("div",{className:"flex items-center justify-between text-xs rounded-md border border-border bg-background px-3 py-2",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("span",{className:"font-medium text-foreground",children:["$",_.amount.toLocaleString(void 0,{minimumFractionDigits:2})]}),a.jsx(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Stripe"}),_.payment_type&&a.jsx("span",{className:"text-muted-foreground truncate text-[10px] capitalize",children:_.payment_type}),a.jsxs("span",{className:"text-muted-foreground flex items-center gap-0.5",children:[a.jsx(Kx,{className:"h-2.5 w-2.5"}),Ye(new Date(_.created*1e3),"MMM d, yyyy")]})]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(Ge,{className:"bg-emerald-100 text-emerald-800 border-0 text-[10px] px-1.5 py-0",children:"Paid"}),_.receipt_url&&a.jsx("a",{href:_.receipt_url,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-primary transition-colors",title:"View receipt",children:a.jsx(M3,{className:"h-3 w-3"})})]})]},_.id))]}):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No payments found."})]})}function lae({contactId:e}){var d;const{data:t=[]}=Ee({queryKey:["contact-completed-experiences",e],queryFn:async()=>{const h=new Date().toISOString().slice(0,10),{data:m,error:f}=await F.from("contact_experiences").select("experience_id, experiences(name, public_name, type, status, target_start_date)").eq("contact_id",e).eq("status","accepted");if(f)throw f;return(m||[]).filter(x=>{var g;return((g=x.experiences)==null?void 0:g.target_start_date)&&x.experiences.target_start_date<h})}}),{data:n=[]}=Ee({queryKey:["contact-upcoming-experiences",e],queryFn:async()=>{const h=new Date().toISOString().slice(0,10),{data:m,error:f}=await F.from("contact_experiences").select("experience_id, status, experiences(name, public_name, type, status, target_start_date)").eq("contact_id",e).in("status",["candidate","expressed_interest","invited","considering","accepted","gen_guide"]);if(f)throw f;return(m||[]).filter(x=>{var g;return!(((g=x.experiences)==null?void 0:g.status)!=="active"||x.experiences.target_start_date&&x.experiences.target_start_date<h)})}}),{data:r=[]}=Ee({queryKey:["contact-coaching",e],queryFn:async()=>{const{data:h,error:m}=await F.from("contact_coaching").select("*, generators(name)").eq("contact_id",e).order("start_date",{ascending:!1});if(m)throw m;return h}}),s={};for(const h of t){const m=((d=h.experiences)==null?void 0:d.type)||"other";s[m]=(s[m]||0)+1}const i={trip:"Trip",peer_group:"Peer Group",coaching:"Coaching",other:"Other"},o=Object.keys(s).length>0,l=n.length>0,c=r.length>0,u=r.find(h=>!h.end_date);return!o&&!l&&!c?null:a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Experience Summary"}),o&&a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(Mr,{className:"h-3.5 w-3.5 text-success mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex flex-wrap gap-1 text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:"Completed:"}),Object.entries(s).map(([h,m])=>a.jsxs(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0 bg-success/10 text-success border-success/20",children:[m," ",i[h]||h,m>1?"s":""]},h))]})]}),c&&a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(sC,{className:"h-3.5 w-3.5 text-primary mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-xs space-y-0.5",children:[a.jsx("span",{className:"text-muted-foreground",children:"Coaching:"}),u?a.jsxs(Ge,{variant:"outline",className:"ml-1 text-[10px] px-1.5 py-0 bg-primary/10 text-primary border-primary/20",children:["Active",u.generators?` with ${u.generators.name}`:""]}):a.jsxs(Ge,{variant:"outline",className:"ml-1 text-[10px] px-1.5 py-0 bg-muted text-muted-foreground border-border",children:[r.length," past session",r.length>
6991?"s":""]})]})]}),l&&a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(pl,{className:"h-3.5 w-3.5 text-accent mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"flex flex-wrap gap-1 text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:"Upcoming:"}),n.map((h,m)=>{var x,g;const f={accepted:"bg-success/10 text-success border-success/20",considering:"bg-warning/10 text-warning border-warning/20",candidate:"bg-muted text-muted-foreground border-border",expressed_interest:"bg-sky-100 text-sky-800 dark:bg-sky-900 dark:text-sky-200 border-sky-300 dark:border-sky-700",invited:"bg-muted text-muted-foreground border-border",gen_guide:"bg-violet-100 text-violet-800 dark:bg-violet-900 dark:text-violet-200 border-violet-300 dark:border-violet-700"};return a.jsxs(Ge,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${f[h.status]||""}`,children:[((x=h.experiences)==null?void 0:x.public_name)||((g=h.experiences)==null?void 0:g.name)," (",h.status,")"]},m)})]})]})]})}function cae({contactId:e}){const{data:t=[]}=ps(),n=at(),{toast:r}=mt(),[s,i]=y.useState(!1),[o,l]=y.useState(null),[c,u]=y.useState(""),[d,h]=y.useState(""),[m,f]=y.useState(""),[x,g]=y.useState(""),[p,v]=y.useState(""),[b,w]=y.useState(""),[N,j]=y.useState("monthly"),[_,S]=y.useState(""),[P,k]=y.useState("recurring"),[C,T]=y.useState([]),[O,L]=y.useState(null),[E,R]=y.useState(""),[q,I]=y.useState(!1),{data:$=[]}=Ee({queryKey:["contact-coaching",e],queryFn:async()=>{const{data:G,error:H}=await F.from("contact_coaching").select("*, generators(name)").eq("contact_id",e).order("start_date",{ascending:!1});if(H)throw H;return G}}),M=Me({mutationFn:async()=>{const G={contact_id:e,start_date:c,end_date:d||null,generator_id:m&&m!=="none"?m:null,notes:x.trim()||null,price:p?Number(p):null,schedule_type:P,payment_count:P==="recurring"&&b?Number(b):null,payment_frequency:P==="recurring"&&b&&Number(b)>=2?N:null,price_due_date:P==="recurring"&&_||null,fixed_payments:P==="fixed"?C.filter(H=>H.date&&H.amount).map(H=>({date:H.date,amount:Number(H.amount)})):[]};if(o){const{error:H}=await F.from("contact_coaching").update(G).eq("id",o);if(H)throw H}else{const{error:H}=await F.from("contact_coaching").insert(G);if(H)throw H}},onSuccess:()=>{n.invalidateQueries({queryKey:["contact-coaching",e]}),A(),r({title:o?"Coaching updated":"Coaching added"})},onError:G=>r({title:"Error",description:G.message,variant:"destructive"})}),B=Me({mutationFn:async G=>{const{error:H}=await F.from("contact_coaching").delete().eq("id",G);if(H)throw H},onSuccess:()=>{n.invalidateQueries({queryKey:["contact-coaching",e]}),r({title:"Coaching record deleted"})}}),W=Me({mutationFn:async({ccId:G,amount:H,pricePaid:fe,currentAmountPaid:te})=>{const J={amount_paid:te+H};fe&&(J.price_paid=!0);const{error:re}=await F.from("contact_coaching").update(J).eq("id",G);if(re)throw re},onSuccess:()=>{n.invalidateQueries({queryKey:["contact-coaching",e]}),L(null),R(""),I(!1),r({title:"Payment recorded"})},onError:G=>r({title:"Error",description:G.message,variant:"destructive"})}),A=()=>{i(!1),l(null),u(""),h(""),f(""),g(""),v(""),w(""),j("monthly"),S(""),k("recurring"),T([])},K=G=>{l(G.id),u(G.start_date),h(G.end_date||""),f(G.generator_id||""),g(G.notes||""),v(G.price!=null?String(G.price):""),k(G.schedule_type||"recurring"),w(G.payment_count!=null?String(G.payment_count):""),j(G.payment_frequency||"monthly"),S(G.price_due_date||"");const H=G.fixed_payments||[];T(H.map(fe=>({date:fe.date||"",amount:String(fe.amount||"")}))),i(!0)};return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Coaching"}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{A(),i(!s)},children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add"]})]}),s&&a.jsxs("div",{className:"mb-3 space-y-2 rounded-md border border-border bg-background p-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Start Date *"}),a.jsx(ce,{type:"date",value:c,onChange:G=>u(G.target.value),className:"h-7 text-xs"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"End Date"}),a.jsx(ce,{type:"date",value:d,onChange:G=>h(G.target.value),className:"h-7 text-xs"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Coach"}),a.jsx(Kt,{value:m,onValueChange:f,options:t.map(G=>({value:G.id,label:G.name})),placeholder:"Select coachâ¦",allowNone:!0,className:"h-7 text-xs"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Comments"}),a.jsx(ce,{value:x,onChange:G=>g(G.target.value),className:"h-7 text-xs",placeholder:"Optional commentsâ¦"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Total Amount"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:"$"}),a.jsx(ce,{type:"number",min:"0",step:"0.01",value:p,onChange:G=>v(G.target.value),className:"h-7 text-xs pl-5",placeholder:"0.00"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Schedule Type"}),a.jsxs(lt,{value:P,onValueChange:G=>k(G),children:[a.jsx(it,{className:"h-7 text-xs",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"recurring",children:"Recurring"}),a.jsx(Oe,{value:"fixed",children:"Fixed Dates"})]})]})]})]}),P==="recurring"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Payment Count"}),a.jsx(ce,{type:"number",min:"0",value:b,onChange:G=>w(G.target.value),className:"h-7 text-xs",placeholder:"e.g. 4"})]}),b&&Number(b)>=2&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Frequency"}),a.jsxs(lt,{value:N,onValueChange:j,children:[a.jsx(it,{className:"h-7 text-xs",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"monthly",children:"Monthly"}),a.jsx(Oe,{value:"quarterly",children:"Quarterly"})]})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:b&&Number(b)>=2?"First Payment Due":"Due Date"}
699),a.jsx(ce,{type:"date",value:_,onChange:G=>S(G.target.value),className:"h-7 text-xs"})]})]}),P==="fixed"&&a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Fixed Payments"}),C.map((G,H)=>a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(ce,{type:"date",value:G.date,onChange:fe=>{const te=[...C];te[H]={...te[H],date:fe.target.value},T(te)},className:"h-7 text-xs flex-1"}),a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:"$"}),a.jsx(ce,{type:"number",min:"0",step:"0.01",value:G.amount,onChange:fe=>{const te=[...C];te[H]={...te[H],amount:fe.target.value},T(te)},className:"h-7 text-xs pl-5",placeholder:"0.00"})]}),a.jsx(Y,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>T(C.filter((fe,te)=>te!==H)),children:a.jsx(pn,{className:"h-3 w-3"})})]},H)),a.jsxs(Y,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>T([...C,{date:"",amount:""}]),children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add Payment"]})]}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:A,children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>M.mutate(),disabled:!c||M.isPending,children:o?"Update":"Save"})]})]}),$.length===0&&!s?a.jsx("p",{className:"text-xs text-muted-foreground",children:"No coaching history."}):a.jsx("div",{className:"space-y-1.5",children:$.map(G=>a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs group",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(sC,{className:"h-3 w-3 text-primary flex-shrink-0"}),a.jsxs("span",{className:"text-foreground",children:[Ye(new Date(G.start_date+"T00:00:00"),"MMM yyyy"),G.end_date?` â ${Ye(new Date(G.end_date+"T00:00:00"),"MMM yyyy")}`:" â Present"]}),G.generators&&a.jsxs("span",{className:"text-muted-foreground",children:["· ",G.generators.name]}),!G.end_date&&a.jsx(Ge,{variant:"outline",className:"text-[10px] px-1 py-0 bg-primary/10 text-primary border-primary/20",children:"Active"}),G.price!=null&&a.jsxs("span",{className:"text-muted-foreground",children:["· $",Number(G.price).toLocaleString()]}),G.amount_paid>0&&a.jsxs("span",{className:"text-muted-foreground",children:["($",Number(G.amount_paid).toLocaleString()," paid)"]})]}),a.jsxs("div",{className:"flex items-center gap-0.5",children:[G.price!=null&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>{const H=`${window.location.origin}/public-coaching?token=${G.public_token}`;navigator.clipboard.writeText(H),r({title:"Coaching link copied to clipboard"})},title:"Copy coaching link",children:a.jsx(Nl,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})}),a.jsx("button",{onClick:()=>{O===G.id?L(null):(L(G.id),R(""),I(!1))},title:"Record manual payment",children:a.jsx(Hi,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})]}),a.jsx("button",{onClick:()=>K(G),className:"opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(Rn,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})}),a.jsx("button",{onClick:()=>B.mutate(G.id),className:"opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(pn,{className:"h-3 w-3 text-muted-foreground hover:text-destructive"})})]})]}),O===G.id&&a.jsxs("div",{className:"mt-1.5 mb-1 rounded-md border border-border bg-background p-2 space-y-2",children:[a.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:"Record Manual Payment"}),a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:"$"}),a.jsx(ce,{type:"number",min:"0",step:"0.01",placeholder:"0.00",value:E,onChange:H=>R(H.target.value),className:"h-7 text-xs pl-5"})]})}),a.jsx("div",{className:"flex flex-col gap-1.5",children:!G.price_paid&&a.jsxs("label",{className:"flex items-center gap-2 text-xs text-foreground cursor-pointer",children:[a.jsx(gt,{checked:q,onCheckedChange:H=>I(!!H),className:"h-3.5 w-3.5"}),"Mark paid in full"]})}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>L(null),children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",disabled:(!E||Number(E)<=0)&&!q,onClick:()=>W.mutate({ccId:G.id,amount:Number(E)||0,pricePaid:q,currentAmountPaid:Number(G.amount_paid)||0}),children:"Record"})]})]})]},G.id))})]})}const p1=["accepted","active","completed"],uae={trip:"Trip",peer_group:"Peer Group",coaching:"Coaching",stakeholder_summit:"Summit"},dae={invited:"Invited",accepted:"Accepted",declined:"Declined",waitlist:"Waitlist",considering:"Considering",expressed_interest:"Interested",candidate:"Candidate",dropped:"Dropped",future:"Future",active:"Active",completed:"Completed",cancelled:"Cancelled"},Fs=e=>
699e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0});function hae(){const{data:e}=Qs(),{data:t}=go();return!!(e||(t==null?void 0:t.type)==="employee")}const fae="id, contact_id, referred_by, status, custom_price, amount_paid, accepted_at, created_at, contacts:contacts!contact_experiences_contact_id_fkey(name), experiences!contact_experiences_experience_id_fkey(id, name, public_name, type, price)",mae="id, contact_id, referred_by, status, price, amount_paid, start_date, created_at, contacts!contact_coaching_contact_id_fkey(name), generators!contact_coaching_generator_id_fkey(name)";async function g1(e,t){if(t&&t.length===0)return[];const n=F,r=async(o,l)=>{const c=[],u=t?Array.from({length:Math.ceil(t.length/200)},(d,h)=>t.slice(h*200,h*200+200)):[null];for(const d of u)for(let h=0;;h+=1e3){let m=n.from(o).select(l).range(h,h+999);m=d?m.in(e,d):m.not(e,"is",null);const{data:f,error:x}=await m;if(x)throw x;if(c.push(...f??[]),!f||f.length<1e3)break}return c},[s,i]=await Promise.all([r("contact_experiences",fae),r("contact_coaching",mae)]);return[...s.filter(o=>o.status!=="gen_guide").map(o=>{var l,c,u,d,h,m;return{key:o.id,referrerId:o.referred_by,personId:o.contact_id,person:((l=o.contacts)==null?void 0:l.name)??"Unknown",booked:((c=o.experiences)==null?void 0:c.public_name)||((u=o.experiences)==null?void 0:u.name)||"â",bookedId:((d=o.experiences)==null?void 0:d.id)??null,kind:((h=o.experiences)==null?void 0:h.type)??"",status:o.status,bookingDate:o.accepted_at||o.created_at,value:Number(o.custom_price??((m=o.experiences)==null?void 0:m.price)??0),paid:Number(o.amount_paid??0)}}),...i.map(o=>{var l,c;return{key:o.id,referrerId:o.referred_by,personId:o.contact_id,person:((l=o.contacts)==null?void 0:l.name)??"Unknown",booked:`Coaching${(c=o.generators)!=null&&c.name?` with ${o.generators.name}`:""}`,bookedId:null,kind:"coaching",status:o.status,bookingDate:o.start_date||o.created_at,value:Number(o.price??0),paid:Number(o.amount_paid??0)}})].sort((o,l)=>String(o.bookingDate??"").localeCompare(String(l.bookingDate??"")))}const yF=e=>e.kind!=="stakeholder_summit";async function pae(e,t){const n=(await g1("referred_by",e)).filter(yF),r=(t==null?void 0:t.slice(0,10))??"",s=new Set;return n.filter(i=>String(i.bookingDate??"").slice(0,10)<r||s.has(i.personId)?!1:(s.add(i.personId),!0))}async function vF(e){const t=await g1("referred_by",e),n={};for(const i of t)n[i.personId]||(n[i.personId]=i.referrerId);const s=(await g1("contact_id",Object.keys(n))).filter(yF).map(i=>({...i,referrerId:n[i.personId]}));return{referrals:t,bookings:s}}function bF(e){const t=e.filter(n=>p1.includes(n.status));return{bookings:e.length,accepted:t.length,revenue:t.reduce((n,r)=>n+r.value,0),collected:t.reduce((n,r)=>n+r.paid,0),otherCash:e.filter(n=>!p1.includes(n.status)).reduce((n,r)=>n+r.paid,0)}}function gae({rows:e,showFinancials:t,revenueLabel:n="Booked revenue"}){const r=bF(e),s=({label:i,value:o,hint:l})=>a.jsxs("div",{className:"rounded border border-border px-3 py-2",title:l,children:[a.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:i}),a.jsx("p",{className:"text-sm font-semibold",children:o})]});return a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-2",children:[a.jsx(s,{label:"Referred bookings",value:String(r.bookings)}),a.jsx(s,{label:"Accepted",value:String(r.accepted)}),t&&a.jsxs(a.Fragment,{children:[a.jsx(s,{label:n,value:Fs(r.revenue),hint:"Booking value of accepted places"}),a.jsx(s,{label:"Collected",value:Fs(r.collected),hint:"Paid on accepted places only"}),r.otherCash>0&&a.jsx(s,{label:"Cash on non-accepted",value:Fs(r.otherCash),hint:"Paid on places not (or no longer) accepted â not in Collected"})]})]})}function wF({rows:e,showFinancials:t,referrerNames:n,revenueLabel:r}){const s=bF(e),i=n?4:3;return a.jsxs("div",{className:"rounded border border-border overflow-x-auto",children:[r&&a.jsx("p",{className:"px-2 py-1 text-[10px] text-muted-foreground border-b border-border",children:r}),a.jsxs("table",{className:"w-full text-xs",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border bg-muted/50 text-muted-foreground",children:[a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Person"}),n&&a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Referred by"}),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Booked"}),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Status"}),t&&a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Value"}),t&&a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Paid"})]})}),a.jsxs("tbody",{children:[e.map(o=>a.jsxs("tr",{className:"border-b border-border",children:[a.jsx("td",{className:"px-2 py-1.5",children:a.jsx("a",{className:"text-primary hover:underline",href:`/contacts?contact=${o.personId}`,children:o.person})}),n&&a.jsx("td",{className:"px-2 py-1.5",children:a.jsx("a",{className:"hover:underline",href:`/contacts?contact=${o.referrerId}`,children:n[o.referrerId]??"â"})}),a.jsxs("td",{className:"px-2 py-1.5",children:[o.bookedId?a.jsx("a",{className:"hover:underline",href:`/experiences?id=${o.bookedId}`,children:o.booked}):o.booked,a.jsxs("span",{className:"text-muted-foreground",children:[" · ",uae[o.kind]??o.kind]})]}),a.jsx("td",{className:"px-2 py-1.5",children:a.jsx(Ge,{variant:"outline",className:"text-[10px]",children:dae[o.status]??o.status})}),t&&a.jsx("td",{className:"px-2 py-1.5",children:Fs(o.value)}),t&&a.jsx("td",{className:"px-2 py-1.5",children:Fs(o.paid)})]},o.key)),a.jsxs("tr",{className:"bg-muted/30 font-medium",children:[a.jsxs("td",{className:"px-2 py-1.5",colSpan:i,children:["Total accepted · ",s.accepted," of ",s.bookings," bookings"]}),t&&a.jsx("td",{className:"px-2 py-1.5",children:Fs(s.revenue)}),t&&a.jsx("td",{className:"px-2 py-1.5",children:Fs(s.collected)})]}),t&&s.otherCash>0&&a.jsxs("tr",{className:"text-muted-foreground",children:[a.jsx("td",{className:"px-2 py-1.5",colSpan:i+1,children:"Cash on non-accepted places (not in Collected)"}),a.jsx("td",{className:"px-2 py-1.5",children:Fs(s.otherCash)})]})]})]})]})}function xae({contactId:e}){const t=hae(),{data:n,isLoading:r}=Ee({queryKey:["referred-bookings","contact",e],queryFn:()=>vF([e])}),s=new Set(((n==null?void 0:n.referrals)??[]).map(o=>o.personId)).size,i=(n==null?void 0:n.bookings)??[];return a.jsxs("div",{children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2 flex items-center gap-1",children:[a.jsx(W3,{className:"h-3 w-3"})," Referrals"]}),r?a.jsx("p",{className:"text-xs text-muted-foreground",children:"Loadingâ¦"}):s===0?a.jsx("p",{className:"text-xs text-muted-foreground",children:"No one referred by this contact."}):a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"text-xs text-muted-foreground mb-2",children:[s," ",s===1?"person":"people"," referred (summit referrals included)."]}),i.length>0&&a.jsx(wF,{rows:i,showFinancials:t,revenueLabel:"Lifetime â every booking by peo
699ple they referred, not just the first"})]})]})}function yae({contact:e,onEdit:t,onDelete:n,onClose:r}){const{data:s=[]}=ps(),i=at(),{toast:o}=mt(),l=s.find(p=>p.id===e.generator_id),[c,u]=y.useState(!1),[d,h]=y.useState(!1),[m,f]=y.useState(e.generator_id||""),{data:x}=Ee({queryKey:["contact-referrer",e.referred_by],enabled:!!e.referred_by,queryFn:async()=>{const{data:p,error:v}=await F.from("contacts").select("id, name").eq("id",e.referred_by).maybeSingle();if(v)throw v;return p}}),g=Me({mutationFn:async p=>{const{error:v}=await F.from("contacts").update({generator_id:p}).eq("id",e.id);if(v)throw v},onSuccess:()=>{i.invalidateQueries({queryKey:["contacts"]}),u(!1),o({title:"Generator updated"})},onError:p=>o({title:"Error",description:p.message,variant:"destructive"})});return a.jsxs("div",{className:"rounded-md border border-border bg-card p-4 animate-fade-in max-h-[calc(100vh-6rem)] overflow-y-auto",children:[a.jsxs("div",{className:"mb-4 flex items-start justify-between",children:[a.jsx("h3",{className:"text-lg font-semibold font-display text-card-foreground",children:e.name}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:t,children:a.jsx(Rn,{className:"h-3.5 w-3.5"})}),d?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"text-[11px] text-destructive font-medium whitespace-nowrap",children:"Delete?"}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>{n(),h(!1)},children:a.jsx(On,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(!1),children:a.jsx(Ht,{className:"h-3.5 w-3.5"})})]}):a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>h(!0),children:a.jsx(pn,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r,children:a.jsx(Ht,{className:"h-3.5 w-3.5"})})]})]}),a.jsxs("div",{className:"space-y-2 text-sm",children:[e.email&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(fs,{className:"h-3.5 w-3.5"}),a.jsx("a",{href:`mailto:${e.email}`,className:"hover:text-foreground transition-colors",children:e.email})]}),e.phone&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(lC,{className:"h-3.5 w-3.5"}),a.jsx("span",{children:e.phone})]}),(()=>{const p=e,v=[p.address_street,p.address_city,p.address_state,p.address_postal_code,p.address_country].filter(Boolean);return v.length===0?null:a.jsxs("div",{className:"flex items-start gap-2 text-muted-foreground",children:[a.jsx(zi,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),a.jsx("span",{children:v.join(", ")})]})})(),e.company&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(rC,{className:"h-3.5 w-3.5"}),a.jsx("span",{children:e.company})]}),e.linkedin_url&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(iH,{className:"h-3.5 w-3.5"}),a.jsx("a",{href:e.linkedin_url,target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground transition-colors",children:"LinkedIn Profile"})]}),e.instagram_handle&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(sH,{className:"h-3.5 w-3.5"}),a.jsx("a",{href:`https://instagram.com/${e.instagram_handle.replace(/^@/,"")}`,target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground transition-colors",children:e.instagram_handle.startsWith("@")?e.instagram_handle:`@${e.instagram_handle}`})]}),a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(Kv,{className:"h-3.5 w-3.5 flex-shrink-0"}),c?a.jsxs("div",{className:"flex items-center gap-1 flex-1",children:[a.jsx(Kt,{value:m,onValueChange:f,options:s.map(p=>({value:p.id,label:p.name})),placeholder:"Select generatorâ¦",allowNone:!0,className:"flex-1 h-7 text-xs"}),a.jsx(Y,{size:"sm",className:"h-7 px-2 text-xs",onClick:()=>g.mutate(m&&m!=="none"?m:null),disabled:g.isPending,children:"Save"}),a.jsx(Y,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>u(!1),children:a.jsx(Ht,{className:"h-3 w-3"})})]}):a.jsx("button",{onClick:()=>{f(e.generator_id||""),u(!0)},className:"hover:text-foreground transition-colors text-left",children:l?l.name:a.jsx("span",{className:"italic",children:"No generator â click to assign"})})]}),x&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(Hc,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Referred by ",x.name]})]}),e.birthdate&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(YK,{className:"h-3.5 w-3.5"}),a.jsx("span",{children:Ye(new Date(e.birthdate+"T00:00:00"),"MMM d, yyyy")})]}),e.dietary_restrictions&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(CH,{className:"h-3.5 w-3.5"}),a.jsx("span",{children:e.dietary_restrictions})]}),e.tshirt_size&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(vH,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Size ",e.tshirt_size]})]}),e.passport_number&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(pa,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Passport: ",e.passport_number]})]}),a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(pl,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Added ",Ye(new Date(e.created_at),"MMM d, yyyy")]})]})]}),(e.offering_interest||[]).length>0&&a.jsxs("div",{className:"mt-3 flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-muted-foreground mr-1",children:"Interested in:"}),e.offering_interest.map(p=>a.jsx(Ge,{variant:"secondary",className:"text-xs",children:p},p))]}),a.jsx("div",{className:"mt-3 border-t border-border pt-3",children:a.jsx(lae,{contactId:e.id})}),(e.mailchimp_tags||[]).length>0&&a.jsxs("div",{className:"mt-3 border-t border-border pt-3",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2 flex items-center gap-1",children:[a.jsx(Wv,{className:"h-3 w-3"})," Mailchimp Tags"]}),a.jsx("div",{className:"flex flex-wrap gap-1",children:e.mailchimp_tags.map(p=>a.jsx(Ge,{variant:"outline",className:"text-xs",children:p},p))})]}),e.notes&&a.jsx("p",{className:"mt-3 text-sm text-muted-foreground border-t border-border pt-3",children:e.notes}),e.mailchimp_id&&a.jsx("div",{className:"mt-3 border-t border-border pt-3",children:a.jsxs("span",{className:"text-xs text-muted-foreground",children:["Synced to Mailchimp",e.mailchimp_synced_at&&a.jsxs(a.Fragment,{children:[" · ",Ye(new Date(e.mailchimp_synced_at),"MMM d, yyyy")]})]})}),a.jsx("div",{className:"mt-4 border-t border-border pt-4",children:a.jsx(oae,{contactId:e.id,contactName:e.name})}),a.jsx("div",{className:"mt-4 border-t border-border pt-4",children:a.jsx(xF,{email:e.email,contactId:e.id})}),a.jsx("div",{className:"mt-4 border-t border-border pt-4",children:a.jsx(cae,{contactId:e.id})}),a.jsx("div",{className:"mt-4 border-t border-border pt-4",children:a.jsx(xae,{contactId:e.id})}),a.jsx("div",{className:"mt-4 border-t border-border pt-4",children:a.jsx(sae,{contactId:e.id})})]})}function vae({selectedCount:e,selectedIds:t,generators:n,experiences:r,onClear:s,onSelectAll:i,totalCount:o}){const[l,c]=y.useState(""),[u,d]=y.useState(""),h=at(),{toast:m}=mt(),f=Me({mutationFn:async()=>
699{if(!u||u==="none")return;const b=Array.from(t);for(const w of b){const{error:N}=await F.from("contacts").update({generator_id:u}).eq("id",w);if(N)throw N}},onSuccess:()=>{h.invalidateQueries({queryKey:["contacts"]}),m({title:`${e} contacts assigned to generator`}),g()},onError:b=>m({title:"Error",description:b.message,variant:"destructive"})}),x=Me({mutationFn:async()=>{if(!u||u==="none")return;const b=Array.from(t);for(const w of b){const{data:N}=await F.from("contact_experiences").select("id").eq("contact_id",w).eq("experience_id",u).maybeSingle();if(N)continue;const{error:j}=await F.from("contact_experiences").insert({contact_id:w,experience_id:u});if(j)throw j}},onSuccess:()=>{h.invalidateQueries({queryKey:["contacts"]}),h.invalidateQueries({queryKey:["experience-contacts"]}),m({title:`${e} contacts added to experience`}),g()},onError:b=>m({title:"Error",description:b.message,variant:"destructive"})}),g=()=>{c(""),d(""),s()},p=f.isPending||x.isPending,v=()=>{l==="generator"?f.mutate():l==="experience"&&x.mutate()};return a.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-primary/30 bg-primary/5 px-4 py-2 mb-4 flex-wrap",children:[a.jsxs("span",{className:"text-sm font-medium text-foreground",children:[e," selected"]}),a.jsxs(Y,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:i,children:["Select all ",o]}),a.jsx(Y,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:s,children:"Clear"}),a.jsxs("div",{className:"ml-auto flex items-center gap-2 flex-wrap",children:[a.jsxs(lt,{value:l,onValueChange:b=>{c(b),d("")},children:[a.jsx(it,{className:"w-40 h-8 text-xs",children:a.jsx(ct,{placeholder:"Assign toâ¦"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"generator",children:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Kv,{className:"h-3.5 w-3.5"})," Generator"]})}),a.jsx(Oe,{value:"experience",children:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(aC,{className:"h-3.5 w-3.5"})," Experience"]})})]})]}),l==="generator"&&a.jsx(Kt,{value:u,onValueChange:d,options:n.map(b=>({value:b.id,label:b.name})),placeholder:"Select generatorâ¦",className:"w-44 h-8 text-xs"}),l==="experience"&&a.jsx(Kt,{value:u,onValueChange:d,options:r.map(b=>({value:b.id,label:oo(b.name,b.target_start_date)})),placeholder:"Select experienceâ¦",className:"w-44 h-8 text-xs"}),a.jsx(Y,{size:"sm",className:"h-8 text-xs",onClick:v,disabled:!l||!u||u==="none"||p,children:p?"Applyingâ¦":"Apply"}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:s,children:a.jsx(Ht,{className:"h-4 w-4"})})]})]})}const hr=y.forwardRef(({className:e,...t},n)=>a.jsx("div",{className:"relative w-full overflow-auto",children:a.jsx("table",{ref:n,className:Se("w-full caption-bottom text-sm",e),...t})}));hr.displayName="Table";const zn=y.forwardRef(({className:e,...t},n)=>a.jsx("thead",{ref:n,className:Se("[&_tr]:border-b",e),...t}));zn.displayName="TableHeader";const Bn=y.forwardRef(({className:e,...t},n)=>a.jsx("tbody",{ref:n,className:Se("[&_tr:last-child]:border-0",e),...t}));Bn.displayName="TableBody";const _F=y.forwardRef(({className:e,...t},n)=>a.jsx("tfoot",{ref:n,className:Se("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));_F.displayName="TableFooter";const yt=y.forwardRef(({className:e,...t},n)=>a.jsx("tr",{ref:n,className:Se("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",e),...t}));yt.displayName="TableRow";const Le=y.forwardRef(({className:e,...t},n)=>a.jsx("th",{ref:n,className:Se("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));Le.displayName="TableHead";const Te=y.forwardRef(({className:e,...t},n)=>a.jsx("td",{ref:n,className:Se("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));Te.displayName="TableCell";const bae=y.forwardRef(({className:e,...t},n)=>a.jsx("caption",{ref:n,className:Se("mt-4 text-sm text-muted-foreground",e),...t}));bae.displayName="TableCaption";function wae(e,t){return y.useReducer((n,r)=>t[n][r]??n,e)}var tk="ScrollArea",[jF,x3e]=jr(tk),[_ae,gs]=jF(tk),NF=y.forwardRef((e,t)=>
vendor: 9,472 bytes, line 699
699{const{__scopeScrollArea:n,type:r="hover",dir:s,scrollHideDelay:i=600,...o}=e,[l,c]=y.useState(null),[u,d]=y.useState(null),[h,m]=y.useState(null),[f,x]=y.useState(null),[g,p]=y.useState(null),[v,b]=y.useState(0),[w,N]=y.useState(0),[j,_]=y.useState(!1),[S,P]=y.useState(!1),k=Ct(t,T=>c(T)),C=mh(s);return a.jsx(_ae,{scope:n,type:r,dir:C,scrollHideDelay:i,scrollArea:l,viewport:u,onViewportChange:d,content:h,onContentChange:m,scrollbarX:f,onScrollbarXChange:x,scrollbarXEnabled:j,onScrollbarXEnabledChange:_,scrollbarY:g,onScrollbarYChange:p,scrollbarYEnabled:S,onScrollbarYEnabledChange:P,onCornerWidthChange:b,onCornerHeightChange:N,children:a.jsx(tt.div,{dir:C,...o,ref:k,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":w+"px",...e.style}})})});NF.displayName=tk;var SF="ScrollAreaViewport",CF=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:s,...i}=e,o=gs(SF,n),l=y.useRef(null),c=Ct(t,l,o.onViewportChange);return a.jsxs(a.Fragment,{children:[a.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),a.jsx(tt.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:a.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});CF.displayName=SF;var Ci="ScrollAreaScrollbar",nk=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=gs(Ci,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=s,l=e.orientation==="horizontal";return y.useEffect(()=>(l?i(!0):o(!0),()=>{l?i(!1):o(!1)}),[l,i,o]),s.type==="hover"?a.jsx(jae,{...r,ref:t,forceMount:n}):s.type==="scroll"?a.jsx(Nae,{...r,ref:t,forceMount:n}):s.type==="auto"?a.jsx(kF,{...r,ref:t,forceMount:n}):s.type==="always"?a.jsx(rk,{...r,ref:t}):null});nk.displayName=Ci;var jae=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=gs(Ci,e.__scopeScrollArea),[i,o]=y.useState(!1);return y.useEffect(()=>{const l=s.scrollArea;let c=0;if(l){const u=()=>{window.clearTimeout(c),o(!0)},d=()=>{c=window.setTimeout(()=>o(!1),s.scrollHideDelay)};return l.addEventListener("pointerenter",u),l.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",u),l.removeEventListener("pointerleave",d)}}},[s.scrollArea,s.scrollHideDelay]),a.jsx(tr,{present:n||i,children:a.jsx(kF,{"data-state":i?"visible":"hidden",...r,ref:t})})}),Nae=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=gs(Ci,e.__scopeScrollArea),i=e.orientation==="horizontal",o=yb(()=>c("SCROLL_END"),100),[l,c]=wae("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return y.useEffect(()=>{if(l==="idle"){const u=window.setTimeout(()=>c("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[l,s.scrollHideDelay,c]),y.useEffect(()=>{const u=s.viewport,d=i?"scrollLeft":"scrollTop";if(u){let h=u[d];const m=()=>{const f=u[d];h!==f&&(c("SCROLL"),o()),h=f};return u.addEventListener("scroll",m),()=>u.removeEventListener("scroll",m)}},[s.viewport,i,c,o]),a.jsx(tr,{present:n||l!=="hidden",children:a.jsx(rk,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:Fe(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Fe(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),kF=y.forwardRef((e,t)=>{const n=gs(Ci,e.__scopeScrollArea),{forceMount:r,...s}=e,[i,o]=y.useState(!1),l=e.orientation==="horizontal",c=yb(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;o(l?u:d)}},10);return Ed(n.viewport,c),Ed(n.content,c),a.jsx(tr,{present:r||i,children:a.jsx(rk,{"data-state":i?"visible":"hidden",...s,ref:t})})}),rk=y.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,s=gs(Ci,e.__scopeScrollArea),i=y.useRef(null),o=y.useRef(0),[l,c]=y.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=TF(l.viewport,l.content),d={...r,sizes:l,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:m=>i.current=m,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:m=>o.current=m};function h(m,f){return Oae(m,o.current,l,f)}return n==="horizontal"?a.jsx(Sae,{...d,ref:t,onThumbPositionChange:()=>{if(s.viewport&&i.current){const m=s.viewport.scrollLeft,f=WO(m,l,s.dir);i.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:m=>{s.viewport&&(s.viewport.scrollLeft=m)},onDragScroll:m=>{s.viewport&&(s.viewport.scrollLeft=h(m,s.dir))}}):n==="vertical"?a.jsx(Cae,{...d,ref:t,onThumbPositionChange:()=>{if(s.viewport&&i.current){const m=s.viewport.scrollTop,f=WO(m,l);i.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:m=>{s.viewport&&(s.viewport.scrollTop=m)},onDragScroll:m=>{s.viewport&&(s.viewport.scrollTop=h(m))}}):null}),Sae=y.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...s}=e,i=gs(Ci,e.__scopeScrollArea),[o,l]=y.useState(),c=y.useRef(null),u=Ct(t,c,i.onScrollbarXChange);return y.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),a.jsx(PF,{"data-orientation":"horizontal",...s,ref:u,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":xb(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(i.viewport){const m=i.viewport.scrollLeft+d.deltaX;e.onWheelScroll(m),DF(m,h)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:uy(o.paddingLeft),paddingEnd:uy(o.paddingRight)}})}})}),Cae=y.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...s}=e,i=gs(Ci,e.__scopeScrollArea),[o,l]=y.useState(),c=y.useRef(null),u=Ct(t,c,i.onScrollbarYChange);return y.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),a.jsx(PF,{"data-orientation":"vertical",...s,ref:u,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":xb(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(i.viewport){const m=i.viewport.scrollTop+d.deltaY;e.onWheelScroll(m),DF(m,h)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:uy(o.paddingTop),paddingEnd:uy(o.paddingBottom)}})}})}),[kae,EF]=jF(Ci),PF=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:s,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:h,...m}=e,f=gs(Ci,n),[x,g]=y.useState(null),p=Ct(t,k=>g(k)),v=y.useRef(null),b=y.useRef(""),w=f.viewport,N=r.content-r.viewport,j=Kn(d),_=Kn(c),S=yb(h,10);function P(k){if(v.current){const C=k.clientX-v.current.left,T=k.clientY-v.current.top;u({x:C,y:T})}}return y.useEffect(()=>{const k=C=>{const T=C.target;(x==null?void 0:x.contains(T))&&j(C,N)};return document.addEventListener("wheel",k,{passive:!1}),()=>document.removeEventListener("wheel",k,{passive:!1})},[w,x,N,j]),y.useEffect(_,[r,_]),Ed(x,S),Ed(f.content,S),a.jsx(kae,{scope:n,scrollbar:x,hasThumb:s,onThumbChange:Kn(i),onThumbPointerUp:Kn(o),onThumbPositionChange:_,onThumbPointerDown:Kn(l),children:a.jsx(tt.div,{...m,ref:p,style:{position:"absolute",...m.style},onPointerDown:Fe(e.onPointerDown,k=>{k.button===0&&(k.target.setPointerCapture(k.pointerId),v.current=x.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),P(k))}),onPointerMove:Fe(e.onPointerMove,P),onPointerUp:Fe(e.onPointerUp,k=>{const C=k.target;C.hasPointerCapture(k.pointerId)&&C.releasePointerCapture(k.pointerId),document.body.style.webkitUserSelect=b.current,f.viewport&&(f.viewport.style.scrollBehavior=""),v.current=null})})})}),cy="ScrollAreaThumb",OF=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=EF(cy,e.__scopeScrollArea);return a.jsx(tr,{present:n||s.hasThumb,children:a.jsx(Eae,{ref:t,...r})})}),Eae=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...s}=e,i=gs(cy,n),o=EF(cy,n),{onThumbPositionChange:l}=o,c=Ct(t,h=>o.onThumbChange(h)),u=y.useRef(void 0),d=yb(()=>{u.current&&(u.current(),u.current=void 0)},100);return y.useEffect(()=>{const h=i.viewport;if(h){const m=()=>{if(d(),!u.current){const f=Aae(h,l);u.current=f,l()}};return l(),h.addEventListener("scroll",m),()=>h.removeEventListener("scroll",m)}},[i.viewport,d,l]),a.jsx(tt.div,{"data-state":o.hasThumb?"visible":"hidden",...s,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Fe(e.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),x=h.clientX-f.left,g=h.clientY-f.top;o.onThumbPointerDown({x,y:g})}),onPointerUp:Fe(e.onPointerUp,o.onThumbPointerUp)})});OF.displayName=cy;var ak="ScrollAreaCorner",AF=y.forwardRef((e,t)=>
699{const n=gs(ak,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?a.jsx(Pae,{...e,ref:t}):null});AF.displayName=ak;var Pae=y.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,s=gs(ak,n),[i,o]=y.useState(0),[l,c]=y.useState(0),u=!!(i&&l);return Ed(s.scrollbarX,()=>{var h;const d=((h=s.scrollbarX)==null?void 0:h.offsetHeight)||0;s.onCornerHeightChange(d),c(d)}),Ed(s.scrollbarY,()=>{var h;const d=((h=s.scrollbarY)==null?void 0:h.offsetWidth)||0;s.onCornerWidthChange(d),o(d)}),u?a.jsx(tt.div,{...r,ref:t,style:{width:i,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function uy(e){return e?parseInt(e,10):0}function TF(e,t){const n=e/t;return isNaN(n)?0:n}function xb(e){const t=TF(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Oae(e,t,n,r="ltr"){const s=xb(n),i=s/2,o=t||i,l=s-o,c=n.scrollbar.paddingStart+o,u=n.scrollbar.size-n.scrollbar.paddingEnd-l,d=n.content-n.viewport,h=r==="ltr"?[0,d]:[d*-1,0];return MF([c,u],h)(e)}function WO(e,t,n="ltr"){const r=xb(t),s=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-s,o=t.content-t.viewport,l=i-r,c=n==="ltr"?[0,o]:[o*-1,0],u=i1(e,c);return MF([0,o],[0,l])(u)}function MF(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function DF(e,t){return e>0&&e<t}var Aae=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function s(){const i={left:e.scrollLeft,top:e.scrollTop},o=n.left!==i.left,l=n.top!==i.top;(o||l)&&t(),n=i,r=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(r)};function yb(e,t){const n=Kn(e),r=y.useRef(0);return y.useEffect(()=>()=>window.clearTimeout(r.current),[]),y.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ed(e,t){const n=Kn(t);dr(()=>{let r=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return s.observe(e),()=>{window.cancelAnimationFrame(r),s.unobserve(e)}}},[e,n])}var $F=NF,Tae=CF,Mae=AF;const Ic=y.forwardRef(({className:e,children:t,...n},r)=>a.jsxs($F,{ref:r,className:Se("relative overflow-hidden",e),...n,children:[a.jsx(Tae,{className:"h-full w-full rounded-[inherit]",children:t}),a.jsx(sk,{}),a.jsx(Mae,{})]}));Ic.displayName=$F.displayName;const sk=y.forwardRef(({className:e,orientation:t="vertical",...n},r)=>a.jsx(nk,{ref:r,orientation:t,className:Se("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:a.jsx(OF,{className:"relative flex-1 rounded-full bg-border"})}));sk.displayName=nk.displayName;const Dae=[{value:"skip",label:"â Skip â"},{value:"name",label:"Name"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"company",label:"Company"},{value:"status",label:"Status"},{value:"notes",label:"Notes"},{value:"referred_by_name",label:"Referred By (name)"}];function $ae(e){const t=e.toLowerCase().trim();return t.includes("name")&&!t.includes("company")?"name":t.includes("email")||t.includes("e-mail")?"email":t.includes("phone")||t.includes("mobile")||t.includes("tel")?"phone":t.includes("company")||t.includes("org")?"company":t.includes("status")?"status":t.includes("note")?"notes":t.includes("refer")?"referred_by_name":"skip"}function Rae({open:e,onOpenChange:t,generators:n}){const[r,s]=y.useState("paste"),[i,o]=y.useState(""),[l,c]=y.useState([]),[u,d]=y.useState([]),[h,m]=y.useState([]),[f,x]=y.useState(""),[g,p]=y.useState({created:0,updated:0,errors:[]}),v=at(),{toast:b}=mt(),w=()=>{s("paste"),o(""),c([]),d([]),m([]),x(""),p({created:0,updated:0,errors:[]})},N=()=>{const S=i.trim().split(` 700`).filter(Boolean);if(S.length<2){b({title:"Need at least a header row and one data row",variant:"destructive"});return}const P=S.map(C=>C.split(" ")),k=P[0];d(k),c(P.slice(1)),m(k.map($ae)),s("map")},j=Me({mutationFn:async()=>{var O,L;const S=h.indexOf("name");if(S===-1)throw new Error("You must map a 'Name' column");const P=h.indexOf("email");let k=0,C=0;const T=[];for(let E=0;E<l.length;E++){const R=l[E],q=(O=R[S])==null?void 0:O.trim();if(!q){T.push(`Row ${E+1}: missing name, skipped`);continue}const I={name:q};
700if(h.forEach((M,B)=>{var A;if(M==="skip"||M==="name"||M==="referred_by_name")return;const W=(A=R[B])==null?void 0:A.trim();W&&(I[M]=W)}),f&&(I.generator_id=f),P!==-1&&((L=R[P])!=null&&L.trim())){const M=R[P].trim(),{data:B}=await F.from("contacts").select("id").eq("email",M).maybeSingle();if(B){const{error:W}=await F.from("contacts").update(I).eq("id",B.id);W?T.push(`Row ${E+1} (${q}): ${W.message}`):C++;continue}}const{error:$}=await F.from("contacts").insert(I);$?T.push(`Row ${E+1} (${q}): ${$.message}`):k++}return{created:k,updated:C,errors:T}},onSuccess:S=>{p(S),s("result"),v.invalidateQueries({queryKey:["contacts"]}),b({title:"Import complete",description:`${S.created} created, ${S.updated} updated`})},onError:S=>{b({title:"Import failed",description:S.message,variant:"destructive"})}}),_=(S,P)=>{m(k=>{const C=[...k],T=C.indexOf(P);return P!=="skip"&&T!==-1&&(C[T]="skip"),C[S]=P,C})};return a.jsx(Dt,{open:e,onOpenChange:S=>{S||w(),t(S)},children:a.jsxs(Pt,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col",children:[a.jsxs(Ot,{children:[a.jsxs(At,{className:"flex items-center gap-2",children:[a.jsx(ao,{className:"h-5 w-5"})," Bulk Import Contacts"]}),a.jsxs(wr,{children:[r==="paste"&&"Copy rows from your spreadsheet and paste them below (include the header row).",r==="map"&&"Map each column to a contact field, then import.",r==="result"&&"Import complete."]})]}),r==="paste"&&a.jsxs("div",{className:"space-y-3 flex-1",children:[a.jsx(qt,{value:i,onChange:S=>o(S.target.value),placeholder:`Name Email Phone Company 701John Doe [email protected] 555-1234 Acme Inc`,className:"min-h-[200px] font-mono text-xs"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: Select cells in Excel/Google Sheets â Copy â Paste here. Tab-separated columns are auto-detected."})]}),r==="map"&&a.jsx(Ic,{className:"flex-1 max-h-[55vh]",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium",children:"Assign to Generator:"}),a.jsxs(lt,{value:f,onValueChange:x,children:[a.jsx(it,{className:"w-48 h-8 text-xs",children:a.jsx(ct,{placeholder:"(optional)"})}),a.jsx(ot,{children:n.map(S=>a.jsx(Oe,{value:S.id,children:S.name},S.id))})]})]}),a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsx(yt,{children:u.map((S,P)=>a.jsx(Le,{className:"p-1",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("span",{className:"text-xs font-medium truncate block",children:S}),a.jsxs(lt,{value:h[P],onValueChange:k=>_(P,k),children:[a.jsx(it,{className:"h-7 text-xs",children:a.jsx(ct,{})}),a.jsx(ot,{children:Dae.map(k=>a.jsx(Oe,{value:k.value,children:k.label},k.value))})]})]})},P))})}),a.jsx(Bn,{children:l.slice(0,5).map((S,P)=>a.jsx(yt,{children:S.map((k,C)=>a.jsx(Te,{className:"p-1 text-xs truncate max-w-[150px]",children:k},C))},P))})]}),l.length>5&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["â¦and ",l.length-5," more rows"]})]})}),r==="result"&&a.jsxs("div",{className:"space-y-3 py-4",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Mr,{className:"h-5 w-5 text-primary"}),a.jsxs("span",{children:[g.created," created, ",g.updated," updated"]})]}),g.errors.length>0&&a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center gap-1 text-sm text-destructive",children:[a.jsx(QK,{className:"h-4 w-4"})," ",g.errors.length," error(s)"]}),a.jsx(Ic,{className:"max-h-32",children:a.jsx("ul",{className:"text-xs space-y-0.5 text-muted-foreground",children:g.errors.map((S,P)=>a.jsx("li",{children:S},P))})})]})]}),a.jsxs(br,{children:[r==="paste"&&a.jsx(Y,{onClick:N,disabled:!i.trim(),children:"Next: Map Columns"}),r==="map"&&a.jsxs(a.Fragment,{children:[a.jsx(Y,{variant:"outline",onClick:()=>s("paste"),children:"Back"}),a.jsx(Y,{onClick:()=>j.mutate(),disabled:j.isPending||!h.includes("name"),children:j.isPending?"Importingâ¦":`Import ${l.length} Contacts`})]}),r==="result"&&a.jsx(Y,{onClick:()=>{w(),t(!1)},children:"Done"})]})]})})}function KO(e){return e.toLowerCase().replace(/[^a-z]/g,"")}function ik(e,t){if(e===t)return 0;const n=e.length,r=t.length;if(!n||!r)return n||r;let s=Array.from({length:r+1},(i,o)=>o);for(let i=1;i<=n;i++){const o=[i];for(let l=1;l<=r;l++)o[l]=Math.min(s[l]+1,o[l-1]+1,s[l-1]+(e[i-1]===t[l-1]?0:1));s=o}return s[r]}const Iae=[["jim","jimmy","james"],["bob","bobby","rob","robby","robert"],["bill","billy","will","willy","william"],["dick","rick","richard","rich","richie"],["mike","mick","michael"],["tom","tommy","thomas"],["dave","david"],["dan","danny","daniel"],["joe","joey","joseph"],["chris","christopher","kristopher"],["matt","matthew"],["steve","stephen","steven"],["tony","anthony"],["ed","eddie","edward"],["ted","teddy","theodore","edward"],["nick","nicholas"],["andy","andrew","drew"],["ben","benji","benjamin"],["sam","sammy","samuel","samantha"],["alex","alexander","alexandra"],["greg","gregory"],["jeff","jeffrey","geoff","geoffrey"],["ken","kenny","kenneth"],["larry","lawrence"],["pat","patty","patrick","patricia"],["pete","peter"],["ron","ronnie","ronald"],["tim","timmy","timothy"],["cathy","kathy","catherine","katherine","kate","katie"],["liz","lizzy","beth","betty","elizabeth"],["sue","susie","susan","suzanne"],["jen","jenny","jennifer"],["deb","debbie","deborah"],["maggie","meg","margaret","peggy"],["sandy","sandra"],["cindy","cynthia"],["barb","barbara"],["vicki","vicky","victoria"],["jess","jessie","jessica"],["abby","abigail"],["nate","nathan","nathaniel"],["zach","zack","zachary"],["charlie","chuck","charles"],["frank","francis","franklin"],["gabe","gabriel"],["hank","henry"],["jack","john","johnny","jon","jonathan"],["josh","joshua"],["marty","martin"],["max","maxwell","maximilian"],["phil","philip","phillip"],["ray","raymond"],["sal","salvatore"],["tobi","toby","tobias"],["vince","vincent"],["walt","walter"]];
701function Lae(e,t){return!e||!t?!1:e===t||Iae.some(n=>n.includes(e)&&n.includes(t))||(e.startsWith(t)||t.startsWith(e))&&Math.min(e.length,t.length)>=3?!0:ik(e,t)<=1&&Math.min(e.length,t.length)>=4}function HO(e){const t=e.toLowerCase().replace(/[^a-z\s]/g," ").split(/\s+/).filter(Boolean);return{first:t[0]||"",last:t.length>1?t[t.length-1]:""}}function Fae(e,t){const n=KO(e),r=KO(t);if(n===r)return!0;if(n.length<3||r.length<3)return!1;if(n.includes(r)||r.includes(n))return!0;const s=HO(e),i=HO(t);return s.last&&s.last===i.last&&Lae(s.first,i.first)?!0:ik(n,r)<=2}function GO(e){const t=e.toLowerCase().trim(),[n="",r=""]=t.split("@");return{local:n,domain:r}}function qae(e,t){const n=GO(e),r=GO(t);if(!n.domain||n.domain!==r.domain)return!1;const s=n.local.replace(/[.+_-]/g,""),i=r.local.replace(/[.+_-]/g,"");return s===i?!0:Math.min(s.length,i.length)<5?!1:ik(s,i)<=2}function zae(e){const t=[],n=new Set,r=new Map;for(const i of e){if(!i.email)continue;const o=i.email.toLowerCase().trim();r.has(o)||r.set(o,[]),r.get(o).push(i)}for(const[i,o]of r)o.length<2||(t.push({key:`email-${i}`,reason:`Same email: ${i}`,contacts:o}),o.forEach(l=>n.add(l.id)));const s=e.filter(i=>!n.has(i.id));for(let i=0;i<s.length;i++)for(let o=i+1;o<s.length;o++){const l=s[i],c=s[o],u=Fae(l.name,c.name),d=!!l.email&&!!c.email&&qae(l.email,c.email);if(!u&&!d)continue;const h=u&&d?"Similar names and emails":u?"Similar names":"Nearly identical emails",m=t.find(f=>f.key.startsWith("near-")&&f.contacts.some(x=>x.id===l.id||x.id===c.id));if(m)for(const f of[l,c])m.contacts.some(x=>x.id===f.id)||m.contacts.push(f);else t.push({key:`near-${l.id}`,reason:h,contacts:[l,c]})}return t}function Bae({open:e,onOpenChange:t}){const{toast:n}=mt(),r=at(),[s,i]=y.useState(new Set),[o,l]=y.useState(null),[c,u]=y.useState({}),{data:d=[],isLoading:h}=Ee({queryKey:["all-contacts-dedup"],enabled:e,queryFn:async()=>{const{data:p,error:v}=await F.from("contacts").select("*").order("updated_at",{ascending:!1});if(v)throw v;return p}}),m=y.useMemo(()=>d.length?zae(d).filter(p=>!s.has(p.key)):[],[d,s]),f=Me({mutationFn:async({keepId:p,mergeId:v})=>{const{data:{session:b}}=await F.auth.getSession(),w=await F.functions.invoke("merge-contacts",{body:{keep_id:p,merge_id:v},headers:{Authorization:`Bearer ${b==null?void 0:b.access_token}`}});if(w.error)throw new Error(w.error.message);return w.data},onSuccess:(p,v)=>{r.invalidateQueries({queryKey:["contacts"]}),r.invalidateQueries({queryKey:["all-contacts-dedup"]}),r.invalidateQueries({queryKey:["contact-experience-names"]}),n({title:"Contacts merged successfully"}),l(null)},onError:p=>{n({title:"Merge failed",description:p.message,variant:"destructive"}),l(null)}}),x=async p=>{l(p.key);const v=c[p.key]||[...p.contacts].sort((w,N)=>new Date(N.updated_at).getTime()-new Date(w.updated_at).getTime())[0].id,b=p.contacts.filter(w=>w.id!==v);try{for(const w of b)await f.mutateAsync({keepId:v,mergeId:w.id})}catch{}l(null)},g=p=>{const v=[];return p.email&&v.push(p.email),p.phone&&v.push(p.phone),p.company&&v.push(p.company),v.join(" · ")||"No details"};return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsx(At,{children:"Find Duplicate Contacts"})}),h?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(vt,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):m.length===0?a.jsxs("div",{className:"text-center py-12",children:[a.jsx(On,{className:"h-8 w-8 text-success mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"No duplicates found!"})]}):a.jsxs("div",{className:"space-y-4",children:[a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Found ",m.length," potential duplicate",m.length!==1?" groups":"",". Merging keeps the most recently updated record and fills any gaps from the duplicate."]}),m.map(p=>a.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(Ge,{variant:"outline",className:"text-xs",children:p.reason}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>i(v=>
701new Set([...v,p.key])),children:"Dismiss"}),p.contacts.length===2&&a.jsxs(Y,{size:"sm",className:"h-7 text-xs",onClick:()=>x(p),disabled:o===p.key,children:[o===p.key?a.jsx(vt,{className:"h-3 w-3 animate-spin mr-1"}):a.jsx(yP,{className:"h-3 w-3 mr-1"}),"Merge"]}),p.contacts.length>2&&a.jsxs(Y,{size:"sm",className:"h-7 text-xs",onClick:()=>x(p),disabled:o===p.key,children:[o===p.key?a.jsx(vt,{className:"h-3 w-3 animate-spin mr-1"}):a.jsx(yP,{className:"h-3 w-3 mr-1"}),"Merge All"]})]})]}),a.jsxs("div",{className:"space-y-2",children:[p.contacts.length>2&&a.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Click a contact to select it as the one to keep:"}),[...p.contacts].sort((v,b)=>{const w=c[p.key];if(w){if(v.id===w)return-1;if(b.id===w)return 1}return new Date(b.updated_at).getTime()-new Date(v.updated_at).getTime()}).map((v,b)=>{const w=c[p.key]?v.id===c[p.key]:b===0;return a.jsxs("div",{className:Se("rounded-md px-3 py-2 text-sm",w?"bg-success/10 border border-success/20":"bg-muted/50 border border-border",p.contacts.length>2&&"cursor-pointer hover:border-primary/40 transition-colors"),onClick:()=>{p.contacts.length>2&&u(N=>({...N,[p.key]:v.id}))},children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("span",{className:"font-medium text-foreground",children:v.name}),w&&a.jsx(Ge,{className:"ml-2 text-[10px] bg-success/20 text-success border-success/30",variant:"outline",children:"Keep"}),!w&&a.jsx(Ge,{className:"ml-2 text-[10px] bg-destructive/20 text-destructive border-destructive/30",variant:"outline",children:"Merge"})]}),a.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Updated ",new Date(v.updated_at).toLocaleDateString()]})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:g(v)})]},v.id)})]})]},p.key))]})]})})}function ok(e){return y.useMemo(()=>{const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),r=e.filter(c=>!c.status||c.status==="active"),s=[],i=[];for(const c of r){const u=c.target_start_date?new Date(c.target_start_date+"T00:00:00"):null;u&&u<n?i.push(c):s.push(c)}const o=(c,u)=>{const d=c.target_start_date||"";return(u.target_start_date||"").localeCompare(d)};s.sort(o),i.sort(o);const l=[];return l.push({label:"",options:[{value:"all",label:"All Contacts"},{value:"any_experience",label:"All Experiences"}]}),s.length>0&&l.push({label:"Future",options:s.map(c=>({value:c.id,label:oo(c.name,c.target_start_date)}))}),i.length>0&&l.push({label:"Past",options:i.map(c=>({value:c.id,label:oo(c.name,c.target_start_date)}))}),l},[e])}var Ow="rovingFocusGroup.onEntryFocus",Uae={bubbles:!1,cancelable:!0},kp="RovingFocusGroup",[x1,RF,Wae]=dp(kp),[Kae,vb]=jr(kp,[Wae]),[Hae,Gae]=Kae(kp),IF=y.forwardRef((e,t)=>a.jsx(x1.Provider,{scope:e.__scopeRovingFocusGroup,children:a.jsx(x1.Slot,{scope:e.__scopeRovingFocusGroup,children:a.jsx(Vae,{...e,ref:t})})}));IF.displayName=kp;var Vae=y.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:s=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...h}=e,m=y.useRef(null),f=Ct(t,m),x=mh(i),[g,p]=oa({prop:o,defaultProp:l??null,onChange:c,caller:kp}),[v,b]=y.useState(!1),w=Kn(u),N=RF(n),j=y.useRef(!1),[_,S]=y.useState(0);return y.useEffect(()=>{const P=m.current;if(P)return P.addEventListener(Ow,w),()=>P.removeEventListener(Ow,w)},[w]),a.jsx(Hae,{scope:n,orientation:r,dir:x,loop:s,currentTabStopId:g,onItemFocus:y.useCallback(P=>p(P),[p]),onItemShiftTab:y.useCallback(()=>b(!0),[]),onFocusableItemAdd:y.useCallback(()=>S(P=>P+1),[]),onFocusableItemRemove:y.useCallback(()=>S(P=>P-1),[]),children:a.jsx(tt.div,{tabIndex:v||_===0?-1:0,"data-orientation":r,...h,ref:f,style:{outline:"none",...e.style},onMouseDown:Fe(e.onMouseDown,()=>{j.current=!0}),onFocus:Fe(e.onFocus,P=>{const k=!j.current;if(P.target===P.currentTarget&&k&&!v){const C=new CustomEvent(Ow,Uae);if(P.currentTarget.dispatchEvent(C),!C.defaultPrevented){const T=N().filter(q=>q.focusable),O=T.find(q=>q.active),L=T.find(q=>
vendor: 16,966 bytes, line 701
701q.id===g),R=[O,L,...T].filter(Boolean).map(q=>q.ref.current);qF(R,d)}}j.current=!1}),onBlur:Fe(e.onBlur,()=>b(!1))})})}),LF="RovingFocusGroupItem",FF=y.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:i,children:o,...l}=e,c=Zn(),u=i||c,d=Gae(LF,n),h=d.currentTabStopId===u,m=RF(n),{onFocusableItemAdd:f,onFocusableItemRemove:x,currentTabStopId:g}=d;return y.useEffect(()=>{if(r)return f(),()=>x()},[r,f,x]),a.jsx(x1.ItemSlot,{scope:n,id:u,focusable:r,active:s,children:a.jsx(tt.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...l,ref:t,onMouseDown:Fe(e.onMouseDown,p=>{r?d.onItemFocus(u):p.preventDefault()}),onFocus:Fe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:Fe(e.onKeyDown,p=>{if(p.key==="Tab"&&p.shiftKey){d.onItemShiftTab();return}if(p.target!==p.currentTarget)return;const v=Xae(p,d.orientation,d.dir);if(v!==void 0){if(p.metaKey||p.ctrlKey||p.altKey||p.shiftKey)return;p.preventDefault();let w=m().filter(N=>N.focusable).map(N=>N.ref.current);if(v==="last")w.reverse();else if(v==="prev"||v==="next"){v==="prev"&&w.reverse();const N=w.indexOf(p.currentTarget);w=d.loop?Jae(w,N+1):w.slice(N+1)}setTimeout(()=>qF(w))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:g!=null}):o})})});FF.displayName=LF;var Yae={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Qae(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Xae(e,t,n){const r=Qae(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Yae[r]}function qF(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Jae(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var zF=IF,BF=FF,y1=["Enter"," "],Zae=["ArrowDown","PageUp","Home"],UF=["ArrowUp","PageDown","End"],ese=[...Zae,...UF],tse={ltr:[...y1,"ArrowRight"],rtl:[...y1,"ArrowLeft"]},nse={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ep="Menu",[ym,rse,ase]=dp(Ep),[Gc,WF]=jr(Ep,[ase,Si,vb]),bb=Si(),KF=vb(),[sse,Vc]=Gc(Ep),[ise,Pp]=Gc(Ep),HF=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:s,onOpenChange:i,modal:o=!0}=e,l=bb(t),[c,u]=y.useState(null),d=y.useRef(!1),h=Kn(i),m=mh(s);return y.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),a.jsx(pp,{...l,children:a.jsx(sse,{scope:t,open:n,onOpenChange:h,content:c,onContentChange:u,children:a.jsx(ise,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:m,modal:o,children:r})})})};HF.displayName=Ep;var ose="MenuAnchor",lk=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=bb(n);return a.jsx(ih,{...s,...r,ref:t})});lk.displayName=ose;var ck="MenuPortal",[lse,GF]=Gc(ck,{forceMount:void 0}),VF=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:s}=e,i=Vc(ck,t);return a.jsx(lse,{scope:t,forceMount:n,children:a.jsx(tr,{present:n||i.open,children:a.jsx(th,{asChild:!0,container:s,children:r})})})};VF.displayName=ck;var ls="MenuContent",[cse,uk]=Gc(ls),YF=y.forwardRef((e,t)=>{const n=GF(ls,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,i=Vc(ls,e.__scopeMenu),o=Pp(ls,e.__scopeMenu);return a.jsx(ym.Provider,{scope:e.__scopeMenu,children:a.jsx(tr,{present:r||i.open,children:a.jsx(ym.Slot,{scope:e.__scopeMenu,children:o.modal?a.jsx(use,{...s,ref:t}):a.jsx(dse,{...s,ref:t})})})})}),use=y.forwardRef((e,t)=>{const n=Vc(ls,e.__scopeMenu),r=y.useRef(null),s=Ct(t,r);return y.useEffect(()=>{const i=r.current;if(i)return ob(i)},[]),a.jsx(dk,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Fe(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),dse=y.forwardRef((e,t)=>{const n=Vc(ls,e.__scopeMenu);return a.jsx(dk,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),hse=ml("MenuContent.ScrollLock"),dk=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,disableOutsideScroll:x,...g}=e,p=Vc(ls,n),v=Pp(ls,n),b=bb(n),w=KF(n),N=rse(n),[j,_]=y.useState(null),S=y.useRef(null),P=Ct(t,S,p.onContentChange),k=y.useRef(0),C=y.useRef(""),T=y.useRef(0),O=y.useRef(null),L=y.useRef("right"),E=y.useRef(0),R=x?wp:y.Fragment,q=x?{as:hse,allowPinchZoom:!0}:void 0,I=M=>{var te,J;const B=C.current+M,W=N().filter(re=>!re.disabled),A=document.activeElement,K=(te=W.find(re=>re.ref.current===A))==null?void 0:te.textValue,G=W.map(re=>re.textValue),H=Nse(G,B,K),fe=(J=W.find(re=>re.textValue===H))==null?void 0:J.ref.current;(function re(pe){C.current=pe,window.clearTimeout(k.current),pe!==""&&(k.current=window.setTimeout(()=>re(""),1e3))})(B),fe&&setTimeout(()=>fe.focus())};y.useEffect(()=>()=>window.clearTimeout(k.current),[]),sb();const $=y.useCallback(M=>{var W,A;return L.current===((W=O.current)==null?void 0:W.side)&&Cse(M,(A=O.current)==null?void 0:A.area)},[]);return a.jsx(cse,{scope:n,searchRef:C,onItemEnter:y.useCallback(M=>{$(M)&&M.preventDefault()},[$]),onItemLeave:y.useCallback(M=>{var B;$(M)||((B=S.current)==null||B.focus(),_(null))},[$]),onTriggerLeave:y.useCallback(M=>{$(M)&&M.preventDefault()},[$]),pointerGraceTimerRef:T,onPointerGraceIntentChange:y.useCallback(M=>{O.current=M},[]),children:a.jsx(R,{...q,children:a.jsx(bp,{asChild:!0,trapped:s,onMountAutoFocus:Fe(i,M=>{var B;M.preventDefault(),(B=S.current)==null||B.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:a.jsx(jl,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:m,onDismiss:f,children:a.jsx(zF,{asChild:!0,...w,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:j,onCurrentTabStopIdChange:_,onEntryFocus:Fe(c,M=>{v.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:a.jsx(gp,{role:"menu","aria-orientation":"vertical","data-state":dq(p.open),"data-radix-menu-content":"",dir:v.dir,...b,...g,ref:P,style:{outline:"none",...g.style},onKeyDown:Fe(g.onKeyDown,M=>{const W=M.target.closest("[data-radix-menu-content]")===M.currentTarget,A=M.ctrlKey||M.altKey||M.metaKey,K=M.key.length===1;W&&(M.key==="Tab"&&M.preventDefault(),!A&&K&&I(M.key));const G=S.current;if(M.target!==G||!ese.includes(M.key))return;M.preventDefault();const fe=N().filter(te=>!te.disabled).map(te=>te.ref.current);UF.includes(M.key)&&fe.reverse(),_se(fe)}),onBlur:Fe(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(k.current),C.current="")}),onPointerMove:Fe(e.onPointerMove,vm(M=>{const B=M.target,W=E.current!==M.clientX;if(M.currentTarget.contains(B)&&W){const A=M.clientX>E.current?"right":"left";L.current=A,E.current=M.clientX}}))})})})})})})});YF.displayName=ls;var fse="MenuGroup",hk=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return a.jsx(tt.div,{role:"group",...r,ref:t})});hk.displayName=fse;var mse="MenuLabel",QF=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return a.jsx(tt.div,{...r,ref:t})});QF.displayName=mse;var dy="MenuItem",VO="menu.itemSelect",wb=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...s}=e,i=y.useRef(null),o=Pp(dy,e.__scopeMenu),l=uk(dy,e.__scopeMenu),c=Ct(t,i),u=y.useRef(!1),d=()=>{const h=i.current;if(!n&&h){const m=new CustomEvent(VO,{bubbles:!0,cancelable:!0});h.addEventListener(VO,f=>r==null?void 0:r(f),{once:!0}),ZS(h,m),m.defaultPrevented?u.current=!1:o.onClose()}};return a.jsx(XF,{...s,ref:c,disabled:n,onClick:Fe(e.onClick,d),onPointerDown:h=>{var m;(m=e.onPointerDown)==null||m.call(e,h),u.current=!0},onPointerUp:Fe(e.onPointerUp,h=>{var m;u.current||(m=h.currentTarget)==null||m.click()}),onKeyDown:Fe(e.onKeyDown,h=>{const m=l.searchRef.current!=="";n||m&&h.key===" "||y1.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});wb.displayName=dy;var XF=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:s,...i}=e,o=uk(dy,n),l=KF(n),c=y.useRef(null),u=Ct(t,c),[d,h]=y.useState(!1),[m,f]=y.useState("");return y.useEffect(()=>{const x=c.current;x&&f((x.textContent??"").trim())},[i.children]),a.jsx(ym.ItemSlot,{scope:n,disabled:r,textValue:s??m,children:a.jsx(BF,{asChild:!0,...l,focusable:!r,children:a.jsx(tt.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:u,onPointerMove:Fe(e.onPointerMove,vm(x=>{r?o.onItemLeave(x):(o.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Fe(e.onPointerLeave,vm(x=>o.onItemLeave(x))),onFocus:Fe(e.onFocus,()=>h(!0)),onBlur:Fe(e.onBlur,()=>h(!1))})})})}),pse="MenuCheckboxItem",JF=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...s}=e;return a.jsx(rq,{scope:e.__scopeMenu,checked:n,children:a.jsx(wb,{role:"menuitemcheckbox","aria-checked":hy(n)?"mixed":n,...s,ref:t,"data-state":mk(n),onSelect:Fe(s.onSelect,()=>r==null?void 0:r(hy(n)?!0:!n),{checkForDefaultPrevented:!1})})})});JF.displayName=pse;var ZF="MenuRadioGroup",[gse,xse]=Gc(ZF,{value:void 0,onValueChange:()=>{}}),eq=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...s}=e,i=Kn(r);return a.jsx(gse,{scope:e.__scopeMenu,value:n,onValueChange:i,children:a.jsx(hk,{...s,ref:t})})});eq.displayName=ZF;var tq="MenuRadioItem",nq=y.forwardRef((e,t)=>{const{value:n,...r}=e,s=xse(tq,e.__scopeMenu),i=n===s.value;return a.jsx(rq,{scope:e.__scopeMenu,checked:i,children:a.jsx(wb,{role:"menuitemradio","aria-checked":i,...r,ref:t,"data-state":mk(i),onSelect:Fe(r.onSelect,()=>{var o;return(o=s.onValueChange)==null?void 0:o.call(s,n)},{checkForDefaultPrevented:!1})})})});nq.displayName=tq;var fk="MenuItemIndicator",[rq,yse]=Gc(fk,{checked:!1}),aq=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...s}=e,i=yse(fk,n);return a.jsx(tr,{present:r||hy(i.checked)||i.checked===!0,children:a.jsx(tt.span,{...s,ref:t,"data-state":mk(i.checked)})})});aq.displayName=fk;var vse="MenuSeparator",sq=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return a.jsx(tt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});sq.displayName=vse;var bse="MenuArrow",iq=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=bb(n);return a.jsx(xp,{...s,...r,ref:t})});iq.displayName=bse;var wse="MenuSub",[y3e,oq]=Gc(wse),mf="MenuSubTrigger",lq=y.forwardRef((e,t)=>{const n=Vc(mf,e.__scopeMenu),r=Pp(mf,e.__scopeMenu),s=oq(mf,e.__scopeMenu),i=uk(mf,e.__scopeMenu),o=y.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=i,u={__scopeMenu:e.__scopeMenu},d=y.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return y.useEffect(()=>d,[d]),y.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),c(null)}},[l,c]),a.jsx(lk,{asChild:!0,...u,children:a.jsx(XF,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":dq(n.open),...e,ref:ro(t,s.onTriggerChange),onClick:h=>{var m;(m=e.onClick)==null||m.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Fe(e.onPointerMove,vm(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:Fe(e.onPointerLeave,vm(h=>{var f,x;d();const m=(f=n.content)==null?void 0:f.getBoundingClientRect();if(m){const g=(x=n.content)==null?void 0:x.dataset.side,p=g==="right",v=p?-5:5,b=m[p?"left":"right"],w=m[p?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+v,y:h.clientY},{x:b,y:m.top},{x:w,y:m.top},{x:w,y:m.bottom},{x:b,y:m.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Fe(e.onKeyDown,h=>{var f;const m=i.searchRef.current!=="";e.disabled||m&&h.key===" "||tse[r.dir].includes(h.key)&&(n.onOpenChange(!0),(f=n.content)==null||f.focus(),h.preventDefault())})})})});lq.displayName=mf;var cq="MenuSubContent",uq=y.forwardRef((e,t)=>{const n=GF(ls,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,i=Vc(ls,e.__scopeMenu),o=Pp(ls,e.__scopeMenu),l=oq(cq,e.__scopeMenu),c=y.useRef(null),u=Ct(t,c);return a.jsx(ym.Provider,{scope:e.__scopeMenu,children:a.jsx(tr,{present:r||i.open,children:a.jsx(ym.Slot,{scope:e.__scopeMenu,children:a.jsx(dk,{id:l.contentId,"aria-labelledby":l.triggerId,...s,ref:u,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;o.isUsingKeyboardRef.current&&((h=c.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:Fe(e.onFocusOutside,d=>{d.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Fe(e.onEscapeKeyDown,d=>{o.onClose(),d.preventDefault()}),onKeyDown:Fe(e.onKeyDown,d=>{var f;const h=d.currentTarget.contains(d.target),m=nse[o.dir].includes(d.key);h&&m&&(i.onOpenChange(!1),(f=l.trigger)==null||f.focus(),d.preventDefault())})})})})})});uq.displayName=cq;function dq(e){return e?"open":"closed"}function hy(e){return e==="indeterminate"}function mk(e){return hy(e)?"indeterminate":e?"checked":"unchecked"}function _se(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function jse(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Nse(e,t,n){const s=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=jse(e,Math.max(i,0));s.length===1&&(o=o.filter(u=>u!==n));const c=o.find(u=>u.toLowerCase().startsWith(s.toLowerCase()));return c!==n?c:void 0}function Sse(e,t){const{x:n,y:r}=e;let s=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const l=t[i],c=t[o],u=l.x,d=l.y,h=c.x,m=c.y;d>r!=m>r&&n<(h-u)*(r-d)/(m-d)+u&&(s=!s)}return s}function Cse(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Sse(n,t)}function vm(e){return t=>t.pointerType==="mouse"?e(t):void 0}var kse=HF,Ese=lk,Pse=VF,Ose=YF,Ase=hk,Tse=QF,Mse=wb,Dse=JF,$se=eq,Rse=nq,Ise=aq,Lse=sq,Fse=iq,qse=lq,zse=uq,_b="DropdownMenu",[Bse,v3e]=jr(_b,[WF]),ua=WF(),[Use,hq]=Bse(_b),fq=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:s,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,c=ua(t),u=y.useRef(null),[d,h]=oa({prop:s,defaultProp:i??!1,onChange:o,caller:_b});return a.jsx(Use,{scope:t,triggerId:Zn(),triggerRef:u,contentId:Zn(),open:d,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(m=>!m),[h]),modal:l,children:a.jsx(kse,{...c,open:d,onOpenChange:h,dir:r,modal:l,children:n})})};fq.displayName=_b;var mq="DropdownMenuTrigger",pq=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...s}=e,i=hq(mq,n),o=ua(n);return a.jsx(Ese,{asChild:!0,...o,children:a.jsx(tt.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...s,ref:ro(t,i.triggerRef),onPointerDown:Fe(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:Fe(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});pq.displayName=mq;var Wse="DropdownMenuPortal",gq=e=>{const{__scopeDropdownMenu:t,...n}=e,r=ua(t);return a.jsx(Pse,{...r,...n})};gq.displayName=Wse;var xq="DropdownMenuContent",yq=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=hq(xq,n),i=ua(n),o=y.useRef(!1);return a.jsx(Ose,{id:s.contentId,"aria-labelledby":s.triggerId,...i,...r,ref:t,onCloseAutoFocus:Fe(e.onCloseAutoFocus,l=>{var c;o.current||(c=s.triggerRef.current)==null||c.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:Fe(e.onInteractOutside,l=>{const c=l.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!s.modal||d)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});yq.displayName=xq;var Kse="DropdownMenuGroup",Hse=y.forwardRef((e,t)=>
701{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx(Ase,{...s,...r,ref:t})});Hse.displayName=Kse;var Gse="DropdownMenuLabel",vq=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx(Tse,{...s,...r,ref:t})});vq.displayName=Gse;var Vse="DropdownMenuItem",bq=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx(Mse,{...s,...r,ref:t})});bq.displayName=Vse;var Yse="DropdownMenuCheckboxItem",wq=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx(Dse,{...s,...r,ref:t})});wq.displayName=Yse;var Qse="DropdownMenuRadioGroup",Xse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx($se,{...s,...r,ref:t})});Xse.displayName=Qse;var Jse="DropdownMenuRadioItem",_q=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx(Rse,{...s,...r,ref:t})});_q.displayName=Jse;var Zse="DropdownMenuItemIndicator",jq=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx(Ise,{...s,...r,ref:t})});jq.displayName=Zse;var eie="DropdownMenuSeparator",Nq=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx(Lse,{...s,...r,ref:t})});Nq.displayName=eie;var tie="DropdownMenuArrow",nie=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx(Fse,{...s,...r,ref:t})});nie.displayName=tie;var rie="DropdownMenuSubTrigger",Sq=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx(qse,{...s,...r,ref:t})});Sq.displayName=rie;var aie="DropdownMenuSubContent",Cq=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=ua(n);return a.jsx(zse,{...s,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Cq.displayName=aie;var sie=fq,iie=pq,oie=gq,kq=yq,Eq=vq,Pq=bq,Oq=wq,Aq=_q,Tq=jq,Mq=Nq,Dq=Sq,$q=Cq;const pk=sie,gk=iie,lie=y.forwardRef(({className:e,inset:t,children:n,...r},s)=>a.jsxs(Dq,{ref:s,className:Se("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",t&&"pl-8",e),...r,children:[n,a.jsx(fp,{className:"ml-auto h-4 w-4"})]}));lie.displayName=Dq.displayName;const cie=y.forwardRef(({className:e,...t},n)=>a.jsx($q,{ref:n,className:Se("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));cie.displayName=$q.displayName;const jb=y.forwardRef(({className:e,sideOffset:t=4,...n},r)=>a.jsx(oie,{children:a.jsx(kq,{ref:r,sideOffset:t,className:Se("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));jb.displayName=kq.displayName;const Os=y.forwardRef(({className:e,inset:t,...n},r)=>a.jsx(Pq,{ref:r,className:Se("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...n}));Os.displayName=Pq.displayName;const v1=y.forwardRef(({className:e,children:t,checked:n,...r},s)=>
701a.jsxs(Oq,{ref:s,className:Se("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:n,...r,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Tq,{children:a.jsx(On,{className:"h-4 w-4"})})}),t]}));v1.displayName=Oq.displayName;const uie=y.forwardRef(({className:e,children:t,...n},r)=>a.jsxs(Aq,{ref:r,className:Se("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:a.jsx(Tq,{children:a.jsx(T3,{className:"h-2 w-2 fill-current"})})}),t]}));uie.displayName=Aq.displayName;const die=y.forwardRef(({className:e,inset:t,...n},r)=>a.jsx(Eq,{ref:r,className:Se("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));die.displayName=Eq.displayName;const Rq=y.forwardRef(({className:e,...t},n)=>a.jsx(Mq,{ref:n,className:Se("-mx-1 my-1 h-px bg-muted",e),...t}));Rq.displayName=Mq.displayName;function xk({generators:e,selectedIds:t,onChange:n,className:r}){var d;const[s,i]=y.useState(!1),o=t.length===0,l=h=>{t.includes(h)?n(t.filter(m=>m!==h)):n([...t,h])},c=()=>n([]),u=o?"All Generators":t.length===1?((d=e.find(h=>h.id===t[0]))==null?void 0:d.name)||"1 Generator":`${t.length} Generators`;return a.jsxs(na,{open:s,onOpenChange:i,children:[a.jsx(ra,{asChild:!0,children:a.jsxs(Y,{variant:"outline",role:"combobox","aria-expanded":s,className:Se("justify-between gap-1 font-normal",r),children:[a.jsx("span",{className:"truncate",children:u}),a.jsx(_n,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]})}),a.jsxs(Kr,{className:"w-52 p-1",align:"start",children:[a.jsxs("button",{onClick:c,className:Se("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent cursor-pointer",o&&"font-medium"),children:[a.jsx("div",{className:Se("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",o?"bg-primary text-primary-foreground":"opacity-50"),children:o&&a.jsx(On,{className:"h-3 w-3"})}),"All Generators"]}),a.jsx("div",{className:"my-1 border-t border-border"}),e.map(h=>{const m=t.includes(h.id);return a.jsxs("button",{onClick:()=>l(h.id),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent cursor-pointer",children:[a.jsx("div",{className:Se("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",m?"bg-primary text-primary-foreground":"opacity-50"),children:m&&a.jsx(On,{className:"h-3 w-3"})}),a.jsx("span",{className:"truncate",children:h.name})]},h.id)})]})]})}function hie({availableTags:e,selectedTags:t,onChange:n,className:r}){const[s,i]=y.useState(!1),o=t.length===0,l=d=>{t.includes(d)?n(t.filter(h=>h!==d)):n([...t,d])},c=()=>n([]),u=o?"All Tags":t.length===1?t[0]:`${t.length} Tags`;return e.length===0?null:a.jsxs(na,{open:s,onOpenChange:i,children:[a.jsx(ra,{asChild:!0,children:a.jsxs(Y,{variant:"outline",role:"combobox","aria-expanded":s,className:Se("justify-between gap-1 font-normal",r),children:[a.jsx(Wv,{className:"h-3 w-3 shrink-0 opacity-50"}),a.jsx("span",{className:"truncate",children:u}),a.jsx(_n,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]})}),a.jsxs(Kr,{className:"w-52 p-1 max-h-64 overflow-y-auto",align:"start",children:[a.jsxs("button",{onClick:c,className:Se("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent cursor-pointer",o&&"font-medium"),children:[a.jsx("div",{className:Se("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",o?"bg-primary text-primary-foreground":"opacity-50"),children:o&&a.jsx(On,{className:"h-3 w-3"})}),"All Tags"]}),a.jsx("div",{className:"my-1 border-t border-border"}),e.map(d=>{const h=t.includes(d);return a.jsxs("button",{onClick:()=>l(d),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent cursor-pointer",children:[a.jsx("div",{className:Se("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",h?"bg-primary text-primary-foreground":"opacity-50"),children:h&&a.jsx(On,{className:"h-3 w-3"})}),a.jsx("span",{className:"truncate",children:d})]},d)})]})]})}const YO=[{value:"trip",label:"Trips"},{value:"peer_group",label:"Peer Groups"},{value:"stakeholder_summit",label:"Summits"},{value:"coaching",label:"Coaching"}];function fie({selected:e,onChange:t,className:n}){var c;const[r,s]=y.useState(!1),i=e.length===0,o=u=>{e.includes(u)?t(e.filter(d=>d!==u)):t([...e,u])},l=i?"Has Done":e.length===1?((c=YO.find(u=>u.value===e[0]))==null?void 0:c.label)||e[0]:`${e.length} Types`;return a.jsxs(na,{open:r,onOpenChange:s,children:[a.jsx(ra,{asChild:!0,children:a.jsxs(Y,{variant:"outline",role:"combobox","aria-expanded":r,className:Se("justify-between gap-1 font-normal",n
701),children:[a.jsx(oC,{className:"h-3 w-3 shrink-0 opacity-50"}),a.jsx("span",{className:"truncate",children:l}),a.jsx(_n,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]})}),a.jsxs(Kr,{className:"w-48 p-1",align:"start",children:[a.jsxs("button",{onClick:()=>t([]),className:Se("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent cursor-pointer",i&&"font-medium"),children:[a.jsx("div",{className:Se("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",i?"bg-primary text-primary-foreground":"opacity-50"),children:i&&a.jsx(On,{className:"h-3 w-3"})}),"All"]}),a.jsx("div",{className:"my-1 border-t border-border"}),YO.map(u=>{const d=e.includes(u.value);return a.jsxs("button",{onClick:()=>o(u.value),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent cursor-pointer",children:[a.jsx("div",{className:Se("flex h-4 w-4 items-center justify-center rounded-sm border border-primary",d?"bg-primary text-primary-foreground":"opacity-50"),children:d&&a.jsx(On,{className:"h-3 w-3"})}),u.label]},u.value)})]})]})}function mie(){const[e]=El(),[t,n]=y.useState(""),[r,s]=y.useState(!1),[i,o]=y.useState(!1),[l,c]=y.useState(!1),[u,d]=y.useState(null),[h,m]=y.useState(null),[f,x]=y.useState(null),[g,p]=y.useState("all"),[v,b]=y.useState([]),[w,N]=y.useState([]),[j,_]=y.useState(new Set),S=at(),{toast:P}=mt(),{data:k=[]}=ps(),{data:C=[]}=po(),T=ok(C),{data:O}=go(),{data:L}=Qs();y.useEffect(()=>{f===null&&L!==void 0&&(L?x([]):O?x([O.id]):O===null&&x([]))},[O,f,L]);const{data:E={}}=Ee({queryKey:["contact-experience-names"],queryFn:async()=>{const{data:te,error:J}=await F.from("contact_experiences").select("contact_id, status, experiences(name, public_name, status, target_start_date)").in("status",["candidate","expressed_interest","invited","considering","accepted","gen_guide","declined","future","waitlist"]);if(J)throw J;const re=new Date().toISOString().slice(0,10),pe={};for(const ye of te||[]){const X=ye.experiences;!X||X.status!=="active"||X.target_start_date&&X.target_start_date<re||(pe[ye.contact_id]||(pe[ye.contact_id]=[]),pe[ye.contact_id].push({name:X.public_name||X.name,status:ye.status}))}return pe}}),{data:R=[],isLoading:q}=Ee({queryKey:["contacts",t,f,g,v,w],enabled:f!==null,queryFn:async()=>{var ye;let te=F.from("contacts").select("*, generators(name)").order("last_viewed_at",{ascending:!1,nullsFirst:!1}).order("name",{ascending:!0});t&&(te=te.or(`name.ilike.%${t}%,email.ilike.%${t}%,company.ilike.%${t}%`)),f&&f.length>0&&(te=te.in("generator_id",f));const{data:J,error:re}=await te;if(re)throw re;let pe=J;if(g==="any_experience"){const{data:X}=await F.from("contact_experiences").select("contact_id"),he=new Set((X||[]).map(D=>D.contact_id));pe=pe.filter(D=>he.has(D.id))}else if(g&&g!=="all"){const{data:X}=await F.from("contact_experiences").select("contact_id").eq("experience_id",g),he=new Set((X||[]).map(D=>D.contact_id));pe=pe.filter(D=>he.has(D.id))}if(v.length>0&&(pe=pe.filter(X=>{const he=X.mailchimp_tags||[];return v.every(D=>he.includes(D))})),w.length>0){const X=w.filter(V=>V!=="coaching"),he=w.includes("coaching"),D=new Date().toISOString().slice(0,10);let le=new Set;if(X.length>0){const{data:V}=await F.from("contact_experiences").select("contact_id, experiences(type, status, target_start_date)").eq("status","accepted");if(V)for(const U of V)(ye=U.experiences)!=null&&ye.target_start_date&&U.experiences.target_start_date<D&&X.includes(U.experiences.type)&&le.add(U.contact_id)}if(he){const{data:V}=await F.from("contact_coaching").select("contact_id");if(V)for(const U of V)le.add(U.contact_id)}pe=pe.filter(V=>le.has(V.id))}return pe}});y.useEffect(()=>{if(h){const te=R.find(J=>J.id===h.id);te&&te!==h&&te.updated_at!==h.updated_at&&m(te)}},[R,h]),y.useEffect(()=>{const te=e.get("contact");if(te&&R.length>0&&!h){const J=R.find(re=>re.id===te);J&&m(J)}},[e,R,h]);const{data:I=[]}=Ee({queryKey:["available-mailchimp-tags"],queryFn:async()=>{const{data:te,error:J}=await F.from("contacts").select("mailchimp_tags");if(J)throw J;const re=new Set;for(const pe of te||[])for(const ye of pe.mailchimp_tags||[])re.add(ye);return Array.from(re).sort()}}),$=Me({mutationFn:async te=>{const{error:J}=await F.from("contacts").delete().eq("id",te);if(J)throw J},onSuccess:()=>{S.invalidateQueries({queryKey:["contacts"]}),m(null),P({title:"Contact deleted"})}}),M=Me({mutationFn:async te=>{const{data:{session:J}}=await F.auth.getSession(),re=await F.functions.invoke("mailchimp-sync",{body:{action:te},headers:{Authorization:`Bearer ${J==null?void 0:J.access_token}`}});if(re.error)throw new Error(re.error.message);return re.data},onSuccess:(te,J)=>{S.invalidateQueries({queryKey:["contacts"]}),J==="sync-all"?P({title:"Mailchimp sync complete",description:`${te.synced} synced, ${te.failed} failed`}):J==="import"&&P({title:"Mailchimp import complete",description:`${te.imported} imported, ${te.skipped} skipped`})},onError:te=>{P({title:"Sync failed",description:te.message,variant:"destructive"})}}),B=te=>{d(te),s(!0)},W=()=>{d(null),s(!0)},A=y.useCallback(async te=>{m(te),await F.from("contacts").update({last_viewed_at:new Date().toISOString()}).eq("id",te.id),S.invalidateQueries({queryKey:["contacts"]})},[S]),K=y.useCallback(te=>{_(J=>{const re=new Set(J);return re.has(te)?re.delete(te):re.add(te),re})},[]),G=y.useCallback(()=>{_(new Set(R.map(te=>te.id)))},[R]),H=y.useCallback(()=>{_(new Set)},[]),fe=()=>{const te=["Name","Email","Phone","Company","Status","Generator","Offering Interest","Mailchimp Tags","Referred By","Notes"],J=R.map(he=>{var D;return[he.name,he.email||"",he.phone||"",he.company||"",he.status,((D=he.generators)==null?void 0:D.name)||"",(he.offering_interest||[]).join("; "),(he.mailchimp_tags||[]).join("; "),he.referred_by||"",(he.notes||"").replace(/"/g,'""')]}),re=[te,...J].map(he=>he.map(D=>`"${D}"`).join(",")).join(` 702`),pe=new Blob([re],{type:"text/csv;charset=utf-8;"}),ye=URL.createObjectURL(pe),X=document.createElement("a");X.href=ye,X.download=`contacts-${new Date().toISOString().slice(0,10)}.csv`,X.click(),URL.revokeObjectURL(ye)};return a.jsxs(Rr,{children:[a.jsxs("div",{className:"animate-fade-in",children:[a.jsxs("div",{className:"mb-6 flex items-center gap-2 flex-wrap",children:[a.jsxs("div",{className:"relative",children:[a.jsx(Bv,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),a.jsx(ce,{placeholder:"Search contactsâ¦",value:t,onChange:te=>n(te.target.value),className:"pl-8 w-48",maxLength:100})]}),a.jsx(xk,{generators:k,selectedIds:f||[],onChange:x,className:"w-40 h-9 text-xs"}),a.jsx(Kt,{value:g,onValueChange:p,options:T,placeholder:"All Experiences",className:"w-36 h-9 text-xs"}),a.jsx(hie,{availableTags:I,selectedTags:v,onChange:b,className:"w-36 h-9 text-xs"}),a.jsx(fie,{selected:w,onChange:N,className:"w-36 h-9 text-xs"}),a.jsxs(Y,{onClick:W,size:"sm",children:[a.jsx(zt,{className:"mr-1 h-4 w-4"})," Add Contact"]}),a.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>o(!0),children:[a.jsx(ao,{className:"mr-1 h-4 w-4"})," Import"]}),a.jsxs(Y,{variant:"outline",size:"sm",onClick:fe,disabled:R.length===0,children:[a.jsx(ja,{className:"mr-1 h-4 w-4"})," Export CSV"]}),a.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>c(!0),children:[a.jsx(Hc,{className:"mr-1 h-4 w-4"})," Find Duplicates"]}),L&&a.jsxs(pk,{children:[a.jsx(gk,{asChild:!0,children:a.jsxs(Y,{variant:"outline",size:"sm",disabled:M.isPending,children:[a.jsx(Hx,{className:`mr-1 h-4 w-4 ${M.isPending?"animate-spin":""}`}),"Mailchimp"]})}),a.jsxs(jb,{align:"end",children:[a.jsxs(Os,{onClick:()=>M.mutate("sync-all"),children:[a.jsx(Hx,{className:"mr-2 h-4 w-4"})," Push all to Mailchimp"]}),a.jsxs(Os,{onClick:()=>M.mutate("import"),children:[a.jsx(ja,{className:"mr-2 h-4 w-4"})," Import from Mailchimp"]})]})]})]}),j.size>0&&a.jsx(vae,{selectedCount:j.size,selectedIds:j,generators:k,experiences:C,onClear:H,onSelectAll:G,totalCount:R.length}),a.jsxs("div",{className:"grid gap-6 lg:grid-cols-5",children:[h&&a.jsx("div",{className:"lg:col-span-2 lg:order-2 self-start sticky top-6",children:a.jsx(yae,{contact:h,onEdit:()=>B(h),onDelete:()=>$.mutate(h.id),onClose:()=>m(null)})}),a.jsx("div",{className:h?"lg:col-span-3 lg:order-1":"lg:col-span-5",children:a.jsx(aee,{contacts:R,loading:q,onSelect:A,selectedId:h==null?void 0:h.id,generators:k,bulkMode:!0,selectedIds:j,onToggleSelect:K,contactExperiences:E})})]})]}),a.jsx(Pne,{open:r,onOpenChange:s,contact:u}),a.jsx(Rae,{open:i,onOpenChange:o,generators:k}),a.jsx(Bae,{open:l,onOpenChange:c})]})}const pie=1,gie="c47d5285-1073-499f-ac37-c4d431e7d690",xie="d4a00433-86df-49a5-a2fb-fb92bc1c1656",yie="/__l5e/assets-v1/c47d5285-1073-499f-ac37-c4d431e7d690/FourCorners-Primary-White.png",vie="a/v1/d4a00433-86df-49a5-a2fb-fb92bc1c1656/c47d5285-1073-499f-ac37-c4d431e7d690/FourCorners-Primary-White.png",bie="FourCorners-Primary-White.png",wie=21361,_ie="image/png",jie="2026-07-03T17:20:16Z",Nie={version:pie,asset_id:gie,project_id:xie,url:yie,r2_key:vie,original_filename:bie,size:wie,content_type:_ie,created_at:jie},Sie=1,Cie="bd9f731e-8715-49f8-8240-1edbbbbf5553",kie="d4a00433-86df-49a5-a2fb-fb92bc1c1656",Eie="/__l5e/assets-v1/bd9f731e-8715-49f8-8240-1edbbbbf5553/Starry_Mountains.jpg",Pie="a/v1/d4a00433-86df-49a5-a2fb-fb92bc1c1656/bd9f731e-8715-49f8-8240-1edbbbbf5553/Starry_Mountains.jpg",Oie="Starry_Mountains.jpg",Aie=2753324,Tie="image/jpeg",Mie="2026-07-03T17:20:45Z",Die={version:Sie,asset_id:Cie,project_id:kie,url:Eie,r2_key:Pie,original_filename:Oie,size:Aie,content_type:Tie,created_at:Mie},$ie=Nie.url,Rie=Die.url;function QO(){const e=new URLSearchParams(window.location.search).get("next");if(!e||!e.startsWith("/")||e.startsWith("//"))return null;try{const t=new URL(e,window.location.origin);return t.origin!==window.location.origin?null:`${t.pathname}${t.search}${t.hash}`}catch{return null}}function Iie(){const[e,t]=y.useState("login"),[n,r]=y.useState(""),[s,i]=y.useState(""),[o,l]=y.useState(!1),{toast:c}=mt(),u=async d=>{d.preventDefault(),l(!0);try{if(e==="forgot"){const{error:h}=await F.auth.resetPasswordForEmail(n,{redirectTo:`${window.location.origin}/`});if(h)throw h;c({title:"Check your email",description:"We've sent you a password reset link."}),t("login")}else if(e==="login"){const{error:h}=await F.auth.signInWithPassword({email:n,password:s});if(h)throw h.message==="Invalid login credentials"?new Error("Please select Create Account if you're logging in for the first time. If you're having issues, please contact Four Corners."):h;const m=QO();m&&(window.location.href=m)}else{const{data:h,error:m}=await F.rpc("is_generator_email",{_email:n.trim()});if(m)throw m;if(!h)throw new Error("New accounts can only be created using a Four Corners team member/partner registered email. Please use a different email or contact Four Corners about having your email registered.");const{error:f}=await F.auth.signUp({email:n,password:s,options:{emailRedirectTo:`${window.location.origin}
702${QO()??"/"}`}});if(f)throw f;c({title:"Check your email",description:"We've sent you a confirmation link to verify your account."})}}catch(h){c({title:"Error",description:h.message,variant:"destructive"})}finally{l(!1)}};return a.jsxs("div",{className:"relative flex min-h-screen items-center justify-center px-4 overflow-hidden",children:[a.jsx("div",{className:"absolute inset-0 bg-cover bg-center bg-no-repeat",style:{backgroundImage:`url(${Rie})`}}),a.jsx("div",{className:"absolute inset-0 bg-black/50"}),a.jsxs("div",{className:"relative z-10 w-full max-w-sm animate-fade-in -mt-[12vh]",children:[a.jsx("div",{className:"mb-4 text-center",children:a.jsx("img",{src:$ie,alt:"Four Corners",className:"mx-auto h-64 w-auto object-contain"})}),a.jsxs("form",{onSubmit:u,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(xe,{htmlFor:"email",className:"text-white",children:"Email"}),a.jsx(ce,{id:"email",type:"email",value:n,onChange:d=>r(d.target.value),placeholder:"[email protected]",required:!0,maxLength:255,className:"border-white/30 bg-white/10 text-white placeholder:text-white/50 focus-visible:ring-white/50"})]}),e!=="forgot"&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(xe,{htmlFor:"password",className:"text-white",children:"Password"}),a.jsx(ce,{id:"password",type:"password",value:s,onChange:d=>i(d.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",required:!0,minLength:6,maxLength:128,className:"border-white/30 bg-white/10 text-white placeholder:text-white/50 focus-visible:ring-white/50"})]}),a.jsx(Y,{type:"submit",className:"w-full bg-white/20 text-white border border-white/30 hover:bg-white/30 backdrop-blur-sm",disabled:o,children:o?"Please waitâ¦":e==="login"?"Sign In":e==="signup"?"Create Account":"Send Reset Link"})]}),e==="login"&&a.jsx("button",{type:"button",onClick:()=>t("forgot"),className:"mt-3 block w-full text-center text-sm text-white/70 underline underline-offset-4 hover:text-white transition-colors",children:"Forgot password?"}),a.jsx("p",{className:"mt-4 text-center text-sm text-white/70",children:e==="forgot"?a.jsxs(a.Fragment,{children:["Remember your password?"," ",a.jsx("button",{type:"button",onClick:()=>t("login"),className:"font-medium text-white underline underline-offset-4 hover:text-white/80 transition-colors",children:"Sign in"})]}):e==="login"?a.jsxs(a.Fragment,{children:["Don't have an account?"," ",a.jsx("button",{type:"button",onClick:()=>t("signup"),className:"font-medium text-white underline underline-offset-4 hover:text-white/80 transition-colors",children:"Create Account"})]}):a.jsxs(a.Fragment,{children:["Already have an account?"," ",a.jsx("button",{type:"button",onClick:()=>t("login"),className:"font-medium text-white underline underline-offset-4 hover:text-white/80 transition-colors",children:"Sign in"})]})})]})]})}const Lie={requested:"Requested",received:"Received",chosen:"Chosen",not_chosen:"Not chosen",expired:"Expired"};function Fie(){return new Date().toLocaleDateString("en-CA")}function XO(e){return e.amount_per_person!=null||e.amount_per_group!=null}function qie(e,t,n){return t.has(e.id)?"chosen":e.valid_until&&e.valid_until<Fie()&&XO(e)?"expired":e.status==="Declined"||n!=null&&n.has(e.id)?"not_chosen":XO(e)?"received":"requested"}function b1(e){const[t,n,r]=e.split("-").map(Number),s=new Date,i=new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime();return Math.max(0,Math.round((i-new Date(t,n-1,r).getTime())/864e5))}function zie(e){var r;let t=0,n=0;for(const s of e){if(s.status==="requested"){const i=s.sent_date||((r=s.created_at)==null?void 0:r.slice(0,10));i&&b1(i)>7&&t++}s.status==="received"&&n++}return{staleRequested:t,unattached:n}}function Iq(e){return Ee({queryKey:["experience-quotes",(e==null?void 0:e.length)===1?e[0]:"all","pipeline",(e==null?void 0:e.join(","))??""],queryFn:async()=>{const t=F;let n=t.from("experience_quotes").select("id, experience_id, status, sent_date, created_at, valid_until, amount_per_person, amount_per_group, supplier_id");e&&(n=n.in("experience_id",e));const{data:r,error:s}=await n;if(s)throw s;const i=(r||[]).map(c=>c.id),o=new Set,l=new Set;if(i.length){const{data:c}=await t.from("experience_budget_items").select("quote_id").in("quote_id",i);
702(c||[]).forEach(d=>d.quote_id&&o.add(d.quote_id));const{data:u}=await t.from("budget_item_quote_options").select("quote_id").in("quote_id",i);(u||[]).forEach(d=>l.add(d.quote_id))}return(r||[]).map(c=>({...c,derived:qie(c,o,l)}))}})}function Lq(e){return zie(e.map(t=>({status:t.derived,sent_date:t.sent_date,created_at:t.created_at})))}function Bie(){const{data:e=[]}=Iq(),t=Array.from(new Set(e.map(s=>s.experience_id))),{data:n=[]}=Ee({queryKey:["quote-pipeline-exps",t.join(",")],enabled:t.length>0,queryFn:async()=>{const{data:s}=await F.from("experiences").select("id, name, public_name, status").in("id",t);return(s||[]).filter(i=>i.status!=="cancelled")}}),r=n.map(s=>({...s,...Lq(e.filter(i=>i.experience_id===s.id))})).filter(s=>s.staleRequested+s.unattached>0);return r.length?a.jsxs("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1 mt-3",children:[a.jsxs("p",{className:"text-xs font-medium",children:["Quote pipeline (",r.length,")"]}),a.jsx("ul",{className:"text-sm space-y-0.5",children:r.map(s=>a.jsxs("li",{children:[a.jsx(Na,{to:`/experiences?id=${s.id}`,className:"hover:underline",children:s.public_name||s.name}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.staleRequested>0&&` · ${s.staleRequested} requested, no reply after 7 days`,s.unattached>0&&` · ${s.unattached} received, not attached`]})]},s.id))})]}):null}const Uie=["Outfitter","Lodging","Transportation"],w1=(e,t)=>t&&e&&e in t?t[e]:Uie.includes(e||""),Fq=(e,t)=>(e.category??"direct")==="direct"&&(e.expects_quote??w1(e.name,t)),Wie=e=>!!e.supplier_id&&!!e.confirmed_date&&Number(e.amount||0)!==0,Kie=e=>!!e.quote_id||!!(e.estimate_reason&&e.estimate_reason.trim())||Wie(e),qq="name, description, category, amount, quote_id, estimate_reason, supplier_id, confirmed_date, expects_quote";function yk(e,t){const n=e.filter(s=>Fq(s,t)),r=n.filter(s=>!Kie(s));return{total:n.length,sourced:n.length-r.length,unsourced:r}}function Hie(){const{data:e=[]}=Ee({queryKey:["unsourced-soon"],queryFn:async()=>{const t=new Date,n=d=>`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`,r=new Date(t);r.setDate(r.getDate()+60);const{data:s,error:i}=await F.from("experiences").select("id, name, public_name, target_start_date").neq("status","cancelled").gte("target_start_date",n(t)).lte("target_start_date",n(r)).order("target_start_date");if(i)throw i;if(!(s!=null&&s.length))return[];const{data:o,error:l}=await F.from("experience_budget_items").select(`experience_id, ${qq}`).in("experience_id",s.map(d=>d.id));if(l)throw l;const{data:c}=await F.from("budget_categories").select("name, expects_quote"),u=Object.fromEntries((c||[]).map(d=>[d.name,!!d.expects_quote]));return s.map(d=>({...d,...yk((o||[]).filter(h=>h.experience_id===d.id),u)})).filter(d=>d.unsourced.length>0)}});return e.length?a.jsxs("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1",children:[a.jsxs("p",{className:"text-xs font-medium",children:["Starting within 60 days with unsourced cost lines (",e.length,")"]}),a.jsx("ul",{className:"text-sm space-y-0.5",children:e.map(t=>a.jsxs("li",{children:[a.jsx(Na,{to:`/experiences?id=${t.id}`,className:"hover:underline",children:t.public_name||t.name}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:[" · starts ",t.target_start_date," · ",t.unsourced.length," unsourced (",t.sourced," of ",t.total," sourced)"]})]},t.id))})]}):null}function Gie(){const{data:e=[]}=po(),t=y.useMemo(()=>{const n=new Date().toISOString().slice(0,10);return e.filter(r=>["trip","peer_group"].includes(r.type)&&!["completed","cancelled"].includes(r.status)).map(r=>({...r,_end:r.end_date||r.target_start_date})).filter(r=>r._end&&r._end<n).sort((r,s)=>r._end.localeCompare(s._end))},[e]);return t.length?a.jsxs("div",{className:"mb-6 rounded-lg border bg-card p-4",children:[a.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-2",children:[a.jsx(za,{className:"h-4 w-4 text-destructive"})," Ended but not Completed (",t.length,")"]}),a.jsx("ul",{className:"space-y-1 text-sm",children:t.map(n=>a.jsxs("li",{className:"flex justify-between gap-4",children:[a.jsx(Na,{to:`/experiences?id=${n.id}`,className:"hover:underline",children:n.name}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["Ended ",n._end]})]},n.id))})]}):null}function Vie(){const{data:e}=vp(),{data:t=[]}=Ee({queryKey:["reconciliation-backlog"],enabled:e===!0,queryFn:async()=>{const{data:r,error:s}=await F.from("experiences").select("id, name, completed_at").eq("status","completed").in("type",["trip","peer_group"]).is("reconciled_at",null).order("completed_at",{ascending:!0});if(s)throw s;return r??[]}});if(!e||!t.length)return null;const n=r=>r?Math.floor((Date.now()-new Date(r).getTime())/864e5):null;return a.jsxs("div",{className:"mb-6 rounded-lg border bg-card p-4",children:[a.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-2",children:[a.jsx(B3,{className:"h-4 w-4"})," Complete, not reconciled (",t.length,")"]}),a.jsx("ul",{className:"space-y-1 text-sm",children:t.map(r=>a.jsxs("li",{className:"flex justify-between gap-2",children:[a.jsx(Na,{to:`/experiences?id=${r.id}`,className:"hover:underline font-medium",children:r.name}),a.jsxs("span",{className:"text-muted-foreground",children:[n(r.completed_at)??"â"," days since completion"]})]},r.id))})]})}function Yie(){const{data:e=[]}=Ee({queryKey:["experiences-no-pm"],queryFn:async()=>{const[{data:t,error:n},{data:r,error:s}]=await Promise.all([F.from("experiences").select("id, name, public_name").eq("status","active").order("target_start_date"),F.from("experience_team_roles").select("experience_id").eq("role","project_manager")]);if(n)throw n;if(s)throw s;const i=new Set((r??[]).map(o=>o.experience_id));return(t??[]).filter(o=>!i.has(o.id))}});return e.length===0?null:a.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-3 space-y-1",children:[a.jsxs("p",{className:"text-xs font-medium flex items-center gap-1.5 text-destructive",children:[a.jsx(za,{className:"h-3.5 w-3.5"})," No Project Manager on the Team (",e.length,")"]}),a.jsx("ul",{className:"text-sm space-y-0.5",children:e.map(t=>a.jsxs("li",{children:[a.jsx(Na,{to:`/experiences?id=${t.id}`,className:"hover:underline",children:t.public_name||t.name}),t.public_name&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:[" · ",t.name]})]},t.id))})]})}const JO=e=>
702(e??0).toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),Qie=e=>new Date(e+"T00:00:00").toLocaleDateString("en-US",{month:"short",year:"numeric"});function Xie(){const{data:e}=vp(),{data:t=[]}=Ee({queryKey:["overdue-supplier-payments"],enabled:e===!0,queryFn:async()=>{const s=new Date().toISOString().slice(0,10),{data:i,error:o}=await F.from("experience_budget_item_payments").select("id, amount, due_month, experience_budget_items!inner(name, description, experience_id, suppliers(name), experiences!inner(name, status))").eq("paid",!1).lt("due_month",s).gt("amount",0).order("due_month");if(o)throw o;return(i??[]).filter(l=>{var c,u;return((u=(c=l.experience_budget_items)==null?void 0:c.experiences)==null?void 0:u.status)!=="cancelled"})}}),{data:n=[]}=Ee({queryKey:["closed-unrecorded-lines"],enabled:e===!0,queryFn:async()=>{const{data:s,error:i}=await F.from("experience_budget_items").select("id, name, description, experience_id, experiences!inner(name, status)").eq("is_closed",!0).is("spent_to_date",null);if(i)throw i;return(s??[]).filter(o=>{var l;return((l=o.experiences)==null?void 0:l.status)!=="cancelled"})}});if(!e||!t.length&&!n.length)return null;const r=t.reduce((s,i)=>s+Number(i.amount||0),0);return a.jsxs(a.Fragment,{children:[n.length>0&&a.jsxs("div",{className:"mb-6 rounded-lg border bg-card p-4",children:[a.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-2",children:[a.jsx(za,{className:"h-4 w-4 text-destructive"})," Closed, amount not recorded (",n.length,")"]}),a.jsx("ul",{className:"space-y-1 text-sm",children:n.map(s=>{var i;return a.jsxs("li",{children:[a.jsx(Na,{to:`/experiences?id=${s.experience_id}`,className:"hover:underline font-medium",children:(i=s.experiences)==null?void 0:i.name}),a.jsxs("span",{className:"text-muted-foreground",children:[" · ",s.name,s.description?` â ${s.description}`:""]})]},s.id)})})]}),t.length>0&&a.jsxs("div",{className:"mb-6 rounded-lg border bg-card p-4",children:[a.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-2",children:[a.jsx(za,{className:"h-4 w-4 text-destructive"})," Supplier payments past due, not marked paid (",t.length," · ",JO(r),")"]}),a.jsx("ul",{className:"space-y-1 text-sm",children:t.map(s=>{var o,l;const i=s.experience_budget_items;return a.jsxs("li",{className:"flex justify-between gap-4",children:[a.jsxs("span",{children:[a.jsx(Na,{to:`/experiences?id=${i.experience_id}`,className:"hover:underline font-medium",children:(o=i.experiences)==null?void 0:o.name}),a.jsxs("span",{className:"text-muted-foreground",children:[" · ",i.name,i.description?` â ${i.description}`:"",(l=i.suppliers)!=null&&l.name?` · ${i.suppliers.name}`:""]})]}),a.jsxs("span",{className:"whitespace-nowrap text-xs",children:[a.jsxs("span",{className:"text-destructive",children:["Due ",Qie(s.due_month)]})," · ",JO(Number(s.amount))]})]},s.id)})})]})]})}function vk({open:e,onOpenChange:t,onCreated:n}){const[r,s]=y.useState(""),[i,o]=y.useState(""),[l,c]=y.useState(""),u=at(),{toast:d}=mt(),{data:h}=go(),m=Me({mutationFn:async()=>{const{data:f,error:x}=await F.from("contacts").insert({name:r.trim(),email:i.trim()||null,phone:l.trim()||null,generator_id:(h==null?void 0:h.id)||null}).select("id, name").single();if(x)throw x;return f},onSuccess:f=>{u.invalidateQueries({queryKey:["contacts"]}
702),u.invalidateQueries({queryKey:["contacts-list"]}),u.invalidateQueries({queryKey:["contacts-list-for-referral"]}),t(!1),s(""),o(""),c(""),d({title:"Contact created"}),n==null||n(f)},onError:f=>{d({title:"Error",description:f.message,variant:"destructive"})}});return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"sm:max-w-sm",children:[a.jsx(Ot,{children:a.jsx(At,{className:"font-display text-xl",children:"Quick Add Contact"})}),a.jsxs("form",{onSubmit:f=>{f.preventDefault(),m.mutate()},className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"qa-name",children:"Name *"}),a.jsx(ce,{id:"qa-name",value:r,onChange:f=>s(f.target.value),required:!0,maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"qa-email",children:"Email *"}),a.jsx(ce,{id:"qa-email",type:"email",value:i,onChange:f=>o(f.target.value),maxLength:255,required:!0})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"qa-phone",children:"Phone"}),a.jsx(ce,{id:"qa-phone",value:l,onChange:f=>c(f.target.value),maxLength:30})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Y,{type:"button",variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),a.jsx(Y,{type:"submit",disabled:m.isPending||!r.trim()||!i.trim(),children:m.isPending?"Creatingâ¦":"Create"})]})]})]})})}const Jie=[{value:"note",label:"Note"},{value:"email",label:"Email"},{value:"call",label:"Call"},{value:"meeting",label:"Meeting"},{value:"follow-up",label:"Follow-up"}];function Zie({open:e,onOpenChange:t,activity:n}){const[r,s]=y.useState(""),[i,o]=y.useState("note"),[l,c]=y.useState(""),[u,d]=y.useState(""),[h,m]=y.useState(""),[f,x]=y.useState(""),[g,p]=y.useState(""),[v,b]=y.useState(!1),[w,N]=y.useState(!1),j=at(),{toast:_}=mt(),{data:S=[]}=ps(),{data:P=[]}=po(),{data:k}=go(),{data:C=[]}=Ee({queryKey:["contacts-list"],queryFn:async()=>{const{data:q,error:I}=await F.from("contacts").select("id, name").order("name");if(I)throw I;return q}});y.useEffect(()=>{n?(s(n.description||""),o(n.type||"note"),c(n.due_date?n.due_date.slice(0,10):""),d(n.contact_id||""),m(n.generator_id||""),x(n.experience_id||""),p(n.notes||""),b(n.completed||!1)):e&&(s(""),o("note"),c(""),d(""),m((k==null?void 0:k.id)||""),x(""),p(""),b(!1))},[n,e]);const T=u&&u!=="none"?u:"",O=h&&h!=="none"?h:"",L=f&&f!=="none"?f:"",E=!!T||!!O||!!L,R=Me({mutationFn:async()=>{const q={contact_id:T||null,description:r.trim(),type:i,due_date:l||null,generator_id:O||null,experience_id:L||null,notes:g.trim()||null,completed:v,completed_at:v?new Date().toISOString():null};if(n){const{error:I}=await F.from("activities").update(q).eq("id",n.id);if(I)throw I}else{const{error:I}=await F.from("activities").insert(q);if(I)throw I}},onSuccess:()=>{j.invalidateQueries({queryKey:["all-activities"]}),j.invalidateQueries({queryKey:["activities"]}),t(!1),_({title:n?"Task updated":"Task created"})},onError:q=>{_({title:"Error",description:q.message,variant:"destructive"})}});return a.jsxs(a.Fragment,{children:[a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsx(At,{className:"font-display text-xl",children:n?"Edit Task":"New Task"})}),a.jsxs("form",{onSubmit:q=>{q.preventDefault(),R.mutate()},className:"space-y-4",children:[a.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Contact"}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Kt,{value:u,onValueChange:d,options:C.map(q=>({value:q.id,label:q.name})),placeholder:"Selectâ¦",allowNone:!0,className:"flex-1 h-9 text-xs"}),a.jsx(Y,{type:"button",variant:"outline",size:"icon",className:"h-9 w-9 flex-shrink-0",onClick:()=>N(!0),title:"Add new contact",children:a.jsx(zt,{className:"h-3.5 w-3.5"})})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Generator"}),a.jsx(Kt,{value:h,onValueChange:m,options:S.map(q=>({value:q.id,label:q.name})),placeholder:"Selectâ¦",allowNone:!0,className:"w-full h-9 text-xs"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Experience"}),a.jsx(Kt,{value:f,onValueChange:x,options:P.map(q=>({value:q.id,label:oo(q.name,q.target_start_date)})),placeholder:"Selectâ¦",allowNone:!0,className:"w-full h-9 text-xs"})]})]}),!E&&a.jsx("p",{className:"text-xs text-destructive",children:"At least one of Contact, Generator, or Experience is required."}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"description",children:"Description *"}),a.jsx(ce,{id:"description",value:r,onChange:q=>s(q.target.value),maxLength:500})]}),a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"type",children:"Type"}),a.jsxs(lt,{value:i,onValueChange:o,children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsx(ot,{children:Jie.map(q=>a.jsx(Oe,{value:q.value,children:q.label},q.value))})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"dueDate",children:"Due Date"}
702),a.jsx(ce,{id:"dueDate",type:"date",value:l,onChange:q=>c(q.target.value)})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"notes",children:"Notes"}),a.jsx(qt,{id:"notes",value:g,onChange:q=>p(q.target.value),rows:3,maxLength:2e3})]}),n&&a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:v,onCheckedChange:q=>b(!!q)}),"Mark as completed"]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Y,{type:"button",variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),a.jsx(Y,{type:"submit",disabled:R.isPending||!r.trim()||!E,children:R.isPending?"Savingâ¦":n?"Update":"Create"})]})]})]})}),a.jsx(vk,{open:w,onOpenChange:N,onCreated:q=>d(q.id)})]})}var St=function(){return St=Object.assign||function(t){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},St.apply(this,arguments)};function eoe(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}function zq(e,t,n){for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}function Op(e){return e.mode==="multiple"}function Ap(e){return e.mode==="range"}function Nb(e){return e.mode==="single"}var toe={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function noe(e,t){return Ye(e,"LLLL y",t)}function roe(e,t){return Ye(e,"d",t)}function aoe(e,t){return Ye(e,"LLLL",t)}function soe(e){return"".concat(e)}function ioe(e,t){return Ye(e,"cccccc",t)}function ooe(e,t){return Ye(e,"yyyy",t)}var loe=Object.freeze({__proto__:null,formatCaption:noe,formatDay:roe,formatMonthCaption:aoe,formatWeekNumber:soe,formatWeekdayName:ioe,formatYearCaption:ooe}),coe=function(e,t,n){return Ye(e,"do MMMM (EEEE)",n)},uoe=function(){return"Month: "},doe=function(){return"Go to next month"},hoe=function(){return"Go to previous month"},foe=function(e,t){return Ye(e,"cccc",t)},moe=function(e){return"Week n. ".concat(e)},poe=function(){return"Year: "},goe=Object.freeze({__proto__:null,labelDay:coe,labelMonthDropdown:uoe,labelNext:doe,labelPrevious:hoe,labelWeekNumber:moe,labelWeekday:foe,labelYearDropdown:poe});function xoe(){var e="buttons",t=toe,n=uF,r={},s={},i=1,o={},l=new Date;return{captionLayout:e,classNames:t,formatters:loe,labels:goe,locale:n,modifiersClassNames:r,modifiers:s,numberOfMonths:i,styles:o,today:l,mode:"default"}}function yoe(e){var t=e.fromYear,n=e.toYear,r=e.fromMonth,s=e.toMonth,i=e.fromDate,o=e.toDate;return r?i=ia(r):t&&(i=new Date(t,0,1)),s?o=JC(s):n&&(o=new Date(n,11,31)),{fromDate:i?vl(i):void 0,toDate:o?vl(o):void 0}}var Bq=y.createContext(void 0);function voe(e){var t,n=e.initialProps,r=xoe(),s=yoe(n),i=s.fromDate,o=s.toDate,l=(t=n.captionLayout)!==null&&t!==void 0?t:r.captionLayout;l!=="buttons"&&(!i||!o)&&(l="buttons");var c;(Nb(n)||Op(n)||Ap(n))&&(c=n.onSelect);var u=St(St(St({},r),n),{captionLayout:l,classNames:St(St({},r.classNames),n.classNames),components:St({},n.components),formatters:St(St({},r.formatters),n.formatters),fromDate:i,labels:St(St({},r.labels),n.labels),mode:n.mode||r.mode,modifiers:St(St({},r.modifiers),n.modifiers),modifiersClassNames:St(St({},r.modifiersClassNames),n.modifiersClassNames),onSelect:c,styles:St(St({},r.styles),n.styles),toDate:o});return a.jsx(Bq.Provider,{value:u,children:e.children})}function jn(){var e=y.useContext(Bq);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function Uq(e){var t=jn(),n=t.locale,r=t.classNames,s=t.styles,i=t.formatters.formatCaption;return a.jsx("div",{className:r.caption_label,style:s.caption_label,"aria-live":"polite",role:"presentation",id:e.id,children:i(e.displayMonth,{locale:n})})}function boe(e){return a.jsx("svg",St({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:a.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.7
70278175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function Wq(e){var t,n,r=e.onChange,s=e.value,i=e.children,o=e.caption,l=e.className,c=e.style,u=jn(),d=(n=(t=u.components)===null||t===void 0?void 0:t.IconDropdown)!==null&&n!==void 0?n:boe;return a.jsxs("div",{className:l,style:c,children:[a.jsx("span",{className:u.classNames.vhidden,children:e["aria-label"]}),a.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:u.classNames.dropdown,style:u.styles.dropdown,value:s,onChange:r,children:i}),a.jsxs("div",{className:u.classNames.caption_label,style:u.styles.caption_label,"aria-hidden":"true",children:[o,a.jsx(d,{className:u.classNames.dropdown_icon,style:u.styles.dropdown_icon})]})]})}function woe(e){var t,n=jn(),r=n.fromDate,s=n.toDate,i=n.styles,o=n.locale,l=n.formatters.formatMonthCaption,c=n.classNames,u=n.components,d=n.labels.labelMonthDropdown;if(!r)return a.jsx(a.Fragment,{});if(!s)return a.jsx(a.Fragment,{});var h=[];if(qre(r,s))for(var m=ia(r),f=r.getMonth();f<=s.getMonth();f++)h.push(Pw(m,f));else for(var m=ia(new Date),f=0;f<=11;f++)h.push(Pw(m,f));var x=function(p){var v=Number(p.target.value),b=Pw(ia(e.displayMonth),v);e.onChange(b)},g=(t=u==null?void 0:u.Dropdown)!==null&&t!==void 0?t:Wq;return a.jsx(g,{name:"months","aria-label":d(),className:c.dropdown_month,style:i.dropdown_month,onChange:x,value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:o}),children:h.map(function(p){return a.jsx("option",{value:p.getMonth(),children:l(p,{locale:o})},p.getMonth())})})}function _oe(e){var t,n=e.displayMonth,r=jn(),s=r.fromDate,i=r.toDate,o=r.locale,l=r.styles,c=r.classNames,u=r.components,d=r.formatters.formatYearCaption,h=r.labels.labelYearDropdown,m=[];if(!s)return a.jsx(a.Fragment,{});if(!i)return a.jsx(a.Fragment,{});for(var f=s.getFullYear(),x=i.getFullYear(),g=f;g<=x;g++)m.push(BO(lF(new Date),g));var p=function(b){var w=BO(ia(n),Number(b.target.value));e.onChange(w)},v=(t=u==null?void 0:u.Dropdown)!==null&&t!==void 0?t:Wq;return a.jsx(v,{name:"years","aria-label":h(),className:c.dropdown_year,style:l.dropdown_year,onChange:p,value:n.getFullYear(),caption:d(n,{locale:o}),children:m.map(function(b){return a.jsx("option",{value:b.getFullYear(),children:d(b,{locale:o})},b.getFullYear())})})}function joe(e,t){var n=y.useState(e),r=n[0],s=n[1],i=t===void 0?r:t;return[i,s]}function Noe(e){var t=e.month,n=e.defaultMonth,r=e.today,s=t||n||r||new Date,i=e.toDate,o=e.fromDate,l=e.numberOfMonths,c=l===void 0?1:l;if(i&&xm(i,s)<0){var u=-1*(c-1);s=Ba(i,u)}return o&&xm(s,o)<0&&(s=o),ia(s)}function Soe(){var e=jn(),t=Noe(e),n=joe(t,e.month),r=n[0],s=n[1],i=function(o){var l;if(!e.disableNavigation){var c=ia(o);s(c),(l=e.onMonthChange)===null||l===void 0||l.call(e,c)}};return[r,i]}function Coe(e,t){for(var n=t.reverseMonths,r=t.numberOfMonths,s=ia(e),i=ia(Ba(s,r)),o=xm(i,s),l=[],c=0;c<o;c++){var u=Ba(s,c);l.push(u)}return n&&(l=l.reverse()),l}function koe(e,t){if(!t.disableNavigation){var n=t.toDate,r=t.pagedNavigation,s=t.numberOfMonths,i=s===void 0?1:s,o=r?i:1,l=ia(e);if(!n)return Ba(l,o);var c=xm(n,e);if(!(c<i))return Ba(l,o)}}function Eoe(e,t){if(!t.disableNavigation){var n=t.fromDate,r=t.pagedNavigation,s=t.numberOfMonths,i=s===void 0?1:s,o=r?i:1,l=ia(e);if(!n)return Ba(l,-o);var c=xm(l,n);if(!(c<=0))return Ba(l,-o)}}var Kq=y.createContext(void 0);function Poe(e){var t=jn(),n=Soe(),r=n[0],s=n[1],i=Coe(r,t),o=koe(r,t),l=Eoe(r,t),c=function(h){return i.some(function(m){return ek(h,m)})},u=function(h,m){c(h)||(m&&pF(h,m)?s(Ba(h,1+t.numberOfMonths*-1)):s(h))},d={currentMonth:r,displayMonths:i,goToMonth:s,goToDate:u,previousMonth:l,nextMonth:o,isDateDisplayed:c};return a.jsx(Kq.Provider,{value:d,children:e.children})}function Tp(){var e=y.useContext(Kq);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function ZO(e){var t,n=jn(),r=n.classNames,s=n.styles,i=n.components,o=Tp().goToMonth,l=function(d){o(Ba(d,e.displayIndex?-e.dis
702playIndex:0))},c=(t=i==null?void 0:i.CaptionLabel)!==null&&t!==void 0?t:Uq,u=a.jsx(c,{id:e.id,displayMonth:e.displayMonth});return a.jsxs("div",{className:r.caption_dropdowns,style:s.caption_dropdowns,children:[a.jsx("div",{className:r.vhidden,children:u}),a.jsx(woe,{onChange:l,displayMonth:e.displayMonth}),a.jsx(_oe,{onChange:l,displayMonth:e.displayMonth})]})}function Ooe(e){return a.jsx("svg",St({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:a.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function Aoe(e){return a.jsx("svg",St({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:a.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var fy=y.forwardRef(function(e,t){var n=jn(),r=n.classNames,s=n.styles,i=[r.button_reset,r.button];e.className&&i.push(e.className);var o=i.join(" "),l=St(St({},s.button_reset),s.button);return e.style&&Object.assign(l,e.style),a.jsx("button",St({},e,{ref:t,type:"button",className:o,style:l}))});function Toe(e){var t,n,r=jn(),s=r.dir,i=r.locale,o=r.classNames,l=r.styles,c=r.labels,u=c.labelPrevious,d=c.labelNext,h=r.components;if(!e.nextMonth&&!e.previousMonth)return a.jsx(a.Fragment,{});var m=u(e.previousMonth,{locale:i}),f=[o.nav_button,o.nav_button_previous].join(" "),x=d(e.nextMonth,{locale:i}),g=[o.nav_button,o.nav_button_next].join(" "),p=(t=h==null?void 0:h.IconRight)!==null&&t!==void 0?t:Aoe,v=(n=h==null?void 0:h.IconLeft)!==null&&n!==void 0?n:Ooe;return a.jsxs("div",{className:o.nav,style:l.nav,children:[!e.hidePrevious&&a.jsx(fy,{name:"previous-month","aria-label":m,className:f,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:s==="rtl"?a.jsx(p,{className:o.nav_icon,style:l.nav_icon}):a.jsx(v,{className:o.nav_icon,style:l.nav_icon})}),!e.hideNext&&a.jsx(fy,{name:"next-month","aria-label":x,className:g,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:s==="rtl"?a.jsx(v,{className:o.nav_icon,style:l.nav_icon}):a.jsx(p,{className:o.nav_icon,style:l.nav_icon})})]})}function eA(e){var t=jn().numberOfMonths,n=Tp(),r=n.previousMonth,s=n.nextMonth,i=n.goToMonth,o=n.displayMonths,l=o.findIndex(function(x){return ek(e.displayMonth,x)}),c=l===0,u=l===o.length-1,d=t>1&&(c||!u),h=t>1&&(u||!c),m=function(){r&&i(r)},f=function(){s&&i(s)};return a.jsx(Toe,{displayMonth:e.displayMonth,hideNext:d,hidePrevious:h,nextMonth:s,previousMonth:r,onPreviousClick:m,onNextClick:f})}function Moe(e){var t,n=jn(),r=n.classNames,s=n.disableNavigation,i=n.styles,o=n.captionLayout,l=n.components,c=(t=l==null?void 0:l.CaptionLabel)!==null&&t!==void 0?t:Uq,u;return s?u=a.jsx(c,{id:e.id,displayMonth:e.displayMonth}):o==="dropdown"?u=a.jsx(ZO,{displayMonth:e.displayMonth,id:e.id}):o==="dropdown-buttons"?u=a.jsxs(a.Fragment,{children:[a.jsx(ZO,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),a.jsx(eA,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):u=a.jsxs(a.Fragment,{children:[a.jsx(c,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),a.jsx(eA,{displayMonth:e.displayMonth,id:e.id})]}),a.jsx("div",{className:r.caption,style:i.caption,children:u})}function Doe(e){var t=jn(),n=t.footer,r=t.styles,s=t.classNames.tfoot;return n?a.jsx("tfoot",{className:s,style:r.tfoot,children:a.jsx("tr",{children:a.jsx("td",{colSpan:8,children:n})})}):a.jsx(a.Fragment,{})}function $oe(e,t,n){for(var r=n?Rc(new Date):_i(new Date,{locale:e,weekStartsOn:t}),s=[],i=0;i<7;i++){var o=Tr(r,i);s.push(o)}return s}function Roe(){var e=jn(),t=e.classNames,n=e.styles,r=e.showWeekNumber,s=e.locale,i=e.weekStartsOn,o=e.ISOWeek,l=e.formatters.formatWeekdayName,c=e.labels.labelWeekday,u=$oe(s,i,o);return a.jsxs("tr",{style:n.head_row,className:t.head_row,children:[r&&a.jsx("td",{style:n.head_cell,className:t.head_cell}),u.map(function(d,h){return a.jsx("th",{scope:"col",className:t.head_cell,style:n.head_cell,"aria-label":c(d,{locale:s}),children:l(d,{locale:s})},h)})]})}function Ioe(){var e,t=jn(),n=t.classNames,r=t.styles,s=t.components,i=(e=s==null?void 0:s.HeadRow)!==null&&e!==void 0?e:Roe;return a.jsx("thead",{style:r.head,className:n.head,children:a.jsx(i,{})})}function Loe(e){var t=jn(),n=t.locale,r=t.formatters.formatDay;return a.jsx(a.Fragment,{children:r(e.date,{locale:n})})}var bk=y.createContext(void 0);function Foe(e){if(!Op(e.initialProps)){var t={selected:void 0,modifiers:{disabled:[]}};return a.jsx(bk.Provider,{value:t,children:e.children})}return a.jsx(qoe,{initialProps:e.initialProps,children:e.children})}function qoe(e){var t=e.initialProps,n=e.children,r=t.selected,s=t.min,i=t.max,o=function(u,d,h){var m,f;(m=t.onDayClick)===null||m===void 0||m.call(t,u,d,h);var x=!!(d.selected&&s&&(r==null?void 0:r.length)===s);if(!x){var g=!!(!d.selected&&i&&(r==null?void 0:r.length)===i);if(!g){var p=r?zq([],r):[];if(d.selected){var v=p.findIndex(function(b){return ya(u,b)});p.splice(v,1)}else p.push(u);(f=t.onSelect)===null||f===void 0||f.call(t,p,u,d,h)}}},l={disabled:[]};r&&l.disabled.push(function(u){var d=i&&r.length>i-1,h=r.some(function(m){return ya(m,u)});return!!(d&&!h)});var c={selected:r,onDayClick:o,modifiers:l};return a.jsx(bk.Provider,{value:c,children:n})}function wk(){var e=y.useContext(bk);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function zoe(e,t){var n=t||{},r=n.from,s=n.to;return r&&s?ya(s,e)&&ya(r,e)?void 0:ya(s,e)?{from:s,to:void 0}:ya(r,e)?void 0:m1(r,e)?{from:e,to:s}:{from:r,to:e}:s?m1(e,s)?{from:s,to:e}:{from:e,to:s}:r?pF(e,r)?{from:e,to:r}:{from:r,to:e}:{from:e,to:void 0}}var _k=y.createContext(void 0);function Boe(e){if(!Ap(e.initialProps)){var t={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return a.jsx(_k.Provider,{value:t,children:e.children})}return a.jsx(Uoe,{initialProps:e.initialProps,children:e.children})}function Uoe(e){var t=e.initialProps,n=e.children,r=t.selected,s=r||{},i=s.from,o=s.to,l=t.min,c=t.max,u=function(f,x,g){var p,v;(p=t.onDayClick)===null||p===void 0||p.call(t,f,x,g);var b=zoe(f,r);(v=t.onSelect)===null||v===void 0||v.call(t,b,f,x,g)},d={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(d.range_start=[i],o?(d.range_end=[o],ya(i,o)||(d.range_middle=[{after:i,before:o}])):d.range_end=[i]):o&&(d.range_start=[o],d.range_end=[o]),l&&(i&&!o&&d.disabled.push({after:Af(i,l-1),before:Tr(i,l-1)}),i&&o&&d.disabled.push({after:i,before:Tr(i,l-1)}),!i&&o&&d.disabled.push({after:Af(o,l-1),before:Tr(o,l-1)})),c){if(i&&!o&&(d.disabled.push({before:Tr(i,-c+1)}),d.disabled.push({after:Tr(i,c-1)})),i&&o){var h=fi(o,i)+1,m=c-h;d.disabled.push({before:Af(i,m)}),d.disabled.push({after:Tr(o,m)})}!i&&o&&(d.disabled.push({before:Tr(o,-c+1)}),d.disabled.push({after:Tr(o,c-1)}))}return a.jsx(_k.Provider,{value:{selected:r,onDayClick:u,modifiers:d},children:n})}function jk(){var e=y.useContext(_k);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function gx(e){return Array.isArray(e)?zq([],e):e!==void 0?[e]:[]}function Woe(e){var t={};return Object.entries(e).forEach(function(n){var r=n[0],s=n[1];t[r]=gx(s)}),t}var Ys;(function(e){e.Outside="outside",e.Disabled="disabled",e.Selected="selected",e.Hidden="hidden",e.Today="today",e.RangeStart="range_start",e.RangeEnd="range_end",e.RangeMiddle="range_middle"})(Ys||(Ys={}));var Koe=Ys.Selected,Pi=Ys.Disabled,Hoe=Ys.Hidden,Goe=Ys.Today,Aw=Ys.RangeEnd,Tw=Ys.RangeMiddle,Mw=Ys.RangeStart,Voe=Ys.Outside;function Yoe(e,t,n){var r,s=(r={},r[Koe]=gx(e.selected),r[Pi]=gx(e.disabled),r[Hoe]=gx(e.hidden),r[Goe]=[e.today],r[Aw]=[],r[Tw]=[],r[Mw]=[],r[Voe]=[],r);return e.fromDate&&s[Pi].push({before:e.fromDate}),e.toDate&&s[Pi].push({after:e.toDate}),Op(e)?s[Pi]=s[Pi].concat(t.modifiers[Pi]):Ap(e)&&(s[Pi]=s[Pi].concat(n.modifiers[Pi]),s[Mw]=n.modifiers[Mw],s[Tw]=n.modifiers[Tw],s[Aw]=n.modifiers[Aw]),s}var Hq=y.createContext(void 0);function Qoe(e){var t=jn(),n=wk(),r=jk(),s=Yoe(t,n,r),i=Woe(t.modifiers),o=St(St({},s),i);return a.jsx(Hq.Provider,{value:o,children:e.children})}function Gq(){var e=y.useContext(Hq);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function Xoe(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function Joe(e){return!!(e&&typeof e=="object"&&"from"in e)}function Zoe(e){return!!(e&&typeof e=="object"&&"after"in e)}function ele(e){return!!(e&&typeof e=="object"&&"before"in e)}function tle(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function nle(e,t){var n,r=t.from,s=t.to;if(r&&s){var i=fi(s,r)<0;i&&(n=[s,r],r=n[0],s=n[1]);var o=fi(e,r)>=0&&fi(s,e)>=0;return o}return s?ya(s,e):r?ya(r,e):!1}function rle(e){return XC(e)}
702function ale(e){return Array.isArray(e)&&e.every(XC)}function sle(e,t){return t.some(function(n){if(typeof n=="boolean")return n;if(rle(n))return ya(e,n);if(ale(n))return n.includes(e);if(Joe(n))return nle(e,n);if(tle(n))return n.dayOfWeek.includes(e.getDay());if(Xoe(n)){var r=fi(n.before,e),s=fi(n.after,e),i=r>0,o=s<0,l=m1(n.before,n.after);return l?o&&i:i||o}return Zoe(n)?fi(e,n.after)>0:ele(n)?fi(n.before,e)>0:typeof n=="function"?n(e):!1})}function Nk(e,t,n){var r=Object.keys(t).reduce(function(i,o){var l=t[o];return sle(e,l)&&i.push(o),i},[]),s={};return r.forEach(function(i){return s[i]=!0}),n&&!ek(e,n)&&(s.outside=!0),s}function ile(e,t){for(var n=ia(e[0]),r=JC(e[e.length-1]),s,i,o=n;o<=r;){var l=Nk(o,t),c=!l.disabled&&!l.hidden;if(!c){o=Tr(o,1);continue}if(l.selected)return o;l.today&&!i&&(i=o),s||(s=o),o=Tr(o,1)}return i||s}var ole=365;function Vq(e,t){var n=t.moveBy,r=t.direction,s=t.context,i=t.modifiers,o=t.retry,l=o===void 0?{count:0,lastFocused:e}:o,c=s.weekStartsOn,u=s.fromDate,d=s.toDate,h=s.locale,m={day:Tr,week:td,month:Ba,year:$ne,startOfWeek:function(p){return s.ISOWeek?Rc(p):_i(p,{locale:h,weekStartsOn:c})},endOfWeek:function(p){return s.ISOWeek?cF(p):ZC(p,{locale:h,weekStartsOn:c})}},f=m[n](e,r==="after"?1:-1);r==="before"&&u?f=Rne([u,f]):r==="after"&&d&&(f=Ine([d,f]));var x=!0;if(i){var g=Nk(f,i);x=!g.disabled&&!g.hidden}return x?f:l.count>ole?l.lastFocused:Vq(f,{moveBy:n,direction:r,context:s,modifiers:i,retry:St(St({},l),{count:l.count+1})})}var Yq=y.createContext(void 0);function lle(e){var t=Tp(),n=Gq(),r=y.useState(),s=r[0],i=r[1],o=y.useState(),l=o[0],c=o[1],u=ile(t.displayMonths,n),d=s??(l&&t.isDateDisplayed(l))?l:u,h=function(){c(s),i(void 0)},m=function(p){i(p)},f=jn(),x=function(p,v){if(s){var b=Vq(s,{moveBy:p,direction:v,context:f,modifiers:n});ya(s,b)||(t.goToDate(b,s),m(b))}},g={focusedDay:s,focusTarget:d,blur:h,focus:m,focusDayAfter:function(){return x("day","after")},focusDayBefore:function(){return x("day","before")},focusWeekAfter:function(){return x("week","after")},focusWeekBefore:function(){return x("week","before")},focusMonthBefore:function(){return x("month","before")},focusMonthAfter:function(){return x("month","after")},focusYearBefore:function(){return x("year","before")},focusYearAfter:function(){return x("year","after")},focusStartOfWeek:function(){return x("startOfWeek","before")},focusEndOfWeek:function(){return x("endOfWeek","after")}};return a.jsx(Yq.Provider,{value:g,children:e.children})}function Sk(){var e=y.useContext(Yq);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function cle(e,t){var n=Gq(),r=Nk(e,n,t);return r}var Ck=y.createContext(void 0);function ule(e){if(!Nb(e.initialProps)){var t={selected:void 0};return a.jsx(Ck.Provider,{value:t,children:e.children})}return a.jsx(dle,{initialProps:e.initialProps,children:e.children})}function dle(e){var t=e.initialProps,n=e.children,r=function(i,o,l){var c,u,d;if((c=t.onDayClick)===null||c===void 0||c.call(t,i,o,l),o.selected&&!t.required){(u=t.onSelect)===null||u===void 0||u.call(t,void 0,i,o,l);return}(d=t.onSelect)===null||d===void 0||d.call(t,i,i,o,l)},s={selected:t.selected,onDayClick:r};return a.jsx(Ck.Provider,{value:s,children:n})}function Qq(){var e=y.useContext(Ck);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function hle(e,t){var n=jn(),r=Qq(),s=wk(),i=jk(),o=Sk(),l=o.focusDayAfter,c=o.focusDayBefore,u=o.focusWeekAfter,d=o.focusWeekBefore,h=o.blur,m=o.focus,f=o.focusMonthBefore,x=o.focusMonthAfter,g=o.focusYearBefore,p=o.focusYearAfter,v=o.focusStartOfWeek,b=o.focusEndOfWeek,w=function(I){var $,M,B,W;Nb(n)?($=r.onDayClick)===null||$===void 0||$.call(r,e,t,I):Op(n)?(M=s.onDayClick)===null||M===void 0||M.call(s,e,t,I):Ap(n)?(B=i.onDayClick)===null||B===void 0||B.call(i,e,t,I):(W=n.onDayClick)===null||W===void 0||W.call(n,e,t,I)},N=function(I){var $;m(e),($=n.onDayFocus)===null||$===void 0||$.call(n,e,t,I)},j=function(I){var $;h(),($=n.onDayBlur)===null||$===void 0||$.call(n,e,t,I)},_=function(I){var $;($=n.onDayMouseEnter)===null||$===void 0||$.call(n,e,t,I)},S=function(I){var $;($=n.onDayMouseLeave)===null||$===void 0||$.call(n,e,t,I)},P=function(I){var $;($=n.onDayPointerEnter)===null||$===void 0||$.call(n,e,t,I)},k=function(I){var $;($=n.onDayPointerLeave)===null||$===void 0||$.call(n,e,t,I)},C=function(I){var $;($=n.onDayTouchCancel)===null||$===void 0||$.call(n,e,t,I)},T=function(I){var $;($=n.onDayTouchEnd)===null||$===void 0||$.call(n,e,t,I)},O=function(I){var $;($=n.onDayTouchMove)===null||$===void 0||$.call(n,e,t,I)},L=function(I){var $;($=n.onDayTouchStart)===null||$===void 0||$.call(n,e,t,I)},E=function(I){var $;($=n.onDayKeyUp)===null||$===void 0||$.call(n,e,t,I)},R=function(I){var $;switch(I.key){case"ArrowLeft":I.preventDefault(),I.stopPropagation(),n.dir==="rtl"?l(
702):c();break;case"ArrowRight":I.preventDefault(),I.stopPropagation(),n.dir==="rtl"?c():l();break;case"ArrowDown":I.preventDefault(),I.stopPropagation(),u();break;case"ArrowUp":I.preventDefault(),I.stopPropagation(),d();break;case"PageUp":I.preventDefault(),I.stopPropagation(),I.shiftKey?g():f();break;case"PageDown":I.preventDefault(),I.stopPropagation(),I.shiftKey?p():x();break;case"Home":I.preventDefault(),I.stopPropagation(),v();break;case"End":I.preventDefault(),I.stopPropagation(),b();break}($=n.onDayKeyDown)===null||$===void 0||$.call(n,e,t,I)},q={onClick:w,onFocus:N,onBlur:j,onKeyDown:R,onKeyUp:E,onMouseEnter:_,onMouseLeave:S,onPointerEnter:P,onPointerLeave:k,onTouchCancel:C,onTouchEnd:T,onTouchMove:O,onTouchStart:L};return q}function fle(){var e=jn(),t=Qq(),n=wk(),r=jk(),s=Nb(e)?t.selected:Op(e)?n.selected:Ap(e)?r.selected:void 0;return s}function mle(e){return Object.values(Ys).includes(e)}function ple(e,t){var n=[e.classNames.day];return Object.keys(t).forEach(function(r){var s=e.modifiersClassNames[r];if(s)n.push(s);else if(mle(r)){var i=e.classNames["day_".concat(r)];i&&n.push(i)}}),n}function gle(e,t){var n=St({},e.styles.day);return Object.keys(t).forEach(function(r){var s;n=St(St({},n),(s=e.modifiersStyles)===null||s===void 0?void 0:s[r])}),n}function xle(e,t,n){var r,s,i,o=jn(),l=Sk(),c=cle(e,t),u=hle(e,c),d=fle(),h=!!(o.onDayCl
702ick||o.mode!=="default");y.useEffect(function(){var _;c.outside||l.focusedDay&&h&&ya(l.focusedDay,e)&&((_=n.current)===null||_===void 0||_.focus())},[l.focusedDay,e,n,h,c.outside]);var m=ple(o,c).join(" "),f=gle(o,c),x=!!(c.outside&&!o.showOutsideDays||c.hidden),g=(i=(s=o.components)===null||s===void 0?void 0:s.DayContent)!==null&&i!==void 0?i:Loe,p=a.jsx(g,{date:e,displayMonth:t,activeModifiers:c}),v={style:f,className:m,children:p,role:"gridcell"},b=l.focusTarget&&ya(l.focusTarget,e)&&!c.outside,w=l.focusedDay&&ya(l.focusedDay,e),N=St(St(St({},v),(r={disabled:c.disabled,role:"gridcell"},r["aria-selected"]=c.selected,r.tabIndex=w||b?0:-1,r)),u),j={isButton:h,isHidden:x,activeModifiers:c,selectedDays:d,buttonProps:N,divProps:v};return j}function yle(e){var t=y.useRef(null),n=xle(e.date,e.displayMonth,t);return n.isHidden?a.jsx("div",{role:"gridcell"}):n.isButton?a.jsx(fy,St({name:"day",ref:t},n.buttonProps)):a.jsx("div",St({},n.divProps))}function vle(e){var t=e.number,n=e.dates,r=jn(),s=r.onWeekNumberClick,i=r.styles,o=r.classNames,l=r.locale,c=r.labels.labelWeekNumber,u=r.formatters.formatWeekNumber,d=u(Number(t),{locale:l});if(!s)return a.jsx("span",{className:o.weeknumber,style:i.weeknumber,children:d});var h=c(Number(t),{locale:l}),m=function(f){s(t,n,f)};return a.jsx(fy,{name:"week-number","aria-label":h,className:o.weeknumber,style:i.weeknumber,onClick:m,children:d})}function ble(e){var t,n,r=jn(),s=r.styles,i=r.classNames,o=r.showWeekNumber,l=r.components,c=(t=l==null?void 0:l.Day)!==null&&t!==void 0?t:yle,u=(n=l==null?void 0:l.WeekNumber)!==null&&n!==void 0?n:vle,d;return o&&(d=a.jsx("td",{className:i.cell,style:s.cell,children:a.jsx(u,{number:e.weekNumber,dates:e.dates})})),a.jsxs("tr",{className:i.row,style:s.row,children:[d,e.dates.map(function(h){return a.jsx("td",{className:i.cell,style:s.cell,role:"presentation",children:a.jsx(c,{displayMonth:e.displayMonth,date:h})},Rre(h))})]})}function tA(e,t,n){for(var r=n!=null&&n.ISOWeek?cF(t):ZC(t,n),s=n!=null&&n.ISOWeek?Rc(e):_i(e,n),i=fi(r,s),o=[],l=0;l<=i;l++)o.push(Tr(s,l));var c=o.reduce(function(u,d){var h=n!=null&&n.ISOWeek?dF(d):fF(d,n),m=u.find(function(f){return f.weekNumber===h});return m?(m.dates.push(d),u):(u.push({weekNumber:h,dates:[d]}),u)},[]);return c}function wle(e,t){var n=tA(ia(e),JC(e),t);if(t!=null&&t.useFixedWeeks){var r=Lre(e,t);if(r<6){var s=n[n.length-1],i=s.dates[s.dates.length-1],o=td(i,6-r),l=tA(td(i,1),o,t);n.push.apply(n,l)}}return n}function _le(e){var t,n,r,s=jn(),i=s.locale,o=s.classNames,l=s.styles,c=s.hideHead,u=s.fixedWeeks,d=s.components,h=s.weekStartsOn,m=s.firstWeekContainsDate,f=s.ISOWeek,x=wle(e.displayMonth,{useFixedWeeks:!!u,ISOWeek:f,locale:i,weekStartsOn:h,firstWeekContainsDate:m}),g=(t=d==null?void 0:d.Head)!==null&&t!==void 0?t:Ioe,p=(n=d==null?void 0:d.Row)!==null&&n!==void 0?n:ble,v=(r=d==null?void 0:d.Footer)!==null&&r!==void 0?r:Doe;return a.jsxs("table",{id:e.id,className:o.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!c&&a.jsx(g,{}),a.jsx("tbody",{className:o.tbody,style:l.tbody,children:x.map(function(b){return a.jsx(p,{displayMonth:e.displayMonth,dates:b.dates,weekNumber:b.weekNumber},b.weekNumber)})}),a.jsx(v,{displayMonth:e.displayMonth})]})}function jle(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Nle=jle()?y.useLayoutEffect:y.useEffect,Dw=!1,Sle=0;function nA(){return"react-day-picker-".concat(++Sle)}function Cle(e){var t,n=e??(Dw?nA():null),r=y.useState(n),s=r[0],i=r[1];return Nle(function(){s===null&&i(nA())},[]),y.useEffect(function(){Dw===!1&&(Dw=!0)},[]),(t=e??s)!==null&&t!==void 0?t:void 0}function kle(e){var t,n,r=jn(),s=r.dir,i=r.classNames,o=r.styles,l=r.components,c=Tp().displayMonths,u=Cle(r.id?"".concat(r.id,"-").concat(e.displayIndex):void 0),d=r.id?"".concat(r.id,"-grid-").concat(e.displayIndex):void 0,h=[i.month],m=o.month,f=e.displayIndex===0,x=e.displayIndex===c.length-1,g=!f&&!x;s==="rtl"&&(t=[f,x],x=t[0],f=t[1]),f&&(h.push(i.caption_start),m=St(St({},m),o.caption_start)),x&&(h.push(i.caption_end),m=St(St({},m),o.caption_end)),g&&(h.push(i.caption_between),m=St(St({},m),o.caption_between));
702var p=(n=l==null?void 0:l.Caption)!==null&&n!==void 0?n:Moe;return a.jsxs("div",{className:h.join(" "),style:m,children:[a.jsx(p,{id:u,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),a.jsx(_le,{id:d,"aria-labelledby":u,displayMonth:e.displayMonth})]},e.displayIndex)}function Ele(e){var t=jn(),n=t.classNames,r=t.styles;return a.jsx("div",{className:n.months,style:r.months,children:e.children})}function Ple(e){var t,n,r=e.initialProps,s=jn(),i=Sk(),o=Tp(),l=y.useState(!1),c=l[0],u=l[1];y.useEffect(function(){s.initialFocus&&i.focusTarget&&(c||(i.focus(i.focusTarget),u(!0)))},[s.initialFocus,c,i.focus,i.focusTarget,i]);var d=[s.classNames.root,s.className];s.numberOfMonths>1&&d.push(s.classNames.multiple_months),s.showWeekNumber&&d.push(s.classNames.with_weeknumber);var h=St(St({},s.styles.root),s.style),m=Object.keys(r).filter(function(x){return x.startsWith("data-")}).reduce(function(x,g){var p;return St(St({},x),(p={},p[g]=r[g],p))},{}),f=(n=(t=r.components)===null||t===void 0?void 0:t.Months)!==null&&n!==void 0?n:Ele;return a.jsx("div",St({className:d.join(" "),style:h,dir:s.dir,id:s.id,nonce:r.nonce,title:r.title,lang:r.lang},m,{children:a.jsx(f,{children:o.displayMonths.map(function(x,g){return a.jsx(kle,{displayIndex:g,displayMonth:x},g)})})}))}function Ole(e){var t=e.children,n=eoe(e,["children"]);return a.jsx(voe,{initialProps:n,children:a.jsx(Poe,{children:a.jsx(ule,{initialProps:n,children:a.jsx(Foe,{initialProps:n,children:a.jsx(Boe,{initialProps:n,children:a.jsx(Qoe,{children:a.jsx(lle,{children:t})})})})})})})}function Ale(e){return a.jsx(Ole,St({},e,{children:a.jsx(Ple,{initialProps:e})}))}function kk({className:e,classNames:t,showOutsideDays:n=!0,...r}){return a.jsx(Ale,{showOutsideDays:n,className:Se("p-3",e),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Se(gm({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Se(gm({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:({...s})=>a.jsx(P3,{className:"h-4 w-4"}),IconRight:({...s})=>a.jsx(fp,{className:"h-4 w-4"})},...r})}kk.displayName="Calendar";function Tle(){const[e,t]=y.useState(!1),[n,r]=y.useState(null),[s,i]=y.useState(null),[o,l]=y.useState(null),[c,u]=y.useState("all"),[d,h]=y.useState("open"),{data:m=[]}=ps(),{data:f=[]}=po(),x=ok(f),{data:g}=go(),{data:p}=Qs(),v=at(),{toast:b}=mt();y.useEffect(()=>{o===null&&p!==void 0&&(g?l([g.id]):g===null&&l([]))},[g,o,p]);const{data:w=[],isLoading:N}=Ee({queryKey:["all-activities",o,c],enabled:o!==null,queryFn:async()=>{let R=F.from("activities").select("*, contacts(name, email, phone), generators(name), experiences(name, public_name)").neq("type","form-field").order("due_date",{ascending:!0,nullsFirst:!1});o&&o.length>0&&(R=R.in("generator_id",o)),c&&c!=="all"&&(R=R.eq("experience_id",c));const{data:q,error:I}=await R.limit(200);if(I)throw I;return q}});y.useEffect(()=>{if(s){const R=w.find(q=>q.id===s.id);R&&JSON.stringify(R)!==JSON.stringify(s)?i(R):R||i(null)}},[w]);const j=Me({mutationFn:async R=>{const{error:q}=await F.from("activities").delete().eq("id",R);if(q)throw q},onSuccess:()=>
702{v.invalidateQueries({queryKey:["all-activities"]}),v.invalidateQueries({queryKey:["activities"]}),i(null),b({title:"Task deleted"})}}),_=d==="all"?w:d==="open"?w.filter(R=>!R.completed):w.filter(R=>R.completed),S=Me({mutationFn:async R=>{const q=!R.completed,{error:I}=await F.from("activities").update({completed:q,completed_at:q?new Date().toISOString():null}).eq("id",R.id);if(I)throw I},onSuccess:()=>{v.invalidateQueries({queryKey:["all-activities"]}),v.invalidateQueries({queryKey:["activities"]})}}),[P,k]=y.useState(null),[C,T]=y.useState(!1),O=Me({mutationFn:async({activity:R,selectedDate:q})=>{var K,G,H;const{error:I}=await F.from("activities").update({completed:!0,completed_at:new Date().toISOString()}).eq("id",R.id);if(I)throw I;const $=((K=R.contacts)==null?void 0:K.name)||"",M=((G=R.experiences)==null?void 0:G.public_name)||((H=R.experiences)==null?void 0:H.name)||"",B=["Follow up on next steps"];$&&B.push(`with ${$}`),M&&B.push(`for ${M}`);const W=`${q.getFullYear()}-${String(q.getMonth()+1).padStart(2,"0")}-${String(q.getDate()).padStart(2,"0")}`,{error:A}=await F.from("activities").insert({description:B.join(" "),type:"follow-up",due_date:W,contact_id:R.contact_id||null,generator_id:(g==null?void 0:g.id)||R.generator_id||null,experience_id:R.experience_id||null,notes:R.notes||null});if(A)throw A},onSuccess:()=>{v.invalidateQueries({queryKey:["all-activities"]}),v.invalidateQueries({queryKey:["activities"]}),T(!1),k(null),b({title:"Task closed and new follow-up created"})},onError:R=>{b({title:"Error",description:R.message,variant:"destructive"})}}),L=R=>{r(R),t(!0)},E=()=>{r(null),t(!0)};return a.jsxs(Rr,{children:[a.jsxs("div",{className:"animate-fade-in",children:[a.jsx(Yie,{}),a.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[a.jsx("h2",{className:"text-2xl font-semibold font-display text-foreground",children:"Tasks"}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsxs(lt,{value:d,onValueChange:h,children:[a.jsx(it,{className:"w-28 h-9 text-xs",children:a.jsx(ct,{placeholder:"Status"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"all",children:"All Status"}),a.jsx(Oe,{value:"open",children:"Open"}),a.jsx(Oe,{value:"completed",children:"Completed"})]})]}),a.jsx(xk,{generators:m,selectedIds:o||[],onChange:l,className:"w-40 h-9 text-xs"}),a.jsx(Kt,{value:c,onValueChange:u,options:x,placeholder:"All Experiences",className:"w-36 h-9 text-xs"}),a.jsxs(Y,{onClick:E,size:"sm",children:[a.jsx(zt,{className:"mr-1 h-4 w-4"})," Add Task"]})]})]}),N?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):_.length===0?a.jsx("div",{className:"flex h-48 items-center justify-center rounded-md border border-dashed border-border",children:a.jsx("p",{className:"text-sm text-muted-foreground",children:"No tasks found."})}):a.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[a.jsx("div",{className:s?"lg:col-span-2":"lg:col-span-3",children:a.jsx("div",{className:"space-y-2",children:_.map(R=>a.jsxs(na,{open:C&&P===R.id,onOpenChange:q=>{T(q),q||k(null)},children:[a.jsx(Mle,{activity:R,selected:(s==null?void 0:s.id)===R.id,onSelect:()=>i(R),onToggle:()=>S.mutate(R),onCloseAndNew:()=>{k(R.id),T(!0)}}),a.jsxs(Kr,{className:"w-auto p-0 bg-popover",align:"end",sideOffset:5,children:[a.jsx("div",{className:"p-2 pb-0",children:a.jsx("p",{className:"text-xs font-medium text-muted-foreground px-1",children:"Select due date for follow-up"})}),a.jsx(kk,{mode:"single",selected:void 0,onSelect:q=>{q&&O.mutate({activity:R,selectedDate:q})},className:Se("p-3 pointer-events-auto")})]})]},R.id))})}),s&&a.jsx("div",{className:"lg:col-span-1 self-start sticky top-6",children:a.jsx(Dle,{activity:s,onEdit:()=>L(s),onDelete:()=>j.mutate(s.id),onClose:()=>i(null)})})]}),a.jsxs("div",{className:"mt-6",children:[a.jsx(Hie,{}),a.jsx(Bie,{}),a.jsx(Xie,{}),a.jsx(Vie,{}),a.jsx(Gie,{})]})]}),a.jsx(Zie,{open:e,onOpenChange:R=>{t(R),R||(n&&(s==null?void 0:s.id)===n.id&&v.invalidateQueries({queryKey:["all-activities"]}).then(()=>{}),r(null))},activity:n})]})}function Mle({activity:e,selected:t,onSelect:n,onToggle:r,onCloseAndNew:s}){return a.jsxs("div",{onClick:n,className:Se("flex w-full items-start gap-3 rounded-md px-4 py-3 text-left transition-colors cursor-pointer",t?"bg-secondary border border-border":"hover:bg-secondary/50"),children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:Se("text-sm text-card-foreground",e.completed&&"line-through text-muted-foreground"),children:e.description}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground flex-wrap",children:[e.due_date&&a.jsx("span",{children:Ye(new Date(e.due_date.substring(0,10)+"T00:00:00"),"MMM d, yyyy")}),e.generators&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:e.generators.name})]}),e.experiences&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:e.experiences.public_name||e.experiences.name})]})]}),e.contacts&&a.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground flex-wrap",children:[a.jsx("a",{href:`/contacts?contact=${e.contact_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",onClick:i=>i.stopPropagation(),children:e.contacts.name}),e.contacts.email&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("a",{href:`mailto:${e.contacts.email}`,className:"text-primary hover:underline",onClick:i=>i.stopPropagation(),children:e.contacts.email})]}),e.contacts.phone&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:e.contacts.phone})]})]})]}),a.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",onClick:i=>i.stopPropagation(),children:!e.completed&&a.jsxs(a.Fragment,{children:[a.jsx(ra,{asChild:!0,children:a.jsxs(Y,{variant:"outline",size:"sm",className:"h-7 text-[10px] px-2",onClick:s,children:[a.jsx(I3,{className:"h-3 w-3 mr-1"})," Close & New"]})}),a.jsxs(Y,{variant:"outline",size:"sm",className:"h-7 text-[10px] px-2",onClick:r,children:[a.jsx(Mr,{className:"h-3 w-3 mr-1"})," Mark Complete"]})]})})]})}function Dle({activity:e,onEdit:t,onDelete:n,onClose:r}){return a.jsxs("div",{className:"rounded-md border border-border bg-card p-4 animate-fade-in",children:[a.jsxs("div",{className:"mb-4 flex items-start justify-between",children:[a.jsx("h3",{className:"text-lg font-semibold font-display text-card-foreground truncate pr-2",children:e.description}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:t,children:a.jsx(Rn,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:n,children:a.jsx(pn,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r,children:a.jsx(Ht,{className:"h-3.5 w-3.5"})})]})]}),a.jsxs("div",{className:"space-y-2 text-sm",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-muted-foreground",children:"Status:"}),a.jsx("span",{className:Se("text-xs font-medium",e.completed?"text-muted-foreground":"text-foreground"),children:e.completed?"Completed":"Open"})]}),a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx("span",{children:"Type:"}),a.jsx("span",{className:"text-foreground capitalize",children:e.type})]}),e.due_date&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(rs,{className:"h-3.5 w-3.5"}),a.jsx("span",{children:Ye(new Date(e.due_date.substring(0,10)+"T00:00:00"),"MMM d, yyyy")})]}),e.contacts&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(Ws,{className:"h-3.5 w-3.5"}),a.jsx("a",{href:`/contacts?contact=${e.contact_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:e.contacts.name}),e.contacts.email&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("a",{href:`mailto:${e.contacts.email}`,className:"text-primary hover:underline",children:e.contacts.email})]}),e.contacts.phone&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:e.contacts.phone})]})]}),e.generators&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(Kv,{className:"h-3.5 w-3.5"}),a.jsx("span",{children:e.generators.name})]}),e.experiences&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(rs,{className:"h-3.5 w-3.5"}),a.jsx("span",{children:e.experiences.public_name||e.experiences.name})]}),a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(pl,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Created ",Ye(new Date(e.created_at),"MMM d, yyyy")]})]}),e.completed_at&&a.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[a.jsx(pl,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Completed ",Ye(new Date(e.completed_at),"MMM d, yyyy")]})]}),e.notes&&a.jsxs("div",{className:"pt-2 border-t border-border",children:[a.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Notes"}),a.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:e.notes})]})]})]})}var Sb="Tabs",[$le,b3e]=jr(Sb,[vb]),Xq=vb(),[Rle,Ek]=$le(Sb),Jq=y.forwardRef((e,t)=>
vendor: 5,381 bytes, line 702
702{const{__scopeTabs:n,value:r,onValueChange:s,defaultValue:i,orientation:o="horizontal",dir:l,activationMode:c="automatic",...u}=e,d=mh(l),[h,m]=oa({prop:r,onChange:s,defaultProp:i??"",caller:Sb});return a.jsx(Rle,{scope:n,baseId:Zn(),value:h,onValueChange:m,orientation:o,dir:d,activationMode:c,children:a.jsx(tt.div,{dir:d,"data-orientation":o,...u,ref:t})})});Jq.displayName=Sb;var Zq="TabsList",e6=y.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...s}=e,i=Ek(Zq,n),o=Xq(n);return a.jsx(zF,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:a.jsx(tt.div,{role:"tablist","aria-orientation":i.orientation,...s,ref:t})})});e6.displayName=Zq;var t6="TabsTrigger",n6=y.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:s=!1,...i}=e,o=Ek(t6,n),l=Xq(n),c=s6(o.baseId,r),u=i6(o.baseId,r),d=r===o.value;return a.jsx(BF,{asChild:!0,...l,focusable:!s,active:d,children:a.jsx(tt.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:c,...i,ref:t,onMouseDown:Fe(e.onMouseDown,h=>{!s&&h.button===0&&h.ctrlKey===!1?o.onValueChange(r):h.preventDefault()}),onKeyDown:Fe(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&o.onValueChange(r)}),onFocus:Fe(e.onFocus,()=>{const h=o.activationMode!=="manual";!d&&!s&&h&&o.onValueChange(r)})})})});n6.displayName=t6;var r6="TabsContent",a6=y.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:s,children:i,...o}=e,l=Ek(r6,n),c=s6(l.baseId,r),u=i6(l.baseId,r),d=r===l.value,h=y.useRef(d);return y.useEffect(()=>{const m=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(m)},[]),a.jsx(tr,{present:s||d,children:({present:m})=>a.jsx(tt.div,{"data-state":d?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!m,id:u,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:m&&i})})});a6.displayName=r6;function s6(e,t){return`${e}-trigger-${t}`}function i6(e,t){return`${e}-content-${t}`}var Ile=Jq,o6=e6,l6=n6,c6=a6;const Pk=Ile,Cb=y.forwardRef(({className:e,...t},n)=>a.jsx(o6,{ref:n,className:Se("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Cb.displayName=o6.displayName;const Zr=y.forwardRef(({className:e,...t},n)=>a.jsx(l6,{ref:n,className:Se("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",e),...t}));Zr.displayName=l6.displayName;const Ja=y.forwardRef(({className:e,...t},n)=>a.jsx(c6,{ref:n,className:Se("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Ja.displayName=c6.displayName;var kb="Switch",[Lle,w3e]=jr(kb),[Fle,qle]=Lle(kb),u6=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:s,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:u,form:d,...h}=e,[m,f]=y.useState(null),x=Ct(t,w=>f(w)),g=y.useRef(!1),p=m?d||!!m.closest("form"):!0,[v,b]=oa({prop:s,defaultProp:i??!1,onChange:u,caller:kb});return a.jsxs(Fle,{scope:n,checked:v,disabled:l,children:[a.jsx(tt.button,{type:"button",role:"switch","aria-checked":v,"aria-required":o,"data-state":m6(v),"data-disabled":l?"":void 0,disabled:l,value:c,...h,ref:x,onClick:Fe(e.onClick,w=>{b(N=>!N),p&&(g.current=w.isPropagationStopped(),g.current||w.stopPropagation())})}),p&&a.jsx(f6,{control:m,bubbles:!g.current,name:r,value:c,checked:v,required:o,disabled:l,form:d,style:{transform:"translateX(-100%)"}})]})});u6.displayName=kb;var d6="SwitchThumb",h6=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,s=qle(d6,n);return a.jsx(tt.span,{"data-state":m6(s.checked),"data-disabled":s.disabled?"":void 0,...r,ref:t})});h6.displayName=d6;var zle="SwitchBubbleInput",f6=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...s},i)=>{const o=y.useRef(null),l=Ct(o,i),c=DC(n),u=yC(t);return y.useEffect(()=>{const d=o.current;if(!d)return;const h=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(h,"checked").set;if(c!==n&&f){const x=new Event("click",{bubbles:r});f.call(d,n),d.dispatchEvent(x)}},[c,n,r]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:l,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});f6.displayName=zle;function m6(e){return e?"checked":"unchecked"}var p6=u6,Ble=h6;const ta=y.forwardRef(({className:e,...t},n)=>a.jsx(p6,{className:Se("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...t,ref:n,children:a.jsx(Ble,{className:Se("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}
702));ta.displayName=p6.displayName;const Ule=new Set(["the","a","an","la","le","les","el","il","lo","der","die","das"]);function _1(e){const t=e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean);for(;t.length>1&&Ule.has(t[0]);)t.shift();return t}const rA=e=>_1(e).join(" ");function Wle(e,t){const n=_1(e);if(!n.length)return 1;const r=_1(t),s=[...r].sort().join(" ");if([...n].sort().join(" ")===s)return 100;let i=0;for(const o of n)r.some(l=>l.startsWith(o)||o.length>=4&&l.includes(o))&&i++;return i<n.length?0:50+Math.round(i/Math.max(r.length,1)*40)}function Eb({experienceId:e,value:t,onChange:n,disabled:r,className:s}){const i=at(),{toast:o}=mt(),[l,c]=y.useState(""),[u,d]=y.useState(!1),[h,m]=y.useState(0),[f,x]=y.useState(!1),g=y.useRef(),{data:p=[]}=Ee({queryKey:["suppliers-options"],queryFn:async()=>{const{data:C}=await F.from("suppliers").select("id, name, type").order("name");return C||[]}}),{data:v}=Ee({queryKey:["supplier-usage",e],queryFn:async()=>{var q;const C=F,{data:T}=e?await C.from("experiences").select("location").eq("id",e).maybeSingle():{data:null},O=((T==null?void 0:T.location)||"").split(",")[0].trim().toLowerCase(),{data:L}=await C.from("experience_budget_items").select("supplier_id, experiences(location)").not("supplier_id","is",null),E=new Set,R=new Set;for(const I of L||[]){E.add(I.supplier_id);const $=(((q=I.experiences)==null?void 0:q.location)||"").split(",")[0].trim().toLowerCase();O&&$===O&&R.add(I.supplier_id)}return{any:E,here:R}}}),b=p.find(C=>C.id===t),w=y.useMemo(()=>{const C=T=>v!=null&&v.here.has(T)?0:v!=null&&v.any.has(T)?1:2;return p.map(T=>({s:T,score:Wle(l,T.name)})).filter(T=>T.score>0).sort((T,O)=>(l.trim()?O.score-T.score:0)||C(T.s.id)-C(O.s.id)||T.s.name.localeCompare(O.s.name)).slice(0,8)},[p,l,v]),N=l.trim()&&p.some(C=>rA(C.name)===rA(l)),j=!!l.trim()&&!N,_=w.length+(j?1:0),S=C=>{n(C),c(""),d(!1)},P=async()=>{const C=l.trim();if(!C||f)return;x(!0);const{data:T,error:O}=await F.from("suppliers").insert({name:C}).select("id").single();if(x(!1),O)return o({title:"Could not add supplier",description:O.message,variant:"destructive"});await i.invalidateQueries({queryKey:["suppliers-options"]}),S(T.id)},k=C=>C<w.length?S(w[C].s.id):P();return b&&!u?a.jsxs("div",{className:Se("flex items-center gap-1 h-8 rounded-md border border-input px-2 text-xs",r&&"opacity-60",s),children:[a.jsx("button",{type:"button",disabled:r,className:"flex-1 text-left truncate",onClick:()=>{d(!0),c("")},children:b.name}),!r&&a.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>S(null),"aria-label":"Clear supplier",children:a.jsx(Ht,{className:"h-3 w-3"})})]}):a.jsxs("div",{className:Se("relative",s),children:[a.jsx(ce,{autoFocus:!!b,disabled:r,className:"h-8 text-xs",placeholder:"Type a supplier nameâ¦",value:l,onFocus:()=>d(!0),onBlur:()=>{g.current=window.setTimeout(()=>d(!1),150)},onChange:C=>{c(C.target.value),m(0),d(!0)},onKeyDown:C=>{C.key==="ArrowDown"?(C.preventDefault(),m(T=>Math.min(T+1,_-1))):C.key==="ArrowUp"?(C.preventDefault(),m(T=>Math.max(T-1,0))):C.key==="Enter"?(C.preventDefault(),_&&k(Math.min(h,_-1))):C.key==="Escape"&&d(!1)}}),u&&_>0&&a.jsxs("div",{className:"absolute z-50 mt-1 w-full rounded-md border border-border bg-popover shadow-md max-h-64 overflow-y-auto",onMouseDown:C=>{C.preventDefault(),window.clearTimeout(g.current)},children:[w.map((C,T)=>a.jsxs("button",{type:"button",className:Se("w-full text-left px-2 py-1.5 text-xs flex justify-between gap-2",T===h&&"bg-accent"),onMouseEnter:()=>m(T),onClick:()=>k(T),children:[a.jsx("span",{className:"truncate",children:C.s.name}),a.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:v!=null&&v.here.has(C.s.id)?"used here":v!=null&&v.any.has(C.s.id)?"used before":""})]},C.s.id)),j&&a.jsxs("button",{type:"button",className:Se("w-full text-left px-2 py-1.5 text-xs border-t border-border flex items-center gap-1",h===w.length&&"bg-accent"),onMouseEnter:()=>m(w.length),onClick:()=>P(),children:[a.jsx(zt,{className:"h-3 w-3"}),' Create "',l.trim(),'"']})]})]})}function g6(){return Ee({queryKey:["supplier-access"],queryFn:async()=>{const[e,t,n]=await Promise.all([F.rpc("is_admin"),F.rpc("is_employee_generator"),F.rpc("is_any_experience_pm")]);return e.data===!0||t.data===!0||n.data===!0}})}const aA=["Outfitter","Hotel","Transfer","Restaurant","Materials/Swag vendor","Other"],Kle=["Full-service","Piecemeal","N/A"],sA={name:"",type:"Outfitter",service_level:"N/A",contact_name:"",contact_email:"",contact_phone:"",destinations:[],quote_lead_time_days:"",pays_commission:!1,notes:""};function $w(e){if(!e)return"â";const[t,n,r]=e.split("-").map(Number);return Ye(new Date(t,n-1,r),"MMM d, yyyy")}function Hle(){const e=at(),{toast:t}=mt(),{data:n,isLoading:r}=g6(),[s,i]=y.useState(""),[o,l]=y.useState("all"),[c,u]=y.useState(!1),[d,h]=y.useState(null),[m,f]=y.useState(sA),[x,g]=y.useState(""),[p,v]=y.useState(null),[b,w]=y.useState(null),[N,j]=y.useState(!1),[_,S]=y.useState(null),[P,k]=y.useState(null),{data:C=new Set}=Ee({queryKey:["suppliers-booked"],enabled:n===!0,queryFn:async()=>{const{data:A}=await F.from("experience_budget_items").select("supplier_id, confirmed_date, is_closed, estimate_status").not("supplier_id","is",null);return new Set((A||[]).filter(K=>K.confirmed_date||K.is_closed||["Contracted","Actual"].includes(K.estimate_status)).map(K=>K.supplier_id))}}),T=Me({mutationFn:async()=>{const{error:A}=await F.rpc("merge_suppliers",{_from:_.id,_to:P});if(A)throw A},onSuccess:()=>{t({title:"Suppliers merged",description:"Every budget line and quote now points at the kept supplier."}
702),S(null),k(null),v(null),e.invalidateQueries({queryKey:["suppliers"]}),e.invalidateQueries({queryKey:["suppliers-options"]}),e.invalidateQueries({queryKey:["suppliers-booked"]})},onError:A=>t({title:"Could not merge",description:A.message,variant:"destructive"})}),{data:O=[],isLoading:L}=Ee({queryKey:["suppliers"],enabled:n===!0,queryFn:async()=>{const{data:A,error:K}=await F.from("suppliers").select("*").order("name");if(K)throw K;return A||[]}});y.useEffect(()=>{if(p){const A=O.find(K=>K.id===p.id);A&&A!==p&&v(A)}},[O]);const{data:E=[]}=Ee({queryKey:["supplier-trips",p==null?void 0:p.id],enabled:!!(p!=null&&p.id),queryFn:async()=>{const{data:A,error:K}=await F.from("experience_budget_items").select("id, name, amount, experience_id, experiences(id, name, target_start_date, end_date, status)").eq("supplier_id",p.id);if(K)throw K;return A||[]}}),R=y.useMemo(()=>{const A=new Map;for(const K of E){const G=K.experiences;if(!G)continue;const H=A.get(G.id)||{id:G.id,name:G.name,date:G.end_date||G.target_start_date||null,lines:[]};H.lines.push(K.name),A.set(G.id,H)}return Array.from(A.values()).sort((K,G)=>(G.date||"").localeCompare(K.date||""))},[E]),q=O.filter(A=>{if(!N&&!C.has(A.id)&&!A.contact_name&&!A.contact_email&&!A.contact_phone||o!=="all"&&A.type!==o)return!1;if(!s.trim())return!0;const K=s.toLowerCase();return A.name.toLowerCase().includes(K)||(A.contact_name||"").toLowerCase().includes(K)||(A.contact_email||"").toLowerCase().includes(K)||(A.destinations||[]).some(G=>G.toLowerCase().includes(K))}),I=()=>{h(null),f(sA),g(""),u(!0)},$=A=>{h(A),f({name:A.name,type:A.type,service_level:A.service_level,contact_name:A.contact_name||"",contact_email:A.contact_email||"",contact_phone:A.contact_phone||"",destinations:A.destinations||[],quote_lead_time_days:A.quote_lead_time_days==null?"":String(A.quote_lead_time_days),pays_commission:A.pays_commission,notes:A.notes||""}),g(""),u(!0)},M=Me({mutationFn:async()=>{if(!m.name.trim())throw new Error("Name is required");const A={name:m.name.trim(),type:m.type,service_level:m.service_level,contact_name:m.contact_name.trim()||null,contact_email:m.contact_email.trim()||null,contact_phone:m.contact_phone.trim()||null,destinations:m.destinations,quote_lead_time_days:m.quote_lead_time_days===""?null:Number(m.quote_lead_time_days),pays_commission:m.pays_commission,notes:m.notes.trim()||null};if(d){const{error:K}=await F.from("suppliers").update(A).eq("id",d.id);if(K)throw K}else{const{error:K}=await F.from("suppliers").insert(A);if(K)throw K}},onSuccess:()=>{e.invalidateQueries({queryKey:["suppliers"]}),u(!1),t({title:d?"Supplier updated":"Supplier added"})},onError:A=>t({title:"Could not save",description:A.message,variant:"destructive"})}),B=Me({mutationFn:async A=>{const{error:K}=await F.from("suppliers").delete().eq("id",A);if(K)throw K},onSuccess:(A,K)=>{e.invalidateQueries({queryKey:["suppliers"]}),(p==null?void 0:p.id)===K&&v(null),t({title:"Supplier deleted"})},onError:A=>t({title:"Could not delete",description:A.message,variant:"destructive"})}),W=()=>{const A=x.trim();A&&(m.destinations.includes(A)||f(K=>({...K,destinations:[...K.destinations,A]})),g(""))};return r?a.jsx(Rr,{children:a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"})}):n?a.jsxs(Rr,{children:[a.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[a.jsxs("h1",{className:"text-xl font-semibold flex items-center gap-2",children:[a.jsx(NH,{className:"h-5 w-5"})," Suppliers"]}),a.jsxs(Y,{size:"sm",onClick:I,children:[a.jsx(zt,{className:"h-4 w-4 mr-1"})," Add supplier"]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[a.jsx(ce,{placeholder:"Search suppliers, contacts or destinationsâ¦",value:s,onChange:A=>i(A.target.value),className:"max-w-xs h-9"}),a.jsxs(lt,{value:o,onValueChange:l,children:[a.jsx(it,{className:"h-9 w-[200px]",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"all",children:"All types"}),aA.map(A=>a.jsx(Oe,{value:A,children:A},A))]})]}),a.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[a.jsx(ta,{checked:N,onCheckedChange:j})," Show all (",O.length,")"]})]}),!N&&a.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Showing suppliers with a completed booking or a contact recorded."}),a.jsx(Dt,{open:!!_,onOpenChange:A=>{A||(S(null),k(null))},children:a.jsxs(Pt,{className:"max-w-md",children:[a.jsxs(Ot,{children:[a.jsxs(At,{children:['Merge "',_==null?void 0:_.name,'" intoâ¦']}),a.jsxs(wr,{children:['Every budget line and quote using "',_==null?void 0:_.name,'" moves to the supplier you pick, then "',_==null?void 0:_.name,'" is removed.']})]}),a.jsx(Eb,{value:P,onChange:A=>k(A===(_==null?void 0:_.id)?null:A)}),a.jsxs(br,{children:[a.jsx(Y,{variant:"outline",onClick:()=>S(null),children:"Cancel"}),a.jsx(Y,{disabled:!P||T.isPending,onClick:()=>T.mutate(),children:"Merge"})]})]})}),L?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):q.length===0?a.jsx("p",{className:"text-sm text-muted-foreground",children:N?"No suppliers yet.":"No booked or c
702ontacted suppliers match â turn on Show all."}):a.jsx("div",{className:"rounded-lg border border-border divide-y divide-border",children:q.map(A=>a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 hover:bg-muted/50 cursor-pointer",onClick:()=>v(A),children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("span",{className:"font-medium text-sm truncate",children:A.name}),a.jsx(Ge,{variant:"outline",className:"text-[10px]",children:A.type}),A.service_level!=="N/A"&&a.jsx(Ge,{variant:"secondary",className:"text-[10px]",children:A.service_level}),A.pays_commission&&a.jsx(Ge,{variant:"outline",className:"text-[10px]",children:"Pays commission"})]}),a.jsxs("div",{className:"text-xs text-muted-foreground truncate mt-0.5",children:[(A.destinations||[]).join(", ")||"No destinations",A.contact_name?` · ${A.contact_name}`:""]})]}),a.jsxs("div",{className:"text-xs text-muted-foreground hidden sm:block whitespace-nowrap",children:["Last used ",$w(A.last_used)]}),a.jsx(Y,{variant:"ghost",size:"sm",title:"Merge into another supplier",onClick:K=>{K.stopPropagation(),S(A)},children:a.jsx(dH,{className:"h-4 w-4"})}),a.jsx(Y,{variant:"ghost",size:"sm",onClick:K=>{K.stopPropagation(),$(A)},children:a.jsx(Rn,{className:"h-4 w-4"})}),a.jsx(Y,{variant:"ghost",size:"sm",onClick:K=>{K.stopPropagation(),b===A.id?(B.mutate(A.id),w(null)):(w(A.id),setTimeout(()=>w(G=>G===A.id?null:G),3e3))},children:a.jsx(pn,{className:b===A.id?"h-4 w-4 text-destructive":"h-4 w-4"})})]},A.id))}),a.jsx(Dt,{open:!!p,onOpenChange:A=>!A&&v(null),children:a.jsx(Pt,{className:"max-w-xl max-h-[85vh] overflow-y-auto",children:p&&a.jsxs(a.Fragment,{children:[a.jsx(Ot,{children:a.jsxs(At,{className:"flex items-center gap-2 flex-wrap",children:[p.name,a.jsx(Ge,{variant:"outline",className:"text-[10px]",children:p.type})]})}),a.jsxs("div",{className:"space-y-4 text-sm",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Service level"}),a.jsx("p",{children:p.service_level})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Quote lead time"}),a.jsx("p",{children:p.quote_lead_time_days==null?"â":`${p.quote_lead_time_days} days`})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Pays commission"}),a.jsx("p",{children:p.pays_commission?"Yes":"No"})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Last used"}),a.jsx("p",{children:$w(p.last_used)})]})]}),(p.contact_name||p.contact_email||p.contact_phone)&&a.jsxs("div",{className:"space-y-1",children:[p.contact_name&&a.jsxs("p",{className:"flex items-center gap-2",children:[a.jsx(Ws,{className:"h-3.5 w-3.5 text-muted-foreground"}),p.contact_name]}),p.contact_email&&a.jsxs("p",{className:"flex items-center gap-2",children:[a.jsx(fs,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.jsx("a",{className:"text-primary underline",href:`mailto:${p.contact_email}`,children:p.contact_email})]}),p.contact_phone&&a.jsxs("p",{className:"flex items-center gap-2",children:[a.jsx(lC,{className:"h-3.5 w-3.5 text-muted-foreground"}),p.contact_phone]})]}),(p.destinations||[]).length>0&&a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx(zi,{className:"h-3.5 w-3.5 text-muted-foreground"}),p.destinations.map(A=>a.jsx(Ge,{variant:"secondary",className:"text-[10px]",children:A},A))]}),p.notes&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Notes"}),a.jsx("p",{className:"whitespace-pre-wrap text-sm",children:p.notes})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Trips used on"}),R.length===0?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Not linked to any trip yet."}):a.jsx("div",{className:"rounded border border-border divide-y divide-border",children:R.map(A=>a.jsxs("div",{className:"px-3 py-2",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsx("span",{className:"text-sm font-medium",children:A.name}),a.jsx("span",{className:"text-xs text-muted-foreground",children:$w(A.date)})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:A.lines.join(", ")})]},A.id))})]})]}),a.jsx(br,{children:a.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>{const A=p;v(null),$(A)},children:[a.jsx(Rn,{className:"h-4 w-4 mr-1"})," Edit"]})})]})})}),a.jsx(Dt,{open:c,onOpenChange:u,children:a.jsxs(Pt,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsx(At,{children:d?"Edit supplier":"Add supplier"})}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Name *"}),a.jsx(ce,{value:m.name,onChange:A=>f(K=>({...K,name:A.target.value}))})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Type"}),a.jsxs(lt,{value:m.type,onValueChange:A=>f(K=>({...K,type:A})),children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsx(ot,{children:aA.map(A=>a.jsx(Oe,{value:A,children:A},A))})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Service level"}),a.jsxs(lt,{value:m.service_level,onValueChange:A=>f(K=>({...K,service_level:A})),children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsx(ot,{children:Kle.map(A=>a.jsx(Oe,{value:A,children:A},A))})]}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Full-service handles lodging, meals and transfers end to end."})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Contact name"}),a.jsx(ce,{value:m.contact_name,onChange:A=>f(K=>({...K,contact_name:A.target.value}))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Contact phone"}),a.jsx(ce,{value:m.contact_phone,onChange:A=>f(K=>({...K,contact_phone:A.target.value}))})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Contact email"}),a.jsx(ce,{type:"email",value:m.contact_email,onChange:A=>f(K=>({...K,contact_email:A.target.value}))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Destinations"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1",children:m.destinations.map(A=>a.jsxs(Ge,{variant:"secondary",className:"text-[10px] gap-1",children:[A,a.jsx("button",{type:"button",onClick:()=>f(K=>({...K,destinations:K.destinations.filter(G=>G!==A)})),children:a.jsx(Ht,{className:"h-3 w-3"})})]},A))}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(ce,{value:x,placeholder:"Add a destination and press Enter",onChange:A=>g(A.target.value),onKeyDown:A=>{(A.key==="Enter"||A.key===",")&&(A.preventDefault(),W())}}),a.jsx(Y,{type:"button",variant:"outline",size:"sm",onClick:W,children:"Add"})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3 items-end",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Quote lead time (days)"}),a.jsx(ce,{type:"text",inputMode:"numeric",value:m.quote_lead_time_days,onChange:A=>f(K=>({...K,quote_lead_time_days:A.target.value.replace(/[^0-9]/g,"")}))})]}),a.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[a.jsx(ta,{checked:m.pays_commission,onCheckedChange:A=>f(K=>({...K,pays_commission:A}))}),a.jsx(xe,{className:"text-xs",children:"Pays commission"})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Notes"}),a.jsx(qt,{className:"min-h-[80px]",value:m.notes,onChange:A=>f(K=>({...K,notes:A.target.value}))})]})]}),a.jsxs(br,{children:[a.jsx(Y,{variant:"outline",onClick:()=>u(!1),children:"Cancel"}),a.jsx(Y,{onClick:()=>M.mutate(),disabled:M.isPending,children:d?"Save":"Add supplier"})]})]})})]}):a.jsx(Rr,{children:a.jsxs("div",{className:"py-16 text-center",children:[a.jsx("h1",{className:"text-lg font-semibold",children:"Suppliers"}),a.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"You don't have access to this page."})]})})}const Gle=["jpg","jpeg","png","webp"],Vle=["heic","heif"],Yle=10*1024*1024;function x6(e){const t=(e.name.split(".").pop()||"").toLowerCase();return Vle.includes(t)||/hei[cf]/i.test(e.type)?"HEIC/HEIF images aren't supported. On iPhone, set Camera â Formats â Most Compatible, or export the photo as JPG first.":e.size?t&&!Gle.includes(t)||e.type&&!e.type.startsWith("image/")?"Please upload a JPG, PNG, or WebP image.":e.size>Yle?`That image is ${(e.size/(1024*1024)).toFixed(1)} MB. Please upload an image under 10 MB.`:null:"That file came through empty (0 bytes). If it's in iCloud or Google Photos, download it to this device first, then upload again."}function Qle(e){return e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/_+/g,"_").replace(/^[._-]+|[._-]+$/g,"").slice(0,180)||"image"}function Xle(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}
702function Pg(e){let t=Xle(e);return t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),"<em>$1</em>"),t=t.replace(/==([^=]+)==/g,'<mark class="bg-accent/40 px-1 rounded">$1</mark>'),t}function Ok(e){const t=e.replace(/\r\n/g,` 703`).split(` 704`),n=[];let r=0,s=null,i=!1;const o=()=>{i&&(n.push("</ul></li>"),i=!1),s&&(n.push("</ul>"),s=null)};for(;r<t.length;){const c=t[r];if(/^\s*$/.test(c)){o(),r++;continue}if(/^---+\s*$/.test(c)){o(),n.push('<hr class="my-4 border-border"/>'),r++;continue}const u=c.match(/^(#{1,3})\s+(.*)$/);if(u){o();const m=u[1].length,f=m===1?"text-xl font-semibold mt-4 mb-2":m===2?"text-lg font-semibold mt-4 mb-2":"text-base font-semibold mt-3 mb-1";n.push(`<h${m} class="${f}">${Pg(u[2])}</h${m}>`),r++;continue}const d=c.match(/^(\s{2,})- (.*)$/),h=c.match(/^- (.*)$/);if(h){s||(n.push('<ul class="list-disc pl-6 space-y-1 my-2">'),s="ul"),i&&(n.push("</ul></li>"),i=!1),n.push(`<li>${Pg(h[1])}`);const m=t[r+1];m&&/^\s{2,}- /.test(m)?(n.push('<ul class="list-disc pl-6 space-y-1 my-1">'),i=!0):n.push("</li>"),r++;continue}if(d&&i){n.push(`<li>${Pg(d[2])}</li>`);const m=t[r+1];(!m||!/^\s{2,}- /.test(m))&&(n.push("</ul></li>"),i=!1),r++;continue}o(),n.push(`<p class="my-2 leading-relaxed">${Pg(c)}</p>`),r++}return o(),n.join(` 705`)}function Jle({canEdit:e}){const[t,n]=y.useState(!1),[r,s]=y.useState(""),[i,o]=y.useState("preview"),l=at(),{toast:c}=mt(),{data:u}=Ee({queryKey:["generator-agreement-template"],queryFn:async()=>{const{data:h,error:m}=await F.from("generator_agreement_template").select("*").order("updated_at",{ascending:!1}).limit(1).maybeSingle();if(m)throw m;return h},enabled:t});y.useEffect(()=>{u!=null&&u.body_markdown&&s(u.body_markdown)},[u==null?void 0:u.body_markdown]);const d=Me({mutationFn:async()=>{if(u){const{error:h}=await F.from("generator_agreement_template").update({body_markdown:r}).eq("id",u.id);if(h)throw h}else{const{error:h}=await F.from("generator_agreement_template").insert({body_markdown:r});if(h)throw h}},onSuccess:()=>{l.invalidateQueries({queryKey:["generator-agreement-template"]}),c({title:"Template saved"})},onError:h=>c({title:"Save failed",description:h.message,variant:"destructive"})});return a.jsxs(Dt,{open:t,onOpenChange:n,children:[a.jsx(qC,{asChild:!0,children:a.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1.5",children:[a.jsx(Hs,{className:"h-4 w-4"})," Agreement Template"]})}),a.jsxs(Pt,{className:"max-w-3xl max-h-[90vh] flex flex-col",children:[a.jsx(Ot,{children:a.jsx(At,{className:"font-display",children:"Generator Agreement Template"})}),a.jsxs("div",{className:"flex items-center gap-2 border-b pb-2",children:[a.jsxs(Y,{variant:i==="preview"?"secondary":"ghost",size:"sm",onClick:()=>o("preview"),className:"gap-1.5",children:[a.jsx(D3,{className:"h-4 w-4"})," Preview"]}),e&&a.jsxs(Y,{variant:i==="edit"?"secondary":"ghost",size:"sm",onClick:()=>o("edit"),className:"gap-1.5",children:[a.jsx(Rn,{className:"h-4 w-4"})," Edit"]}),a.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:"Markdown supported: **bold**, *italic*, # headings, - lists, ==highlight=="})]}),a.jsx("div",{className:"overflow-auto flex-1 -mx-6 px-6",children:i==="preview"?a.jsx("div",{className:"prose prose-sm max-w-none text-sm",dangerouslySetInnerHTML:{__html:Ok(r||"")}}):a.jsx(qt,{value:r,onChange:h=>s(h.target.value),className:"min-h-[60vh] font-mono text-xs"})}),e&&i==="edit"&&a.jsx("div",{className:"flex justify-end pt-2 border-t",children:a.jsx(Y,{onClick:()=>d.mutate(),disabled:d.isPending,children:d.isPending?"Savingâ¦":"Save Template"})})]})]})}function y6(e){return fa((e??[]).filter(t=>nce(t.status)&&!t.is_comped&&Xn(t.effective_price)>0).reduce((t,n)=>t+Xn(n.effective_price),0))}const xx=e=>Number.isFinite(e)?e/100:0,Xn=e=>Number.isFinite(e)?e:0;function Pb(e,t,n=0){var x;const r=Xn(e.trip_price_snapshot),s=((x=e.quality_invite_ids)==null?void 0:x.length)??0,i=s>=e.invite_bonus_threshold,o=i?r*xx(Xn(e.invite_bonus_pct)):0,l=(t??[]).filter(g=>g.counts_as_recruit),c=l.reduce((g,p)=>g+Xn(p.effective_price),0),u=c*xx(Xn(e.recruitment_share_pct)),d=o+u,h=Math.min(d,r),m=Xn(n)*xx(Xn(e.host_guide_pct??0)),f=Math.max(0,d-r)+m;
705return{qualityInviteCount:s,meetsInviteThreshold:i,inviteCredit:fa(o),recruitedCount:l.length,recruitedRevenue:fa(c),recruitmentCredit:fa(u),confirmedRevenue:fa(Xn(n)),hostGuideCredit:fa(m),totalCredit:fa(d),totalEarnings:fa(d+m),tripOffset:fa(h),cashPayout:fa(f),recruitingCashPayout:fa(Math.max(0,d-r)),tripFullyComped:r>0&&d>=r}}function v6(e,t,n,r){const s=Math.max(0,Math.floor(Xn(t))),i=Xn(n),o=Math.max(1,Math.floor(Xn((r==null?void 0:r.generatorCount)??1))),l=Math.max(0,Math.min(s,Math.floor(Xn((r==null?void 0:r.compedGeneratorSeats)??1)))),u=Math.max(0,s-o)/o,d=fa(Math.max(0,s-l)*i),h=[{contact_experience_id:"planned",effective_price:fa(u*i),counts_as_recruit:!0}],m=Math.max(0,Math.floor(Xn(e.invite_bonus_threshold))),f={...e,quality_invite_ids:Array.from({length:m},(g,p)=>`planned-invite-${p}`)};return{...Pb(f,h,d),recruitedCount:Math.round(u*100)/100}}function my(e,t,n){const r=Math.max(1,e.length);let s=new Set(e.filter(o=>Xn(o.agreement.invite_bonus_pct)>=100&&Xn(o.agreement.invite_bonus_threshold)<=0).map(o=>o.id)),i=new Map;for(let o=0;o<4;o++){i=new Map(e.map(c=>[c.id,v6(c.agreement,t,n,{generatorCount:r,compedGeneratorSeats:s.size})]));const l=new Set(e.filter(c=>i.get(c.id).tripFullyComped).map(c=>c.id));if(l.size===s.size&&[...l].every(c=>s.has(c)))break;s=l}return i}function iA(e,t){return fa(Math.max(Xn(e),Xn(t)))}function Zle(e,t,n){const r=xx(Xn(e.recruitment_share_pct));if(r<=0||n<=0)return null;const s=Xn(e.trip_price_snapshot)-t;return s<=0?0:Math.ceil(s/(n*r))}function fa(e){return Math.round(e*100)/100}const ece=["accepted"];function j1(e){return!!e&&ece.includes(e)}const tce=["accepted","gen_guide"];function nce(e){return!!e&&tce.includes(e)}const ko=e=>Math.round(e*100)/100;function b6(){return Ee({staleTime:5*60*1e3,gcTime:30*60*1e3,refetchOnWindowFocus:!1,queryKey:["generator-earnings"],queryFn:async()=>{var k;const[{data:e},{data:t},{data:n},{data:r,error:s},{data:i,error:o},{data:l,error:c},{data:u,error:d},{data:h,error:m},{data:f,error:x}]=await Promise.all([F.rpc("is_admin"),F.rpc("is_employee_generator"),F.rpc("get_current_generator_id"),F.from("generator_experience_comp").select("experience_id, generator_id, invite_bonus_pct, invite_bonus_threshold, recruitment_share_pct, trip_price_snapshot, quality_invite_ids, host_guide_pct"),F.from("experiences").select("id, name, status, price"),F.from("contact_experiences").select("id, experience_id, status, custom_price, contacts(email, generator_id)"),F.from("contact_experience_addons").select("contact_experience_id, experience_addons(price, third_party_payer)"),F.from("generators").select("id, name, email"),F.from("generator_payouts").select("generator_id, experience_id, amount")]);for(const C of[s,o,c,d,m,x])if(C)throw C;const g=e===!0||t===!0,p=new Map((i??[]).map(C=>[C.id,C])),v=new Map((h??[]).map(C=>[C.id,C])),b=new Map;for(const C of u??[]){const T=C.experience_addons;if(!T||T.third_party_payer)continue;const O=C.contact_experience_id;b.set(O,(b.get(O)??0)+Number(T.price||0))}const w=new Map;for(const C of r??[]){const T=(((k=v.get(C.generator_id))==null?void 0:k.email)||"").toLowerCase();if(!T)continue;const O=w.get(C.experience_id)??new Set;O.add(T),w.set(C.experience_id,O)}const N=new Map;for(const C of l??[]){const T=N.get(C.experience_id)??[];T.push(C),N.set(C.experience_id,T)}const j=new Map;for(const C of f??[]){const T=`${C.generator_id}:${C.experience_id??"none"}`;j.set(T,(j.get(T)??0)+Number(C.amount||0))}const _=[];for(const C of r??[]){if(!g&&C.generator_id!==n)continue;const T=p.get(C.experience_id);if(!T||T.status==="cancelled")continue;const O=v.get(C.generator_id);if(!O)continue;const L=N.get(T.id)??[],E=W=>Number(W.custom_price??T.price??0)+(b.get(W.id)??0),R=w.get(T.id)??new Set,q=L.find(W=>{var A;return(((A=W.contacts)==null?void 0:A.email)||"").toLowerCase()===(O.email||"").toLowerCase()}),I=L.filter(W=>{var A;return((A=W.contacts)==null?void 0:A.generator_id)===O.id&&W.id!==(q==null?void 0:q.id)}).map(W=>({contact_experience_id:W.id,effective_price:E(W),counts_as_recruit:j1(W.status)})),$=y6(L.map(W=>{var A;return{status:W.status,effective_price:E(W),is_comped:W.status==="gen_guide"||R.has((((A=W.contacts)==null?void 0:A.email)||"").toLowerCase())}})),M=Pb({invite_bonus_pct:Number(C.invite_bonus_pct)||0,invite_bonus_threshold:Number(C.invite_bonus_threshold)||0,recruitment_share_pct:Number(C.recruitment_share_pct)||0,trip_price_snapshot:Number(C.trip_price_snapshot)||0,quality_invite_ids:C.quality_invite_ids??[],host_guide_pct:Number(C.host_guide_pct)||0},I,$),B=j.get(`${O.id}:${T.id}`)??0;_.push({generator_id:O.id,generator_name:O.name,experience_id:T.id,experience_name:T.name,experience_status:T.status,experience_closed:T.status==="completed"||T.status==="closed",confirmedRevenue:M.confirmedRevenue,invite
705Credit:M.inviteCredit,recruitmentCredit:M.recruitmentCredit,hostGuideFee:M.hostGuideCredit,hostGuidePct:Number(C.host_guide_pct)||0,tripOffset:M.tripOffset,earned:M.cashPayout,paid:ko(B),owed:ko(M.cashPayout-B)})}const S=new Map;for(const C of _){const T=S.get(C.generator_id)??[];T.push(C),S.set(C.generator_id,T)}const P=Array.from(S.entries()).map(([C,T])=>{const O=ko(T.reduce((E,R)=>E+R.earned,0)),L=ko(T.reduce((E,R)=>E+R.paid,0));return{generator_id:C,generator_name:T[0].generator_name,earned:O,paid:L,owed:ko(O-L),rows:T.sort((E,R)=>R.owed-E.owed)}}).sort((C,T)=>T.owed-C.owed||C.generator_name.localeCompare(T.generator_name));return{rows:_,byGenerator:P,totalEarned:ko(P.reduce((C,T)=>C+T.earned,0)),totalPaid:ko(P.reduce((C,T)=>C+T.paid,0)),totalOwed:ko(P.reduce((C,T)=>C+T.owed,0))}}})}const ks=e=>e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2});function rce({canEdit:e}){const[t,n]=y.useState(!1),[r,s]=y.useState({}),[i,o]=y.useState(null),{data:l,isLoading:c}=b6(),{data:u=[]}=Ee({queryKey:["generator-payouts"],enabled:t,queryFn:async()=>{const{data:h,error:m}=await F.from("generator_payouts").select("id, generator_id, experience_id, amount, paid_on, method, note").order("paid_on",{ascending:!1});if(m)throw m;return h??[]}}),d=y.useMemo(()=>{const h=new Map;for(const m of u){const f=`${m.generator_id}:${m.experience_id??"none"}`,x=h.get(f)??[];x.push(m),h.set(f,x)}return h},[u]);return a.jsxs(Dt,{open:t,onOpenChange:n,children:[a.jsx(qC,{asChild:!0,children:a.jsxs(Y,{variant:"outline",size:"sm",children:[a.jsx(H3,{className:"mr-1 h-4 w-4"})," Payouts"]})}),a.jsxs(Pt,{className:"max-w-3xl",children:[a.jsxs(Ot,{children:[a.jsx(At,{className:"font-display text-xl",children:"Team Payouts"}),a.jsx(wr,{children:"Cash earned from recruiting overages and Host/Guide fees, less payouts recorded."})]}),c||!l?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{label:"Earned",value:l.totalEarned},{label:"Paid",value:l.totalPaid},{label:"Owed",value:l.totalOwed}].map(h=>a.jsxs("div",{className:"rounded-md border border-border p-3",children:[a.jsx("div",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:h.label}),a.jsx("div",{className:"text-lg font-semibold tabular-nums",children:ks(h.value)})]},h.label))}),a.jsx(Ic,{className:"max-h-[55vh] pr-3",children:a.jsxs("div",{className:"space-y-1",children:[l.byGenerator.length===0&&a.jsx("p",{className:"text-sm text-muted-foreground italic py-6 text-center",children:"No compensation agreements yet."}),l.byGenerator.map(h=>{const m=!!r[h.generator_id];return a.jsxs("div",{className:"rounded-md border border-border",children:[a.jsxs("button",{className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-secondary/50",onClick:()=>s(f=>({...f,[h.generator_id]:!m})),children:[a.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[m?a.jsx(_n,{className:"h-4 w-4 text-muted-foreground"}):a.jsx(fp,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium truncate",children:h.generator_name}),a.jsxs(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[h.rows.length," ",h.rows.length===1?"experience":"experiences"]})]}),a.jsxs("span",{className:"flex items-center gap-4 text-xs tabular-nums flex-shrink-0",children:[a.jsxs("span",{className:"text-muted-foreground",children:["Earned ",ks(h.earned)]}),a.jsxs("span",{className:"text-muted-foreground",children:["Paid ",ks(h.paid)]}),a.jsxs("span",{className:Se("font-semibold",h.owed>0?"text-foreground":"text-muted-foreground"),children:["Owed ",ks(h.owed)]})]})]}),m&&a.jsx("div",{className:"border-t border-border divide-y divide-border",children:h.rows.map(f=>{const x=`${f.generator_id}:${f.experience_id}`,g=d.get(x)??[];return a.jsxs("div",{className:"px-3 py-2 space-y-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-sm truncate",children:f.experience_name}),a.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Recruiting overage ",ks(Math.max(0,f.earned-f.hostGuideFee)),f.hostGuidePct>0&&a.jsxs(a.Fragment,{children:[" · ","Host/Guide ",f.hostGuidePct,"% of ",ks(f.confirmedRevenue)," ="," ",ks(f.hostGuideFee)]})]})]}),a.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0 text-xs tabular-nums",children:[a.jsxs("span",{className:"text-muted-foreground",children:["Paid ",ks(f.paid)]}),a.jsx("span",{className:"font-semibold",children:ks(f.owed)}),e&&a.jsx(Y,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",onClick:()=>o(f),children:"Record"})]})]}),g.length>0&&a.jsx("div",{className:"space-y-0.5 pl-1",children:g.map(p=>a.jsx(ace,{payout:p,canEdit:e},p.id))})]},f.experience_id)})})]},h.generator_id)})]})})]}),i&&a.jsx(sce,{row:i,open:!!i,onOpenChange:h=>!h&&o(null)})]})]})}function ace({payout:e,canEdit:t}){const n=at(),{toast:r}=mt(),[s,i]=y.useState(!1),o=Me({mutationFn:async()=>{const{error:l}=await F.from("generator_payouts").delete().eq("id",e.id);if(l)throw l},onSuccess:()=>{n.invalidateQueries({queryKey:["generator-payouts"]}),n.invalidateQueries({queryKey:["generator-earnings"]}
705),r({title:"Payout deleted"})},onError:l=>r({title:"Error",description:l.message,variant:"destructive"})});return a.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[a.jsxs("span",{className:"truncate",children:[e.paid_on,e.method?` · ${e.method}`:"",e.note?` · ${e.note}`:""]}),a.jsxs("span",{className:"flex items-center gap-1 flex-shrink-0 tabular-nums",children:[ks(Number(e.amount)),t&&a.jsx(Y,{variant:"ghost",size:"icon",className:Se("h-6 w-6",s&&"text-destructive"),onClick:()=>s?o.mutate():i(!0),onBlur:()=>i(!1),title:s?"Click again to delete":"Delete payout",children:a.jsx(pn,{className:"h-3 w-3"})})]})]})}function sce({row:e,open:t,onOpenChange:n}){const r=at(),{toast:s}=mt(),[i,o]=y.useState(e.owed>0?String(e.owed):""),[l,c]=y.useState(new Date().toISOString().slice(0,10)),[u,d]=y.useState(""),[h,m]=y.useState(""),f=Me({mutationFn:async()=>{var v;const x=parseFloat(i);if(!Number.isFinite(x)||x===0)throw new Error("Enter a payout amount");const{data:g}=await F.auth.getUser(),{error:p}=await F.from("generator_payouts").insert({generator_id:e.generator_id,experience_id:e.experience_id,amount:x,paid_on:l,method:u.trim()||null,note:h.trim()||null,created_by:((v=g==null?void 0:g.user)==null?void 0:v.id)??null});if(p)throw p},onSuccess:()=>{r.invalidateQueries({queryKey:["generator-payouts"]}),r.invalidateQueries({queryKey:["generator-earnings"]}),s({title:"Payout recorded"}),n(!1)},onError:x=>s({title:"Error",description:x.message,variant:"destructive"})});return a.jsx(Dt,{open:t,onOpenChange:n,children:a.jsxs(Pt,{className:"sm:max-w-sm",children:[a.jsxs(Ot,{children:[a.jsx(At,{className:"font-display text-lg",children:"Record Payout"}),a.jsxs(wr,{children:[e.generator_name," · ",e.experience_name," · owed ",ks(e.owed)]})]}),a.jsxs("form",{className:"space-y-3",onSubmit:x=>{x.preventDefault(),f.mutate()},children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Amount *"}),a.jsx(ce,{type:"text",inputMode:"decimal",value:i,onChange:x=>o(x.target.value),placeholder:"0.00"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Date paid"}),a.jsx(ce,{type:"date",value:l,onChange:x=>c(x.target.value)})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Method"}),a.jsx(ce,{value:u,onChange:x=>d(x.target.value),placeholder:"Check, ACH, Venmoâ¦",maxLength:50})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Note"}),a.jsx(ce,{value:h,onChange:x=>m(x.target.value),maxLength:200})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[a.jsx(Y,{type:"button",variant:"ghost",onClick:()=>n(!1),children:"Cancel"}),a.jsx(Y,{type:"submit",disabled:f.isPending,children:f.isPending?"Savingâ¦":"Record"})]})]})]})})}function ice({canEdit:e}){const[t,n]=y.useState(!1),r=at(),{toast:s}=mt(),{data:i}=Ee({queryKey:["app-settings"],queryFn:async()=>{const{data:g,error:p}=await F.from("app_settings").select("zoom_link, zoom_host_key, zoom_username, zoom_password").eq("id",1).maybeSingle();if(p)throw p;return g}}),[o,l]=y.useState(""),[c,u]=y.useState(""),[d,h]=y.useState(""),[m,f]=y.useState("");y.useEffect(()=>{i&&(l(i.zoom_link||""),u(i.zoom_host_key||""),h(i.zoom_username||""),f(i.zoom_password||""))},[i,t]);const x=Me({mutationFn:async()=>{const{error:g}=await F.from("app_settings").update({zoom_link:o.trim()||null,zoom_host_key:c.trim()||null,zoom_username:d.trim()||null,zoom_password:m.trim()||null,updated_at:new Date().toISOString()}).eq("id",1);if(g)throw g},onSuccess:()=>{r.invalidateQueries({queryKey:["app-settings"]}),s({title:"Zoom defaults saved"}),n(!1)},onError:g=>s({title:"Save failed",description:g.message,variant:"destructive"})});return a.jsxs(Dt,{open:t,onOpenChange:n,children:[a.jsx(qC,{asChild:!0,children:a.jsxs(Y,{variant:"outline",size:"sm",children:[a.jsx(nm,{className:"mr-1 h-4 w-4"})," Zoom Defaults"]})}),a.jsxs(Pt,{children:[a.jsxs(Ot,{children:[a.jsx(At,{children:"Zoom Defaults"}),a.jsx(wr,{children:"The link is shared with all participants on virtual dates. The host key and login are only visible to Guides on the public portal."})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Zoom link"}),a.jsx(ce,{value:o,onChange:g=>l(g.target.value),placeholder:"https://zoom.us/j/...",disabled:!e})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Host key"}),a.jsx(ce,{value:c,onChange:g=>u(g.target.value),placeholder:"6-digit host key",disabled:!e})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Zoom username"}),a.jsx(ce,{value:d,onChange:g=>h(g.target.value),disabled:!e})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Zoom password"}),a.jsx(ce,{value:m,onChange:g=>f(g.target.value),disabled:!e})]})]})]}),e&&a.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[a.jsx(Y,{variant:"ghost",onClick:()=>n(!1),children:"Cancel"}),a.jsx(Y,{onClick:()=>x.mutate(),disabled:x.isPending,children:"Save"})]})]})]})}function oce(){const[e,t]=y.useState(!1),[n,r]=y.useState(null),[s,i]=y.useState(null),o=at(),{toast:l}=mt(),{data:c=[],isLoading:u}=Ee({queryKey:["generators"],queryFn:async()=>{const{data:p,error:v}=await F.from("generators").select("*").order("name");if(v)throw v;return p}});y.useEffect(()=>{if(s){const p=c.find(v=>v.id===s.id);
705p&&(p.bio!==s.bio||p.headshot_url!==s.headshot_url||p.updated_at!==s.updated_at)&&i(p)}},[c,s]);const{data:d={}}=Ee({queryKey:["generator-admin-statuses",c.map(p=>p.email)],enabled:c.length>0,queryFn:async()=>{const p={};for(const v of c){const{data:b}=await F.rpc("is_generator_admin",{_generator_email:v.email});p[v.id]=b===!0}return p}}),{data:h=!1}=Ee({queryKey:["current-user-is-admin"],queryFn:async()=>{const{data:p}=await F.rpc("is_admin");return p===!0}}),m=Me({mutationFn:async({email:p,isAdmin:v})=>{const b=v?"revoke_admin_by_email":"grant_admin_by_email",{error:w}=await F.rpc(b,{_email:p});if(w)throw w},onSuccess:()=>{o.invalidateQueries({queryKey:["generator-admin-statuses"]}),l({title:"Admin status updated"})},onError:p=>l({title:"Error",description:p.message,variant:"destructive"})}),f=Me({mutationFn:async p=>{const{error:v}=await F.from("generators").delete().eq("id",p);if(v)throw v},onSuccess:()=>{o.invalidateQueries({queryKey:["generators"]}),i(null),l({title:"Generator deleted"})}}),x=p=>{r(p),t(!0)},g=()=>{r(null),t(!0)};return a.jsx(Rr,{children:a.jsxs(dce,{children:[a.jsxs("div",{className:"animate-fade-in",children:[a.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[a.jsx("h2",{className:"text-2xl font-semibold font-display text-foreground",children:"Team"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ice,{canEdit:h}),a.jsx(rce,{canEdit:h}),a.jsx(Jle,{canEdit:h}),h&&a.jsx(Y,{variant:"outline",size:"sm",asChild:!0,children:a.jsx(Na,{to:"/settings/budget-categories",children:"Budget categories"})}),h&&a.jsxs(Y,{onClick:g,size:"sm",children:[a.jsx(zt,{className:"mr-1 h-4 w-4"})," Team Member"]})]})]}),u?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):c.length===0?a.jsx("div",{className:"flex h-48 items-center justify-center rounded-md border border-dashed border-border",children:a.jsx("p",{className:"text-sm text-muted-foreground",children:"No generators yet. Add your first one."})}):a.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[a.jsx("div",{className:s?"lg:col-span-2":"lg:col-span-3",children:a.jsx("div",{className:"space-y-1",children:c.map(p=>a.jsxs("button",{onClick:()=>i(p),className:Se("flex w-full items-center justify-between rounded-md px-4 py-3 text-left transition-colors",(s==null?void 0:s.id)===p.id?"bg-secondary border border-border":"hover:bg-secondary/50"),children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium text-sm text-foreground",children:p.name}),h&&a.jsx(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0 capitalize",children:p.type}),!p.active&&a.jsx(Ge,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Inactive"}),d[p.id]&&a.jsxs(Ge,{variant:"default",className:"text-[10px] px-1.5 py-0 gap-0.5",children:[a.jsx(Gx,{className:"h-3 w-3"})," Admin"]})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[a.jsx("span",{children:p.email}),p.phone&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:p.phone})]})]})]}),a.jsx("div",{className:"flex items-center gap-1 ml-2 flex-shrink-0",onClick:v=>v.stopPropagation(),children:h&&a.jsxs(a.Fragment,{children:[a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>m.mutate({email:p.email,isAdmin:!!d[p.id]}),disabled:m.isPending,children:[a.jsx(Gx,{className:"h-3.5 w-3.5"}),d[p.id]?"Remove Admin":"Make Admin"]}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>x(p),children:a.jsx(Rn,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>f.mutate(p.id),children:a.jsx(pn,{className:"h-3.5 w-3.5"})})]})})]},p.id))})}),s&&a.jsx("div",{className:"lg:col-span-1 self-start sticky top-6",children:a.jsx(lce,{generator:s,onEdit:()=>x(s),onDelete:()=>f.mutate(s.id),onClose:()=>i(null),isAdmin:h})})]})]}),a.jsx(uce,{open:e,onOpenChange:t,generator:n})]})})}function lce({generator:e,onEdit:t,onDelete:n,onClose:r,isAdmin:s}){const i=at(),{toast:o}=mt(),{data:l=[]}=po(),{data:c=[]}=Ee({queryKey:["generator-contacts",e.id],queryFn:async()=>{const{data:j,error:_}=await F.from("contacts").select("id, name, email, company").eq("generator_id",e.id).order("name");if(_)throw _;return j}}),{data:u=[]}=Ee({queryKey:["generator-experiences",e.id],queryFn:async()=>{const[{data:j,error:_},{data:S,error:P}]=await Promise.all([F.from("generator_experiences").select("id, experience_id, experiences(name, public_name, status, type)").eq("generator_id",e.id),F.from("experiences").select("id, name, status, type").eq("project_manager_id",e.id)]);if(_)throw _;if(P)throw P;const k=j||[],C=new Set(k.map(O=>O.experience_id)),T=(S||[]).filter(O=>!C.has(O.id)).map(O=>({id:`pm-${O.id}`,experience_id:O.id,experiences:{name:O.name,status:O.status,type:O.type},_pmOnly:!0}));return[...k,...T]}}),{data:d=[]}=Ee({queryKey:["generator-activities",e.id],queryFn:async()=>{const{data:j,error:_}=await F.from("activities").select("id, description, type, completed, due_date, contacts(name), experiences(name, public_name)").eq("generator_id",e.id).order("due_date",{ascending:!0,nullsFirst:!1});if(_)throw _;return j}}),h=new Set(u.map(j=>j.experience_id)),[m,f]=y.useState(""),[x,g]=y.useState(""),p=Me({mutationFn:async()=>
705{if(!m||m==="none")return;const{error:j}=await F.from("generator_experiences").insert({generator_id:e.id,experience_id:m});if(j)throw j},onSuccess:()=>{i.invalidateQueries({queryKey:["generator-experiences",e.id]}),f(""),o({title:"Experience added"})}}),v=Me({mutationFn:async j=>{const{error:_}=await F.from("generator_experiences").delete().eq("id",j);if(_)throw _},onSuccess:()=>i.invalidateQueries({queryKey:["generator-experiences",e.id]})}),b=Me({mutationFn:async()=>{if(!x.trim())return;const{error:j}=await F.from("activities").insert({description:x.trim(),generator_id:e.id});if(j)throw j},onSuccess:()=>{i.invalidateQueries({queryKey:["generator-activities",e.id]}),i.invalidateQueries({queryKey:["all-activities"]}),g(""),o({title:"Task added"})}}),w=Me({mutationFn:async j=>{const{error:_}=await F.from("activities").delete().eq("id",j);if(_)throw _},onSuccess:()=>{i.invalidateQueries({queryKey:["generator-activities",e.id]}),i.invalidateQueries({queryKey:["all-activities"]})}}),N=Me({mutationFn:async j=>{const _=!j.completed,{error:S}=await F.from("activities").update({completed:_,completed_at:_?new Date().toISOString():null}).eq("id",j.id);if(S)throw S},onSuccess:()=>{i.invalidateQueries({queryKey:["generator-activities",e.id]}),i.invalidateQueries({queryKey:["all-activities"]})}});return a.jsxs("div",{className:"rounded-md border border-border bg-card p-4 animate-fade-in space-y-4",children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold font-display text-card-foreground",children:e.name}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[a.jsx("span",{children:e.email}),e.phone&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"·"}),a.jsx("span",{children:e.phone})]})]})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s&&a.jsxs(a.Fragment,{children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:t,children:a.jsx(Rn,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:n,children:a.jsx(pn,{className:"h-3.5 w-3.5"})})]}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r,children:a.jsx(Ht,{className:"h-3.5 w-3.5"})})]})]}),a.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[s&&a.jsx(Ge,{variant:"outline",className:"text-xs capitalize",children:e.type}),!e.active&&a.jsx(Ge,{variant:"secondary",className:"text-xs",children:"Inactive"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(pl,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Added ",Ye(new Date(e.created_at),"MMM d, yyyy")]})]})]}),a.jsx(cce,{generator:e}),a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:["Contacts (",c.length,")"]}),a.jsxs("div",{className:"space-y-1 mb-2",children:[c.map(j=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Ws,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.jsx("span",{children:j.name}),j.company&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",j.company]})]},j.id)),c.length===0&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"No contacts assigned."})]})]}),a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:["Experiences (",u.length,")"]}),a.jsx("div",{className:"space-y-1 mb-2",children:u.map(j=>{var _,S;return a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(aC,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.jsx("span",{children:((_=j.experiences)==null?void 0:_.public_name)||((S=j.experiences)==null?void 0:S.name)}),j._pmOnly&&a.jsx(Ge,{variant:"outline",className:"text-[10px] py-0 px-1.5",children:"PM"})]}),!j._pmOnly&&a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>v.mutate(j.id),children:a.jsx(Ht,{className:"h-3 w-3"})})]},j.id)})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Kt,{value:m,onValueChange:f,options:l.filter(j=>!h.has(j.id)).map(j=>({value:j.id,label:oo(j.name,j.target_start_date)})),placeholder:"Add experienceâ¦",className:"flex-1 h-8 text-xs"}),a.jsx(Y,{size:"sm",className:"h-8 px-2",onClick:()=>p.mutate(),disabled:!m||m==="none",children:a.jsx(zt,{className:"h-3.5 w-3.5"})})]})]}),a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:["Tasks (",d.length,")"]}),a.jsx("div",{className:"space-y-1 mb-2",children:d.map(j=>a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(gt,{checked:j.completed,onCheckedChange:()=>N.mutate(j),className:"flex-shrink-0"}),a.jsx("span",{className:Se("truncate",j.completed&&"line-through text-muted-foreground"),children:j.description})]}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive flex-shrink-0",onClick:()=>w.mutate(j.id),children:a.jsx(Ht,{className:"h-3 w-3"})})]},j.id))}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(ce,{value:x,onChange:j=>g(j.target.value),placeholder:"New taskâ¦",className:"flex-1 h-8 text-xs",maxLength:500,onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),b.mutate())}}),a.jsx(Y,{size:"sm",className:"h-8 px-2",onClick:()=>b.mutate(),disabled:!x.trim(),children:a.jsx(zt,{className:"h-3.5 w-3.5"})})]})]})]})}function cce({generator:e}){const t=at(),{toast:n}=mt(),r=y.useRef(null),[s,i]=y.useState(!1),[o,l]=y.useState(!1),[c,u]=y.useState(e.bio||"");y.useEffect(()=>{u(e.bio||""),l(!1)},[e.id,e.bio]);const d=async f=>{const x=(f.name.split(".").pop()||"").toLowerCase(),g=x6(f);if(g){n({title:"Can't upload this image",description:g,variant:"destructive"});return}i(!0);try{const p=`${e.id}.${x}`;await F.storage.from("generator-headshots").remove([p]);const{error:v}=await F.storage.from("generator-headshots").upload(p,f,{upsert:!1});if(v)throw v;const{data:b}=F.storage.from("generator-headshots").getPublicUrl(p),w=b.publicUrl+"?t="+D
705ate.now(),{error:N}=await F.from("generators").update({headshot_url:w}).eq("id",e.id);if(N)throw N;t.invalidateQueries({queryKey:["generators"]}),n({title:"Headshot uploaded"})}catch(p){n({title:"Upload failed",description:p.message,variant:"destructive"})}finally{i(!1)}},h=async()=>{var g,p;const f=((p=(g=e.headshot_url)==null?void 0:g.split(".").pop())==null?void 0:p.split("?")[0])||"jpg",x=`${e.id}.${f}`;await F.storage.from("generator-headshots").remove([x]),await F.from("generators").update({headshot_url:null}).eq("id",e.id),t.invalidateQueries({queryKey:["generators"]}),n({title:"Headshot removed"})},m=async()=>{const{error:f}=await F.from("generators").update({bio:c.trim()||null}).eq("id",e.id);if(f){n({title:"Error",description:f.message,variant:"destructive"});return}t.invalidateQueries({queryKey:["generators"]}),l(!1),n({title:"Bio updated"})};return a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Profile"}),a.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.headshot_url?a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:e.headshot_url,alt:e.name,className:"h-16 w-16 rounded-full object-cover"}),a.jsx("button",{onClick:h,className:"absolute -top-1 -right-1 h-5 w-5 rounded-full bg-destructive text-destructive-foreground flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(Ht,{className:"h-3 w-3"})})]}):a.jsx("div",{onClick:()=>{var f;return(f=r.current)==null?void 0:f.click()},className:"h-16 w-16 rounded-full bg-muted flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",children:s?a.jsx(vt,{className:"h-5 w-5 animate-spin text-muted-foreground"}):a.jsx(ao,{className:"h-5 w-5 text-muted-foreground"})}),a.jsx("input",{ref:r,type:"file",accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:f=>{var g;const x=(g=f.target.files)==null?void 0:g[0];x&&d(x),f.target.value=""}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[e.headshot_url&&a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs mb-1",onClick:()=>{var f;return(f=r.current)==null?void 0:f.click()},disabled:s,children:[s?a.jsx(vt,{className:"h-3 w-3 animate-spin mr-1"}):a.jsx(ao,{className:"h-3 w-3 mr-1"}),"Change Photo"]}),o?a.jsxs("div",{className:"space-y-1",children:[a.jsx(qt,{value:c,onChange:f=>u(f.target.value),rows:3,className:"text-xs",maxLength:1e3,placeholder:"A short bio for the public pageâ¦"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:m,children:"Save"}),a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{u(e.bio||""),l(!1)},children:"Cancel"})]})]}):a.jsxs("div",{children:[e.bio?a.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-line",children:e.bio}):a.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No bio yet."}),a.jsx(Y,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>l(!0),children:e.bio?"Edit bio":"Add bio"})]})]})]})]})}function uce({open:e,onOpenChange:t,generator:n}){const[r,s]=y.useState(""),[i,o]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState("employee"),[h,m]=y.useState(!0),[f,x]=y.useState(""),g=at(),{toast:p}=mt(),{data:v=[]}=Ee({queryKey:["contacts-for-generator-link"],enabled:e,queryFn:async()=>{const{data:_,error:S}=await F.from("contacts").select("id, name, email, phone, headshot_url").order("name");if(S)throw S;return _||[]}});y.useEffect(()=>{e&&(x(""),n?(s(n.name),o(n.email),c(n.phone||""),d(n.type),m(n.active)):(s(""),o(""),c(""),d("employee"),m(!0)))},[e,n]);const b=v.find(_=>_.id===f),w=!n&&!f&&i.trim()?v.find(_=>(_.email||"").toLowerCase()===i.trim().toLowerCase()):void 0,N=_=>{x(_);const S=v.find(P=>P.id===_);S&&(s(S.name||""),o(S.email||""),c(S.phone||""))},j=Me({mutationFn:async()=>{var P;const _={name:r.trim(),email:i.trim(),phone:l.trim()||null,type:u,active:h,...!n&&(b!=null&&b.headshot_url)?{headshot_url:b.headshot_url}:{}};if(n){const{error:k}=await F.from("generators").update(_).eq("id",n.id);if(k)throw k}else{const{error:k}=await F.from("generators").insert(_);if(k)throw k}const S=f||((P=v.find(k=>(k.email||"").toLowerCase()===i.trim().toLowerCase()))==null?void 0:P.id);if(S){const{error:k}=await F.from("contacts").update({name:r.trim(),email:i.trim(),phone:l.trim()||null}).eq("id",S);if(k)throw k}},onSuccess:()=>{g.invalidateQueries({queryKey:["generators"]}),g.invalidateQueries({queryKey:["contacts"]}),t(!1),p({title:n?"Generator updated":"Generator created"})},onError:_=>p({title:"Error",description:_.message,variant:"destructive"})});return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"sm:max-w-md",children:[a.jsx(Ot,{children:a.jsx(At,{className:"font-display text-xl",children:n?"Edit Generator":"New Generator"})}),a.jsxs("form",{onSubmit:_=>{_.preventDefault(),j.mutate()},className:"space-y-4",children:[!n&&a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Existing contact (optional)"}),a.jsx(Kt,{value:f,onValueChange:_=>_?N(_):x(""),options:v.map(_=>({value:_.id,label:_.email?`${_.name} · ${_.email}`:_.name})),placeholder:"Search contactsâ¦",allowNone:!0,noneLabel:"Not an existing contact"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:b?`Prefilled from ${b.name}${b.headshot_url?" (headshot included)":""}. Their contact record stays in sync.`:w?`That email matches contact ${w.name} â select them to pull in details and link the records.`:"Link a contact to pre-populate details and keep both records in sync."})]}),a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{children:"Name *"}),a.jsx(ce,{value:r,onChange:_=>s(_.target.value),required:!0,maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Email *"}),a.jsx(ce,{type:"email",value:i,onChange:_=>o(_.target.value),required:!0,maxLength:255})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Phone"}
705),a.jsx(ce,{value:l,onChange:_=>c(_.target.value),maxLength:30})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Type"}),a.jsxs(lt,{value:u,onValueChange:d,children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"employee",children:"Employee"}),a.jsx(Oe,{value:"contractor",children:"Contractor"})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[a.jsx(ta,{checked:h,onCheckedChange:m}),a.jsx(xe,{children:"Active"})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Y,{type:"button",variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),a.jsx(Y,{type:"submit",disabled:j.isPending||!r.trim()||!i.trim(),children:j.isPending?"Savingâ¦":n?"Update":"Create"})]})]})]})})}function dce({children:e}){const{data:t}=g6(),[n,r]=El();if(!t)return a.jsx(a.Fragment,{children:e});const s=n.get("tab")==="suppliers"?"suppliers":"team";return a.jsxs(Pk,{value:s,onValueChange:i=>r(i==="team"?{}:{tab:i},{replace:!0}),children:[a.jsxs(Cb,{className:"mb-4",children:[a.jsx(Zr,{value:"team",children:"Team"}),a.jsx(Zr,{value:"suppliers",children:"Suppliers"})]}),a.jsx(Ja,{value:"team",children:e}),a.jsx(Ja,{value:"suppliers",children:a.jsx(Hle,{})})]})}const Og=F,oA=e=>(e??0).toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0});function hce({ceId:e,participantName:t,seatTotal:n}){const r=at(),[s,i]=y.useState(!1),[o,l]=y.useState([]),{data:c=[]}=Ee({queryKey:["seat-schedule",e],queryFn:async()=>{const{data:g,error:p}=await Og.from("seat_payment_schedule").select("*").eq("contact_experience_id",e).order("sort_order");if(p)throw p;return g}}),{data:u=[]}=Ee({queryKey:["contacts-payer-options"],enabled:s,queryFn:async()=>{const{data:g,error:p}=await Og.from("contacts").select("id, name, contact_type, payment_terms").order("name");if(p)throw p;return g}}),d=()=>{l(c.map(g=>({id:g.id,payer_contact_id:g.payer_contact_id,amount:String(g.amount),due_date:g.due_date,note:g.note??""}))),i(!0)},h=o.reduce((g,p)=>g+(Number(p.amount.replace(/[$,]/g,""))||0),0),m=c.some(g=>g.payer_contact_id),f=async()=>{if(o.some(p=>!p.due_date))return Mt.error("Every row needs a due date");const{error:g}=await Og.from("seat_payment_schedule").delete().eq("contact_experience_id",e);if(g)return Mt.error(g.message);if(o.length){const{error:p}=await Og.from("seat_payment_schedule").insert(o.map((v,b)=>({contact_experience_id:e,payer_contact_id:v.payer_contact_id||null,amount:Number(v.amount.replace(/[$,]/g,""))||0,due_date:v.due_date,note:v.note||null,sort_order:b})));if(p)return Mt.error(p.message)}
705r.invalidateQueries({queryKey:["seat-schedule",e]}),r.invalidateQueries({queryKey:["forecast"]}),r.invalidateQueries({queryKey:["outstanding-balances"]}),Mt.success("Payment schedule saved"),i(!1)},x=(g,p)=>l(v=>v.map((b,w)=>w===g?{...b,...p}:b));return a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",onClick:d,className:`h-4 w-4 flex-shrink-0 ${c.length?"text-primary":"text-muted-foreground/40 hover:text-muted-foreground"}`,title:c.length?`Payer schedule: ${c.length} row(s)${m?", includes a sponsor":""}`:"Set payers / split payment schedule",children:a.jsx(rC,{className:"h-3 w-3"})}),a.jsx(Dt,{open:s,onOpenChange:i,children:a.jsxs(Pt,{className:"sm:max-w-2xl",children:[a.jsx(Ot,{children:a.jsxs(At,{children:["Payment schedule â ",t]})}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Each row is one payment: amount, due date and who pays. Leave payer blank for the participant. An organization's cash is expected on the due date plus its terms. The seat price doesn't change."}),a.jsxs("div",{className:"space-y-2",children:[o.map((g,p)=>a.jsxs("div",{className:"grid grid-cols-[1fr_7rem_9rem_2rem] gap-2 items-center",children:[a.jsxs(lt,{value:g.payer_contact_id??"self",onValueChange:v=>x(p,{payer_contact_id:v==="self"?null:v}),children:[a.jsx(it,{className:"h-8",children:a.jsx(ct,{})}),a.jsxs(ot,{className:"max-h-72",children:[a.jsxs(Oe,{value:"self",children:[t," (participant)"]}),u.filter(v=>v.contact_type==="organization").map(v=>a.jsxs(Oe,{value:v.id,children:[v.name," · ",v.payment_terms||"no terms"]},v.id)),u.filter(v=>v.contact_type!=="organization").map(v=>a.jsx(Oe,{value:v.id,children:v.name},v.id))]})]}),a.jsx(ce,{className:"h-8 text-right",inputMode:"decimal",value:g.amount,onChange:v=>x(p,{amount:v.target.value}),placeholder:"Amount"}),a.jsx(ce,{className:"h-8",type:"date",value:g.due_date,onChange:v=>x(p,{due_date:v.target.value})}),a.jsx(Y,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>l(v=>v.filter((b,w)=>w!==p)),children:a.jsx(pn,{className:"h-4 w-4"})})]},p)),a.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>l(g=>[...g,{payer_contact_id:null,amount:o.length?"":String(n),due_date:"",note:""}]),children:[a.jsx(zt,{className:"h-4 w-4 mr-1"}),"Add payment"]})]}),a.jsxs("div",{className:`text-sm ${o.length&&Math.abs(h-n)>.5?"text-destructive":"text-muted-foreground"}`,children:["Scheduled ",oA(h)," of seat total ",oA(n),o.length&&Math.abs(h-n)>.5?" â doesn't match":""]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Y,{variant:"ghost",onClick:()=>i(!1),children:"Cancel"}),a.jsx(Y,{onClick:f,children:"Save"})]})]})})]})}const gn=y.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Se("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));gn.displayName="Card";const fr=y.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Se("flex flex-col space-y-1.5 p-6",e),...t}));fr.displayName="CardHeader";const mr=y.forwardRef(({className:e,...t},n)=>a.jsx("h3",{ref:n,className:Se("text-2xl font-semibold leading-none tracking-tight",e),...t}));mr.displayName="CardTitle";const fce=y.forwardRef(({className:e,...t},n)=>a.jsx("p",{ref:n,className:Se("text-sm text-muted-foreground",e),...t}));fce.displayName="CardDescription";const bn=y.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Se("p-6 pt-0",e),...t}));bn.displayName="CardContent";const mce=y.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Se("flex items-center p-6 pt-0",e),...t}));mce.displayName="CardFooter";const pce={trip:"Trip",peer_group:"Peer Group",coaching:"Coaching"},gce={invited:"Invited",accepted:"Accepted",declined:"Declined",waitlist:"Waitlist",considering:"Considering",expressed_interest:"Interested",candidate:"Candidate",dropped:"Dropped",future:"Future",active:"Active",completed:"Completed",cancelled:"Cancelled"},xce=["overhead contribution","budgeted profit"],mu=e=>e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0});function yce(e,t){if(!e||!t)return null;const n=new Date(e.slice(0,10)+"T00:00:00"),r=new Date(t.slice(0,10)+"T00:00:00"),s=(r.getFullYear()-n.getFullYear())*12+(r.getMonth()-n.getMonth())-(r.getDate()<n.getDate()?1:0);return Math.max(0,s)}function vce({summit:e,showFinancials:t}){const n=e.id,r=e.end_date||e.target_start_date||null,s=at(),{data:i,isLoading:o}=Ee({queryKey:["summit-bookings",n],queryFn:async()=>{const b=F,{data:w,error:N}=await b.from("contact_experiences").select("id").eq("experience_id",n).eq("status","accepted");if(N)throw N;const{data:j,error:_}=await b.from("experiences").select("id").eq("originating_summit_id",n);if(_)throw _;const S=(j??[]).map(M=>M.id),P="id, contact_id, status, custom_price, amount_paid, accepted_at, created_at, contacts:contacts!contact_experiences_contact_id_fkey(name), experiences!contact_experiences_experience_id_fkey(id, name, public_name, type, price)",{data:k,error:C}=await b.from("contact_experiences").select(P).eq("originating_summit_id",n);if(C)throw C;let T=[];
705if(S.length){const{data:M,error:B}=await b.from("contact_experiences").select(P).in("experience_id",S).neq("status","gen_guide");if(B)throw B;T=M??[]}const O=new Map;[...k??[],...T].forEach(M=>O.set(M.id,M));const L=[...O.values()],{data:E,error:R}=await b.from("contact_coaching").select("id, contact_id, start_date, status, price, amount_paid, created_at, contacts!contact_coaching_contact_id_fkey(name), generators!contact_coaching_generator_id_fkey(name)").eq("originating_summit_id",n);if(R)throw R;const q=[...new Set(L.map(M=>{var B;return(B=M.experiences)==null?void 0:B.id}).filter(Boolean))],I={};if(q.length){const{data:M,error:B}=await b.from("experience_budget_items").select("experience_id, name, cost_type, amount").in("experience_id",q).eq("cost_type","pct_revenue");if(!B)for(const W of M??[])xce.includes(String(W.name).trim().toLowerCase())&&(I[W.experience_id]=(I[W.experience_id]??0)+Number(W.amount||0)/100)}const $=[...L.map(M=>{var B,W,A,K,G,H,fe;return{key:M.id,person:((B=M.contacts)==null?void 0:B.name)??"Unknown",contactId:M.contact_id,booked:((W=M.experiences)==null?void 0:W.public_name)||((A=M.experiences)==null?void 0:A.name)||"â",bookedId:((K=M.experiences)==null?void 0:K.id)??null,kind:((G=M.experiences)==null?void 0:G.type)??"",status:M.status,bookingDate:M.accepted_at||M.created_at,value:Number(M.custom_price??((H=M.experiences)==null?void 0:H.price)??0),paid:Number(M.amount_paid??0),margin:(fe=M.experiences)!=null&&fe.id&&I[M.experiences.id]>0?I[M.experiences.id]:null}}),...(E??[]).map(M=>{var B,W;return{key:M.id,person:((B=M.contacts)==null?void 0:B.name)??"Unknown",contactId:M.contact_id,booked:`Coaching${(W=M.generators)!=null&&W.name?` with ${M.generators.name}`:""}`,bookedId:null,kind:"coaching",status:M.status,bookingDate:M.start_date||M.created_at,value:Number(M.price??0),paid:Number(M.amount_paid??0),margin:null}})].sort((M,B)=>String(M.bookingDate??"").localeCompare(String(B.bookingDate??"")));return{attendees:(w??[]).length,rows:$}}}),l=(i==null?void 0:i.rows)??[],c=l.filter(b=>["accepted","active","completed"].includes(b.status)),u=c.reduce((b,w)=>b+w.value,0),d=l.reduce((b,w)=>b+w.paid,0),h=c.filter(b=>b.margin!=null),m=h.reduce((b,w)=>b+w.value*w.margin,0),f=e.actual_cost!=null?Number(e.actual_cost):null,[x,g]=y.useState(f!=null?String(f):"");y.useEffect(()=>{g(e.actual_cost!=null?String(e.actual_cost):"")},[e.actual_cost]);const p=Me({mutationFn:async b=>{const{error:w}=await F.from("experiences").update({actual_cost:b}).eq("id",n);if(w)throw w},onSuccess:()=>s.invalidateQueries({queryKey:["experiences"]})});y.useEffect(()=>{const b=setTimeout(()=>{const w=x.replace(/[$,\s]/g,""),N=w===""?null:Number(w);N!==null&&isNaN(N)||N!==(e.actual_cost!=null?Number(e.actual_cost):null)&&p.mutate(N)},700);return()=>clearTimeout(b)},[x]);const v=({label:b,value:w,hint:N})=>a.jsxs("div",{className:"rounded border border-border px-3 py-2",title:N,children:[a.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:b}),a.jsx("p",{className:"text-sm font-semibold",children:w})]});return a.jsxs(gn,{children:[a.jsx(fr,{className:"pb-2",children:a.jsx(mr,{className:"font-display text-lg",children:"Bookings Generated"})}),a.jsxs(bn,{className:"space-y-3",children:[t&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("label",{className:"text-xs text-muted-foreground w-24",children:"Actual cost"}),a.jsx(ce,{type:"text",inputMode:"decimal",className:"h-8 w-40 text-sm",placeholder:"$0",value:x,onChange:b=>g(b.target.value)}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"What this summit really cost, alongside its budget."})]}),a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-7 gap-2",children:[a.jsx(v,{label:"Attendees",value:String((i==null?void 0:i.attendees)??0),hint:"Accepted participants on this summit"}),a.jsx(v,{label:"Bookings",value:String(l.length)}),a.jsx(v,{label:"Accepted",value:String(c.length)}),t&&a.jsxs(a.Fragment,{children:[a.jsx(v,{label:"Booked revenue",value:mu(u),hint:"Booking value of accepted bookings"}),a.jsx(v,{label:"Collected",value:mu(d)}),a.jsx(v,{label:"Actual cost",value:f!=null?mu(f):"â"}),a.jsx(v,{label:"Est. contribution",value:h.length?mu(m):"â",hint:`Booked revenue à each trip's budgeted margin (Overhead Contribution + Budgeted Profit). ${h.length} of ${c.length} accepted bookings have a margin set.`})]})]}),o?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):l.length===0?a.jsx("p",{className:"text-sm text-muted-foreground",children:"No bookings are linked to this summit yet."}):a.jsx("div",{className:"rounded border border-border overflow-x-auto",children:a.jsxs("table",{className:"w-full text-xs",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border bg-muted/50 text-muted-foreground",children:[a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Person"}),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Booked"}),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Status"}),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Months after"}),t&&a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Value"}),t&&a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Paid"})]})}),a.jsx("tbody",{children:l.map(b=>{const w=yce(r,b.bookingDate);return a.jsxs("tr",{className:"border-b border-border last:border-0",children:[a.jsx("td",{className:"px-2 py-1.5",children:b.contactId?a.jsx("a",{className:"text-primary hover:underline",href:`/contacts?contact=${b.contactId}`,children:b.person}):b.person}),a.jsxs("td",{className:"px-2 py-1.5",children:[b.bookedId?a.jsx("a",{className:"hover:underline",href:`/experiences?id=${b.bookedId}`,children:b.booked}):b.booked,a.jsxs("span",{className:"text-muted-foreground",children:[" · ",pce[b.kind]??b.kind]})]}),a.jsx("td",{className:"px-2 py-1.5",children:a.jsx(Ge,{variant:"outline",className:"text-[10px]",children:gce[b.status]??b.status})}),a.jsx("td",{className:"px-2 py-1.5",children:w??"â"}),t&&a.jsx("td",{className:"px-2 py-1.5",children:mu(b.value)}),t&&a.jsx("td",{className:"px-2 py-1.5",children:mu(b.paid)})]},b.key)})})]})})]})]})}const lA=e=>(e==null?void 0:e.end_date)||(e==null?void 0:e.target_start_date)||null,cA=e=>(e==null?void 0:e.public_name)||(e==null?void 0:e.name)||"Summit";function bce(e,t){const n=Ee({queryKey:["summit-options"],enabled:t,queryFn:async()=>{const{data:s,error:i}=await F.from("experiences").select("id, name, public_name, target_start_date, end_date").eq("type","stakeholder_summit").order("target_start_date",{ascending:!1,nullsFirst:!1});if(i)throw i;return(s??[]).map(o=>({id:o.id,label:cA(o),date:lA(o)}))}}),r=Ee({queryKey:["summit-sources",e],enabled:t,queryFn:async()=>{const{data:s,error:i}=await F.from("contact_experiences").select("id, contact_id, status, accepted_at, created_at, originating_summit_id, summit_source_reviewed_at").eq("experience_id",e);if(i)throw i;const o=s??[],l=[...new Set(o.map(h=>
705h.contact_id))];if(l.length===0)return{};const{data:c,error:u}=await F.from("contact_experiences").select("id, contact_id, status, accepted_at, created_at, experiences!contact_experiences_experience_id_fkey(id, name, public_name, type, target_start_date, end_date)").in("contact_id",l);if(u)throw u;const d={};for(const h of o){const m={linkedId:h.originating_summit_id??null,reviewed:!!h.summit_source_reviewed_at,suggestion:null};if(d[h.id]=m,h.status!=="accepted"||m.linkedId||m.reviewed)continue;const f=(h.accepted_at||h.created_at||new Date().toISOString()).slice(0,10),x=(c??[]).filter(b=>b.contact_id===h.contact_id),p=x.filter(b=>{var w;return b.status==="accepted"&&((w=b.experiences)==null?void 0:w.type)==="stakeholder_summit"}).map(b=>({e:b.experiences,d:lA(b.experiences)})).filter(b=>b.d&&b.d<f).sort((b,w)=>b.d<w.d?1:-1)[0];!p||x.some(b=>{var N;if(b.id===h.id||!["trip","peer_group"].includes((N=b.experiences)==null?void 0:N.type)||b.status!=="accepted"||!b.accepted_at)return!1;const w=b.accepted_at.slice(0,10);return w>=p.d&&(w<f||w===f&&b.accepted_at<(h.accepted_at??""))})||(m.suggestion={id:p.e.id,label:cA(p.e),date:p.d})}return d}});return{summits:n.data??[],sources:r.data??{}}}function wce({ceId:e,experienceId:t,info:n,summits:r}){const s=at(),i=Me({mutationFn:async c=>{const{error:u}=await F.from("contact_experiences").update({originating_summit_id:c,summit_source_reviewed_at:new Date().toISOString()}).eq("id",e);if(u)throw u},onSuccess:()=>{s.invalidateQueries({queryKey:["summit-sources",t]}),s.invalidateQueries({queryKey:["summit-bookings"]})}}),o=n!=null&&n.linkedId?r.find(c=>
705c.id===n.linkedId):null,l=n==null?void 0:n.suggestion;return a.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[l&&a.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-accent px-1 py-0.5 text-[9px] text-accent-foreground",children:[a.jsx(vc,{className:"h-2.5 w-2.5"}),"From ",l.label,"?",a.jsx("button",{title:"Confirm",className:"hover:text-primary",onClick:()=>i.mutate(l.id),children:a.jsx(On,{className:"h-2.5 w-2.5"})}),a.jsx("button",{title:"Not from this summit",className:"hover:text-destructive",onClick:()=>i.mutate(null),children:a.jsx(Ht,{className:"h-2.5 w-2.5"})})]}),a.jsxs(na,{children:[a.jsx(ra,{asChild:!0,children:a.jsxs("button",{className:Se("inline-flex items-center gap-0.5 text-[9px]",o?"text-primary":"text-muted-foreground/60 hover:text-muted-foreground"),title:"Originating summit",children:[o?a.jsxs(a.Fragment,{children:[a.jsx(vc,{className:"h-2.5 w-2.5"}),o.label]}):!l&&"+ summit",l&&"change"]})}),a.jsxs(Kr,{className:"w-64 p-2",align:"start",children:[a.jsx("p",{className:"text-xs font-medium mb-1",children:"Originating summit"}),a.jsxs("div",{className:"max-h-56 overflow-y-auto space-y-0.5",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"w-full justify-start h-7 text-xs",onClick:()=>i.mutate(null),children:"None"}),r.map(c=>a.jsxs(Y,{variant:c.id===(n==null?void 0:n.linkedId)?"secondary":"ghost",size:"sm",className:"w-full justify-start h-7 text-xs",onClick:()=>i.mutate(c.id),children:[a.jsx("span",{className:"truncate",children:c.label}),c.date&&a.jsx("span",{className:"ml-auto text-muted-foreground",children:c.date.slice(0,7)})]},c.id))]})]})]})]})}function _ce(e){return Ee({queryKey:["referrer-options"],enabled:e,queryFn:async()=>{const{data:t,error:n}=await F.rpc("get_all_contacts_for_assignment");if(n)throw n;return t??[]}}).data??[]}function jce({ceId:e,contactId:t,referredBy:n,options:r}){const s=at(),i=Me({mutationFn:async l=>{const{error:c}=await F.from("contact_experiences").update({referred_by:l}).eq("id",e);if(c)throw c},onSuccess:()=>{s.invalidateQueries({queryKey:["experience-contacts"]}),s.invalidateQueries({queryKey:["participant-referrers"]}),s.invalidateQueries({queryKey:["referred-bookings"]})}}),o=n?r.find(l=>l.id===n):null;return a.jsxs(na,{children:[a.jsx(ra,{asChild:!0,children:a.jsx("button",{className:Se("inline-flex items-center gap-0.5 text-[9px]",o?"text-primary":"text-muted-foreground/60 hover:text-muted-foreground"),title:"Referred by",children:o?a.jsxs(a.Fragment,{children:[a.jsx(W3,{className:"h-2.5 w-2.5"}),"Ref: ",o.name]}):"+ referrer"})}),a.jsxs(Kr,{className:"w-64 p-2",align:"start",children:[a.jsx("p",{className:"text-xs font-medium mb-1",children:"Referred by"}),a.jsx(Kt,{value:n??"",onValueChange:l=>i.mutate(l&&l!=="none"?l:null),options:r.filter(l=>l.id!==t).map(l=>({value:l.id,label:l.name})),placeholder:"Select contactâ¦",allowNone:!0})]})]})}function Nce({summitId:e,summitDate:t,showFinancials:n}){const{data:r,isLoading:s}=Ee({queryKey:["referred-bookings","summit",e],queryFn:async()=>{var d;const{data:o,error:l}=await F.from("contact_experiences").select("contact_id, contacts:contacts!contact_experiences_contact_id_fkey(name)").eq("experience_id",e).eq("status","accepted");if(l)throw l;const c={};for(const h of o??[])c[h.contact_id]=((d=h.contacts)==null?void 0:d.name)??"Unknown";return{rows:await pae(Object.keys(c),t),names:c}}}),i=(r==null?void 0:r.rows)??[];return a.jsxs(gn,{children:[a.jsxs(fr,{className:"pb-2",children:[a.jsx(mr,{className:"font-display text-lg",children:"Referred Bookings"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"People referred by a summit attendee. Each referred person's first booking after the summit, same rule as Bookings Generated. Counted separately."})]}),a.jsxs(bn,{className:"space-y-3",children:[a.jsx(gae,{rows:i,showFinancials:n,revenueLabel:"Booked revenue (first booking)"}),s?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):i.length===0?a.jsx("p",{className:"text-sm text-muted-foreground",children:"No bookings referred by this summit's attendees yet."}):a.jsx(wF,{rows:i,showFinancials:n,referrerNames:r==null?void 0:r.names})]})]})}const as=y.forwardRef(({value:e,onCommit:t,onKeyDown:n,...r},s)=>{const[i,o]=y.useState(String(e??""));y.useEffect(()=>{o(String(e??""))},[e]);const l=()=>{i!==String(e??"")&&t(i)};return a.jsx(ce,{ref:s,value:i,onChange:c=>o(c.target.value),onBlur:l,onKeyDown:c=>{c.key==="Enter"&&c.currentTarget.blur(),n==null||n(c)},...r})});as.displayName="DebouncedInput";const w6=cb,Sce=ub,_6=y.forwardRef(({className:e,...t},n)=>a.jsx(hh,{className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));_6.displayName=hh.displayName;const Cce=nh("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),Ak=y.forwardRef(({side:e="right",className:t,children:n,...r},s)=>
705a.jsxs(Sce,{children:[a.jsx(_6,{}),a.jsxs(fh,{ref:s,className:Se(Cce({side:e}),t),...r,children:[n,a.jsxs(db,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[a.jsx(Ht,{className:"h-4 w-4"}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ak.displayName=fh.displayName;const Tk=({className:e,...t})=>a.jsx("div",{className:Se("flex flex-col space-y-2 text-center sm:text-left",e),...t});Tk.displayName="SheetHeader";const Mk=y.forwardRef(({className:e,...t},n)=>a.jsx(_p,{ref:n,className:Se("text-lg font-semibold text-foreground",e),...t}));Mk.displayName=_p.displayName;const j6=y.forwardRef(({className:e,...t},n)=>a.jsx(jp,{ref:n,className:Se("text-sm text-muted-foreground",e),...t}));j6.displayName=jp.displayName;var kce="Separator",uA="horizontal",Ece=["horizontal","vertical"],N6=y.forwardRef((e,t)=>{const{decorative:n,orientation:r=uA,...s}=e,i=Pce(r)?r:uA,l=n?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return a.jsx(tt.div,{"data-orientation":i,...l,...s,ref:t})});N6.displayName=kce;function Pce(e){return Ece.includes(e)}var S6=N6;const py=y.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},s)=>a.jsx(S6,{ref:s,decorative:n,orientation:t,className:Se("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));py.displayName=S6.displayName;const Oce=[{value:"prospect",label:"Prospect"},{value:"contacted",label:"Contacted"},{value:"engaged",label:"Engaged"},{value:"active",label:"Active"},{value:"alumni",label:"Alumni"}];function Ace({open:e,onOpenChange:t,contactId:n,experienceId:r}){const[s,i]=y.useState(""),[o,l]=y.useState(""),[c,u]=y.useState(""),[d,h]=y.useState(""),[m,f]=y.useState(""),[x,g]=y.useState(""),[p,v]=y.useState("prospect"),[b,w]=y.useState(""),[N,j]=y.useState(""),[_,S]=y.useState(""),[P,k]=y.useState(""),[C,T]=y.useState(""),[O,L]=y.useState(""),[E,R]=y.useState(""),[q,I]=y.useState(""),[$,M]=y.useState(!1),[B,W]=y.useState(""),[A,K]=y.useState(()=>new Date().toISOString().slice(0,10)),[G,H]=y.useState(!1),[fe,te]=y.useState(!1),[J,re]=y.useState(""),pe=at(),{toast:ye}=mt(),{data:X=[]}=ps(),{data:he}=Ee({queryKey:["contact-for-edit",n],enabled:!!n&&e,queryFn:async()=>{const{data:z,error:Z}=await F.from("contacts").select("*").eq("id",n).maybeSingle();if(Z)throw Z;return z}}),{data:D=[]}=Ee({queryKey:["contacts-list-for-referral"],queryFn:async()=>{const{data:z,error:Z}=await F.from("contacts").select("id, name").order("name");if(Z)throw Z;return z}}),{data:le}=Ee({queryKey:["contact-experience-for-drawer",n,r],enabled:!!n&&!!r&&e,queryFn:async()=>{const{data:z,error:Z}=await F.from("contact_experiences").select("id, amount_paid, deposit_paid, price_paid").eq("contact_id",n).eq("experience_id",r).maybeSingle();if(Z)throw Z;return z}});y.useEffect(()=>{he&&(i(he.name),l(he.email||""),u(he.phone||""),h(he.company||""),f(he.linkedin_url||""),g(he.instagram_handle||""),v(he.status),w(he.notes||""),j(he.generator_id||""),S(he.referred_by||""),k(he.address_street||""),T(he.address_city||""),L(he.address_state||""),R(he.address_postal_code||""),I(he.address_country||""))},[he]),y.useEffect(()=>{e||(M(!1),W(""),K(new Date().toISOString().slice(0,10)),H(!1),te(!1),re(""))},[e]);const V=Me({mutationFn:async()=>{if(!n)return;const z={name:s.trim(),email:o.trim()||null,phone:c.trim()||null,company:d.trim()||null,linkedin_url:m.trim()||null,instagram_handle:x.trim()||null,status:p,notes:b.trim()||null,generator_id:N&&N!=="none"?N:null,referred_by:_&&_!=="none"?_:null,address_street:P.trim()||null,address_city:C.trim()||null,address_state:O.trim()||null,address_postal_code:E.trim()||null,address_country:q.trim()||null},{error:Z}=await F.from("contacts").update(z).eq("id",n);if(Z)throw Z},onSuccess:()=>{pe.invalidateQueries({queryKey:["contacts"]}),pe.invalidateQueries({queryKey:["experience-contacts"]}),pe.invalidateQueries({queryKey:["contact-for-edit",n]}),t(!1),ye({title:"Contact updated"})},onError:z=>{ye({title:"Error",description:sF(z),variant:"destructive"})}}),U=Me({mutationFn:async()=>
705{if(!le)throw new Error("No experience enrollment found");const z=(B||"").toString().replace(/[$,\s]/g,""),Z=z===""?0:Number(z);if(z!==""&&!Number.isFinite(Z))throw new Error(`Invalid payment amount: "${B}". Use digits and a decimal point only (no commas).`);const ve=Z>0?Z:0;if(ve===0&&!G&&!fe)throw new Error("Enter a payment amount or check a status box before recording.");const ee={amount_paid:Number(le.amount_paid)+ve};G&&(ee.deposit_paid=!0),fe&&(ee.price_paid=!0);const{error:de}=await F.from("contact_experiences").update(ee).eq("id",le.id);if(de)throw de;if(ve>0){const{error:je}=await F.from("manual_payments").insert({contact_experience_id:le.id,amount:ve,recorded_at:A?new Date(A+"T12:00:00").toISOString():new Date().toISOString(),payment_method:J||null});if(je)throw je}},onSuccess:()=>{pe.invalidateQueries({queryKey:["contact-experiences"]}),pe.invalidateQueries({queryKey:["experience-contacts"]}),pe.invalidateQueries({queryKey:["manual-payments",n]}),pe.invalidateQueries({queryKey:["contact-experience-for-drawer",n,r]}),M(!1),W(""),K(new Date().toISOString().slice(0,10)),H(!1),te(!1),re(""),ye({title:"Payment recorded"})},onError:z=>ye({title:"Error",description:z.message,variant:"destructive"})});return a.jsx(w6,{open:e,onOpenChange:t,children:a.jsxs(Ak,{side:"right",className:"sm:max-w-lg p-0 flex flex-col",children:[a.jsx(Tk,{className:"px-6 pt-6 pb-2",children:a.jsx(Mk,{className:"font-display text-xl",children:"Edit Contact"})}),a.jsx(Ic,{className:"flex-1 px-6 pb-6",children:a.jsxs("form",{id:"contact-edit-drawer-form",onSubmit:z=>{z.preventDefault(),V.mutate()},className:"space-y-4 pt-2",children:[a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{htmlFor:"drawer-name",children:"Name *"}),a.jsx(ce,{id:"drawer-name",value:s,onChange:z=>i(z.target.value),required:!0,maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-email",children:"Email"}),a.jsx(ce,{id:"drawer-email",type:"email",value:o,onChange:z=>l(z.target.value),maxLength:255})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-phone",children:"Phone"}),a.jsx(ce,{id:"drawer-phone",value:c,onChange:z=>u(z.target.value),maxLength:30})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-company",children:"Company"}),a.jsx(ce,{id:"drawer-company",value:d,onChange:z=>h(z.target.value),maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-linkedin",children:"LinkedIn URL"}),a.jsx(ce,{id:"drawer-linkedin",value:m,onChange:z=>f(z.target.value),placeholder:"https://linkedin.com/in/...",maxLength:200})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-instagram",children:"Instagram Handle"}),a.jsx(ce,{id:"drawer-instagram",value:x,onChange:z=>g(z.target.value),placeholder:"@yourhandle",maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-status",children:"Status"}),a.jsxs(lt,{value:p,onValueChange:v,children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsx(ot,{children:Oce.map(z=>a.jsx(Oe,{value:z.value,children:z.label},z.value))})]})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{children:"Generator (Owner)"}),a.jsx(Kt,{value:N,onValueChange:j,options:X.map(z=>({value:z.id,label:z.name})),placeholder:"Select generatorâ¦",allowNone:!0,className:"w-full"})]})]}),a.jsx(py,{}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Mailing Address"}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{htmlFor:"drawer-addr-street",children:"Street Address"}),a.jsx(ce,{id:"drawer-addr-street",value:P,onChange:z=>k(z.target.value),maxLength:200})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-addr-city",children:"City"}),a.jsx(ce,{id:"drawer-addr-city",value:C,onChange:z=>T(z.target.value),maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-addr-state",children:"State / Province"}
705),a.jsx(ce,{id:"drawer-addr-state",value:O,onChange:z=>L(z.target.value),maxLength:100})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-addr-postal",children:"Postal Code"}),a.jsx(ce,{id:"drawer-addr-postal",value:E,onChange:z=>R(z.target.value),maxLength:20})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-addr-country",children:"Country"}),a.jsx(ce,{id:"drawer-addr-country",value:q,onChange:z=>I(z.target.value),maxLength:100})]})]})]}),n&&a.jsxs(a.Fragment,{children:[a.jsx(py,{}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h4",{className:"text-sm font-medium text-foreground flex items-center gap-1.5",children:"Payment History"}),le&&a.jsxs("button",{type:"button",onClick:()=>M(!$),className:"text-xs text-primary hover:underline flex items-center gap-1",children:[a.jsx(Hi,{className:"h-3 w-3"})," Record Payment"]})]}),$&&le&&a.jsxs("div",{className:"mb-3 rounded-md border border-border bg-background p-2 space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:"$"}),a.jsx(ce,{type:"text",inputMode:"decimal",placeholder:"0.00",value:B,onChange:z=>W(z.target.value),className:"h-7 text-xs pl-5"})]}),a.jsx(ce,{type:"date",value:A,onChange:z=>K(z.target.value),className:"h-7 text-xs w-[130px]"})]}),a.jsxs("select",{value:J,onChange:z=>re(z.target.value),className:"h-7 text-xs rounded-md border border-input bg-background px-2 w-full",children:[a.jsx("option",{value:"",children:"Payment methodâ¦"}),a.jsx("option",{value:"Stripe",children:"Stripe"}),a.jsx("option",{value:"Check",children:"Check"}),a.jsx("option",{value:"Other",children:"Other"})]}),a.jsxs("div",{className:"flex flex-col gap-1.5",children:[!le.deposit_paid&&a.jsxs("label",{className:"flex items-center gap-2 text-xs text-foreground cursor-pointer",children:[a.jsx(gt,{checked:G,onCheckedChange:z=>H(!!z),className:"h-3.5 w-3.5"}),"Mark deposit as paid"]}),!le.price_paid&&a.jsxs("label",{className:"flex items-center gap-2 text-xs text-foreground cursor-pointer",children:[a.jsx(gt,{checked:fe,onCheckedChange:z=>te(!!z),className:"h-3.5 w-3.5"}),"Mark paid in full"]})]}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>M(!1),children:"Cancel"}),a.jsx(Y,{type:"button",size:"sm",className:"h-6 text-xs",disabled:(!B||Number(B)<=0)&&!G&&!fe,onClick:()=>U.mutate(),children:"Record"})]})]}),a.jsx(xF,{email:(he==null?void 0:he.email)??null,contactId:n})]})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{children:"Referred By"}),a.jsx(Kt,{value:_,onValueChange:S,options:D.filter(z=>z.id!==n).map(z=>({value:z.id,label:z.name})),placeholder:"Select referring contactâ¦",allowNone:!0,className:"w-full"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{htmlFor:"drawer-notes",children:"Notes"}),a.jsx(qt,{id:"drawer-notes",value:b,onChange:z=>w(z.target.value),rows:3,maxLength:2e3})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2 pb-4",children:[a.jsx(Y,{type:"button",variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),a.jsx(Y,{type:"submit",disabled:V.isPending||!s.trim(),children:V.isPending?"Savingâ¦":"Update"})]})]})})]})})}const Tce="modulepreload",Mce=function(e){return"/"+e},dA={},Dce=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));s=Promise.allSettled(n.map(c=>{if(c=Mce(c),c in dA)return;dA[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":Tce,u||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),u)return new Promise((m,f)=>{h.addEventListener("load",m),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return s.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},yx=["qbo_class","category","supplier","description","unit_amount","basis","source_link","valid_until","notes","spent"],$ce={line_item:"category",supplier_name:"supplier",amount:"unit_amount"},Rce={trip:"Expeditions",peer_group:"Peer Groups",stakeholder_summit:"Summits",coaching:"Coaching"},Ice=e=>e&&Rce[e]||null,C6=(e,t)=>{const n=Ice(e);return n&&t?`${n}:${t}`:null},N1=e=>{const t=(e||"").trim(),n=t.lastIndexOf(":");return(n>=0?t.slice(n+1):t).trim()},Lce=/^\d{4}-(0[1-9]|1[0-2]) \S/,Fce=e=>Lce.test((e||"").trim()),qce=e=>{const t=/^(\d{4})-(\d{2})/.exec(e.startDate||"");if(!t)return"";const n=`${t[1]}-${t[2]}`;if(e.format==="peer_group")return`${n} Cohort ${String(e.nextCohort).padStart(2,"0")}`;const r=(e.location||"").split(",")[0].trim();return r?`${n} ${r}`:n},k6=e=>e,hA=(e,t)=>t.includes(e)?e:null,zce=["per_person","flat","pct_outfitter","pct_price","pct_per_person","pct_revenue"];function E6(e){const t=[];let n=[],r="",s=!1;const i=e.replace(/^\uFEFF/,"");for(let o=0;o<i.length;o++){const l=i[o];s?l==='"'?i[o+1]==='"'?(r+='"',o++):s=!1:r+=l:l==='"'?s=!0:l===","?(n.push(r),r=""):l===` 706`||l==="\r"?(l==="\r"&&i[o+1]===` 707`&&o++,n.push(r),r="",n.some(c=>c.trim()!=="")&&t.push(n),n=[]):r+=l}return n.push(r),n.some(o=>o.trim()!=="")&&t.push(n),t}function Dk(e){return e.map(t=>t.map(n=>`"${String(n??"").replace(/"/g,'""')}"`).join(",")).join(` 708`)}function $k(e,t){const n=new Blob([t],{type:"text/csv"}),r=URL.createObjectURL(n),s=document.createElement("a");s.href=r,s.download=e,s.click(),URL.revokeObjectURL(r)}function Bce(e){const t=e.trim().toLowerCase().replace(/[\s-]+/g,"_");
708if(!t)return"flat";const r={per_participant:"per_person",pp:"per_person",group:"flat",per_group:"flat"}[t]||t;return zce.includes(r)?r:null}const Uce=(e,t)=>e?t==null?"closed_unrecorded":"closed_recorded":t==null?"open_unpaid":"open_part_paid",P6=(e,t)=>Uce(e,t)==="closed_unrecorded",fA=(e,t,n)=>t.trim()?`${e}|s|${t.trim().toLowerCase()}`:`${e}|d|${n.trim().toLowerCase()}`;async function Rk(e){const{supabase:t}=await Dce(async()=>{const{supabase:i}=await Promise.resolve().then(()=>FZ);return{supabase:i}},void 0),n=[];for(let i=0;;i+=1e3){let o=t.from("experience_budget_items").select("*, suppliers(name), experiences(name, type, target_start_date)").eq("category","direct").order("experience_id").order("sort_order").range(i,i+999);e&&(o=o.in("experience_id",e));const{data:l,error:c}=await o;if(c)throw c;if(n.push(...l||[]),!l||l.length<1e3)break}const r=n.map(i=>i.id),s=[];for(let i=0;i<r.length;i+=200){const{data:o,error:l}=await t.from("experience_budget_item_payments").select("budget_item_id, due_month, paid").in("budget_item_id",r.slice(i,i+200)).order("due_month");if(l)throw l;s.push(...o||[])}return n.map(i=>{var o,l,c;return{...i,qbo_class:C6((o=i.experiences)==null?void 0:o.type,((l=i.experiences)==null?void 0:l.name)||""),supplier_name:((c=i.suppliers)==null?void 0:c.name)||"",payments:s.filter(u=>u.budget_item_id===i.id)}})}function O6(e,t,n){return[e.qbo_class||"",k6(t),e.supplier_name,n,e.amount,e.cost_type,e.source_link||"",e.valid_until||"",e.notes||"",e.spent_to_date==null?"":e.spent_to_date]}function Wce({experienceId:e}){const t=at(),{toast:n}=mt(),r=y.useRef(null),[s,i]=y.useState(!1),{data:o=[]}=Ee({queryKey:["experience-resources",e],queryFn:async()=>{const{data:m,error:f}=await F.from("experience_resources").select("*").eq("experience_id",e).order("created_at",{ascending:!1});if(f)throw f;return m}}),l=Me({mutationFn:async m=>{const f=Array.from(m);if(console.log("Upload mutation called with",f.length,"files"),f.length===0)throw new Error("No files selected");i(!0);const x=[];for(const g of f){console.log(`Uploading file: ${g.name}, size: ${g.size}, type: ${g.type}`);const p=g.name.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/_+/g,"_").replace(/^[._-]+|[._-]+$/g,"").slice(0,180)||"file",v=`${e}/${Date.now()}-${p}`,{error:b}=await F.storage.from("experience-resources").upload(v,g,{upsert:!1});if(b)throw console.error("Storage upload error:",b),b;console.log("Storage upload success, inserting DB record...");const{error:w}=await F.from("experience_resources").insert({experience_id:e,file_name:g.name,file_path:v,file_size:g.size,content_type:g.type||"application/octet-stream",visible_to_accepted:!1,visible_to_all:!1});if(w)throw console.error("DB insert error:",w),w;x.push(g.name)}return x},onSuccess:m=>{t.invalidateQueries({queryKey:["experience-resources",e]}),n({title:`Uploaded ${m.length} file${m.length>1?"s":""}`}),i(!1)},onError:m=>{n({title:"Upload failed",description:m.message,variant:"destructive"}),i(!1)}}),c=Me({mutationFn:async({id:m,field:f,value:x})=>{const{error:g}=await F.from("experience_resources").update({[f]:x}).eq("id",m);if(g)throw g},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-resources",e]})}}),u=Me({mutationFn:async({id:m,filePath:f})=>{await F.storage.from("experience-resources").remove([f]);const{error:x}=await F.from("experience_resources").delete().eq("id",m);if(x)throw x},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-resources",e]}),n({title:"Resource deleted"})}}),d=async(m,f)=>{const{data:x,error:g}=await F.storage.from("experience-resources").createSignedUrl(m,300,{download:f});if(g){n({title:"Download failed",description:g.message,variant:"destructive"});return}const p=document.createElement("a");p.href=x.signedUrl,p.download=f,p.target="_blank",p.click()},h=m=>m?m<1024?`${m} B`:m<1024*1024?`${(m/1024).toFixed(0)} KB`:`${(m/(1024*1024)).toFixed(1)} MB`:"";return a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:["Resources (",o.length,")"]}),a.jsx("div",{className:"space-y-1 mb-2",children:o.map(m=>a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(Hs,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("span",{className:"truncate block text-xs",children:m.file_name}),a.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[h(m.file_size),m.created_at&&` · ${Ye(new Date(m.created_at),"MMM d")}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>d(m.file_path,m.file_name),title:"Download",children:a.jsx(ja,{className:"h-3 w-3"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>u.mutate({id:m.id,filePath:m.file_path}),title:"Delete",children:a.jsx(pn,{className:"h-3 w-3"})})]})]}),a.jsxs("div",{className:"flex items-center gap-3 pl-5",children:[a.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-muted-foreground cursor-pointer",children:[a.jsx(gt,{className:"h-3 w-3",checked:m.visible_to_all??!1,onCheckedChange:f=>c.mutate({id:m.id,field:"visible_to_all",value:!!f})}),"All Contacts"]}),a.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-muted-foreground cursor-pointer",children:[a.jsx(gt,{className:"h-3 w-3",checked:m.visible_to_accepted??!1,onCheckedChange:f=>c.mutate({id:m.id,field:"visible_to_accepted",value:!!f})}),"Only Accepted"]})]})]},m.id))}),a.jsx("input",{ref:r,type:"file",multiple:!0,className:"hidden",onChange:m=>{const f=m.target.files;if(f&&f.length>0){const x=Array.from(f);l.mutate(x)}m.target.value=""}}),a.jsx(Y,{size:"sm",variant:"outline",className:"h-8 text-xs w-full",onClick:()=>{var m;return(m=r.current)==null?void 0:m.click()},disabled:s,children:s?a.jsxs(a.Fragment,{children:[a.jsx(vt,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Uploadingâ¦"]}):a.jsxs(a.Fragment,{children:[a.jsx(zt,{className:"h-3.5 w-3.5 mr-1"})," Upload Files"]})})]})}function Kce({experienceId:e}){const t=at(),{toast:n}=mt(),[r,s]=y.useState(!1),[i,o]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState(""),[h,m]=y.useState(null),[f,x]=y.useState(""),[g,p]=y.useState(""),[v,b]=y.useState(""),{data:w=[]}=Ee({queryKey:["experience-addons",e],queryFn:async()=>{const{data:k,error:C}=await F.from("experience_addons").select("*").eq("experience_id",e).order("created_at",{ascending:!0});if(C)throw C;return k}}),N=Me({mutationFn:async()=>{const{error:k}=await F.from("experience_addons").insert({experience_id:e,name:i.trim(),price:parseFloat(l)||0,description:u.trim()||null});if(k)throw k},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-addons",e]}),t.invalidateQueries({queryKey:["budget-included-addons",e]}),o(""),c(""),d(""),s(!1),n({title:"Add-on created"})}}),j=Me({mutationFn:async({id:k,updates:C})=>{const{error:T}=await F.from("experience_addons").update(C).eq("id",k);if(T)throw T},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-addons",e]}),t.invalidateQueries({queryKey:["budget-included-addons",e]})}}),_=k=>{j.mutate({id:k,updates:{name:f.trim(),price:parseFloat(g)||0,description:v.trim()||null}},{onSuccess:()=>{m(null),n({title:"Add-on updated"}),t.invalidateQueries({queryKey:["experience-addons",e]}),t.invalidateQueries({queryKey:["budget-included-addons",e]})}})},S=Me({mutationFn:async k=>{const{error:C}=await F.from("experience_addons").delete().eq("id",k);if(C)throw C},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-addons",e]}),t.invalidateQueries({queryKey:["budget-included-addons",e]}),n({title:"Add-on deleted"})}}),P=k=>{m(k.id),x(k.name),p(String(k.price)),b(k.description||"")};return a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Add-Ons (",w.length,")"]}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>s(!r),children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add"]})]}),r&&a.jsxs("div",{className:"mb-3 space-y-2 rounded-md border border-border bg-background p-2",children:[a.jsx(ce,{value:i,onChange:k=>o(k.target.value),placeholder:"Add-on name (e.g. Extra hotel night)",className:"h-8 text-xs",maxLength:200}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(ce,{type:"number",min:"0",step:"0.01",value:l,onCh
708ange:k=>c(k.target.value),placeholder:"Price",className:"h-8 text-xs w-24"}),a.jsx(ce,{value:u,onChange:k=>d(k.target.value),placeholder:"Description (optional)",className:"h-8 text-xs flex-1",maxLength:500})]}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>s(!1),children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>N.mutate(),disabled:!i.trim()||N.isPending,children:"Save"})]})]}),a.jsx("div",{className:"space-y-2",children:w.map(k=>a.jsx("div",{className:"text-sm group rounded-md border border-transparent hover:border-border p-1.5",children:h===k.id?a.jsxs("div",{className:"flex-1 space-y-1",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsx(ce,{value:f,onChange:C=>x(C.target.value),className:"h-7 text-xs flex-1",maxLength:200}),a.jsx(ce,{type:"number",min:"0",step:"0.01",value:g,onChange:C=>p(C.target.value),className:"h-7 text-xs w-20"})]}),a.jsxs("div",{className:"flex gap-1 justify-end",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>m(null),children:a.jsx(Ht,{className:"h-3 w-3"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-primary",onClick:()=>_(k.id),disabled:!f.trim(),children:a.jsx(On,{className:"h-3 w-3"})})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"text-foreground truncate",children:k.name}),a.jsxs("span",{className:"text-muted-foreground text-xs",children:["$",Number(k.price).toLocaleString()]}),k.third_party_payer&&a.jsx(Ge,{variant:"outline",className:"text-[9px] px-1 py-0",children:"3rd-party paid"})]}),a.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>P(k),children:a.jsx(Rn,{className:"h-3 w-3"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>S.mutate(k.id),children:a.jsx(pn,{className:"h-3 w-3"})})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 mt-1 pl-0.5 text-[11px] text-muted-foreground",children:[a.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[a.jsx(gt,{checked:k.include_in_budget,onCheckedChange:C=>j.mutate({id:k.id,updates:{include_in_budget:!!C}}),className:"h-3.5 w-3.5"}),"Include in budget"]}),k.include_in_budget&&a.jsxs("label",{className:"flex items-center gap-1.5",children:["Est. qty",a.jsx(ce,{type:"number",min:"0",defaultValue:k.budget_quantity,onBlur:C=>{const T=parseInt(C.target.value)||0;T!==k.budget_quantity&&j.mutate({id:k.id,updates:{budget_quantity:T}})},className:"h-6 w-14 text-xs"})]}),a.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[a.jsx(gt,{checked:k.third_party_payer,onCheckedChange:C=>j.mutate({id:k.id,updates:{third_party_payer:!!C}}),className:"h-3.5 w-3.5"}),"3rd-party payer"]})]})]})},k.id))})]})}const Hce=`For our trips we recommend all of our travelers purchase a comprehensive travel insurance policy that can cover things like trip cancellation, trip delay/interruption and emergency medical expenses. 709 710To make it easy we recommend buying a trip protection plan with Wanderwell. Wanderwell travel and health/evacuation insurance has been designed by a mission-driven organization specifically for Four Corners. You can elect trip medical/evac coverage, cancellation, and more. Visit the link below to learn more and purchase the insurance at a very reasonable rate. 711 712https://www.gowanderwell.com/affiliate/four-corners-exploration/ 713 714Please upload a copy of your insurance (from Wanderwell or your preferred provider) to keep it on file here for your convenience.`,Gce=[{description:"Agreements and Insurance",field_type:"section_header",field_options:{section_header:!0},required:!0,sort_order:0,due_on_acceptance:!0},{description:"Liability Waiver & Confidentiality Agreement",field_type:"agreement",field_options:{agreement_text:`I agree to this Confidentiality Agreement ("Agreement") amongst the facilitators and participants of Four Corners Exploration ("Parties"). 715 716Purpose of Agreement: The Parties hereby agree to maintain the confidentiality of all discussions, information, and materials shared during their meetings related to both work and personal lives. 717 718Definition of Confidential Information: "Confidential Information" shall include but not be limited to any and all verbal discussions, written materials, documents, reports, data, plans, strategies, financial information, personal anecdotes, and any other information disclosed during the course of the meetings. 719 720Obligations of Parties: The Parties agree to keep all Confidential Information strictly confidential and shall not disclose, reveal, or make available any Confidential Information to any third party without the express written consent of all Parties. 721 722Exceptions: The obligations of confidentiality shall not apply to any information that (a) is already in the public domain at the time of disclosure or subsequently enters the public domain through no fault of the Parties; (b) was rightfully known to the Parties prior to disclosure without any obligation of confidentiality; (c) is independently developed by the Parties without reference to the Confidential Information; or (d) is required to be disclosed by law, regulation, or court order, provided that the disclosing Party gives prompt notice to the other Parties to enable them to seek a protective order or other appropriate remedy. 723 724Duration: The obligations of confidentiality under this Agreement shall survive the termination of the Parties' relationship and shall remain in effect indefinitely. 725 726Remedies: The Parties acknowledge that a breach of this Agreement may cause irreparable harm, and therefore, in addition to any other remedies available at law or in equity, the non-breaching Party shall be entitled to seek injunctive relief to enforce the terms of this Agreement. 727 728Governing Law: This Agreement shall be governed by and construed in accordance with the laws of Minnesota, without regard to its conflict of laws principles. 729 730Entire Agreement: This Agreement constitutes the entire understanding and agreement between the Parties concerning the subject matter hereof and supersedes all prior or contemporaneous agreements, understandings, negotiations, and discussions, whether oral or written, between the Parties relating to the subject matter hereof. 731 732FOUR CORNERS AGREEMENT AND LIABILITY WAIVER ("Agreement and Waiver") 733 734Authority to Register and/or to Act as Agent: You represent and warrant to Four Corners Exploration ("4C") that you have full legal authority and capacity to complete your participation and/or leadership of the upcoming trip you're taking ("Experience"), including this Agreement and Waiver, on behalf of yourself and/or, where applicable, any party for whom you are registering (the "Registered Parties"), including full authority to make use of the payment method(s) to which registration fees will be charged. As used in this Agreement and Waiver, (a) "4C" means and includes Four Corners Exploration, its partners, licensors, and any and all subsidiaries, affiliated entities, or entities that control, are controlled by, or are under common control with 4C singly or together and its and each of their officers, employees, contractors, subcontractors and agents (and for the avoidance of doubt agents may be defined as anyone operating as a guide or organizer/generator of an Experience not employed by 4C) and each of their agents, representatives, successors and assigns including Jeff Dykstra, Matt Norman, Dale Carnegie & Associates, Norman & Associates, and Partners in Food Solutions ("4C Affiliates"); and (b) "I," "you" or "your" means and includes you (as an individual) and all other Registered Parties for whom you are registering, and by virtue of agreeing to this Agreement and Waiver, for whom you are waiving certain rights. 735 736Assumption of Inherent Risks: 737 738The 4C Experience is meant to be an adventure of reflection, stamina, camaraderie, and mental grit that takes place over a series of days. It is not a competition against other participants, but rather a personal stretch experience and opportunity to enjoy peer relationships and the outdoors. Some of the activities include runs, hikes, skiing, swimming, rafting, etc. The 4C Experience can be a hazardous activity that presents physical and mental challenge to participants. 739 740I acknowledge that the Experience is a test of my physical and mental capacity that carries with it inherent risks of physical injury. Inherent risks are risks that cannot be eliminated completely (without changing the challenging nature of the Experience) regardless of the care and precautions taken by 4C and Released Parties). I also understand that the Experience is strenuous, with the accompanying risks and dangers generally present in such activities. I understand that these hazards may be magnified due to the fact that the Experience is often conducted under what may be adverse conditions and circumstances. 741 742I further understand and acknowledge that any of these risks and others, not specifically named, may cause injury or injuries that may be categorized as minor, serious, or catastrophic. Minor injuries are common and include, but are not limited to: scrapes, bruises, sprains, strains, muscle tension and soreness, nausea, cuts, sunburn, abrasions, grazes, lacerations, and contusions. Serious injuries are less common, but do sometimes occur. They include but are not limited to property loss or damage, broken bone
742s, fractures, torn or strained ligaments and tendons, concussions, exposure, dehydration, heat exhaustion and other heat-related illnesses, mental stress or exhaustion, infection, vomiting, dislocations, hyperthermia, hypothermia, anemia, electrolyte imbalance, loss of consciousness, syncope, dizziness, fainting, seizures, electric shock and/or injury, and neurological disorders/pain. Catastrophic injuries are rare; however, we feel that our participants should be aware that they could occur. These injuries can include, but are not limited to, permanent disabilities, stroke, single or multiple organ failure or dysfunction, physical damage to organs, spinal injuries, paralysis, heart attack, heart failure, blood cell disorder, brain swelling, and even death. 743 744I also understand that it is my responsibility to consult with my personal physician prior to me or my minor child/ward participating in the Experience to ensure that such participation will not pose any unusual risks to my health and well-being. 745 746If I believe or become aware that any aspect of the Experience is unsafe or poses unreasonable risks, I agree to immediately notify appropriate personnel. By participating in the Experience, I am acknowledging that I have found the facilities, equipment, and areas to be used to be safe and acceptable for participation. I accept full and sole responsibility for the condition and adequacy of my equipment. 747 748I understand fully the inherent risks of my participation in the Experience and assert that I am willingly and voluntarily participating in the experience. I have read the preceding paragraphs and acknowledge that 1) I know the nature of the Experience; 2) I understand the demands of this activity relative to my physical condition; and 3) I appreciate the potential impact of the types of injuries and/or illnesses that may result from the Experience. I hereby assert that I knowingly assume all of the inherent risks of the activity on behalf of myself and take full responsibility for any and all damages, liabilities, losses, or expenses that I may incur as a result of participating in the Experience. 749 750Consent to Medical Care: IF YOU NEED MEDICAL TREATMENT AS A RESULT OF YOUR PARTICIPATION IN THIS EXPERIENCE, TRAVEL TO AND FROM THE EXPERIENCE, OR ANY EVENTS INCIDENTAL TO THIS EXPERIENCE, YOU AGREE TO BE FINANCIALLY RESPONSIBLE FOR ANY COSTS INCURRED AS A RESULT OF SUCH TREATMENT. YOU ARE AWARE THAT 4C DOES NOT PROVIDE HEALTH OR LIABILITY INSURANCE FOR YOU AND THAT YOU SHOULD CARRY YOUR OWN INSURANCE. 751 752Delay or Cancellation: I acknowledge that 4C at its sole discretion may delay, modify, or cancel the Experience if conditions beyond the control of 4C, or natural or man-made emergencies beyond the control of 4C, make administering the event unreasonably difficult or unsafe. I agree that conditions beyond the control of 4C may include but not be limited to closure of the accommodations or planned activities. I agree that "emergency" includes but is not limited to: high wind, extreme rain or hail, hurricane, tornado, earthquake, flood, acts of terrorism, fire, threatened or actual strike, labor difficulty or work stoppage, insurrection, war, pandemic or epidemic, public disaster, unavoidable casualty, or any government restrictions related to these events. In the event of a delay, modification, or cancellation of the Experience as described in this paragraph, I understand that I may not be entitled to a refund of my registration fee or any other costs incurred in connection with the Experience. I further understand and agree that the terms of this waiver shall apply to any newly rescheduled date or location. 753 754Govern Participation: I understand that 4C has the authority to issue instructions or directions relating to the manner of my safe participation in the activities of the Experience and the authority to halt my participation in the Experience at any time they deem it necessary to protect the safety of participants and personnel; and/or promote a positive experience for all. 755 756Fee Refunds: I understand that all fees and associated costs (including optional product purchases and donations), paid in registration for this Experience are not refundable for any reason under any circumstances, including but not limited to injury, a scheduling conflict, and/or event cancellation. Transfers to another participant are optional at the discretion of 4C. 757 758Taxes: 4C's fees do not include any taxes, levies, duties or similar governmental assessments of any nature, including, for example, value-ad
758ded, sales, use or withholding taxes, assessable by any jurisdiction whatsoever (collectively, "Taxes"). You are responsible for paying all Taxes associated with your purchases hereunder. If 4C has the legal obligation to pay or collect Taxes for which you are responsible under this section, 4C will invoice you and you will be required to pay that amount unless you provide 4C with a valid tax exemption certificate authorized by the appropriate taxing authority. For clarity, 4C is solely responsible for taxes assessable against it based on its income, property and employees. 759 760RELEASE AND WAIVER OF LIABILITY: IN CONSIDERATION FOR BEING ALLOWED TO PARTICIPATE IN THIS EXPERIENCE, YOU RELEASE FROM LIABILITY AND WAIVE YOUR RIGHT TO SUE 4C AND 4C AFFILIATES FROM ANY AND ALL CLAIMS, INCLUDING CLAIMS OF 4C'S OR 4C AFFILIATES' NEGLIGENCE, RESULTING IN ANY PHYSICAL INJURY, ILLNESS (INCLUDING DEATH) OR ECONOMIC LOSS YOU MAY SUFFER OR WHICH MAY RESULT FROM YOUR PARTICIPATION IN THIS EXPERIENCE, TRAVEL TO AND FROM THE EXPERIENCE (INCLUDING AIR TRAVEL), OR ANY EVENTS INCIDENTAL TO THIS EXPERIENCE. 761 762INDEMNITY: YOU AGREE TO INDEMNIFY, DEFEND, AND HOLD HARMLESS 4C AND 4C AFFILIATES FROM ANY AND ALL CLAIMS, LOSS OR DAMAGE TO MY PERSONAL PROPERTY, LIABILITIES AND COSTS, INCLUDING ATTORNEY'S FEES, AS A RESULT OF MY PARTICIPATION IN THIS EXPERIENCE, INCLUDING TRAVEL TO AND FROM THE EXPERIENCE (INCLUDING AIR TRAVEL) OR ANY EVENTS INCIDENTAL TO THIS EXPERIENCE. IF 4C OR 4C AFFILIATES INCUR ANY OF THESE TYPES OF EXPENSES, YOU AGREE TO REIMBURSE 4C. 763 764DISCLAIMER OF WARRANTIES: YOU EXPRESSLY AGREE THAT USE OF 4C'S SERVICES IS AT YOUR SOLE RISK. THE SERVICES ARE PROVIDED ON AN "AS IS" AND "AS AVAILABLE" BASIS. 4C MAKES NO WARRANTY THAT 4C SERVICES WILL BE UNINTERRUPTED, SECURE, OR ERROR FREE. 4C EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 4C DOES NOT GUARANTEE THE ACCURACY OR COMPLETENESS OF ANY INFORMATION ON, OR PROVIDED IN CONNECTION WITH, THE 4C MATERIALS AND WEBSITE. 4C IS NOT RESPONSIBLE FOR ANY ERRORS OR OMISSIONS, OR FOR THE RESULTS OBTAINED FROM THE USE OF SUCH INFORMATION. 765 766Personal Release: 4C (and/or others on behalf of 4C) may be photographing, recording (both audio and video), webcasting, podcasting, or otherwise transmitting during any or all of an Experience. Your image, likeness, voice, statements and other identifying characteristics (each, an "Image") may be captured in photographs, recordings (both audio and video), webcasts, podcasts, or other transmissions of the Experience (each, a "Recording"). 767 768You hereby grant 4C a worldwide, royalty-free, fully paid-up, non-exclusive, perpetual, irrevocable, transferable and fully sublicensable license, without additional consideration to you or any third-party, to reproduce, distribute, perform and display (publicly or otherwise, create derivative works of, adapt, modify and otherwise use, analyze and exploit Recordings (including your Images therein), in whole or in part, in any format or media now known or hereinafter developed, and for any purpose (including for promotional purposes, such as testimonials). 769 7704C exclusively owns all right, title and interest (including intellectual property rights) in and to the Recordings, all modifications and derivatives of Recordings, and all proceeds derived therefrom. 4C has no obligation to share any such proceeds with you. 771 772You hereby irrevocably waive any right you may have to inspect or approve the use of other exploitation of any Recording or any reproductions thereof, and you agree that 4C has no obligation to use any Recording (including any Images) or otherwise exercise any of the rights granted to 4C with respect to your Images. 773 774Your Images may appear in Recordings made available to the public, and third parties may retain, use or distribute such Recordings. Once made available to the public, 4C has no control over, and is not responsible for, any use or misuse (including any distribution) by any third party of Recordings. 775 776In connection with the use or other exploitation of Recordings (including your Images), you hereby irrevocably waive and release any and all claims with respect to intellectual property, rights of publicity, rights of privacy, and any other claims or damages with respect to such use or other exploitation. 777 778Limitation of Liability: You agree that the maximum aggregate liability of 4C, together with all 4C Affiliates, for all damages, losses and causes of action in connection with this Experience will be limited to the Experience registration fees paid by you to AND RECEIVED BY 4C for the Experience giving rise to the liability. IN NO EVENT WILL 4C BE LIABLE FOR ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, PUNITIVE, SPECIAL, EXEMPLARY OR SIMILAR DAMAGES OF ANY KIND (INCLUDING WITHOUT LIMITATION DAMAGES FOR LOSS OF PROFITS OR OPPORTUNITIES, OR OTHER PECUNIARY LOSS) ARISING OUT OF THIS EXPERIENCE OR THIS AGREEMENT, WHETHER SUCH LIABILITY IS PREDICATED ON CONTRACT, TORT, STRICT LIABILITY OR ANY OTHER THEORY OF RECOVERY. 779 780Arbitration: Any dispute arising out of this Agreement shall be settled by arbitration to be held in Minneapolis, Minnesota, before a single arbitrator and in accordance with the Commercial Arbitration Rules then in effect of the American Arbitration Association. The parties will cooperate with each other in causing the arbitration to be held in as efficie
780nt and expeditious a manner as practicable. If the parties are unable to appoint a mutually acceptable arbitrator within 30 days after a party gives written notice to the other party requesting arbitration of a dispute, the American Arbitration Association shall appoint the arbitrator in accordance with the Commercial Arbitration Rules. The arbitrator may grant injunctions or other relief in such dispute or controversy. The decision of the Arbitrator shall be final, conclusive and binding on the parties to the arbitration. Judgment may be entered on the arbitrator's decision on any court having jurisdiction. Each party to this Agreement shall pay one half of the costs and expenses of such arbitration, and each party shall separately pay the fees and expenses of its own counsel. Nothing herein shall prevent the parties from settling any dispute by mutual agreement. 781 782Successors and Assigns: This agreement shall be binding on you and your successors and assigns and upon 4C and its successors and assigns. Neither party shall assign nor transfer its interest in this agreement or any part thereof without the written consent of the other party. 783 784Governing Law: This agreement shall be governed by and construed in accordance with the laws of Minnesota, without giving effect to any conflict of laws provisions. 785 786Acceptance: This agreement may be executed by consenting to reading and understanding the agreement through the registration form and shall become binding when you have ticked the box demonstrating your consent. 787 788Severability: You further expressly agree that this Agreement and Waiver is intended to be as broad and inclusive as is permitted by applicable law, and if any provision of this Agreement and Waiver is held to be unenforceable by a court of competent jurisdiction for any reason whatsoever, (a) the validity, legality, and enforceability of the remaining provisions of this Agreement and Waiver (including without limitation, all portions of any provisions containing any such unenforceable provision that are not themselves unenforceable) shall not in any way be affected or impaired thereby, and (b) to the fullest extent possible, the unenforceable provision shall be deemed modified and replaced by a provision that approximates the intent and economic effect of the unenforceable provision and the Agreement and Waiver shall be deemed amended accordingly.`},required:!0,sort_order:1,due_on_acceptance:!1},{description:"Profile",field_type:"section_header",field_options:{section_header:!0},required:!0,sort_order:2,due_on_acceptance:!0},{description:"Travel / Evacuation Insurance",field_type:"file_upload",field_options:{accept:"*/*",agreement_text:Hce},required:!1,sort_order:3,due_on_acceptance:!1},{description:"Phone Number",field_type:"text",field_options:{placeholder:"Your phone number",contact_field:"phone"},required:!1,sort_order:4,due_on_acceptance:!1},{description:"Street Address",field_type:"text",field_options:{placeholder:"123 Main St",contact_field:"address_street"},required:!1,sort_order:5,due_on_acceptance:!1},{description:"City",field_type:"text",field_options:{placeholder:"City",contact_field:"address_city"},required:!1,sort_order:6,due_on_acceptance:!1},{description:"State / Province",field_type:"text",field_options:{placeholder:"e.g. MN",contact_field:"address_state"},required:!1,sort_order:7,due_on_acceptance:!1},{description:"Postal Code",field_type:"text",field_options:{placeholder:"Postal / ZIP code",contact_field:"address_postal_code"},required:!1,sort_order:8,due_on_acceptance:!1},{description:"Country",field_type:"text",field_options:{placeholder:"Country",contact_field:"address_country"},required:!1,sort_order:9,due_on_acceptance:!1},{description:"Emergency Contact Name",field_type:"text",field_options:{placeholder:"Full name",contact_field:"emergency_contact_name"},required:!0,sort_order:10,due_on_acceptance:!1},{description:"Emergency Contact Phone",field_type:"text",field_options:{placeholder:"Phone number",contact_field:"emergency_contact_phone"},required:!0,sort_order:11,due_on_acceptance:!1},{description:"Emergency Contact Relationship",field_type:"text",field_options:{placeholder:"e.g. Spouse, Parent, Sibling",contact_field:"emergency_contact_relationship"},required:!0,sort_order:12,due_on_acceptance:!1},{description:"Passport#",field_type:"text",field_options:null,required:!0,sort_order:13,due_on_acceptance:!1},{description:"Tell us more about you",field_type:"section_header",field_options:{section_header:!0},required:!0,sort_order:14,due_on_acceptance:!0},{description:"Shirt Size",field_type:"select",field_options:{options:["Small","Medium","Large","X-Large"]},required:!0,sort_order:15,due_on_acceptance:!1},{description:"Favorite Snacks and Drinks",field_type:"textarea",field_options:null,required:!0,sort_order:16,due_on_acceptance:!1},{description:"Please upload a Head Shot Photo",field_type:"file_upload",field_options:{accept:"*/*"},required:!0,sort_order:17,due_on_acceptance:!1},{description:"LinkedIn Profile",field_type:"text",field_options:{placeholder:"https://linkedin.com/in/...",contact_field:"linkedin_url"},required:!0,sort_order:18,due_on_acceptance:!1},{description:"Instagram Handle",field_type:"text",field_options:{placeholder:"@yourhandle",contact_field:"instagram_handle"},required:!1,sort_order:19,due_on_acceptance:!1},{description:"Outfitter Questions",field_type:"section_header",field_options:{section_header:!0},required:!0,sort_order:20,due_on_acceptance:!0},{description:"Age",field_type:"text",field_options:{placeholder:"Bike Outfitter Question "},required:!1,sort_order:21,due_on_acceptance:!1},{description:"Height",field_type:"text",field_options:null,required:!1,sort_order:22,due_on_acceptance:!1},{description:"Fitness Level (1-5)",field_type:"select",field_options:{options:["1","2","3","4","5"]},required:!1,sort_order:23,due_on_acceptance:!1},{description:"Activity Experience Level (1-5)",field_type:"select",field_options:{options:["1","2","3","4","5"]},required:!1,sort_order:24,due_on_acceptance:!1},{description:"Any Medical conditions to be aware of? If yes, please give details",field_type:"textarea",field_options:null,required:!0,sort_order:25,due_on_acceptance:!1},{description:"Any food allergies or dietary concerns?",field_type:"textarea",field_options:null,required:!0,sort_order:26,due_on_acceptance:!1},{description:"Flight Information in and out of Destination City",field_type:"section_header",field_options:{section_header:!0},required:!0,sort_order:27,due_on_acceptance:!1},{description:"Flight timing guidance coming soon.",field_type:"information",field_options:{display_only:!0},required:!1,sort_order:28,due_on_acceptance:!1},{description:"Flight Arrival Information (airline, flight# and time)",field_type:"textarea",field_options:null,required:!0,sort_order:29,due_on_acceptance:!1},{description:"Flight Departure Information (airline and time)",field_type:"textarea",field_options:null,required:!0,sort_order:30,due_on_acceptance:!1},{description:"Outfitter Waiver - Coming Soon",field_type:"section_header",field_options:{section_header:!0},required:!0,sort_order:31,due_on_acceptance:!1},{description:"Waiver",field_type:"agreement",field_options:{agreement_text:"https://book.peek.com/waivers/9e1702a1-38a5-4960-9292-f320b0434666/b_33wrjpj;s=36cbc52520f77015"},required:!0,sort_order:32,due_on_acceptance:!1}],S1=[{value:"section_header",label:"Section Header",icon:R3},{value:"information",label:"Information",icon:tm},{value:"task",label:"Checklist Task",icon:Gx},{value:"text",label:"Short Text",icon:SH},{value:"textarea",label:"Long Text",icon:HK},{value:"file_upload",label:"File Upload",icon:ao},{value:"agreement",label:"Agreement / Waiver",icon:Hs},{value:"select",label:"Dropdown Select",icon:oH}],Vce=Object.fromEntries(S1.map(e=>[e.value,e.label]));function Yce({experienceId:e}){const t=at(),{toast:n}=mt(),[r,s]=y.useState(!1),[i,o]=y.useState(!0),[l,c]=y.useState(null),[u,d]=y.useState(null),[h,m]=y.useState(null),[f,x]=y.useState(null),[g,p]=y.useState(null),[v,b]=y.useState(""),[w,N]=y.useState("task"),[j,_]=y.useState(!1),[S,P]=y.useState(""),[k,C]=y.useState(""),[T,O]=y.useState(""),[L,E]=y.useState(""),[R,q]=y.useState(!1),[I,$]=y.useState(""),[M,B]=y.useState("task"),[W,A]=y.useState(!1),[K,G]=y.useState(""),[H,fe]=y.useState(""),[te,J]=y.useState(""),[re,pe]=y.useState(""),[ye,X]=y.useState(!1),[he,D]=y.useState(null),{data:le=[],isSuccess:V}=Ee({queryKey:["experience-form-fields",e],queryFn:async()=>{const{data:Ae,error:et}=await F.from("activities").select("id, description, field_type, field_options, required, sort_order, completed, type, due_date, due_on_acceptance").eq("experience_id",e).is("contact_id",null).eq("type","form-field").order("sort_order",{ascending:!0});if(et)throw et;return Ae}}),U=(Ae,et,Ne,be)=>{const Ue={};return(Ae==="agreement"||Ae==="file_upload")&&et&&(Ue.agreement_text=et),Ae==="select"&&Ne&&(Ue.options=Ne.split(` 789`).map(Ze=>
789Ze.trim()).filter(Boolean)),(Ae==="text"||Ae==="textarea")&&be&&(Ue.placeholder=be),Ae==="file_upload"&&(Ue.accept="*/*"),Ae==="information"&&(Ue.display_only=!0),Ae==="section_header"&&(Ue.section_header=!0),Object.keys(Ue).length>0?Ue:null},z=Me({mutationFn:async()=>{const Ae=le.length>0?Math.max(...le.map(Ne=>Ne.sort_order)):-1,{error:et}=await F.from("activities").insert({description:v.trim(),experience_id:e,field_type:w,field_options:U(w,S,k,T),required:j,sort_order:Ae+1,type:"form-field",due_date:R?null:L||null,due_on_acceptance:R});if(et)throw et},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-form-fields",e]}),t.invalidateQueries({queryKey:["experience-activities",e]}),Q(),n({title:"Form field added"})}}),Z=Me({mutationFn:async({id:Ae})=>{const{error:et}=await F.from("activities").update({description:I.trim(),field_type:M,field_options:U(M,K,H,te),required:W,due_date:ye?null:re||null,due_on_acceptance:ye}).eq("id",Ae);if(et)throw et},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-form-fields",e]}),t.invalidateQueries({queryKey:["experience-activities",e]}),c(null),n({title:"Field updated"})}}),ve=Me({mutationFn:async Ae=>{const{error:et}=await F.from("activities").delete().eq("id",Ae);if(et)throw et},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-form-fields",e]}),t.invalidateQueries({queryKey:["experience-activities",e]}),t.invalidateQueries({queryKey:["all-activities"]})}}),ee=Me({mutationFn:async({fromId:Ae,toId:et})=>{const Ne=[...le],be=Ne.findIndex(rt=>rt.id===Ae),Ue=Ne.findIndex(rt=>rt.id===et);if(be===-1||Ue===-1||be===Ue)return;const[Ze]=Ne.splice(be,1);Ne.splice(Ue,0,Ze);const nt=Ne.map((rt,kt)=>F.from("activities").update({sort_order:kt}).eq("id",rt.id));await Promise.all(nt)},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-form-fields",e]})}}),de=Me({mutationFn:async({fromSectionId:Ae,toSectionId:et})=>{const Ne=[];let be=[];for(const jt of le)jt.field_type==="section_header"?Ne.push({headerId:jt.id,fieldIds:[]}):Ne.length>0?Ne[Ne.length-1].fieldIds.push(jt.id):be.push(jt.id);const Ue=Ne.findIndex(jt=>jt.headerId===Ae),Ze=Ne.findIndex(jt=>jt.headerId===et);if(Ue===-1||Ze===-1||Ue===Ze)return;const[nt]=Ne.splice(Ue,1);Ne.splice(Ze,0,nt);const rt=[...be];for(const jt of Ne)rt.push(jt.headerId,...jt.fieldIds);const kt=rt.map((jt,Et)=>F.from("activities").update({sort_order:Et}).eq("id",jt));await Promise.all(kt)},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-form-fields",e]})}}),je=Me({mutationFn:async()=>{const Ae=le.length>0?Math.max(...le.map(be=>be.sort_order)):-1,et=Gce.map((be,Ue)=>({description:be.description,experience_id:e,field_type:be.field_type,field_options:be.field_options,required:be.required,sort_order:Ae+1+Ue,type:"form-field",due_on_acceptance:be.due_on_acceptance}));if(et.length===0)return;const{error:Ne}=await F.from("activities").insert(et);if(Ne)throw Ne},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-form-fields",e]}),t.invalidateQueries({queryKey:["experience-activities",e]}),n({title:"Default fields added"})}}),Q=()=>{b(""),N("task"),_(!1),P(""),C(""),O(""),E(""),q(!1),s(!1)},oe=Ae=>{var et,Ne,be;c(Ae.id),$(Ae.description),B(Ae.field_type),A(Ae.required),G(((et=Ae.field_options)==null?void 0:et.agreement_text)||""),fe((((Ne=Ae.field_options)==null?void 0:Ne.options)||[]).join(` 790`)),J(((be=Ae.field_options)==null?void 0:be.placeholder)||""),pe(Ae.due_date?Ae.due_date.substring(0,10):""),X(Ae.due_on_acceptance||!1)},Pe=le.length>0,ze=y.useRef(!1);y.useEffect(()=>{V&&le.length===0&&!ze.current&&!je.isPending&&(ze.current=!0,je.mutate())},[V,le]);const Je=Ae=>{var et,Ne,be,Ue;return a.jsxs(a.Fragment,{children:[l===Ae.id?a.jsxs("div",{className:"p-2 space-y-2",children:[a.jsx(ce,{value:I,onChange:Ze=>$(Ze.target.value),className:"h-7 text-xs",maxLength:300}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(lt,{value:M,onValueChange:B,children:[a.jsx(it,{className:"h-7 text-xs flex-1",children:a.jsx(ct,{})}),a.jsx(ot,{children:S1.map(Ze=>a.jsx(Oe,{value:Ze.value,children:Ze.label},Ze.value))})]}),a.jsxs("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:W,onChange:Ze=>A(Ze.target.checked),className:"rounded"}),"Required"]})]}),(M==="agreement"||M==="file_upload")&&a.jsx(qt,{value:K,onChange:Ze=>G(Ze.target.value),placeholder:M==="file_upload"?"Description / instructions shown above the upload fieldâ¦":"Agreement textâ¦",rows:4,className:"text-xs"}),M==="select"&&a.jsx(qt,{value:H,onChange:Ze=>fe(Ze.target.value),placeholder:"One option per line",rows:3,className:"text-xs"}),(M==="text"||M==="textarea")&&a.jsx(ce,{value:te,onChange:Ze=>J(Ze.target.value),placeholder:"Placeholder text (optional)",className:"h-7 text-xs"}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer whitespace-nowrap",children:[a.jsx("input",{type:"checkbox",checked:ye,onChange:Ze=>{X(Ze.target.checked),Ze.target.checked&&pe("")},className:"rounded"}),"Due on Acceptance"]}),!ye&&a.jsxs(a.Fragment,{children:[a.jsx("label",{className:"text-xs text-muted-foreground whitespace-nowrap",children:"Due Date"}),a.jsx(ce,{type:"date",value:re,onChange:Ze=>pe(Ze.target.value),className:"h-7 text-xs flex-1"})]})]}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>c(null),children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>Z.mutate({id:Ae.id}),disabled:!I.trim(),children:"Save"})]})]}):a.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 group",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 cursor-pointer",onClick:()=>D(he===Ae.id?null:Ae.id),children:[a.jsx(iC,{className:Se("h-3 w-3 flex-shrink-0 cursor-grab active:cursor-grabbing",Ae.field_type==="section_header"?"text-accent":"text-muted-foreground
790/50")}),a.jsx("span",{className:Se("truncate",Ae.field_type==="section_header"?"text-xs font-semibold text-foreground":"text-xs text-foreground"),children:Ae.description}),Ae.field_type!=="section_header"&&a.jsx(Ge,{variant:"outline",className:"text-[9px] px-1 py-0 flex-shrink-0",children:Vce[Ae.field_type]||Ae.field_type}),((et=Ae.field_options)==null?void 0:et.contact_field)&&a.jsx(Ge,{variant:"default",className:"text-[9px] px-1 py-0 flex-shrink-0 bg-primary/20 text-primary border-0",children:"Contact"}),Ae.required&&a.jsx(Ge,{variant:"secondary",className:"text-[9px] px-1 py-0 flex-shrink-0",children:"Required"}),Ae.due_on_acceptance&&!Ae.due_date&&a.jsx(Ge,{variant:"outline",className:"text-[9px] px-1 py-0 flex-shrink-0 text-accent border-accent/30",children:"Due on Acceptance"}),Ae.due_date&&a.jsxs(Ge,{variant:"outline",className:"text-[9px] px-1 py-0 flex-shrink-0 text-muted-foreground",children:["Due ",Ye(new Date(Ae.due_date),"MMM d")]}),Ae.field_type==="section_header"&&a.jsx(Ge,{variant:"outline",className:"text-[9px] px-1 py-0 flex-shrink-0 text-accent border-accent/30",children:"Section"}),(Ae.field_type==="agreement"||((Ne=Ae.field_options)==null?void 0:Ne.agreement_text))&&(he===Ae.id?a.jsx(_r,{className:"h-3 w-3 text-muted-foreground"}):a.jsx(_n,{className:"h-3 w-3 text-muted-foreground"}))]}),a.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>oe(Ae),children:a.jsx(Rn,{className:"h-3 w-3"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>ve.mutate(Ae.id),children:a.jsx(pn,{className:"h-3 w-3"})})]})]}),he===Ae.id&&((be=Ae.field_options)==null?void 0:be.agreement_text)&&a.jsx("div",{className:"px-3 pb-2 border-t border-border",children:a.jsxs("p",{className:"text-[10px] text-muted-foreground whitespace-pre-line max-h-32 overflow-y-auto mt-1.5",children:[Ae.field_options.agreement_text.substring(0,500),Ae.field_options.agreement_text.length>500&&"â¦"]})}),he===Ae.id&&Ae.field_type==="select"&&((Ue=Ae.field_options)==null?void 0:Ue.options)&&a.jsx("div",{className:"px-3 pb-2 border-t border-border",children:a.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:Ae.field_options.options.map((Ze,nt)=>a.jsx(Ge,{variant:"outline",className:"text-[9px]",children:Ze},nt))})})]})};return a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("button",{type:"button",onClick:()=>o(Ae=>!Ae),className:"flex items-center justify-between w-full text-left",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5",children:[a.jsx(Hs,{className:"h-3.5 w-3.5"})," Information & Forms (",le.length,")"]}),i?a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),!i&&a.jsxs("div",{className:"flex items-center justify-end gap-1 mt-2",children:[!Pe&&a.jsxs(Y,{variant:"outline",size:"sm",className:"h-6 text-xs",onClick:()=>je.mutate(),disabled:je.isPending,children:[a.jsx(Gx,{className:"h-3 w-3 mr-1"})," Add Defaults"]}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>s(!r),children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add Field/Section"]})]}),!i&&a.jsxs(a.Fragment,{children:[r&&a.jsxs("div",{className:"mb-3 space-y-2 rounded-md border border-border bg-background p-3",children:[a.jsx(ce,{value:v,onChange:Ae=>b(Ae.target.value),placeholder:"Field label (e.g. Passport Number, Clothing Size)",className:"h-8 text-xs",maxLength:300}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(lt,{value:w,onValueChange:N,children:[a.jsx(it,{className:"h-8 text-xs flex-1",children:a.jsx(ct,{})}),a.jsx(ot,{children:S1.map(Ae=>a.jsx(Oe,{value:Ae.value,children:Ae.label},Ae.value))})]}),a.jsxs("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:j,onChange:Ae=>_(Ae.target.checked),className:"rounded"}),"Required"]})]}),(w==="agreement"||w==="file_upload")&&a.jsx(qt,{value:S,onChange:Ae=>P(Ae.target.value),placeholder:w==="file_upload"?"Description / instructions shown above the upload fieldâ¦":"Agreement text that must be acceptedâ¦",rows:4,className:"text-xs"}),w==="select"&&a.jsx(qt,{value:k,onChange:Ae=>C(Ae.target.value),placeholder:"One option per line (e.g. Small\\nMedium\\nLarge)",rows:3,className:"text-xs"}),(w==="text"||w==="textarea")&&a.jsx(ce,{value:T,onChange:Ae=>O(Ae.target.value),placeholder:"Placeholder text (optional)",className:"h-8 text-xs"}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsxs("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer whitespace-nowrap",children:[a.jsx("input",{type:"checkbox",checked:R,onChange:Ae=>{q(Ae.target.checked),Ae.target.checked&&E("")},className:"rounded"}),"Due on Acceptance"]}),!R&&a.jsxs(a.Fragment,{children:[a.jsx("label",{className:"text-xs text-muted-foreground whitespace-nowrap",children:"Due Date"}),a.jsx(ce,{type:"date",value:L,onChange:Ae=>E(Ae.target.value),className:"h-8 text-xs flex-1"})]})]}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:Q,children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>z.mutate(),disabled:!v.trim()||z.isPending,children:"Add"})]})]}),a.jsx("div",{className:"space-y-1",children:(()=>{const Ae=[];let et={header:null,fields:[]};for(const Ne of le)Ne.field_type==="section_header"?((et.fields.length>0||et.header)&&Ae.push(et),et={header:Ne,fields:[]}):et.fields.push(Ne);return(et.fields.length>0||et.header)&&Ae.push(et),Ae.map(Ne=>{if(Ne.header){const be=Ne.header.id,Ue=f===be,Ze=g===be&&f!==be;return a.jsxs("div",{className:Se("rounded-md border-2 transition-all",Ue&&"opacity-40",Ze?"border-accent border-dashed":"border-transparent"),children:[a.jsx("div",{draggable:l!==be&&!u,onDragStart:nt=>{nt.stopPropagation(),x(be),d(null),nt.dataTransfer.effectAllowed="move"},onDragOver:nt=>{nt.preventDefault(),f?p(be):u&&m(be)},onDragLeave:()=>{g===be&&p(null),h===be&&m(null)},onDrop:nt=>{nt.preventDefault(),nt.stopPropagation(),f&&f!==be?de.mutate({fromSectionId:f,toSectionId:be}):u&&u!==be&&ee.mutate({fromId:u,toId:be}),x(null),p(null),d(null),m(null)},onDragEnd:()=>{x(null),p(null),d(null),m(null)},className:Se("rounded border bg-muted/40 transition-all",u===be&&"opacity-40",h===be&&u!==be&&"border-primary border-dashed",l!==be&&"border-border"),children:Je(Ne.header)}),a.jsx("div",{className:"ml-3 mt-1 space-y-1 border-l-2 border-muted pl-2",children:Ne.fields.map(nt=>a.jsx("div",{draggable:l!==nt.id&&!f,onDragStart:rt=>{rt.stopPropagation(),d(nt.id),x(null),rt.dataTransfer.effectAllowed="move"},onDragOver:rt=>{rt.preventDefault(),f||m(nt.id)},onDragLeave:()=>{h===nt.id&&m(null)},onDrop:rt=>{rt.preventDefault(),rt.stopPropagation(),u&&u!==nt.id&&ee.mutate({fromId:u,toId:nt.id}),d(null),m(null)},onDragEnd:()=>{d(null),m(null)},className:Se("rounded border border-border bg-background transition-all",u===nt.id&&"opacity-40",h===nt.id&&u!==nt.id&&"border-primary border-dashed"),children:Je(nt)},nt.id))})]},be)}
790return Ne.fields.map(be=>a.jsx("div",{draggable:l!==be.id&&!f,onDragStart:Ue=>{d(be.id),x(null),Ue.dataTransfer.effectAllowed="move"},onDragOver:Ue=>{Ue.preventDefault(),f||m(be.id)},onDragLeave:()=>{h===be.id&&m(null)},onDrop:Ue=>{Ue.preventDefault(),u&&u!==be.id&&ee.mutate({fromId:u,toId:be.id}),d(null),m(null)},onDragEnd:()=>{d(null),m(null)},className:Se("rounded border border-border bg-background transition-all",u===be.id&&"opacity-40",h===be.id&&u!==be.id&&"border-primary border-dashed"),children:Je(be)},be.id))})})()})]})]})}var A6="AlertDialog",[Qce,_3e]=jr(A6,[R4]),xo=R4(),T6=e=>{const{__scopeAlertDialog:t,...n}=e,r=xo(t);return a.jsx(cb,{...r,...n,modal:!0})};T6.displayName=A6;var Xce="AlertDialogTrigger",M6=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=xo(n);return a.jsx(J4,{...s,...r,ref:t})});M6.displayName=Xce;var Jce="AlertDialogPortal",D6=e=>{const{__scopeAlertDialog:t,...n}=e,r=xo(t);return a.jsx(ub,{...r,...n})};D6.displayName=Jce;var Zce="AlertDialogOverlay",$6=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=xo(n);return a.jsx(hh,{...s,...r,ref:t})});$6.displayName=Zce;var nd="AlertDialogContent",[eue,tue]=Qce(nd),nue=t3("AlertDialogContent"),R6=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...s}=e,i=xo(n),o=y.useRef(null),l=Ct(t,o),c=y.useRef(null);return a.jsx(nte,{contentName:nd,titleName:I6,docsSlug:"alert-dialog",children:a.jsx(eue,{scope:n,cancelRef:c,children:a.jsxs(fh,{role:"alertdialog",...i,...s,ref:l,onOpenAutoFocus:Fe(s.onOpenAutoFocus,u=>{var d;u.preventDefault(),(d=c.current)==null||d.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[a.jsx(nue,{children:r}),a.jsx(aue,{contentRef:o})]})})})});R6.displayName=nd;var I6="AlertDialogTitle",L6=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=xo(n);return a.jsx(_p,{...s,...r,ref:t})});L6.displayName=I6;var F6="AlertDialogDescription",q6=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=xo(n);return a.jsx(jp,{...s,...r,ref:t})});q6.displayName=F6;var rue="AlertDialogAction",z6=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,s=xo(n);return a.jsx(db,{...s,...r,ref:t})});z6.displayName=rue;var B6="AlertDialogCancel",U6=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:s}=tue(B6,n),i=xo(n),o=Ct(t,s);return a.jsx(db,{...i,...r,ref:o})});U6.displayName=B6;var aue=({contentRef:e})=>{const t=`\`${nd}\` requires a description for the component to be accessible for screen reader users. 791 792You can add a description to the \`${nd}\` by passing a \`${F6}\` component as a child, which also benefits sighted users by adding visible context to the dialog. 793 794Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${nd}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. 795 796For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return y.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},sue=T6,iue=M6,oue=D6,W6=$6,K6=R6,H6=z6,G6=U6,V6=L6,Y6=q6;const lue=sue,cue=iue,uue=oue,Q6=y.forwardRef(({className:e,...t},n)=>a.jsx(W6,{className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Q6.displayName=W6.displayName;const X6=y.forwardRef(({className:e,...t},n)=>a.jsxs(uue,{children:[a.jsx(Q6,{}),a.jsx(K6,{ref:n,className:Se("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rou
796nded-lg",e),...t})]}));X6.displayName=K6.displayName;const J6=({className:e,...t})=>a.jsx("div",{className:Se("flex flex-col space-y-2 text-center sm:text-left",e),...t});J6.displayName="AlertDialogHeader";const Z6=({className:e,...t})=>a.jsx("div",{className:Se("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Z6.displayName="AlertDialogFooter";const e8=y.forwardRef(({className:e,...t},n)=>a.jsx(V6,{ref:n,className:Se("text-lg font-semibold",e),...t}));e8.displayName=V6.displayName;const t8=y.forwardRef(({className:e,...t},n)=>a.jsx(Y6,{ref:n,className:Se("text-sm text-muted-foreground",e),...t}));t8.displayName=Y6.displayName;const n8=y.forwardRef(({className:e,...t},n)=>a.jsx(H6,{ref:n,className:Se(gm(),e),...t}));n8.displayName=H6.displayName;const r8=y.forwardRef(({className:e,...t},n)=>a.jsx(G6,{ref:n,className:Se(gm({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));r8.displayName=G6.displayName;function due({open:e,onOpenChange:t,experienceId:n,experienceName:r,generatorId:s,generatorName:i,generatorEmail:o,canManage:l=!0}){const c=at(),{toast:u}=mt(),[d,h]=y.useState(""),[m,f]=y.useState("preview"),{data:x}=go(),g=(x==null?void 0:x.type)==="employee",{data:p=[]}=Ee({queryKey:["experience-gen-agreements",n],queryFn:async()=>{const{data:k,error:C}=await F.from("generator_experience_agreements").select("*").eq("experience_id",n);if(C)throw C;return k}}),{data:v,isFetched:b}=Ee({queryKey:["generator-agreement-template"],queryFn:async()=>{const{data:k,error:C}=await F.from("generator_agreement_template").select("body_markdown").order("updated_at",{ascending:!1}).limit(1).maybeSingle();if(C)throw C;return k}}),w=p.find(k=>k.generator_id===s);y.useEffect(()=>{if(!e||!b)return;let k=!1;return(async()=>{if(w){const O=w.body_markdown??"";if(!O.trim()&&(v!=null&&v.body_markdown)&&l&&!w.accepted_at&&!w.verbally_accepted_at){const{error:L}=await F.from("generator_experience_agreements").update({body_markdown:v.body_markdown}).eq("id",w.id);k||h(v.body_markdown),L||c.invalidateQueries({queryKey:["experience-gen-agreements",n]});return}k||h(O);return}if(!l)return;const{data:C,error:T}=await F.from("generator_experience_agreements").insert({experience_id:n,generator_id:s,body_markdown:(v==null?void 0:v.body_markdown)??""}).select().single();if(T){if(T.code==="23505"){c.invalidateQueries({queryKey:["experience-gen-agreements",n]});return}u({title:"Could not create agreement",description:T.message,variant:"destructive"});return}k||h(C.body_markdown??""),c.invalidateQueries({queryKey:["experience-gen-agreements",n]})})(),()=>{k=!0}},[e,w==null?void 0:w.id,v==null?void 0:v.body_markdown,b,l]),y.useEffect(()=>{e&&f("preview")},[e]);const N=Me({mutationFn:async()=>{if(!w)return;const{error:k}=await F.from("generator_experience_agreements").update({body_markdown:d}).eq("id",w.id);if(k)throw k},onSuccess:()=>{c.invalidateQueries({queryKey:["experience-gen-agreements",n]}),u({title:"Agreement updated"})},onError:k=>u({title:"Save failed",description:k.message,variant:"destructive"})}),j=Me({mutationFn:async k=>{const{error:C}=await F.from("generator_experience_agreements").update({verbally_accepted_at:new Date().toISOString(),verbally_accepted_by_name:(x==null?void 0:x.name)??null,verbally_accepted_by:(x==null?void 0:x.id)??null}).eq("id",k);if(C)throw C},onSuccess:()=>{c.invalidateQueries({queryKey:["experience-gen-agreements",n]}),u({title:"Marked as verbally accepted"})},onError:k=>u({title:"Failed",description:k.message,variant:"destructive"})}),_=k=>`${window.location.origin}/generator-agreement?token=${k}`,S=k=>{navigator.clipboard.writeText(_(k)),u({title:"Link copied"})},P=k=>{if(!o){u({title:"No email on file for this Generator",variant:"destructive"});return}const C=encodeURIComponent(`Please review & accept: ${r} agreement`),T=encodeURIComponent(`Hi, 797 798Please review and accept the agreement for ${r}: 799 800${_(k)} 801 802Thanks!`);window.location.href=`mailto:${o}?subject=${C}&body=${T}`};return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"max-w-3xl max-h-[90vh] flex flex-col",children:[a.jsx(Ot,{children:a.jsxs(At,{className:"font-display",children:["Agreement â ",i]})}),a.jsxs("div",{className:"flex items-center gap-2 border-b pb-2 flex-wrap",children:[a.jsxs(Y,{variant:m==="preview"?"secondary":"ghost",size:"sm",onClick:()=>f("preview"),className:"gap-1.5",children:[a.jsx(D3,{className:"h-4 w-4"})," Preview"]}),l&&a.jsxs(Y,{variant:m==="edit"?"secondary":"ghost",size:"sm",onClick:()=>f("edit"),className:"gap-1.5",children:[a.jsx(Rn,{className:"h-4 w-4"})," Edit"]}),(w==null?void 0:w.accepted_at)&&a.jsxs(Ge,{variant:"default",className:"bg-green-600 hover:bg-green-600 gap-1",children:[a.jsx(Mr,{className:"h-3 w-3"}),"Accepted by ",w.accepted_name," on ",Ye(new Date(w.accepted_at),"MMM d, yyyy")]}),!(w!=null&&w.accepted_at)&&(w==null?void 0:w.verbally_accepted_at)&&a.jsxs(Ge,{variant:"default",className:"bg-amber-600 hover:bg-amber-600 gap-1",children:[a.jsx(Nj,{className:"h-3 w-3"}),"Verbally Accepted",w.verbally_accepted_by_name?` · recorded by ${w.verbally_accepted_by_name}`:""," on ",Ye(new Date(w.verbally_accepted_at),"MMM d, yyyy")]}),a.jsxs("div",{className:"ml-auto flex gap-1",children:[l&&w&&!w.accepted_at&&!w.verbally_accepted_at&&g&&a.jsxs(lue,{children:[a.jsx(cue,{asChild:!0,children:a.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1.5",children:[a.jsx(Nj,{className:"h-3.5 w-3.5"})," Mark Verbally Accepted"]})}),a.jsxs(X6,{children:[a.jsxs(J6,{children:[a.jsx(e8,{children:"Mark agreement as verbally accepted?"}),a.jsxs(t8,{children:["This will record that ",a.jsx("strong",{children:i})," verbally accepted the agreement for ",a.jsx("strong",{children:r}),'. The agreement will be locked from further edits, and the public link will show "already verbally accepted" instead of the sign form. This will be attributed to you (',(x==null?void 0:x.name)??"you",")."]})]}),a.jsxs(Z6,{children:[a.jsx(r8,{children:"Cancel"}),a.jsx(n8,{onClick:()=>j.mutate(w.id),children:"Confirm"})]})]})]}),w&&!l&&!w.accepted_at&&!w.verbally_accepted_at&&a.jsxs(Y,{size:"sm",className:"gap-1.5",onClick:()=>window.open(_(w.acceptance_token),"_blank"),children:[a.jsx(fH,{className:"h-3.5 w-3.5"})," Review & Sign"]}),w&&a.jsxs(a.Fragment,{children:[a.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>S(w.acceptance_token),children:[a.jsx(zv,{className:"h-3.5 w-3.5"})," Copy Link"]}),a.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>P(w.acceptance_token),children:[a.jsx(cC,{className:"h-3.5 w-3.5"})," Email Link"]})]})]})]}),a.jsx("div",{className:"overflow-auto flex-1 -mx-6 px-6",children:m==="preview"?a.jsx("div",{className:"prose prose-sm max-w-none text-sm",dangerouslySetInnerHTML:{__html:Ok(d||"")}}):a.jsx(qt,{value:d,onChange:k=>h(k.target.value),className:"min-h-[60vh] font-mono text-xs"})}),m==="edit"&&l&&a.jsx("div",{className:"flex justify-end pt-2 border-t",children:a.jsx(Y,{onClick:()=>N.mutate(),disabled:N.isPending||!!(w!=null&&w.accepted_at)||!!(w!=null&&w.verbally_accepted_at),children:w!=null&&w.accepted_at?"Already Accepted":w!=null&&w.verbally_accepted_at?"Verbally Accepted (locked)":N.isPending?"Savingâ¦":"Save Changes"})})]})})}var Ob="Collapsible",[hue,a8]=jr(Ob),[fue,Ik]=hue(Ob),s8=y.forwardRef((e,t)=>
vendor: 4,191 bytes, line 802
802{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:i,onOpenChange:o,...l}=e,[c,u]=oa({prop:r,defaultProp:s??!1,onChange:o,caller:Ob});return a.jsx(fue,{scope:n,disabled:i,contentId:Zn(),open:c,onOpenToggle:y.useCallback(()=>u(d=>!d),[u]),children:a.jsx(tt.div,{"data-state":zk(c),"data-disabled":i?"":void 0,...l,ref:t})})});s8.displayName=Ob;var i8="CollapsibleTrigger",Lk=y.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,s=Ik(i8,n);return a.jsx(tt.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":zk(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:t,onClick:Fe(e.onClick,s.onOpenToggle)})});Lk.displayName=i8;var Fk="CollapsibleContent",qk=y.forwardRef((e,t)=>{const{forceMount:n,...r}=e,s=Ik(Fk,e.__scopeCollapsible);return a.jsx(tr,{present:n||s.open,children:({present:i})=>a.jsx(mue,{...r,ref:t,present:i})})});qk.displayName=Fk;var mue=y.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:s,...i}=e,o=Ik(Fk,n),[l,c]=y.useState(r),u=y.useRef(null),d=Ct(t,u),h=y.useRef(0),m=h.current,f=y.useRef(0),x=f.current,g=o.open||l,p=y.useRef(g),v=y.useRef(void 0);return y.useEffect(()=>{const b=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(b)},[]),dr(()=>{const b=u.current;if(b){v.current=v.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const w=b.getBoundingClientRect();h.current=w.height,f.current=w.width,p.current||(b.style.transitionDuration=v.current.transitionDuration,b.style.animationName=v.current.animationName),c(r)}},[o.open,r]),a.jsx(tt.div,{"data-state":zk(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!g,...i,ref:d,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":x?`${x}px`:void 0,...e.style},children:g&&s})});function zk(e){return e?"open":"closed"}var o8=s8,pue=Lk,gue=qk,Js="Accordion",xue=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Bk,yue,vue]=dp(Js),[Ab,j3e]=jr(Js,[vue,a8]),Uk=a8(),l8=ae.forwardRef((e,t)=>{const{type:n,...r}=e,s=r,i=r;return a.jsx(Bk.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?a.jsx(jue,{...i,ref:t}):a.jsx(_ue,{...s,ref:t})})});l8.displayName=Js;var[c8,bue]=Ab(Js),[u8,wue]=Ab(Js,{collapsible:!1}),_ue=ae.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:s=()=>{},collapsible:i=!1,...o}=e,[l,c]=oa({prop:n,defaultProp:r??"",onChange:s,caller:Js});return a.jsx(c8,{scope:e.__scopeAccordion,value:ae.useMemo(()=>l?[l]:[],[l]),onItemOpen:c,onItemClose:ae.useCallback(()=>i&&c(""),[i,c]),children:a.jsx(u8,{scope:e.__scopeAccordion,collapsible:i,children:a.jsx(d8,{...o,ref:t})})})}),jue=ae.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:s=()=>{},...i}=e,[o,l]=oa({prop:n,defaultProp:r??[],onChange:s,caller:Js}),c=ae.useCallback(d=>l((h=[])=>[...h,d]),[l]),u=ae.useCallback(d=>l((h=[])=>h.filter(m=>m!==d)),[l]);return a.jsx(c8,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:u,children:a.jsx(u8,{scope:e.__scopeAccordion,collapsible:!0,children:a.jsx(d8,{...i,ref:t})})})}),[Nue,Tb]=Ab(Js),d8=ae.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:s,orientation:i="vertical",...o}=e,l=ae.useRef(null),c=Ct(l,t),u=yue(n),h=mh(s)==="ltr",m=Fe(e.onKeyDown,f=>{var P;if(!xue.includes(f.key))return;const x=f.target,g=u().filter(k=>{var C;return!((C=k.ref.current)!=null&&C.disabled)}),p=g.findIndex(k=>k.ref.current===x),v=g.length;if(p===-1)return;f.preventDefault();let b=p;const w=0,N=v-1,j=()=>{b=p+1,b>N&&(b=w)},_=()=>{b=p-1,b<w&&(b=N)};switch(f.key){case"Home":b=w;break;case"End":b=N;break;case"ArrowRight":i==="horizontal"&&(h?j():_());break;case"ArrowDown":i==="vertical"&&j();break;case"ArrowLeft":i==="horizontal"&&(h?_():j());break;case"ArrowUp":i==="vertical"&&_();break}const S=b%v;(P=g[S].ref.current)==null||P.focus()});return a.jsx(Nue,{scope:n,disabled:r,direction:s,orientation:i,children:a.jsx(Bk.Slot,{scope:n,children:a.jsx(tt.div,{...o,"data-orientation":i,ref:c,onKeyDown:r?void 0:m})})})}),gy="AccordionItem",[Sue,Wk]=Ab(gy),h8=ae.forwardRef((e,t)=>
802{const{__scopeAccordion:n,value:r,...s}=e,i=Tb(gy,n),o=bue(gy,n),l=Uk(n),c=Zn(),u=r&&o.value.includes(r)||!1,d=i.disabled||e.disabled;return a.jsx(Sue,{scope:n,open:u,disabled:d,triggerId:c,children:a.jsx(o8,{"data-orientation":i.orientation,"data-state":y8(u),...l,...s,ref:t,disabled:d,open:u,onOpenChange:h=>{h?o.onItemOpen(r):o.onItemClose(r)}})})});h8.displayName=gy;var f8="AccordionHeader",m8=ae.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,s=Tb(Js,n),i=Wk(f8,n);return a.jsx(tt.h3,{"data-orientation":s.orientation,"data-state":y8(i.open),"data-disabled":i.disabled?"":void 0,...r,ref:t})});m8.displayName=f8;var C1="AccordionTrigger",p8=ae.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,s=Tb(Js,n),i=Wk(C1,n),o=wue(C1,n),l=Uk(n);return a.jsx(Bk.ItemSlot,{scope:n,children:a.jsx(pue,{"aria-disabled":i.open&&!o.collapsible||void 0,"data-orientation":s.orientation,id:i.triggerId,...l,...r,ref:t})})});p8.displayName=C1;var g8="AccordionContent",x8=ae.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,s=Tb(Js,n),i=Wk(g8,n),o=Uk(n);return a.jsx(gue,{role:"region","aria-labelledby":i.triggerId,"data-orientation":s.orientation,...o,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});x8.displayName=g8;function y8(e){return e?"open":"closed"}var Cue=l8,kue=h8,Eue=m8,v8=p8,b8=x8;const Pue=Cue,k1=y.forwardRef(({className:e,...t},n)=>a.jsx(kue,{ref:n,className:Se("border-b",e),...t}));k1.displayName="AccordionItem";const E1=y.forwardRef(({className:e,children:t,...n},r)=>a.jsx(Eue,{className:"flex",children:a.jsxs(v8,{ref:r,className:Se("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,a.jsx(_n,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));E1.displayName=v8.displayName;const P1=y.forwardRef(({className:e,children:t,...n},r)=>a.jsx(b8,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:a.jsx("div",{className:Se("pb-4 pt-0",e),children:t})}));P1.displayName=b8.displayName;const ln=e=>e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0});function Oue({open:e,onOpenChange:t,experienceId:n,experienceName:r,experiencePrice:s,generatorId:i,generatorName:o,readOnly:l=!1}){const c=at(),{toast:u}=mt(),[d,h]=y.useState("25"),[m,f]=y.useState("10"),[x,g]=y.useState("10"),[p,v]=y.useState(""),[b,w]=y.useState("0"),[N,j]=y.useState(""),[_,S]=y.useState(!0),P=(Number(d)||0)>=100&&(Number(m)||0)<=0,k=Ne=>{Ne?(h("100"),f("0")):(h("25"),f("10"))},{data:C}=Ee({queryKey:["generator-comp",n,i],enabled:e,queryFn:async()=>{const{data:Ne,error:be}=await F.from("generator_experience_comp").select("*").eq("experience_id",n).eq("generator_id",i).maybeSingle();if(be)throw be;return Ne}}),{data:T=[]}=Ee({queryKey:["generator-recruits",n,i],enabled:e,queryFn:async()=>{const{data:Ne,error:be}=await F.from("contact_experiences").select("id, status, custom_price, contacts!contact_experiences_contact_id_fkey!inner(name, email, generator_id), experiences(price)").eq("experience_id",n).eq("contacts.generator_id",i);if(be)throw be;return Ne??[]}}),{data:O}=Ee({queryKey:["generator-self-email",i],enabled:e,queryFn:async()=>{const{data:Ne,error:be}=await F.from("generators").select("email, name").eq("id",i).maybeSingle();if(be)throw be;return Ne}}),{data:L=[]}=Ee({queryKey:["experience-ces-picker",n],enabled:e,refetchOnMount:"always",queryFn:async()=>{const{data:Ne,error:be}=await F.rpc("get_experience_contacts_for_display",{_experience_id:n});if(be)throw be;return(Ne??[]).map(Ue=>({id:Ue.id,status:Ue.status,contacts:{name:Ue.contact_name,email:Ue.contact_email,generator_id:Ue.contact_generator_id}}))}}),{data:E=[]}=Ee({queryKey:["experience-companion-rows",n],enabled:e,queryFn:async()=>{const{data:Ne,error:be}=await F.from("contact_experiences").select("id, contact_id, custom_price, companion_of_contact_id, contacts!contact_experiences_contact_id_fkey(name, email)").eq("experience_id",n);if(be)throw be;return Ne??[]}}),R=["invited","expressed_interest","considering","accepted","future","declined","dropped"],q=((O==null?void 0:O.email)||"").toLowerCase(),I=Ne=>{var be;return!!q&&(((be=Ne.contacts)==null?void 0:be.email)||"").toLowerCase()===q},$=y.useMemo(()=>L.filter(Ne=>{var be;return((be=Ne.contacts)==null?void 0:be.generator_id)===i&&R.includes(Ne.status)&&!I(Ne)}),[L,i,q]),M=y.useMemo(()=>$.map(Ne=>Ne.id),[$]),{data:B=[]}=Ee({queryKey:["experience-confirmed-revenue",n],enabled:e,queryFn:async()=>{const[{data:Ne,error:be},{data:Ue,error:Ze},{data:nt,error:rt}]=await Promise.all([F.from("contact_experiences").select("id, status, custom_price, contacts!contact_experiences_contact_id_fkey(email), experiences(price)").eq("experience_id",n),F.from("generator_experience_comp").select("generator_id, generators(email)").eq("experience_id",n),F.from("contact_experience_addons").select("contact_experience_id, experience_addons(price, third_party_payer)")]);if(be)throw be;if(Ze)throw Ze;if(rt)throw rt;const kt=new Set((Ue??[]).map(Et=>{var Nt,ue;return(ue=(Nt=Et.generators)==null?void 0:Nt.email)==null?void 0:ue.toLowerCase()}
802).filter(Boolean)),jt=new Map;for(const Et of nt??[]){const Nt=Et.experience_addons;if(!Nt||Nt.third_party_payer)continue;const ue=Et.contact_experience_id;jt.set(ue,(jt.get(ue)??0)+Number(Nt.price||0))}return(Ne??[]).map(Et=>{var Nt,ue;return{status:Et.status,effective_price:Number(Et.custom_price??((Nt=Et.experiences)==null?void 0:Nt.price)??0)+(jt.get(Et.id)??0),is_comped:Et.status==="gen_guide"||kt.has((((ue=Et.contacts)==null?void 0:ue.email)||"").toLowerCase())}})}}),W=y.useMemo(()=>y6(B),[B]);y.useEffect(()=>{e&&(C?(h(String(C.invite_bonus_pct??0)),f(String(C.invite_bonus_threshold??0)),g(String(C.recruitment_share_pct??0)),v(String(C.trip_price_snapshot??0)),w(String(C.host_guide_pct??0)),j(C.notes??"")):(h("25"),f("10"),g("10"),v(s!=null?String(s):""),w("0"),j("")))},[C,e,s]);const A={invite_bonus_pct:Number(d)||0,invite_bonus_threshold:Number(m)||0,recruitment_share_pct:Number(x)||0,trip_price_snapshot:Number(p)||0,quality_invite_ids:M,host_guide_pct:Number(b)||0},K=y.useMemo(()=>T.filter(Ne=>{var be;return!q||(((be=Ne.contacts)==null?void 0:be.email)||"").toLowerCase()!==q}),[T,q]),G=y.useMemo(()=>K.map(Ne=>{var be;return{contact_experience_id:Ne.id,effective_price:Ne.custom_price??((be=Ne.experiences)==null?void 0:be.price)??0,counts_as_recruit:j1(Ne.status)}}),[K]),H=y.useMemo(()=>Pb(A,G,W),[A,G,W]),{data:fe}=Ee({queryKey:["budget-pax-assumption",n],enabled:e,queryFn:async()=>{const[{data:Ne},{data:be}]=await Promise.all([F.from("experience_budget_settings").select("override_pax_count").eq("experience_id",n).maybeSingle(),F.from("experiences").select("max_size, price").eq("id",n).maybeSingle()]);return{pax:Number((Ne==null?void 0:Ne.override_pax_count)??(be==null?void 0:be.max_size)??0)||0,price:Number((be==null?void 0:be.price)??0)||0}}}),{data:te=[]}=Ee({queryKey:["experience-comp-agreements",n],enabled:e,queryFn:async()=>{const{data:Ne,error:be}=await F.from("generator_experience_comp").select("generator_id, invite_bonus_pct, invite_bonus_threshold, recruitment_share_pct, trip_price_snapshot, quality_invite_ids, host_guide_pct, generators(name, email)").eq("experience_id",n);if(be)throw be;return Ne??[]}}),J=(fe==null?void 0:fe.pax)??0,re=(fe==null?void 0:fe.price)||Number(p)||0,pe=y.useMemo(()=>{const Ne=te.filter(be=>be.generator_id!==i).map(be=>({id:be.generator_id,agreement:{invite_bonus_pct:Number(be.invite_bonus_pct)||0,invite_bonus_threshold:Number(be.invite_bonus_threshold)||0,recruitment_share_pct:Number(be.recruitment_share_pct)||0,trip_price_snapshot:Number(be.trip_price_snapshot)||0,quality_invite_ids:be.quality_invite_ids??[],host_guide_pct:Number(be.host_guide_pct)||0}}));return Ne.push({id:i,agreement:A}),my(Ne,J,re)},[te,i,A,J,re]),ye=y.useMemo(()=>pe.get(i)??v6(A,J,re),[pe,i,A,J,re]),X=Math.max(1,new Set([...te.map(Ne=>Ne.generator_id),i]).size),he=y.useMemo(()=>{const Ne=te.filter(be=>be.generator_id!==i).map(be=>({id:be.generator_id,agreement:{invite_bonus_pct:Number(be.invite_bonus_pct)||0,invite_bonus_threshold:Number(be.invite_bonus_threshold)||0,recruitment_share_pct:Number(be.recruitment_share_pct)||0,trip_price_snapshot:Number(be.trip_price_snapshot)||0,quality_invite_ids:be.quality_invite_ids??[],host_guide_pct:Number(be.host_guide_pct)||0}}));return Ne.push({id:i,agreement:A}),Ne},[te,i,A]),D=iA(H.tripFullyComped?H.recruitingCashPayout:H.totalCredit,ye.tripFullyComped?ye.recruitingCashPayout:ye.totalCredit),le=iA(H.hostGuideCredit,ye.hostGuideCredit),V=ye.tripOffset+ye.cashPayout>H.tripOffset+H.cashPayout,U=V?ye:H,z=Number(A.trip_price_snapshot)||0,Z=Math.max(0,z-U.tripOffset),ve=U.cashPayout-Z,ee=H.recruitedCount>0?H.recruitedRevenue/H.recruitedCount:Number(p)||0,de=Zle(A,H.totalCredit,ee),je=J>0?Math.max(0,J-X-H.recruitedCount):null,Q=de!==null&&je!==null&&de>je,oe=y.useMemo(()=>{var Nt,ue;const Ne=E;if(!q||Ne.length===0)return null;const be=Ne.find(we=>{var Ie;return(((Ie=we.contacts)==null?void 0:Ie.email)||"").toLowerCase()===q});if(!be)return null;const Ue=Ne.find(we=>we.contact_id===be.companion_of_contact_id)??Ne.find(we=>we.companion_of_contact_id===be.contact_id);if(!Ue)return null;const Ze=(((Nt=Ue.contacts)==null?void 0:Nt.email)||"").toLowerCase(),nt=te.find(we=>{var Ie;return(((Ie=we.generators)==null?void 0:Ie.email)||"").toLowerCase()===Ze}),rt=Number((nt==null?void 0:nt.trip_price_snapshot)??Ue.custom_price??s??0),kt=nt?pe.get(nt.generator_id):null,jt=(kt==null?void 0:kt.tripOffset)??0,Et=(kt==null?void 0:kt.cashPayout)??0;return{name:((ue=Ue.contacts)==null?void 0:ue.name)||"Companion",generatorId:(nt==null?void 0:nt.generator_id)??null,tripPr
802ice:rt,netTripPrice:Math.max(0,rt-jt),cashPayout:Et,hasAgreement:!!nt}},[E,q,te,pe,s]),Pe=oe?{tripPrice:z+oe.tripPrice,netTripPrice:Z+oe.netTripPrice,cashPayout:U.cashPayout+oe.cashPayout,net:U.cashPayout+oe.cashPayout-(Z+oe.netTripPrice)}:null,ze=!!oe&&_,Je=y.useMemo(()=>{const Ne=Math.max(J,0),be=Ne-X;if(Ne<=0||re<=0||be<0)return[];const Ue=z+(ze&&oe?oe.tripPrice:0),Ze=[];for(let nt=0;nt<=be;nt++){const rt=nt+X,kt=my(he,rt,re),jt=kt.get(i);if(!jt)continue;let Et=jt.tripOffset,Nt=jt.cashPayout,ue=Math.max(0,z-jt.tripOffset);if(ze&&oe){const we=oe.generatorId?kt.get(oe.generatorId):null;Et+=(we==null?void 0:we.tripOffset)??0,Nt+=(we==null?void 0:we.cashPayout)??0,ue+=Math.max(0,oe.tripPrice-((we==null?void 0:we.tripOffset)??0))}Ze.push({pax:nt,tripOffset:Et,cashPayout:Nt,netPrice:ue,net:Nt-ue})}return Ze.map(nt=>({...nt,basePrice:Ue}))},[he,i,J,re,X,z,oe,ze]),Ae=Me({mutationFn:async()=>{const Ne={experience_id:n,generator_id:i,invite_bonus_pct:A.invite_bonus_pct,invite_bonus_threshold:A.invite_bonus_threshold,recruitment_share_pct:A.recruitment_share_pct,trip_price_snapshot:A.trip_price_snapshot,quality_invite_ids:A.quality_invite_ids,host_guide_pct:A.host_guide_pct??0,notes:N||null},{error:be}=await F.from("generator_experience_comp").upsert(Ne,{onConflict:"experience_id,generator_id"});if(be)throw be;const Ue=async(Ze,nt,rt,kt)=>{var ge;const{data:jt,error:Et}=await F.from("experience_budget_items").select("id").eq("experience_id",n).eq("source",Ze).eq("generator_id",i);if(Et)throw Et;let Nt=jt;if(!(Nt!=null&&Nt.length)){const{data:$e,error:Ke}=await F.from("experience_budget_items").select("id").eq("experience_id",n).eq("source",Ze).is("generator_id",null).ilike("description",rt.trim());if(Ke)throw Ke;Nt=$e}if(Nt&&Nt.length>0){const{error:$e}=await F.from("experience_budget_items").update({category:"direct",name:nt,description:rt,generator_id:i,amount:kt,cost_type:"flat",currency:"USD",includes_generators:!1,generator_count:0}).eq("id",Nt[0].id);if($e)throw $e;return}if(kt<=0)return;const{data:ue,error:we}=await F.from("experience_budget_items").select("sort_order").eq("experience_id",n).order("sort_order",{ascending:!1}).limit(1);if(we)throw we;const Ie=(((ge=ue==null?void 0:ue[0])==null?void 0:ge.sort_order)??0)+1,{error:se}=await F.from("experience_budget_items").insert({experience_id:n,category:"direct",name:nt,description:rt,generator_id:i,cost_type:"flat",amount:kt,currency:"USD",includes_generators:!1,generator_count:0,sort_order:Ie,source:Ze});if(se)throw se};await Ue("generator_comp","Generator Recruiting Comp",o,D),await Ue("facilitator_comp","Guide Facilitation Comp",o,le)},onSuccess:()=>{c.invalidateQueries({queryKey:["generator-comp",n,i]}),c.invalidateQueries({queryKey:["budget-items",n]}),c.invalidateQueries({queryKey:["budget-accepted-contacts",n]}),c.invalidateQueries({queryKey:["budget-addon-selections",n]}),c.invalidateQueries({queryKey:["experience-contacts",n]}),c.invalidateQueries({queryKey:["experience-status-counts"]}),c.invalidateQueries({queryKey:["experience-ces-picker",n]}),c.invalidateQueries({queryKey:["generator-recruits",n,i]}),c.invalidateQueries({queryKey:["generator-comp-list",n]}),c.invalidateQueries({queryKey:["experience-companion-rows",n]}),c.invalidateQueries({queryKey:["budget-comp-agreements",n]}),c.invalidateQueries({queryKey:["budget-generator-count",n]}),c.invalidateQueries({queryKey:["budget-included-addons",n]}),c.invalidateQueries({queryKey:["budget-experience-meta",n]}),c.invalidateQueries({queryKey:["budget-settings",n]}),c.invalidateQueries({queryKey:["generator-earnings"]}),u({title:"Compensation saved",description:"Budget updated."}),t(!1)},onError:Ne=>u({title:"Save failed",description:Ne.message,variant:"destructive"})}),et=(ee||0)*(A.recruitment_share_pct/100);return a.jsx(w6,{open:e,onOpenChange:t,children:a.jsxs(Ak,{className:"w-full sm:max-w-xl overflow-y-auto",children:[a.jsxs(Tk,{children:[a.jsxs(Mk,{className:"font-display",children:["Compensation â ",o]}),a.jsx(j6,{children:r})]}),a.jsxs("div",{className:"mt-6 space-y-6",children:[a.jsxs("section",{className:`rounded-md border p-3 space-y-3 ${l?"opacity-90 pointer-events-none select-none":""}`,children:[a.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:["Comp terms",l?" (view only)":""]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Trip price"}),a.jsx(as,{type:"text",inputMode:"decimal",value:p,onCommit:v})]}),a.jsxs("div",{className:"rounded border bg-muted/20 p-2.5 space-y-2.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gt,{id:"fully-comped",checked:P,onCheckedChange:Ne=>k(!!Ne)}),a.jsx(xe,{htmlFor:"fully-comped",className:"text-xs font-medium cursor-pointer",children:"Trip fully comped (no invite requirement)"})]}),P?a.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Their ",ln(z)," seat is covered outright as a Host/Guide."]}
802):a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Invite bonus %"}),a.jsx(as,{type:"text",inputMode:"decimal",value:d,onCommit:h})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Invite threshold"}),a.jsx(as,{type:"text",inputMode:"numeric",value:m,onCommit:f})]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Generator commission %"}),a.jsx(as,{type:"text",inputMode:"decimal",value:x,onCommit:g}),a.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Of what each recruit pays"})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Host/Guide facilitator fee %"}),a.jsx(as,{type:"text",inputMode:"decimal",value:b,onCommit:w}),a.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Of experience revenue"})]})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Notes"}),a.jsx(qt,{value:N,onChange:Ne=>j(Ne.target.value),rows:2,placeholder:"Optional â special terms, side letters, etc."})]})]}),a.jsxs("section",{className:"rounded-md border bg-muted/20 p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[a.jsx(_j,{className:"h-3.5 w-3.5"})," How your comp works"]}),a.jsxs("ol",{className:"space-y-1.5 text-xs text-muted-foreground list-decimal pl-4",children:[a.jsx("li",{children:P?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-foreground font-medium",children:"Trip fully covered"})," â the"," ",ln(z)," seat is comped, with nothing required in return."]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-foreground font-medium",children:"Invite bonus"})," â"," ",A.invite_bonus_pct,"% off the ",ln(z)," trip once"," ",A.invite_bonus_threshold," quality invites are made."]})}),a.jsxs("li",{children:[a.jsx("span",{className:"text-foreground font-medium",children:"Generator commission"})," â"," ",A.recruitment_share_pct,"% of what each recruit actually pays (",ln(et)," per seat at ",ln(ee||0),")."]}),a.jsx("li",{children:P?a.jsx(a.Fragment,{children:"Because the trip is already covered, all commission is paid in cash."}):a.jsxs(a.Fragment,{children:["Commission pays down"," ",a.jsx("span",{className:"text-foreground font-medium",children:"their own trip first"}),"; anything past ",ln(z)," is paid in cash."]})}),(A.host_guide_pct??0)>0&&a.jsxs("li",{children:[a.jsx("span",{className:"text-foreground font-medium",children:"Facilitator fee"})," â"," ",A.host_guide_pct,"% of confirmed experience revenue, always cash."]})]})]}),a.jsxs("section",{className:"rounded-md border p-3 space-y-1.5 text-sm",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1",children:[a.jsx(jH,{className:"h-3.5 w-3.5"})," What you'd earn at trip max size"]}),a.jsx(Va,{label:"Trip price",value:ln(z)}),a.jsx(Va,{label:P?"â Comped trip credit":"â Invite bonus",value:`â ${ln(U.inviteCredit)}`,sub:P?"Granted outright":U.meetsInviteThreshold?`Threshold met (${H.qualityInviteCount}/${A.invite_bonus_threshold})`:`Threshold not yet met (${H.qualityInviteCount}/${A.invite_bonus_threshold})`}),a.jsx(Va,{label:"â Commission applied to trip",value:`â ${ln(Math.max(0,U.tripOffset-U.inviteCredit))}`,sub:`${U.recruitedCount} recruit seat${U.recruitedCount===1?"":"s"} · ${ln(U.recruitmentCredit)} earned`}),a.jsx("div",{className:"h-px bg-border my-2"}),a.jsx(Va,{label:"Net trip price",value:ln(Z),bold:!0,sub:Z===0?"Trip fully covered":"Still owed for their own seat"}),a.jsx("div",{className:"h-px bg-border my-2"}),a.jsx(Va,{label:"+ Cash commission paid out",value:ln(Math.max(0,U.cashPayout-U.hostGuideCredit)),sub:"Credit beyond the trip price"}),a.jsx(Va,{label:`+ Facilitator fee (${A.host_guide_pct??0}%)`,value:ln(U.hostGuideCredit),sub:`${ln(U.confirmedRevenue)} revenue base`}),a.jsx("div",{className:"h-px bg-border my-2"}),a.jsx(Va,{label:"Bottom line",value:`${ln(Math.abs(ve))}${ve===0?"":ve>0?" earned":" to pay"}`,bold:!0,sub:V?`Planned: ${ye.recruitedCount} recruit seats at ${ln(re)}${X>1?` (pro-rata across ${X} agreements)`:""}`:"Based on actual recruits to date"}),a.jsxs("div",{className:"mt-3 rounded bg-muted/40 p-2 space-y-1 text-xs text-muted-foreground",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{children:"Quality invites"}),a.jsx("span",{className:"tabular-nums text-foreground",children:A.invite_bonus_threshold>
8020?`${H.qualityInviteCount} / ${A.invite_bonus_threshold}`:`${H.qualityInviteCount} (no threshold)`})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{children:"Recruits registered"}),a.jsx("span",{className:"tabular-nums text-foreground",children:H.recruitedCount})]}),je!==null&&a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{children:"Seats remaining on trip"}),a.jsx("span",{className:"tabular-nums text-foreground",children:je})]}),de!==null&&de>0&&!Q&&a.jsxs("p",{className:"flex items-start gap-1 pt-1",children:[a.jsx(tm,{className:"h-3 w-3 mt-0.5 flex-shrink-0"}),"~",de," more recruit",de===1?"":"s"," at"," ",ln(ee)," to fully comp the trip."]})]})]}),oe&&Pe&&a.jsxs("section",{className:"rounded-md border p-3 space-y-1.5 text-sm",children:[a.jsx("div",{className:"flex items-center justify-between gap-2",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gt,{id:"combined",checked:_,onCheckedChange:Ne=>S(!!Ne)}),a.jsxs(xe,{htmlFor:"combined",className:"text-xs font-medium cursor-pointer",children:["Show combined with ",oe.name]})]})}),_&&a.jsxs("div",{className:"pt-2 space-y-1.5",children:[a.jsx(Va,{label:"Combined trip price",value:ln(Pe.tripPrice)}),a.jsx(Va,{label:`${oe.name}'s net seat`,value:ln(oe.netTripPrice),sub:oe.hasAgreement?"Has their own comp agreement":"No comp agreement"}),a.jsx(Va,{label:"Combined net trip price",value:ln(Pe.netTripPrice),bold:!0}),a.jsx(Va,{label:"Combined cash comp",value:ln(Pe.cashPayout)}),a.jsx("div",{className:"h-px bg-border my-2"}),a.jsx(Va,{label:"Combined bottom line",value:`${ln(Math.abs(Pe.net))}${Pe.net===0?"":Pe.net>0?" earned":" to pay"}`,bold:!0})]})]}),Je.length>0&&a.jsxs("section",{className:"rounded-md border p-3 space-y-2 text-sm",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[a.jsx(_j,{className:"h-3.5 w-3.5"})," ",ze?"Combined all-in comp by group size":"All-in comp by group size"]}),a.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Group size is recruited guests only â it excludes the ",X," generator/guide seat",X===1?"":"s"," (they can't recruit themselves). Assumes recruitment at ",ln(re)," per seat, split pro-rata across"," ",X," generator",X===1?"/guide":"s/guides",ze&&oe?`, combining ${o} and ${oe.name} (${ln(Je[0].basePrice)} of seats).`:"."]}),a.jsx("div",{className:"max-h-64 overflow-y-auto",children:a.jsxs("table",{className:"w-full text-xs tabular-nums",children:[a.jsx("thead",{className:"sticky top-0 bg-background",children:a.jsxs("tr",{className:"text-muted-foreground text-left",children:[a.jsx("th",{className:"py-1 font-medium",children:"Group size"}),a.jsx("th",{className:"py-1 font-medium text-right",children:"Trip credit"}),a.jsx("th",{className:"py-1 font-medium text-right",children:"Net price"}),a.jsx("th",{className:"py-1 font-medium text-right",children:"Cash"}),a.jsx("th",{className:"py-1 font-medium text-right",children:"All-in comp (net)"})]})}),a.jsx("tbody",{children:Je.map(Ne=>{var be;return a.jsxs("tr",{className:`border-t ${Ne.pax===((be=Je[Je.length-1])==null?void 0:be.pax)?"bg-muted/50 font-medium":""}`,children:[a.jsx("td",{className:"py-1",children:Ne.pax}),a.jsx("td",{className:"py-1 text-right",children:ln(Ne.tripOffset)}),a.jsx("td",{className:"py-1 text-right",children:ln(Ne.netPrice)}),a.jsx("td",{className:"py-1 text-right",children:ln(Ne.cashPayout)}),a.jsx("td",{className:"py-1 text-right",children:ln(Ne.net)})]},Ne.pax)})})]})})]}),a.jsxs(Pue,{type:"multiple",className:"border rounded-md px-3",children:[a.jsxs(k1,{value:"recruits",className:"border-b-0",children:[a.jsx(E1,{className:"text-xs uppercase tracking-wider text-muted-foreground",children:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Hc,{className:"h-3.5 w-3.5"})," Recruited registrations (",K.length,")"]})}),a.jsx(P1,{children:K.length===0?a.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No registrations yet owned by this generator."}):a.jsx("div",{className:"space-y-1 text-sm",children:K.map(Ne=>{var be,Ue;return a.jsxs("div",{className:"flex items-center justify-between gap-2 py-1",children:[a.jsxs("div",{className:"min-w-0 flex-1 truncate",children:[(be=Ne.contacts)==null?void 0:be.name,a.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:Ne.status})]}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[j1(Ne.status)?a.jsx(Ge,{variant:"secondary",className:"text-[10px]",children:"counts"}):a.jsx(Ge,{variant:"outline",className:"text-[10px]",children:"not yet"}),a.jsx("span",{className:"ml-2 tabular-nums",children:ln(Ne.custom_price??((Ue=Ne.experiences)==null?void 0:Ue.price)??0)})]})]},Ne.id)})})})]}),a.jsxs(k1,{value:"invites",className:"border-b-0",children:[a.jsxs(E1,{className:"text-xs uppercase tracking-wider text-muted-foreground",children:["Quality invites (",$.length,")"]}),a.jsx(P1,{children:$.length===0?a.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No qualifying invites yet."}):a.jsx("div",{className:"max-h-48 overflow-y-auto divide-y",children:$.map(Ne=>{var be;return a.jsxs("div",{className:"flex items-center gap-2 py-1.5 text-sm",children:[a.jsx("span",{className:"flex-1 truncate",children:(be=Ne.contacts)==null?void 0:be.name}),a.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:String(Ne.status).replace(/_/g," ")})]},Ne.id)})})})]})]}),!l&&a.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2 border-t",children:[a.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[a.jsx(Hi,{className:"h-3 w-3"}),"Saving syncs one direct-cost budget line for this generator."]}),a.jsx(Y,{onClick:()=>Ae.mutate(),disabled:Ae.isPending,children:Ae.isPending?"Savingâ¦":"Save"})]})]})]})})}function Va({label:e,value:t,sub:n,bold:r}){return a.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:e}),a.jsxs("div",{className:"text-right",children:[a.jsx("div",{className:r?"font-semibold tabular-nums":"tabular-nums",children:t}),n&&a.jsx("div",{className:"text-[10px] text-muted-foreground",children:n})]})]})}function Aue({experienceId:e,experienceName:t,experiencePrice:n,generatorId:r,generatorName:s,generatorEmail:i,showAgreement:o,canManage:l=!0}){const[c,u]=y.useState(!1),[d,h]=y.useState(!1),{data:m=[]}=Ee({queryKey:["experience-gen-agreements",e],queryFn:async()=>{const{data:w,error:N}=await F.from("generator_experience_agreements").select("*").eq("experience_id",e);if(N)throw N;return w}}),{data:f=[]}=Ee({queryKey:["generator-comp-list",e],queryFn:async()=>{const{data:w,error:N}=await F.from("generator_experience_comp").select("generator_id, invite_bonus_pct, recruitment_share_pct, host_guide_pct").eq("experience_id",e);if(N)throw N;return w??[]}}),x=m.find(w=>w.generator_id===r),g=f.find(w=>w.generator_id===r),p=!!(x!=null&&x.accepted_at),v=!!(x!=null&&x.verbally_accepted_at)&&!p,b=p?"Agreement accepted":v?"Agreement verbally accepted":x?l?"Agreement pending":"Review & sign your agreement":l?"Create agreement from template":"No agreement yet";return a.jsxs(a.Fragment,{children:[o&&a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",title:b,onClick:()=>u(!0),children:p?a.jsx(Mr,{className:"h-3.5 w-3.5 text-green-600"}):v?a.jsx(Nj,{className:"h-3.5 w-3.5 text-amber-600"}):x?a.jsx(Rn,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(U3,{className:"h-3.5 w-3.5 text-muted-foreground"})}),a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 px-1.5",title:g?l?"Edit compensation":"View compensation":l?"Set up compensation":"No compensation set",onClick:()=>h(!0),children:g?a.jsxs(Ge,{variant:"secondary",className:"text-[10px] px-1.5 py-0 gap-0.5 font-normal",children:[a.jsx(mH,{className:"h-3 w-3"}
802),Number(g.invite_bonus_pct)||0,"/",Number(g.recruitment_share_pct)||0,"/",Number(g.host_guide_pct)||0]}):a.jsx(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0 font-normal",children:"Comp"})}),c&&a.jsx(due,{open:c,onOpenChange:u,experienceId:e,experienceName:t,generatorId:r,generatorName:s,generatorEmail:i,canManage:l}),d&&a.jsx(Oue,{open:d,onOpenChange:h,experienceId:e,experienceName:t,experiencePrice:n,generatorId:r,generatorName:s,readOnly:!l})]})}function w8({feedUrl:e,size:t="sm",className:n,label:r="Subscribe to Calendar"}){const[s,i]=y.useState(!1),[o,l]=y.useState(!1),c=e.startsWith("//")?`https:${e}`:e,u=`${c}${c.includes("?")?"&":"?"}download=1`,d=c.replace(/^https?:\/\//,"webcal://"),h=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(d)}`,m=`https://outlook.live.com/calendar/0/addfromweb?url=${encodeURIComponent(c)}&name=${encodeURIComponent("Four Corners")}`,f="flex items-start gap-2 w-full rounded-md px-3 py-2 text-sm hover:bg-accent/10 text-foreground transition-colors text-left",x=async()=>{try{await navigator.clipboard.writeText(c),l(!0),Mt.success("Subscription link copied"),setTimeout(()=>l(!1),2e3)}catch{Mt.error("Failed to copy link")}};return a.jsxs(na,{open:s,onOpenChange:i,children:[a.jsx(ra,{asChild:!0,children:a.jsxs(Y,{variant:"outline",size:t,className:n,children:[a.jsx(jj,{className:"h-4 w-4"})," ",r]})}),a.jsxs(Kr,{align:"end",className:"w-72 p-1",children:[a.jsx("p",{className:"px-3 pt-2 pb-1 text-xs text-muted-foreground",children:"Subscribing keeps your calendar in sync â date changes update automatically."}),a.jsxs("a",{href:d,className:f,onClick:()=>i(!1),children:[a.jsx(jj,{className:"h-4 w-4 mt-0.5"}),a.jsxs("span",{children:["Apple Calendar",a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Opens your installed calendar app"})]})]}),a.jsxs("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:f,onClick:()=>i(!1),children:[a.jsx(vP,{className:"h-4 w-4 mt-0.5"}),a.jsxs("span",{children:["Google Calendar",a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Auto-updating subscription"})]})]}),a.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:f,onClick:()=>i(!1),children:[a.jsx(vP,{className:"h-4 w-4 mt-0.5"}),a.jsxs("span",{children:["Outlook on the web",a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Auto-updating subscription"})]})]}),a.jsxs("button",{onClick:x,className:f,children:[o?a.jsx(On,{className:"h-4 w-4 mt-0.5 text-emerald-600"}):a.jsx(Nl,{className:"h-4 w-4 mt-0.5"}),a.jsxs("span",{children:[o?"Copied!":"Copy subscription link",a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Outlook desktop: Add calendar â Subscribe from web"})]})]}),a.jsx("div",{className:"h-px bg-border my-1"}),a.jsxs("a",{href:u,className:f,onClick:()=>i(!1),children:[a.jsx(ja,{className:"h-4 w-4 mt-0.5"}),a.jsxs("span",{children:["Download .ics (one-time)",a.jsx("span",{className:"block text-xs text-muted-foreground",children:"Won't update if dates change"})]})]})]})]})}function Xr(e){const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r)}function pf(e,t){const[n,r,s]=e.split("-").map(Number),[i,o]=t.split(":").map(Number);return new Date(n,r-1,s,i,o)}function pu(e,t){if(!e)return{date:"",time:""};const n=pf(e,t||"00:00");return n.setHours(n.getHours()+1),{date:Ye(n,"yyyy-MM-dd"),time:Ye(n,"HH:mm")}}const mA=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function pA(e,t,n,r,s,i,o){const l=[],c=Xr(n),u=e.time||"00:00",[d,h]=u.split(":").map(Number);if(e.type==="every_n_weeks"){const m=e.interval||2;let f=Xr(t);const x=(e.weekday-zO(f)+7)%7;f=Tr(f,x),f.setHours(d,h,0,0);let g=0;for(;f<=c;)l.push({label:`${r} â ${Ye(f,"MMM d, yyyy")}`,start_date:f.toISOString(),end_date:null,all_day:o,experience_id:s,parent_date_id:i,sort_order:g}),f=td(f,m),f.setHours(d,h,0,0),g++}else if(e.type==="nth_weekday_monthly"){const m=e.nth||1;let f=ia(Xr(t)),x=0;for(;f<=c;){let g=Fre(f,e.weekday,{weekStartsOn:0});zO(f)>e.weekday&&(g=td(g,1));const p=td(g,m-1);p.setHours(d,h,0,0),p>=Xr(t)&&p<=c&&(l.push({label:`${r} â ${Ye(p,"MMM d, yyyy")}`,start_date:p.toISOString(),end_date:null,all_day:o,experience_id:s,parent_date_id:i,sort_order:x}),x++),f=Ba(f,1)}}else if(e.type==="every_n_months"){const m=e.monthInterval||2;let f=Xr(t);f.setHours(d,h,0,0);let x=0;for(;f<=c;)l.push({label:`${r} â ${Ye(f,"MMM d, yyyy")}`,start_date:f.toISOString(),end_date:null,all_day:o,experience_id:s,parent_date_id:i,sort_order:x}),f=Ba(f,m),f.setHours(d,h,0,0),x++}return l}function Rw(e,t,n,r,s,i,o){return{type:e,weekday:parseInt(t),...e==="every_n_weeks"?{interval:parseInt(n)}:{},...e==="nth_weekday_monthly"?{nth:parseInt(r)}:{},...e==="every_n_months"?{monthInterval:parseInt(s)}:{},time:i?void 0:o||"09:00"}}function Tue({experienceId:e}){const t=at(),{toast:n}=mt(),[r,s]=y.useState(!1),[i,o]=y.useState(null),[l,c]=y.useState(""),[u,d]=y.useState(""),[h,m]=y.useState(""),[f,x]=y.useState(""),[g,p]=y.useState(""),[v,b]=y.useState(!0),[w,N]=y.useState(!1),[j,_]=y.useState("every_n_weeks"),[S,P]=y.useState("4"),[k,C]=y.useState("2"),[T,O]=y.useState("3"),[L,E]=y.useState("2"),[R,q]=y.useState(""),[I,$]=y.useState(""),[M,B]=y.useState(""),[W,A]=y.useState(""),[K,G]=y.useState(!1),[H,fe]=y.useState(!1),[te,J]=y.useState(""),[re,pe]=y.useState(""),[ye,X]=y.useState(""),[he,D]=y.useState(""),[le,V]=y.useState(""),[U,z]=y.useState(!0),[Z,ve]=y.useState(""),[ee,de]=y.useState(""),[je,Q]=y.useState(""),[oe,Pe]=y.useState(!1),[ze,Je]=y.useState("every_n_weeks"),[Ae,et]=y.useState("4"),[Ne,be]=y.useState("2"),[Ue,Ze]=y.useState("3"),[nt,rt]=y.useState("2"),[kt,jt]=y.useState(""),[Et,Nt]=y.useState(!1),[ue,we]=y.useState(!1),{data:Ie=[]}=Ee({queryKey:["experience-dates",e],queryFn:async()=>{const{data:Ce,error:ut}=await F.from("experience_dates").select("*").eq("experience_id",e).order("sort_order",{ascending:!0});if(ut)throw ut;return Ce}}),{data:se}=Ee({queryKey:["experience-trip-dates",e],queryFn:async()=>{const{data:Ce,error:ut}=await F.from("experiences").select("target_start_date, end_date").eq("id",e).maybeSingle();if(ut)throw ut;return Ce}}),{data:ge}=Ee({queryKey:["app-settings"],queryFn:async()=>{const{data:Ce}=await F.from("app_settings").select("zoom_link").eq("id",1).maybeSingle();return Ce}});y.useEffect(()=>{if(!(se!=null&&se.target_start_date)||!(se!=null&&se.end_date)||Ie.length>0)return;const Ce=Xr(se.target_start_date).toISOString(),ut=Xr(se.end_date).toISOString();(async()=>{const{error:ne}=await F.from("experience_dates").insert({experience_id:e,label:"Trip Dates",start_date:Ce,end_date:ut,all_day:!0,sort_order:0,is_recurring:!1,is_embedded_trip:!0});ne||t.invalidateQueries({queryKey:["experience-dates",e]})})()},[se==null?void 0:se.target_start_date,se==null?void 0:se.end_date,Ie,e,t]);const $e=(Ce,ut)=>new Date(Ce.start_date).getTime()-new Date(ut.start_date).getTime()||Ce.sort_order-ut.sort_order,Ke=Ie.filter(Ce=>!Ce.parent_date_id).sort($e),Qe=Ce=>Ie.filter(ut=>ut.parent_date_id===Ce).sort($e),He=Me({mutationFn:async()=>{const Ce=Ie.length>0?Math.max(...Ie.map(Lt=>Lt.sort_order)):-1;let ut,ne=null;if(v?(ut=Xr(u).toISOString(),ne=f?Xr(f).toISOString():null):(ut=pf(u,h||"00:00").toISOString(),ne=f?pf(f,g||h||"00:00").toISOString():null),K){const{error:Lt}=await F.from("experience_dates").update({is_embedded_trip:!1}).eq("experience_id",e);if(Lt)throw Lt}const{data:qe,error:Ve}=await F.from("experience_dates").insert({experience_id:e,label:l.trim(),start_date:ut,end_date:ne,all_day:v,sort_order:Ce+1,notes:I.trim()||null,location:M.trim()||null,description:W.trim()||null,is_recurring:w,recurrence_rule:w?Rw(j,S,k,T,L,v,h):null,recurrence_end_date:w&&R?Xr(R).toISOString():null,is_embedded_trip:K,is_virtual:H}).select().single();if(Ve)throw Ve;if(w&&R&&qe){const Lt=Rw(j,S,k,T,L,v,h),nr=pA(Lt,u,R,l.trim(),e,qe.id,v);if(nr.length>0){const{error:Nn}=await F.from("experience_dates").insert(nr);if(Nn)throw Nn}}},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-dates",e]}),Xt(),n({title:"Date added"})}}),Tt=Me({mutationFn:async({id:Ce,isChild:ut})=>{let ne,qe=null;if(U?(ne=Xr(re).toISOString(),qe=he?Xr(he).toISOString():null):(ne=pf(re,ye||"00:00").toISOString(),qe=he?pf(he,le||ye||"00:00").toISOString():null),ut){const{error:Ve}=await F.from("experience_dates").update({label:te.trim(),start_date:ne,end_date:qe,all_day:U,notes:Z.trim()||null,location:ee.trim()||null,description:je.trim()||null,is_virtual:ue}).eq("id",Ce);if(Ve)throw Ve}else{const Ve=oe?Rw(ze,Ae,Ne,Ue,nt,U,ye):null;if(Et){const{error:Nn}=await F.from("experience_dates").update({is_embedded_trip:!1}).eq("experience_id",e).neq("id",Ce);if(Nn)throw Nn}const{error:Lt}=await F.from("experience_dates").update({label:te.trim(),start_date:ne,end_date:qe,all_day:U,notes:Z.trim()||null,location:ee.trim()||null,description:je.trim()||null,is_recurring:oe,recurrence_rule:Ve,recurrence_end_date:oe&&kt?Xr(kt).toISOString():null,is_embedded_trip:Et,is_virtual:ue}).eq("id",Ce);if(Lt)throw Lt;const{error:nr}=await F.from("experience_dates").delete().eq("parent_date_id",Ce);if(nr)throw nr;if(oe&&kt){const gr=pA(Ve,re,kt,te.trim(),e,Ce,U);if(gr.length>0){const{error:Ha}=await F.from("experience_dates").insert(gr);if(Ha)throw Ha}}}},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-dates",e]}),o(null),n({title:"Date updated"})}}),fn=Me({mutationFn:async Ce=>{const{error:ut}=await F.from("experience_dates").delete().eq("id",Ce);if(ut)throw ut},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-dates",e]})}}),Xt=()=>{c(""),d(""),m(""),x(""),p(""),b(!0),N(!1),_("every_n_weeks"),P("4"),C("2"),O("3"),E("2"),q(""),$(""),B(""),A(""),G(!1),fe(!1),s(!1)},_e=Ce=>{o(Ce.id),J(Ce.label),z(Ce.all_day);const ut=new Date(Ce.start_date);if(pe(Ye(ut,"yyyy-MM-dd")),X(Ce.all_day?"":Ye(ut,"HH:mm")),Ce.end_date){const ne=new Date(Ce.end_date);D(Ye(ne,"yyyy-MM-dd")),V(Ce.all_day?"":Ye(ne,"HH:mm"))}else D(""),V("");
802if(ve(Ce.notes||""),de(Ce.location||""),Q(Ce.description||""),Pe(Ce.is_recurring),Nt(Ce.is_embedded_trip||!1),we(Ce.is_virtual||!1),Ce.recurrence_rule){const ne=Ce.recurrence_rule;Je(ne.type),et(String(ne.weekday)),be(String(ne.interval||2)),Ze(String(ne.nth||3)),rt(String(ne.monthInterval||2))}else Je("every_n_weeks"),et("4"),be("2"),Ze("3"),rt("2");jt(Ce.recurrence_end_date?Ye(new Date(Ce.recurrence_end_date),"yyyy-MM-dd"):"")},It=Ce=>{const ut=new Date(Ce.start_date),ne=Ce.end_date?new Date(Ce.end_date):null;if(Ce.all_day){const Lt=Ye(Xr(Ce.start_date.substring(0,10)),"MMM d, yyyy"),nr=ne?` â ${Ye(Xr(Ce.end_date.substring(0,10)),"MMM d, yyyy")}`:"";return Lt+nr}const qe=Ye(ut,"MMM d, yyyy h:mm a"),Ve=ne?` â ${Ye(ne,"MMM d, yyyy h:mm a")}`:"";return qe+Ve},nn=(Ce,ut)=>a.jsxs("div",{className:"p-2 space-y-2",children:[a.jsx(ce,{value:te,onChange:ne=>J(ne.target.value),className:"h-7 text-xs",placeholder:"Label"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ta,{checked:U,onCheckedChange:ne=>{if(z(ne),!ne&&re&&!he){const qe=pu(re,ye||"09:00");ye||X("09:00"),D(qe.date),V(qe.time)}},className:"scale-75"}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"All day"})]}),a.jsxs("div",{className:"flex gap-1.5 flex-wrap",children:[a.jsx(ce,{type:"date",value:re,onChange:ne=>{if(pe(ne.target.value),!U&&ne.target.value){const qe=pu(ne.target.value,ye||"09:00");D(qe.date),V(qe.time)}},className:"h-7 text-xs w-[8.5rem]"}),!U&&a.jsx(ce,{type:"time",value:ye,onChange:ne=>{if(X(ne.target.value),re){const qe=pu(re,ne.target.value);D(qe.date),V(qe.time)}},className:"h-7 text-xs w-[5.5rem]"}),a.jsx("span",{className:"text-xs text-muted-foreground self-center",children:"â"}),a.jsx(ce,{type:"date",value:he,onChange:ne=>D(ne.target.value),className:"h-7 text-xs w-[8.5rem]",placeholder:"End"}),!U&&a.jsx(ce,{type:"time",value:le,onChange:ne=>V(ne.target.value),className:"h-7 text-xs w-[5.5rem]"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ta,{checked:ue,onCheckedChange:we,className:"scale-75"}),a.jsx(nm,{className:"h-3 w-3 text-muted-foreground"}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Virtual"}),ue&&(ge==null?void 0:ge.zoom_link)&&a.jsx(Y,{type:"button",variant:"outline",size:"sm",className:"h-6 text-[10px] ml-auto",onClick:()=>de(ge.zoom_link),children:"Insert Zoom default"})]}),a.jsx(ce,{value:ee,onChange:ne=>de(ne.target.value),placeholder:ue?"Zoom or meeting link":"Location",className:"h-7 text-xs"}),a.jsx(qt,{value:je,onChange:ne=>Q(ne.target.value),placeholder:"Internal-only notes - NOT sent to participants",rows:2,className:"text-xs"}),!ut&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ta,{checked:Et,onCheckedChange:Nt,className:"scale-75"}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Embedded trip dates (syncs to task anchors)"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ta,{checked:oe,onCheckedChange:Pe,className:"scale-75"}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Recurring"})]}),oe&&a.jsxs("div",{className:"space-y-2 rounded border border-border p-2 bg-muted/30",children:[a.jsxs(lt,{value:ze,onValueChange:ne=>Je(ne),children:[a.jsx(it,{className:"h-7 text-xs",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"every_n_weeks",children:"Every N weeks"}),a.jsx(Oe,{value:"nth_weekday_monthly",children:"Nth weekday of month"}),a.jsx(Oe,{value:"every_n_months",children:"Every N months"})]})]}),a.jsxs("div",{className:"flex gap-2 items-end",children:[ze!=="every_n_months"&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Weekday"}),a.jsxs(lt,{value:Ae,onValueChange:et,children:[a.jsx(it,{className:"h-7 text-xs w-28",children:a.jsx(ct,{})}),a.jsx(ot,{children:mA.map((ne,qe)=>a.jsx(Oe,{value:String(qe),children:ne},qe))})]})]}),ze==="every_n_weeks"&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Every N weeks"}),a.jsx(ce,{type:"number",min:"1",max:"12",value:Ne,onChange:ne=>be(ne.target.value),className:"h-7 text-xs w-16"})]}),ze==="nth_weekday_monthly"&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Nth occurrence"}),a.jsxs(lt,{value:Ue,onValueChange:Ze,children:[a.jsx(it,{className:"h-7 text-xs w-20",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"1",children:"1st"}),a.jsx(Oe,{value:"2",children:"2nd"}),a.jsx(Oe,{value:"3",children:"3rd"}),a.jsx(Oe,{value:"4",children:"4th"})]})]})]}),ze==="every_n_months"&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Every N months"}),a.jsx(ce,{type:"number",min:"1",max:"12",value:nt,onChange:ne=>rt(ne.target.value),className:"h-7 text-xs w-16"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Recurrence ends"}),a.jsx(ce,{type:"date",value:kt,onChange:ne=>jt(ne.target.value),className:"h-7 text-xs"})]})]})]}),a.jsx(qt,{value:Z,onChange:ne=>ve(ne.target.value),placeholder:"Notes (e.g. virtual meeting link, agenda)",rows:2,className:"text-xs"}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>o(null),children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>Tt.mutate({id:Ce.id,isChild:ut}),disabled:!te.trim()||!re,children:"Save"})]})]}),tn=Ce=>a.jsxs(a.Fragment,{children:[(Ce.location||Ce.description)&&i!==Ce.id&&a.jsxs("div",{className:"px-2 pb-1 space-y-0.5",children:[Ce.location&&a.jsxs("div",{className:"flex items-center gap-1 pl-5",children:[a.jsx(zi,{className:"h-2.5 w-2.5 text-muted-foreground flex-shrink-0"}),a.jsx("span",{className:"text-[10px] text-muted-foreground truncate",children:Ce.location})]}),Ce.description&&a.jsx("p",{className:"text-[10px] text-muted-foreground truncate pl-5",children:Ce.description})]}),Ce.notes&&i!==Ce.id&&a.jsx("div",{className:"px-2 pb-1",children:a.jsx("p",{className:"text-[10px] text-muted-foreground truncate pl-5 italic",children:Ce.notes})})]}),Zt=`https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/calendar-feed/${e}.ics`;return a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Dates (",Ie.length,")"]}),a.jsxs("div",{className:"flex items-center gap-1",children:[Ie.length>0&&a.jsx(w8,{feedUrl:Zt,label:"Calendar",className:"h-6 px-2 text-xs gap-1"}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>s(!r),children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add Date"]})]})]}),r&&a.jsxs("div",{className:"mb-3 space-y-2 rounded-md border border-border bg-background p-3",children:[a.jsx(ce,{value:l,onCh
802ange:Ce=>c(Ce.target.value),placeholder:"Label (e.g. Meeting 1, Trip Dates)",className:"h-8 text-xs"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ta,{checked:v,onCheckedChange:Ce=>{if(b(Ce),!Ce&&u&&!f){const ut=pu(u,h||"09:00");h||m("09:00"),x(ut.date),p(ut.time)}},className:"scale-75"}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"All day"})]}),a.jsxs("div",{className:"flex gap-1.5 flex-wrap",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Start"}),a.jsx(ce,{type:"date",value:u,onChange:Ce=>{if(d(Ce.target.value),!v&&Ce.target.value){const ut=pu(Ce.target.value,h||"09:00");x(ut.date),p(ut.time)}},className:"h-8 text-xs w-[8.5rem]"})]}),!v&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Time"}),a.jsx(ce,{type:"time",value:h,onChange:Ce=>{if(m(Ce.target.value),u){const ut=pu(u,Ce.target.value);x(ut.date),p(ut.time)}},className:"h-8 text-xs w-[5.5rem]"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"End (optional)"}),a.jsx(ce,{type:"date",value:f,onChange:Ce=>x(Ce.target.value),className:"h-8 text-xs w-[8.5rem]"})]}),!v&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Time"}),a.jsx(ce,{type:"time",value:g,onChange:Ce=>p(Ce.target.value),className:"h-8 text-xs w-[5.5rem]"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ta,{checked:H,onCheckedChange:fe,className:"scale-75"}),a.jsx(nm,{className:"h-3 w-3 text-muted-foreground"}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Virtual"}),H&&(ge==null?void 0:ge.zoom_link)&&a.jsx(Y,{type:"button",variant:"outline",size:"sm",className:"h-6 text-[10px] ml-auto",onClick:()=>B(ge.zoom_link),children:"Insert Zoom default"})]}),a.jsx(ce,{value:M,onChange:Ce=>B(Ce.target.value),placeholder:H?"Zoom or meeting link":"Location",className:"h-8 text-xs"}),a.jsx(qt,{value:W,onChange:Ce=>A(Ce.target.value),placeholder:"Internal-only notes - NOT sent to participants",rows:2,className:"text-xs"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ta,{checked:K,onCheckedChange:G,className:"scale-75"}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Embedded trip dates (syncs to task anchors)"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ta,{checked:w,onCheckedChange:N,className:"scale-75"}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Recurring"})]}),w&&a.jsxs("div",{className:"space-y-2 rounded border border-border p-2 bg-muted/30",children:[a.jsxs(lt,{value:j,onValueChange:Ce=>_(Ce),children:[a.jsx(it,{className:"h-7 text-xs",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"every_n_weeks",children:"Every N weeks"}),a.jsx(Oe,{value:"nth_weekday_monthly",children:"Nth weekday of month"}),a.jsx(Oe,{value:"every_n_months",children:"Every N months"})]})]}),a.jsxs("div",{className:"flex gap-2 items-end",children:[j!=="every_n_months"&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Weekday"}),a.jsxs(lt,{value:S,onValueChange:P,children:[a.jsx(it,{className:"h-7 text-xs w-28",children:a.jsx(ct,{})}),a.jsx(ot,{children:mA.map((Ce,ut)=>a.jsx(Oe,{value:String(ut),children:Ce},ut))})]})]}),j==="every_n_weeks"&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Every N weeks"}),a.jsx(ce,{type:"number",min:"1",max:"12",value:k,onChange:Ce=>C(Ce.target.value),className:"h-7 text-xs w-16"})]}),j==="nth_weekday_monthly"&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Nth occurrence"}),a.jsxs(lt,{value:T,onValueChange:O,children:[a.jsx(it,{className:"h-7 text-xs w-20",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"1",children:"1st"}),a.jsx(Oe,{value:"2",children:"2nd"}),a.jsx(Oe,{value:"3",children:"3rd"}),a.jsx(Oe,{value:"4",children:"4th"})]})]})]}),j==="every_n_months"&&a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Every N months"}),a.jsx(ce,{type:"number",min:"1",max:"12",value:L,onChange:Ce=>E(Ce.target.value),className:"h-7 text-xs w-16"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Recurrence ends"}),a.jsx(ce,{type:"date",value:R,onChange:Ce=>q(Ce.target.value),className:"h-7 text-xs"})]})]}),a.jsx(qt,{value:I,onChange:Ce=>$(Ce.target.value),placeholder:"Notes (e.g. virtual meeting link, agenda, location details)",rows:2,className:"text-xs"}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:Xt,children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>He.mutate(),disabled:!l.trim()||!u||He.isPending,children:"Add"})]})]}),a.jsx("div",{className:"space-y-1",children:Ke.map(Ce=>{const ut=Qe(Ce.id);return a.jsxs("div",{className:"rounded border border-border bg-background",children:[i===Ce.id?nn(Ce,!1):a.jsxs("div",{className:"flex items-center justify-between px-2 py-1.5 group",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[Ce.is_recurring?a.jsx(Hx,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}):a.jsx(rs,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),a.jsx("span",{className:"text-xs font-medium text-foreground",children:Ce.label}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:It(Ce)}),Ce.is_embedded_trip&&a.jsx("span",{className:"text-[9px] uppercase tracking-wide px-1.5 py-0.5 rounded bg-primary/10 text-primary font-medium",children:"Trip Dates"}),Ce.is_recurring&&ut.length>0&&a.jsxs("span",{className:"text-[10px] text-primary",children:["(",ut.length," dates)"]})]}),a.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>_e(Ce),children:a.jsx(Rn,{className:"h-3 w-3"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>fn.mutate(Ce.id),children:a.jsx(pn,{className:"h-3 w-3"})})]})]}),tn(Ce),ut.length>0&&i!==Ce.id&&a.jsx("div",{className:"border-t border-border px-2 py-1 space-y-0.5 bg-muted/20",children:ut.map(ne=>a.jsx("div",{children:i===ne.id?nn(ne,!0):a.jsxs("div",{className:"group",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted-foreground pl-4",children:[a.jsx(rs,{className:"h-2.5 w-2.5 flex-shrink-0"}),a.jsx("span",{className:"flex-1",children:It(ne)}),ne.location&&a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(zi,{className:"h-2 w-2"}),a.jsx("span",{className:"truncate max-w-[100px]",children:ne.location})]}),a.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>_e(ne),children:a.jsx(Rn,{className:"h-2.5 w-2.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5 text-destructive",onClick:()=>fn.mutate(ne.id),children:a.jsx(pn,{className:"h-2.5 w-2.5"})})]})]}),(ne.description||ne.notes)&&a.jsxs("div",{className:"pl-9 pb-0.5",children:[ne.description&&a.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:ne.description}),ne.notes&&a.jsx("p",{className:"text-[10px] text-muted-foreground truncate italic",children:ne.n
802otes})]})]})},ne.id))})]},Ce.id)})})]})}const Oi=F,Mue=[{key:"cost_type",label:"Type"},{key:"amount",label:"Amount"},{key:"currency",label:"Currency"},{key:"includes_generators",label:"Incl. Gen/Guide"},{key:"supplier_id",label:"Supplier"},{key:"quote_id",label:"Quote"}];function Due({experienceId:e,selected:t,orderedIds:n,totals:r,categories:s,onClear:i}){const o=at(),[l,c]=y.useState("supplier"),[u,d]=y.useState(""),[h,m]=y.useState("amount"),{data:f=[]}=Ee({queryKey:["suppliers-options"],queryFn:async()=>(await Oi.from("suppliers").select("id, name, type").order("name")).data||[]}),{data:x=[]}=Ee({queryKey:["experience-quotes-for-lines",e],queryFn:async()=>(await Oi.from("experience_quotes").select("id, received_date, status, suppliers(name)").eq("experience_id",e)).data||[]}),g=t.map(w=>w.id),p=()=>{o.invalidateQueries({queryKey:["budget-items",e]}),o.invalidateQueries({queryKey:["budget-item-detail"]}),o.invalidateQueries({queryKey:["budget-item-payments"]}),o.invalidateQueries({queryKey:["budget-payment-counts",e]})},v=async()=>{if(!u&&l!=="supplier"&&l!=="quote")return Mt.error("Choose a value");let w=null;if(l==="supplier"){const N=t.filter(j=>j.quote_id).length;({error:w}=await Oi.from("experience_budget_items").update({supplier_id:u||null}).in("id",g).is("quote_id",null)),N&&Mt.message(`${N} line(s) skipped â their supplier comes from the attached quote`)}else if(l==="quote")({error:w}=await Oi.from("experience_budget_items").update({quote_id:u||null,...u?{stale_pending_requote:!1}:{}}).in("id",g));else if(l==="category")({error:w}=await Oi.from("experience_budget_items").update({name:u}).in("id",g));else if(l==="due"){const N=`${u}-01`;for(const j of g){await Oi.from("experience_budget_item_payments").delete().eq("budget_item_id",j);const _=await Oi.from("experience_budget_item_payments").insert({budget_item_id:j,due_month:N,amount:Math.round(r[j]||0)});if(_.error){w=_.error;break}}w||({error:w}=await Oi.from("experience_budget_items").update({schedule_edited:!0}).in("id",g))}if(w)return Mt.error(w.message);Mt.success(`Updated ${g.length} line(s)`),p()},b=async()=>{const w=n.filter(k=>g.includes(k));if(w.length<2)return Mt.error("Select the source row and at least one row below it");const N=t.find(k=>k.id===w[0]),j=w.slice(1);let _={[h]:N[h]??null};h==="quote_id"&&(_={quote_id:N.quote_id??null,...N.quote_id?{stale_pending_requote:!1}:{}});let S=Oi.from("experience_budget_items").update(_).in("id",j);h==="supplier_id"&&(S=S.is("quote_id",null));const{error:P}=await S;if(P)return Mt.error(P.message);Mt.success(`Filled ${j.length} row(s) from the top selected row`),p()};return a.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5 text-[11px] mb-1",children:[a.jsxs("span",{className:"font-medium",children:[g.length," selected"]}),a.jsx("span",{className:"text-muted-foreground",children:"Set for all:"}),a.jsxs(lt,{value:l,onValueChange:w=>{c(w),d("")},children:[a.jsx(it,{className:"h-7 w-28 text-[11px]",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"supplier",children:"Supplier"}),a.jsx(Oe,{value:"quote",children:"Quote"}),a.jsx(Oe,{value:"category",children:"Category"}),a.jsx(Oe,{value:"due",children:"Payment due"})]})]}),l==="due"?a.jsx(ce,{type:"month",className:"h-7 w-36 text-[11px]",value:u,onChange:w=>d(w.target.value)}):a.jsxs(lt,{value:u||"none",onValueChange:w=>d(w==="none"?"":w),children:[a.jsx(it,{className:"h-7 w-48 text-[11px]",children:a.jsx(ct,{placeholder:"Chooseâ¦"})}),a.jsxs(ot,{className:"max-h-72",children:[l!=="category"&&a.jsx(Oe,{value:"none",children:"None"}),l==="supplier"&&f.map(w=>a.jsx(Oe,{value:w.id,children:w.name},w.id)),l==="quote"&&x.map(w=>{var N;return a.jsxs(Oe,{value:w.id,children:[((N=w.suppliers)==null?void 0:N.name)||"No supplier"," â ",w.received_date||"not received"]},w.id)}),l==="category"&&s.map(w=>a.jsx(Oe,{value:w,children:w},w))]})]}),a.jsx(Y,{size:"sm",className:"h-7 text-[11px]",onClick:v,children:"Apply"}),a.jsx("span",{className:"text-muted-foreground ml-2",children:"Fill down:"}),a.jsxs(lt,{value:h,onValueChange:m,children:[a.jsx(it,{className:"h-7 w-32 text-[11px]",children:a.jsx(ct,{})}),a.jsx(ot,{children:Mue.map(w=>a.jsx(Oe,{value:w.key,children:w.label},w.key))})]}),a.jsx(Y,{size:"sm",variant:"outline",className:"h-7 text-[11px]",onClick:b,children:"Fill down"}),a.jsx(Y,{size:"sm",variant:"ghost",className:"h-7 text-[11px] ml-auto",onClick:i,children:"Clear"})]})}const $ue={USD:"$",EUR:"â¬",GBP:"£",CHF:"CHF",CAD:"C$",NZD:"NZ$",AUD:"A$",KES:"KSh",NOK:"kr"},Rue=["EUR","GBP","CHF","CAD","NZD","AUD","KES","NOK"];function Iue({experienceId:e,settings:t,canEdit:n}){const r=at(),{data:s}=Ee({queryKey:["experience-reconciled",e],queryFn:async()=>(await F.from("experiences").select("reconciled_at").eq("id",e).maybeSingle()).data}),{data:i=[]}=Ee({queryKey:["experience-rate-log",e],queryFn:async()=>(await F.from("experience_rate_log").select("*").eq("experience_id",e).order("changed_at",{ascending:!1})).data??[]}),o=!!(s!=null&&s.reconciled_at),l=o&&!(t!=null&&t.rate_unlocked),c=(t==null?void 0:t.foreign_currency)||"EUR",u=Me({mutationFn:async m=>{const{error:f}=await F.from("experience_budget_settings").update(m).eq("experience_id",e);if(f)throw f},onSuccess:()=>{r.invalidateQueries({queryKey:["budget-settings",e]}),r.invalidateQueries({queryKey:["experience-rate-log",e]}),r.invalidateQueries({queryKey:["budget-items",e]})},onError:m=>Mt.error(m.message)}),d=async m=>{await u.mutateAsync(m),o&&await u.mutateAsync({rate_unlocked:!1}),r.invalidateQueries()},h=t!=null&&t.rate_entered_at?new Date(t.rate_entered_at).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):"no date";return a.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[a.jsxs(lt,{value:c,disabled:!n||l,onValueChange:m=>d({foreign_currency:m}),children:[a.jsx(it,{className:"h-6 w-14 text-[10px] px-1",children:a.jsx(ct,{})}),a.jsx(ot,{children:Rue.map(m=>a.jsx(Oe,{value:m,children:m},m))})]}),a.jsx(xe,{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:"âUSD:"}),a.jsx(as,{type:"text",inputMode:"decimal",disabled:!n||l,className:"h-6 w-16 text-[10px] px-1",value:(t==null?void 0:t.exchange_rate_eur)??1.08,onCommit:m=>{const f=m?parseFloat(m):NaN;!isNaN(f)&&f!==(t==null?void 0:t.exchange_rate_eur)&&d({exchange_rate_eur:f})}}),a.jsxs("span",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:["entered ",h,t!=null&&t.rate_date_backfilled?" (backfilled)":""]}),l&&a.jsxs(a.Fragment,{children:[a.jsx(lH,{className:"h-3 w-3 text-muted-foreground","aria-label":"Locked â experience is Reconciled"}),n&&a.jsx(Y,{variant:"link",size:"sm",className:"h-auto p-0 text-[10px]",onClick:()=>{window.confirm("This experience is Reconciled. Unlock the rate? The unlock is recorded in the rate log.")&&u.mutate({rate_unlocked:!0})},children:"Unlock"})]}),a.jsxs(na,{children:[a.jsx(ra,{asChild:!0,children:a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",title:"Rate change log",children:a.jsx(oC,{className:"h-3 w-3"})})}),a.jsxs(Kr,{className:"w-80 text-[11px] space-y-1 max-h-72 overflow-auto",children:[a.jsx("p",{className:"font-medium",children:"Rate log"}),i.length===0&&a.jsx("p",{className:"text-muted-foreground",children:"No changes recorded."}),i.map(m=>a.jsxs("div",{className:"border-b border-border pb-1",children:[a.jsx("span",{className:"text-muted-foreground",children:new Date(m.changed_at).toLocaleStr
802ing()})," ",m.action==="change"&&a.jsxs(a.Fragment,{children:[m.currency,": ",m.old_rate??"â"," â ",m.new_rate]}),m.action==="unlock"&&a.jsx(a.Fragment,{children:"Unlocked"}),m.action==="relock"&&a.jsx(a.Fragment,{children:"Relocked"}),m.action==="backfill"&&a.jsxs(a.Fragment,{children:["Date backfilled (",m.currency," ",m.new_rate,")"]}),m.changed_by_email&&a.jsxs("span",{className:"text-muted-foreground",children:[" · ",m.changed_by_email]})]},m.id))]})]})]})}const Ai=F,gA=e=>(e||"").split(",")[0].trim().toLowerCase(),Lue=["id","created_at","updated_at","experience_id","suppliers","estimate_status"];function Fue({experienceId:e,location:t,activeCategories:n}){const r=at(),[s,i]=y.useState(""),[o,l]=y.useState(!1),c=gA(t),{data:u=[]}=Ee({queryKey:["budget-copy-candidates",e,c],enabled:!!c,queryFn:async()=>{const{data:m}=await Ai.from("experiences").select("id, name, public_name, location, target_start_date").neq("id",e).order("target_start_date",{ascending:!1}),f=(m||[]).filter(p=>gA(p.location)===c);if(!f.length)return[];const{data:x}=await Ai.from("experience_budget_items").select("experience_id").in("experience_id",f.map(p=>p.id)).gt("amount",0),g=new Set((x||[]).map(p=>p.experience_id));return f.filter(p=>g.has(p.id))}});if(!u.length)return null;const d=s||u[0].id,h=async()=>{l(!0);try{const{data:m,error:f}=await Ai.from("experience_budget_items").select("*").eq("experience_id",d).order("sort_order");if(f)throw f;const x=(m||[]).filter(j=>j.source!=="generator_comp"&&j.source!=="facilitator_comp"),g=[...new Set(x.map(j=>j.quote_id).filter(Boolean))],p=new Map;if(g.length){const{data:j,error:_}=await Ai.from("experience_quotes").select("*").in("id",g);if(_)throw _;for(const S of j||[]){const{id:P,created_at:k,updated_at:C,experience_id:T,...O}=S,{data:L,error:E}=await Ai.from("experience_quotes").insert({...O,experience_id:e,copied_from_quote_id:P}).select("id").single();if(E)throw E;p.set(P,L.id)}}const v=x.map(j=>{const _={};for(const[S,P]of Object.entries(j))Lue.includes(S)||(_[S]=P);return{..._,experience_id:e,quote_id:j.quote_id?p.get(j.quote_id)??null:null,copied_from_experience_id:d,stale_pending_requote:!0,is_closed:!1,spent_to_date:null,confirmed_date:null,confirmation_ref:null,status_override:null,status_override_reason:null,schedule_edited:!1,valid_until:j.quote_id?j.valid_until:null}});if(v.length){const{error:j}=await Ai.from("experience_budget_items").insert(v);if(j)throw j}const b=new Set(v.filter(j=>j.category==="direct").map(j=>j.name)),w=n.filter(j=>!b.has(j.name)).map(j=>({name:j.name,cost_type:j.default_cost_type,sort_order:j.sort_order,experience_id:e,category:"direct",amount:0,currency:"USD",includes_generators:!0,generator_count:0}));w.length&&await Ai.from("experience_budget_items").insert(w);const{data:N}=await Ai.from("experience_budget_settings").select("exchange_rate_eur").eq("experience_id",d).maybeSingle();await Ai.from("experience_budget_settings").upsert({experience_id:e,override_pax_count:null,exchange_rate_eur:(N==null?void 0:N.exchange_rate_eur)??1.08}),r.invalidateQueries({queryKey:["budget-items",e]}),r.invalidateQueries({queryKey:["budget-settings",e]}),Mt.success(`Copied ${v.length} lines â all flagged stale until re-quoted`)}catch(m){Mt.error(m.message)}finally{l(!1)}};return a.jsxs("div",{className:"flex flex-col items-center gap-1.5 border-t border-border pt-3 mt-1 w-full",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"We've run this destination before. Copy that budget with its suppliers and quotes?"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(lt,{value:d,onValueChange:i,children:[a.jsx(it,{className:"h-8 text-xs w-64",children:a.jsx(ct,{})}),a.jsx(ot,{children:u.map(m=>a.jsxs(Oe,{value:m.id,className:"text-xs",children:[m.public_name||m.name,m.target_start_date?` · ${m.target_start_date.slice(0,7)}`:""]},m.id))})]}),a.jsxs(Y,{size:"sm",variant:"outline",className:"text-xs",onClick:h,disabled:o,children:[o?a.jsx(vt,{className:"h-3 w-3 mr-1 animate-spin"}):a.jsx(zv,{className:"h-3 w-3 mr-1"})," Copy budget"]})]})]})}const Ag=e=>
802e==null?"â":e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),xA=e=>`${e.name.trim().toLowerCase()}|${(e.description||"").trim().toLowerCase()}`;function que({open:e,onOpenChange:t,priorTripId:n,currentLines:r,currentAmounts:s,renderStatus:i}){const{data:o,isLoading:l}=Ee({queryKey:["prior-trip-compare",n],enabled:e,queryFn:async()=>{const[{data:f},{data:x,error:g}]=await Promise.all([F.from("experiences").select("name, status").eq("id",n).maybeSingle(),F.from("experience_budget_items").select("id, name, description, category, sort_order").eq("experience_id",n).eq("category","direct").order("sort_order")]);if(g)throw g;const p=await Promise.all((x||[]).map(async v=>{const{data:b}=await F.rpc("compute_budget_item_total",{_item_id:v.id});return[v.id,Number(b)||0]}));return{exp:f,items:x||[],totals:Object.fromEntries(p)}}}),c=[];if(o){const f=new Map,x=new Map;for(const p of o.items){const v=xA(p);f.set(v,(f.get(v)||0)+(o.totals[p.id]||0)),x.set(v,p)}const g=new Set;for(const p of r.filter(v=>v.category==="direct")){const v=xA(p);g.add(v),c.push({label:p.name,detail:p.description||"",prior:f.has(v)?f.get(v):null,current:s[p.id]??0,status:p.estimate_status,hasCurrent:!0})}for(const[p,v]of f){if(g.has(p))continue;const b=x.get(p);c.push({label:b.name,detail:b.description||"",prior:v,current:null,hasCurrent:!1})}}const u=c.reduce((f,x)=>f+(x.prior||0),0),d=c.reduce((f,x)=>f+(x.current||0),0),h=(f,x)=>f==null||x==null?null:f===0?x===0?0:null:(x-f)/f*100,m=f=>a.jsx("span",{className:Se(f==null?"text-muted-foreground":f>0?"text-destructive":f<0?"text-emerald-700 dark:text-emerald-400":""),children:f==null?"â":`${f>0?"+":""}${f.toFixed(1)}%`});return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsxs(At,{children:["Compare to prior trip",o!=null&&o.exp?`: ${o.exp.name}`:""]})}),(o==null?void 0:o.exp)&&o.exp.status!=="completed"&&a.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"The prior trip isn't marked Completed, so its amounts may not be final actuals."}),l?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-xs text-muted-foreground border-b",children:[a.jsx("th",{className:"text-left py-1.5",children:"Line item"}),a.jsx("th",{className:"text-right py-1.5",children:"Prior actual"}),a.jsx("th",{className:"text-right py-1.5",children:"Current"}),a.jsx("th",{className:"text-right py-1.5",children:"Diff"}),a.jsx("th",{className:"text-center py-1.5",children:"Status"})]})}),a.jsxs("tbody",{children:[c.map((f,x)=>a.jsxs("tr",{className:"border-b last:border-0",children:[a.jsxs("td",{className:"py-1.5",children:[a.jsx("div",{children:f.label}),f.detail&&a.jsx("div",{className:"text-xs text-muted-foreground",children:f.detail})]}),a.jsx("td",{className:"text-right tabular-nums",children:Ag(f.prior)}),a.jsx("td",{className:"text-right tabular-nums",children:Ag(f.current)}),a.jsx("td",{className:"text-right tabular-nums",children:m(h(f.prior,f.current))}),a.jsx("td",{className:"text-center",children:f.hasCurrent?i(f.status):a.jsx("span",{className:"text-xs text-muted-foreground",children:"not on this trip"})})]},x)),a.jsxs("tr",{className:"font-medium border-t-2",children:[a.jsx("td",{className:"py-1.5",children:"Total direct costs"}),a.jsx("td",{className:"text-right tabular-nums",children:Ag(u)}),a.jsx("td",{className:"text-right tabular-nums",children:Ag(d)}),a.jsx("td",{className:"text-right tabular-nums",children:m(h(u,d))}),a.jsx("td",{})]})]})]})]})})}function Mp(){return Ee({queryKey:["budget-categories"],queryFn:async()=>{const{data:e,error:t}=await F.from("budget_categories").select("name, default_cost_type, sort_order, active, expects_quote").order("sort_order");if(t)throw t;return e||[]},staleTime:6e4})}const zue={USD:"$",EUR:"â¬",GBP:"£",CHF:"CHF ",CAD:"CA$"},yA=e=>zue[e||"USD"]||`${e} `;function Bue({budgetItemId:e,experienceId:t,chosenId:n,onChoose:r,currency:s="USD"}
802){const i=F,o=at(),{toast:l}=mt(),[c,u]=y.useState(!1),[d,h]=y.useState(null),[m,f]=y.useState(""),{data:x=[]}=Ee({queryKey:["quote-options",e,n],queryFn:async()=>{const{data:w}=await i.from("budget_item_quote_options").select("quote_id, experience_quotes(id, received_date, amount_per_person, amount_per_group, valid_until, currency, suppliers(name))").eq("budget_item_id",e),N=(w||[]).map(j=>j.experience_quotes).filter(Boolean);if(n&&!N.some(j=>j.id===n)){await i.from("budget_item_quote_options").insert({budget_item_id:e,quote_id:n});const{data:j}=await i.from("experience_quotes").select("id, received_date, amount_per_person, amount_per_group, valid_until, currency, suppliers(name)").eq("id",n).maybeSingle();j&&N.unshift(j)}return N}}),g=()=>{o.invalidateQueries({queryKey:["quote-options",e]}),o.invalidateQueries({queryKey:["experience-quotes",t]}),o.invalidateQueries({queryKey:["experience-quotes-for-lines",t]})},p=async()=>{const w=parseFloat(m.replace(/[^0-9.\-]/g,""));if(!d||!isFinite(w))return l({title:"A quote needs a supplier and an amount",variant:"destructive"});const{data:N,error:j}=await i.from("experience_quotes").insert({experience_id:t,supplier_id:d,status:"Received",received_date:new Date().toLocaleDateString("en-CA"),amount_per_group:w,currency:s}).select("id").single();if(j)return l({title:"Could not add quote",description:j.message,variant:"destructive"});await i.from("budget_item_quote_options").insert({budget_item_id:e,quote_id:N.id}),u(!1),h(null),f(""),g(),n||r(N.id)},v=async w=>{await i.from("budget_item_quote_options").delete().eq("budget_item_id",e).eq("quote_id",w),g()},b=w=>w.amount_per_group!=null?`${yA(w.currency)}${Number(w.amount_per_group).toLocaleString()}`:w.amount_per_person!=null?`${yA(w.currency)}${Number(w.amount_per_person).toLocaleString()} pp`:"â";return a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Quotes for this line"}),x.length>0&&a.jsx("div",{className:"rounded border border-border divide-y divide-border",children:x.map(w=>{var j;const N=w.id===n;return a.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 text-xs",children:[a.jsx("span",{className:"flex-1 truncate",children:((j=w.suppliers)==null?void 0:j.name)||"No supplier"}),a.jsx("span",{className:"tabular-nums",children:b(w)}),a.jsx("span",{className:"text-muted-foreground w-20",children:w.received_date||""}),N?a.jsx("span",{className:"rounded bg-primary/10 text-primary px-1.5 py-0.5 text-[10px] font-medium",children:"Chosen"}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Not chosen"}),a.jsx(Y,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>r(w.id),children:"Choose"}),a.jsx(Y,{variant:"link",size:"sm",className:"h-auto p-0 text-xs text-muted-foreground",title:"Remove from this line (the quote is kept on the trip)",onClick:()=>v(w.id),children:"Remove"})]})]},w.id)})}),c?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Eb,{experienceId:t,value:d,onChange:h,className:"flex-1"}),a.jsx(ce,{className:"h-8 text-xs w-28",type:"text",inputMode:"decimal",placeholder:"Amount",value:m,onChange:w=>f(w.target.value)}),a.jsx(Y,{size:"sm",className:"h-8 text-xs",onClick:p,children:"Add"}),a.jsx(Y,{size:"sm",variant:"ghost",className:"h-8 text-xs",onClick:()=>u(!1),children:"Cancel"})]}):a.jsx("div",{children:a.jsx(Y,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>u(!0),children:"+ Add competing quote"})})]})}function Uue({supplierId:e}){const t=F,n=at(),[r,s]=y.useState(""),[i,o]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState(!1),{data:h}=Ee({queryKey:["supplier-contact",e],queryFn:async()=>(await t.from("suppliers").select("id, name, contact_name, contact_email, contact_phone, contact_prompt_dismissed_at").eq("id",e).maybeSingle()).data});if(u||!h||h.contact_name||h.contact_email||h.contact_phone||h.contact_prompt_dismissed_at)return null;const m=async f=>{d(!0),await t.from("suppliers").update({...f,contact_prompt_dismissed_at:new Date().toISOString()}).eq("id",e),n.invalidateQueries({queryKey:["supplier-contact",e]}),n.invalidateQueries({queryKey:["suppliers"]})};return a.jsxs("div",{className:"col-span-2 rounded border border-border bg-muted/40 p-2 space-y-1.5 text-xs",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{children:["Add a contact for ",a.jsx("b",{children:h.name}),"? (optional)"]}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5","aria-label":"Dismiss",onClick:()=>m({}),children:a.jsx(Ht,{className:"h-3 w-3"})})]}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx(ce,{className:"h-7 text-xs",placeholder:"Name",value:r,onChange:f=>s(f.target.value)}),a.jsx(ce,{className:"h-7 text-xs",placeholder:"Email",value:i,onChange:f=>o(f.target.value)}),a.jsx(ce,{className:"h-7 text-xs",placeholder:"Phone",value:l,onCh
802ange:f=>c(f.target.value)}),a.jsx(Y,{size:"sm",className:"h-7 text-xs",disabled:!r.trim()&&!i.trim()&&!l.trim(),onClick:()=>m({contact_name:r.trim()||null,contact_email:i.trim()||null,contact_phone:l.trim()||null}),children:"Save"})]})]})}function xy(e){return e?e<new Date().toISOString().slice(0,10):!1}function _8(e){return(e==null?void 0:e.slice(0,7))??""}function vA(e){return e?`${e}-01`:""}function Wue(e){return _8(e)}function Kue(e,t,n){const r=e.deposit_amount!=null?Number(e.deposit_amount):e.deposit_pct!=null?t*Number(e.deposit_pct)/100:null;if(r==null||!e.deposit_due_date||!n)return null;const s=`${n.slice(0,7)}-01`;return[{label:"Deposit",amount:Math.min(r,t),month:`${String(e.deposit_due_date).slice(0,7)}-01`},{label:"Balance",amount:Math.max(0,t-r),month:s}].filter(i=>i.amount>0)}function Hue({open:e,onOpenChange:t,budgetItemId:n,itemName:r,budgetedAmount:s,defaultMonth:i,experienceId:o,isCogs:l=!0,fx:c=null}){const u=at(),{toast:d}=mt(),[h,m]=y.useState(""),[f,x]=y.useState(""),g=y.useRef(null),[p,v]=y.useState(!1),[b,w]=y.useState("Estimate"),[N,j]=y.useState(""),[_,S]=y.useState(null),{data:P=[],isLoading:k}=Ee({queryKey:["budget-item-payments",n],queryFn:async()=>{const{data:V,error:U}=await F.from("experience_budget_item_payments").select("*").eq("budget_item_id",n).order("due_month");if(U)throw U;return V},enabled:e}),{data:C}=Ee({queryKey:["budget-item-detail",n],queryFn:async()=>{const{data:V,error:U}=await F.from("experience_budget_items").select("id, estimate_status, cost_source, source_link, val
802id_until, notes, supplier_id, quote_id, confirmed_date, confirmation_ref, status_override, status_override_reason, estimate_reason, expects_quote, name, copied_from_experience_id, schedule_edited, spent_to_date, spent_foreign, cost_type, amount").eq("id",n).maybeSingle();if(U)throw U;return V},enabled:e}),{data:T=[]}=Ee({queryKey:["experience-quotes-for-lines",o],enabled:e&&!!o,queryFn:async()=>{const{data:V,error:U}=await F.from("experience_quotes").select("id, supplier_id, received_date, valid_until, amount_per_person, amount_per_group, deposit_pct, deposit_amount, deposit_due_date, deposit_terms, status, suppliers(name)").eq("experience_id",o).order("received_date",{ascending:!1,nullsFirst:!1});if(U)throw U;return V}}),{data:O}=Ee({queryKey:["exp-name",C==null?void 0:C.copied_from_experience_id],enabled:e&&!!(C!=null&&C.copied_from_experience_id),queryFn:async()=>{const{data:V}=await F.from("experiences").select("name, public_name").eq("id",C.copied_from_experience_id).maybeSingle();return(V==null?void 0:V.public_name)||(V==null?void 0:V.name)||"a prior trip"}});Ee({queryKey:["suppliers-options"],enabled:e,queryFn:async()=>{const{data:V,error:U}=await F.from("suppliers").select("id, name, type").order("name");return U?[]:V||[]}});const L=V=>{var U;return`${((U=V.suppliers)==null?void 0:U.name)||"No supplier"} â ${V.received_date||"not received"}${V.status?` · ${V.status}`:""}`},E=!!(C!=null&&C.quote_id),R=T.find(V=>V.id===(C==null?void 0:C.quote_id)),q=R?`Quote: ${L(R)}`:C!=null&&C.copied_from_experience_id?`Copied from ${O||"a prior trip"}`:C!=null&&C.cost_source&&C.cost_source!=="quote"?`${C.cost_source} (entered before sources were automatic)`:"Estimate",I=["Estimate","Quoted"].includes((C==null?void 0:C.estimate_status)||"Estimate"),{data:$=[]}=Mp(),M=Object.fromEntries($.map(V=>[V.name,!!V.expects_quote])),B=Me({mutationFn:async V=>{const{error:U}=await F.from("experience_budget_items").update(V).eq("id",n);if(U)throw U},onSuccess:()=>{u.invalidateQueries({queryKey:["budget-item-detail",n]}),u.invalidateQueries({queryKey:["budget-items"]})},onError:V=>d({title:"Could not save",description:V.message,variant:"destructive"})}),W=()=>{C!=null&&C.schedule_edited||F.from("experience_budget_items").update({schedule_edited:!0}).eq("id",n).then(()=>u.invalidateQueries({queryKey:["budget-item-detail",n]}))},A=V=>{C!=null&&C.quote_id&&F.from("budget_item_quote_options").upsert({budget_item_id:n,quote_id:C.quote_id},{onConflict:"budget_item_id,quote_id",ignoreDuplicates:!0}).then(()=>{}),B.mutate(V?{quote_id:V,stale_pending_requote:!1}:{quote_id:null});const U=T.find(z=>z.id===V);S(U&&!(C!=null&&C.schedule_edited)?Kue(U,s,i):null)},[K,G]=y.useState(null),H=async V=>{var Z;if(G(null),V&&!E&&o){const ve=F,{data:ee}=await ve.from("experience_quotes").select("id, status, valid_until, amount_per_person, amount_per_group, currency, suppliers(name)").eq("experience_id",o).eq("supplier_id",V).neq("status","Declined"),de=(ee||[]).filter(je=>je.amount_per_person!=null||je.amount_per_group!=null);if(de.length){const{data:je}=await ve.from("experience_budget_items").select("quote_id").in("quote_id",de.map(Pe=>Pe.id)),Q=new Set((je||[]).map(Pe=>Pe.quote_id)),oe=de.find(Pe=>!Q.has(Pe.id));if(oe){B.mutate({supplier_id:V}),G({id:oe.id,supplier:((Z=oe.suppliers)==null?void 0:Z.name)||"This supplier",amount:Number(oe.amount_per_person??oe.amount_per_group),perPerson:oe.amount_per_person!=null,currency:oe.currency||"USD"});return}}}if(!V||E||!o||!l||!(s>0))return B.mutate({supplier_id:V});const{data:U,error:z}=await F.from("experience_quotes").insert({experience_id:o,supplier_id:V,status:"Received",received_date:new Date().toLocaleDateString("en-CA"),currency:(C==null?void 0:C.currency)||"USD",...(C==null?void 0:C.cost_type)==="per_person"&&Number(C==null?void 0:C.amount)>0?{amount_per_person:Number(C.amount)}:{amount_per_group:Math.round(s*100)/100}}).select("id").single();if(z)return d({title:"Could not record quote",description:z.message,variant:"destructive"}),B.mutate({supplier_id:V});await F.from("budget_item_quote_options").insert({budget_item_id:n,quote_id:U.id}),B.mutate({supplier_id:V,quote_id:U.id,stale_pending_requote:!1}
802),u.invalidateQueries({queryKey:["experience-quotes-for-lines",o]}),u.invalidateQueries({queryKey:["experience-quotes",o]}),u.invalidateQueries({queryKey:["experience-quotes"]})},fe=()=>{K&&(F.from("budget_item_quote_options").upsert({budget_item_id:n,quote_id:K.id},{onConflict:"budget_item_id,quote_id",ignoreDuplicates:!0}).then(()=>{}),A(K.id),G(null),u.invalidateQueries({queryKey:["experience-quotes",o]}),u.invalidateQueries({queryKey:["experience-quotes"]}))},te=async V=>{if(!R)return;const{error:U}=await F.from("experience_quotes").update(V).eq("id",R.id);if(U)return d({title:"Could not save quote",description:U.message,variant:"destructive"});u.invalidateQueries({queryKey:["experience-quotes-for-lines",o]}),u.invalidateQueries({queryKey:["experience-quotes",o]}),u.invalidateQueries({queryKey:["budget-item-detail",n]}),u.invalidateQueries({queryKey:["budget-items"]})},J=async()=>{if(!_)return;await F.from("experience_budget_item_payments").delete().eq("budget_item_id",n);const{error:V}=await F.from("experience_budget_item_payments").insert(_.map(U=>({budget_item_id:n,due_month:U.month,amount:Math.round(U.amount)})));if(V)return d({title:"Could not save schedule",description:V.message,variant:"destructive"});S(null),u.invalidateQueries({queryKey:["budget-item-payments",n]})},re=P.reduce((V,U)=>V+Number(U.amount||0),0),pe=Math.max(0,s-re),ye=V=>V>0?V.toLocaleString(void 0,{maximumFractionDigits:2}):"";y.useEffect(()=>{if(e){m(Wue(i||""));const V=P.length>0?pe:s,U=V>.01?ye(V):"",z=parseFloat(f.replace(/[^0-9.-]/g,""))||0;(!f||z===g.current)&&(x(U),g.current=parseFloat(U.replace(/[^0-9.-]/g,""))||null)}},[e,i,s,P,pe]);const X=Me({mutationFn:async()=>{const V=vA(h),U=parseFloat(f.replace(/[^0-9.\-]/g,""))||0;if(!V)throw new Error("Pick a month");const{error:z}=await F.from("experience_budget_item_payments").insert({budget_item_id:n,due_month:V,amount:U});if(z)throw z},onSuccess:()=>{W(),u.invalidateQueries({queryKey:["budget-item-payments",n]}),m(""),x("")},onError:V=>d({title:"Could not add",description:V.message,variant:"destructive"})}),he=Me({mutationFn:async({id:V,updates:U})=>{const{error:z}=await F.from("experience_budget_item_payments").update(U).eq("id",V);if(z)throw z},onSuccess:()=>{W(),u.invalidateQueries({queryKey:["budget-item-payments",n]}),u.invalidateQueries({queryKey:["budget-item-detail",n]}),u.invalidateQueries({queryKey:["budget-items"]})}}),D=Me({mutationFn:async V=>{const{error:U}=await F.from("experience_budget_item_payments").delete().eq("id",V);if(U)throw U},onSuccess:()=>{W(),u.invalidateQueries({queryKey:["budget-item-payments",n]}),u.invalidateQueries({queryKey:["budget-item-detail",n]}),u.invalidateQueries({queryKey:["budget-items"]})}}),le=re-s;return P.length>0&&Math.abs(le)>.01,a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"max-w-2xl sm:max-w-3xl max-h-[90vh] flex flex-col",children:[a.jsxs(Ot,{children:[a.jsxs(At,{children:["Expense Detail â ",r]}),a.jsx(wr,{children:"Split this cost across months. If empty, the full amount lands in the experience start month."})]}),a.jsxs("div",{className:"space-y-3 flex flex-col min-h-0 flex-1 overflow-y-auto pr-1",children:[a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Budgeted: ",a.jsxs("span",{className:"font-semibold text-foreground",children:["$",s.toLocaleString(void 0,{maximumFractionDigits:2})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 border-b border-border pb-3",children:[a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Status (worked out automatically)"}),a.jsxs("div",{className:"flex items-center gap-2 text-xs flex-wrap",children:[a.jsx("span",{className:"rounded bg-muted px-2 py-0.5 font-medium",children:(C==null?void 0:C.estimate_status)||"Estimate"}),C!=null&&C.status_override?a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"text-muted-foreground",children:["Overridden: ",C.status_override_reason]}),a.jsx(Y,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>B.mutate({status_override:null,status_override_reason:null}),children:"Remove override"})]}):p?a.jsxs(a.Fragment,{children:[a.jsxs(lt,{value:b,onValueChange:w,children:[a.jsx(it,{className:"h-7 w-28 text-xs",children:a.jsx(ct,{})}),a.jsx(ot,{children:["Estimate","Quoted","Contracted","Actual"].map(V=>a.jsx(Oe,{value:V,className:"text-xs",children:V},V))})]}),a.jsx(ce,{className:"h-7 text-xs flex-1 min-w-[10rem]",placeholder:"Reason (required)",value:N,onChange:V=>j(V.target.value)}),a.jsx(Y,{size:"sm",className:"h-7 text-xs",disabled:!N.trim(),onClick:()=>{B.mutate({status_override:b,status_override_reason:N.trim()}),v(!1),j("")},children:"Save"})]}):a.jsx(Y,{variant:"link",size:"sm",className:"h-auto p-0 text-xs",onClick:()=>v(!0),children:"Overrideâ¦"})]}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Estimate â Quoted (quote attached) â Contracted (Confirmed date or any payment marked paid) â Actual (closed with Spent)."})]}),(C==null?void 0:C.confirmed_date)&&(C==null?void 0:C.supplier_id)&&a.jsx(Uue,{supplierId:C.supplier_id}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Confirmed date"}),a.jsx(ce,{type:"date",className:"h-8 text-xs",value:(C==null?void 0:C.confirmed_date)||"",onChange:V=>B.mutate({confirmed_date:V.target.value||null})})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Confirmation reference"}),a.jsx(ce,{className:"h-8 text-xs",placeholder:"Booking no., reservation codeâ¦",defaultValue:(C==null?void 0:C.confirmation_ref)||"",onBlur:V=>{const U=V.target.value.trim()||null;U!==((C==null?void 0:C.confirmation_ref)||null)&&B.mutate({confirmation_ref:U})}},`ref-${C==null?void 0:C.id}-${(C==null?void 0:C.confirmation_ref)??""}`)]}),l&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Quote"}),a.jsxs(lt,{value:(C==null?void 0:C.quote_id)||"none",onValueChange:V=>A(V==="none"?null:V),children:[a.jsx(it,{className:"h-8 text-xs",children:a.jsx(ct,{placeholder:"None"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"none",className:"text-xs",children:"No quote"}),T.map(V=>a.jsx(Oe,{value:V.id,className:"text-xs",children:L(V)},V.id))]})]}),!T.length&&a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Pick a supplier below and a quote is recorded for this line automatically."})]}),o&&a.jsx(Bue,{budgetItemId:n,experienceId:o,chosenId:(C==null?void 0:C.quote_id)||null,onChoose:V=>A(V),currency:(C==null?void 0:C.currency)||"USD"}),a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Source"}),a.jsx("p",{className:"text-xs",children:q})]}),a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsxs(xe,{className:"text-xs",children:["Supplier ",E&&a.jsx("span",{className:"text-muted-foreground",children:"(from quote)"})]}),a.jsx(Eb,{experienceId:o,disabled:E,value:(C==null?void 0:C.supplier_id)||null,onChange:H}),K&&a.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 rounded border border-border bg-muted/50 px-2 py-1 text-xs",children:[a.jsxs("span",{children:[K.supplier," has a quote for ",K.currency," ",K.amount.toLocaleStr
802ing(void 0,{maximumFractionDigits:2}),K.perPerson?" per person":""," on this trip. Use it?"]}),a.jsx("button",{type:"button",className:"font-medium text-primary hover:underline",onClick:fe,children:"Use quote"}),a.jsx("button",{type:"button",className:"text-muted-foreground hover:underline",onClick:()=>G(null),children:"No thanks"})]}),E&&R&&a.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[a.jsx(xe,{className:"text-xs shrink-0",children:"Quoted"}),a.jsx(ce,{type:"date",className:"h-7 text-xs w-40",value:R.received_date||"",onChange:V=>V.target.value&&te({received_date:V.target.value})})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsxs(xe,{className:"text-xs",children:["Source link ",E&&a.jsx("span",{className:"text-muted-foreground",children:"(from quote)"})]}),a.jsx(ce,{disabled:E,className:"h-8 text-xs",placeholder:"https://â¦",defaultValue:(C==null?void 0:C.source_link)||"",onBlur:V=>{const U=V.target.value.trim()||null;U!==((C==null?void 0:C.source_link)||null)&&B.mutate({source_link:U})}},`link-${C==null?void 0:C.id}-${(C==null?void 0:C.source_link)??""}`)]}),I&&a.jsxs("div",{className:"space-y-1",children:[a.jsxs(xe,{className:"text-xs flex items-center gap-1",children:["Valid until ",E&&a.jsx("span",{className:"text-muted-foreground",children:"(on the quote)"}),xy(C==null?void 0:C.valid_until)&&a.jsx(za,{className:"h-3.5 w-3.5 text-amber-500","aria-label":"Expired"})]}),a.jsx(ce,{type:"date",className:"h-8 text-xs",value:(E?R==null?void 0:R.valid_until:C==null?void 0:C.valid_until)||"",onChange:V=>E?te({valid_until:V.target.value||null}):B.mutate({valid_until:V.target.value||null})}),xy(E?R==null?void 0:R.valid_until:C==null?void 0:C.valid_until)&&a.jsx("p",{className:"text-[10px] text-amber-600",children:"This line holds an expired quote."})]}),a.jsxs("div",{className:"col-span-2 flex items-center gap-2 text-xs",children:[a.jsx("input",{type:"checkbox",id:`eq-${C==null?void 0:C.id}`,checked:Fq(C||{},M),onChange:V=>{const U=w1(C==null?void 0:C.name,M);B.mutate({expects_quote:V.target.checked===U?null:V.target.checked})}}),a.jsx("label",{htmlFor:`eq-${C==null?void 0:C.id}`,children:"Expects a quote"}),a.jsxs("span",{className:"text-muted-foreground",children:["(",(C==null?void 0:C.expects_quote)==null?"category default":`overridden â category default is ${w1(C==null?void 0:C.name,M)?"yes":"no"}`,"; when off, the line runs Estimate â Actual and isn't counted in sourcing)"]})]}),!E&&a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Estimate reason (counts this line as sourced without a quote)"}),a.jsx(ce,{className:"h-8 text-xs",placeholder:"e.g. Same as last year's lodging cost",defaultValue:(C==null?void 0:C.estimate_reason)||"",onBlur:V=>{const U=V.target.value.trim()||null;U!==((C==null?void 0:C.estimate_reason)||null)&&B.mutate({estimate_reason:U})}},`er-${C==null?void 0:C.id}-${(C==null?void 0:C.estimate_reason)??""}`)]})]}),a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Notes"}),a.jsx(qt,{className:"text-xs min-h-[60px]",defaultValue:(C==null?void 0:C.notes)||"",onBlur:V=>{const U=V.target.value.trim()||null;U!==((C==null?void 0:C.notes)||null)&&B.mutate({notes:U})}},`notes-${C==null?void 0:C.id}-${(C==null?void 0:C.notes)??""}`)]})]}),c&&a.jsxs("div",{className:"border-b border-border pb-3 space-y-1.5 text-xs",children:[a.jsxs(xe,{className:"text-xs",children:["Foreign amount paid (",c.currency,") â the supplier's invoice"]}),a.jsx(ce,{type:"text",inputMode:"decimal",className:"h-8 text-xs w-40",defaultValue:(C==null?void 0:C.spent_foreign)??"",onBlur:V=>{const U=V.target.value.replace(/[^0-9.\-]/g,""),z=U===""?null:Number(U);z!==((C==null?void 0:C.spent_foreign)??null)&&B.mutate({spent_foreign:z})}},`sf-${C==null?void 0:C.id}-${(C==null?void 0:C.spent_foreign)??""}`),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Spent on the budget is always the actual US dollars that left the bank, fees included â never converted."}),(()=>{const V=c.rate?s/c.rate:0,U=C==null?void 0:C.spent_to_date,z=C==null?void 0:C.spent_foreign;if(U==null||z==null||!z)return a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Enter Spent (USD) and the foreign amount paid to split the variance."});
802const Z=U/z,ve=U-z*c.rate,ee=(z-V)*c.rate,de=je=>`${je>=0?"+":"â"}$${Math.abs(Math.round(je)).toLocaleString()}`;return a.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-0.5 rounded bg-muted/50 px-2 py-1.5",children:[a.jsx("span",{children:"Budget rate / rate paid"}),a.jsxs("span",{className:"tabular-nums",children:[c.rate," / ",Z.toFixed(4)]}),a.jsxs("span",{title:"Foreign amount paid at the rate actually paid vs at the budget rate",children:["Rate effect (",c.currency," rate)"]}),a.jsx("span",{className:"tabular-nums",children:de(ve)}),a.jsx("span",{title:"Difference in the foreign amount itself, at the budget rate",children:"Cost effect (supplier)"}),a.jsx("span",{className:"tabular-nums",children:de(ee)}),a.jsx("span",{className:"font-medium",children:"Total variance"}),a.jsx("span",{className:"tabular-nums font-medium",children:de(ve+ee)})]})})()]}),_&&a.jsxs("div",{className:"rounded border border-primary/40 bg-primary/5 p-2 text-xs space-y-1",children:[a.jsx("div",{className:"font-medium",children:"Proposed schedule from the quote's deposit terms"}),_.map((V,U)=>a.jsxs("div",{children:[V.label,": $",Math.round(V.amount).toLocaleString()," in ",V.month.slice(0,7)]},U)),a.jsxs("div",{className:"flex gap-2 pt-1",children:[a.jsx(Y,{size:"sm",className:"h-7 text-xs",onClick:J,children:"Accept"}),a.jsx(Y,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>S(null),children:"Dismiss"})]})]}),k?a.jsx("p",{className:"text-xs text-muted-foreground",children:"Loadingâ¦"}):a.jsxs("div",{className:"space-y-1 flex flex-col min-h-0 shrink-0",children:[P.length>0&&a.jsxs("div",{className:"text-[10px] text-muted-foreground px-1",children:[P.length," ",P.length===1?"entry":"entries"]}),P.length===0&&a.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No schedule entries yet."}),P.length>0&&a.jsxs("div",{className:"grid grid-cols-[9rem_5rem_4rem_2.5rem_8rem_1.5rem] gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground px-1 sticky top-0 bg-background pb-1 z-10",children:[a.jsx("span",{children:"Month"}),a.jsx("span",{children:"Amount"}),a.jsx("span",{title:"Scaled proportionally to current budgeted total; remainder from rounding is applied to the last payment",children:"Effective"}),a.jsx("span",{title:"Mark when this payment has been made",children:"Paid"}),a.jsx("span",{title:"Date the payment was made (set automatically when marked paid; overrides scheduled month)",children:"Actual"}),a.jsx("span",{})]}),a.jsx("div",{className:"space-y-1 overflow-y-auto max-h-[45vh] pr-1 shrink-0",children:(()=>{const V=re>0?s/re:1,U=P.map(z=>Math.round(Number(z.amount||0)*V));if(P.length>0&&re>0){const z=U.slice(0,-1).reduce((Z,ve)=>Z+ve,0);U[U.length-1]=Math.round(s)-z}return P.map((z,Z)=>{const ve=U[Z],ee=new Date().toISOString().slice(0,10),de=!z.paid&&!z.actual_date&&z.due_month<ee.slice(0,7)+"-01";return a.jsxs("div",{className:"grid grid-cols-[9rem_5rem_4rem_2.5rem_8rem_1.5rem] gap-1.5 items-center",children:[a.jsx(ce,{type:"month",className:`h-8 text-xs px-1.5 w-full min-w-[8rem] ${de?"border-amber-500":""}`,value:_8(z.due_month),onChange:je=>{const Q=vA(je.target.value);Q&&he.mutate({id:z.id,updates:{due_month:Q}})},title:de?"Past due â will roll into the current month in the forecast until marked paid or given an actual date":void 0}),a.jsx(ce,{type:"text",inputMode:"decimal",className:"h-8 text-xs px-1.5",defaultValue:String(z.amount??""),onBlur:je=>{const Q=parseFloat(je.target.value.replace(/[^0-9.\-]/g,""))||0;Q!==Number(z.amount)&&he.mutate({id:z.id,updates:{amount:Q}})}}),a.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:["$",ve.toLocaleString(void 0,{maximumFractionDigits:0})]}),a.jsx("div",{className:"flex justify-center",children:a.jsx(gt,{checked:z.paid,onCheckedChange:je=>{const Q=!!je,oe={paid:Q};Q&&!z.actual_date&&(oe.actual_date=ee),he.mutate({id:z.id,updates:oe})}})}),a.jsx("span",{className:"text-xs text-muted-foreground tabular-nums px-1.5",title:z.actual_date?"Date the payment was made (set automatically when marked paid)":"Set automatically when marked paid",children:z.actual_date?(()=>{const[je,Q,oe]=z.actual_date.split("-").map(Number);return new Date(je,Q-1,oe).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})})():"â"}),a.jsx(Y,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive",onClick:()=>D.mutate(z.id),children:a.jsx(Ht,{className:"h-3.5 w-3.5"})})]},z.id)})})()})]}),a.jsxs("div",{className:"border-t border-border pt-2 space-y-2",children:[a.jsx(xe,{className:"text-xs",children:"Add entry"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ce,{type:"month",className:"h-8 text-xs min-w-[8rem]",value:h,onChange:V=>m(V.target.value)}),a.jsx(ce,{type:"text",inputMode:"decimal",placeholder:"Amount",className:"h-8 text-xs w-28",value:f,onChange:V=>x(V.target.value)}),a.jsx(Y,{size:"icon",variant:"outline",className:"h-8 w-8",onClick:()=>X.mutate(),disabled:!h||X.isPending,children:a.jsx(zt,{className:"h-3.5 w-3.5"})})]})]}),a.jsxs("div",{className:"flex items-center justify-between text-xs pt-2 border-t border-border",children:[a.jsx("span",{className:"text-muted-foreground",children:"Scheduled total (entered)"}),a.jsxs("span",{className:"font-semibold",children:["$",re.toLocaleStr
802ing(void 0,{maximumFractionDigits:2})]})]}),P.length>0&&a.jsxs("div",{className:"flex items-center justify-between text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:"Effective total (scaled to budget)"}),a.jsxs("span",{className:"font-semibold",children:["$",s.toLocaleString(void 0,{maximumFractionDigits:2})]})]}),P.length>0&&a.jsxs("div",{className:"flex items-start gap-2 text-xs text-muted-foreground bg-muted/50 rounded px-2 py-1.5",children:[a.jsx(za,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),a.jsx("span",{children:`Entries are stored as proportions. If the budgeted total changes (e.g., pax count changes), the forecast will automatically scale each month's amount â shown in the "Effective" column.`})]})]}),a.jsx(br,{children:a.jsx(Y,{variant:"outline",onClick:()=>t(!1),children:"Done"})})]})})}const Ea=e=>`${e<0?"-":""}$${Math.abs(e).toLocaleString(void 0,{maximumFractionDigits:0})}`;function Gue({open:e,onOpenChange:t,experienceId:n,currentPrice:r,currentPax:s,maxSize:i,budgetItems:o,exchangeRate:l,fxCurrency:c="EUR",budgetedAddonRevenue:u,customPrice:d={total:0,count:0},customPricedTeamIds:h,compEntries:m,revenueBasis:f="projected",lockedReason:x}){const{toast:g}=mt(),p=at(),[v,b]=y.useState("price"),[w,N]=y.useState("0"),[j,_]=y.useState("25");y.useEffect(()=>{e&&(b("price"),N("0"),_("25"))},[e]);const S=parseFloat(w)||0,P=y.useMemo(()=>(q,I)=>{const $=m.map(X=>({id:X.id,agreement:{...X.agreement,trip_price_snapshot:q}})),M=my($,I,q),B=$.length,W=$.reduce((X,he)=>{var D;return(D=M.get(he.id))!=null&&D.tripFullyComped||h!=null&&h.has(he.id)?X:X+q},0),K=Math.max(0,I-d.count)*q+d.total+W+u,G=new Map;let H=0,fe=0;m.forEach(X=>{const he=M.get(X.id);if(!he)return;const D=he.tripFullyComped?he.recruitingCashPayout:he.totalCredit;G.set(`generator_comp|${X.name}`,D),G.set(`facilitator_comp|${X.name}`,he.hostGuideCredit),H+=D,fe+=he.hostGuideCredit});const te=X=>X.includes_generators?I+B:I,J=o.find(X=>X.name==="Outfitter"&&X.category==="direct");let re=0;J&&(re=J.cost_type==="flat"?J.amount:J.amount*te(J),re*=J.currency==="USD"?1:J.currency===c?l:0);const pe=X=>{if(X.source==="generator_comp"||X.source==="facilitator_comp")return G.get(`${X.source}|${X.description??""}`)??X.amount;let he=0;const D=te(X);switch(X.cost_type){case"per_person":he=X.amount*D;break;case"flat":he=X.amount;break;case"pct_price":he=K*(X.amount/100);break;case"pct_outfitter":he=re*(X.amount/100);break;case"pct_per_person":he=q*(X.amount/100);break;case"pct_revenue":he=K*(X.amount/100);break}return he*=X.currency==="USD"?1:X.currency===c?l:0,he},ye=o.reduce((X,he)=>X+pe(he),0);return{revenue:K,cost:ye,surplus:K-ye,recruitingTotal:H,facilitatorTotal:fe,compLineAmounts:G}},[o,m,l,c,u,d.total,d.count,h]),k=y.useMemo(()=>P(r,s),[P,r,s]),C=y.useMemo(()=>{const q=v==="price"?A=>P(A,s).surplus-S:A=>P(r,A).surplus-S;let I=0,$=v==="price"?Math.max(r*10,1e5):Math.max(i*4,200);const M=q(I),B=q($);if(!Number.isFinite(M)||!Number.isFinite(B)||M>0&&B>0||M<0&&B<0)return null;for(let A=0;A<80;A++){const K=(I+$)/2;q(I)*q(K)<=0?$=K:I=K}const W=(I+$)/2;return v==="price"?W:Math.ceil(W)},[P,v,S,r,s,i]),T=parseInt(j,10),O=C==null?null:v==="price"?Math.ceil(C/T)*T:C,L=y.useMemo(()=>O==null?null:v==="price"?P(O,s):P(r,O),[O,P,v,r,s]),E=Me({mutationFn:async()=>{if(!(O==null||L==null)){if(v==="pax"){const{error:q}=await F.from("experience_budget_settings").upsert({experience_id:n,override_pax_count:O});if(q)throw q}else{const{error:q}=await F.from("experiences").update({price:O}).eq("id",n);if(q)throw q;if(m.length>0){const{error:I}=await F.from("generator_experience_comp").update({trip_price_snapshot:O}).eq("experience_id",n);if(I)throw I}}for(const q of o){if(q.source!=="generator_comp"&&q.source!=="facilitator_comp")continue;const I=L.compLineAmounts.get(`${q.source}|${q.description??""}`);if(I==null)continue;const{error:$}=await F.from("experience_budget_items").update({amount:I}).eq("id",q.id);if($)throw $}}},onSuccess:()=>{["budget-items","budget-settings","budget-comp-agreements","budget-generator-count","budget-included-addons","budget-experience-meta","budget-accepted-contacts","generator-comp-list","experiences","experience-contacts"].forEach(q=>p.invalidateQueries({queryKey:[q]})),g({title:v==="price"?"Price updated":"Group size updated",description:"Budget recalculated."}),t(!1)},onError:q=>g({title:"Could not apply",description:q.message,variant:"destructive"})}),R=O==null?0:v==="price"?O-r:O-s;return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"max-w-lg",children:[a.jsxs(Ot,{children:[a.jsx(At,{className:"font-display",children:"Goal seek"}),a.jsx(wr,{children:"Solve for the value that brings the projected bottom line to your target. Generator and facilitator comp scale with the price."})]}),a.jsxs("div",{className:"space-y-4",children:[f==="confirmed"&&a.jsxs("div",{className:"flex gap-2 rounded border border-border bg-muted/40 p-2 text-[11px] text-muted-foreground",children:[a.jsx(za,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}
802),a.jsxs("span",{children:["Your budget card is showing the ",a.jsx("strong",{children:"Confirmed"})," basis, but goal seek always plans against ",a.jsx("strong",{children:"projected"}),' revenue (full group at the standard price). The "Now" surplus below will differ from the confirmed figure on the card.']})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Solve for"}),a.jsxs(lt,{value:v,onValueChange:q=>b(q),children:[a.jsx(it,{className:"h-8 text-xs",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"price",children:"Standard per-pax price"}),a.jsx(Oe,{value:"pax",children:"Group size"})]})]})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Target surplus ($)"}),a.jsx(ce,{type:"text",inputMode:"decimal",className:"h-8 text-xs",value:w,onChange:q=>N(q.target.value)})]})]}),v==="price"&&a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Round price up to nearest"}),a.jsxs(lt,{value:j,onValueChange:q=>_(q),children:[a.jsx(it,{className:"h-8 text-xs w-32",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"1",children:"$1"}),a.jsx(Oe,{value:"25",children:"$25"}),a.jsx(Oe,{value:"50",children:"$50"}),a.jsx(Oe,{value:"100",children:"$100"})]})]})]}),O==null?a.jsx("p",{className:"text-xs text-muted-foreground rounded border border-border p-3",children:"No solution in a sensible range. The bottom line may not respond to this lever â check that per-person costs and comp percentages leave room to move."}):a.jsx("div",{className:"rounded border border-border overflow-hidden text-xs",children:a.jsxs("table",{className:"w-full",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"bg-muted/50 text-[10px] uppercase tracking-wider text-muted-foreground",children:[a.jsx("th",{className:"text-left px-2 py-1 font-medium"}),a.jsx("th",{className:"text-right px-2 py-1 font-medium",children:"Now"}),a.jsx("th",{className:"text-right px-2 py-1 font-medium",children:"After"})]})}),a.jsxs("tbody",{className:"[&_td]:px-2 [&_td]:py-1 [&_tr]:border-t [&_tr]:border-border",children:[a.jsxs("tr",{children:[a.jsx("td",{className:"text-muted-foreground",children:v==="price"?"Per-pax price":"Group size"}),a.jsx("td",{className:"text-right tabular-nums",children:v==="price"?Ea(r):s}),a.jsxs("td",{className:"text-right tabular-nums font-semibold",children:[v==="price"?Ea(O):O,a.jsxs("span",{className:"ml-1 text-[10px] text-muted-foreground",children:["(",R>=0?"+":"",v==="price"?Ea(R):R,")"]})]})]}),a.jsxs("tr",{children:[a.jsx("td",{className:"text-muted-foreground",children:"Projected revenue"}),a.jsx("td",{className:"text-right tabular-nums",children:Ea(k.revenue)}),a.jsx("td",{className:"text-right tabular-nums",children:Ea(L.revenue)})]}),a.jsxs("tr",{children:[a.jsx("td",{className:"text-muted-foreground",children:"Generator comp"}),a.jsx("td",{className:"text-right tabular-nums",children:Ea(k.recruitingTotal)}),a.jsx("td",{className:"text-right tabular-nums",children:Ea(L.recruitingTotal)})]}),a.jsxs("tr",{children:[a.jsx("td",{className:"text-muted-foreground",children:"Guide Facilitation Comp"}),a.jsx("td",{className:"text-right tabular-nums",children:Ea(k.facilitatorTotal)}),a.jsx("td",{className:"text-right tabular-nums",children:Ea(L.facilitatorTotal)})]}),a.jsxs("tr",{children:[a.jsx("td",{className:"text-muted-foreground",children:"Total cost"}),a.jsx("td",{className:"text-right tabular-nums",children:Ea(k.cost)}),a.jsx("td",{className:"text-right tabular-nums",children:Ea(L.cost)})]}),a.jsxs("tr",{className:"bg-muted/30",children:[a.jsx("td",{className:"font-medium",children:"Surplus / (deficit)"}),a.jsx("td",{className:Se("text-right tabular-nums",k.surplus<0&&"text-red-600 dark:text-red-400"),children:Ea(k.surplus)}),a.jsx("td",{className:Se("text-right tabular-nums font-semibold",L.surplus<0&&"text-red-600 dark:text-red-400"),children:Ea(L.surplus)})]})]})]})}),v==="price"&&x&&a.jsxs("div",{className:"flex gap-2 rounded border border-amber-300 bg-amber-50 dark:bg-amber-950/40 dark:border-amber-800 p-2 text-[11px] text-amber-900 dark:text-amber-200",children:[a.jsx(za,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),a.jsx("span",{children:x})]}),v==="price"&&!x&&a.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Applying updates the experience's standard price and every generator's comp trip price on this experience, then refreshes the comp cost lines."})]}),a.jsxs(br,{children:[a.jsx(Y,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Close"}),a.jsx(Y,{size:"sm",disabled:O==null||E.isPending||v==="price"&&!!x,onClick:()=>E.mutate(),children:E.isPending?"Applyingâ¦":"Apply"})]})]})})}const Vue={add:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-200",replace:"bg-sky-100 text-sky-800 dark:bg-sky-900/40 dark:text-sky-200",skip:"bg-muted text-muted-foreground",error:"bg-destructive/15 text-destructive"},Iw=e=>
802`$${e.toLocaleString(void 0,{maximumFractionDigits:2})}`,Yue=e=>(e==null?void 0:e.startsWith("pct_"))??!1;function Que({experienceId:e,experienceName:t}){const n=at(),{toast:r}=mt(),{data:s=[]}=Mp(),i=s.length?s.map(b=>b.name):Pd,o=y.useRef(null),[l,c]=y.useState(null),[u,d]=y.useState(null),[h,m]=y.useState(!1),f=async()=>{let b;try{b=await Rk([e])}catch(_){return r({title:"Export failed",description:_.message,variant:"destructive"})}const{data:w}=await F.from("experiences").select("name, type").eq("id",e).maybeSingle();if(!C6(w==null?void 0:w.type,(w==null?void 0:w.name)||""))return r({title:"Not exported â no QuickBooks class",description:`"${(w==null?void 0:w.name)||"This trip"}" has Format "${(w==null?void 0:w.type)||"none"}", which has no parent class. Change its Format to Trip, Peer Group or Stakeholder Summit, then export again.`,variant:"destructive"});const N=b.map(_=>O6(_,Ar(_),mi(_))),j=(t||(w==null?void 0:w.name)||"trip").replace(/[^a-z0-9]+/gi,"-").toLowerCase();$k(`budget-lines-${j}.csv`,Dk([[...yx],...N])),await F.rpc("mark_classes_exported",{_ids:[e]})},x=async b=>{const w=await b.text(),N=E6(w);if(N.length<2){d(["The file has no data rows."]);return}const j=N[0].map(B=>{const W=B.trim().toLowerCase();return $ce[W]||W}),S=yx.filter(B=>
802B!=="qbo_class"&&B!=="spent").filter(B=>!j.includes(B));if(j.includes("status")){d(["File rejected: it has a status column. Status is worked out automatically now â remove the column and import again."]);return}if(S.length){d([`Header row is missing: ${S.join(", ")}. Expected columns: ${yx.join(", ")}`]);return}const P=B=>j.indexOf(B),k=j.indexOf("qbo_class");if(k>=0){const{data:B}=await F.from("experiences").select("name").eq("id",e).maybeSingle(),W=((B==null?void 0:B.name)||"").trim().toLowerCase(),A=[];if(N.slice(1).forEach((K,G)=>{const H=(K[k]||"").trim();H&&N1(H).toLowerCase()!==W&&A.push(`Row ${G+2}: "${H}" does not match this trip's QuickBooks Class "${B==null?void 0:B.name}"`)}),A.length){d(["File rejected â rows belong to a different QuickBooks Class.",...A]);return}}const[{data:C},{data:T}]=await Promise.all([F.from("suppliers").select("id, name"),F.from("experience_budget_items").select("*, suppliers(name)").eq("experience_id",e).eq("category","direct")]),O=s.length?s.filter(B=>B.active).map(B=>B.name):Pd,L=(T||[]).map(B=>Ar(B)),E=Array.from(new Set([...O,...L])),R=[];if(N.slice(1).forEach((B,W)=>{const A=(B[P("category")]||"").trim();hA(A,E)||R.push(`Row ${W+2}: "${A||"(blank)"}" is not an active category or one already on this budget`)}),R.length){d([`File rejected. line_item must be one of: ${E.map(k6).join(", ")}.`,...R]);return}const q=new Map((C||[]).map(B=>[B.name.trim().toLowerCase(),B])),I=new Map;(T||[]).forEach(B=>{var W;I.set(fA(Ar(B),((W=B.suppliers)==null?void 0:W.name)||"",mi(B)),B)});const $=new Map,M=N.slice(1).map((B,W)=>{const A=U=>(B[P(U)]||"").trim(),K=W+2,G=[],H=A("category"),fe=hA(H,i),te=A("description"),J=A("unit_amount").replace(/[$,\s]/g,""),re=Number(J),pe=Bce(A("basis")),ye=A("valid_until"),X=A("supplier");let he="add";(!J||!Number.isFinite(re))&&(G.push("Amount is missing or not a number"),he="error"),pe||(G.push(`Basis "${A("basis")}" is not valid (per_person, flat, pct_outfitter, pct_price, pct_per_person, pct_revenue)`),he="error"),ye&&!/^\d{4}-\d{2}-\d{2}$/.test(ye)&&(G.push("valid_until must be YYYY-MM-DD"),he="error"),!X&&!te&&(G.push("Needs a description or supplier_name to identify the line"),he="error");let D=null;if(X){const U=q.get(X.toLowerCase());U?D=U.id:G.push(`Supplier "${X}" not in directory â supplier link left blank`)}const le=fA(fe,X,te);$.has(le)?(G.push(`Same category + ${X?"supplier":"description"} as row ${$.get(le)}`),he="error"):$.set(le,K);const V=I.get(le);if(he!=="error"&&V){const U=V.estimate_status||"Estimate";Yue(V.cost_type)?(he="skip",G.push(`Existing line uses ${V.cost_type} â formula amount not overwritten`)):U==="Contracted"||U==="Actual"?(he="skip",G.push(`Existing line is ${U} â not overwritten`)):(he="replace",G.push(`Replaces existing ${U} line (was ${Iw(Number(V.amount))})`))}return{rowNum:K,csvCategory:H,category:fe,description:te,amount:Number.isFinite(re)?re:0,basis:pe||"flat",status:"Estimate",source:"",sourceLink:A("source_link"),validUntil:ye||null,supplierName:X,supplierId:D,notes:A("notes"),outcome:he,messages:G,existing:V?{id:V.id,amount:Number(V.amount),notes:V.notes,basis:V.cost_type}:void 0}});c(M)},g=async()=>{if(l){m(!0);try{const{data:b}=await F.from("experience_budget_items").select("sort_order").eq("experience_id",e);let w=Math.max(0,...(b||[]).map(_=>_.sort_order||0))+1,N=0,j=0;for(const _ of l){const S={name:_.category,description:_.description||null,amount:_.amount,cost_type:_.basis,source_link:_.sourceLink||null,valid_until:_.validUntil,supplier_id:_.supplierId};if(_.outcome==="add"){const{error:P}=await F.from("experience_budget_items").insert({...S,experience_id:e,category:"direct",currency:"USD",sort_order:w++,notes:_.notes||null});if(P)throw new Error(`Row ${_.rowNum}: ${P.message}`);N++}else if(_.outcome==="replace"&&_.existing){const P=`Previous amount: ${Iw(_.existing.amount)} (replaced by CSV import ${new Date().toISOString().slice(0,10)})`,k=[_.notes,P].filter(Boolean).join(` 803`),{error:C}=await F.from("experience_budget_items").update({...S,notes:k}).eq("id",_.existing.id);if(C)throw new Error(`Row ${_.rowNum}: ${C.message}`);j++}}n.invalidateQueries({queryKey:["budget-items",e]}
803),r({title:"Budget lines imported",description:`${N} added, ${j} replaced.`}),c(null)}catch(b){r({title:"Import stopped",description:b.message,variant:"destructive"})}finally{m(!1)}}},p=l==null?void 0:l.reduce((b,w)=>({...b,[w.outcome]:(b[w.outcome]||0)+1}),{}),v=((p==null?void 0:p.add)||0)+((p==null?void 0:p.replace)||0);return a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:o,type:"file",accept:".csv,text/csv",className:"hidden",onChange:b=>{var N;const w=(N=b.target.files)==null?void 0:N[0];b.target.value="",w&&x(w)}}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs gap-1",onClick:()=>{var b;return(b=o.current)==null?void 0:b.click()},children:[a.jsx(ao,{className:"h-3 w-3"})," Import budget lines from CSV"]}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs gap-1",onClick:f,children:[a.jsx(ja,{className:"h-3 w-3"})," Export budget lines to CSV"]}),a.jsx(Dt,{open:!!u,onOpenChange:b=>!b&&d(null),children:a.jsxs(Pt,{className:"sm:max-w-lg",children:[a.jsxs(Ot,{children:[a.jsx(At,{children:"Can't import this file"}),a.jsx(wr,{children:"Nothing was changed."})]}),a.jsx("ul",{className:"text-sm space-y-1 max-h-[50vh] overflow-y-auto",children:u==null?void 0:u.map((b,w)=>a.jsx("li",{className:w===0?"font-medium":"text-destructive",children:b},w))}),a.jsx(br,{children:a.jsx(Y,{onClick:()=>d(null),children:"OK"})})]})}),a.jsx(Dt,{open:!!l,onOpenChange:b=>!b&&!h&&c(null),children:a.jsxs(Pt,{className:"sm:max-w-5xl max-h-[90vh] overflow-y-auto",children:[a.jsxs(Ot,{children:[a.jsx(At,{children:"Review budget import"}),a.jsxs(wr,{children:[(p==null?void 0:p.add)||0," to add · ",(p==null?void 0:p.replace)||0," to replace · ",(p==null?void 0:p.skip)||0," skipped · ",(p==null?void 0:p.error)||0," with errors. Nothing is saved until you confirm; error and skipped rows are ignored."]})]}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-xs",children:[a.jsx("thead",{className:"text-muted-foreground",children:a.jsxs("tr",{className:"border-b border-border text-left",children:[a.jsx("th",{className:"py-1 pr-2",children:"Row"}),a.jsx("th",{className:"py-1 pr-2",children:"Outcome"}),a.jsx("th",{className:"py-1 pr-2",children:"Category"}),a.jsx("th",{className:"py-1 pr-2",children:"Description"}),a.jsx("th",{className:"py-1 pr-2",children:"Supplier"}),a.jsx("th",{className:"py-1 pr-2 text-right",children:"Amount"}),a.jsx("th",{className:"py-1 pr-2",children:"Basis"}),a.jsx("th",{className:"py-1",children:"Notes"})]})}),a.jsx("tbody",{children:l==null?void 0:l.map(b=>a.jsxs("tr",{className:"border-b border-border/50 align-top",children:[a.jsx("td",{className:"py-1 pr-2",children:b.rowNum}),a.jsx("td",{className:"py-1 pr-2",children:a.jsx(Ge,{className:`${Vue[b.outcome]} border-0 capitalize`,children:b.outcome})}),a.jsx("td",{className:"py-1 pr-2",children:b.csvCategory}),a.jsx("td",{className:"py-1 pr-2",children:b.description||"â"}),a.jsx("td",{className:"py-1 pr-2",children:b.supplierName||"â"}),a.jsx("td",{className:"py-1 pr-2 text-right",children:Iw(b.amount)}),a.jsx("td",{className:"py-1 pr-2",children:b.basis}),a.jsx("td",{className:"py-1 text-muted-foreground",children:b.messages.join("; ")})]},b.rowNum))})]})}),a.jsxs(br,{children:[a.jsx(Y,{variant:"outline",onClick:()=>c(null),disabled:h,children:"Cancel"}),a.jsx(Y,{onClick:g,disabled:h||v===0,children:h?"Importingâ¦":`Confirm import (${v} line${v===1?"":"s"})`})]})]})})]})}const j8=[{name:"Lodging",cost_type:"per_person",sort_order:0},{name:"Outfitter",cost_type:"per_person",sort_order:1},{name:"Gratuity",cost_type:"pct_outfitter",sort_order:2},{name:"Food/Bev",cost_type:"per_person",sort_order:3},{name:"Transportation",cost_type:"flat",sort_order:4},{name:"Materials",cost_type:"flat",sort_order:5},{name:"Swag",cost_type:"per_person",sort_order:6},{name:"Misc",cost_type:"flat",sort_order:7},{name:"Guide Travel",cost_type:"flat",sort_order:8},{name:"Guide Facilitation Comp",cost_type:"per_person",sort_order:9},{name:"Project Management",cost_type:"flat",sort_order:10},{name:"Generator Recruiting Comp",cost_type:"per_person",sort_order:11}],Pd=j8.map(e=>e.name);function Ar(e){return e.source==="generator_comp"?"Generator Recruiting Comp":e.source==="facilitator_comp"?"Guide Facilitation Comp":Pd.find(n=>n.toLowerCase()===(e.name||"").toLowerCase())||e.name||"Misc"}function mi(e){return e.description?e.description:Pd.some(t=>t.toLowerCase()===e.name.toLowerCase())?"":e.name}
803const Xue=[{name:"Sales Comp",cost_type:"pct_revenue",sort_order:100},{name:"Overhead Contribution",cost_type:"pct_revenue",sort_order:101},{name:"Budgeted Profit",cost_type:"pct_revenue",sort_order:102}],Jue=new Set(["Project Management","CC Fees","Credit Card Fees","Generator Recruiting Comp","Guide Facilitation Comp","Materials","Swag","Misc"]),Zue=["generator recruiting comp","guide facilitation comp","facilitator comp"],bA=e=>{if(Jue.has(e))return!0;const t=(e||"").toLowerCase();return Zue.some(n=>t.startsWith(n))},wA=e=>Math.round((Number(e)||0)*100)/100,N8={per_person:"Per Person",flat:"Flat",pct_price:"% of Rev",pct_outfitter:"% of Outfitter",pct_per_person:"% of Price",pct_revenue:"% of Revenue"},_A={Estimate:"bg-slate-400 border-slate-500 dark:bg-slate-500 dark:border-slate-400","Default Estimate":"bg-slate-400 border-slate-500 dark:bg-slate-500 dark:border-slate-400",Quoted:"bg-blue-500 border-blue-600 dark:bg-blue-500 dark:border-blue-400",Contracted:"bg-green-500 border-green-600 dark:bg-green-500 dark:border-green-400",Actual:"bg-emerald-700 border-emerald-800 dark:bg-emerald-600 dark:border-emerald-500"};function jA({status:e}){const t=e||"Estimate";return a.jsx("span",{className:Se("inline-block w-2.5 h-1.5 rounded-full border",_A[t]||_A.Estimate),title:t,"aria-label":t})}const ede=["Guide Facilitation Comp","Generator Recruiting Comp","Project Management"],tde="Project Management",S8=["Lodging","Outfitter","Gratuity","Food/Bev","Transportation","Materials","Swag","Misc","Guide Travel"];function nde({experienceId:e,experiencePrice:t,maxSize:n,restricted:r=!1,experienceType:s,targetStartDate:i,embeddedTripStartDate:o,briefComplete:l=!0,priorTripId:c=null,viewerRole:u="employee",viewerGeneratorId:d=null,location:h=null}){const m=at(),[f,x]=y.useState(new Set),g=ie=>x(ke=>{const Be=new Set(ke);return Be.has(ie)?Be.delete(ie):Be.add(ie),Be}),{toast:p}=mt(),[v,b]=y.useState(""),[w,N]=y.useState(!0),[j,_]=y.useState(!1),[S,P]=y.useState(!1),[k,C]=y.useState("direct"),[T,O]=y.useState("Lodging"),[L,E]=y.useState(!1),{data:R=[]}=Mp(),q=y.useMemo(()=>R.length?R.filter(ie=>ie.active):j8.map(ie=>({name:ie.name,default_cost_type:ie.cost_type,sort_order:ie.sort_order,active:!0})),[R]),{data:I=[],isLoading:$}=Ee({queryKey:["budget-items",e],queryFn:async()=>{const{data:ie,error:ke}=await F.from("experience_budget_items").select("*, suppliers(name)").eq("experience_id",e).order("sort_order");if(ke)throw ke;return ie}}),{data:M={}}=Ee({queryKey:["budget-payment-counts",e,I.length],enabled:I.length>0,queryFn:async()=>{const ie=I.map(Be=>Be.id),ke={};for(let Be=0;Be<ie.length;Be+=200){const{data:$t}=await F.from("experience_budget_item_payments").select("budget_item_id, due_month").in("budget_item_id",ie.slice(Be,Be+200)),pt={};($t||[]).forEach(sn=>{var Vn;(pt[Vn=sn.budget_item_id]||(pt[Vn]=new Set)).add(sn.due_month)}),Object.entries(pt).forEach(([sn,Vn])=>{ke[sn]=Vn.size})}return ke}}),{data:B}=Ee({queryKey:["budget-settings",e],queryFn:async()=>{const{data:ie,error:ke}=await F.from("experience_budget_settings").select("*").eq("experience_id",e).maybeSingle();if(ke)throw ke;return ie}}),{data:W=[]}=Ee({queryKey:["budget-accepted-contacts",e],queryFn:async()=>{const{data:ie,error:ke}=await F.from("contact_experiences").select("id, custom_price, amount_paid, status, contacts!contact_experiences_contact_id_fkey(email)").eq("experience_id",e).in("status",["accepted","gen_guide"]);if(ke)throw ke;return ie??[]}}),{data:A=[]}=Ee({queryKey:["budget-comp-agreements",e],queryFn:async()=>{const{data:ie,error:ke}=await F.from("generator_experience_comp").select("generator_id, invite_bonus_pct, invite_bonus_threshold, recruitment_share_pct, trip_price_snapshot, quality_invite_ids, host_guide_pct, generators(email, name)").eq("experience_id",e);if(ke)throw ke;return ie??[]}}),K=W.map(ie=>ie.id),{data:G=[]}=Ee({queryKey:["budget-addon-selections",e,K],queryFn:async()=>{if(K.length===0)return[];const{data:ie,error:ke}=await F.from("contact_experience_addons").select("contact_experience_id, experience_addons(price)").in("contact_experience_id",K);if(ke)throw ke;return ie},enabled:K.length>0});Ee({queryKey:["budget-generator-count",e],queryFn:async()=>{const{count:ie,error:ke}=await F.from("generator_experiences").select("id",{count:"exact",head:!0}).eq("experience_id",e);if(ke)throw ke;return ie??0}});const{data:H}=Ee({queryKey:["budget-experience-meta",e],queryFn:async()=>{const{data:ie,error:ke}=await F.from("experiences").select("deposit_due_date").eq("id",e).maybeSingle();if(ke)throw ke;return ie}}),fe=(B==null?void 0:B.exchange_rate_eur)??1.08,te=(B==null?void 0:B.foreign_currency)||"EUR",J=ie=>ie==="USD"?1:ie===te?fe:0,re=I.some(ie=>ie.currency!=="USD"),pe=I.filter(ie=>ie.currency!=="USD"&&ie.currency!==te),ye=(B==null?void 0:B.override_pax_count)??n,[X,he]=y.useState(null),D=X!==null?parseInt(X)||0:ye,le=W.filter(ie=>ie.status==="accepted"),V=W.filter(ie=>ie.status==="gen_guide"),U=le.length,z=y.useMemo(()=>s==="peer_group"&&o?o:i||null,[s,i,o]);y.useEffect(()=>{he(null)},[ye]);const Z=Me({mutationFn:async()=>{const ie=q.map(on=>({name:on.name,cost_type:on.default_cost_type,sort_order:on.sort_order,experience_id:e,category:"direct",amount:0,currency:"USD",includes_generators:!0,generator_count:0,estimate_status:"Estimate"})),ke=r?[]:Xue.map(on=>({...on,experience_id:e,category:"indirect",amount:0,currency:"USD",includes_generators:!0,generator_count:0})),Be=new Set(I.map(on=>(on.name||"").toLowerCase())),$t=[...ie,...ke].filter(on=>!Be.has(on.name.toLowerCase())),{error:pt}=await F.from("experience_budget_items").insert($t);if(pt)throw pt;const sn=I.filter(on=>on.category==="direct");if(sn.length){let on=200;for(const bs of sn)await F.from("experience_budget_items").update({sort_order:on++}).eq("id",bs.id)}const{error:Vn}=await F.from("experience_budget_settings").upsert({experience_id:e,override_pax_count:null,exchange_rate_eur:1.08});if(Vn)throw Vn},onSuccess:()=>
803{m.invalidateQueries({queryKey:["budget-items",e]}),m.invalidateQueries({queryKey:["budget-settings",e]})}}),ve=Me({mutationFn:async({id:ie,updates:ke})=>{const{error:Be}=await F.from("experience_budget_items").update(ke).eq("id",ie);if(Be)throw Be},onSuccess:()=>m.invalidateQueries({queryKey:["budget-items",e]})}),ee=Me({mutationFn:async ie=>{const ke=I.find($t=>$t.id===ie);if(ke&&ke.category==="direct"){const $t=Ar(ke);if(I.filter(sn=>sn.category==="direct"&&Ar(sn)===$t).length<=1){const{error:sn}=await F.from("experience_budget_items").update({amount:0}).eq("id",ie);if(sn)throw sn;return"zeroed"}}const{error:Be}=await F.from("experience_budget_items").delete().eq("id",ie);if(Be)throw Be;return"deleted"},onSuccess:ie=>{m.invalidateQueries({queryKey:["budget-items",e]}),ie==="zeroed"&&p({title:"Amount set to $0",description:"Every category keeps at least one line, so this one was zeroed instead of deleted."})},onError:ie=>p({title:"Could not delete",description:ie.message,variant:"destructive"})}),[de,je]=y.useState(null),[Q,oe]=y.useState(null),Pe=Me({mutationFn:async ie=>{for(const ke of ie){const{error:Be}=await F.from("experience_budget_items").update({sort_order:ke.sort_order}).eq("id",ke.id);if(Be)throw Be}},onSuccess:()=>m.invalidateQueries({queryKey:["budget-items",e]}),onError:ie=>p({title:"Reorder failed",description:ie.message,variant:"destructive"})}),ze=y.useCallback((ie,ke,Be)=>{const $t=de;if(je(null),oe(null),!$t||$t===ke)return;const pt=ie.findIndex(Gr=>Gr.id===$t),sn=ie.findIndex(Gr=>Gr.id===ke);if(pt<0||sn<0)return;if(Be&&Be(ie[pt])!==Be(ie[sn])){p({title:"Lines reorder within their category",description:"Change the category on the line instead."});return}const Vn=[...ie],[on]=Vn.splice(pt,1);Vn.splice(sn,0,on);const bs=Math.min(...ie.map(Gr=>Gr.sort_order));Pe.mutate(Vn.map((Gr,Ga)=>({id:Gr.id,sort_order:bs+Ga})))},[de,Pe]),Je=Me({mutationFn:async()=>{var $t;const ie=k==="direct";if(!ie&&!v.trim())return;const ke=Math.max(0,...I.map(pt=>pt.sort_order)),{error:Be}=await F.from("experience_budget_items").insert({experience_id:e,name:ie?T:v.trim(),description:ie&&v.trim()||null,category:k,cost_type:k==="indirect"?"pct_revenue":(($t=q.find(pt=>pt.name===T))==null?void 0:$t.default_cost_type)||"per_person",amount:0,currency:"USD",includes_generators:!0,generator_count:0,sort_order:ke+1});if(Be)throw Be},onSuccess:()=>{m.invalidateQueries({queryKey:["budget-items",e]}),b("")}}),Ae=Me({mutationFn:async ie=>{const{error:ke}=await F.from("experience_budget_settings").upsert({experience_id:e,...ie});if(ke)throw ke},onSuccess:()=>m.invalidateQueries({queryKey:["budget-settings",e]})}),{data:et=[]}=Ee({queryKey:["budget-included-addons",e],queryFn:async()=>{const{data:ie,error:ke}=await F.from("experience_addons").select("id, price, budget_quantity, include_in_budget").eq("experience_id",e).eq("include_in_budget",!0);if(ke)throw ke;return ie}}),Ne=y.useMemo(()=>et.reduce((ie,ke)=>ie+Number(ke.price)*Number(ke.budget_quantity||0),0),[et]),be=y.useMemo(()=>A.map(ie=>({id:ie.generator_id,agreement:{invite_bonus_pct:Number(ie.invite_bonus_pct)||0,invite_bonus_threshold:Number(ie.invite_bonus_threshold)||0,recruitment_share_pct:Number(ie.recruitment_share_pct)||0,trip_price_snapshot:Number(ie.trip_price_snapshot)||0,quality_invite_ids:ie.quality_invite_ids??[],host_guide_pct:Number(ie.host_guide_pct)||0}})),[A]),Ue=y.useMemo(()=>be.map((ie,ke)=>{var Be,$t;return{...ie,name:(($t=(Be=A[ke])==null?void 0:Be.generators)==null?void 0:$t.name)??""}}),[be,A]),Ze=y.useMemo(()=>{var ie;return my(be,D,t??((ie=be[0])==null?void 0:ie.agreement.trip_price_snapshot)??0)},[be,D,t]),nt=y.useMemo(()=>{const ie=new Map;return A.forEach(ke=>{var $t;const Be=((($t=ke.generators)==null?void 0:$t.email)||"").toLowerCase();Be&&ie.set(Be,Number(ke.trip_price_snapshot)||Number(t)||0)}),ie},[A,t]),rt=y.useMemo(()=>{const ie=new Set;return be.forEach(ke=>{var Be;(Be=Ze.get(ke.id))!=null&&Be.tripFullyComped&&ie.add(ke.id)}),ie},[be,Ze]),kt=y.useMemo(()=>{const ie=new Set;return A.forEach(ke=>{var $t;const Be=((($t=ke.generators)==null?void 0:$t.email)||"").toLowerCase();Be&&rt.has(ke.generator_id)&&ie.add(Be)}),ie},[A,rt]),jt=y.useMemo(()=>{const ie=[];return Ue.forEach(ke=>{const Be=Ze.get(ke.id);if(!Be||!ke.name)return;
803const $t=wA(Be.tripFullyComped?Be.recruitingCashPayout:Be.totalCredit),pt=wA(Be.hostGuideCredit),sn=(Vn,on,bs)=>{const Gr=I.find(Ga=>Ga.source===Vn&&Ga.generator_id===ke.id)??I.find(Ga=>Ga.source===Vn&&!Ga.generator_id&&Ga.description===on);Gr&&Math.abs(Number(Gr.amount)-bs)>.005&&ie.push({id:Gr.id,amount:bs})};sn("generator_comp",ke.name,$t),sn("facilitator_comp",ke.name,pt)}),ie},[Ue,Ze,I]),Et=jt.map(ie=>`${ie.id}:${ie.amount}`).join("|");y.useEffect(()=>{if(!jt.length)return;let ie=!1;const ke=setTimeout(async()=>{for(const Be of jt){const{error:$t}=await F.from("experience_budget_items").update({amount:Be.amount}).eq("id",Be.id);if($t)return}ie||m.invalidateQueries({queryKey:["budget-items",e]})},600);return()=>{ie=!0,clearTimeout(ke)}},[Et,e]);const Nt=y.useMemo(()=>Math.max(be.length,V.length),[be.length,V.length]),ue=y.useMemo(()=>{var ke;const ie=new Set;for(const Be of W)Be.status==="gen_guide"&&Be.custom_price!=null&&ie.add((((ke=Be.contacts)==null?void 0:ke.email)||"").toLowerCase());return ie},[W]),we=y.useMemo(()=>{const ie=new Map;return A.forEach(ke=>{var Be;ie.set(ke.generator_id,(((Be=ke.generators)==null?void 0:Be.email)||"").toLowerCase())}),ie},[A]),Ie=y.useMemo(()=>be.length===0?0:be.reduce((ie,ke)=>rt.has(ke.id)||ue.has(we.get(ke.id)||"")?ie:ie+(ke.agreement.trip_price_snapshot||t||0),0),[be,t,rt,ue,we]),se=y.useMemo(()=>{const ie=new Set;return be.forEach(ke=>{ue.has(we.get(ke.id)||"")&&ie.add(ke.id)}),ie},[be,ue,we]),ge=y.useMemo(()=>{let ie=0,ke=0;for(const Be of W)Be.custom_price!=null&&(ie+=Number(Be.custom_price),Be.status!=="gen_guide"&&(ke+=1));return{total:ie,count:ke}},[W]),$e=y.useMemo(()=>Math.max(0,D-ge.count)*(t??0)+ge.total+Ie+Ne,[D,Nt,ge,t,Ie,Ne]),Ke=y.useMemo(()=>{var Be,$t;const ie=t??0;let ke=0;for(const pt of W)if(pt.status==="gen_guide"){const sn=(((Be=pt.contacts)==null?void 0:Be.email)||"").toLowerCase(),Vn=nt.get(sn);Vn!=null&&!kt.has(sn)?ke+=Vn:Vn==null&&pt.custom_price!=null&&(ke+=Number(pt.custom_price))}else ke+=pt.custom_price!=null?Number(pt.custom_price):ie;for(const pt of G)ke+=Number((($t=pt.experience_addons)==null?void 0:$t.price)??0);return ke},[W,G,t,nt,kt]),Qe=`budget-revenue-basis:${e}`,[He,Tt]=y.useState(()=>{if(typeof window<"u"){const ie=window.localStorage.getItem(Qe);if(ie==="projected"||ie==="confirmed")return ie}return null});y.useEffect(()=>{if(He!==null||!n)return;if((H==null?void 0:H.deposit_due_date)&&new Date(H.deposit_due_date)<new Date){Tt("confirmed");return}Tt(U>=n*.5?"confirmed":"projected")},[He,U,n,H==null?void 0:H.deposit_due_date]);const fn=ie=>{Tt(ie),typeof window<"u"&&window.localStorage.setItem(Qe,ie)},Xt=He==="projected"?$e:Ke,_e=He==="confirmed"?U:D,It=He==="confirmed"?V.length:Nt,nn=y.useCallback(ie=>ie.includes_generators?_e+It:_e,[_e,It]),tn=y.useMemo(()=>{const ie=I.filter(Be=>Be.category==="direct"&&Ar(Be)==="Outfitter");let ke=0;for(const Be of ie){const $t=nn(Be);let pt=Be.cost_type==="flat"?Be.amount:Be.amount*$t;pt=pt*J(Be.currency),ke+=pt}return ke},[I,nn,fe,te]),Zt=y.useMemo(()=>I.filter(ie=>ie.category==="direct"&&ie.cost_type==="per_person").reduce((ie,ke)=>{const Be=nn(ke);let $t=ke.amount*Be;return $t=$t*J(ke.currency),ie+$t},0),[I,nn,fe,te]),Ce=y.useCallback(ie=>{let ke=0;const Be=nn(ie);switch(ie.cost_type){case"per_person":ke=ie.amount*Be;break;case"flat":ke=ie.amount;break;case"pct_price":ke=Xt*(ie.amount/100);break;case"pct_outfitter":ke=tn*(ie.amount/100);break;case"pct_per_person":ke=t*(ie.amount/100);break;case"pct_revenue":ke=Xt*(ie.amount/100);break}return ke=ke*J(ie.currency),ke},[nn,W,U,t,Xt,fe,te,tn,Zt,He]),ut=y.useCallback(ie=>{const ke=J(ie.currency),Be=ie.amount/100*ke;switch(ie.cost_type){case"per_person":return{basis:"per person",unit:ie.amount*ke,qty:nn(ie)};case"flat":return{basis:"per trip",unit:ie.amount*ke,qty:1};case"pct_outfitter":return{basis:"% of Outfitter",unit:Be,qty:tn};case"pct_per_person":return{basis:"% of price",unit:Be,qty:t??0};default:return{basis:ie.cost_type==="pct_price"?"% of price":"% of revenue",unit:Be,qty:Xt}}},[fe,nn,tn,t,Xt]),ne=async()=>{var J2,Z2,eE;const ie=await Rk([e]),ke=new Map(I.map(Sr=>
803[Sr.id,Sr])),Be=ie.map(Sr=>({...ke.get(Sr.id)||Sr,_l:Sr})),$t=((J2=ie[0])==null?void 0:J2.qbo_class)||"",pt=((eE=(Z2=ie[0])==null?void 0:Z2.experiences)==null?void 0:eE.name)||"trip",sn=new Map(ie.map(Sr=>[Sr.id,Sr.supplier_name])),Vn=Sr=>{var Ll,Fl;const eu=((Ll=ie.find(_o=>_o.id===Sr))==null?void 0:Ll.payments)||[];return((Fl=eu.find(_o=>!_o.paid)||eu[eu.length-1])==null?void 0:Fl.due_month)||""},on=Sr=>Sr.toFixed(2),bs=[["qbo_class","category","supplier","description","basis","unit_amount","quantity","line_total","spent","variance","payment_due_date","closed"]];let Gr=0,Ga=0,k0=!1;for(const Sr of Ve){const eu=Be.filter(ws=>Ar(ws)===Sr);if(!eu.length)continue;let Ll=0,Fl=0,_o=!1;for(const ws of eu){const ql=ut(ws),E0=ql.unit*ql.qty,tu=ws.spent_to_date==null?null:Number(ws.spent_to_date);Ll+=E0,tu==null?_o=!0:Fl+=tu,bs.push([$t,Sr,sn.get(ws.id)||"",mi(ws),ql.basis,ws.cost_type.startsWith("pct_")?ql.unit.toFixed(6):on(ql.unit),ws.cost_type.startsWith("pct_")?on(ql.qty):ql.qty,on(E0),tu==null?"":on(tu),tu==null?"unknown":on(E0-tu),Vn(ws.id),ws.is_closed?"Yes":"No"])}bs.push([$t,`${Sr} total`,"","","","","",on(Ll),on(Fl)+(_o?" (some unknown)":""),_o?"unknown":on(Ll-Fl),"",""]),Gr+=Ll,Ga+=Fl,_o&&(k0=!0)}bs.push([$t,"Experience grand total","","","","","",on(Gr),on(Ga)+(k0?" (some unknown)":""),k0?"unknown":on(Gr-Ga),"",""]);const _9=pt.replace(/[^a-z0-9]+/gi,"-").toLowerCase();$k(`budget-reconciliation-${_9}.csv`,Dk(bs))},qe=I.filter(ie=>ie.category==="direct"),Ve=(()=>{const ie=(R.length?R.map(ke=>ke.name):Pd).slice();for(const ke of qe){const Be=Ar(ke);ie.includes(Be)||ie.push(Be)}return ie})(),Lt=I.filter(ie=>ie.category==="indirect"),nr=qe.reduce((ie,ke)=>ie+Ce(ke),0),Nn=u==="employee"||u==="project_manager",gr=Nn?qe:qe.filter(ie=>{const ke=Ar(ie),Be=!!d&&ie.generator_id===d;return u==="booking"?ke===tde?Be:S8.includes(ke):ede.includes(ke)?Be:!0}),Ha=gr.reduce((ie,ke)=>ie+Ce(ke),0),vs=Lt.reduce((ie,ke)=>ie+Ce(ke),0),ei=nr+vs,Il=$e-ei,C0=Ke-ei,Zc=I.filter(ie=>ie.category==="direct"&&!bA(ie.name)),Kp=Zc.filter(ie=>["Quoted","Contracted","Actual"].includes(ie.estimate_status||"Estimate")).length,Hp=Zc.length,Eh=I.filter(ie=>ie.source!=="generator_comp"&&ie.source!=="facilitator_comp");return!$&&Eh.length===0?a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Budget"}),a.jsxs("div",{className:"flex flex-col items-center gap-2 py-4 text-center",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"No budget set up yet for this experience."}),a.jsx(Y,{size:"sm",variant:"outline",className:"text-xs",onClick:()=>Z.mutate(),disabled:Z.isPending,children:Z.isPending?a.jsxs(a.Fragment,{children:[a.jsx(Hx,{className:"h-3 w-3 mr-1 animate-spin"})," Creatingâ¦"]}):a.jsxs(a.Fragment,{children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Initialize Budget"]})}),!r&&a.jsx(Fue,{experienceId:e,location:h,activeCategories:q})]})]}):$?a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Budget"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Loadingâ¦"})]}):a.jsxs("div",{className:"border-t border-border pt-3 space-y-3",children:[a.jsxs("button",{type:"button",onClick:()=>N(ie=>!ie),className:"flex items-center justify-between w-full text-left",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5",children:[a.jsx(H3,{className:"h-3.5 w-3.5"})," Budget"]}),w?a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),!l&&a.jsxs("div",{className:"flex items-start gap-2 rounded border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200",children:[a.jsx(za,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),a.jsx("span",{children:`The Trip Brief isn't marked complete yet. Open the trip's Trip Brief (edit) and tick "Brief complete" once it's filled in.`})]}),!w&&a.jsxs("div",{className:"flex flex-wrap justify-end gap-1",children:[!r&&a.jsx(Que,{experienceId:e}),c&&!r&&a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs gap-1",onClick:()=>P(!0),children:[a.jsx(rH,{className:"h-3 w-3"})," Compare to prior trip"]}),!r&&a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs gap-1",onClick:ne,title:"Export only â this file can't be imported. Use the budget export for re-importing.",children:[a.jsx(ja,{className:"h-3 w-3"})," Reconciliation CSV ",a.jsx("span",{className:"text-muted-foreground",children:"(export only
803)"})]}),c&&S&&a.jsx(que,{open:S,onOpenChange:P,priorTripId:c,currentLines:qe,currentAmounts:Object.fromEntries(qe.map(ie=>[ie.id,Ce(ie)])),renderStatus:ie=>a.jsxs("span",{className:"inline-flex items-center gap-1 text-xs",children:[a.jsx(jA,{status:ie}),ie||"Estimate"]})})]}),!w&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex flex-wrap gap-3 text-xs",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(xe,{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:"Pax Count:"}),a.jsx(ce,{type:"text",inputMode:"numeric",className:"h-6 w-14 text-[10px] px-1",value:X!==null?X:(B==null?void 0:B.override_pax_count)!=null?String(B.override_pax_count):"",placeholder:String(n),onChange:ie=>{const ke=ie.target.value.replace(/[^0-9]/g,"");he(ke)},onBlur:ie=>{const ke=ie.target.value;Ae.mutate({override_pax_count:ke?parseInt(ke):null})},onKeyDown:ie=>{ie.key==="Enter"&&ie.currentTarget.blur()}}),a.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",U," accepted)"]})]}),re&&a.jsx(Iue,{experienceId:e,settings:B,canEdit:Nn})]}),pe.length>0&&a.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/5 px-2 py-1.5 text-[11px] space-y-0.5",children:[a.jsxs("p",{className:"font-medium text-destructive",children:["This budget's rate is for ",te,", but ",pe.length," line(s) use another foreign currency and are not counted:"]}),pe.map(ie=>a.jsxs("p",{children:["⢠",Ar(ie),mi(ie)?` â ${mi(ie)}`:"",": ",ie.amount," ",ie.currency]},ie.id)),a.jsxs("p",{className:"text-muted-foreground",children:["Re-enter each in USD or ",te," and record the original amount and rate in the line's note."]})]}),a.jsxs("div",{className:Se("grid grid-cols-2 gap-2",!Nn&&"hidden"),children:[a.jsxs("label",{className:Se("rounded px-2 py-1.5 text-xs cursor-pointer border-2 transition-colors flex items-center justify-between gap-2",He==="projected"?"border-primary bg-primary/5":"border-transparent bg-muted/50"),children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-muted-foreground block text-[10px]",children:"Projected Revenue"}),a.jsxs("span",{className:"text-muted-foreground text-[10px]",children:[Math.max(0,D-ge.count)," paying à $",t??0,ge.count>0?` + ${ge.count} custom $${ge.total.toLocaleString(void 0,{maximumFractionDigits:0})}`:"",Nt>0&&Ie>0?` + ${Nt} team seat${Nt===1?"":"s"} gross $${Ie.toLocaleString(void 0,{maximumFractionDigits:0})}`:"",Ne>0?` + $${Ne.toLocaleString(void 0,{maximumFractionDigits:0})} add-ons`:""]}),a.jsxs("span",{className:"font-semibold text-foreground block",children:["$",$e.toLocaleString(void 0,{maximumFractionDigits:0}),"*"]})]}),a.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[a.jsx("input",{type:"radio",name:"revenueBasis",checked:He==="projected",onChange:()=>fn("projected"),className:"accent-primary h-3 w-3"}),a.jsx("span",{className:"text-muted-foreground text-[10px]",children:"Show Budget"})]})]}),a.jsxs("label",{className:Se("rounded px-2 py-1.5 text-xs cursor-pointer border-2 transition-colors flex items-center justify-between gap-2",He==="confirmed"?"border-primary bg-primary/5":"border-transparent bg-muted/50"),children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-muted-foreground block text-[10px]",children:"Confirmed Revenue"}),a.jsxs("span",{className:"text-muted-foreground text-[10px]",children:[U," accepted",V.length>0?` + ${V.length} gen seat${V.length===1?"":"s"}`:"",G.length>0?" + addons":""]}),a.jsxs("span",{className:"font-semibold text-foreground block",children:["$",Ke.toLocaleString(void 0,{maximumFractionDigits:0})]})]}),a.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[a.jsx("input",{type:"radio",name:"revenueBasis",checked:He==="confirmed",onChange:()=>fn("confirmed"),className:"accent-primary h-3 w-3"}),a.jsx("span",{className:"text-muted-foreground text-[10px]",children:"Show Budget"})]})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:"Direct Expenses"}),a.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground cursor-pointer",children:[a.jsx(ta,{checked:L,onCheckedChange:E,className:"scale-75"}),"Hide $0 lines"]})]}),Nn&&f.size>0&&a.jsx(Due,{experienceId:e,selected:gr.filter(ie=>f.has(ie.id)),orderedIds:Ve.flatMap(ie=>gr.filter(ke=>Ar(ke)===ie).map(ke=>ke.id)),totals:Object.fromEntries(gr.map(ie=>[ie.id,Ce(ie)])),categories:q.map(ie=>ie.name),onClear:()=>x(new Set)}),a.jsx("div",{className:"rounded border border-border overflow-hidden",children:a.jsxs("table",{className:"w-full text-[10px]",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border bg-muted/50",children:[a.jsx("th",{className:"w-4 px-0"}),a.jsx("th",{className:"text-left px-1.5 py-1 font-medium text-muted-foreground",children:"Item"}),a.jsx("th",{className:"text-left px-1.5 py-1 font-medium text-muted-foreground w-20",children:"Type"}),a.jsx("th",{className:"text-right px-1.5 py-1 font-medium text-muted-foreground w-16",children:"Amount"}),a.jsx("th",{className:"text-center px-1.5 py-1 font-medium text-muted-foreground w-8",children:"$"}),a.jsx("th",{className:"text-center px-1.5 py-1 font-medium text-muted-foreground w-10 whitespace-nowrap",title:"Incl. Gen/Guide â when checked, Gen/Guide seats are included in this line's headcount. Uncheck to exclude them.",children:"G/G"}),a.jsx("th",{className:"text-right px-1.5 py-1 font-medium text-muted-foreground w-20",children:"Total"}),a.jsx("th",{className:"text-right px-1.5 py-1 font-medium text-muted-foreground w-16",title:"Actual spent-to-date (blank = use budget)",children:"Spent"}),a.jsx("th",{className:"text-center px-1.5 py-1 font-medium text-muted-foreground w-10",title:"Mark closed â excludes from forecast",children:"Closed"}),a.jsx("th",{className:"w-6 px-1",title:"Expense schedule"}),a.jsx("th",{className:"w-6 px-1"})]})}),a.jsxs("tbody",{children:[Ve.map(ie=>{const ke=gr.filter(pt=>Ar(pt)===ie),Be=L?ke.filter(pt=>Math.abs(Ce(pt))>=.005):ke;if(Be.length===0)return null;const $t=ke.reduce((pt,sn)=>pt+Ce(sn),0);return a.jsxs(y.Fragment,{children:[a.jsxs("tr",{className:"border-b border-border bg-muted/20",children:[a.jsx("td",{}),a.jsx("td",{colSpan:5,className:"px-1.5 py-0.5 font-semibold text-foreground",children:a.jsxs("span",{className:"inline-flex flex-wrap items-center gap-1.5",children:[a.jsxs("span",{children:[ie,Be.length>1&&a.jsxs("span",{className:"ml-1 font-normal text-muted-foreground",children:["(",Be.length,")"]})]}),ke.filter(pt=>!bA(pt.name)).map(pt=>a.jsx(jA,{status:pt.estimate_status},pt.id))]})}),a.jsxs("td",{className:"px-1.5 py-0.5 text-right font-semibold tabular-nums",children:["$",$t.toLocaleStr
803ing(void 0,{maximumFractionDigits:0})]}),a.jsx("td",{colSpan:4})]}),Be.map(pt=>a.jsx(rde,{item:pt,calculatedCost:Ce(pt),defaultMonth:z,selectable:Nn,selected:f.has(pt.id),onToggleSelect:()=>g(pt.id),scheduleDates:M[pt.id]||0,fxCurrency:te,exchangeRate:fe,onUpdate:sn=>ve.mutate({id:pt.id,updates:sn}),onDelete:()=>ee.mutate(pt.id),isDragging:de===pt.id,isDragOver:Q===pt.id,onDragStart:()=>je(pt.id),onDragEnd:()=>{je(null),oe(null)},onDragOverRow:()=>oe(pt.id),onDropRow:()=>ze(qe,pt.id,Ar)},pt.id))]},ie)}),a.jsxs("tr",{className:"border-t border-border bg-muted/30",children:[a.jsx("td",{colSpan:6,className:"px-1.5 py-1 font-medium text-muted-foreground text-right",children:Nn?"Subtotal":"Subtotal (lines you can see)"}),a.jsxs("td",{className:"px-1.5 py-1 text-right font-semibold",children:["$",Ha.toLocaleString(void 0,{maximumFractionDigits:0})]}),a.jsx("td",{colSpan:4})]})]})]})})]}),!r&&a.jsxs("div",{children:[a.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1",children:"Indirect Expenses"}),a.jsx("div",{className:"rounded border border-border overflow-hidden",children:a.jsxs("table",{className:"w-full text-[10px]",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border bg-muted/50",children:[a.jsx("th",{className:"w-4 px-0"}),a.jsx("th",{className:"text-left px-1.5 py-1 font-medium text-muted-foreground",children:"Item"}),a.jsx("th",{className:"text-left px-1.5 py-1 font-medium text-muted-foreground w-20",children:"Type"}),a.jsx("th",{className:"text-right px-1.5 py-1 font-medium text-muted-foreground w-16",children:"%"}),a.jsx("th",{className:"text-right px-1.5 py-1 font-medium text-muted-foreground w-20",colSpan:3,children:"Total"}),a.jsx("th",{className:"w-6 px-1"})]})}),a.jsxs("tbody",{children:[Lt.map(ie=>a.jsxs("tr",{className:Se("border-b border-border last:border-0 hover:bg-muted/30",de===ie.id&&"opacity-50",Q===ie.id&&de!==ie.id&&"bg-primary/10"),draggable:!0,onDragStart:ke=>{if(ke.target.closest("input, textarea, select, button, [role='combobox']")){ke.preventDefault();return}je(ie.id)},onDragEnd:()=>{je(null),oe(null)},onDragOver:ke=>{ke.preventDefault(),oe(ie.id)},onDrop:ke=>{ke.preventDefault(),ze(Lt,ie.id),oe(null)},children:[a.jsx("td",{className:"px-0 py-1 text-center cursor-grab active:cursor-grabbing text-muted-foreground",title:"Drag to reorder",children:a.jsx(iC,{className:"h-3 w-3 mx-auto"})}),a.jsx("td",{className:"px-1.5 py-1",children:a.jsx("span",{children:ie.name})}),a.jsx("td",{className:"px-1.5 py-1 text-muted-foreground",children:N8[ie.cost_type]}),a.jsx("td",{className:"px-1.5 py-1 text-right",children:a.jsx(as,{type:"text",inputMode:"decimal",className:"h-5 w-14 text-[10px] px-1 text-right ml-auto block",value:ie.amount||"",placeholder:"0",onCommit:ke=>{ve.mutate({id:ie.id,updates:{amount:ke?parseFloat(ke):0}})}})}),a.jsxs("td",{className:"px-1.5 py-1 text-right font-medium",colSpan:3,children:["$",Ce(ie).toLocaleString(void 0,{maximumFractionDigits:0})]}),a.jsx("td",{className:"px-1 py-1",children:a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5 text-destructive",onClick:()=>ee.mutate(ie.id),children:a.jsx(Ht,{className:"h-3 w-3"})})})]},ie.id)),a.jsxs("tr",{className:"border-t border-border bg-muted/30",children:[a.jsx("td",{colSpan:6,className:"px-1.5 py-1 font-medium text-muted-foreground text-right",children:"Subtotal"}),a.jsxs("td",{className:"px-1.5 py-1 text-right font-semibold",children:["$",vs.toLocaleString(void 0,{maximumFractionDigits:0})]}),a.jsx("td",{})]})]})]})})]}),!r&&Hp>0&&(()=>{const ie=yk(I,Object.fromEntries((R||[]).map(ke=>[ke.name,!!ke.expects_quote])));return a.jsxs("div",{className:"flex items-center justify-between text-[10px] bg-muted/60 rounded px-2 py-1",title:"Counts only lines that expect a quote. Sourced = a quote attached, an estimate reason, or a confirmed supplier.",children:[a.jsxs("span",{className:ie.sourced<ie.total?"text-foreground font-medium":"text-muted-foreground",children:[ie.sourced," of ",ie.total," cost lines sourced"]}
803),a.jsxs("span",{className:"text-muted-foreground/70",children:[Kp," of ",Hp," quoted or better"]})]})})(),!r&&(()=>{const ie=He==="projected"?Il:C0,ke=He==="projected"?ie>=0?"Projected Surplus":"Projected Deficit":ie>=0?"Confirmed Surplus":"Confirmed Deficit";return a.jsxs("div",{className:Se("rounded px-2 py-1.5 text-xs flex items-center justify-between",ie>=0?"bg-emerald-50 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-200":"bg-red-50 text-red-800 dark:bg-red-950 dark:text-red-200"),children:[a.jsx("span",{className:"text-[10px]",children:ke}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"font-semibold text-right",children:["$",Math.abs(ie).toLocaleString(void 0,{maximumFractionDigits:0})]}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-5 px-1.5 text-[10px] gap-1 hover:bg-background/60",onClick:()=>_(!0),title:"Goal seek â solve for the price that hits a target bottom line",children:[a.jsx(_H,{className:"h-3 w-3"}),"Goal seek"]})]})]})})(),!r&&a.jsx(Gue,{open:j,onOpenChange:_,experienceId:e,currentPrice:t??0,currentPax:D,maxSize:n,budgetItems:I,exchangeRate:fe,fxCurrency:te,budgetedAddonRevenue:Ne,compEntries:Ue,customPrice:ge,customPricedTeamIds:se,revenueBasis:He??"projected",lockedReason:U>0?`${U} participant${U===1?" is":"s are"} already signed up, so the standard price can't be changed here. Solve for group size instead, or adjust individual prices on each participant.`:null}),a.jsxs("div",{className:Se("flex items-center gap-1",!Nn&&"hidden"),children:[!r&&a.jsxs(lt,{value:k,onValueChange:ie=>C(ie),children:[a.jsx(it,{className:"h-7 w-20 text-[10px]",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"direct",children:"Direct"}),a.jsx(Oe,{value:"indirect",children:"Indirect"})]})]}),k==="direct"&&a.jsxs(lt,{value:T,onValueChange:O,children:[a.jsx(it,{className:"h-7 w-40 text-[10px]",children:a.jsx(ct,{})}),a.jsx(ot,{children:q.map(({name:ie})=>a.jsx(Oe,{value:ie,className:"text-[10px]",children:ie},ie))})]}),a.jsx(ce,{value:v,onChange:ie=>b(ie.target.value),placeholder:k==="direct"?"Description (e.g. Airport hotel, night 1)â¦":"New indirect expense itemâ¦",className:"h-7 flex-1 text-[10px]",onKeyDown:ie=>{ie.key==="Enter"&&(ie.preventDefault(),Je.mutate())}}),a.jsx(Y,{size:"sm",className:"h-7 px-2",onClick:()=>Je.mutate(),disabled:k==="indirect"&&!v.trim(),children:a.jsx(zt,{className:"h-3 w-3"})})]})]})]})}function rde({item:e,calculatedCost:t,defaultMonth:n,onUpdate:r,onDelete:s,isDragging:i,isDragOver:o,onDragStart:l,onDragEnd:c,onDragOverRow:u,onDropRow:d,selectable:h=!1,selected:m=!1,onToggleSelect:f,scheduleDates:x=0,fxCurrency:g="EUR",exchangeRate:p=1}){var N;const[v,b]=y.useState(!1),w=j=>{if(j.target.closest("input, textarea, select, button, [role='combobox']")){j.preventDefault();return}l==null||l()};return a.jsxs("tr",{className:Se("border-b border-border last:border-0 hover:bg-muted/30",i&&"opacity-50",o&&!i&&"bg-primary/10"),draggable:!0,onDragStart:w,onDragEnd:c,onDragOver:j=>{j.preventDefault(),u==null||u()},onDrop:j=>{j.preventDefault(),d==null||d(),c==null||c()},children:[a.jsx("td",{className:"px-0 py-1 text-center cursor-grab active:cursor-grabbing text-muted-foreground",title:"Drag to reorder",children:a.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[h&&a.jsx(gt,{checked:m,onCheckedChange:()=>f==null?void 0:f(),className:"h-3 w-3","aria-label":"Select line"}),a.jsx(iC,{className:"h-3 w-3"})]})}),a.jsx("td",{className:"px-1.5 py-1",children:a.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[a.jsx(ade,{item:e,scheduleDates:x}),e.source==="generator_comp"||e.source==="facilitator_comp"?a.jsx("span",{className:"text-muted-foreground",children:mi(e)||e.name}):a.jsx(as,{type:"text",className:"h-5 flex-1 min-w-[6rem] !text-[11px] leading-[13px] px-1 border-transparent hover:border-input placeholder:text-muted-foreground/70",value:mi(e),placeholder:"Add descriptionâ¦",onCommit:j=>r({description:j.trim()||null})}),((N=e.suppliers)==null?void 0:N.name)&&a.jsxs("span",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:["· ",e.suppliers.name]})]})}),a.jsx("td",{className:"px-1.5 py-1",children:e.source==="generator_comp"||e.source==="facilitator_comp"?a.jsx("span",{className:"text-muted-foreground text-[10px]",children:N8[e.cost_type]}):a.jsxs(lt,{value:e.cost_type,onValueChange:j=>r({cost_type:j}),children:[a.jsx(it,{className:"h-5 text-[10px] border-0 px-1 w-full",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"per_person",children:"Per Person"}),a.jsx(Oe,{value:"flat",children:"Flat"}),a.jsx(Oe,{value:"pct_price",children:"% of Rev"}),a.jsx(Oe,{value:"pct_outfitter",children:"% of Outfitter"}),a.jsx(Oe,{value:"pct_per_person",children:"% of Price"})]})]})}),a.jsx("td",{className:"px-1.5 py-1 text-right",children:a.jsx(as,{type:"text",inputMode:"decimal",className:"h-5 w-14 text-[10px] px-1 text-right ml-auto block",value:e.amount||"",placeholder:"0",onCommit:j=>{r({amount:j?parseFloat(j):0})}})}),a.jsx("td",{className:"px-1.5 py-1 text-center",children:a.jsxs(lt,{value:e.currency,onValueChange:j=>r({currency:j}),children:[a.jsx(it,{className:"h-5 text-[10px] border-0 px-0 w-8",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"USD",children:"$"}),a.jsx(Oe,{value:g,children:$ue[g]||g}),e.currency!=="USD"&&e.currency!==g&&a.jsxs(Oe,{value:e.currency,children:[e.currency," (not counted)"]})]})]})}),a.jsx("td",{className:"px-1.5 py-1 text-center",children:(e.cost_type==="per_person"||e.cost_type==="pct_price")&&a.jsx("div",{className:"flex items-center gap-0.5 justify-center",children:a.jsx(gt,{checked:e.includes_generators,onCheckedChange:j=>r({includes_generators:!!j,generator_count:0}),className:"h-3 w-3"})})}),a.jsxs("td",{className:"px-1.5 py-1 text-right font-medium",children:["$",t.toLocaleStr
803ing(void 0,{maximumFractionDigits:0})]}),a.jsx("td",{className:"px-1.5 py-1 text-right",children:a.jsx(as,{type:"text",inputMode:"decimal",className:"h-5 w-14 text-[10px] px-1 text-right ml-auto block",value:e.spent_to_date!=null?String(e.spent_to_date):"",placeholder:"â",onCommit:j=>{const _=j.replace(/[$,\s]/g,""),S=_===""?null:Number(_);r({spent_to_date:S!=null&&Number.isFinite(S)?S:null})}})}),a.jsx("td",{className:"px-1.5 py-1 text-center",children:a.jsx(gt,{checked:!!e.is_closed,onCheckedChange:j=>{if(j&&e.spent_to_date==null){window.alert("Enter a Spent amount before closing this line â use 0 if the cost didn't materialise.");return}r({is_closed:!!j})},className:"h-3 w-3","aria-label":"Mark closed",title:P6(e.is_closed,e.spent_to_date)?"Closed, amount not recorded":void 0})}),a.jsxs("td",{className:"px-1 py-1 text-center",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:xy(e.valid_until)?`Expense detail â quote expired ${e.valid_until}`:"Expense detail",onClick:()=>b(!0),children:xy(e.valid_until)?a.jsx(za,{className:"h-3 w-3 text-amber-500"}):a.jsx(xH,{className:"h-3 w-3"})}),a.jsx(Hue,{open:v,onOpenChange:b,budgetItemId:e.id,itemName:mi(e)?`${Ar(e)} â ${mi(e)}`:Ar(e),budgetedAmount:t,defaultMonth:n||void 0,experienceId:e.experience_id,isCogs:S8.includes(Ar(e)),fx:e.currency===g&&e.currency!=="USD"?{currency:g,rate:p}:null})]}),a.jsx("td",{className:"px-1 py-1",children:a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5 text-destructive",onClick:s,children:a.jsx(Ht,{className:"h-3 w-3"})})})]})}function ade({item:e,scheduleDates:t}){return a.jsxs("span",{className:"inline-flex items-center gap-0.5 shrink-0",children:[t>1&&a.jsxs("span",{className:"text-[8px] text-muted-foreground",title:`Payment schedule has ${t} dates`,children:["Ã",t]}),e.stale_pending_requote&&a.jsx("span",{className:"text-[8px] font-semibold text-destructive",title:"Copied from a prior trip â re-quote pending",children:"stale"})]})}const sde=["Lodging","Outfitter","Gratuity","Food/Bev","Transportation","Materials","Swag","Misc","Guide Travel"];function ide({quote:e,experienceId:t,label:n}){const r=at(),[s,i]=y.useState(!1),[o,l]=y.useState([]),[c,u]=y.useState(new Set),d=async()=>{const{data:m,error:f}=await F.from("experience_budget_items").select("id, name, description, quote_id, amount").eq("experience_id",t).eq("category","direct").order("sort_order");if(f)return Mt.error(f.message);const x=(m||[]).filter(g=>sde.includes(g.name));l(x),u(new Set(x.filter(g=>g.quote_id===e.id).map(g=>g.id))),i(!0)},h=async()=>{const m=[...c],f=o.filter(x=>x.quote_id===e.id&&!c.has(x.id)).map(x=>x.id);if(m.length){const{error:x}=await F.from("experience_budget_items").update({quote_id:e.id,stale_pending_requote:!1}).in("id",m);if(x)return Mt.error(x.message)}if(f.length){const{error:x}=await F.from("experience_budget_items").update({quote_id:null}).in("id",f);if(x)return Mt.error(x.message)}
803r.invalidateQueries({queryKey:["budget-items"]}),r.invalidateQueries({queryKey:["experience-quotes"]}),r.invalidateQueries({queryKey:["budget-item-detail"]}),Mt.success(`Quote attached to ${m.length} line${m.length===1?"":"s"}. Open a line's detail to accept a proposed payment schedule.`),i(!1)};return a.jsxs(a.Fragment,{children:[a.jsxs(Y,{size:"sm",variant:"outline",className:"h-6 text-[10px] mr-1",onClick:d,children:[a.jsx(Nl,{className:"h-3 w-3 mr-1"})," Attach to lines"]}),a.jsx(Dt,{open:s,onOpenChange:i,children:a.jsxs(Pt,{className:"sm:max-w-md",children:[a.jsxs(Ot,{children:[a.jsxs(At,{children:["Attach quote â ",n]}),a.jsx(wr,{children:"Ticked lines take this quote's supplier, source, link and valid-until, and show as Quoted."})]}),a.jsxs("div",{className:"space-y-1 max-h-[50vh] overflow-y-auto",children:[o.map(m=>a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx(gt,{checked:c.has(m.id),onCheckedChange:f=>u(x=>{const g=new Set(x);return f?g.add(m.id):g.delete(m.id),g})}),a.jsxs("span",{children:[m.name,m.description?` â ${m.description}`:""]}),m.quote_id&&m.quote_id!==e.id&&a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"(has another quote)"})]},m.id)),!o.length&&a.jsx("p",{className:"text-sm text-muted-foreground",children:"No cost lines on this budget yet."})]}),a.jsxs(br,{children:[a.jsx(Y,{variant:"ghost",onClick:()=>i(!1),children:"Cancel"}),a.jsx(Y,{onClick:h,children:"Save"})]})]})})]})}const ode={requested:"bg-blue-100 text-blue-800 border-blue-200 dark:bg-blue-950 dark:text-blue-200 dark:border-blue-900",received:"bg-green-100 text-green-800 border-green-200 dark:bg-green-950 dark:text-green-200 dark:border-green-900",chosen:"bg-primary/10 text-primary border-primary/20",not_chosen:"bg-muted text-muted-foreground border-border",expired:"bg-amber-100 text-amber-800 border-amber-200 dark:bg-amber-950 dark:text-amber-200 dark:border-amber-900",Drafted:"bg-muted text-muted-foreground border-border",Sent:"bg-blue-100 text-blue-800 border-blue-200 dark:bg-blue-950 dark:text-blue-200 dark:border-blue-900",Received:"bg-green-100 text-green-800 border-green-200 dark:bg-green-950 dark:text-green-200 dark:border-green-900",Declined:"bg-red-100 text-red-800 border-red-200 dark:bg-red-950 dark:text-red-200 dark:border-red-900",Expired:"bg-amber-100 text-amber-800 border-amber-200 dark:bg-amber-950 dark:text-amber-200 dark:border-amber-900"};function Wh(e){if(!e)return"â";const[t,n,r]=e.split("-").map(Number);return new Date(t,n-1,r).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}const lde={USD:"$",EUR:"â¬",GBP:"£",CHF:"CHF ",CAD:"CA$"};function NA(e){return lde[e||"USD"]||`${e} `}function gu(e){if(e===""||e==null)return null;const t=parseFloat(String(e).replace(/[^0-9.\-]/g,""));return Number.isFinite(t)?t:null}function cde({experienceId:e}){const t=at(),{toast:n}=mt(),{data:r=[]}=Mp(),s=r.length?r.filter(Q=>Q.active).map(Q=>Q.name):Pd,[i,o]=y.useState(!1),[l,c]=y.useState({}),[u,d]=y.useState(null),[h,m]=y.useState(!1),[f,x]=y.useState(null),g=y.useRef(null),{data:p=[]}=Ee({queryKey:["experience-quotes",e],queryFn:async()=>{const{data:Q,error:oe}=await F.from("experience_quotes").select("*").eq("experience_id",e).order("created_at",{ascending:!1});if(oe)throw oe;return Q||[]}}),{data:v=[]}=Ee({queryKey:["suppliers-options"],queryFn:async()=>{const{data:Q,error:oe}=await F.from("suppliers").select("id, name, type").order("name");return oe?[]:Q||[]}}),{data:b=[]}=Iq([e]),w=Q=>{var oe;return((oe=b.find(Pe=>Pe.id===Q))==null?void 0:oe.derived)||"received"},[N,j]=y.useState(!1),_=p.filter(Q=>["requested","received"].includes(w(Q.id))),S=p.filter(Q=>!["requested","received"].includes(w(Q.id))),P=()=>{t.invalidateQueries({queryKey:["experience-quotes",e]}),t.invalidateQueries({queryKey:["experience-quotes"]})},k=Q=>{var oe;return((oe=v.find(Pe=>Pe.id===Q))==null?void 0:oe.name)||"â"},C=()=>{c({status:"Received",received_date:new Date().toLocaleDateString("en-CA")}),I(!1),d(null),o(!0)},T=()=>{c({status:"Sent",sent_date:new Date().toLocaleDateString("en-CA")}),I(!1),d(null),o(!0)},O=Q=>{c(Q),I(["inclusions","exclusions","deposit_terms","deposit_pct","deposit_amount","deposit_due_date","source","source_link","group_minimum","valid_until","quote_text","attachment_name"].some(oe=>Q[oe]!=null&&Q[oe]!=="")),d(null),o(!0)},L=["Drafted","Sent"].includes(l.status||""),E=Me({mutationFn:async()=>
803{if(L){const ze=[!l.supplier_id&&"supplier",!l.sent_date&&"date sent"].filter(Boolean);if(ze.length)throw new Error(`A requested quote needs ${ze.join(" and ")}.`)}else if(l.status!=="Declined"){const ze=[!l.supplier_id&&"supplier",gu(l.amount_per_person)==null&&gu(l.amount_per_group)==null&&"amount",!l.received_date&&"Quoted date"].filter(Boolean);if(ze.length)throw new Error(`A quote needs ${ze.join(", ")}.`)}m(!0);let Q=l.attachment_path??null,oe=l.attachment_name??null;if(u){const ze=u.name.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/_+/g,"_").slice(0,180)||"file",Je=`${e}/quotes/${Date.now()}-${ze}`,{error:Ae}=await F.storage.from("experience-resources").upload(Je,u);if(Ae)throw Ae;Q=Je,oe=u.name}const Pe={experience_id:e,supplier_id:l.supplier_id||null,sent_date:l.sent_date||null,status:l.status||"Drafted",received_date:l.received_date||null,amount_per_person:gu(l.amount_per_person),amount_per_group:gu(l.amount_per_group),currency:l.currency||"USD",inclusions:l.inclusions||null,exclusions:l.exclusions||null,deposit_terms:l.deposit_terms||null,deposit_pct:gu(l.deposit_pct),deposit_amount:gu(l.deposit_amount),deposit_due_date:l.deposit_due_date||null,source:l.source||null,source_link:l.source_link||null,group_minimum:l.group_minimum==null||l.group_minimum===""?null:Number(l.group_minimum),valid_until:l.valid_until||null,quote_text:l.quote_text||null,attachment_path:Q,attachment_name:oe};if(l.id){const{error:ze}=await F.from("experience_quotes").update(Pe).eq("id",l.id);if(ze)throw ze}else{const{error:ze}=await F.from("experience_quotes").insert(Pe);if(ze)throw ze}},onSuccess:()=>{m(!1),o(!1),P(),n({title:"Quote saved"})},onError:Q=>{m(!1),n({title:"Could not save quote",description:Q.message,variant:"destructive"})}}),R=Me({mutationFn:async Q=>{Q.attachment_path&&await F.storage.from("experience-resources").remove([Q.attachment_path]);const{error:oe}=await F.from("experience_quotes").delete().eq("id",Q.id);if(oe)throw oe},onSuccess:()=>{P(),n({title:"Quote deleted"})},onError:Q=>n({title:"Could not delete quote",description:Q.message,variant:"destructive"})}),[q,I]=y.useState(!1),[$,M]=y.useState(null),[B,W]=y.useState("Misc"),[A,K]=y.useState(""),G=Q=>{var ze;const oe=((ze=v.find(Je=>Je.id===Q.supplier_id))==null?void 0:ze.type)||"";W({Outfitter:"Outfitter",Hotel:"Lodging",Transfer:"Transportation",Restaurant:"Food/Bev","Materials/Swag vendor":"Materials"}
803[oe]||"Misc"),K(""),M(Q)},H=Me({mutationFn:async({q:Q,name:oe,description:Pe})=>{const ze=Q.amount_per_person!=null,Je=Number(ze?Q.amount_per_person:Q.amount_per_group||0),{data:Ae}=await F.from("experience_budget_items").select("sort_order").eq("experience_id",e),et=Math.max(0,...(Ae||[]).map(be=>be.sort_order||0)),{error:Ne}=await F.from("experience_budget_items").insert({experience_id:e,name:oe,description:Pe.trim()||null,category:"direct",cost_type:ze?"per_person":"flat",amount:Je,currency:Q.currency||"USD",includes_generators:!0,generator_count:0,sort_order:et+1,quote_id:Q.id});if(Ne)throw Ne},onSuccess:()=>{t.invalidateQueries({queryKey:["budget-items",e]}),P(),M(null),n({title:"Budget line created"})},onError:Q=>n({title:"Could not create budget line",description:Q.message,variant:"destructive"})}),fe=async Q=>{if(!Q.attachment_path)return;const{data:oe,error:Pe}=await F.storage.from("experience-resources").createSignedUrl(Q.attachment_path,300,{download:Q.attachment_name||"quote"});if(Pe){n({title:"Download failed",description:Pe.message,variant:"destructive"});return}const ze=document.createElement("a");ze.href=oe.signedUrl,ze.target="_blank",ze.click()},te=(Q,oe)=>c(Pe=>({...Pe,[Q]:oe})),[J,re]=y.useState(!1),[pe,ye]=y.useState([]),[X,he]=y.useState(""),[D,le]=y.useState(!1),{data:V=[]}=Ee({queryKey:["suppliers-contacts"],enabled:J,queryFn:async()=>{const{data:Q}=await F.from("suppliers").select("id, contact_name, contact_email");return Q||[]}}),U=async()=>{var Pe;const{data:Q}=await F.from("experiences").select("location, target_start_date, end_date, max_size, activity_level, outsourcing_level, inclusions").eq("id",e).maybeSingle(),oe=Q!=null&&Q.target_start_date?`${Wh(Q.target_start_date)}${Q.end_date?` â ${Wh(Q.end_date)}`:""}`:"TBD";return["Hello,","","Four Corners is planning a group trip and would love a quote from you. Details below:","",`⢠Location: ${(Q==null?void 0:Q.location)||"TBD"}`,`⢠Dates: ${oe}`,`⢠Group size (goal): ${(Q==null?void 0:Q.max_size)??"TBD"} participants`,`⢠Activity level: ${(Q==null?void 0:Q.activity_level)||"TBD"}`,`⢠Service level we're looking for: ${(Q==null?void 0:Q.outsourcing_level)||"TBD"}`,"","What we need included:",((Pe=Q==null?void 0:Q.inclusions)==null?void 0:Pe.trim())||"[Add inclusions here]","","Standing requirements for all our groups:","⢠60â90 minutes of protected group time each day (no scheduled activities)","⢠A private space where the group can gather for that time","","In your reply, please include:","⢠Per-person pricing","⢠Group minimum","⢠Deposit terms","⢠How long the quote is valid","","Thank you â we look forward to hearing from you.","","Best regards,","Four Corners"].join(` 804`)},z=async()=>{ye([]),he(await U()),re(!0)},Z=Q=>ye(oe=>oe.includes(Q)?oe.filter(Pe=>Pe!==Q):[...oe,Q]),ve=pe.map(Q=>{const oe=V.find(Pe=>Pe.id===Q);return oe!=null&&oe.contact_email?`${oe.contact_name||k(Q)} <${oe.contact_email}>`:`${k(Q)} (no email)`}).join(", "),ee=async()=>{const Q=ve?`To: ${ve} 805 806${X}`:X,oe=await ly(Q);n({title:oe?"Inquiry copied":"Copy failed",variant:oe?void 0:"destructive"})},de=async()=>{if(!pe.length)return;le(!0);const{error:Q}=await F.from("experience_quotes").insert(pe.map(oe=>({experience_id:e,supplier_id:oe,status:"Sent",sent_date:new Date().toLocaleDateString("en-CA"),quote_text:X})));if(le(!1),Q){n({title:"Could not create quotes",description:Q.message,variant:"destructive"});return}P(),n({title:`${pe.length} requested quote${pe.length>1?"s":""} created`}),re(!1)},je=Q=>a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-xs",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-muted-foreground border-b border-border",children:[a.jsx("th",{className:"text-left font-medium py-1 pr-2",children:"Supplier"}),a.jsx("th",{className:"text-left font-medium py-1 pr-2",children:"Status"}),a.jsx("th",{className:"text-left font-medium py-1 pr-2",children:"Sent"}),a.jsx("th",{className:"text-left font-medium py-1 pr-2",children:"Received"}),a.jsx("th",{className:"text-right font-medium py-1 pr-2",children:"Per person"}),a.jsx("th",{className:"text-right font-medium py-1 pr-2",children:"Per group"}),a.jsx("th",{className:"text-left font-medium py-1 pr-2",children:"Valid until"}),a.jsx("th",{className:"py-1"})]})}),a.jsx("tbody",{children:Q.map(oe=>a.jsxs("tr",{className:"border-b border-border/50 last:border-0 hover:bg-muted/40",children:[a.jsxs("td",{className:"py-1.5 pr-2",children:[a.jsx("button",{className:"hover:underline text-left",onClick:()=>O(oe),children:k(oe.supplier_id)}),a.jsx("button",{className:"ml-1 align-middle text-muted-foreground hover:text-foreground",onClick:()=>O(oe),title:"Edit quote","aria-label":"Edit quote",children:a.jsx(Rn,{className:"h-3 w-3 inline"})}),a.jsx(ide,{quote:oe,experienceId:e,label:k(oe.supplier_id)}),oe.attachment_path&&a.jsx("button",{className:"ml-1 align-middle text-muted-foreground hover:text-foreground",onClick:()=>fe(oe),title:oe.attachment_name||"Attachment",children:a.jsx(q3,{className:"h-3 w-3 inline"})})]}),a.jsxs("td",{className:"py-1.5 pr-2",children:[a.jsx("span",{className:`inline-block rounded-full border px-2 py-0.5 text-[10px] ${ode[w(oe.id)]}`,children:Lie[w(oe.id)]}),w(oe.id)==="requested"&&(oe.sent_date||oe.created_at)&&a.jsxs("span",{className:`ml-1.5 text-[10px] ${b1(oe.sent_date||oe.created_at.slice(0,10))>7?"text-amber-600 font-medium":"text-muted-foreground"}`,children:[b1(oe.sent_date||oe.created_at.slice(0,10)),"d since request"]})]}),a.jsx("td",{className:"py-1.5 pr-2 text-muted-foreground",children:Wh(oe.sent_date)}),a.jsx("td",{className:"py-1.5 pr-2 text-muted-foreground",children:Wh(oe.received_date)}),a.jsx("td",{className:"py-1.5 pr-2 text-right tabular-nums",children:oe.amount_per_person!=null?`${NA(oe.currency)}
806${Number(oe.amount_per_person).toLocaleString()}`:"â"}),a.jsx("td",{className:"py-1.5 pr-2 text-right tabular-nums",children:oe.amount_per_group!=null?`${NA(oe.currency)}${Number(oe.amount_per_group).toLocaleString()}`:"â"}),a.jsx("td",{className:"py-1.5 pr-2 text-muted-foreground",children:Wh(oe.valid_until)}),a.jsxs("td",{className:"py-1.5 text-right whitespace-nowrap",children:[w(oe.id)==="received"&&a.jsxs(Y,{size:"sm",variant:"outline",className:"h-6 text-[10px] mr-1",onClick:()=>G(oe),children:[a.jsx(I3,{className:"h-3 w-3 mr-1"})," Create budget line"]}),oe.attachment_path&&a.jsx(Y,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:()=>fe(oe),children:a.jsx(ja,{className:"h-3 w-3"})}),a.jsx(Y,{size:f===oe.id?"sm":"icon",variant:f===oe.id?"destructive":"ghost",className:f===oe.id?"h-6 px-2 text-[10px]":"h-6 w-6 text-muted-foreground",onClick:()=>{f===oe.id?(R.mutate(oe),x(null)):(x(oe.id),setTimeout(()=>x(Pe=>Pe===oe.id?null:Pe),3e3))},title:f===oe.id?"Click again to delete":"Delete quote",children:f===oe.id?"Click to delete":
806a.jsx(pn,{className:"h-3 w-3"})})]})]},oe.id))})]})});return a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Quotes (",p.length,")",(()=>{const Q=Lq(b);return Q.staleRequested+Q.unattached>0?a.jsxs("span",{className:"ml-2 normal-case tracking-normal font-normal",children:[Q.staleRequested>0&&a.jsxs("span",{className:"text-amber-600",children:[Q.staleRequested," no reply after 7d"]}),Q.staleRequested>0&&Q.unattached>0&&" · ",Q.unattached>0&&a.jsxs("span",{children:[Q.unattached," received, unattached"]})]}):null})()]}),a.jsxs("div",{className:"flex gap-1",children:[a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:z,children:[a.jsx(fs,{className:"h-3 w-3 mr-1"})," Draft inquiry"]}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:T,children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Log request"]}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:C,children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add received quote"]})]})]}),a.jsx(Dt,{open:J,onOpenChange:re,children:a.jsxs(Pt,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[a.jsxs(Ot,{children:[a.jsx(At,{children:"Draft supplier inquiry"}),a.jsx(wr,{children:"Built from the Trip Brief. Copy it into your email â nothing is sent from the app."})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Address to"}),a.jsxs("div",{className:"max-h-40 overflow-y-auto border border-border rounded-md p-2 space-y-1",children:[v.length===0&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"No suppliers in the directory."}),v.map(Q=>a.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[a.jsx(gt,{checked:pe.includes(Q.id),onCheckedChange:()=>Z(Q.id)}),Q.name," ",a.jsxs("span",{className:"text-muted-foreground",children:["â ",Q.type]})]},Q.id))]}),ve&&a.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["To: ",ve]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Email text"}),a.jsx(qt,{className:"text-xs min-h-[320px] font-mono",value:X,onChange:Q=>he(Q.target.value)})]})]}),a.jsxs(br,{className:"gap-2",children:[a.jsxs(Y,{variant:"outline",onClick:ee,children:[a.jsx(zv,{className:"h-3 w-3 mr-1"})," Copy"]}),a.jsx(Y,{onClick:de,disabled:!pe.length||D,children:D?"Creatingâ¦":`Log ${pe.length||""} requested quote${pe.length===1?"":"s"}`})]})]})}),p.length===0?a.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No quotes yet."}):a.jsxs(a.Fragment,{children:[_.length===0?a.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Nothing waiting â every quote is attached or settled."}):je(_),S.length>0&&a.jsxs("div",{className:"mt-2",children:[a.jsxs("button",{className:"text-[11px] text-muted-foreground hover:text-foreground",onClick:()=>j(Q=>!Q),children:[N?"â¾":"â¸"," Attached, not chosen & expired (",S.length,")"]}),N&&a.jsx("div",{className:"opacity-80 mt-1",children:je(S)})]})]}),a.jsx(Dt,{open:i,onOpenChange:o,children:a.jsxs(Pt,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[a.jsxs(Ot,{children:[a.jsx(At,{children:l.id?"Edit quote":"New quote"}),a.jsx(wr,{children:"Track a supplier quote for this experience."})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Supplier"}),a.jsx(Eb,{experienceId:e,value:l.supplier_id||null,onChange:Q=>te("supplier_id",Q)})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Status"}),a.jsxs(lt,{value:L?"Sent":l.status==="Declined"?"Declined":"Received",onValueChange:Q=>te("status",Q),children:[a.jsx(it,{className:"h-8 text-xs",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"Sent",className:"text-xs",children:"Requested (no price yet)"}),a.jsx(Oe,{value:"Received",className:"text-xs",children:"Received"}),a.jsx(Oe,{value:"Declined",className:"text-xs",children:"Not chosen"})]})]}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Chosen is set by attaching to a budget line; Expired comes from Valid until."})]}),L?a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Date sent"}),a.jsx(ce,{type:"date",className:"h-8 text-xs",value:l.sent_date||"",onChange:Q=>te("sent_date",Q.target.value||null)})]}):a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Quoted"}),a.jsx(ce,{type:"date",className:"h-8 text-xs",value:l.received_date||"",onChange:Q=>te("received_date",Q.target.value||null)})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Amount per person"}),a.jsx(ce,{type:"text",inputMode:"decimal",className:"h-8 text-xs",value:l.amount_per_person??"",onChange:Q=>te("amount_per_person",Q.target.value)})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Amount per group"}),a.jsx(ce,{type:"text",inputMode:"decimal",className:"h-8 text-xs",value:l.amount_per_group??"",onChange:Q=>te("amount_per_group",Q.target.value)})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Currency"}),a.jsxs(lt,{value:l.currency||"USD",onValueChange:Q=>te("currency",Q),children:[a.jsx(it,{className:"h-8 text-xs",children:a.jsx(ct,{})}),a.jsx(ot,{children:["USD","EUR","GBP","CHF","CAD"].map(Q=>a.jsx(Oe,{value:Q,className:"text-xs",children:Q},Q))})]})]}),l.id&&l.created_at&&a.jsxs("p",{className:"col-span-2 text-[10px] text-muted-foreground",children:["Recorded ",new Date(l.created_at).toLocaleStr
806ing()," (system)"]}),l.valid_until&&l.valid_until<new Date().toLocaleDateString("en-CA")&&a.jsx("p",{className:"col-span-2 text-xs text-amber-600",children:"Valid-until is in the past â lines using this quote will be flagged as holding an expired quote."}),q?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Group minimum"}),a.jsx(ce,{type:"number",min:"0",className:"h-8 text-xs",value:l.group_minimum??"",onChange:Q=>te("group_minimum",Q.target.value===""?null:Number(Q.target.value))})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Sent date"}),a.jsx(ce,{type:"date",className:"h-8 text-xs",value:l.sent_date||"",onChange:Q=>te("sent_date",Q.target.value||null)})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Deposit terms"}),a.jsx(ce,{className:"h-8 text-xs",value:l.deposit_terms||"",onChange:Q=>te("deposit_terms",Q.target.value)})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Deposit % or amount"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx(ce,{type:"text",inputMode:"decimal",className:"h-8 text-xs",placeholder:"%",value:l.deposit_pct??"",onChange:Q=>te("deposit_pct",Q.target.value)}),a.jsx(ce,{type:"text",inputMode:"decimal",className:"h-8 text-xs",placeholder:"$",value:l.deposit_amount??"",onChange:Q=>te("deposit_amount",Q.target.value)})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Deposit due date"}),a.jsx(ce,{type:"date",className:"h-8 text-xs",value:l.deposit_due_date||"",onChange:Q=>te("deposit_due_date",Q.target.value||null)})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Source"}),a.jsx(ce,{className:"h-8 text-xs",placeholder:"e.g. Email from outfitter",value:l.source||"",onChange:Q=>te("source",Q.target.value)})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Source link"}),a.jsx(ce,{className:"h-8 text-xs",placeholder:"https://â¦",value:l.source_link||"",onChange:Q=>te("source_link",Q.target.value)})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Valid until"}),a.jsx(ce,{type:"date",className:"h-8 text-xs",value:l.valid_until||"",onChange:Q=>te("valid_until",Q.target.value||null)})]}),a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Inclusions"}),a.jsx(qt,{className:"text-xs min-h-[60px]",value:l.inclusions||"",onChange:Q=>te("inclusions",Q.target.value)})]}),a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Exclusions"}),a.jsx(qt,{className:"text-xs min-h-[60px]",value:l.exclusions||"",onChange:Q=>te("exclusions",Q.target.value)})]}),a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Quote text"}),a.jsx(qt,{className:"text-xs min-h-[100px]",placeholder:"Paste the supplier's email or a summary of the attachment",value:l.quote_text||"",onChange:Q=>te("quote_text",Q.target.value)})]}),a.jsxs("div",{className:"space-y-1 col-span-2",children:[a.jsx(xe,{className:"text-xs",children:"Attachment"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{ref:g,type:"file",className:"hidden",onChange:Q=>{var oe;return d(((oe=Q.target.files)==null?void 0:oe[0])||null)}}),a.jsxs(Y,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>{var Q;return(Q=g.current)==null?void 0:Q.click()},children:[a.jsx(nH,{className:"h-3 w-3 mr-1"})," Choose file"]}),a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:(u==null?void 0:u.name)||l.attachment_name||"No file"})]})]})]}):a.jsx(Y,{variant:"link",size:"sm",className:"col-span-2 h-auto p-0 text-xs justify-start",onClick:()=>I(!0),children:"+ More details (inclusions, deposit terms, valid until, link, attachmentâ¦)"})]}),a.jsxs(br,{children:[a.jsx(Y,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),a.jsx(Y,{onClick:()=>E.mutate(),disabled:h,children:h?"Savingâ¦":"Save"})]})]})}),a.jsx(Dt,{open:!!$,onOpenChange:Q=>!Q&&M(null),children:a.jsxs(Pt,{className:"sm:max-w-sm",children:[a.jsxs(Ot,{children:[a.jsx(At,{children:"Create budget line from quote"}),a.jsxs(wr,{children:["Adds a Quoted line linked to ",$?k($.supplier_id):"",", using the quote's amount, basis and valid-until date."]})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Category"}),a.jsxs(lt,{value:B,onValueChange:W,children:[a.jsx(it,{className:"h-8 text-xs",children:a.jsx(ct,{})}),a.jsx(ot,{children:s.map(Q=>a.jsx(Oe,{value:Q,children:Q},Q))})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{className:"text-xs",children:"Description"}),a.jsx(ce,{className:"h-8 text-xs",value:A,onChange:Q=>K(Q.target.value),placeholder:"e.g. Airport hotel, night 1"})]})]}),a.jsxs(br,{children:[a.jsx(Y,{variant:"outline",onClick:()=>M(null),children:"Cancel"}),a.jsx(Y,{disabled:H.isPending,onClick:()=>$&&H.mutate({q:$,name:B,description:A}),children:H.isPending?"Creatingâ¦":"Create line"})]})]})})]})}const vx=[{key:"prepaid_released",label:"Prepaid costs released"},{key:"swag_allocated",label:"Swag allocated"},{key:"deposits_cleared",label:"Refundable deposits cleared"},{key:"revenue_recognized",label:"Revenue recognized"},{key:"survey_sent",label:"Survey sent"},{key:"slideshow_compiled",label:"Slideshow compiled"},{key:"website_page_created",label:"4C website trip page created"},{key:"felt_cards_sent",label:"Felt cards sent"},{key:"followup_held",label:"Follow-up meeting held"}];function ude(e){return Ee({queryKey:["closeout",e],queryFn:async()=>{const[{data:t,error:n},{data:r,error:s}]=await Promise.all([F.from("experience_closeout_checks").select("item_key, checked_by_email, checked_at").eq("experience_id",e),F.from("experience_budget_items").select("id, is_closed, spent_to_date").eq("experience_id",e)]);if(n)throw n;if(s)throw s;const i=(r||[]).filter(u=>!u.is_closed||u.spent_to_date==null).length,o={};for(const u of t||[])o[u.item_key]=u;const l=i===0,c=l&&vx.every(u=>o[u.key]);return{map:o,suppliersPaid:l,openLines:i,totalLines:(r||[]).length,allDone:c}}})}function dde({experienceId:e}){const t=at(),{toast:n}=mt(),{data:r}=ude(e),s=Me({mutationFn:async({key:l,on:c})=>{var m,f;const u=F.from("experience_closeout_checks"),{data:d}=await F.auth.getUser(),{error:h}=c?await u.insert({experience_id:e,item_key:l,checked_by:(m=d.user)==null?void 0:m.id,checked_by_email:(f=d.user)==null?void 0:f.email}):await u.delete().eq("experience_id",e).eq("item_key",l);if(h)throw h},onSuccess:()=>
806t.invalidateQueries({queryKey:["closeout",e]}),onError:l=>n({title:"Error",description:l.message,variant:"destructive"})});if(!r)return null;const i=vx.filter(l=>r.map[l.key]).length+(r.suppliersPaid?1:0),o=l=>l?`${l.checked_by_email??"Unknown"} · ${Ye(new Date(l.checked_at),"yyyy-MM-dd h:mm a")}`:"";return a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[a.jsx(ZK,{className:"h-4 w-4"})," Closeout"]}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:[i," of ",vx.length+1," done"]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(gt,{checked:r.suppliersPaid,disabled:!0,className:"mt-0.5"}),a.jsxs("div",{className:"text-sm",children:["Every budget line closed with a Spent amount recorded",a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Automatic â ",r.suppliersPaid?"every budget line is closed with Spent recorded":`${r.openLines} of ${r.totalLines} budget lines open or missing a Spent amount`]})]})]}),vx.map(l=>{const c=r.map[l.key];return a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx(gt,{checked:!!c,disabled:s.isPending,onCheckedChange:u=>s.mutate({key:l.key,on:!!u}),className:"mt-0.5"}),a.jsxs("div",{className:"text-sm",children:[l.label,c&&a.jsx("div",{className:"text-xs text-muted-foreground",children:o(c)})]})]},l.key)})]}),!r.allDone&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"All items must be done before this can be marked Completed."})]})}const Lw=e=>e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),hde=.15;function SA(e,t){return t==null?!1:e===0?t!==0:Math.abs(t-e)/Math.abs(e)>hde}function fde({experienceId:e}){const t=at(),{toast:n}=mt(),r=["reconciliation",e],{data:s}=Ee({queryKey:r,queryFn:async()=>{const _=F,[{data:S,error:P},{data:k,error:C},{data:T,error:O},{data:L}]=await Promise.all([_.from("experiences").select("status, completed_at, variance_reviewed, final_margin, reconciled_at, reconciled_by_email").eq("id",e).single(),F.from("experience_budget_items").select("id, name").eq("experience_id",e),_.from("experience_reconciliation_lines").select("*").eq("experience_id",e),_.from("qbo_actual_lines").select("category, amount").eq("experience_id",e)]);if(P)throw P;if(C)throw C;if(O)throw O;const E=await Promise.all((k||[]).map(async $=>{const{data:M}=await F.rpc("compute_budget_item_total",{_item_id:$.id});return[$.name,Number(M||0)]})),R={};for(const[$,M]of E)R[$]=(R[$]||0)+M;const q={};for(const $ of L||[])$.category&&(q[$.category]=(q[$.category]||0)+Number($.amount||0));const I=Object.keys(R).sort().map($=>{const M=(T||[]).find(B=>B.category===$);return{category:$,budget:R[$],imported:q[$]??null,actual:(M==null?void 0:M.qbo_actual)??null,note:(M==null?void 0:M.variance_note)??"",noteBy:(M==null?void 0:M.note_by_email)??null,noteAt:(M==null?void 0:M.note_updated_at)??null}});return{exp:S,rows:I}}}),[i,o]=y.useState({}),[l,c]=y.useState({}),[u,d]=y.useState("");if(y.useEffect(()=>{s&&(o(Object.fromEntries(s.rows.map(_=>[_.category,_.actual==null?"":String(_.actual)]))),c(Object.fromEntries(s.rows.map(_=>[_.category,_.note]))),d(s.exp.final_margin==null?"":String(s.exp.final_margin)))},[s]),!s)return null;const{exp:h,rows:m}=s,f=h.status==="completed",x=!!h.reconciled_at,g=!f||x,p=async(_,S)=>{var T;const{data:P}=await F.auth.getUser(),k={experience_id:e,category:_};if(S.actual!==void 0){const O=S.actual.trim()===""?null:Number(S.actual.replace(/[$,]/g,""));if(O!=null&&!Number.isFinite(O))return n({title:"Enter a number",variant:"destructive"});k.qbo_actual=O}S.note!==void 0&&(k.variance_note=S.note,k.note_by_email=(T=P.user)==null?void 0:T.email,k.note_updated_at=new Date().toISOString());const{error:C}=await F.from("experience_reconciliation_lines").upsert(k,{onConflict:"experience_id,category"});if(C){n({title:"Error",description:C.message,variant:"destructive"}),t.invalidateQueries({queryKey:r});return}
806t.invalidateQueries({queryKey:r})},v=async _=>{const{error:S}=await F.from("experiences").update(_).eq("id",e);S&&n({title:"Can't save",description:S.message,variant:"destructive"}),t.invalidateQueries({queryKey:r}),t.invalidateQueries({queryKey:["reconciliation-backlog"]})},b=async()=>{var S,P;const{data:_}=await F.auth.getUser();v({reconciled_at:new Date().toISOString(),reconciled_by:(S=_.user)==null?void 0:S.id,reconciled_by_email:(P=_.user)==null?void 0:P.email})},w=m.every(_=>_.actual!=null),N=m.every(_=>!SA(_.budget,_.actual)||_.note.trim()),j=f&&w&&h.variance_reviewed&&N&&h.final_margin!=null;return a.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[a.jsx(B3,{className:"h-4 w-4"})," Reconciled"]}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Ge,{variant:f?"default":"outline",children:f?"Complete":"Not complete"}),a.jsx(Ge,{variant:x?"default":"outline",children:x?"Reconciled":"Not reconciled"})]})]}),!f&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Available once closeout is complete and the experience is marked Completed. Variance notes can be written any time."}),x&&a.jsxs("p",{className:"text-sm",children:["Signed by ",h.reconciled_by_email??"Unknown"," · ",Ye(new Date(h.reconciled_at),"yyyy-MM-dd h:mm a")]}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{className:"text-xs text-muted-foreground",children:a.jsxs("tr",{children:[a.jsx("th",{className:"text-left py-1",children:"Category"}),a.jsx("th",{className:"text-left",children:"Budget"}),a.jsx("th",{className:"text-left",children:"QuickBooks actual"}),a.jsx("th",{className:"text-left",children:"Variance"})]})}),a.jsx("tbody",{children:m.map(_=>{const S=_.actual,P=S==null||_.budget===0?null:(S-_.budget)/Math.abs(_.budget),k=SA(_.budget,S);return a.jsxs("tr",{className:"border-t align-top",children:[a.jsx("td",{className:"py-2 pr-2 font-medium",children:_.category}),a.jsx("td",{className:"py-2 pr-2",children:Lw(_.budget)}),a.jsxs("td",{className:"py-2 pr-2",children:[a.jsx(ce,{type:"text",inputMode:"decimal",className:"h-8 w-28",disabled:g,value:i[_.category]??"",onChange:C=>o(T=>({...T,[_.category]:C.target.value})),onBlur:C=>{C.target.value!==(_.actual==null?"":String(_.actual))&&p(_.category,{actual:C.target.value})}}),_.imported!=null&&!g&&a.jsxs("button",{className:"text-xs text-muted-foreground hover:underline",onClick:()=>p(_.category,{actual:String(_.imported)}),children:["Imported: ",Lw(_.imported)]})]}),a.jsxs("td",{className:"py-2",children:[S==null?a.jsx("span",{className:"text-muted-foreground",children:"â"}):a.jsxs("span",{className:k?"text-destructive font-medium":"",children:[Lw(S-_.budget),P!=null&&` (${(P*100).toFixed(0)}%)`]}),(k||_.note)&&a.jsxs("div",{className:"mt-1",children:[a.jsx(qt,{rows:2,placeholder:"Why did this cost what it did? (required over 15%)",className:"text-xs",value:l[_.category]??"",onChange:C=>c(T=>({...T,[_.category]:C.target.value})),onBlur:C=>{C.target.value!==_.note&&p(_.category,{note:C.target.value})}}),_.noteBy&&a.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[_.noteBy," · ",_.noteAt&&Ye(new Date(_.noteAt),"yyyy-MM-dd")]})]})]})]},_.category)})})]})}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[a.jsx(gt,{checked:h.variance_reviewed,disabled:g,onCheckedChange:_=>v({variance_reviewed:!!_})}),"Variance reviewed"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm",children:["Final margin (%)",a.jsx(ce,{type:"text",inputMode:"decimal",className:"h-8 w-24",disabled:g,value:u,onChange:_=>d(_.target.value),onBlur:_=>{const S=_.target.value.trim()===""?null:Number(_.target.value.replace(/[%,]/g,""));if(S!=null&&!Number.isFinite(S))return n({title:"Enter a number",variant:"destructive"});S!==h.final_margin&&v({final_margin:S})}})]})]}),f&&!x&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Y,{size:"sm",disabled:!j,onClick:b,children:"Sign as Reconciled"}),!j&&a.jsx("span",{className:"text-xs text-muted-foreground",children:"Needs every QuickBooks actual, variance reviewed, a note on each variance over 15%, and final margin."})]}),x&&a.jsx(Y,{size:"sm",variant:"outline",onClick:()=>v({reconciled_at:null,reconciled_by:null,reconciled_by_email:null}
806),children:"Reopen reconciliation"})]})}function mde({experienceId:e}){const t=at(),{toast:n}=mt(),[r,s]=y.useState(!1),[i,o]=y.useState(null),{data:l}=Ee({queryKey:["experience-planning-notes",e],queryFn:async()=>{const{data:h,error:m}=await F.from("experiences").select("planning_notes").eq("id",e).single();if(m)throw m;return h}});y.useEffect(()=>{o(null),s(!1)},[e]);const c=i??(l==null?void 0:l.planning_notes)??"",u=i!==null&&i!==((l==null?void 0:l.planning_notes)??""),d=Me({mutationFn:async h=>{const{error:m}=await F.from("experiences").update({planning_notes:h||null}).eq("id",e);if(m)throw m},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-planning-notes",e]}),t.invalidateQueries({queryKey:["experiences"]}),o(null),n({title:"Planning notes saved"})},onError:h=>{n({title:"Save failed",description:h.message,variant:"destructive"})}});return a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5",children:[a.jsx(wH,{className:"h-3.5 w-3.5"})," Planning Notes",c&&a.jsx("span",{className:"text-[10px] text-primary",children:"(set)"})]}),r?a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),r&&a.jsxs("div",{className:"mt-2 space-y-2",children:[a.jsx(qt,{value:c,onChange:h=>o(h.target.value),placeholder:"Add planning notes for the team⦠e.g. Recommend eating dinner in the back room at ABC Restaurant on Saturday.",className:"min-h-[120px] text-xs"}),u&&a.jsxs(Y,{size:"sm",className:"h-7 text-xs gap-1",disabled:d.isPending,onClick:()=>d.mutate(i),children:[d.isPending?a.jsx(vt,{className:"h-3 w-3 animate-spin"}):a.jsx(z3,{className:"h-3 w-3"}),"Save"]})]})]})}function pde({experienceId:e}){const t=at(),{toast:n}=mt(),[r,s]=y.useState(!1),[i,o]=y.useState(null),[l,c]=y.useState(!1),{data:u,isLoading:d}=Ee({queryKey:["experience-prep-guide",e],queryFn:async()=>{const{data:p,error:v}=await F.from("experiences").select("training_plan, activity_type, location, target_start_date, name").eq("id",e).single();if(v)throw v;return p}}),h=i??(u==null?void 0:u.training_plan)??"",m=Me({mutationFn:async()=>{const{data:p,error:v}=await F.functions.invoke("generate-training-plan",{body:{experience_id:e}});if(v)throw v;return p},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-prep-guide",e]}),t.invalidateQueries({queryKey:["experiences"]}),o(null),c(!1),n({title:"Preparation guide generated"})},onError:p=>{n({title:"Generation failed",description:p.message,variant:"destructive"})}}),f=Me({mutationFn:async p=>{const{error:v}=await F.from("experiences").update({training_plan:p||null}).eq("id",e);if(v)throw v},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-prep-guide",e]}),t.invalidateQueries({queryKey:["experiences"]}),o(null),c(!1),n({title:"Preparation guide saved"})},onError:p=>{n({title:"Save failed",description:p.message,variant:"destructive"})}}),x=i!==null&&i!==((u==null?void 0:u.training_plan)??""),g=!!(u!=null&&u.activity_type);return a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5",children:[a.jsx(vc,{className:"h-3.5 w-3.5"})," Preparation Guide",h&&a.jsx("span",{className:"text-[10px] text-primary",children:"(set)"})]}),r?a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),r&&a.jsxs("div",{className:"mt-2 space-y-2",children:[!g&&!h&&a.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Set an activity type on this experience to enable AI generation."}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsxs(Y,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",disabled:!g||m.isPending,onClick:()=>m.mutate(),children:[m.isPending?a.jsx(vt,{className:"h-3 w-3 animate-spin"}):a.jsx(Uv,{className:"h-3 w-3"}),h?"Regenerate":"Generate"]}),x&&a.jsxs(Y,{size:"sm",className:"h-7 text-xs gap-1",disabled:f.isPending,onClick:()=>f.mutate(i),children:[f.isPending?a.jsx(vt,{className:"h-3 w-3 animate-spin"}):a.jsx(z3,{className:"h-3 w-3"}),"Save"]})]}),(h||l)&&a.jsx(qt,{value:h,onChange:p=>{o(p.target.value),l||c(!0)},onFocus:()=>c(!0),placeholder:"Write or generate a preparation guideâ¦",className:"min-h-[160px] text-xs font-mono"}),!h&&!l&&g&&a.jsx("button",{onClick:()=>c(!0),className:"text-xs text-muted-foreground hover:text-foreground underline",children:"Or write manuallyâ¦"})]})]})}const Mb=o8,Db=Lk,$b=qk,C8=["Hiking Experience","Skiing Experience","Mountain Biking Experience","Pilgrimage","Paddling Experience","Peer Group","1:1 Coaching","Couples Experience","Donate to Four Corners Leadership Fund for Non-Profit Leaders","Form a Private Experience"],gde=[{id:"q1",label:"Overall rating of this experience",type:"rating",required:!0,is_future_interest:!1},{id:"q1b",label:"What value will this experience have for you?",type:"text",required:!1,is_future_interest:!1},{id:"q2",label:"What went well?",type:"text",required:!1,is_future_interest:!1},{id:"q3",label:"What could be improved?",type:"text",required:!1,is_future_interest:!1},{id:"q3a",label:"How would you rate your ability to make the most meaningful choices with your time, energy and money BEFORE starting this experience?",type:"rating_10",required:!1,is_future_interest:!1},{id:"q3b",label:"How would you rate your ability to make the most meaningful choices with your time, energy and money AFTER completing this experience?",type:"rating_10",required:!1,is_future_interest:!1},{id:"q4",label:"Would you recommend this experience to a friend?",type:"yes_no",required:!1,is_future_interest:!1},{id:"q5",label:"Any additional comments?",type:"text",required:!1,is_future_interest:!1},{id:"future_interest",label:"What types of future experiences interest you?",type:"multi_select",required:!0,is_future_interest:!0,options:C8}],xde=[{id:"pg1",label:"Overall rating of the trip",type:"rating",required:!0,is_future_interest:!1},{id:"pg2",label:"Overall rating of the year of peer group meetings",type:"rating",required:!1,is_future_interest:!1},{id:"pg3",label:"Overall rating of the year of 1:1 coaching",type:"rating",required:!1,is_future_interest:!1},{id:"pg4",label:"What value will this experience have for you - the peer group, the coaching, and trip?",type:"text",required:!1,is_future_interest:!1},{id:"q2",label:"What went well?",type:"text",required:!1,is_future_interest:!1},{id:"q3",label:"What could be improved?",type:"text",required:!1,is_future_interest:!1},{id:"q3a",label:"How would you rate your ability to make the most meaningful choices with your time, energy and money BEFORE starting this experience?",type:"rating_10",required:!1,is_future_interest:!1},{id:"q3b",label:"How would you rate your ability to make the most meaningful choices with your time, energy and money AFTER completing this experience?",type:"rating_10",required:!1,is_future_interest:!1},{id:"q4",label:"Would you recommend this experience to a friend?",type:"yes_no",required:!1,is_future_interest:!1},{id:"q5",label:"Any additional comments?",type:"text",required:!1,is_future_interest:!1},{id:"future_interest",label:"What types of future experiences interest you?",type:"multi_select",required:!0,is_future_interest:!0,options:C8}],yde={rating:"Rating (1-5)",rating_10:"Rating (1-10)",text:"Text",yes_no:"Yes / No",multi_select:"Multi-Select"};function vde(){return"q_"+Math.random().toString(36).substring(2,9)}function bde({experienceId:e}){const t=at(),{toast:n}=mt(),[r,s]=y.useState(!1),[i,o]=y.useState([]),[l,c]=y.useState(""),[u,d]=y.useState(!1),{data:h,isLoading:m}=Ee({queryKey:["experience-survey",e],queryFn:async()=>{const{data:j,error:_}=await F.from("experience_surveys").select("*").eq("experience_id",e).maybeSingle();if(_)throw _;return j}}),{data:f}=Ee({queryKey:["experience-type-for-survey",e],queryFn:async()=>{const{data:j,error:_}=await F.from("experiences").select("type").eq("id",e).maybeSingle();if(_)throw _;return(j==null?void 0:j.type)??null}});y.useEffect(()=>{h&&(o(h.questions||[]),c(h.show_date||"")),d(!1)}
806,[h]);const x=Me({mutationFn:async()=>{if(!l)throw new Error("Survey visible from date is required");const j={experience_id:e,show_date:l,questions:JSON.parse(JSON.stringify(i))};if(h){const{error:_}=await F.from("experience_surveys").update(j).eq("id",h.id);if(_)throw _}else{const{error:_}=await F.from("experience_surveys").insert(j);if(_)throw _}},onSuccess:()=>{t.invalidateQueries({queryKey:["experience-survey",e]}),d(!1),n({title:"Survey saved"})},onError:j=>n({title:"Error",description:j.message,variant:"destructive"})}),g=()=>{o(f==="peer_group"?xde:gde),d(!0)},p=()=>{o(j=>[...j,{id:vde(),label:"",type:"text",required:!1,is_future_interest:!1}]),d(!0)},v=(j,_)=>{o(S=>S.map((P,k)=>k===j?{...P,..._}:P)),d(!0)},b=j=>{i[j].is_future_interest||(o(_=>_.filter((S,P)=>P!==j)),d(!0))},w=(j,_)=>{const S=j+_;if(S<0||S>=i.length)return;const P=[...i];[P[j],P[S]]=[P[S],P[j]],o(P),d(!0)},N=!!h||i.length>0;return a.jsx("div",{className:"border-t border-border pt-3",children:a.jsxs(Mb,{open:r,onOpenChange:s,children:[a.jsx(Db,{asChild:!0,children:a.jsxs("button",{className:"flex items-center justify-between w-full text-left group",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5",children:[a.jsx(em,{className:"h-3.5 w-3.5"}),"Survey ",N&&a.jsx("span",{className:"text-primary",children:"·"}),l&&a.jsxs("span",{className:"normal-case font-normal text-[10px]",children:["shows ",l]})]}),r?a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),a.jsxs($b,{className:"mt-2 space-y-3",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"text-[10px] text-muted-foreground",children:["Survey visible from ",a.jsx("span",{className:"text-destructive",children:"*"})]}),a.jsx(ce,{type:"date",value:l,onChange:j=>{c(j.target.value),d(!0)},className:"h-8 text-xs",required:!0}),!l&&i.length>0&&a.jsx("p",{className:"text-[10px] text-destructive mt-0.5",children:"Required to save the survey"})]}),i.length===0&&!m&&a.jsxs("div",{className:"text-center py-4",children:[a.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"No survey configured yet."}),a.jsxs(Y,{variant:"outline",size:"sm",className:"text-xs",onClick:g,children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Initialize Default Survey"]})]}),i.map((j,_)=>a.jsx("div",{className:"rounded border border-border bg-background p-2 space-y-1.5",children:a.jsxs("div",{className:"flex items-start gap-1",children:[a.jsxs("div",{className:"flex flex-col gap-0.5 pt-1",children:[a.jsx("button",{className:"text-muted-foreground hover:text-foreground disabled:opacity-30",onClick:()=>w(_,-1),disabled:_===0,children:a.jsx(_r,{className:"h-3 w-3"})}),a.jsx("button",{className:"text-muted-foreground hover:text-foreground disabled:opacity-30",onClick:()=>w(_,1),disabled:_===i.length-1,children:a.jsx(_n,{className:"h-3 w-3"})})]}),a.jsxs("div",{className:"flex-1 space-y-1.5",children:[a.jsx(ce,{value:j.label,onChange:S=>v(_,{label:S.target.value}),placeholder:"Question text",className:"h-7 text-xs"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(lt,{value:j.type,onValueChange:S=>v(_,{type:S,options:S==="multi_select"?j.options||[""]:void 0}),disabled:j.is_future_interest,children:[a.jsx(it,{className:"h-7 text-xs w-32",children:a.jsx(ct,{})}),a.jsx(ot,{children:Object.entries(yde).map(([S,P])=>a.jsx(Oe,{value:S,children:P},S))})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(ta,{checked:j.required,onCheckedChange:S=>v(_,{required:S}),className:"scale-75",disabled:j.is_future_interest}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Required"})]}),j.is_future_interest&&a.jsx("span",{className:"text-[10px] text-primary font-medium ml-auto",children:"Future Interest"})]}),j.type==="multi_select"&&j.options&&a.jsxs("div",{className:"space-y-1 pl-1",children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Options"}),j.options.map((S,P)=>a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(ce,{value:S,onChange:k=>{const C=[...j.options||[]];C[P]=k.target.value,v(_,{options:C})},className:"h-6 text-[11px] flex-1",placeholder:"Option text"}),a.jsx("button",{className:"text-destructive hover:text-destructive/80",onClick:()=>{const k=(j.options||[]).filter((C,T)=>T!==P);v(_,{options:k})},children:a.jsx(pn,{className:"h-3 w-3"})})]},P)),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-5 text-[10px] px-1",onClick:()=>v(_,{options:[...j.options||[],""]}),children:[a.jsx(zt,{className:"h-2.5 w-2.5 mr-0.5"})," Add Option"]})]})]}),!j.is_future_interest&&a.jsx("button",{className:"text-destructive hover:text-destructive/80 mt-1",onClick:()=>b(_),children:a.jsx(pn,{className:"h-3.5 w-3.5"})})]})},j.id)),i.length>0&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:p,children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add Question"]}),u&&a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>x.mutate(),disabled:x.isPending||!l,children:"Save Survey"})]})]})]})})}const k8="activity-uploads";async function E8(e){try{const{data:t}=await F.auth.getUser(),n=t==null?void 0:t.user;if(!n)return;await F.from("document_downloads").insert({file_path:e.filePath,file_name:e.fileName??null,experience_id:e.experienceId??null,contact_id:e.contactId??null,activity_response_id:e.activityResponseId??null,downloaded_by:n.id,downloaded_by_email:n.email??null})}catch{}}async function wde(e,t=300){const{data:n,error:r}=await F.storage.from(k8).createSignedUrl(e,t,{download:!0});if(r)throw r;return n.signedUrl}async function P8(e){const t=await wde(e.filePath);await E8(e);const n=document.createElement("a");n.href=t,n.download=e.fileName||e.filePath.split("/").pop()||"document",n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()}async function _de(e){const{data:t,error:n}=await F.storage.from(k8).download(e);if(n)throw n;return t}
806function jde({experienceId:e}){const[t,n]=y.useState(!1),[r,s]=y.useState(null),{data:i=[]}=Ee({queryKey:["experience-form-responses-contacts",e],queryFn:async()=>{const{data:T,error:O}=await F.from("contact_experiences").select("id, status, contacts:contacts!contact_experiences_contact_id_fkey(id, name, email)").eq("experience_id",e).in("status",["accepted","gen_guide"]).order("status");if(O)throw O;return T},enabled:t}),{data:o=[]}=Ee({queryKey:["experience-form-responses-generators",e],queryFn:async()=>{const{data:T,error:O}=await F.from("generator_experiences").select("id, generators(id, name)").eq("experience_id",e);if(O)throw O;return T},enabled:t}),{data:l=[]}=Ee({queryKey:["experience-form-fields-report",e],queryFn:async()=>{const{data:T,error:O}=await F.from("activities").select("id, description, field_type, field_options, sort_order").eq("experience_id",e).is("contact_id",null).eq("type","form-field").order("sort_order");if(O)throw O;return T},enabled:t}),c=i.map(T=>T.id),u=o.map(T=>T.id),{data:d=[]}=Ee({queryKey:["experience-form-activity-responses",e,c,u],queryFn:async()=>{if(c.length===0&&u.length===0)return[];const T=[];c.length>0&&T.push(`contact_experience_id.in.(${c.join(",")})`),u.length>0&&T.push(`generator_experience_id.in.(${u.join(",")})`);const{data:O,error:L}=await F.from("activity_responses").select("*").or(T.join(","));if(L)throw L;return O},enabled:t&&(c.length>0||u.length>0)}),h=y.useMemo(()=>{const T=i.map(E=>{var R,q;return{id:E.id,name:((R=E.contacts)==null?void 0:R.name)||"Unknown",isTeam:E.status==="gen_guide",contactId:((q=E.contacts)==null?void 0:q.id)??null}}),O=new Set(T.map(E=>E.name.trim().toLowerCase())),L=o.map(E=>{var R;return{id:E.id,name:((R=E.generators)==null?void 0:R.name)||"Unknown",isTeam:!0,contactId:null}}).filter(E=>!O.has(E.name.trim().toLowerCase()));return[...T,...L]},[i,o]),m=y.useMemo(()=>{const T=[];let O={label:"General",fieldIds:[]};for(const L of l)L.field_type==="section_header"?((O.fieldIds.length>0||T.length===0)&&O.fieldIds.length>0&&T.push(O),O={label:L.description,fieldIds:[]}):["section_header","information"].includes(L.field_type)||O.fieldIds.push(L.id);return O.fieldIds.length>0&&T.push(O),T},[l]),[f,x]=y.useState(null),g=f??new Set(m.map(T=>T.label)),p=l.filter(T=>!["section_header","information"].includes(T.field_type)),v=y.useMemo(()=>{const T=new Set;return m.forEach(O=>{g.has(O.label)&&O.fieldIds.forEach(L=>T.add(L))}),T},[m,g]),b=p.filter(T=>v.has(T.id)),w=new Map;d.forEach(T=>{const O=T.contact_experience_id||T.generator_experience_id;O&&(w.has(O)||w.set(O,new Map),w.get(O).set(T.activity_id,T))});const N=p.length>0,j=h.filter(T=>w.has(T.id)).length,_=(T,O)=>{if(!O)return"";const{field_type:L}=T;return L==="agreement"||L==="task"?O.response_bool?"Yes":"No":L==="file_upload"?O.response_file_name||"":O.response_text||""},S=async(T,O)=>{try{await P8({filePath:T.response_file_path,fileName:T.response_file_name,experienceId:e,contactId:O,activityResponseId:T.id})}catch(L){Mt.error((L==null?void 0:L.message)||"Could not download the file")}},P=(T,O,L,E=null)=>{if(!O)return a.jsx("span",{className:"text-muted-foreground text-[10px]",children:"â"});const{field_type:R}=T;return R==="agreement"||R==="task"?O.response_bool?a.jsx(Mr,{className:"h-3.5 w-3.5 text-emerald-600"}):a.jsx(Ht,{className:"h-3.5 w-3.5 text-muted-foreground"}):R==="file_upload"?O.response_file_path?a.jsxs("button",{type:"button",className:"flex items-center gap-1 text-primary hover:underline max-w-[140px]",onClick:q=>{q.stopPropagation(),S(O,E)},title:`Download ${O.response_file_name||"file"}`,children:[a.jsx(Hs,{className:"h-3 w-3 shrink-0"}),a.jsx("span",{className:"truncate",children:O.response_file_name||"Download"})]}):a.jsx("span",{className:"text-muted-foreground text-[10px]",children:"â"}):O.response_text?a.jsx("span",{className:Se("block",L?"whitespace-pre-wrap":"truncate max-w-[150px]"),children:O.response_text}):a.jsx("span",{className:"text-muted-foreground text-[10px]",children:"â"})},k=y.useCallback(()=>{if(!N||h.length===0)return;const T=b,O=["Name","Role",...T.map(M=>M.description)],L=h.map(M=>{const B=w.get(M.id);return[M.name,M.isTeam?"Team":"Participant",...T.map(W=>_(W,B==null?void 0:B.get(W.id)))]}),E=M=>M.includes(",")||M.includes('"')||M.includes(` 807`)?`"${M.replace(/"/g,'""')}"`:M,R=[O.map(E).join(","),...L.map(M=>M.map(E).join(","))].join(` 808`),q=new Blob([R],{type:"text/csv;charset=utf-8;"}),I=URL.createObjectURL(q),$=document.createElement("a");$.href=I,$.download="form-responses.csv",$.click(),URL.revokeObjectURL(I)},[h,b,w,N]),C=T=>{const O=new Set(g);O.has(T)?O.delete(T):O.add(T),x(O)};return a.jsx("div",{className:"border-t border-border pt-3",children:a.jsxs(Mb,{open:t,onOpenChange:n,children:[a.jsx(Db,{asChild:!0,children:a.jsxs("button",{className:"flex items-center justify-between w-full text-left group",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5",children:[a.jsx($3,{className:"h-3.5 w-3.5"}),"Form Responses",t&&j>0&&a.jsxs("span",{className:"normal-case font-normal text-[10px]",children:["· ",j," of ",h.length," responded"]})]}),t?a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),a.jsxs($b,{className:"mt-2",children:[!N&&a.jsx("p",{className:"text-xs text-muted-foreground py-4 text-center",children:"No form fields configured for this experience."}),N&&h.length===0&&a.jsx("p",{className:"text-xs text-muted-foreground py-4 text-center",children:"No accepted contacts or team members for this experience."}),N&&h.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-end gap-1 mb-1",children:[m.length>1&&a.jsxs(pk,{children:[a.jsx(gk,{asChild:!0,children:a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-[10px] gap-1",children:["Sections",a.jsx(_n,{className:"h-2.5 w-2.5"})]})}),a.jsxs(jb,{align:"end",className:"w-48",children:[a.jsx(v1,{checked:g.size===m.length,onCheckedChange:T=>{x(T?null:new Set)},children:a.jsx("span",{className:"text-xs font-medium",children:"All Sections"})}),a.jsx(Rq,{}),m.map(T=>a.jsx(v1,{checked:g.has(T.label),onCheckedChange:()=>C(T.label),children:a.jsx("span",{className:"text-xs",children:T.label})},T.label))]})]}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-[10px] gap-1",onClick:k,children:[a.jsx(ja,{className:"h-3 w-3"}),"Export CSV"]})]}),a.jsx("div",{className:"w-full overflow-x-auto rounded-md border border-border",children:a.jsxs("table",{className:"w-full caption-bottom text-sm border-collapse",children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{className:"sticky left-0 bg-card z-20 min-w-[140px] text-[10px] shadow-[1px_0_0_0_hsl(var(--border))]",children:"Name"}),b.map(T=>a.jsx(Le,{className:"text-[10px] min-w-[100px] max-w-[160px]",children:a.jsx("span",{className:"truncate block",children:T.description})},T.id))]})}),a.jsx(Bn,{children:h.map(T=>{const O=w.get(T.id),L=r===T.id;return a.jsxs(yt,{className:"cursor-pointer hover:bg-muted/50 group",onClick:()=>s(L?null:T.id),children:[a.jsxs(Te,{className:"sticky left-0 bg-card z-10 py-1.5
808shadow-[1px_0_0_0_hsl(var(--border))] group-hover:bg-muted/50",children:[a.jsx("span",{className:"text-xs font-medium truncate max-w-[120px] block",children:T.name}),T.isTeam&&a.jsx("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground",children:"Team"})]}),b.map(E=>a.jsx(Te,{className:Se("py-1.5 text-xs",L&&"align-top"),children:P(E,O==null?void 0:O.get(E.id),L,T.contactId??null)},E.id))]},T.id)})})]})}),a.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 text-center",children:"Click a row to expand full responses"})]})]})]})})}function Tg(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var O8={exports:{}};/*! 809 810JSZip v3.10.1 - A JavaScript class for generating and reading zip files 811<http://stuartk.com/jszip> 812 813(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com> 814Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. 815 816JSZip uses the library pako released under the MIT license : 817https://github.com/nodeca/pako/blob/main/LICENSE 818*/(function(e,t){(function(n){e.exports=n()})(function(){return function n(r,s,i){function o(u,d){if(!s[u]){if(!r[u]){var h=typeof Tg=="function"&&Tg;if(!d&&h)return h(u,!0);if(l)return l(u,!0);var m=new Error("Cannot find module '"+u+"'");throw m.code="MODULE_NOT_FOUND",m}var f=s[u]={exports:{}};r[u][0].call(f.exports,function(x){var g=r[u][1][x];return o(g||x)},f,f.exports,n,r,s,i)}return s[u].exports}for(var l=typeof Tg=="function"&&Tg,c=0;c<i.length;c++)o(i[c]);return o}({1:[function(n,r,s){var i=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(c){for(var u,d,h,m,f,x,g,p=[],v=0,b=c.length,w=b,N=i.getTypeOf(c)!=="string";v<c.length;)w=b-v,h=N?(u=c[v++],d=v<b?c[v++]:0,v<b?c[v++]:0):(u=c.charCodeAt(v++),d=v<b?c.charCodeAt(v++):0,v<b?c.charCodeAt(v++):0),m=u>>2,f=(3&u)<<4|d>>4,x=1<w?(15&d)<<2|h>>6:64,g=2<w?63&h:64,p.push(l.charAt(m)+l.charAt(f)+l.charAt(x)+l.charAt(g));return p.join("")},s.decode=function(c){var u,d,h,m,f,x,g=0,p=0,v="data:";if(c.substr(0,v.length)===v)throw new Error("Invalid base64 input, it looks like a data url.");var b,w=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&w--,c.charAt(c.length-2)===l.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(b=o.uint8array?new Uint8Array(0|w):new Array(0|w);g<c.length;)u=l.indexOf(c.charAt(g++))<<2|(m=l.indexOf(c.charAt(g++)))>>4,d=(15&m)<<4|(f=l.indexOf(c.charAt(g++)))>>2,h=(3&f)<<6|(x=l.indexOf(c.charAt(g++))),b[p++]=u,f!==64&&(b[p++]=d),x!==64&&(b[p++]=h);return b}},{"./support":30,"./utils":32}],2:[function(n,r,s){var i=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,h,m,f,x){this.compressedSize=d,this.uncompressedSize=h,this.crc32=m,this.compression=f,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),h=this;return d.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,h,m){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(h.compressWorker(m)).pipe(new c("compressedSize")).withStreamInfo("compression",h)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,s){var i=n("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},s.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,s){var i=n("./utils"),o=function(){for(var l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c}();
vendor: 7,982 bytes, lines 818-819
818r.exports=function(l,c){return l!==void 0&&l.length?i.getTypeOf(l)!=="string"?function(u,d,h,m){var f=o,x=m+h;u^=-1;for(var g=m;g<x;g++)u=u>>>8^f[255&(u^d[g])];return-1^u}(0|c,l,l.length,0):function(u,d,h,m){var f=o,x=m+h;u^=-1;for(var g=m;g<x;g++)u=u>>>8^f[255&(u^d.charCodeAt(g))];return-1^u}(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(n,r,s){var i=null;i=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:i}},{lie:37}],7:[function(n,r,s){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=i?"uint8array":"array";function d(h,m){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=m,this.meta={}}s.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,h.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(m){h.push({data:m,meta:h.meta})}},s.compressWorker=function(h){return new d("Deflate",h)},s.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,s){function i(f,x){var g,p="";for(g=0;g<x;g++)p+=String.fromCharCode(255&f),f>>>=8;return p}function o(f,x,g,p,v,b){var w,N,j=f.file,_=f.compression,S=b!==u.utf8encode,P=l.transformTo("string",b(j.name)),k=l.transformTo("string",u.utf8encode(j.name)),C=j.comment,T=l.transformTo("string",b(C)),O=l.transformTo("string",u.utf8encode(C)),L=k.length!==j.name.length,E=O.length!==C.length,R="",q="",I="",$=j.dir,M=j.date,B={crc32:0,compressedSize:0,uncompressedSize:0};x&&!g||(B.crc32=f.crc32,B.compressedSize=f.compressedSize,B.uncompressedSize=f.uncompressedSize);var W=0;x&&(W|=8),S||!L&&!E||(W|=2048);var A=0,K=0;$&&(A|=16),v==="UNIX"?(K=798,A|=function(H,fe){var te=H;return H||(te=fe?16893:33204),(65535&te)<<16}(j.unixPermissions,$)):(K=20,A|=function(H){return 63&(H||0)}(j.dosPermissions)),w=M.getUTCHours(),w<<=6,w|=M.getUTCMinutes(),w<<=5,w|=M.getUTCSeconds()/2,N=M.getUTCFullYear()-1980,N<<=4,N|=M.getUTCMonth()+1,N<<=5,N|=M.getUTCDate(),L&&(q=i(1,1)+i(d(P),4)+k,R+="up"+i(q.length,2)+q),E&&(I=i(1,1)+i(d(T),4)+O,R+="uc"+i(I.length,2)+I);var G="";return G+=` 819\0`,G+=i(W,2),G+=_.magic,G+=i(w,2),G+=i(N,2),G+=i(B.crc32,4),G+=i(B.compressedSize,4),G+=i(B.uncompressedSize,4),G+=i(P.length,2),G+=i(R.length,2),{fileRecord:h.LOCAL_FILE_HEADER+G+P+R,dirRecord:h.CENTRAL_FILE_HEADER+i(K,2)+G+i(T.length,2)+"\0\0\0\0"+i(A,4)+i(p,4)+P+R+T}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),h=n("../signature");function m(f,x,g,p){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=g,this.encodeFileName=p,this.streamFiles=f,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(m,c),m.prototype.push=function(f){var x=f.meta.percent||0,g=this.entriesCount,p=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,c.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:g?(x+100*(g-p-1))/g:100}}))},m.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var x=this.streamFiles&&!f.file.dir;if(x){var g=o(f,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(f){this.accumulate=!1;var x=this.streamFiles&&!f.file.dir,g=o(f,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),x)this.push({data:function(p){return h.DATA_DESCRIPTOR+i(p.crc32,4)+i(p.compressedSize,4)+i(p.uncompressedSize,4)}(f),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var f=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var g=this.bytesWritten-f,p=function(v,b,w,N,j){var _=l.transformTo("string",j(N));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(v,2)+i(v,2)+i(b,4)+i(w,4)+i(_.length,2)+_}(this.dirRecords.length,g,f,this.zipComment,this.encodeFileName);this.push({data:p,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(f){this._sources.push(f);var x=this;return f.on("data",function(g){x.processChunk(g)}),f.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),f.on("error",function(g){x.error(g)}),this},m.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(f){var x=this._sources;if(!c.prototype.error.call(this,f))return!1;for(var g=0;g<x.length;g++)try{x[g].error(f)}catch{}return!0},m.prototype.lock=function(){c.prototype.lock.call(this);for(var f=this._sources,x=0;x<f.length;x++)f[x].lock()},r.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,s){var i=n("../compressions"),o=n("./ZipFileWorker");s.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),h=0;try{l.forEach(function(m,f){h++;var x=function(b,w){var N=b||w,j=i[N];if(!j)throw new Error(N+" is not a valid compression method !");return j}(f.options.compression,c.compression),g=f.options.compressionOptions||c.compressionOptions||{},p=f.dir,v=f.date;f._compressWorker(x,g).withStreamInfo("file",{name:m,dir:p,date:v,comment:f.comment||"",unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(m){d.error(m)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,s){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new i;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(i.prototype=n("./object")).loadAsync=n("./load"),i.support=n("./support"),i.defaults=n("./defaults"),i.version="3.10.1",i.loadAsync=function(o,l){return new i().loadAsync(o,l)},i.external=n("./external"),r.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,s){var i=n("./utils"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function h(m){return new o.Promise(function(f,x){var g=m.decompressed.getContentWorker().pipe(new u);g.on("error",function(p){x(p)}).on("end",function(){g.streamInfo.crc32!==m.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):f()}).resume()})}r.exports=function(m,f){var x=this;return f=i.extend(f||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(m)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip f
819ile",m,!0,f.optimizedBinaryString,f.base64).then(function(g){var p=new c(f);return p.load(g),p}).then(function(g){var p=[o.Promise.resolve(g)],v=g.files;if(f.checkCRC32)for(var b=0;b<v.length;b++)p.push(h(v[b]));return o.Promise.all(p)}).then(function(g){for(var p=g.shift(),v=p.files,b=0;b<v.length;b++){var w=v[b],N=w.fileNameStr,j=i.resolve(w.fileNameStr);x.file(j,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:f.createFolders}),w.dir||(x.file(j).unsafeOriginalName=N)}return p.zipComment.length&&(x.comment=p.zipComment),x})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,s){var i=n("../utils"),o=n("../stream/GenericWorker");function l(c,u){o.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}i.inherits(l,o),l.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},l.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,s){var i=n("readable-stream").Readable;function o(l,c,u){i.call(this,c),this._helper=l;var d=this;l.on("data",function(h,m){d.push(h)||d._helper.pause(),u&&u(m)}).on("error",function(h){d.emit("error",h)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,i),o.prototype._read=function(){this._helper.resume()},r.exports=o},{"../utils":32,"readable-stream":16}],14:[function(n,r,s){r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,o);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,o)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var o=new Buffer(i);return o.fill(0),o},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(n,r,s){function i(j,_,S){var P,k=l.getTypeOf(_),C=l.extend(S||{},d);C.date=C.date||new Date,C.compression!==null&&(C.compression=C.compression.toUpperCase()),typeof C.unixPermissions=="string"&&(C.unixPermissions=parseInt(C.unixPermissions,8)),C.unixPermissions&&16384&C.unixPermissions&&(C.dir=!0),C.dosPermissions&&16&C.dosPermissions&&(C.dir=!0),C.dir&&(j=v(j)),C.createFolders&&(P=p(j))&&b.call(this,P,!0);var T=k==="string"&&C.binary===!1&&C.base64===!1;S&&S.binary!==void 0||(C.binary=!T),(_ instanceof h&&_.uncompressedSize===0||C.dir||!_||_.length===0)&&(C.base64=!1,C.binary=!0,_="",C.compression="STORE",k="string");var O=null;O=_ instanceof h||_ instanceof c?_:x.isNode&&x.isStream(_)?new g(j,_):l.prepareContent(j,_,C.binary,C.optimizedBinaryString,C.base64);var L=new m(j,O,C);this.files[j]=L}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),h=n("./compressedObject"),m=n("./zipObject"),f=n("./generate"),x=n("./nodejsUtils"),g=n("./nodejs/NodejsStreamInputAdapter"),p=function(j){j.slice(-1)==="/"&&(j=j.substring(0,j.length-1));var _=j.lastIndexOf("/");return 0<_?j.substring(0,_):""},v=function(j){return j.slice(-1)!=="/"&&(j+="/"),j},b=function(j,_){return _=_!==void 0?_:d.createFolders,j=v(j),this.files[j]||i.call(this,j,null,{dir:!0,createFolders:_}),this.files[j]};function w(j){return Object.prototype.toString.call(j)==="[object RegExp]"}var N={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(j){var _,S,P;for(_ in this.files)P=this.files[_],(S=_.slice(this.root.length,_.length))&&_.slice(0,this.root.length)===this.root&&j(S,P)},filter:function(j){var _=[];return this.forEach(function(S,P){j(S,P)&&_.push(P)}),_},file:function(j,_,S){if(arguments.length!==1)return j=this.root+j,i.call(this,j,_,S),this;if(w(j)){var P=j;return this.filter(function(C,T){return!T.dir&&P.test(C)})}var k=this.files[this.root+j];return k&&!k.dir?k:null},folder:function(j){if(!j)return this;if(w(j))return this.filter(function(k,C){return C.dir&&j.test(k)});var _=this.root+j,S=b.call(this,_),P=this.clone();return P.root=S.name,P},remove:function(j){j=this.root+j;var _=this.files[j];if(_||(j.slice(-1)!=="/"&&(j+="/"),_=this.files[j]),_&&!_.dir)delete this.files[j];else for(var S=this.filter(function(k,C){return C.name.slice(0,j.length)===j}),P=0;P<S.length;P++)delete this.files[S[P].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")}
vendor: 22,011 bytes, line 819
819,generateInternalStream:function(j){var _,S={};try{if((S=l.extend(j||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),S.type==="binarystring"&&(S.type="string"),!S.type)throw new Error("No output type specified.");l.checkSupport(S.type),S.platform!=="darwin"&&S.platform!=="freebsd"&&S.platform!=="linux"&&S.platform!=="sunos"||(S.platform="UNIX"),S.platform==="win32"&&(S.platform="DOS");var P=S.comment||this.comment||"";_=f.generateWorker(this,S,P)}catch(k){(_=new c("error")).error(k)}return new u(_,S.type||"string",S.mimeType)},generateAsync:function(j,_){return this.generateInternalStream(j).accumulate(_)},generateNodeStream:function(j,_){return(j=j||{}).type||(j.type="nodebuffer"),this.generateInternalStream(j).toNodejsStream(_)}};r.exports=N},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,s){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,s){var i=n("./DataReader");function o(l){i.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,i),o.prototype.byteAt=function(l){return this.data[this.zero+l]},o.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),h=l.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===c&&this.data[m+1]===u&&this.data[m+2]===d&&this.data[m+3]===h)return m-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),h=l.charCodeAt(3),m=this.readData(4);return c===m[0]&&u===m[1]&&d===m[2]&&h===m[3]},o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],18:[function(n,r,s){var i=n("../utils");function o(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return i.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=o},{"../utils":32}],19:[function(n,r,s){var i=n("./Uint8ArrayReader");function o(l){i.call(this,l)}n("../utils").inherits(o,i),o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,s){var i=n("./DataReader");function o(l){i.call(this,l)}n("../utils").inherits(o,i),o.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},o.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},o.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},o.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(n,r,s){var i=n("./ArrayReader");function o(l){i.call(this,l)}n("../utils").inherits(o,i),o.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,s){var i=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(h){var m=i.getTypeOf(h);return i.checkSupport(m),m!=="string"||o.uint8array?m==="nodebuffer"?new u(h):o.uint8array?new d(i.transformTo("uint8array",h)):new l(i.transformTo("array",h)):new c(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,s){s.LOCAL_FILE_HEADER="PK��",s.CENTRAL_FILE_HEADER="PK��",s.CENTRAL_DIRECTORY_END="PK��",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK�\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK��",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,s){var i=n("./GenericWorker"),o=n("../utils");function l(c){i.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,i),l.prototype.processChunk=function(c){this.push({data:o.transformTo(this.destType,c.data),meta:c.meta})},r.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,s){var i=n("./GenericWorker"),o=n("../crc32");function l(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,i),l.prototype.processChunk=function(c){this.streamInfo.crc32=o(c.data,this.streamInfo.crc32||0),this.push(c)},r.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,s){var i=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}i.inherits(l,o),l.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}o.prototype.processChunk.call(this,c)},r.exports=l},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,s){var i=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=i.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}i.inherits(l,o),l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,s){function i(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,l){return this._listeners[o].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,l){if(this._listeners[o])for(var c=0;c<this._listeners[o].length;c++)this._listeners[o][c].call(this,l)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var l=this;return o.on("data",function(c){l.processChunk(c)}),o.on("end",function(){l.end()}),o.on("error",function(c){l.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,l){return this.extraStreamInfo[o]=l,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},r.exports=i},{}],29:[function(n,r,s){var i=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),h=null;if(u.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(x,g){return new d.Promise(function(p,v){var b=[],w=x._internalType,N=x._outputType,j=x._mimeType;x.on("data",function(_,S){b.push(_),g&&g(S)}).on("error",function(_){b=[],v(_)}).on("end",function(){try{var _=function(S,P,k){switch(S){case"blob":return i.newBlob(i.transformTo("arraybuffer",P),k);case"base64":return c.encode(P);default:return i.transformTo(S,P)}}(N,function(S,P){var k,C=0,T=null,O=0;for(k=0;k<P.length;k++)O+=P[k].length;switch(S){case"string":return P.join("");case"array":return Array.prototype.concat.apply([],P);case"uint8array":for(T=new Uint8Array(O),k=0;k<P.length;k++)T.set(P[k],C),C+=P[k].length;return T;case"nodebuffer":return Buffer.concat(P);default:throw new Error("concat : unsupported type '"+S+"'")}}(w,b),j);p(_)}catch(S){v(S)}b=[]}).resume()})}function f(x,g,p){var v=g;switch(g){case"blob":case"arraybuffer":v="uint8array";break;case"base64":v="string"}try{this._internalType=v,this._outputType=g,this._mimeType=p,i.checkSupport(v),this._worker=x.pipe(new o(v)),x.lock()}catch(b){this._worker=new l("error"),this._worker.error(b)}}f.prototype={accumulate:function(x){return m(this,x)},on:function(x,g){var p=this;return x==="data"?this._worker.on(x,function(v){g.call(p,v.data,v.meta)}):this._worker.on(x,function(){i.delay(g,arguments,p)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,s){if(s.base64=!0,s.array=!0,s.string=!0,s.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",s.nodebuffer=typeof Buffer<"u",s.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")s.blob=!1;else{var i=new ArrayBuffer(0);try{s.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(i),s.blob=o.getBlob("application/zip").size===0}catch{s.blob=!1}}}try{s.nodestream=!!n("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,s){for(var i=n("./utils"),o=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function h(){c.call(this,"utf-8 decode"),this.leftOver=null}function m(){c.call(this,"utf-8 encode")}s.utf8encode=function(f){return o.nodebuffer?l.newBufferFrom(f,"utf-8"):function(x){var g,p,v,b,w,N=x.length,j=0;for(b=0;b<N;b++)(64512&(p=x.charCodeAt(b)))==55296&&b+1<N&&(64512&(v=x.charCodeAt(b+1)))==56320&&(p=65536+(p-55296<<10)+(v-56320),b++),j+=p<128?1:p<2048?2:p<65536?3:4;for(g=o.uint8array?new Uint8Array(j):new Array(j),b=w=0;w<j;b++)(64512&(p=x.charCodeAt(b)))==55296&&b+1<N&&(64512&(v=x.charCodeAt(b+1)))==56320&&(p=65536+(p-55296<<10)+(v-56320),b++),p<128?g[w++]=p:(p<2048?g[w++]=192|p>>>6:(p<65536?g[w++]=224|p>>>12:(g[w++]=240|p>>>18,g[w++]=128|p>>>12&63),g[w++]=128|p>>>6&63),g[w++]=128|63&p);return g}(f)},s.utf8decode=function(f){return o.nodebuffer?i.transformTo("nodebuffer",f).toString("utf-8"):function(x){var g,p,v,b,w=x.length,N=new Array(2*w);for(g=p=0;g<w;)if((v=x[g++])<128)N[p++]=v;else if(4<(b=u[v]))N[p++]=65533,g+=b-1;else{for(v&=b===2?31:b===3?15:7;1<b&&g<w;)v=v<<6|63&x[g++],b--;1<b?N[p++]=65533:v<65536?N[p++]=v:(v-=65536,N[p++]=55296|v>>10&1023,N[p++]=56320|1023&v)}return N.length!==p&&(N.subarray?N=N.subarray(0,p):N.length=p),i.applyFromCharCode(N)}(f=i.transformTo(o.uint8array?"uint8array":"array",f))},i.inherits(h,c),h.prototype.processChunk=function(f){var x=i.transformTo(o.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var g=x;(x=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),x.set(g,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var p=function(b,w){var N;for((w=w||b.length)>b.length&&(w=b.length),N=w-1;0<=N&&(192&b[N])==128;)N--;return N<0||N===0?w:N+u[b[N]]>w?N:w}(x),v=x;p!==x.length&&(o.uint8array?(v=x.subarray(0,p),this.leftOver=x.subarray(p,x.length)):(v=x.slice(0,p),this.leftOver=x.slice(p,x.length))),this.push({data:s.utf8decode(v),meta:f.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=h,i.inherits(m,c),m.prototype.processChunk=function(f){this.push({data:s.utf8encode(f.data),meta:f.meta})},s.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,s){var i=n("./support"),o=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(g){return g}function d(g,p){for(var v=0;v<g.length;++v)p[v]=255&g.charCodeAt(v);return p}n("setimmediate"),s.newBlob=function(g,p){s.checkSupport("blob");try{return new Blob([g],{type:p})}catch{try{var v=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return v.append(g),v.getBlob(p)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(g,p,v){var b=[],w=0,N=g.length;if(N<=v)return String.fromCharCode.apply(null,g);for(;w<N;)p==="array"||p==="nodebuffer"?b.push(String.fromCharCode.apply(null,g.slice(w,Math.min(w+v,N)))):b.push(String.fromCharCode.apply(null,g.subarray(w,Math.min(w+v,N)))),w+=v;return b.join("")},stringifyByChar:function(g){for(var p="",v=0;v<g.length;v++)p+=String.fromCharCode(g[v]);return p},applyCanBeUsed:{uint8array:function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}}()}};function m(g){var p=65536,v=s.getTypeOf(g),b=!0;if(v==="uint8array"?b=h.applyCanBeUsed.uint8array:v==="nodebuffer"&&(b=h.applyCanBeUsed.nodebuffer),b)for(;1<p;)try{return h.stringifyByChunk(g,v,p)}catch{p=Math.floor(p/2)}return h.stringifyByChar(g)}function f(g,p){for(var v=0;v<g.length;v++)p[v]=g[v];return p}s.applyFromCharCode=m;var x={};x.string={string:u,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return x.string.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:function(g){return d(g,l.allocBuffer(g.length))}},x.array={string:m,array:u,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return l.newBufferFrom(g)}},x.arraybuffer={string:function(g){return m(new Uint8Array(g))},array:function(g){return f(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:u,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return l.newBufferFrom(new Uint8Array(g))}},x.uint8array={string:m,array:function(g){return f(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return l.newBufferFrom(g)}},x.nodebuffer={string:m,array:function(g){return f(g,new Array(g.length))},arraybuffer:function(g){return x.nodebuffer.uint8array(g).buffer},uint8array:function(g){return f(g,new Uint8Array(g.length))},nodebuffer:u},s.transformTo=function(g,p){if(p=p||"",!g)return p;s.checkSupport(g);var v=s.getTypeOf(p);return x[v][g](p)},s.resolve=function(g){for(var p=g.split("/"),v=[],b=0;b<p.length;b++){var w=p[b];w==="."||w===""&&b!==0&&b!==p.length-1||(w===".."?v.pop():v.push(w))}return v.join("/")},s.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":i.nodebuffer&&l.isBuffer(g)?"nodebuffer":i.uint8array&&g instanceof Uint8Array?"uint8array":i.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},s.checkSupport=function(g){if(!i[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},s.MAX_VALUE_16BITS=65535,s.MAX_VALUE_32BITS=-1,s.pretty=function(g){var p,v,b="";for(v=0;v<(g||"").length;v++)b+="\\x"+((p=g.charCodeAt(v))<16?"0":"")+p.toString(16).toUpperCase();return b},s.delay=function(g,p,v){setImmediate(function(){g.apply(v||null,p||[])})},s.inherits=function(g,p){function v(){}v.prototype=p.prototype,g.prototype=new v},s.extend=function(){var g,p,v={};for(g=0;g<arguments.length;g++)for(p in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],p)&&v[p]===void 0&&(v[p]=arguments[g][p]);return v},s.prepareContent=function(g,p,v,b,w){return c.Promise.resolve(p).then(function(N){return i.blob&&(N instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(N))!==-1)&&typeof FileReader<"u"?new c.Promise(function(j,_){var S=new FileReader;S.onload=function(P){j(P.target.result)},S.onerror=function(P){_(P.target.error)},S.readAsArrayBuffer(N)}):N}).then(function(N){var j=s.getTypeOf(N);return j?(j==="arraybuffer"?N=s.transformTo("uint8array",N):j==="string"&&(w?N=o.decode(N):v&&b!==!0&&(N=function(_){return d(_,i.uint8array?new Uint8Array(_.length):new Array(_.length))}(N))),N):c.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,s){var i=n("./reader/readerFor"),o=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(h){this.files=[],this.loadOptions=h}d.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(m)+", expected "+o.pretty(h)+")")}},isSignature:function(h,m){var f=this.reader.index;this.reader.setIndex(h);var x=this.reader.readString(4)===m;return this.reader.setIndex(f),x},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var h=this.reader.readData(this.zipCommentLength),m=u.uint8array?"uint8array":"array",f=o.transformTo(m,h);this.zipComment=this.loadOptions.decodeFileName(f)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h,m,f,x=this.zip64EndOfCentralSize-44;0<x;)h=this.reader.readInt(2),m=this.reader.readInt(4),f=this.reader.readData(m),this.zip64ExtensibleData[h]={id:h,length:m,value:f}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,m;for(h=0;h<this.files.length;h++)m=this.files[h],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(h=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var h=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip f
819ile ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(h);var m=h;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(h=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(h),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var f=this.centralDirOffset+this.centralDirSize;this.zip64&&(f+=20,f+=12+this.zip64EndOfCentralSize);var x=m-f;if(0<x)this.isSignature(m,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(h){this.reader=i(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,s){var i=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),h=n("./support");function m(f,x){this.options=f,this.loadOptions=x}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(f){var x,g;if(f.skip(22),this.fileNameLength=f.readInt(2),g=f.readInt(2),this.fileName=f.readData(this.fileNameLength),f.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=function(p){for(var v in d)if(Object.prototype.hasOwnProperty.call(d,v)&&d[v].magic===p)return d[v];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new l(this.compressedSize,this.uncompressedSize,this.crc32,x,f.readData(this.compressedSize))},readCentralPart:function(f){this.versionMadeBy=f.readInt(2),f.skip(2),this.bitFlag=f.readInt(2),this.compressionMethod=f.readString(2),this.date=f.readDate(),this.crc32=f.readInt(4),this.compressedSize=f.readInt(4),this.uncompressedSize=f.readInt(4);var x=f.readInt(2);if(this.extraFieldsLength=f.readInt(2),this.fileCommentLength=f.readInt(2),this.diskNumberStart=f.readInt(2),this.internalFileAttributes=f.readInt(2),this.externalFileAttributes=f.readInt(4),this.localHeaderOffset=f.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");f.skip(x),this.readExtraFields(f),this.parseZIP64ExtraField(f),this.fileComment=f.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var f=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=i(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&
vendor: 7,719 bytes, line 819
819(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var x,g,p,v=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4<v;)x=f.readInt(2),g=f.readInt(2),p=f.readData(g),this.extraFields[x]={id:x,length:g,value:p};f.setIndex(v)},handleUTF8:function(){var f=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var g=o.transformTo(f,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var p=this.findExtraFieldUnicodeComment();if(p!==null)this.fileCommentStr=p;else{var v=o.transformTo(f,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(v)}}},findExtraFieldUnicodePath:function(){var f=this.extraFields[28789];if(f){var x=i(f.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(f.length-5))}return null},findExtraFieldUnicodeComment:function(){var f=this.extraFields[25461];if(f){var x=i(f.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(f.length-5))}return null}},r.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,s){function i(x,g,p){this.name=x,this.dir=p.dir,this.date=p.date,this.comment=p.comment,this.unixPermissions=p.unixPermissions,this.dosPermissions=p.dosPermissions,this._data=g,this._dataBinary=p.binary,this.options={compression:p.compression,compressionOptions:p.compressionOptions}}var o=n("./stream/StreamHelper"),l=n("./stream/DataWorker"),c=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");i.prototype={internalStream:function(x){var g=null,p="string";try{if(!x)throw new Error("No output type specified.");var v=(p=x.toLowerCase())==="string"||p==="text";p!=="binarystring"&&p!=="text"||(p="string"),g=this._decompressWorker();var b=!this._dataBinary;b&&!v&&(g=g.pipe(new c.Utf8EncodeWorker)),!b&&v&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(w){(g=new d("error")).error(w)}return new o(g,p,"")},async:function(x,g){return this.internalStream(x).accumulate(g)},nodeStream:function(x,g){return this.internalStream(x||"nodebuffer").toNodejsStream(g)},_compressWorker:function(x,g){if(this._data instanceof u&&this._data.compression.magic===x.magic)return this._data.getCompressedWorker();var p=this._decompressWorker();return this._dataBinary||(p=p.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(p,x,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<h.length;f++)i.prototype[h[f]]=m;r.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,s){(function(i){var o,l,c=i.MutationObserver||i.WebKitMutationObserver;if(c){var u=0,d=new c(x),h=i.document.createTextNode("");d.observe(h,{characterData:!0}),o=function(){h.data=u=++u%2}}else if(i.setImmediate||i.MessageChannel===void 0)o="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var g=i.document.createElement("script");g.onreadystatechange=function(){x(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},i.document.documentElement.appendChild(g)}:function(){setTimeout(x,0)};else{var m=new i.MessageChannel;m.port1.onmessage=x,o=function(){m.port2.postMessage(0)}}var f=[];function x(){var g,p;l=!0;for(var v=f.length;v;){for(p=f,f=[],g=-1;++g<v;)p[g]();v=f.length}l=!1}r.exports=function(g){f.push(g)!==1||l||o()}}).call(this,typeof Vo<"u"?Vo:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,s){var i=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function h(v){if(typeof v!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,v!==o&&g(this,v)}function m(v,b,w){this.promise=v,typeof b=="function"&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function f(v,b,w){i(function(){var N;try{N=b(w)}catch(j){return l.reject(v,j)}N===v?l.reject(v,new TypeError("Cannot resolve promise with itself")):l.resolve(v,N)})}function x(v){var b=v&&v.then;if(v&&(typeof v=="object"||typeof v=="function")&&typeof b=="function")return function(){b.apply(v,arguments)}}function g(v,b){var w=!1;function N(S){w||(w=!0,l.reject(v,S))}function j(S){w||(w=!0,l.resolve(v,S))}var _=p(function(){b(j,N)});_.status==="error"&&N(_.value)}function p(v,b){var w={};try{w.value=v(b),w.status="success"}catch(N){w.status="error",w.value=N}return w}(r.exports=h).prototype.finally=function(v){if(typeof v!="function")return this;var b=this.constructor;return this.then(function(w){return b.resolve(v()).then(function(){return w})},function(w){return b.resolve(v()).then(function(){throw w})})},h.prototype.catch=function(v){return this.then(null,v)},h.prototype.then=function(v,b){if(typeof v!="function"&&this.state===u||typeof b!="function"&&this.state===c)return this;var w=new this.constructor(o);return this.state!==d?f(w,this.state===u?v:b,this.outcome):this.queue.push(new m(w,v,b)),w},m.prototype.callFulfilled=function(v){l.resolve(this.promise,v)},m.prototype.otherCallFulfilled=function(v){f(this.promise,this.onFulfilled,v)},m.prototype.callRejected=function(v){l.reject(this.promise,v)},m.prototype.otherCallRejected=function(v){f(this.promise,this.onRejected,v)},l.resolve=function(v,b){var w=p(x,b);if(w.status==="error")return l.reject(v,w.value);var N=w.value;if(N)g(v,N);else{v.state=u,v.outcome=b;for(var j=-1,_=v.queue.length;++j<_;)v.queue[j].callFulfilled(b)}return v},l.reject=function(v,b){v.state=c,v.outcome=b;for(var w=-1,N=v.queue.length;++w<N;)v.queue[w].callRejected(b);return v},h.resolve=function(v){return v instanceof this?v:l.resolve(new this(o),v)},h.reject=function(v){var b=new this(o);return l.reject(b,v)},h.all=function(v){var b=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=v.length,N=!1;if(!w)return this.resolve([]);for(var j=new Array(w),_=0,S=-1,P=new this(o);++S<w;)k(v[S],S);return P;function k(C,T){b.resolve(C).then(function(O){j[T]=O,++_!==w||N||(N=!0,l.resolve(P,j))},function(O){N||(N=!0,l.reject(P,O))})}},h.race=function(v){var b=this;if(Object.prototype.toString.call(v)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=v.length,N=!1;if(!w)return this.resolve([]);for(var j=-1,_=new this(o);++j<w;)S=v[j],b.resolve(S).then(function(P){N||(N=!0,l.resolve(_,P))},function(P){N||(N=!0,l.reject(_,P))});var S;return _}},{immediate:36}],38:[function(n,r,s){var i={};(0,n("./lib/utils/common").assign)(i,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,s){var i=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,h=0,m=-1,f=0,x=8;function g(v){if(!(this instanceof g))return new g(v);this.options=o.assign({level:m,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:f,to:""},v||{});var b=this.options;
vendor: 4,462 bytes, line 819
819b.raw&&0<b.windowBits?b.windowBits=-b.windowBits:b.gzip&&0<b.windowBits&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var w=i.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(w!==h)throw new Error(c[w]);if(b.header&&i.deflateSetHeader(this.strm,b.header),b.dictionary){var N;if(N=typeof b.dictionary=="string"?l.string2buf(b.dictionary):d.call(b.dictionary)==="[object ArrayBuffer]"?new Uint8Array(b.dictionary):b.dictionary,(w=i.deflateSetDictionary(this.strm,N))!==h)throw new Error(c[w]);this._dict_set=!0}}function p(v,b){var w=new g(b);if(w.push(v,!0),w.err)throw w.msg||c[w.err];return w.result}g.prototype.push=function(v,b){var w,N,j=this.strm,_=this.options.chunkSize;if(this.ended)return!1;N=b===~~b?b:b===!0?4:0,typeof v=="string"?j.input=l.string2buf(v):d.call(v)==="[object ArrayBuffer]"?j.input=new Uint8Array(v):j.input=v,j.next_in=0,j.avail_in=j.input.length;do{if(j.avail_out===0&&(j.output=new o.Buf8(_),j.next_out=0,j.avail_out=_),(w=i.deflate(j,N))!==1&&w!==h)return this.onEnd(w),!(this.ended=!0);j.avail_out!==0&&(j.avail_in!==0||N!==4&&N!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(j.output,j.next_out))):this.onData(o.shrinkBuf(j.output,j.next_out)))}while((0<j.avail_in||j.avail_out===0)&&w!==1);return N===4?(w=i.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===h):N!==2||(this.onEnd(h),!(j.avail_out=0))},g.prototype.onData=function(v){this.chunks.push(v)},g.prototype.onEnd=function(v){v===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},s.Deflate=g,s.deflate=p,s.deflateRaw=function(v,b){return(b=b||{}).raw=!0,p(v,b)},s.gzip=function(v,b){return(b=b||{}).gzip=!0,p(v,b)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,s){var i=n("./zlib/inflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),h=n("./zlib/gzheader"),m=Object.prototype.toString;function f(g){if(!(this instanceof f))return new f(g);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},g||{});var p=this.options;p.raw&&0<=p.windowBits&&p.windowBits<16&&(p.windowBits=-p.windowBits,p.windowBits===0&&(p.windowBits=-15)),!(0<=p.windowBits&&p.windowBits<16)||g&&g.windowBits||(p.windowBits+=32),15<p.windowBits&&p.windowBits<48&&!(15&p.windowBits)&&(p.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var v=i.inflateInit2(this.strm,p.windowBits);if(v!==c.Z_OK)throw new Error(u[v]);this.header=new h,i.inflateGetHeader(this.strm,this.header)}function x(g,p){var v=new f(p);if(v.push(g,!0),v.err)throw v.msg||u[v.err];return v.result}f.prototype.push=function(g,p){var v,b,w,N,j,_,S=this.strm,P=this.options.chunkSize,k=this.options.dictionary,C=!1;if(this.ended)return!1;b=p===~~p?p:p===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?S.input=l.binstring2buf(g):m.call(g)==="[object ArrayBuffer]"?S.input=new Uint8Array(g):S.input=g,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new o.Buf8(P),S.next_out=0,S.avail_out=P),(v=i.inflate(S,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&k&&(_=typeof k=="string"?l.string2buf(k):m.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,v=i.inflateSetDictionary(this.strm,_)),v===c.Z_BUF_ERROR&&C===!0&&(v=c.Z_OK,C=!1),v!==c.Z_STREAM_END&&v!==c.Z_OK)return this.onEnd(v),!(this.ended=!0);S.next_out&&(S.avail_out!==0&&v!==c.Z_STREAM_END&&(S.avail_in!==0||b!==c.Z_FINISH&&b!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=l.utf8border(S.output,S.next_out),N=S.next_out-w,j=l.buf2string(S.output,w),S.next_out=N,S.avail_out=P-N,N&&o.arraySet(S.output,S.output,w,N,0),this.onData(j)):this.onData(o.shrinkBuf(S.output,S.next_out)))),S.avail_in===0&&S.avail_out===0&&(C=!0)}while((0<S.avail_in||S.avail_out===0)&&v!==c.Z_STREAM_END);return v===c.Z_STREAM_END&&(b=c.Z_FINISH),b===c.Z_FINISH?(v=i.inflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===c.Z_OK):b!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(S.avail_out=0))},f.prototype.onData=function(g){this.chunks.push(g)},f.prototype.onEnd=function(g){g===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg}
vendor: 17,846 bytes, line 819
819,s.Inflate=f,s.inflate=x,s.inflateRaw=function(g,p){return(p=p||{}).raw=!0,x(g,p)},s.ungzip=x},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,s){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";s.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var h in d)d.hasOwnProperty(h)&&(c[h]=d[h])}}return c},s.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,h,m){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+h),m);else for(var f=0;f<h;f++)c[m+f]=u[d+f]},flattenChunks:function(c){var u,d,h,m,f,x;for(u=h=0,d=c.length;u<d;u++)h+=c[u].length;for(x=new Uint8Array(h),u=m=0,d=c.length;u<d;u++)f=c[u],x.set(f,m),m+=f.length;return x}},l={arraySet:function(c,u,d,h,m){for(var f=0;f<h;f++)c[m+f]=u[d+f]},flattenChunks:function(c){return[].concat.apply([],c)}};s.setTyped=function(c){c?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,o)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,l))},s.setTyped(i)},{}],42:[function(n,r,s){var i=n("./common"),o=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!1}for(var c=new i.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(h,m){if(m<65537&&(h.subarray&&l||!h.subarray&&o))return String.fromCharCode.apply(null,i.shrinkBuf(h,m));for(var f="",x=0;x<m;x++)f+=String.fromCharCode(h[x]);return f}c[254]=c[254]=1,s.string2buf=function(h){var m,f,x,g,p,v=h.length,b=0;for(g=0;g<v;g++)(64512&(f=h.charCodeAt(g)))==55296&&g+1<v&&(64512&(x=h.charCodeAt(g+1)))==56320&&(f=65536+(f-55296<<10)+(x-56320),g++),b+=f<128?1:f<2048?2:f<65536?3:4;for(m=new i.Buf8(b),g=p=0;p<b;g++)(64512&(f=h.charCodeAt(g)))==55296&&g+1<v&&(64512&(x=h.charCodeAt(g+1)))==56320&&(f=65536+(f-55296<<10)+(x-56320),g++),f<128?m[p++]=f:(f<2048?m[p++]=192|f>>>6:(f<65536?m[p++]=224|f>>>12:(m[p++]=240|f>>>18,m[p++]=128|f>>>12&63),m[p++]=128|f>>>6&63),m[p++]=128|63&f);return m},s.buf2binstring=function(h){return d(h,h.length)},s.binstring2buf=function(h){for(var m=new i.Buf8(h.length),f=0,x=m.length;f<x;f++)m[f]=h.charCodeAt(f);return m},s.buf2string=function(h,m){var f,x,g,p,v=m||h.length,b=new Array(2*v);for(f=x=0;f<v;)if((g=h[f++])<128)b[x++]=g;else if(4<(p=c[g]))b[x++]=65533,f+=p-1;else{for(g&=p===2?31:p===3?15:7;1<p&&f<v;)g=g<<6|63&h[f++],p--;1<p?b[x++]=65533:g<65536?b[x++]=g:(g-=65536,b[x++]=55296|g>>10&1023,b[x++]=56320|1023&g)}return d(b,x)},s.utf8border=function(h,m){var f;for((m=m||h.length)>h.length&&(m=h.length),f=m-1;0<=f&&(192&h[f])==128;)f--;return f<0||f===0?m:f+c[h[f]]>m?f:m}},{"./common":41}],43:[function(n,r,s){r.exports=function(i,o,l,c){for(var u=65535&i|0,d=i>>>16&65535|0,h=0;l!==0;){for(l-=h=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--h;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,s){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,s){var i=function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var u=0;u<8;u++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l}();r.exports=function(o,l,c,u){var d=i,h=u+c;o^=-1;for(var m=u;m<h;m++)o=o>>>8^d[255&(o^l[m])];return-1^o}},{}],46:[function(n,r,s){var i,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),h=0,m=4,f=0,x=-2,g=-1,p=4,v=2,b=8,w=9,N=286,j=30,_=19,S=2*N+1,P=15,k=3,C=258,T=C+k+1,O=42,L=113,E=1,R=2,q=3,I=4;function $(D,le){return D.msg=d[le],le}function M(D){return(D<<1)-(4<D?9:0)}function B(D){for(var le=D.length;0<=--le;)D[le]=0}function W(D){var le=D.state,V=le.pending;V>D.avail_out&&(V=D.avail_out),V!==0&&(o.arraySet(D.output,le.pending_buf,le.pending_out,V,D.next_out),D.next_out+=V,le.pending_out+=V,D.total_out+=V,D.avail_out-=V,le.pending-=V,le.pending===0&&(le.pending_out=0))}function A(D,le){l._tr_flush_block(D,0<=D.block_start?D.block_start:-1,D.strstart-D.block_start,le),D.block_start=D.strstart,W(D.strm)}function K(D,le){D.pending_buf[D.pending++]=le}function G(D,le){D.pending_buf[D.pending++]=le>>>8&255,D.pending_buf[D.pending++]=255&le}function H(D,le){var V,U,z=D.max_chain_length,Z=D.strstart,ve=D.prev_length,ee=D.nice_match,de=D.strstart>D.w_size-T?D.strstart-(D.w_size-T):0,je=D.window,Q=D.w_mask,oe=D.prev,Pe=D.strstart+C,ze=je[Z+ve-1],Je=je[Z+ve];D.prev_length>=D.good_match&&(z>>=2),ee>D.lookahead&&(ee=D.lookahead);do if(je[(V=le)+ve]===Je&&je[V+ve-1]===ze&&je[V]===je[Z]&&je[++V]===je[Z+1]){Z+=2,V++;do;while(je[++Z]===je[++V]&&je[++Z]===je[++V]&&je[++Z]===je[++V]&&je[++Z]===je[++V]&&je[++Z]===je[++V]&&je[++Z]===je[++V]&&je[++Z]===je[++V]&&je[++Z]===je[++V]&&Z<Pe);if(U=C-(Pe-Z),Z=Pe-C,ve<U){if(D.match_start=le,ee<=(ve=U))break;ze=je[Z+ve-1],Je=je[Z+ve]}}while((le=oe[le&Q])>de&&--z!=0);return ve<=D.lookahead?ve:D.lookahead}function fe(D){var le,V,U,z,Z,ve,ee,de,je,Q,oe=D.w_size;do{if(z=D.window_size-D.lookahead-D.strstart,D.strstart>=oe+(oe-T)){for(o.arraySet(D.window,D.window,oe,oe,0),D.match_start-=oe,D.strstart-=oe,D.block_start-=oe,le=V=D.hash_size;U=D.head[--le],D.head[le]=oe<=U?U-oe:0,--V;);for(le=V=oe;U=D.prev[--le],D.prev[le]=oe<=U?U-oe:0,--V;);z+=oe}if(D.strm.avail_in===0)break;if(ve=D.strm,ee=D.window,de=D.strstart+D.lookahead,je=z,Q=void 0,Q=ve.avail_in,je<Q&&(Q=je),V=Q===0?0:(ve.avail_in-=Q,o.arraySet(ee,ve.input,ve.next_in,Q,de),ve.state.wrap===1?ve.adler=c(ve.adler,ee,Q,de):ve.state.wrap===2&&(ve.adler=u(ve.adler,ee,Q,de)),ve.next_in+=Q,ve.total_in+=Q,Q),D.lookahead+=V,D.lookahead+D.insert>=k)for(Z=D.strstart-D.insert,D.ins_h=D.window[Z],D.ins_h=(D.ins_h<<D.hash_shift^D.window[Z+1])&D.hash_mask;D.insert&&(D.ins_h=(D.ins_h<<D.hash_shift^D.window[Z+k-1])&D.hash_mask,D.prev[Z&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=Z,Z++,D.insert--,!(D.lookahead+D.insert<k)););}while(D.lookahead<T&&D.strm.avail_in!==0)}function te(D,le){for(var V,U;;){if(D.lookahead<T){if(fe(D),D.lookahead<T&&le===h)return E;if(D.lookahead===0)break}if(V=0,D.lookahead>=k&&(D.ins_h=(D.ins_h<<D.hash_shift^D.window[D.strstart+k-1])&D.hash_mask,V=D.prev[D.strstart&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=D.strstart),V!==0&&D.strstart-V<=D.w_size-T&&(D.match_length=H(D,V)),D.match_length>=k)if(U=l._tr_tally(D,D.strstart-D.match_start,D.match_length-k),D.lookahead-=D.match_length,D.match_length<=D.max_lazy_match&&D.lookahead>=k){for(D.match_length--;D.strstart++,D.ins_h=(D.ins_h<<D.hash_shift^D.window[D.strstart+k-1])&D.hash_mask,V=D.prev[D.strstart&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=D.strstart,--D.match_length!=0;);D.strstart++}else D.strstart+=D.match_length,D.match_length=0,D.ins_h=D.window[D.strstart],D.ins_h=(D.ins_h<<D.hash_shift^D.window[D.strstart+1])&D.hash_mask;else U=l._tr_tally(D,0,D.window[D.strstart]),D.lookahead--,D.strstart++;if(U&&(A(D,!1),D.strm.avail_out===0))return E}return D.insert=D.strstart<k-1?D.strstart:k-1,le===m?(A(D,!0),D.strm.avail_out===0?q:I):D.last_lit&&(A(D,!1),D.strm.avail_out===0)?E:R}function J(D,le){for(var V,U,z;;){if(D.lookahead<T){if(fe(D),D.lookahead<T&&le===h)return E;if(D.lookahead===0)break}if(V=0,D.lookahead>=k&&(D.ins_h=(D.ins_h<<D.hash_shift^D.window[D.strstart+k-1])&D.hash_mask,V=D.prev[D.strstart&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=D.strstart),D.prev_length=D.match_length,D.prev_match=D.match_start,D.match_length=k-1,V!==0&&D.prev_length<D.max_lazy_match&&D.strstart-V<=D.w_size-T&&(D.match_length=H(D,V),D.match_length<=5&&(D.strategy===1||D.match_length===k&&4096<D.strstart-D.match_start)&&(D.match_length=k-1)),D.prev_length>=k&&D.match_length<=D.prev_length){for(z=D.strstart+D.lookahead-k,U=l._tr_tally(D,D.strstart-1-D.prev_match,D.prev_length-k),D.lookahead-=D.prev_length-1,D.prev_length-=2;++D.strstart<=z&&(D.ins_h=(D.ins_h<<D.hash_shift^D.window[D.strstart+k-1])&D.hash_mask,V=D.prev[D.strstart&D.w_mask]=D.head[D.ins_h],D.head[D.ins_h]=D.strstart),--D.prev_length!=0;);if(D.match_available=0,D.match_length=k-1,D.strstart++,U&&(A(D,!1),D.strm.avail_out===0))return E}else if(D.match_available){if((U=l._tr_tally(D,0,D.window[D.strstart-1]))&&A(D,!1),D.strstart++,D.lookahead--,D.strm.avail_out===0)return E}else D.match_available=1,D.strstart++,D.lookahead--}return D.match_available&&(U=l._tr_tally(D,0,D.window[D.strstart-1]),D.match_available=0),D.insert=D.strstart<k-1?D.strstart:k-1,le===m?(A(D,!0),D.strm.avail_out===0?q:I):D.last_lit&&(A(D,!1),D.strm.avail_out===0)?E:R}function re(D,le,V,U,z){this.good_length=D,this.max_lazy=le,this.nice_length=V,this.max_chain=U,this.func=z}function pe(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=b,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*S),this.dyn_dtree=new o.Buf16(2*(2*j+1)),this.bl_tree=new o.Buf16(2*(2*_+1)),B(this.dyn_ltree),B(this.dyn_dtree),B(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(P+1),this.heap=new o.Buf16(2*N+1),B(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*N+1),B(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ye(D){var le;return D&&D.state?(D.total_in=D.total_out=0,D.data_type=v,(le=D.state).pending=0,le.pending_out=0,le.wrap<0&&(le.wrap=-le.wrap),le.status=le.wrap?O:L,D.adler=le.wrap===2?0:1,le.last_flush=h,l._tr_init(le),f):$(D,x)}function X(D){var le=ye(D);return le===f&&function(V){V.window_size=2*V.w_size,B(V.head),V.max_lazy_match=i[V.level].max_lazy,V.good_match=i[V.level].good_length,V.nice_match=i[V.level].nice_length,V.max_chain_length=i[V.level].max_chain,V.strstart=0,V.block_start=0,V.lookahead=0,V.insert=0,V.match_length=V.prev_length=k-1,V.match_available=0,V.ins_h=0}(D.state),le}function he(D,le,V,U,z,Z){if(!D)return x;var ve=1;if(le===g&&(le=6),U<0?(ve=0,U=-U):15<U&&(ve=2,U-=16),z<1||w<z||V!==b||U<8||15<U||le<0||9<le||Z<0||p<Z)return $(D,x);U===8&&(U=9);var ee=new pe;return(D.state=ee).strm=D,ee.wrap=ve,ee.gzhead=null,ee.w_bits=U,ee.w_size=1<<ee.w_bits,ee.w_mask=ee.w_size-1,ee.hash_bits=z+7,ee.hash_size=1<<ee.hash_bits,ee.hash_mask=ee.hash_size-1,ee.hash_shift=~~((ee.hash_bits+k-1)/k),ee.window=new o.Buf8(2*ee.w_size),ee.head=new o.Buf16(ee.hash_size),ee.prev=new o.Buf16(ee.w_size),ee.lit_bufsize=1<<z+6,ee.pending_buf_size=4*ee.lit_bufsize,ee.pending_buf=new o.Buf8(ee.pending_buf_size),ee.d_buf=1*ee.lit_bufsize,ee.l_buf=3*ee.lit_bufsize,ee.level=le,ee.strategy=Z,ee.method=V,X(D)}i=[new re(0,0,0,0,function(D,le){var V=65535;for(V>D.pending_buf_size-5&&(V=D.pending_buf_size-5);;){if(D.lookahead<=1){if(fe(D),D.lookahead===0&&le===h)return E;if(D.lookahead===0)break}D.strstart+=D.lookahead,D.lookahead=0;var U=D.block_start+V;if((D.strstart===0||D.strstart>=U)&&(D.lookahead=D.strstart-U,D.strstart=U,A(D,!1),D.strm.avail_out===0)||D.strstart-D.block_start>=D.w_size-T&&(A(D,!1),D.strm.avail_out===0))return E}return D.insert=0,le===m?(A(D,!0),D.strm.avail_out===0?q:I):(D.strstart>D.block_start&&(A(D,!1),D.strm.avail_out),E)}),new re(4,4,8,4,te),new re(4,5,16,8,te),new re(4,6,32,32,te),new re(4,4,16,16,J),new re(8,16,32,32,J),new re(8,16,128,128,J),new re(8,32,128,256,J),new re(32,128,258,1024,J),new re(32,258,258,4096,J)],s.deflateInit=function(D,le){return he(D,le,b,15,8,0)},s.deflateInit2=he,s.deflateReset=X,s.deflateResetKeep=ye,s.deflateSetHeader=function(D,le){return D&&D.state?D.state.wrap!==2?x:(D.state.gzhead=le,f):x},s.deflate=function(D,le){var V,U,z,Z;if(!D||!D.state||5<le||le<0)return D?$(D,x):x;if(U=D.state,!D.output||!D.input&&D.avail_in!==0||U.status===666&&le!==m)return $(D,D.avail_out===0?-5:x);if(U.strm=D,V=U.last_flush,U.last_flush=le,U.status===O)if(U.wrap===2)D.adler=0,K(U,31),K(U,139),K(U,8),U.gzhead?(K(U,(U.gzhead.text?1:0)+(U.gzhead.hcrc?2:0)+(U.gzhead.extra?4:0)+(U.gzhead.name?8:0)+(U.gzhead.comment?16:0)),K(U,255&U.gzhead.time),K(U,U.gzhead.time>>8&255),K(U,U.gzhead.time>>16&255),K(U,U.gzhead.time>>24&255),K(U,U.level===9?2:2<=U.strategy||U.level<2?4:0),K(U,255&U.gzhead.os),U.gzhead.extra&&U.gzhead.extra.length&&(K(U,255&U.gzhead.extra.length),K(U,U.gzhead.extra.length>>8&255)),U.gzhead.hcrc&&(D.adler=u(D.adler,U.pending_buf,U.pending,0)),U.gzindex=0,U.status=69):(K(U,0),K(U,0),K(U,0),K(U,0),K(U,0),K(U,U.level===9?2:2<=U.strategy||U.level<2?4:0),K(U,3),U.status=L);else{var ve=b+(U.w_bits-8<<4)<<8;ve|=(2<=U.strategy||U.level<2?0:U.level<6?1:U.level===6?2:3)<<6,U.strstart!==0&&(ve|=32),ve+=31-ve%31,U.status=L,G(U,ve),U.strstart!==0&&(G(U,D.adler>>>16),G(U,65535&D.adler)),D.adler=1}if(U.status===69)if(U.gzhead.extra){for(z=U.pending;U.gzindex<(65535&U.gzhead.extra.length)&&(U.pending!==U.pending_buf_size||(U.gzhead.hcrc&&U.pending>z&&(D.adler=u(D.adler,U.pending_buf,U.pending-z,z)),W(D),z=U.pending,U.pending!==U.pending_buf_size));)K(U,255&U.gzhead.extra[U.gzindex]),U.gzindex++;U.gzhead.hcrc&&U.pending>z&&(D.adler=u(D.adler,U.pending_buf,U.pending-z,z)),U.gzindex===U.gzhead.extra.length&&(U.gzindex=0,U.status=73)}else U.status=73;if(U.status===73)if(U.gzhead.name){z=U.pending;do{if(U.pending===U.pending_buf_size&&(U.gzhead.hcrc&&U.pending>z&&(D.adler=u(D.adler,U.pending_buf,U.pending-z,z)),W(D),z=U.pending,U.pending===U.pending_buf_size)){Z=1;break}Z=U.gzindex<U.gzhead.name.length?255&U.gzhead.name.charCodeAt(U.gzindex++):0,K(U,Z)}while(Z!==0);U.gzhead.hcrc&&U.pending>z&&(D.adler=u(D.adler,U.pending_buf,U.pending-z,z)),Z===0&&(U.gzindex=0,U.status=91)}else U.status=91;if(U.status===91)if(U.gzhead.comment){z=U.pending;do{if(U.pending===U.pending_buf_size&&(U.gzhead.hcrc&&U.pending>z&&(D.adler=u(D.adler,U.pending_buf,U.pending-z,z)),W(D),z=U.pending,U.pending===U.pending_buf_size)){Z=1;break}Z=U.gzindex<U.gzhead.comment.length?255&U.gzhead.comment.charCodeAt(U.gzindex++):0,K(U,Z)}while(Z!==0);U.gzhead.hcrc&&U.pending>z&&(D.adler=u(D.adler,U.pending_buf,U.pending-z,z)),Z===0&&(U.status=103)}else U.status=103;if(U.status===103&&(U.gzhead.hcrc?(U.pending+2>U.pending_buf_size&&W(D),U.pending+2<=U.pending_buf_size&&(K(U,255&D.adler),K(U,D.adler>>8&255),D.adler=0,U.status=L)):U.status=L),U.pending!==0){if(W(D),D.avail_out===0)return U.last_flush=-1,f}else if(D.avail_in===0&&M(le)<=M(V)&&le!==m)return $(D,-5);if(U.status===666&&D.avail_in!==0)return $(D,-5);if(D.avail_in!==0||U.lookahead!==0||le!==h&&U.status!==666){var ee=U.strategy===2?function(de,je){for(var Q;;){if(de.lookahead===0&&(fe(de),de.lookahead===0)){if(je===h)return E;break}if(de.match_length=0,Q=l._tr_tally(de,0,de.window[de.strstart]),de.lookahead--,de.strstart++,Q&&(A(de,!1),de.strm.avail_out===0))return E}return de.insert=0,je===m?(A(de,!0),de.strm.avail_out===0?q:I):de.last_lit&&(A(de,!1),de.strm.avail_out===0)?E:R}(U,le):U.strategy===3?function(de,je){for(var Q,oe,Pe,ze,Je=de.window;;){if(de.lookahead<=C){if(fe(de),de.lookahead<=C&&je===h)return E;if(de.lookahead===0)break}if(de.match_length=0,de.lookahead>=k&&0<de.strstart&&(oe=Je[Pe=de.strstart-1])===Je[++Pe]&&oe===Je[++Pe]&&oe===Je[++Pe]){ze=de.strstart+C;do;while(oe===Je[++Pe]&&oe===Je[++Pe]&&oe===Je[++Pe]&&oe===Je[++Pe]&&oe===Je[++Pe]&&oe===Je[++Pe]&&oe===Je[++Pe]&&oe===Je[++Pe]&&Pe<ze);de.match_length=C-(ze-Pe),de.match_length>de.lookahead&&(de.match_length=de.lookahead)}if(de.match_length>=k?(Q=l._tr_tally(de,1,de.match_length-k),de.lookahead-=de.match_length,de.strstart+=de.match_length,de.match_length=0):(Q=l._tr_tally(de,0,de.window[de.strstart]),de.lookahead--,de.strstart++),Q&&(A(de,!1),de.strm.avail_out===0))return E}return de.insert=0,je===m?(A(de,!0),de.strm.avail_out===0?q:I):de.last_lit&&(A(de,!1),de.strm.avail_out===0)?E:R}(U,le):i[U.level].func(U,le);if(ee!==q&&ee!==I||(U.status=666),ee===E||ee===q)return D.avail_out===0&&(U.last_flush=-1),f;if(ee===R&&(le===1?l._tr_align(U):le!==5&&(l._tr_stored_block(U,0,0,!1),le===3&&(B(U.head),U.lookahead===0&&(U.strstart=0,U.block_start=0,U.insert=0))),W(D),D.avail_out===0))return U.last_flush=-1,f}return le!==m?f:U.wrap<=0?1:(U.wrap===2?(K(U,255&D.adler),K(U,D.adler>>8&255),K(U,D.adler>>16&255),K(U,D.adler>>24&255),K(U,255&D.total_in),K(U,D.total_in>>8&255),K(U,D.total_in>>16&255),K(U,D.total_in>>24&255)):(G(U,D.adler>>>16),G(U,65535&D.adler)),W(D),0<U.wrap&&(U.wrap=-U.wrap),U.pending!==0?f:1)},s.deflateEnd=function(D){var le;return D&&D.state?(le=D.state.status)!==O&&le!==69&&le!==73&&le!==91&&le!==103&&le!==L&&le!==666?$(D,x):(D.state=null,le===L?$(D,-3):f):x},s.deflateSetDictionary=function(D,le){var V,U,z,Z,ve,ee,de,je,Q=le.length;if(!D||!D.state||(Z=(V=D.state).wrap)===2||Z===1&&V.status!==O||V.lookahead)return x;for(Z===1&&(D.adler=c(D.adler,le,Q,0)),V.wrap=0,Q>=V.w_size&&(Z===0&&(B(V.head),V.strstart=0,V.block_start=0,V.insert=0),je=new o.Buf8(V.w_size),o.arraySet(je,le,Q-V.w_size,V.w_size,0),le=je,Q=V.w_size),ve=D.avail_in,ee=D.next_in,de=D.input,D.avail_in=Q,D.next_in=0,D.input=le,fe(V);V.lookahead>=k;){for(U=V.strstart,z=V.lookahead-(k-1);
vendor: 13,785 bytes, line 819
819V.ins_h=(V.ins_h<<V.hash_shift^V.window[U+k-1])&V.hash_mask,V.prev[U&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=U,U++,--z;);V.strstart=U,V.lookahead=k-1,fe(V)}return V.strstart+=V.lookahead,V.block_start=V.strstart,V.insert=V.lookahead,V.lookahead=0,V.match_length=V.prev_length=k-1,V.match_available=0,D.next_in=ee,D.input=de,D.avail_in=ve,V.wrap=Z,f},s.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,s){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,s){r.exports=function(i,o){var l,c,u,d,h,m,f,x,g,p,v,b,w,N,j,_,S,P,k,C,T,O,L,E,R;l=i.state,c=i.next_in,E=i.input,u=c+(i.avail_in-5),d=i.next_out,R=i.output,h=d-(o-i.avail_out),m=d+(i.avail_out-257),f=l.dmax,x=l.wsize,g=l.whave,p=l.wnext,v=l.window,b=l.hold,w=l.bits,N=l.lencode,j=l.distcode,_=(1<<l.lenbits)-1,S=(1<<l.distbits)-1;e:do{w<15&&(b+=E[c++]<<w,w+=8,b+=E[c++]<<w,w+=8),P=N[b&_];t:for(;;){if(b>>>=k=P>>>24,w-=k,(k=P>>>16&255)===0)R[d++]=65535&P;else{if(!(16&k)){if(!(64&k)){P=N[(65535&P)+(b&(1<<k)-1)];continue t}if(32&k){l.mode=12;break e}i.msg="invalid literal/length code",l.mode=30;break e}C=65535&P,(k&=15)&&(w<k&&(b+=E[c++]<<w,w+=8),C+=b&(1<<k)-1,b>>>=k,w-=k),w<15&&(b+=E[c++]<<w,w+=8,b+=E[c++]<<w,w+=8),P=j[b&S];n:for(;;){if(b>>>=k=P>>>24,w-=k,!(16&(k=P>>>16&255))){if(!(64&k)){P=j[(65535&P)+(b&(1<<k)-1)];continue n}i.msg="invalid distance code",l.mode=30;break e}if(T=65535&P,w<(k&=15)&&(b+=E[c++]<<w,(w+=8)<k&&(b+=E[c++]<<w,w+=8)),f<(T+=b&(1<<k)-1)){i.msg="invalid distance too far back",l.mode=30;break e}if(b>>>=k,w-=k,(k=d-h)<T){if(g<(k=T-k)&&l.sane){i.msg="invalid distance too far back",l.mode=30;break e}if(L=v,(O=0)===p){if(O+=x-k,k<C){for(C-=k;R[d++]=v[O++],--k;);O=d-T,L=R}}else if(p<k){if(O+=x+p-k,(k-=p)<C){for(C-=k;R[d++]=v[O++],--k;);if(O=0,p<C){for(C-=k=p;R[d++]=v[O++],--k;);O=d-T,L=R}}}else if(O+=p-k,k<C){for(C-=k;R[d++]=v[O++],--k;);O=d-T,L=R}for(;2<C;)R[d++]=L[O++],R[d++]=L[O++],R[d++]=L[O++],C-=3;C&&(R[d++]=L[O++],1<C&&(R[d++]=L[O++]))}else{for(O=d-T;R[d++]=R[O++],R[d++]=R[O++],R[d++]=R[O++],2<(C-=3););C&&(R[d++]=R[O++],1<C&&(R[d++]=R[O++]))}break}}break}}while(c<u&&d<m);c-=C=w>>3,b&=(1<<(w-=C<<3))-1,i.next_in=c,i.next_out=d,i.avail_in=c<u?u-c+5:5-(c-u),i.avail_out=d<m?m-d+257:257-(d-m),l.hold=b,l.bits=w}},{}],49:[function(n,r,s){var i=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,h=2,m=0,f=-2,x=1,g=852,p=592;function v(O){return(O>>>24&255)+(O>>>8&65280)+((65280&O)<<8)+((255&O)<<24)}function b(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(O){var L;return O&&O.state?(L=O.state,O.total_in=O.total_out=L.total=0,O.msg="",L.wrap&&(O.adler=1&L.wrap),L.mode=x,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new i.Buf32(g),L.distcode=L.distdyn=new i.Buf32(p),L.sane=1,L.back=-1,m):f}function N(O){var L;return O&&O.state?((L=O.state).wsize=0,L.whave=0,L.wnext=0,w(O)):f}function j(O,L){var E,R;return O&&O.state?(R=O.state,L<0?(E=0,L=-L):(E=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?f:(R.window!==null&&R.wbits!==L&&(R.window=null),R.wrap=E,R.wbits=L,N(O))):f}function _(O,L){var E,R;return O?(R=new b,(O.state=R).window=null,(E=j(O,L))!==m&&(O.state=null),E):f}var S,P,k=!0;function C(O){if(k){var L;for(S=new i.Buf32(512),P=new i.Buf32(32),L=0;L<144;)O.lens[L++]=8;for(;L<256;)O.lens[L++]=9;for(;L<280;)O.lens[L++]=7;for(;L<288;)O.lens[L++]=8;for(u(d,O.lens,0,288,S,0,O.work,{bits:9}),L=0;L<32;)O.lens[L++]=5;u(h,O.lens,0,32,P,0,O.work,{bits:5}),k=!1}O.lencode=S,O.lenbits=9,O.distcode=P,O.distbits=5}function T(O,L,E,R){var q,I=O.state;return I.window===null&&(I.wsize=1<<I.wbits,I.wnext=0,I.whave=0,I.window=new i.Buf8(I.wsize)),R>=I.wsize?(i.arraySet(I.window,L,E-I.wsize,I.wsize,0),I.wnext=0,I.whave=I.wsize):(R<(q=I.wsize-I.wnext)&&(q=R),i.arraySet(I.window,L,E-R,q,I.wnext),(R-=q)?(i.arraySet(I.window,L,E-R,R,0),I.wnext=R,I.whave=I.wsize):(I.wnext+=q,I.wnext===I.wsize&&(I.wnext=0),I.whave<I.wsize&&(I.whave+=q))),0}s.inflateReset=N,s.inflateReset2=j,s.inflateResetKeep=w,s.inflateInit=function(O){return _(O,15)},s.inflateInit2=_,s.inflate=function(O,L){var E,R,q,I,$,M,B,W,A,K,G,H,fe,te,J,re,pe,ye,X,he,D,le,V,U,z=0,Z=new i.Buf8(4),ve=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!O||!O.state||!O.output||!O.input&&O.avail_in!==0)return f;(E=O.state).mode===12&&(E.mode=13),$=O.next_out,q=O.output,B=O.avail_out,I=O.next_in,R=O.input,M=O.avail_in,W=E.hold,A=E.bits,K=M,G=B,le=m;e:for(;;)switch(E.mode){case x:if(E.wrap===0){E.mode=13;break}for(;A<16;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}if(2&E.wrap&&W===35615){Z[E.check=0]=255&W,Z[1]=W>>>8&255,E.check=l(E.check,Z,2,0),A=W=0,E.mode=2;break}if(E.flags=0,E.head&&(E.head.done=!1),!(1&E.wrap)||(((255&W)<<8)+(W>>8))%31){O.msg="incorrect header check",E.mode=30;break}if((15&W)!=8){O.msg="unknown compression method",E.mode=30;break}if(A-=4,D=8+(15&(W>>>=4)),E.wbits===0)E.wbits=D;else if(D>E.wbits){O.msg="invalid window size",E.mode=30;break}E.dmax=1<<D,O.adler=E.check=1,E.mode=512&W?10:12,A=W=0;break;case 2:for(;A<16;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}if(E.flags=W,(255&E.flags)!=8){O.msg="unknown compression method",E.mode=30;break}if(57344&E.flags){O.msg="unknown header flags set",E.mode=30;break}E.head&&(E.head.text=W>>8&1),512&E.flags&&(Z[0]=255&W,Z[1]=W>>>8&255,E.check=l(E.check,Z,2,0)),A=W=0,E.mode=3;case 3:for(;A<32;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}E.head&&(E.head.time=W),512&E.flags&&(Z[0]=255&W,Z[1]=W>>>8&255,Z[2]=W>>>16&255,Z[3]=W>>>24&255,E.check=l(E.check,Z,4,0)),A=W=0,E.mode=4;case 4:for(;A<16;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}E.head&&(E.head.xflags=255&W,E.head.os=W>>8),512&E.flags&&(Z[0]=255&W,Z[1]=W>>>8&255,E.check=l(E.check,Z,2,0)),A=W=0,E.mode=5;case 5:if(1024&E.flags){for(;A<16;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}E.length=W,E.head&&(E.head.extra_len=W),512&E.flags&&(Z[0]=255&W,Z[1]=W>>>8&255,E.check=l(E.check,Z,2,0)),A=W=0}else E.head&&(E.head.extra=null);E.mode=6;case 6:if(1024&E.flags&&(M<(H=E.length)&&(H=M),H&&(E.head&&(D=E.head.extra_len-E.length,E.head.extra||(E.head.extra=new Array(E.head.extra_len)),i.arraySet(E.head.extra,R,I,H,D)),512&E.flags&&(E.check=l(E.check,R,H,I)),M-=H,I+=H,E.length-=H),E.length))break e;E.length=0,E.mode=7;case 7:if(2048&E.flags){if(M===0)break e;for(H=0;D=R[I+H++],E.head&&D&&E.length<65536&&(E.head.name+=String.fromCharCode(D)),D&&H<M;);if(512&E.flags&&(E.check=l(E.check,R,H,I)),M-=H,I+=H,D)break e}else E.head&&(E.head.name=null);E.length=0,E.mode=8;case 8:if(4096&E.flags){if(M===0)break e;for(H=0;D=R[I+H++],E.head&&D&&E.length<65536&&(E.head.comment+=String.fromCharCode(D)),D&&H<M;);if(512&E.flags&&(E.check=l(E.check,R,H,I)),M-=H,I+=H,D)break e}else E.head&&(E.head.comment=null);E.mode=9;case 9:if(512&E.flags){for(;A<16;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}if(W!==(65535&E.check)){O.msg="header crc mismatch",E.mode=30;break}A=W=0}E.head&&(E.head.hcrc=E.flags>>9&1,E.head.done=!0),O.adler=E.check=0,E.mode=12;break;case 10:for(;A<32;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}O.adler=E.check=v(W),A=W=0,E.mode=11;case 11:if(E.havedict===0)return O.next_out=$,O.avail_out=B,O.next_in=I,O.avail_in=M,E.hold=W,E.bits=A,2;O.adler=E.check=1,E.mode=12;case 12:if(L===5||L===6)break e;case 13:if(E.last){W>>>=7&A,A-=7&A,E.mode=27;break}for(;A<3;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}switch(E.last=1&W,A-=1,3&(W>>>=1)){case 0:E.mode=14;break;case 1:if(C(E),E.mode=20,L!==6)break;W>>>=2,A-=2;break e;case 2:E.mode=17;break;case 3:O.msg="invalid block type",E.mode=30}W>>>=2,A-=2;break;case 14:for(W>>>=7&A,A-=7&A;A<32;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}if((65535&W)!=(W>>>16^65535)){O.msg="invalid stored block lengths",E.mode=30;break}if(E.length=65535&W,A=W=0,E.mode=15,L===6)break e;case 15:E.mode=16;case 16:if(H=E.length){if(M<H&&(H=M),B<H&&(H=B),H===0)break e;i.arraySet(q,R,I,H,$),M-=H,I+=H,B-=H,$+=H,E.length-=H;break}E.mode=12;break;case 17:for(;A<14;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}if(E.nlen=257+(31&W),W>>>=5,A-=5,E.ndist=1+(31&W),W>>>=5,A-=5,E.ncode=4+(15&W),W>>>=4,A-=4,286<E.nlen||30<E.ndist){O.msg="too many length or distance symbols",E.mode=30;break}E.have=0,E.mode=18;case 18:for(;E.have<E.ncode;){for(;A<3;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}E.lens[ve[E.have++]]=7&W,W>>>=3,A-=3}for(;E.have<19;)E.lens[ve[E.have++]]=0;if(E.lencode=E.lendyn,E.lenbits=7,V={bits:E.lenbits},le=u(0,E.lens,0,19,E.lencode,0,E.work,V),E.lenbits=V.bits,le){O.msg="invalid code lengths set",E.mode=30;break}E.have=0,E.mode=19;case 19:for(;E.have<E.nlen+E.ndist;){for(;re=(z=E.lencode[W&(1<<E.lenbits)-1])>>>16&255,pe=65535&z,!((J=z>>>24)<=A);){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}if(pe<16)W>>>=J,A-=J,E.lens[E.have++]=pe;else{if(pe===16){for(U=J+2;A<U;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}if(W>>>=J,A-=J,E.have===0){O.msg="invalid bit length repeat",E.mode=30;break}D=E.lens[E.have-1],H=3+(3&W),W>>>=2,A-=2}else if(pe===17){for(U=J+3;A<U;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}A-=J,D=0,H=3+(7&(W>>>=J)),W>>>=3,A-=3}else{for(U=J+7;A<U;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}A-=J,D=0,H=11+(127&(W>>>=J)),W>>>=7,A-=7}if(E.have+H>E.nlen+E.ndist){O.msg="invalid bit length repeat",E.mode=30;break}for(;H--;)E.lens[E.have++]=D}}if(E.mode===30)break;if(E.lens[256]===0){O.msg="invalid code -- missing end-of-block",E.mode=30;break}if(E.lenbits=9,V={bits:E.lenbits},le=u(d,E.lens,0,E.nlen,E.lencode,0,E.work,V),E.lenbits=V.bits,le){O.msg="invalid literal/lengths set",E.mode=30;break}if(E.distbits=6,E.distcode=E.distdyn,V={bits:E.distbits},le=u(h,E.lens,E.nlen,E.ndist,E.distcode,0,E.work,V),E.distbits=V.bits,le){O.msg="invalid distances set",E.mode=30;break}if(E.mode=20,L===6)break e;case 20:E.mode=21;case 21:if(6<=M&&258<=B){O.next_out=$,O.avail_out=B,O.next_in=I,O.avail_in=M,E.hold=W,E.bits=A,c(O,G),$=O.next_out,q=O.output,B=O.avail_out,I=O.next_in,R=O.input,M=O.avail_in,W=E.hold,A=E.bits,E.mode===12&&(E.back=-1);break}for(E.back=0;re=(z=E.lencode[W&(1<<E.lenbits)-1])>>>16&255,pe=65535&z,!((J=z>>>24)<=A);){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}if(re&&!(240&re)){for(ye=J,X=re,he=pe;re=(z=E.lencode[he+((W&(1<<ye+X)-1)>>ye)])>>>16&255,pe=65535&z,!(ye+(J=z>>>24)<=A);){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}W>>>=ye,A-=ye,E.back+=ye}if(W>>>=J,A-=J,E.back+=J,E.length=pe,re===0){E.mode=26;break}if(32&re){E.back=-1,E.mode=12;break}if(64&re){O.msg="invalid literal/length code",E.mode=30;break}E.extra=15&re,E.mode=22;case 22:if(E.extra){for(U=E.extra;A<U;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}E.length+=W&(1<<E.extra)-1,W>>>=E.extra,A-=E.extra,E.back+=E.extra}E.was=E.length,E.mode=23;case 23:for(;re=(z=E.distcode[W&(1<<E.distbits)-1])>>>16&255,pe=65535&z,!((J=z>>>24)<=A);){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}if(!(240&re)){for(ye=J,X=re,he=pe;re=(z=E.distcode[he+((W&(1<<ye+X)-1)>>ye)])>>>16&255,pe=65535&z,!(ye+(J=z>>>24)<=A);){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}W>>>=ye,A-=ye,E.back+=ye}if(W>>>=J,A-=J,E.back+=J,64&re){O.msg="invalid distance code",E.mode=30;break}E.offset=pe,E.extra=15&re,E.mode=24;case 24:if(E.extra){for(U=E.extra;A<U;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}E.offset+=W&(1<<E.extra)-1,W>>>=E.extra,A-=E.extra,E.back+=E.extra}if(E.offset>E.dmax){O.msg="invalid distance too far back",E.mode=30;break}E.mode=25;case 25:if(B===0)break e;if(H=G-B,E.offset>H){if((H=E.offset-H)>E.whave&&E.sane){O.msg="invalid distance too far back",E.mode=30;break}fe=H>E.wnext?(H-=E.wnext,E.wsize-H):E.wnext-H,H>E.length&&(H=E.length),te=E.window}else te=q,fe=$-E.offset,H=E.length;for(B<H&&(H=B),B-=H,E.length-=H;q[$++]=te[fe++],--H;);E.length===0&&(E.mode=21);break;case 26:if(B===0)break e;q[$++]=E.length,B--,E.mode=21;break;case 27:if(E.wrap){for(;A<32;){if(M===0)break e;M--,W|=R[I++]<<A,A+=8}if(G-=B,O.total_out+=G,E.total+=G,G&&(O.adler=E.check=E.flags?l(E.check,q,G,$-G):o(E.check,q,G,$-G)),G=B,(E.flags?W:v(W))!==E.check){O.msg="incorrect data check",E.mode=30;break}A=W=0}E.mode=28;case 28:if(E.wrap&&E.flags){for(;A<32;){if(M===0)break e;M--,W+=R[I++]<<A,A+=8}if(W!==(4294967295&E.total)){O.msg="incorrect length check",E.mode=30;break}A=W=0}E.mode=29;case 29:le=1;break e;case 30:le=-3;break e;case 31:return-4;case 32:default:return f}return O.next_out=$,O.avail_out=B,O.next_in=I,O.avail_in=M,E.hold=W,E.bits=A,(E.wsize||G!==O.avail_out&&E.mode<30&&(E.mode<27||L!==4))&&T(O,O.output,O.next_out,G-O.avail_out)?(E.mode=31,-4):(K-=O.avail_in,G-=O.avail_out,O.total_in+=K,O.total_out+=G,E.total+=G,E.wrap&&G&&(O.adler=E.check=E.flags?l(E.check,q,G,O.next_out-G):o(E.check,q,G,O.next_out-G)),O.data_type=E.bits+(E.last?64:0)+(E.mode===12?128:0)+(E.mode===20||E.mode===15?256:0),(K==0&&G===0||L===4)&&le===m&&(le=-5),le)},s.inflateEnd=function(O){if(!O||!O.state)return f;var L=O.state;return L.window&&(L.window=null),O.state=null,m},s.inflateGetHeader=function(O,L){var E;return O&&O.state&&2&(E=O.state).wrap?((E.head=L).done=!1,m):f},s.inflateSetDictionary=function(O,L){var E,R=L.length;return O&&O.state?(E=O.state).wrap!==0&&E.mode!==11?f:E.mode===11&&o(1,L,R,0)!==E.check?-3:T(O,L,R,R)?(E.mode=31,-4):(E.havedict=1,m):f},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}
vendor: 10,541 bytes, line 819
819],50:[function(n,r,s){var i=n("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,h,m,f,x,g,p,v){var b,w,N,j,_,S,P,k,C,T=v.bits,O=0,L=0,E=0,R=0,q=0,I=0,$=0,M=0,B=0,W=0,A=null,K=0,G=new i.Buf16(16),H=new i.Buf16(16),fe=null,te=0;for(O=0;O<=15;O++)G[O]=0;for(L=0;L<f;L++)G[h[m+L]]++;for(q=T,R=15;1<=R&&G[R]===0;R--);if(R<q&&(q=R),R===0)return x[g++]=20971520,x[g++]=20971520,v.bits=1,0;for(E=1;E<R&&G[E]===0;E++);for(q<E&&(q=E),O=M=1;O<=15;O++)if(M<<=1,(M-=G[O])<0)return-1;if(0<M&&(d===0||R!==1))return-1;for(H[1]=0,O=1;O<15;O++)H[O+1]=H[O]+G[O];for(L=0;L<f;L++)h[m+L]!==0&&(p[H[h[m+L]]++]=L);if(S=d===0?(A=fe=p,19):d===1?(A=o,K-=257,fe=l,te-=257,256):(A=c,fe=u,-1),O=E,_=g,$=L=W=0,N=-1,j=(B=1<<(I=q))-1,d===1&&852<B||d===2&&592<B)return 1;for(;;){for(P=O-$,C=p[L]<S?(k=0,p[L]):p[L]>S?(k=fe[te+p[L]],A[K+p[L]]):(k=96,0),b=1<<O-$,E=w=1<<I;x[_+(W>>$)+(w-=b)]=P<<24|k<<16|C|0,w!==0;);for(b=1<<O-1;W&b;)b>>=1;if(b!==0?(W&=b-1,W+=b):W=0,L++,--G[O]==0){if(O===R)break;O=h[m+p[L]]}if(q<O&&(W&j)!==N){for($===0&&($=q),_+=E,M=1<<(I=O-$);I+$<R&&!((M-=G[I+$])<=0);)I++,M<<=1;if(B+=1<<I,d===1&&852<B||d===2&&592<B)return 1;x[N=W&j]=q<<24|I<<16|_-g|0}}return W!==0&&(x[_+W]=O-$<<24|64<<16|0),v.bits=q,0}},{"../utils/common":41}],51:[function(n,r,s){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,s){var i=n("../utils/common"),o=0,l=1;function c(z){for(var Z=z.length;0<=--Z;)z[Z]=0}var u=0,d=29,h=256,m=h+1+d,f=30,x=19,g=2*m+1,p=15,v=16,b=7,w=256,N=16,j=17,_=18,S=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],P=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],k=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],T=new Array(2*(m+2));c(T);var O=new Array(2*f);c(O);var L=new Array(512);c(L);var E=new Array(256);c(E);var R=new Array(d);c(R);var q,I,$,M=new Array(f);function B(z,Z,ve,ee,de){this.static_tree=z,this.extra_bits=Z,this.extra_base=ve,this.elems=ee,this.max_length=de,this.has_stree=z&&z.length}function W(z,Z){this.dyn_tree=z,this.max_code=0,this.stat_desc=Z}function A(z){return z<256?L[z]:L[256+(z>>>7)]}function K(z,Z){z.pending_buf[z.pending++]=255&Z,z.pending_buf[z.pending++]=Z>>>8&255}function G(z,Z,ve){z.bi_valid>v-ve?(z.bi_buf|=Z<<z.bi_valid&65535,K(z,z.bi_buf),z.bi_buf=Z>>v-z.bi_valid,z.bi_valid+=ve-v):(z.bi_buf|=Z<<z.bi_valid&65535,z.bi_valid+=ve)}function H(z,Z,ve){G(z,ve[2*Z],ve[2*Z+1])}function fe(z,Z){for(var ve=0;ve|=1&z,z>>>=1,ve<<=1,0<--Z;);return ve>>>1}function te(z,Z,ve){var ee,de,je=new Array(p+1),Q=0;for(ee=1;ee<=p;ee++)je[ee]=Q=Q+ve[ee-1]<<1;for(de=0;de<=Z;de++){var oe=z[2*de+1];oe!==0&&(z[2*de]=fe(je[oe]++,oe))}}function J(z){var Z;for(Z=0;Z<m;Z++)z.dyn_ltree[2*Z]=0;for(Z=0;Z<f;Z++)z.dyn_dtree[2*Z]=0;for(Z=0;Z<x;Z++)z.bl_tree[2*Z]=0;z.dyn_ltree[2*w]=1,z.opt_len=z.static_len=0,z.last_lit=z.matches=0}function re(z){8<z.bi_valid?K(z,z.bi_buf):0<z.bi_valid&&(z.pending_buf[z.pending++]=z.bi_buf),z.bi_buf=0,z.bi_valid=0}function pe(z,Z,ve,ee){var de=2*Z,je=2*ve;return z[de]<z[je]||z[de]===z[je]&&ee[Z]<=ee[ve]}function ye(z,Z,ve){for(var ee=z.heap[ve],de=ve<<1;de<=z.heap_len&&(de<z.heap_len&&pe(Z,z.heap[de+1],z.heap[de],z.depth)&&de++,!pe(Z,ee,z.heap[de],z.depth));)z.heap[ve]=z.heap[de],ve=de,de<<=1;z.heap[ve]=ee}function X(z,Z,ve){var ee,de,je,Q,oe=0;if(z.last_lit!==0)for(;ee=z.pending_buf[z.d_buf+2*oe]<<8|z.pending_buf[z.d_buf+2*oe+1],de=z.pending_buf[z.l_buf+oe],oe++,ee===0?H(z,de,Z):(H(z,(je=E[de])+h+1,Z),(Q=S[je])!==0&&G(z,de-=R[je],Q),H(z,je=A(--ee),ve),(Q=P[je])!==0&&G(z,ee-=M[je],Q)),oe<z.last_lit;);H(z,w,Z)}function he(z,Z){var ve,ee,de,je=Z.dyn_tree,Q=Z.stat_desc.static_tree,oe=Z.stat_desc.has_stree,Pe=Z.stat_desc.elems,ze=-1;for(z.heap_len=0,z.heap_max=g,ve=0;ve<Pe;ve++)je[2*ve]!==0?(z.heap[++z.heap_len]=ze=ve,z.depth[ve]=0):je[2*ve+1]=0;for(;z.heap_len<2;)je[2*(de=z.heap[++z.heap_len]=ze<2?++ze:0)]=1,z.depth[de]=0,z.opt_len--,oe&&(z.static_len-=Q[2*de+1]);for(Z.max_code=ze,ve=z.heap_len>>1;1<=ve;ve--)ye(z,je,ve);for(de=Pe;ve=z.heap[1],z.heap[1]=z.heap[z.heap_len--],ye(z,je,1),ee=z.heap[1],z.heap[--z.heap_max]=ve,z.heap[--z.heap_max]=ee,je[2*de]=je[2*ve]+je[2*ee],z.depth[de]=(z.depth[ve]>=z.depth[ee]?z.depth[ve]:z.depth[ee])+1,je[2*ve+1]=je[2*ee+1]=de,z.heap[1]=de++,ye(z,je,1),2<=z.heap_len;);z.heap[--z.heap_max]=z.heap[1],function(Je,Ae){var et,Ne,be,Ue,Ze,nt,rt=Ae.dyn_tree,kt=Ae.max_code,jt=Ae.stat_desc.static_tree,Et=Ae.stat_desc.has_stree,Nt=Ae.stat_desc.extra_bits,ue=Ae.stat_desc.extra_base,we=Ae.stat_desc.max_length,Ie=0;for(Ue=0;Ue<=p;Ue++)Je.bl_count[Ue]=0;for(rt[2*Je.heap[Je.heap_max]+1]=0,et=Je.heap_max+1;et<g;et++)we<(Ue=rt[2*rt[2*(Ne=Je.heap[et])+1]+1]+1)&&(Ue=we,Ie++),rt[2*Ne+1]=Ue,kt<Ne||(Je.bl_count[Ue]++,Ze=0,ue<=Ne&&(Ze=Nt[Ne-ue]),nt=rt[2*Ne],Je.opt_len+=nt*(Ue+Ze),Et&&(Je.static_len+=nt*(jt[2*Ne+1]+Ze)));if(Ie!==0){do{for(Ue=we-1;Je.bl_count[Ue]===0;)Ue--;Je.bl_count[Ue]--,Je.bl_count[Ue+1]+=2,Je.bl_count[we]--,Ie-=2}while(0<Ie);for(Ue=we;Ue!==0;Ue--)for(Ne=Je.bl_count[Ue];Ne!==0;)kt<(be=Je.heap[--et])||(rt[2*be+1]!==Ue&&(Je.opt_len+=(Ue-rt[2*be+1])*rt[2*be],rt[2*be+1]=Ue),Ne--)}}(z,Z),te(je,ze,z.bl_count)}function D(z,Z,ve){var ee,de,je=-1,Q=Z[1],oe=0,Pe=7,ze=4;for(Q===0&&(Pe=138,ze=3),Z[2*(ve+1)+1]=65535,ee=0;ee<=ve;ee++)de=Q,Q=Z[2*(ee+1)+1],++oe<Pe&&de===Q||(oe<ze?z.bl_tree[2*de]+=oe:de!==0?(de!==je&&z.bl_tree[2*de]++,z.bl_tree[2*N]++):oe<=10?z.bl_tree[2*j]++:z.bl_tree[2*_]++,je=de,ze=(oe=0)===Q?(Pe=138,3):de===Q?(Pe=6,3):(Pe=7,4))}function le(z,Z,ve){var ee,de,je=-1,Q=Z[1],oe=0,Pe=7,ze=4;for(Q===0&&(Pe=138,ze=3),ee=0;ee<=ve;ee++)if(de=Q,Q=Z[2*(ee+1)+1],!(++oe<Pe&&de===Q)){if(oe<ze)for(;H(z,de,z.bl_tree),--oe!=0;);else de!==0?(de!==je&&(H(z,de,z.bl_tree),oe--),H(z,N,z.bl_tree),G(z,oe-3,2)):oe<=10?(H(z,j,z.bl_tree),G(z,oe-3,3)):(H(z,_,z.bl_tree),G(z,oe-11,7));je=de,ze=(oe=0)===Q?(Pe=138,3):de===Q?(Pe=6,3):(Pe=7,4)}}c(M);var V=!1;function U(z,Z,ve,ee){G(z,(u<<1)+(ee?1:0),3),function(de,je,Q,oe){re(de),K(de,Q),K(de,~Q),i.arraySet(de.pending_buf,de.window,je,Q,de.pending),de.pending+=Q}(z,Z,ve)}s._tr_init=function(z){V||(function(){var Z,ve,ee,de,je,Q=new Array(p+1);for(de=ee=0;de<d-1;de++)for(R[de]=ee,Z=0;Z<1<<S[de];Z++)E[ee++]=de;for(E[ee-1]=de,de=je=0;de<16;de++)for(M[de]=je,Z=0;Z<1<<P[de];Z++)L[je++]=de;for(je>>=7;de<f;de++)for(M[de]=je<<7,Z=0;Z<1<<P[de]-7;Z++)L[256+je++]=de;for(ve=0;ve<=p;ve++)Q[ve]=0;for(Z=0;Z<=143;)T[2*Z+1]=8,Z++,Q[8]++;for(;Z<=255;)T[2*Z+1]=9,Z++,Q[9]++;for(;Z<=279;)T[2*Z+1]=7,Z++,Q[7]++;for(;Z<=287;)T[2*Z+1]=8,Z++,Q[8]++;for(te(T,m+1,Q),Z=0;Z<f;Z++)O[2*Z+1]=5,O[2*Z]=fe(Z,5);q=new B(T,S,h+1,m,p),I=new B(O,P,0,f,p),$=new B(new Array(0),k,0,x,b)}(),V=!0),z.l_desc=new W(z.dyn_ltree,q),z.d_desc=new W(z.dyn_dtree,I),z.bl_desc=new W(z.bl_tree,$),z.bi_buf=0,z.bi_valid=0,J(z)},s._tr_stored_block=U,s._tr_flush_block=function(z,Z,ve,ee){var de,je,Q=0;0<z.level?(z.strm.data_type===2&&(z.strm.data_type=function(oe){var Pe,ze=4093624447;for(Pe=0;Pe<=31;Pe++,ze>>>=1)if(1&ze&&oe.dyn_ltree[2*Pe]!==0)return o;if(oe.dyn_ltree[18]!==0||oe.dyn_ltree[20]!==0||oe.dyn_ltree[26]!==0)return l;for(Pe=32;Pe<h;Pe++)if(oe.dyn_ltree[2*Pe]!==0)return l;return o}(z)),he(z,z.l_desc),he(z,z.d_desc),Q=function(oe){var Pe;for(D(oe,oe.dyn_ltree,oe.l_desc.max_code),D(oe,oe.dyn_dtree,oe.d_desc.max_code),he(oe,oe.bl_desc),Pe=x-1;3<=Pe&&oe.bl_tree[2*C[Pe]+1]===0;Pe--);return oe.opt_len+=3*(Pe+1)+5+5+4,Pe}(z),de=z.opt_len+3+7>>>3,(je=z.static_len+3+7>>>3)<=de&&(de=je)):de=je=ve+5,ve+4<=de&&Z!==-1?U(z,Z,ve,ee):z.strategy===4||je===de?(G(z,2+(ee?1:0),3),X(z,T,O)):(G(z,4+(ee?1:0),3),function(oe,Pe,ze,Je){var Ae;for(G(oe,Pe-257,5),G(oe,ze-1,5),G(oe,Je-4,4),Ae=0;Ae<Je;Ae++)G(oe,oe.bl_tree[2*C[Ae]+1],3);le(oe,oe.dyn_ltree,Pe-1),le(oe,oe.dyn_dtree,ze-1)}(z,z.l_desc.max_code+1,z.d_desc.max_code+1,Q+1),X(z,z.dyn_ltree,z.dyn_dtree)),J(z),ee&&re(z)},s._tr_tally=function(z,Z,ve){return z.pending_buf[z.d_buf+2*z.last_lit]=Z>>>8&255,z.pending_buf[z.d_buf+2*z.last_lit+1]=255&Z,z.pending_buf[z.l_buf+z.last_lit]=255&ve,z.last_lit++,Z===0?z.dyn_ltree[2*ve]++:(z.matches++,Z--,z.dyn_ltree[2*(E[ve]+h+1)]++,z.dyn_dtree[2*A(Z)]++),z.last_lit===z.lit_bufsize-1},s._tr_align=function(z){G(z,2,3),H(z,w,T),function(Z){Z.bi_valid===16?(K(Z,Z.bi_buf),Z.bi_buf=0,Z.bi_valid=0):8<=Z.bi_valid&&(Z.pending_buf[Z.pending++]=255&Z.bi_buf,Z.bi_buf>>=8,Z.bi_valid-=8)}(z)}},{"../utils/common":41}],53:[function(n,r,s){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,s){(function(i){(function(o,l){if(!o.setImmediate){var c,u,d,h,m=1,f={},x=!1,g=o.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(o);p=p&&p.setTimeout?p:o,c={}.toString.call(o.process)==="[object process]"?function(N){process.nextTick(function(){b(N)})}:function(){if(o.postMessage&&!o.importScripts){var N=!0,j=o.onmessage;return o.onmessage=function(){N=!1},o.postMessage("","*"),o.onmessage=j,N}}()?(h="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",w,!1):o.attachEvent("onmessage",w),function(N){o.postMessage(h+N,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(N){b(N.data)},function(N){d.port2.postMessage(N)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(N){var j=g.createElement("script");j.onreadystatechange=function(){b(N),j.onreadystatechange=null,u.removeChild(j),j=null},u.appendChild(j)}):function(N){setTimeout(b,0,N)},p.setImmediate=function(N){typeof N!="function"&&(N=new Function(""+N));for(var j=new Array(arguments.length-1),_=0;_<j.length;_++)j[_]=arguments[_+1];var S={callback:N,args:j};return f[m]=S,c(m),m++},p.clearImmediate=v}function v(N){delete f[N]}function b(N){if(x)setTimeout(b,0,N);else{var j=f[N];if(j){x=!0;try{(function(_){var S=_.callback,P=_.args;switch(P.length){case 0:S();break;case 1:S(P[0]);break;case 2:S(P[0],P[1]);break;case 3:S(P[0],P[1],P[2]);break;default:S.apply(l,P)}})(j)}finally{v(N),x=!1}}}}
819function w(N){N.source===o&&typeof N.data=="string"&&N.data.indexOf(h)===0&&b(+N.data.slice(h.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof Vo<"u"?Vo:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(O8);var Nde=O8.exports;const Sde=dn(Nde);function Cde({experienceId:e}){const[t,n]=y.useState(!1),[r,s]=y.useState(!1),[i,o]=y.useState(!1),{data:l=[]}=Ee({queryKey:["experience-docs-contacts",e],queryFn:async()=>{const{data:_,error:S}=await F.from("contact_experiences").select("id, status, contacts:contacts!contact_experiences_contact_id_fkey(id, name)").eq("experience_id",e).in("status",["accepted","gen_guide"]).order("status");if(S)throw S;return _},enabled:t}),{data:c=[]}=Ee({queryKey:["experience-docs-generators",e],queryFn:async()=>{const{data:_,error:S}=await F.from("generator_experiences").select("id, generators(id, name)").eq("experience_id",e);if(S)throw S;return _},enabled:t}),{data:u=[]}=Ee({queryKey:["experience-docs-fields",e],queryFn:async()=>{const{data:_,error:S}=await F.from("activities").select("id, description, required, sort_order").eq("experience_id",e).is("contact_id",null).eq("type","form-field").eq("field_type","file_upload").order("sort_order");if(S)throw S;return _},enabled:t}),d=y.useMemo(()=>{const _=l.map(k=>{var C,T;return{key:k.id,name:((C=k.contacts)==null?void 0:C.name)||"Unknown",isTeam:k.status==="gen_guide",contactId:((T=k.contacts)==null?void 0:T.id)??null}}),S=new Set(_.map(k=>k.name.trim().toLowerCase())),P=c.map(k=>{var C;return{key:k.id,name:((C=k.generators)==null?void 0:C.name)||"Unknown",isTeam:!0,contactId:null}}).filter(k=>!S.has(k.name.trim().toLowerCase()));return[..._,...P]},[l,c]),h=l.map(_=>_.id),m=c.map(_=>_.id),f=u.map(_=>_.id),{data:x=[]}=Ee({queryKey:["experience-docs-responses",e,h,m,f],queryFn:async()=>{if(f.length===0||h.length===0&&m.length===0)return[];const _=[];h.length>0&&_.push(`contact_experience_id.in.(${h.join(",")})`),m.length>0&&_.push(`generator_experience_id.in.(${m.join(",")})`);const{data:S,error:P}=await F.from("activity_responses").select("id, activity_id, contact_experience_id, generator_experience_id, response_file_path, response_file_name, responded_at").in("activity_id",f).or(_.join(","));if(P)throw P;return S},enabled:t&&f.length>0}),{data:g=[],refetch:p}=Ee({queryKey:["experience-docs-log",e],queryFn:async()=>{const{data:_,error:S}=await F.from("document_downloads").select("id, file_name, file_path, downloaded_by_email, created_at, contacts:contacts(name)").eq("experience_id",e).order("created_at",{ascending:!1}).limit(200);if(S)throw S;return _},enabled:i}),v=y.useMemo(()=>{const _=new Map;return x.forEach(S=>{const P=S.contact_experience_id||S.generator_experience_id;!P||!S.response_file_path||(_.has(P)||_.set(P,new Map),_.get(P).set(S.activity_id,S))}),_},[x]),b=x.filter(_=>_.response_file_path).length,w=d.length*u.length,N=async(_,S)=>{try{await P8({filePath:S.response_file_path,fileName:S.response_file_name,experienceId:e,contactId:_.contactId,activityResponseId:S.id})}catch(P){Mt.error((P==null?void 0:P.message)||"Could not download the file")}},j=async()=>{const _=[];if(d.forEach(S=>{u.forEach(P=>{var C;const k=(C=v.get(S.key))==null?void 0:C.get(P.id);k!=null&&k.response_file_path&&_.push({row:S,field:P,resp:k})})}),_.length===0){Mt.error("No uploaded documents to download");return}s(!0);try{const S=new Sde;for(const{row:T,field:O,resp:L}of _){const E=await _de(L.response_file_path),R=q=>q.replace(/[^\w\-. ]+/g,"_");S.file(`${R(T.name)}/${R(O.description)}-${R(L.response_file_name||"file")}`,E)}await Promise.all(_.map(({row:T,resp:O})=>E8({filePath:O.response_file_path,fileName:O.response_file_name,experienceId:e,contactId:T.contactId,activityResponseId:O.id})));const P=await S.generateAsync({type:"blob"}),k=URL.createObjectURL(P),C=document.createElement("a");C.href=k,C.download="collected-documents.zip",C.click(),URL.revokeObjectURL(k),Mt.success(`Downloaded ${_.length} document${_.length===1?"":"s"}`)}catch(S){Mt.error((S==null?void 0:S.message)||"Could not build the ZIP")}finally{s(!1)}};return a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs(Mb,{open:t,onOpenChange:n,children:[a.jsx(Db,{asChild:!0,children:a.jsxs("button",{className:"flex items-center justify-between w-full text-left group",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5",children:[a.jsx(R3,{className:"h-3.5 w-3.5"}),"Collected Documents",t&&u.length>0&&a.jsxs("span",{className:"normal-case font-normal text-[10px]",children:["· ",b," of ",w," uploaded"]})]}),t?a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),a.jsxs($b,{className:"mt-2",children:[u.length===0&&a.jsx("p",{className:"text-xs text-muted-foreground py-4 text-center",children:"No document upload fields configured for this experience."}),u.length>0&&d.length===0&&a.jsx("p",{className:"text-xs text-muted-foreground py-4 text-center",children:"No accepted contacts or team members for this experience."}),u.length>0&&d.length>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-end gap-1 mb-1",children:[a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-[10px] gap-1",onClick:()=>o(!0),children:[a.jsx(oC,{className:"h-3 w-3"}),"Download log"]}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-[10px] gap-1",onClick:j,disabled:r,children:[r?a.jsx(vt,{className:"h-3 w-3 animate-spin"}):a.jsx(ja,{className:"h-3 w-3"}),"Download all (ZIP)"]})]}),a.jsx("div",{className:"w-full overflow-x-auto rounded-md border border-border",children:a.jsxs("table",{className:"w-full caption-bottom text-sm border-collapse",children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{className:"sticky left-0 bg-card z-20 min-w-[140px] text-[10px] shadow-[1px_0_0_0_hsl(var(--border))]",children:"Name"}),u.map(_=>a.jsx(Le,{className:"text-[10px] min-w-[140px]",children:a.jsxs("span",{className:"truncate block",children:[_.description,_.required&&a.jsx("span",{className:"text-destructive",children:" *"})]})},_.id))]})}),a.jsx(Bn,{children:d.map(_=>a.jsxs(yt,{children:[a.jsxs(Te,{className:"sticky left-0 bg-card z-10 py-1.5
819shadow-[1px_0_0_0_hsl(var(--border))]",children:[a.jsx("span",{className:"text-xs font-medium truncate max-w-[120px] block",children:_.name}),_.isTeam&&a.jsx("span",{className:"text-[9px] uppercase tracking-wide text-muted-foreground",children:"Team"})]}),u.map(S=>{var k;const P=(k=v.get(_.key))==null?void 0:k.get(S.id);return a.jsx(Te,{className:"py-1.5 text-xs",children:P!=null&&P.response_file_path?a.jsxs("button",{type:"button",className:"flex items-center gap-1 text-primary hover:underline max-w-[180px]",onClick:()=>N(_,P),children:[a.jsx(Hs,{className:"h-3 w-3 shrink-0"}),a.jsx("span",{className:"truncate",children:P.response_file_name||"Download"})]}):a.jsxs(Ge,{variant:"outline",className:"text-[9px] font-normal text-muted-foreground gap-1",children:[a.jsx(Ht,{className:"h-2.5 w-2.5"}),"Missing"]})},S.id)})]},_.key))})]})})]})]})]}),a.jsx(Dt,{open:i,onOpenChange:_=>{o(_),_&&p()},children:a.jsxs(Pt,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsx(At,{className:"text-base",children:"Document download log"})}),g.length===0?a.jsx("p",{className:"text-xs text-muted-foreground py-6 text-center",children:"No downloads recorded yet."}):a.jsxs("table",{className:"w-full text-xs",children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{className:"text-[10px]",children:"When"}),a.jsx(Le,{className:"text-[10px]",children:"Who"}),a.jsx(Le,{className:"text-[10px]",children:"Document"}),a.jsx(Le,{className:"text-[10px]",children:"Participant"})]})}),a.jsx(Bn,{children:g.map(_=>{var S;return a.jsxs(yt,{children:[a.jsx(Te,{className:"py-1.5 whitespace-nowrap",children:Ye(new Date(_.created_at),"MMM d, yyyy h:mm a")}),a.jsx(Te,{className:"py-1.5 truncate max-w-[160px]",children:_.downloaded_by_email||"â"}),a.jsx(Te,{className:"py-1.5 truncate max-w-[180px]",children:_.file_name||_.file_path}),a.jsx(Te,{className:"py-1.5 truncate max-w-[140px]",children:((S=_.contacts)==null?void 0:S.name)||"â"})]},_.id)})})]})]})})]})}const A8=[{key:"personal_story",label:"Personal Story",hint:"The shaping moments that brought you here."},{key:"central_theme",label:"Central Theme",hint:"The theme you're carrying into this season."},{key:"resistance",label:"Resistance",hint:"What's pushing back â internally or externally."},{key:"key_relationships",label:"Key Relationships",hint:"Who matters most right now, and why."},{key:"growth_focus",label:"Growth Focus",hint:"Where you most want to grow."},{key:"priorities",label:"Possibilities & Priorities",hint:"What deserves your attention over the next months."}],kde={key:"meeting_topics",label:"Meeting Topics"},CA=[kde,{key:"meeting_insights",label:"Meeting Insights"},{key:"meeting_commitments",label:"Meeting Commitments"},{key:"coaching_insights",label:"Coaching Insights"},{key:"coaching_commitments",label:"Coaching Commitments"}],Ede={key:"expedition",title:"Expedition",subtitle:"Reflections from the trip itself.",fields:[{key:"fear",label:"Fear"},{key:"suffering",label:"Suffering"},{key:"beauty",label:"Beauty"},{key:"rule_of_life",label:"Rule of Life",hint:"The commitment you're carrying home."}]};function Pde(e){const t=A8[e-1],n=CA.slice(1);return t?[t,...n]:[...CA]}function T8(e=6){const t=[];for(let n=1;n<=e;n++)t.push({key:`meeting_${n}`,title:`Meeting & Coaching ${n}`,subtitle:A8[n-1]?"Complete your preparation before this meeting.":void 0,fields:Pde(n)});return[...t,Ede]}function O1(e,t){return{filled:t.fields.filter(r=>((e==null?void 0:e[r.key])||"").trim().length>0).length,total:t.fields.length}}function Ode({experienceId:e,meetingCount:t}){const[n,r]=y.useState(!1),[s,i]=y.useState(null),o=T8(t),{data:l,isLoading:c}=Ee({queryKey:["experience-tracker",e,t],enabled:n,queryFn:async()=>{const{data:d,error:h}=await F.from("contact_experiences").select("id, status, contacts:contacts!contact_experiences_contact_id_fkey(id, name)").eq("experience_id",e).in("status",["accepted","gen_guide"]);if(h)throw h;const m=(d||[]).map(x=>x.id);let f=[];if(m.length){const{data:x,error:g}=await F.from("peer_group_tracker_entries").select("contact_experience_id, block_key, entry_values, updated_at").in("contact_experience_id",m);if(g)throw g;f=x||[]}return(d||[]).map(x=>{var v;const g={};let p=null;for(const b of f.filter(w=>w.contact_experience_id===x.id))g[b.block_key]=b.entry_values||{},(!p||b.updated_at>p)&&(p=b.updated_at);return{id:x.id,name:((v=x.contacts)==null?void 0:v.name)||"Unknown",entries:g,updatedAt:p}}).sort((x,g)=>x.name.localeCompare(g.name))}}),u=o.reduce((d,h)=>d+h.fields.length,0);return a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("button",{onClick:()=>r(!n),className:"flex items-center justify-between w-full text-left",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5",children:[a.jsx(F3,{className:"h-3.5 w-3.5"})," Peer Group Tracker"]}),n?a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),n&&a.jsxs("div",{className:"mt-2 space-y-2",children:[c&&a.jsx(vt,{className:"h-4 w-4 animate-spin text-muted-foreground"}),!c&&(l||[]).length===0&&a.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No accepted participants yet."}),(l||[]).map(d=>{const h=o.reduce((f,x)=>f+O1(d.entries[x.key],x).filled,0),m=s===d.id;return a.jsxs("div",{className:"rounded-md border border-border",children:[a.jsxs("button",{onClick:()=>i(m?null:d.id),className:"w-full flex items-center justify-between gap-2 px-3 py-2 text-left",children:[a.jsx("span",{className:"text-sm text-foreground",children:d.name}),a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsxs(Ge,{variant:h===0?"outline":"secondary",className:"text-[10px]",children:[h,"/",u]}),m?a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]}),m&&a.jsxs("div",{className:"px-3 pb-3 space-y-3",children:[o.map(f=>{const x=d.entries[f.key]||{},g=f.fields.filter(p=>(x[p.key]||"").trim());return g.length===0?null:a.jsxs("div",{children:[a.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1",children:f.title}),a.jsx("div",{className:"space-y-1.5",children:g.map(p=>a.jsxs("div",{children:[a.jsx("p",{className:"text-[11px] font-medium text-foreground",children:p.label}),a.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:x[p.key]})]},p.key))})]},f.key)}),o.every(f=>O1(d.entries[f.key],f).filled===0)&&a.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Nothing written yet."})]})]},d.id)})]})]})}function Ade({experienceId:e}){const[t,n]=y.useState(!1),[r,s]=y.useState(null),{data:i=[]}=Ee({queryKey:["experience-survey-responses-contacts",e],queryFn:async()=>{const{data:p,error:v}=await F.from("contact_experiences").select("id, status, contacts:contacts!contact_experiences_contact_id_fkey(id, name, email)").eq("experience_id",e).eq("status","accepted").order("status");if(v)throw v;return p},enabled:t}),{data:o}=Ee({queryKey:["experience-survey-report",e],queryFn:async()=>{const{data:p,error:v}=await F.from("experience_surveys").select("*").eq("experience_id",e).maybeSingle();if(v)throw v;return p},enabled:t}),l=o?o.questions||[]:[],c=i.map(p=>p.id),{data:u=[]}=Ee({queryKey:["experience-survey-responses-data",o==null?void 0:o.id,c],queryFn:async()=>
819{if(!o||c.length===0)return[];const{data:p,error:v}=await F.from("survey_responses").select("*").eq("survey_id",o.id).in("contact_experience_id",c);if(v)throw v;return p},enabled:t&&!!o&&c.length>0}),d=new Map;u.forEach(p=>{d.set(p.contact_experience_id,p.answers||{})});const h=l.length>0,m=i.filter(p=>d.has(p.id)).length,f=(p,v)=>{if(!v)return"";const b=v[p.id];return b==null||b===""?"":p.type==="rating"?`${b}/5`:p.type==="rating_10"?`${b}/10`:p.type==="yes_no"?b?"Yes":"No":p.type==="multi_select"&&Array.isArray(b)?b.join(", "):String(b)},x=(p,v,b)=>{if(!v)return a.jsx("span",{className:"text-muted-foreground text-[10px]",children:"â"});const w=v[p.id];return w==null||w===""?a.jsx("span",{className:"text-muted-foreground text-[10px]",children:"â"}):p.type==="rating"?a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(bP,{className:"h-3 w-3 text-amber-500 fill-amber-500"}),a.jsxs("span",{children:[w,"/5"]})]}):p.type==="rating_10"?a.jsxs("span",{className:"flex items-center gap-0.5",children:[a.jsx(bP,{className:"h-3 w-3 text-amber-500 fill-amber-500"}),a.jsxs("span",{children:[w,"/10"]})]}):p.type==="yes_no"?w?a.jsx(Mr,{className:"h-3.5 w-3.5 text-emerald-600"}):a.jsx(Ht,{className:"h-3.5 w-3.5 text-muted-foreground"}):p.type==="multi_select"&&Array.isArray(w)?a.jsx("div",{className:"flex flex-wrap gap-0.5",children:w.map((N,j)=>a.jsx(Ge,{variant:"secondary",className:"text-[9px] px-1 py-0",children:N},j))}):a.jsx("span",{className:Se("block",b?"whitespace-pre-wrap":"truncate max-w-[150px]"),children:String(w)})},g=y.useCallback(()=>{if(!h||i.length===0)return;const p=["Contact",...l.map(S=>S.label)],v=i.map(S=>{const P=S.contacts,k=d.get(S.id);return[(P==null?void 0:P.name)||"Unknown",...l.map(C=>f(C,k))]}),b=S=>S.includes(",")||S.includes('"')||S.includes(` 820`)?`"${S.replace(/"/g,'""')}"`:S,w=[p.map(b).join(","),...v.map(S=>S.map(b).join(","))].join(` 821`),N=new Blob([w],{type:"text/csv;charset=utf-8;"}),j=URL.createObjectURL(N),_=document.createElement("a");_.href=j,_.download="survey-responses.csv",_.click(),URL.revokeObjectURL(j)},[i,l,d,h]);return a.jsx("div",{className:"border-t border-border pt-3",children:a.jsxs(Mb,{open:t,onOpenChange:n,children:[a.jsx(Db,{asChild:!0,children:a.jsxs("button",{className:"flex items-center justify-between w-full text-left group",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5",children:[a.jsx($3,{className:"h-3.5 w-3.5"}),"Survey Responses",t&&m>0&&a.jsxs("span",{className:"normal-case font-normal text-[10px]",children:["· ",m," of ",i.length," responded"]})]}),t?a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),a.jsxs($b,{className:"mt-2",children:[!h&&a.jsx("p",{className:"text-xs text-muted-foreground py-4 text-center",children:"No survey questions configured for this experience."}),h&&i.length===0&&a.jsx("p",{className:"text-xs text-muted-foreground py-4 text-center",children:"No accepted contacts for this experience."}),h&&i.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex justify-end mb-1",children:a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-[10px] gap-1",onClick:g,children:[a.jsx(ja,{className:"h-3 w-3"}),"Export CSV"]})}),a.jsxs(Ic,{className:"w-full",children:[a.jsx("div",{className:"min-w-[600px]",children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{className:"sticky left-0 bg-card z-10 min-w-[140px] text-[10px]",children:"Contact"}),l.map(p=>a.jsx(Le,{className:"text-[10px] min-w-[100px] max-w-[160px]",children:a.jsx("span",{className:"truncate block",children:p.label})},p.id))]})}),a.jsx(Bn,{children:i.map(p=>{const v=p.contacts,b=d.get(p.id),w=r===p.id;return a.jsxs(yt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>s(w?null:p.id),children:[a.jsx(Te,{className:"sticky left-0 bg-card z-10 py-1.5",children:a.jsx("span",{className:"text-xs font-medium truncate max-w-[120px] block",children:(v==null?void 0:v.name)||"Unknown"})}),l.map(N=>a.jsx(Te,{className:Se("py-1.5 text-xs",w&&"align-top"),children:x(N,b,w)},N.id))]}
821,p.id)})})]})}),a.jsx(sk,{orientation:"horizontal"})]}),a.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 text-center",children:"Click a row to expand full responses"})]})]})]})})}var Fw,Rb="HoverCard",[M8,N3e]=jr(Rb,[Si]),Ib=Si(),[Tde,Kk]=M8(Rb),D8=e=>{const{__scopeHoverCard:t,children:n,open:r,defaultOpen:s,onOpenChange:i,openDelay:o=700,closeDelay:l=300}=e,c=Ib(t),u=y.useRef(0),d=y.useRef(0),h=y.useRef(!1),m=y.useRef(!1),[f,x]=oa({prop:r,defaultProp:s??!1,onChange:i,caller:Rb}),g=y.useCallback(()=>{clearTimeout(d.current),u.current=window.setTimeout(()=>x(!0),o)},[o,x]),p=y.useCallback(()=>{clearTimeout(u.current),!h.current&&!m.current&&(d.current=window.setTimeout(()=>x(!1),l))},[l,x]),v=y.useCallback(()=>x(!1),[x]);return y.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(d.current)},[]),a.jsx(Tde,{scope:t,open:f,onOpenChange:x,onOpen:g,onClose:p,onDismiss:v,hasSelectionRef:h,isPointerDownOnContentRef:m,children:a.jsx(pp,{...c,children:n})})};D8.displayName=Rb;var $8="HoverCardTrigger",R8=y.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,s=Kk($8,n),i=Ib(n);return a.jsx(ih,{asChild:!0,...i,children:a.jsx(tt.a,{"data-state":s.open?"open":"closed",...r,ref:t,onPointerEnter:Fe(e.onPointerEnter,vy(s.onOpen)),onPointerLeave:Fe(e.onPointerLeave,vy(s.onClose)),onFocus:Fe(e.onFocus,s.onOpen),onBlur:Fe(e.onBlur,s.onClose),onTouchStart:Fe(e.onTouchStart,o=>o.preventDefault())})})});R8.displayName=$8;var Mde="HoverCardPortal",[S3e,Dde]=M8(Mde,{forceMount:void 0}),yy="HoverCardContent",I8=y.forwardRef((e,t)=>{const n=Dde(yy,e.__scopeHoverCard),{forceMount:r=n.forceMount,...s}=e,i=Kk(yy,e.__scopeHoverCard);return a.jsx(tr,{present:r||i.open,children:a.jsx($de,{"data-state":i.open?"open":"closed",...s,onPointerEnter:Fe(e.onPointerEnter,vy(i.onOpen)),onPointerLeave:Fe(e.onPointerLeave,vy(i.onClose)),ref:t})})});I8.displayName=yy;var $de=y.forwardRef((e,t)=>{const{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:o,...l}=e,c=Kk(yy,n),u=Ib(n),d=y.useRef(null),h=Ct(t,d),[m,f]=y.useState(!1);return y.useEffect(()=>{if(m){const x=document.body;return Fw=x.style.userSelect||x.style.webkitUserSelect,x.style.userSelect="none",x.style.webkitUserSelect="none",()=>{x.style.userSelect=Fw,x.style.webkitUserSelect=Fw}}},[m]),y.useEffect(()=>{if(d.current){const x=()=>{f(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var p;((p=document.getSelection())==null?void 0:p.toString())!==""&&(c.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",x),()=>{document.removeEventListener("pointerup",x),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),y.useEffect(()=>{d.current&&Lde(d.current).forEach(g=>g.setAttribute("tabindex","-1"))}),a.jsx(jl,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:o,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:Fe(i,x=>{x.preventDefault()}),onDismiss:c.onDismiss,children:a.jsx(gp,{...u,...l,onPointerDown:Fe(l.onPointerDown,x=>{x.currentTarget.contains(x.target)&&f(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:h,style:{...l.style,userSelect:m?"text":void 0,WebkitUserSelect:m?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})}),Rde="HoverCardArrow",Ide=y.forwardRef((e,t)=>{const{__scopeHoverCard:n,...r}=e,s=Ib(n);return a.jsx(xp,{...s,...r,ref:t})});Ide.displayName=Rde;function vy(e){return t=>t.pointerType==="touch"?void 0:e()}function Lde(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)t.push(n.currentNode);return t}var Fde=D8,qde=R8,L8=I8;const zde=Fde,Bde=qde,F8=y.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},s)=>
821a.jsx(L8,{ref:s,align:t,sideOffset:n,className:Se("z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r}));F8.displayName=L8.displayName;function Ude({open:e,onOpenChange:t,experience:n,existingContactIds:r}){const[s,i]=y.useState(new Set),o=at(),{toast:l}=mt(),{data:c,isLoading:u}=Ee({queryKey:["find-matching-contacts",n.id,n.type,n.activity_type,n.audience],enabled:e,queryFn:async()=>{var C;const{data:p,error:v}=await F.from("contact_experiences").select("contact_id, status, experiences(id, name, type, activity_type, audience, status), contacts:contacts!contact_experiences_contact_id_fkey(id, name, email, generators:generator_id(id, name))").in("status",["future","waitlist"]);if(v)throw v;const b=new Map,w=T=>(T==null?void 0:T.trim().toLowerCase())??null,N=new Set(["women","men"]),j=new Set,_=w(n.audience);if(_&&N.has(_))for(const T of p){const O=T.experiences,L=T.contacts;if(!O||!L)continue;
821const E=w(O.audience);E&&N.has(E)&&E!==_&&j.add(L.id)}for(const T of p){const O=T.experiences,L=T.contacts;if(!O||!L||O.id===n.id||r.has(L.id)||j.has(L.id))continue;const E=[];if(O.type===n.type&&E.push("Format"),n.activity_type&&O.activity_type===n.activity_type&&E.push("Activity"),n.audience&&O.audience===n.audience&&E.push("Audience"),E.length===0)continue;const R=b.get(L.id);if(R)E.length>R.matchCount&&(R.matchCount=E.length,R.matchedCriteria=E),R.sourceExperiences.includes(O.name)||R.sourceExperiences.push(O.name);else{const q=((C=L.generators)==null?void 0:C.name)??null;b.set(L.id,{contactId:L.id,contactName:L.name,contactEmail:L.email,matchCount:E.length,matchedCriteria:E,sourceExperiences:[O.name],generatorName:q})}}const S=Array.from(b.values()).sort((T,O)=>O.matchCount!==T.matchCount?O.matchCount-T.matchCount:T.contactName.localeCompare(O.contactName)),P=new Map;for(const T of S){const O=T.generatorName??"Unassigned",L=P.get(O)??[];L.push(T),P.set(O,L)}const k=Array.from(P.entries()).sort(([T],[O])=>T==="Unassigned"?1:O==="Unassigned"?-1:T.localeCompare(O));return{contacts:S,groups:k}}}),d=p=>{i(v=>{const b=new Set(v);return b.has(p)?b.delete(p):b.add(p),b})},h=(c==null?void 0:c.contacts)??[],m=(c==null?void 0:c.groups)??[],f=h.length>0&&h.every(p=>s.has(p.contactId)),x=Me({mutationFn:async()=>{const p=Array.from(s).map(b=>({contact_id:b,experience_id:n.id,status:"candidate"})),{error:v}=await F.from("contact_experiences").insert(p);if(v)throw v},onSuccess:()=>{o.invalidateQueries({queryKey:["experience-contacts",n.id]}),o.invalidateQueries({queryKey:["contacts-list"]}),l({title:`${s.size} contact${s.size===1?"":"s"} added`}),i(new Set),t(!1)},onError:p=>l({title:"Error",description:p.message,variant:"destructive"})}),g=1+(n.activity_type?1:0)+(n.audience?1:0);return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[a.jsxs(Ot,{children:[a.jsx(At,{className:"font-display text-xl",children:"Find Prospects"}),a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[`Contacts with "Future" or "Waitlist" status in other experiences matching this experience's Format`,n.activity_type?", Activity Type":"",n.audience?", Audience":"","."]})]}),u?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(vt,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):h.length===0?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx("p",{className:"text-sm text-muted-foreground",children:"No matching contacts found."})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("button",{type:"button",onClick:()=>{i(f?new Set:new Set(h.map(p=>p.contactId)))},className:"text-xs text-primary hover:underline",children:f?"Deselect all":"Select all"}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:[h.length," match",h.length===1?"":"es"]})]}),a.jsx("div",{className:"space-y-3",children:m.map(([p,v])=>a.jsxs("div",{children:[a.jsx("div",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide px-3 py-1 border-b border-border mb-1",children:p}),a.jsx("div",{className:"space-y-0.5",children:v.map(b=>a.jsxs("label",{className:"flex items-start gap-2 rounded-md px-3 py-2 hover:bg-secondary/50 cursor-pointer transition-colors",children:[a.jsx(gt,{checked:s.has(b.contactId),onCheckedChange:()=>d(b.contactId),className:"mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:b.contactName}),a.jsxs(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[b.matchCount,"/",g]})]}),b.contactEmail&&a.jsx("span",{className:"text-xs text-muted-foreground truncate block",children:b.contactEmail}),a.jsxs("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[b.matchedCriteria.map(w=>a.jsx(Ge,{variant:"secondary",className:"text-[10px] px-1 py-0",children:w}
821,w)),a.jsxs("span",{className:"text-[10px] text-muted-foreground ml-1",children:["from ",b.sourceExperiences.join(", ")]})]})]})]},b.contactId))})]},p))}),a.jsxs("div",{className:"flex justify-end gap-2 mt-4 border-t border-border pt-3",children:[a.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Cancel"}),a.jsxs(Y,{size:"sm",onClick:()=>x.mutate(),disabled:s.size===0||x.isPending,children:[x.isPending?a.jsx(vt,{className:"h-3.5 w-3.5 animate-spin mr-1"}):null,"Add ",s.size," as Candidate",s.size===1?"":"s"]})]})]})]})})}const Wde=[{value:"candidate",label:"Candidate"},{value:"invited",label:"Invited"},{value:"considering",label:"Considering"},{value:"accepted",label:"Accepted"},{value:"gen_guide",label:"Gen/Guide"},{value:"future",label:"Future"},{value:"waitlist",label:"Waitlist"}];function Kde(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:""}function Hde({open:e,onOpenChange:t,experienceId:n,experienceName:r,contacts:s}){const{toast:i}=mt(),o=y.useRef(null),[l,c]=y.useState("individual"),[u,d]=y.useState(["accepted","gen_guide"]),[h,m]=y.useState(`Four Corners ${r}`),[f,x]=y.useState(`Hi [First Name], 822 823`),[g,p]=y.useState(!0),[v,b]=y.useState(!1),[w,N]=y.useState(!0),[j,_]=y.useState([]),[S,P]=y.useState([]),[k,C]=y.useState(""),[T,O]=y.useState(!1),[L,E]=y.useState(!1),[R,q]=y.useState([]),[I,$]=y.useState(!1),[M,B]=y.useState(new Set),[W,A]=y.useState(!1),K=y.useMemo(()=>s.filter(X=>u.includes(X.status)),[s,u]);y.useEffect(()=>{B(new Set(K.map(X=>X.id)))},[K]),y.useEffect(()=>{e&&m(`Four Corners ${r}`)},[e,n,r]);const G=M.size,H=y.useMemo(()=>{const X={};for(const he of s)X[he.status]=(X[he.status]||0)+1;return X},[s]),fe=y.useMemo(()=>{const X=u.some(D=>D==="candidate"||D==="invited"),he=u.some(D=>D==="accepted"||D==="gen_guide");return X&&!he},[u]);y.useEffect(()=>{l==="individual"?(x(X=>X.startsWith("Hi everyone")?`Hi [First Name], 824 825`:X),p(!0)):(x(X=>X.startsWith("Hi [First Name]")?`Hi everyone, 826 827`:X),p(!1))},[l]),y.useEffect(()=>{!e||!n||(async()=>{const X=new Map,{data:he}=await F.from("generator_experiences").select("generators(name, email)").eq("experience_id",n);if(he)for(const U of he){const z=U.generators;z!=null&&z.email&&X.set(z.email.toLowerCase(),{name:z.name,email:z.email})}const{data:D}=await F.from("experiences").select("project_manager_id, generators:project_manager_id(name, email)").eq("id",n).single();if(D){const U=D.generators;U!=null&&U.email&&X.set(U.email.toLowerCase(),{name:U.name,email:U.email})}const{data:le}=await F.from("experience_team_roles").select("generators(name, email)").eq("experience_id",n);for(const U of le||[]){const z=U.generators;z!=null&&z.email&&X.set(z.email.toLowerCase(),{name:z.name,email:z.email})}const V=Array.from(X.values());P(V),_(V.map(U=>U.name)),V.length>0&&!k&&C(V[0].email)})()},[e,n]),y.useEffect(()=>{e||q([])},[e]);const te=X=>{d(he=>he.includes(X)?he.filter(D=>D!==X):[...he,X])},J=async X=>{if(!(!X||X.length===0)){$(!0);try{for(const he of Array.from(X)){const D=he.name.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/_+/g,"_").replace(/^[._-]+|[._-]+$/g,"").slice(0,180)||"file",le=`${n}/email-attachments/${Date.now()}-${D}`,{error:V}=await F.storage.from("experience-resources").upload(le,he,{upsert:!1});if(V)throw V;const{data:U,error:z}=await F.storage.from("experience-resources").createSignedUrl(le,60*60*24*365);if(z)throw z;q(Z=>[...Z,{fileName:he.name,url:U.signedUrl,size:he.size}])}}catch(he){i({title:"Upload failed",description:he.message,variant:"destructive"})}finally{$(!1)}}},re=X=>{q(he=>he.filter((D,le)=>le!==X))},pe=async()=>{if(u.length===0){i({title:"Select at least one status first",variant:"destructive"});return}E(!0);try{const{data:X,error:he}=await F.functions.invoke("generate-experience-email",{body:{experienceId:n,statuses:u,sendMode:l,currentSubject:h,currentMessage:f}});if(he)throw he;X!=null&&X.subject&&m(X.subject),X!=null&&X.message&&x(X.message),i({title:"Draft generated",description:"Review and edit before sending."})}catch(X){i({title:"AI write failed",description:X.message,variant:"destructive"})}finally{E(!1)}},ye=async()=>
827{if(!h.trim()||!f.trim()||!k)return;if(u.length===0){i({title:"Select at least one status",variant:"destructive"});return}if(G===0){i({title:"No recipients selected",variant:"destructive"});return}const X=K.filter(le=>M.has(le.id)),he=X.filter(le=>!le.email),D=X.length-he.length;if(D===0){i({title:"None of the selected recipients have an email address",description:"Add email addresses to their contact records before sending.",variant:"destructive"});return}if(he.length>0){const le=he.slice(0,3).map(z=>z.name).join(", "),V=he.length>3?` +${he.length-3} more`:"";if(!window.confirm(`${he.length} of ${X.length} selected contacts have no email and will be skipped (${le}${V}). 828 829Send to the remaining ${D}?`))return}O(!0);try{const le=S.find(ve=>ve.email===k),{data:V,error:U}=await F.functions.invoke("send-experience-email",{body:{experienceId:n,subject:h.trim(),message:f.trim(),includeLink:l==="individual"?g:!1,includeCalendarLink:v,ccTeam:w,senderEmail:le==null?void 0:le.email,senderName:le==null?void 0:le.name,sendMode:l,statuses:u,contactExperienceIds:Array.from(M),attachments:R.length>0?R.map(ve=>({filename:ve.fileName,path:ve.url})):void 0}});if(U)throw U;const z=(V==null?void 0:V.sent)||0,Z=(V==null?void 0:V.skipped)||0;if(z===0){i({title:"Nothing was sent",description:Z>0?`All ${Z} selected recipients were skipped (no email address or unsubscribed/bounced). Check the recipient list and try again.`:"No recipients matched the selected statuses. Adjust your filters and try again.",variant:"destructive"});return}i({title:l==="group"?`Group email sent to ${z} contact${z!==1?"s":""}`:`Email queued for ${z} contact${z!==1?"s":""}`,description:Z>0?`${Z} skipped (no email or suppressed)`:void 0}),t(!1),x(l==="individual"?`Hi [First Name], 830 831`:`Hi everyone, 832 833`)}catch(le){i({title:"Failed to send",description:le.message,variant:"destructive"})}finally{O(!1)}};return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[a.jsxs(Ot,{children:[a.jsx(At,{className:"text-base",children:"Email Contacts"}),a.jsxs(wr,{className:"text-xs",children:["Send a branded email to ",G," contact",G!==1?"s":""," for ",r,"."]})]}),a.jsxs("div",{className:"space-y-3 mt-2",children:[a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs font-medium",children:"Send to contacts with status"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Wde.map(X=>{const he=u.includes(X.value),D=H[X.value]||0;return a.jsxs("button",{type:"button",onClick:()=>te(X.value),className:Se("px-2.5 py-1 rounded-full text-[11px] font-medium border transition-colors",he?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-border hover:bg-accent"),children:[X.label," ",a.jsxs("span",{className:"opacity-70",children:["(",D,")"]})]},X.value)})}),fe&&a.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:"Outreach statuses send as plain text (no logo or links) to feel like an authentic 1:1 message."})]}),K.length>0&&a.jsxs("div",{className:"border rounded-md",children:[a.jsxs("button",{type:"button",onClick:()=>A(X=>!X),className:"w-full flex items-center justify-between px-2.5 py-1.5 text-xs hover:bg-accent rounded-md",children:[a.jsxs("span",{className:"flex items-center gap-1.5 font-medium",children:[W?a.jsx(_n,{className:"h-3 w-3"}):a.jsx(fp,{className:"h-3 w-3"}),"Recipients (",G," of ",K.length," selected)"]}),W&&a.jsxs("span",{className:"flex gap-2",children:[a.jsx("span",{role:"button",tabIndex:0,onClick:X=>{X.stopPropagation(),B(new Set(K.map(he=>he.id)))},className:"text-primary hover:underline cursor-pointer",children:"All"}),a.jsx("span",{role:"button",tabIndex:0,onClick:X=>{X.stopPropagation(),B(new Set)},className:"text-muted-foreground hover:underline cursor-pointer",children:"None"})]})]}),W&&a.jsx("div",{className:"max-h-48 overflow-y-auto border-t px-2 py-1.5 space-y-1",children:K.map(X=>{const he=M.has(X.id);return a.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer hover:bg-accent rounded px-1.5 py-1",children:[a.jsx(gt,{checked:he,onCheckedChange:D=>{B(le=>{const V=new Set(le);return D?V.add(X.id):V.delete(X.id),V})}}),a.jsx("span",{className:"flex-1 truncate",children:X.name}),!X.email&&a.jsx("span",{className:"text-[10px] text-destructive",children:"no email"})]},X.id)})})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs font-medium",children:"Send mode"}),a.jsxs("div",{className:"flex gap-2 mt-1",children:[a.jsxs("button",{type:"button",onClick:()=>c("individual"),className:Se("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors",l==="individual"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-border hover:bg-accent"),children:[a.jsx(Ws,{className:"h-3.5 w-3.5"}),"Individual emails"]}),a.jsxs("button",{type:"button",onClick:()=>c("group"),className:Se("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors",l==="group"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-border hover:bg-accent"),children:[a.jsx(Hc,{className:"h-3.5 w-3.5"}),"Group email"]})]}),a.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:l==="individual"?"One personalized email per contact. Supports [First Name] and personal page links.":"One email with all contacts in the TO line. No per-person personalization."})]}),S.length>0&&a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs font-medium",children:"Send from"}),a.jsxs(lt,{value:k,onValueChange:C,children:[a.jsx(it,{className:"mt-1 text-sm",children:a.jsx(ct,{placeholder:"Select senderâ¦"})}),a.jsx(ot,{children:S.map(X=>a.jsxs(Oe,{value:X.email,children:[X.name," <",X.email,">"]},X.email))})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(xe,{className:"text-xs font-medium",children:"Subject"}),a.jsx(Y,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:pe,disabled:L||u.length===0,title:fe?"Generate outreach invitation":"Generate update email",children:L?a.jsxs(a.Fragment,{children:[a.jsx(vt,{className:"h-3 w-3 animate-spin"})," Writingâ¦"]}):a.jsxs(a.Fragment,{children:[a.jsx(Uv,{className:"h-3 w-3"})," AI Write"]})})]}),a.jsx(ce,{value:h,onChange:X=>m(X.target.value),className:"mt-1 text-sm",placeholder:"Email subject line"}),fe&&a.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"AI Write will draft a concise outreach invitation in the Four Corners voice."})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs font-medium",children:"Message"}),a.jsx(qt,{value:f,onChange:X=>x(X.target.value),className:"mt-1 text-sm min-h-[180px]",placeholder:l==="individual"?"Write your message here⦠[First Name] will be replaced with each contact's first name.":"Write your message hereâ¦"})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs font-medium",children:"Attachments"}),R.length>0&&a.jsx("div",{className:"space-y-1 mt-1",children:R.map((X,he)=>a.jsxs("div",{className:"flex items-center gap-2 text-xs bg-muted/50 rounded px-2 py-1",children:[a.jsx(Hs,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),a.jsx("span",{className:"truncate flex-1",children:X.fileName}),X.size&&a.jsx("span",{className:"text-muted-foreground flex-shrink-0",children:Kde(X.size)}),a.jsx("button",{type:"button",onClick:()=>re(he),className:"text-muted-foreground hover:text-destructive flex-shrink-0",children:a.jsx(Ht,{className:"h-3 w-3"})})]},he))}),a.jsx("input",{ref:o,type:"file",multiple:!0,className:"hidden",onChange:X=>{J(X.target.files),X.target.value=""}}),a.jsx(Y,{type:"button",variant:"outline",size:"sm",className:"mt-1 h-7 text-xs gap-1",onClick:()=>{var X;return(X=o.current)==null?void 0:X.click()},disabled:I,children:I?a.jsxs(a.Fragment,{children:[a.jsx(vt,{className:"h-3 w-3 animate-spin"})," Uploadingâ¦"]}):a.jsxs(a.Fragment,{children:[a.jsx(q3,{className:"h-3 w-3"})," Attach file"]})})]}),l==="individual"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gt,{id:"include-link",checked:g,onCheckedChange:X=>p(!!X)}),a.jsx(xe,{htmlFor:"include-link",className:"text-xs cursor-pointer",children:"Include personalized page link"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gt,{id:"include-calendar",checked:v,onCheckedChange:X=>b(!!X)}),a.jsx(xe,{htmlFor:"include-calendar",className:"text-xs cursor-pointer",children:'Include "Subscribe to Calendar" link'})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gt,{id:"cc-team",checked:w,onCheckedChange:X=>N(!!X)}),a.jsxs(xe,{htmlFor:"cc-team",className:"text-xs cursor-pointer",children:["CC team & project manager",j.length>0&&a.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",j.join(", "),")"]})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>t(!1),disabled:T,children:"Cancel"}),a.jsxs(Y,{size:"sm",onClick:ye,disabled:T||!h.trim()||!f.trim()||!k||G===0,className:"gap-1.5",children:[T?a.jsx(vt,{className:"h-3.5 w-3.5 animate-spin"}):a.jsx(cC,{className:"h-3.5 w-3.5"}),l==="group"?"Send group email":`Send to ${G} Contact${G!==1?"s":""}`]})]})]})]})})}function q8(e){const[t,n]=e.split("-");return`${n} '${t.slice(2)}`}function qw(e){const[t,n]=e.split("-"),s=(parseInt(n.slice(1),10)-1)*3+2;return`${t}-${String(s).padStart(2,"0")}-01`}function Gde(){const e=new Date,t=[],n=e.getFullYear();for(let r=n;r<=n+5;r++)for(let s=1;s<=4;s++)t.push(`${r}-Q${s}`);return t}const A1=Gde();
833function kA(e){return e.toLocaleString(void 0,{style:"currency",currency:"USD",maximumFractionDigits:0})}function Vde(){const e=at(),{toast:t}=mt(),[n,r]=y.useState(null),[s,i]=y.useState(!1),[o,l]=y.useState(A1[0]),{data:c=[]}=Ee({queryKey:["long_range_plan_items"],queryFn:async()=>{const{data:p,error:v}=await F.from("long_range_plan_items").select("*").is("published_experience_id",null).order("quarter",{ascending:!0}).order("sort_order",{ascending:!0});if(v)throw v;return p}}),u=y.useMemo(()=>{const p=new Map;for(const v of c)p.has(v.quarter)||p.set(v.quarter,[]),p.get(v.quarter).push(v);return Array.from(p.entries()).sort(([v],[b])=>v.localeCompare(b))},[c]),d=Me({mutationFn:async p=>{const{error:v}=await F.from("long_range_plan_items").delete().eq("id",p);if(v)throw v},onSuccess:()=>{e.invalidateQueries({queryKey:["long_range_plan_items"]}),t({title:"Removed from plan"})}}),[h,m]=y.useState(null),f=Me({mutationFn:async({item:p,sourceExperienceId:v})=>{let b={name:p.name,type:"trip",status:"active",target_start_date:qw(p.quarter),price:p.forecasted_revenue&&p.forecasted_revenue>0?p.forecasted_revenue:null};if(v){const{data:_,error:S}=await F.from("experiences").select("*").eq("id",v).single();if(S)throw S;const{id:P,created_at:k,updated_at:C,name:T,target_start_date:O,end_date:L,embedded_trip_start_date:E,embedded_trip_end_date:R,deposit_due_date:q,price_due_date:I,status:$,...M}=_;b={...M,name:p.name,status:"active",target_start_date:qw(p.quarter),price:p.forecasted_revenue&&p.forecasted_revenue>0?p.forecasted_revenue:_.price}}const{data:w,error:N}=await F.from("experiences").insert(b).select("id").single();if(N)throw N;if(v){const _=qw(p.quarter),{data:S}=await F.from("experiences").select("target_start_date").eq("id",v).single();let P=0;if(S!=null&&S.target_start_date){const T=new Date(S.target_start_date),O=new Date(_);P=(O.getFullYear()-T.getFullYear())*12+(O.getMonth()-T.getMonth())}const{data:k}=await F.from("experience_budget_items").select("*").eq("experience_id",v);if(k&&k.length>0){const T=k.map(({id:q,created_at:I,updated_at:$,experience_id:M,...B})=>({...B,experience_id:w.id})),{data:O,error:L}=await F.from("experience_budget_items").insert(T).select("id");if(L)throw L;const E=k.map(q=>q.id),{data:R}=await F.from("experience_budget_item_payments").select("*").in("budget_item_id",E);if(R&&R.length>0&&O){const q=new Map;
833k.forEach((M,B)=>{O[B]&&q.set(M.id,O[B].id)});const I=M=>{const B=new Date(M);return B.setMonth(B.getMonth()+P),B.toISOString().slice(0,10)},$=R.map(({id:M,created_at:B,updated_at:W,budget_item_id:A,due_month:K,...G})=>{const H=q.get(A);return H?{...G,budget_item_id:H,due_month:I(K)}:null}).filter(Boolean);$.length>0&&await F.from("experience_budget_item_payments").insert($)}}const{data:C}=await F.from("experience_addons").select("*").eq("experience_id",v);if(C&&C.length>0){const T=C.map(({id:O,created_at:L,experience_id:E,...R})=>({...R,experience_id:w.id}));await F.from("experience_addons").insert(T)}}const{error:j}=await F.from("long_range_plan_items").update({published_experience_id:w.id}).eq("id",p.id);if(j)throw j;return w},onSuccess:()=>{e.invalidateQueries({queryKey:["long_range_plan_items"]}),e.invalidateQueries({queryKey:["experiences"]}),t({title:"Published to Experiences"}),m(null)},onError:p=>t({title:"Publish failed",description:p.message,variant:"destructive"})}),x=p=>{r(null),l(p),i(!0)},g=p=>{r(p),i(!0)};return a.jsxs("div",{className:"mt-8",children:[a.jsx(py,{className:"mb-6"}),a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"text-xl font-semibold font-display text-foreground",children:"Long-Range Plan"}),a.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>x(A1[0]),children:[a.jsx(zt,{className:"mr-1 h-4 w-4"})," Add Item"]})]}),u.length===0?a.jsx("p",{className:"text-sm text-muted-foreground",children:"No long-range items yet."}):a.jsx("div",{className:"space-y-6",children:u.map(([p,v])=>{const b=v.reduce((w,N)=>w+(Number(N.forecasted_revenue)||0),0);return a.jsxs("div",{children:[a.jsx("div",{className:"flex items-center justify-between mb-2",children:a.jsxs("div",{className:"flex items-baseline gap-3",children:[a.jsx("h4",{className:"text-sm font-semibold text-foreground",children:q8(p)}),b>0&&a.jsx("span",{className:"text-xs text-muted-foreground",children:kA(b)})]})}),a.jsx("div",{className:"space-y-1",children:v.map(w=>a.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-card px-3 py-2 hover:bg-secondary/30",children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsx("div",{className:"text-sm text-foreground truncate",children:w.name})}),a.jsx("div",{className:"text-xs text-muted-foreground w-24 text-right",children:w.forecasted_revenue&&Number(w.forecasted_revenue)>0?kA(Number(w.forecasted_revenue)):"â"}),a.jsx(Y,{size:"icon",variant:"ghost",className:"h-7 w-7",title:"Edit",onClick:()=>g(w),children:a.jsx(Rn,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{size:"icon",variant:"ghost",className:"h-7 w-7",title:"Publish to Experience",onClick:()=>m(w),children:a.jsx(pH,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm(`Delete "${w.name}" from the plan?`)&&d.mutate(w.id)},children:a.jsx(pn,{className:"h-3.5 w-3.5"})})]},w.id))})]},p)})}),a.jsx(Yde,{open:s,onOpenChange:i,item:n,defaultQuarter:o,onSaved:()=>e.invalidateQueries({queryKey:["long_range_plan_items"]})}),a.jsx(Qde,{item:h,onOpenChange:p=>{p||m(null)},onPublish:p=>{h&&f.mutate({item:h,sourceExperienceId:p})},isPublishing:f.isPending})]})}function Yde({open:e,onOpenChange:t,item:n,defaultQuarter:r,onSaved:s}){const{toast:i}=mt(),[o,l]=y.useState(""),[c,u]=y.useState(r),[d,h]=y.useState(""),[m,f]=y.useState(!1);y.useMemo(()=>{e&&(l((n==null?void 0:n.name)??""),u((n==null?void 0:n.quarter)??r),h(n!=null&&n.forecasted_revenue?String(n.forecasted_revenue):""))},[e,n,r]);const x=async()=>{if(!o.trim()){i({title:"Name required",variant:"destructive"});return}f(!0);const g=parseFloat(d.replace(/[^0-9.]/g,""))||0;try{if(n){const{error:p}=await F.from("long_range_plan_items").update({name:o.trim(),quarter:c,forecasted_revenue:g}).eq("id",n.id);if(p)throw p}else{const{error:p}=await F.from("long_range_plan_items").insert({name:o.trim(),quarter:c,forecasted_revenue:g,sort_order:1e3});if(p)throw p}s(),t(!1),i({title:n?"Updated":"Added"})}catch(p){i({title:"Save failed",description:p.message,variant:"destructive"})}finally{f(!1)}};return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{children:[a.jsx(Ot,{children:a.jsx(At,{children:n?"Edit Plan Item":"Add Plan Item"})}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx(xe,{children:"Name"}),a.jsx(ce,{value:o,onChange:g=>l(g.target.value),placeholder:"e.g. Dykstra â Couples Hiking â Africa"})]}),a.jsxs("div",{children:[a.jsx(xe,{children:"Quarter"}),a.jsxs(lt,{value:c,onValueChange:u,children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsx(ot,{children:A1.map(g=>a.jsx(Oe,{value:g,children:q8(g)},g))})]})]}),a.jsxs("div",{children:[a.jsx(xe,{children:"Forecasted Revenue"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),a.jsx(ce,{value:d,onChange:g=>h(g.target.value),inputMode:"decimal",className:"pl-7",placeholder:"0"})]})]})]}),a.jsxs(br,{children:[a.jsx(Y,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),a.jsx(Y,{onClick:x,disabled:m,children:m?"Savingâ¦":"Save"})]})]})})}function Qde({item:e,onOpenChange:t,onPublish:n,isPublishing:r}){const s=e!==null,[i,o]=y.useState("blank"),[l,c]=y.useState(null),[u,d]=y.useState(!1);y.useMemo(()=>{s&&(o("blank"),c(null))},[s,e==null?void 0:e.id]);const{data:h=[]}=Ee({queryKey:["publish-source-experiences"],queryFn:async()=>{const{data:x,error:g}=await F.from("experiences").select("id, name, type, target_start_date").order("target_start_date",{ascending:!1,nullsFirst:!1});if(g)throw g;return x},enabled:s}),m=h.find(x=>x.id===l),f=i==="blank"||i==="copy"&&l!==null;return a.jsx(Dt,{open:s,onOpenChange:t,children:a.jsxs(Pt,{children:[a.jsx(Ot,{children:a.jsxs(At,{children:['Publish "',e==null?void 0:e.name,'" to Experiences']})}),a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:"Start with a blank experience, or copy settings (type, audience, pricing, budget items, and add-ons) from an existing experience."}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>o("blank"),className:Se("flex-1 rounded-md border px-3 py-2 text-sm text-left",i==="blank"?"border-primary bg-primary/5":"border-border hover:bg-secondary/30"),children:[a.jsx("div",{className:"font-medium",children:"Start blank"}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Just name, quarter date, and forecasted price."})]}),a.jsxs("button",{type:"button",onClick:()=>o("copy"),className:Se("flex-1 rounded-md border px-3 py-2 text-sm text-left",i==="copy"?"border-primary bg-primary/5":"border-border hover:bg-secondary/30"),children:[a.jsx("div",{className:"font-medium",children:"Copy existing"}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Duplicate from a past or current experience."})]})]}),i==="copy"&&a.jsxs("div",{children:[a.jsx(xe,{children:"Copy from"}),a.jsxs(na,{open:u,onOpenChange:d,children:[a.jsx(ra,{asChild:!0,children:a.jsxs(Y,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[m?m.name:"Select an experienceâ¦",a.jsx(O3,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),a.jsx(Kr,{className:"p-0 w-[var(--radix-popover-trigger-width)]",align:"start",children:a.jsxs(UC,{children:[a.jsx(WC,{placeholder:"Search experiencesâ¦"}),a.jsxs(KC,{children:[a.jsx(HC,{children:"No experience found."}),a.jsx(Of,{children:h.map(x=>a.jsxs(GC,{value:`${x.name} ${x.type}`,onSelect:()=>{c(x.id),d(!1)},children:[a.jsx(On,{className:Se("mr-2 h-4 w-4",l===x.id?"opacity-100":"opacity-0")}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"truncate",children:x.name}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[x.type,x.target_start_date?` · ${x.target_start_date}`:""]})]})]},x.id))})]})]})})]})]})]}),a.jsxs(br,{children:[a.jsx(Y,{variant:"outline",onClick:()=>t(!1),disabled:r,children:"Cancel"}),a.jsx(Y,{onClick:()=>n(i==="copy"?l:null),disabled:!f||r,children:r?"Publishingâ¦":"Publish"})]})]})})}const Xde={trip:"Trip",peer_group:"Peer Group",stakeholder_summit:"Summit",custom:"Custom"},z8=[{value:"men",label:"Men"},{value:"women",label:"Women"},{value:"couples",label:"Couples"},{value:"mixed_gender",label:"Mixed Gender"}],B8=[{value:"hiking",label:"Hiking"},{value:"skiing",label:"Skiing"},{value:"mountain_biking",label:"Mountain Biking"},{value:"pilgrimage",label:"Pilgrimage"},{value:"paddling",label:"Paddling"}],Jde=Object.fromEntries(B8.map(e=>[e.value,e.label])),zw=[{value:"candidate",label:"Candidate",color:"bg-muted text-muted-foreground"},{value:"expressed_interest",label:"Expressed Interest",color:"bg-sky-100 text-sky-800 dark:bg-sky-900 dark:text-sky-200"},{value:"invited",label:"Invited",color:"bg-secondary text-secondary-foreground"}
833,{value:"considering",label:"Considering",color:"bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200"},{value:"accepted",label:"Accepted",color:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200"},{value:"gen_guide",label:"Gen/Guide",color:"bg-violet-100 text-violet-800 dark:bg-violet-900 dark:text-violet-200"},{value:"declined",label:"Declined",color:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"},{value:"dropped",label:"Dropped",color:"bg-slate-200 text-slate-700 dark:bg-slate-800 dark:text-slate-200"},{value:"future",label:"Future",color:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"},{value:"waitlist",label:"Waitlist",color:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200"}],Zde={active:"Active",cancelled:"Cancelled"};function ehe(){const[e,t]=y.useState(!1),[n,r]=y.useState(null),[s,i]=y.useState(null),[o,l]=y.useState(!1),[c,u]=y.useState(null),[d,h]=y.useState(null),[m,f]=y.useState("upcoming"),x=at(),{toast:g}=mt(),{data:p=[]}=ps(),{data:v}=go(),{data:b}=Qs();y.useEffect(()=>{d===null&&b!==void 0&&(b?h([]):v?h([v.id]):v===null&&h([]))},[v,d,b]);const{data:w=[],isLoading:N}=Ee({queryKey:["experiences",d,m],enabled:d!==null,queryFn:async()=>{let E=F.from("experiences").select("*").order("target_start_date",{ascending:!0,nullsFirst:!1});m==="upcoming"&&(E=E.eq("status","active"));const{data:R,error:q}=await E;if(q)throw q;let I=R;if(m==="upcoming"){const $=new Date;$.setDate($.getDate()-60);const M=$.toISOString().slice(0,10);I=I.filter(B=>B.end_date?B.end_date>=M:!B.target_start_date||B.target_start_date>=M)}if(d&&d.length>0){const[{data:$},{data:M}]=await Promise.all([F.from("generator_experiences").select("experience_id").in("generator_id",d),F.from("experience_team_roles").select("experience_id").in("generator_id",d)]),B=new Set([...$||[],...M||[]].map(W=>W.experience_id));I=I.filter(W=>B.has(W.id)||W.project_manager_id&&d.includes(W.project_manager_id))}return I}}),[j,_]=El(),S=j.get("id");y.useEffect(()=>{if(!S||(c==null?void 0:c.id)===S)return;let E=!1;return(async()=>{const R=w.find(q=>q.id===S);if(R)E||u(R);else{const{data:q}=await F.from("experiences").select("*").eq("id",S).maybeSingle();!E&&q&&(u(q),m==="upcoming"&&f("all"))}if(!E){const q=new URLSearchParams(j);q.delete("id"),_(q,{replace:!0})}})(),()=>{E=!0}},[S,w]);const P=w.map(E=>E.id),{data:k={accepted:{},gen_guide:{},considering:{}}}=Ee({queryKey:["experience-status-counts",P],enabled:P.length>0,queryFn:async()=>{const{data:E,error:R}=await F.from("contact_experiences").select("experience_id, status").in("status",["accepted","gen_guide","considering"]).in("experience_id",P);if(R)throw R;const q={},I={},$={};return(E||[]).forEach(M=>{M.status==="accepted"?q[M.experience_id]=(q[M.experience_id]||0)+1:M.status==="gen_guide"?I[M.experience_id]=(I[M.experience_id]||0)+1:M.status==="considering"&&($[M.experience_id]=($[M.experience_id]||0)+1)}),{accepted:q,gen_guide:I,considering:$}}}),C=k.accepted,T=k.gen_guide,O=k.considering;y.useEffect(()=>{if(c&&w.length>0){const E=w.find(R=>R.id===c.id);E&&JSON.stringify(E)!==JSON.stringify(c)&&u(E)}},[w]);const L=Me({mutationFn:async E=>{const{error:R}=await F.from("experiences").delete().eq("id",E);if(R)throw R},onSuccess:()=>{x.invalidateQueries({queryKey:["experiences"]}),u(null),g({title:"Experience deleted"})}});return a.jsxs(Rr,{children:[a.jsxs("div",{className:"animate-fade-in",children:[a.jsxs("div",{className:"mb-6 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[a.jsx("h2",{className:"text-2xl font-semibold font-display text-foreground",children:"Experiences"}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx(xk,{generators:p,selectedIds:d||[],onChange:h,className:"w-40 h-9 text-xs"}),a.jsxs(lt,{value:m,onValueChange:E=>f(E),children:[a.jsx(it,{className:"w-36 h-9 text-xs",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"upcoming",children:"Upcoming/Recent"}),a.jsx(Oe,{value:"all",children:"All Experiences"})]})]}),a.jsxs(Y,{onClick:()=>{r(null),t(!0)},size:"sm",children:[a.jsx(zt,{className:"mr-1 h-4 w-4"})," Add Experience"]})]})]}),N?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):w.length===0?a.jsx("div",{className:"flex h-48 items-center justify-center rounded-md border border-dashed border-border",children:a.jsx("p",{className:"text-sm text-muted-foreground",children:"No experiences yet. Add your first one."})}):a.jsxs("div",{className:"grid gap-6 lg:grid-cols-7",children:[a.jsxs("div",{className:c?"lg:col-span-3":"lg:col-span-7",children:[a.jsx("div",{className:"space-y-1",children:w.map(E=>a.jsx("button",{onClick:()=>u(E),className:Se("flex w-full items-center justify-between rounded-md px-4 py-3 text-left transition-colors",(c==null?void 0:c.id)===E.id?"bg-secondary border border-border":"hover:bg-secondary/50"),children:a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium text-sm text-foreground",children:E.name}),(C[E.id]||0)>0&&a.jsx("span",{className:"inline-flex items-center justify-center h-5 min-w-5 px-1.5 rounded-full bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200 text-[10px] font-semibold",children:C[E.id]}),(T[E.id]||0)>0&&a.jsx("span",{className:"inline-flex items-center justify-center h-5 min-w-5 px-1.5 rounded-full bg-violet-100 text-violet-800 dark:bg-violet-900 dark:text-violet-200 text-[10px] font-semibold",children:T[E.id]}),(O[E.id]||0)>0&&a.jsx("span",{className:"inline-flex items-center justify-center h-5 min-w-5 px-1.5 rounded-full bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200 text-[10px] font-semibold",children:O[E.id]})]}),a.jsx("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:E.target_start_date&&a.jsxs("span",{children:["Starts ",Ye(new Date(E.target_start_date+"T00:00:00"),"MMM d, yyyy")]})})]})},E.id))}),a.jsx(Vde,{})]}),c&&a.jsx("div",{className:"lg:col-span-4 self-start sticky top-6",children:a.jsx(nhe,{experience:c,onEdit:()=>{r(c),t(!0)},onDelete:()=>L.mutate(c.id),onClone:()=>{i(c),l(!0)},onClose:()=>u(null)})})]})]}),a.jsx(rhe,{open:e,onOpenChange:t,experience:n}),a.jsx(ahe,{open:o,onOpenChange:l,experience:s})]})}const EA=["expressed_interest","accepted","gen_guide","considering","
833waitlist","invited","candidate","future","declined","dropped"];function the({contacts:e,experience:t,onStatusChange:n,onRemove:r,onCustomPriceChange:s,onDiscountReasonChange:i,onScheduleChange:o,onCopyPublicLink:l,onCreateFollowUp:c,onEditContact:u,companionMap:d,onSetCompanion:h}){const m=t.type==="trip"||t.type==="peer_group",{summits:f,sources:x}=bce(t.id,m),g=_ce(m),{data:p={}}=Ee({queryKey:["participant-referrers",t.id],enabled:m,queryFn:async()=>{const{data:J,error:re}=await F.from("contact_experiences").select("id, referred_by").eq("experience_id",t.id);if(re)throw re;return Object.fromEntries((J??[]).map(pe=>[pe.id,pe.referred_by]))}}),[v,b]=y.useState("status"),[w,N]=y.useState("asc"),[j,_]=y.useState(null),[S,P]=y.useState(null),[k,C]=y.useState(null),[T,O]=y.useState(null),[L,E]=y.useState(""),[R,q]=y.useState(null),[I,$]=y.useState(""),[M,B]=y.useState(""),[W,A]=y.useState(""),{data:K=[]}=Ee({queryKey:["experience-comp-agreements-table",t.id],queryFn:async()=>{const{data:J,error:re}=await F.from("generator_experience_comp").select("generator_id, invite_bonus_pct, invite_bonus_threshold, recruitment_share_pct, trip_price_snapshot, quality_invite_ids, generators(email)").eq("experience_id",t.id);if(re)throw re;return J??[]}}),G=y.useMemo(()=>{var pe,ye;const J=new Map;if(K.length===0)return J;const re=new Map;for(const X of K){const he=(((pe=X.generators)==null?void 0:pe.email)||"").toLowerCase();he&&re.set(he,X)}for(const X of e){if(X.status!=="gen_guide")continue;const he=re.get((((ye=X.contacts)==null?void 0:ye.email)||"").toLowerCase());if(!he)continue;const D=Number(he.trip_price_snapshot)||Number(X.custom_price??t.price??0),le=(he.quality_invite_ids||[]).length,V=Number(he.invite_bonus_threshold)||0,U=le>=V?D*((Number(he.invite_bonus_pct)||0)/100):0,z=e.filter(ee=>{var de;return ee.id!==X.id&&ee.status==="accepted"&&((de=ee.contacts)==null?void 0:de.generator_id)===he.generator_id}),Z=z.reduce((ee,de)=>ee+Number(de.custom_price??t.price??0),0),ve=U+Z*((Number(he.recruitment_share_pct)||0)/100);J.set(X.id,{base:D,credit:Math.round(ve*100)/100,net:Math.round(Math.max(0,D-Math.min(ve,D))*100)/100,recruits:z.length})}return J},[K,e,t.price]),H=J=>{v===J?N(re=>re==="asc"?"desc":"asc"):(b(J),N("asc"))},fe=y.useMemo(()=>{const J=[...e];return J.sort((re,pe)=>{var X,he,D,le;let ye=0;return v==="name"?ye=(((X=re.contacts)==null?void 0:X.name)||"").localeCompare(((he=pe.contacts)==null?void 0:he.name)||""):ye=EA.indexOf(re.status||"candidate")-EA.indexOf(pe.status||"candidate"),ye!==0?w==="desc"?-ye:ye:(((D=re.contacts)==null?void 0:D.name)||"").localeCompare(((le=pe.contacts)==null?void 0:le.name)||"")}),J},[e,v,w]),te=({field:J})=>v!==J?a.jsx(VK,{className:"h-3 w-3 ml-1 opacity-40"}):w==="asc"?a.jsx(E3,{className:"h-3 w-3 ml-1"}):a.jsx(k3,{className:"h-3 w-3 ml-1"});return e.length===0?null:a.jsx("div",{className:"rounded border border-border overflow-hidden",children:a.jsxs("table",{className:"w-full text-xs",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border bg-muted/50",children:[a.jsx("th",{className:"text-left px-2 py-1.5 font-medium text-muted-foreground",children:a.jsxs("button",{className:"inline-flex items-center hover:text-foreground",onClick:()=>H("name"),children:["Name ",a.jsx(te,{field:"name"})]})}),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium text-muted-foreground",children:a.jsxs("button",{className:"inline-flex items-center hover:text-foreground",onClick:()=>H("status"),children:["Status ",a.jsx(te,{field:"status"})]})}),a.jsx("th",{className:"w-7 px-1 py-1.5",title:"Generator"}),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium text-muted-foreground w-20",children:"Price"}),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium text-muted-foreground w-16",children:"Paid"}),a.jsx("th",{className:"w-20 px-2 py-1.5"})]})}),a.jsx("tbody",{children:fe.map(J=>{var pe,ye,X,he,D,le,V,U,z,Z,ve;const re=zw.find(ee=>ee.value===J.status)||zw[0];return a.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/30 transition-colors",children:[a.jsxs("td",{className:"px-2 py-1.5",children:[a.jsxs(zde,{openDelay:300,closeDelay:100,children:[a.jsx(Bde,{asChild:!0,children:a.jsxs("a",{href:`/contacts?contact=${J.contact_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate inline-flex items-center gap-1.5",onClick:ee=>ee.stopPropagation(),children:[J.re_engaged_at&&a.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-500 flex-shrink-0",title:`Re-engaged ${Ye(new Date(J.re_engaged_at),"MMM d, yyyy 'at' h:mm a")}`}),a.jsx("span",{className:"truncate",children:(pe=J.contacts)==null?void 0:pe.name})]})}),a.jsx(F8,{side:"left",align:"start",className:"w-72 p-3",children:a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:(ye=J.contacts)==null?void 0:ye.name}),((X=J.contacts)==null?void 0:X.company)&&a.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1 mt-0.5",children:[a.jsx(rC,{
833className:"h-3 w-3"})," ",J.contacts.company]})]}),a.jsxs("div",{className:"space-y-1",children:[((he=J.contacts)==null?void 0:he.email)&&a.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[a.jsx(fs,{className:"h-3 w-3"})," ",J.contacts.email]}),((D=J.contacts)==null?void 0:D.phone)&&a.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[a.jsx(lC,{className:"h-3 w-3"})," ",J.contacts.phone]})]}),((le=J.contacts)==null?void 0:le.status)&&a.jsx(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0 capitalize",children:J.contacts.status}),J.last_viewed_at&&a.jsxs("p",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[a.jsx(pl,{className:"h-3 w-3"})," Viewed page ",Ye(new Date(J.last_viewed_at),"MMM d, yyyy 'at' h:mm a")]}),(((V=J.contacts)==null?void 0:V.offering_interest)||[]).length>0&&a.jsx("div",{className:"flex flex-wrap gap-1",children:J.contacts.offering_interest.map(ee=>a.jsx(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:ee},ee))})]})})]}),m&&(J.status==="accepted"||((U=x[J.id])==null?void 0:U.linkedId
833))&&a.jsx(wce,{ceId:J.id,experienceId:t.id,info:x[J.id],summits:f}),m&&J.status!=="gen_guide"&&a.jsx(jce,{ceId:J.id,contactId:J.contact_id,referredBy:p[J.id]??null,options:g}),(()=>{var Q,oe;const ee=d[J.id]||null,de=ee?e.find(Pe=>Pe.contact_id===ee):null,je=e.filter(Pe=>d[Pe.id]===J.contact_id);return a.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[de&&a.jsxs("span",{className:"text-[10px] text-muted-foreground truncate",title:"Companion of",children:["+ with ",(Q=de.contacts)==null?void 0:Q.name]}),!de&&je.length>0&&a.jsxs("span",{className:"text-[10px] text-muted-foreground truncate",title:"Companions",children:["+ ",je.map(Pe=>{var ze;return(ze=Pe.contacts)==null?void 0:ze.name}).join(", ")]}),a.jsxs(na,{open:R===J.id,onOpenChange:Pe=>q(Pe?J.id:null),children:[a.jsx(ra,{asChild:!0,children:a.jsx("button",{className:Se("h-4 w-4 flex-shrink-0",de?"text-primary":"text-muted-foreground/40 hover:text-muted-foreground"),title:"Link as companion (couple)",children:a.jsx(Hc,{className:"h-3 w-3"})})}),a.jsxs(Kr,{className:"w-64 p-3 z-[100]",align:"start",sideOffset:5,children:[a.jsxs("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:["Link ",(oe=J.contacts)==null?void 0:oe.name," as companion of"]}),a.jsx(Kt,{value:ee||"",onValueChange:Pe=>{h(J.id,Pe||null),q(null)},options:e.filter(Pe=>Pe.contact_id!==J.contact_id).map(Pe=>{var ze;return{value:Pe.contact_id,label:((ze=Pe.contacts)==null?void 0:ze.name)||"Unnamed"}}),placeholder:"Select participant..."}),de&&a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 mt-2 text-[11px] text-destructive px-1",onClick:()=>{h(J.id,null),q(null)},children:"Unlink"})]})]})]})})()]}),a.jsx("td",{className:"px-2 py-1.5",children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs(lt,{value:J.status||"candidate",onValueChange:ee=>n(J.id,ee),children:[a.jsx(it,{className:Se("h-5 px-1.5 text-[10px] font-medium border-0 gap-1 w-auto",re.color),children:a.jsx(ct,{})}),a.jsx(ot,{children:zw.map(ee=>a.jsx(Oe,{value:ee.value,children:ee.label},ee.value))})]}),J.status==="invited"&&a.jsx("span",{className:"text-[10px] text-muted-foreground",title:"Probability used in projected revenue",children:"25%"}),(J.status==="considering"||J.status==="expressed_interest")&&a.jsx("span",{className:"text-[10px] text-muted-foreground",title:"Probability used in projected revenue",children:"50%"})]})}),a.jsx("td",{className:"px-1 py-1.5",children:(Z=(z=J.contacts)==null?void 0:z.generators)!=null&&Z.name?a.jsx("div",{className:"h-5 w-5 rounded-full bg-primary/15 text-primary flex items-center justify-center text-[9px] font-semibold leading-none",title:J.contacts.generators.name,children:J.contacts.generators.name.split(" ").map(ee=>ee[0]).join("").slice(0,2).toUpperCase()}):null}),a.jsx("td",{className:"px-2 py-1.5",children:a.jsxs("div",{className:"flex items-center gap-0.5",children:[(()=>{const ee=G.get(J.id);return ee?a.jsx("span",{className:"h-5 w-16 px-1 text-[10px] flex items-center rounded bg-violet-50 text-violet-800 dark:bg-violet-950 dark:text-violet-200 tabular-nums",title:`Live comp price â base $${ee.base.toLocaleString()} less $${ee.credit.toLocaleString()} credit from ${ee.recruits} accepted recruit${ee.recruits===1?"":"s"}. Updates automatically.`,children:ee.net.toLocaleString()}):a.jsx(as,{type:"text",inputMode:"decimal",className:"h-5 w-16 text-[10px] text-left px-1 block",placeholder:t.price!=null?`${t.price}`:"â",value:J.custom_price!=null?J.custom_price:"",onCommit:de=>{s(J.id,de?parseFloat(de):null)},title:J.custom_price!=null?`Custom: $${J.custom_price}`:`Default: $${t.price||0}`})})(),J.custom_price!=null&&t.price!=null&&Number(J.custom_price)<Number(t.price)&&a.jsxs(na,{open:T===J.id,onOpenChange:ee=>{ee?(O(J.id),E(J.discount_reason||"")):O(null)},children:[a.jsx(ra,{asChild:!0,children:a.jsx("button",{className:`h-4 w-4 flex-shrink-0 ${J.discount_reason?"text-primary":"text-muted-foreground/40 hover:text-muted-foreground"}`,title:J.discount_reason?`Discount reason: ${J.discount_reason}`:"Record discount reason",children:a.jsx(Wv,{className:"h-3 w-3"})})}),a.jsxs(Kr,{className:"w-56 p-3 z-[100]",align:"start",sideOffset:5,children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Discount Reason"}),a.jsx(ce,{className:"h-6 text-xs",placeholder:"e.g. Repeat participant",value:L,onChange:ee=>E(ee.target.value)}),a.jsxs("div",{className:"flex justify-end gap-1 mt-2",children:[a.jsx(Y,{size:"sm",variant:"ghost",className:"h-6 text-xs",onClick:()=>O(null),children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>{i(J.id,L.trim()||null),O(null)},children:"Save"})]})]})]}),(J.status==="accepted"||J.status==="gen_guide")&&a.jsx(hce,{ceId:J.id,participantName:((ve=J.contacts)==null?void 0:ve.name)??"Participant",seatTotal:Number(J.custom_price??t.price??0)}),a.jsxs(na,{open:k===J.id,onOpenChange:ee=>{ee?(C(J.id),$(J.payment_count!=null?String(J.payment_count):""),B(J.payment_frequency||""),A(J.price_due_date||"")):C(null)},children:[a.jsx(ra,{asChild:!0,children:a.jsx("button",{className:`h-4 w-4 flex-shrink-0 ${J.payment_count!=null||J.price_due_date?"text-primary":"text-muted-foreground
833/40 hover:text-muted-foreground"}`,title:J.payment_count!=null?`Custom schedule: ${J.payment_count} payments (${J.payment_frequency||"monthly"})${J.price_due_date?`, due ${J.price_due_date}`:""}`:J.price_due_date?`Custom due date: ${J.price_due_date}`:"Set custom payment schedule",children:a.jsx(Kx,{className:"h-3 w-3"})})}),a.jsxs(Kr,{className:"w-52 p-3 z-[100]",align:"start",sideOffset:5,children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Custom Payment Schedule"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Number of Payments"}),a.jsx(ce,{type:"number",min:"0",className:"h-6 text-xs",placeholder:t.payment_count!=null?`${t.payment_count} (default)`:"None",value:I,onChange:ee=>$(ee.target.value)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Frequency"}),a.jsxs(lt,{value:M,onValueChange:B,children:[a.jsx(it,{className:"h-6 text-xs",children:a.jsx(ct,{placeholder:t.payment_frequency||"Monthly (default)"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"monthly",children:"Monthly"}),a.jsx(Oe,{value:"quarterly",children:"Quarterly"})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Final Payment Due"}),a.jsx(ce,{type:"date",className:"h-6 text-xs",placeholder:t.price_due_date||"",value:W,onChange:ee=>A(ee.target.value)})]}),a.jsxs("div",{className:"flex gap-1 justify-end pt-1",children:[(J.payment_count!=null||J.price_due_date!=null)&&a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{o(J.id,null,null,null),C(null)},children:"Reset"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>{const ee=I?parseInt(I):null,de=M||null,je=W||null;o(J.id,ee&&ee>=2?ee:null,ee&&ee>=2?de:null,je),C(null)},children:"Save"})]})]})]})]})]})}),a.jsx("td",{className:"px-2 py-1.5 text-left",children:a.jsxs("span",{className:"text-[10px] font-medium text-muted-foreground",children:["$",Number(J.amount_paid||0).toLocaleString()]})}),a.jsx("td",{className:"px-2 py-1.5",children:a.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",title:"Edit contact",onClick:()=>u(J.contact_id),children:a.jsx(Rn,{className:"h-3 w-3"})}),["candidate","expressed_interest","invited","considering"].includes(J.status)&&a.jsxs(na,{open:j===J.contact_id,onOpenChange:ee=>_(ee?J.contact_id:null),children:[a.jsx(ra,{asChild:!0,children:a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",title:"Create follow-up task",children:a.jsx(hH,{className:"h-3.5 w-3.5"})})}),a.jsxs(Kr,{className:"w-auto p-0 z-[100]",align:"end",sideOffset:5,children:[a.jsx("div",{className:"p-2 pb-0",children:a.jsx("p",{className:"text-xs font-medium text-muted-foreground px-1",children:"Select due date for follow-up"})}),a.jsx(kk,{mode:"single",selected:void 0,onSelect:ee=>{var de;ee&&(c(((de=J.contacts)==null?void 0:de.name)||"",J.contact_id,ee),_(null))},disabled:ee=>ee<new Date(new Date().setHours(0,0,0,0)),initialFocus:!0,className:"p-3 pointer-events-auto"})]})]}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",title:"Copy personalized magic link",onClick:()=>l(J.public_token),children:a.jsx(Nl,{className:"h-3.5 w-3.5"})}),S===J.id?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"text-[10px] text-destructive font-medium whitespace-nowrap",children:Number(J.amount_paid||0)>0?`Remove? ($${Number(J.amount_paid).toLocaleString()} paid)`:"Remove?"}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5 text-destructive",onClick:()=>{r(J.id),P(null)},children:a.jsx(On,{className:"h-3 w-3"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>P(null),children:a.jsx(Ht,{className:"h-3 w-3"})})]}):a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>P(J.id),children:a.jsx(Ht,{className:"h-3.5 w-3.5"})})]})})]},J.id)})})]})})}function nhe({experience:e,onEdit:t,onDelete:n,onClone:r,onClose:s}){var Nt;
833const{data:i=[]}=ps(),{data:o}=Qs(),{data:l}=go(),c=!!(o||l&&l.type==="employee"),u=at(),{toast:d}=mt(),{data:h=[]}=Ee({queryKey:["experience-contacts",e.id],queryFn:async()=>{const{data:ue,error:we}=await F.rpc("get_experience_contacts_for_display",{_experience_id:e.id});if(we)throw we;const{data:Ie}=await F.from("contact_experiences").select("id, discount_reason").eq("experience_id",e.id),se=new Map((Ie??[]).map(ge=>[ge.id,ge.discount_reason]));return(ue??[]).map(ge=>({id:ge.id,contact_id:ge.contact_id,status:ge.status,custom_price:ge.custom_price,discount_reason:se.get(ge.id)??null,amount_paid:ge.amount_paid,deposit_paid:ge.deposit_paid,price_paid:ge.price_paid,public_token:ge.public_token,last_viewed_at:ge.last_viewed_at,re_engaged_at:ge.re_engaged_at,payment_count:ge.payment_count,payment_frequency:ge.payment_frequency,price_due_date:ge.price_due_date,contacts:{id:ge.contact_id,name:ge.contact_name,email:ge.contact_email,phone:ge.contact_phone,company:ge.contact_company,status:ge.contact_status,offering_interest:ge.contact_offering_interest,generator_id:ge.contact_generator_id,generators:ge.generator_id?{id:ge.generator_id,name:ge.generator_name}:null}}))}}),{data:m=[]}=Ee({queryKey:["experience-companions",e.id],queryFn:async()=>{const{data:ue,error:we}=await F.from("contact_experiences").select("id, companion_of_contact_id").eq("experience_id",e.id);if(we)throw we;return ue??[]}}),f=y.useMemo(()=>{const ue={};for(const we of m)ue[we.id]=we.companion_of_contact_id;return ue},[m]),x=Me({mutationFn:async({ceId:ue,companionContactId:we})=>{const{error:Ie}=await F.from("contact_experiences").update({companion_of_contact_id:we}).eq("id",ue);if(Ie)throw Ie},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-companions",e.id]}),d({title:"Companion link updated"})},onError:ue=>d({title:"Could not update companion",description:ue.message,variant:"destructive"})}),{data:g=[]}=Ee({queryKey:["experience-generators",e.id],queryFn:async()=>{const{data:ue,error:we}=await F.from("generator_experiences").select("id, generator_id, is_host_guide, is_generator, generators(name, email, type)").eq("experience_id",e.id);if(we)throw we;return ue}}),{data:p=[]}=Ee({queryKey:["experience-team-roles",e.id],queryFn:async()=>{const{data:ue,error:we}=await F.from("experience_team_roles").select("id, generator_id, role").eq("experience_id",e.id);if(we)throw we;return ue??[]}}),v=Me({mutationFn:async({role:ue,generatorId:we})=>{const{error:Ie}=await F.from("experience_team_roles").delete().eq("experience_id",e.id).eq("role",ue);if(Ie)throw Ie;if(we){const{error:se}=await F.from("experience_team_roles").insert({experience_id:e.id,generator_id:we,role:ue});if(se)throw se}},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-team-roles",e.id]}),u.invalidateQueries({queryKey:["experiences"]}
833),u.invalidateQueries({queryKey:["experiences-no-pm"]}),d({title:"Team updated"})},onError:ue=>d({title:"Could not update Team",description:ue.message,variant:"destructive"})}),b=(()=>{if(c)return"employee";const ue=l==null?void 0:l.id;if(!ue)return null;if(p.some(Ie=>(Ie.role==="project_manager"||Ie.role==="booking")&&Ie.generator_id===ue))return"project_manager";const we=g.filter(Ie=>Ie.generator_id===ue);return we.some(Ie=>Ie.is_generator!==!1)?"generator":we.some(Ie=>Ie.is_host_guide)?"guide":null})(),{data:w=[]}=Ee({queryKey:["experiences-list-simple"],queryFn:async()=>{const{data:ue,error:we}=await F.from("experiences").select("id, name, target_start_date").order("name");if(we)throw we;return ue}}),{data:N=[]}=Ee({queryKey:["experience-activities",e.id],queryFn:async()=>{const{data:ue,error:we}=await F.from("activities").select("id, description, type, completed, due_date, field_type, contact_id, generator_id, experience_id, notes, contacts(name)").eq("experience_id",e.id).eq("field_type","task").eq("completed",!1).order("due_date",{ascending:!0,nullsFirst:!1});if(we)throw we;return ue}}),{data:j=[]}=Ee({queryKey:["contacts-for-assignment"],queryFn:async()=>{const{data:ue,error:we}=await F.rpc("get_all_contacts_for_assignment");if(we)throw we;return ue??[]}}),[_,S]=y.useState(""),[P,k]=y.useState(""),[C,T]=y.useState(""),[O,L]=y.useState(!1),[E,R]=y.useState(""),[q,I]=y.useState(""),[$,M]=y.useState(""),[B,W]=y.useState(""),[A,K]=y.useState(null),[G,H]=y.useState(""),[fe,te]=y.useState(""),[J,re]=y.useState(""),[pe,ye]=y.useState(""),[X,he]=y.useState(""),[D,le]=y.useState(""),[V,U]=y.useState(!1),[z,Z]=y.useState(null),[ve,ee]=y.useState(!1),[de,je]=y.useState(!1),Q=new Set(h.map(ue=>ue.contact_id)),oe=new Set(g.map(ue=>ue.generator_id)),Pe=Me({mutationFn:async()=>{if(!_||_==="none")return;const{error:ue}=await F.from("contact_experiences").insert({contact_id:_,experience_id:e.id});if(ue)throw ue},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-contacts",e.id]}),S(""),d({title:"Contact added"})}}),ze=Me({mutationFn:async()=>{if(!P||P==="none")return;const{error:ue}=await F.from("generator_experiences").insert({generator_id:P,experience_id:e.id});if(ue)throw ue},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-generators",e.id]}),k(""),d({title:"Generator added"})}}),Je=Me({mutationFn:async()=>{if(!C.trim())return;const ue=q||((l==null?void 0:l.id)??(g.length>0?g[0].generator_id:null)),{error:we}=await F.from("activities").insert({description:C.trim(),experience_id:e.id,generator_id:ue||null,contact_id:E||null,due_date:$||null,notes:B.trim()||null});if(we)throw we},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-activities",e.id]}),u.invalidateQueries({queryKey:["all-activities"]}),T(""),R(""),I(""),M(""),W(""),L(!1),d({title:"Task added"})}}),Ae=Me({mutationFn:async ue=>{const{error:we}=await F.from("activities").update({description:G.trim(),contact_id:fe||null,generator_id:J||null,experience_id:pe||null,due_date:X||null,notes:D.trim()||null}).eq("id",ue);if(we)throw we},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-activities",e.id]}),u.invalidateQueries({queryKey:["all-activities"]}),K(null),d({title:"Task updated"})}}),et=Me({mutationFn:async ue=>{await F.from("manual_payments").delete().eq("contact_experience_id",ue),await F.from("contact_experience_addons").delete().eq("contact_experience_id",ue),await F.from("survey_responses").delete().eq("contact_experience_id",ue),await F.from("activity_responses").delete().eq("contact_experience_id",ue);const{error:we}=await F.from("contact_experiences").delete().eq("id",ue);if(we)throw we},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-contacts",e.id]}),u.invalidateQueries({queryKey:["experience-status-counts"]}
833),u.invalidateQueries({queryKey:["summit-sources"]}),d({title:"Contact removed from experience"})},onError:ue=>d({title:"Error removing contact",description:ue.message,variant:"destructive"})}),Ne=Me({mutationFn:async ue=>{const{error:we}=await F.from("generator_experiences").delete().eq("id",ue);if(we)throw we},onSuccess:()=>u.invalidateQueries({queryKey:["experience-generators",e.id]})}),be=Me({mutationFn:async({id:ue,value:we})=>{const{error:Ie}=await F.from("generator_experiences").update({is_generator:we}).eq("id",ue);if(Ie)throw Ie},onSuccess:()=>u.invalidateQueries({queryKey:["experience-generators",e.id]}),onError:ue=>d({title:"Could not update role",description:ue.message,variant:"destructive"})}),Ue=Me({mutationFn:async({id:ue,value:we,generatorId:Ie})=>{const{error:se}=await F.from("generator_experiences").update({is_host_guide:we}).eq("id",ue);if(se)throw se;if(!we)return{created:!1};const{data:ge,error:$e}=await F.from("generator_experience_comp").select("id").eq("experience_id",e.id).eq("generator_id",Ie).maybeSingle();if($e)throw $e;if(ge)return{created:!1};const{error:Ke}=await F.from("generator_experience_comp").insert({experience_id:e.id,generator_id:Ie,invite_bonus_pct:100,invite_bonus_threshold:0,recruitment_share_pct:10,trip_price_snapshot:e.price??0,quality_invite_ids:[],host_guide_pct:8});if(Ke)throw Ke;return{created:!0}},onSuccess:ue=>{u.invalidateQueries({queryKey:["experience-generators",e.id]}),u.invalidateQueries({queryKey:["generator-comp-list",e.id]}),u.invalidateQueries({queryKey:["budget-comp-agreements",e.id]}),u.invalidateQueries({queryKey:["budget-generator-count",e.id]}),u.invalidateQueries({queryKey:["budget-items",e.id]}),u.invalidateQueries({queryKey:["generator-earnings"]}),ue!=null&&ue.created&&d({title:"Host/Guide comp created",description:"100% invite bonus, no threshold, 8% Host/Guide fee. Edit in Compensation."})},onError:ue=>d({title:"Update failed",description:ue.message,variant:"destructive"})}),Ze=Me({mutationFn:async ue=>{const{error:we}=await F.from("activities").delete().eq("id",ue);if(we)throw we},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-activities",e.id]}),u.invalidateQueries({queryKey:["all-activities"]})}}),nt=Me({mutationFn:async ue=>{const we=!ue.completed,{error:Ie}=await F.from("activities").update({completed:we,completed_at:we?new Date().toISOString():null}).eq("id",ue.id);if(Ie)throw Ie},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-activities",e.id]}),u.invalidateQueries({queryKey:["all-activities"]})}}),rt=Me({mutationFn:async({ceId:ue,status:we})=>{const{error:Ie}=await F.from("contact_experiences").update({status:we}).eq("id",ue);if(Ie)throw Ie},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-contacts",e.id]}),u.invalidateQueries({queryKey:["budget-accepted-contacts",e.id]}),u.invalidateQueries({queryKey:["experience-ces-picker",e.id]}),u.invalidateQueries({queryKey:["generator-recruits",e.id]})}}),kt=Me({mutationFn:async({ceId:ue,price:we})=>{const{error:Ie}=await F.from("contact_experiences").update({custom_price:we}).eq("id",ue);if(Ie)throw Ie},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-contacts",e.id]})}}),jt=Me({mutationFn:async({ceId:ue,reason:we})=>{const{error:Ie}=await F.from("contact_experiences").update({discount_reason:we}).eq("id",ue);if(Ie)throw Ie},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-contacts",e.id]})}}),Et=Me({mutationFn:async({ceId:ue,paymentCount:we,paymentFrequency:Ie,priceDueDate:se})=>{const{error:ge}=await F.from("contact_experiences").update({payment_count:we,payment_frequency:Ie,price_due_date:se}).eq("id",ue);if(ge)throw ge},onSuccess:()=>{u.invalidateQueries({queryKey:["experience-contacts",e.id]})}});return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-md border border-border bg-card p-4 animate-fade-in space-y-4",children:[a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold font-display text-card-foreground",children:e.public_name||e.name}),a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx(Ge,{variant:"outline",className:"text-xs",children:Xde[e.type]||e.type}),e.activity_type&&a.jsx(Ge,{variant:"outline",className:"text-xs",children:Jde[e.activity_type]||e.activity_type}),a.jsx(Ge,{variant:"secondary",className:"text-xs",children:Zde[e.status]||e.status})]})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:t,children:a.jsx(Rn,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{const ue=`${window.location.origin}/experience?experienceId=${e.id}`;navigator.clipboard.writeText(ue),d({title:"Public link copied to clipboard"})},title:"Copy public link",children:a.jsx(Nl,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r,title:"Clone",children:a.jsx(zv,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:n,children:a.jsx(pn,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:s,children:a.jsx(Ht,{className:"h-3.5 w-3.5"})})]})]}),a.jsxs("div",{className:"space-y-1 text-sm text-muted-foreground",children:[e.location&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(zi,{className:"h-3.5 w-3.5"}),a.jsx("span",{children:e.location})]}),e.target_start_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rs,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Starts ",Ye(new Date(e.target_start_date+"T00:00:00"),"MMM d, yyyy"),e.end_date?` â Ends ${Ye(new Date(e.end_date+"T00:00:00"),"MMM d, yyyy")}`:""]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(pl,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Created ",Ye(new Date(e.created_at),"MMM d, yyyy")]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ws,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Goal Size: ",e.max_size??10]})]}),e.audience&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ws,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Audience: ",((Nt=z8.find(ue=>ue.value===e.audience))==null?void 0:Nt.label)||e.audience]})]}),(e.price!=null||e.deposit!=null)&&a.jsxs("div",{className:"border-t border-border pt-2 mt-2 space-y-1",children:[e.price!=null&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hi,{className:"h-3.5 w-3.5"}
833),a.jsxs("span",{children:["Price: $",Number(e.price).toLocaleString()]}),e.price_due_date&&a.jsxs("span",{className:"text-xs",children:["· ",e.price_due_date&&a.jsxs("span",{className:"text-xs",children:["· ",e.payment_count&&e.payment_count>=2?"Final Payment Due":"Due"," ",Ye(new Date(e.price_due_date+"T00:00:00"),"MMM d, yyyy")]})," ",Ye(new Date(e.price_due_date+"T00:00:00"),"MMM d, yyyy")]})]}),e.payment_count&&e.payment_count>=2?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hi,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:[e.payment_count," ",e.payment_frequency||""," payments"]}),e.price!=null&&a.jsxs("span",{className:"text-xs",children:["· $",Math.round(Number(e.price)/e.payment_count).toLocaleString()," each"]})]}):e.deposit!=null?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hi,{className:"h-3.5 w-3.5"}),a.jsxs("span",{children:["Deposit: $",Number(e.deposit).toLocaleString()]}),e.deposit_due_date&&a.jsxs("span",{className:"text-xs",children:["· Due ",Ye(new Date(e.deposit_due_date+"T00:00:00"),"MMM d, yyyy")]})]}):null]})]}),a.jsx(Tue,{experienceId:e.id}),a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Team"}),a.jsxs("div",{className:"space-y-1 mb-3",children:[["project_manager","booking"].map(ue=>{var se;const we=p.find(ge=>ge.role===ue),Ie=ue==="project_manager"?"Project Manager":"Booking";return a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"w-28 shrink-0 text-xs text-muted-foreground",children:Ie}),c?a.jsx(Kt,{value:(we==null?void 0:we.generator_id)??"",onValueChange:ge=>v.mutate({role:ue,generatorId:ge&&ge!=="none"?ge:null}),options:i.map(ge=>({value:ge.id,label:ge.name})),placeholder:ue==="project_manager"?"No PM set":"None",allowNone:!0,className:"flex-1 h-8 text-xs"}):a.jsx("span",{className:Se("text-sm",!we&&"text-muted-foreground italic"),children:((se=i.find(ge=>ge.id===(we==null?void 0:we.generator_id)))==null?void 0:se.name)??(ue==="project_manager"?"No PM set":"None")})]},ue)}),!p.some(ue=>ue.role==="project_manager")&&a.jsx("p",{className:"text-[10px] text-destructive",children:"This experience has no Project Manager."})]}),a.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:["Generators & Guides (",g.length,")"]}),g.length>0&&a.jsxs("div",{className:"flex items-center justify-end text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:[a.jsx("span",{className:"w-8 text-center",title:"Recruits participants (paid recruiting comp)",children:"Gen"}),a.jsx("span",{className:"w-8 text-center",title:"Facilitates on the trip (paid guide comp)",children:"Guide"}),a.jsx("span",{className:"w-6 flex-shrink-0"})]}),a.jsx("div",{className:"space-y-1 mb-2",children:g.map(ue=>{var ge,$e,Ke,Qe;const we=ue.is_generator!==!1,Ie=!!ue.is_host_guide,se=p.filter(He=>He.generator_id===ue.generator_id).map(He=>He.role==="project_manager"?"PM":"Booking");return a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.jsx(Kv,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(ge=ue.generators)==null?void 0:ge.name}),se.map(He=>a.jsx(Ge,{variant:"outline",className:"text-[9px] px-1 py-0 font-normal",children:He},He)),(c||(l==null?void 0:l.id)===ue.generator_id)&&a.jsx(Aue,{canManage:c,experienceId:e.id,experienceName:e.name,experiencePrice:e.price??null,generatorId:ue.generator_id,generatorName:(($e=ue.generators)==null?void 0:$e.name)??"",generatorEmail:(Ke=ue.generators)==null?void 0:Ke.email,showAgreement:((Qe=ue.generators)==null?void 0:Qe.type)==="contractor"})]}),a.jsxs("div",{className:"flex items-center flex-shrink-0",children:[a.jsx("div",{className:"w-8 flex justify-center",children:a.jsx(gt,{checked:we,disabled:!c||we&&!Ie,onCheckedChange:He=>be.mutate({id:ue.id,value:!!He}),title:we&&!Ie?"Generator (a person needs at least one role â remove instead)":"Generator"})}),a.jsx("div",{className:"w-8 flex justify-center",children:a.jsx(gt,{checked:Ie,disabled:!c||Ie&&!we,onCheckedChange:He=>Ue.mutate({id:ue.id,value:!!He,generatorId:ue.generator_id}),title:Ie&&!we?"Guide (a person needs at least one role â remove instead)":"Guide"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>Ne.mutate(ue.id),children:a.jsx(Ht,{className:"h-3 w-3"})})]})]},ue.id)})}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Kt,{value:P,onValueChange:k,options:i.filter(ue=>!oe.has(ue.id)).map(ue=>({value:ue.id,label:ue.name})),placeholder:"Add generatorâ¦",className:"flex-1 h-8 text-xs"}),a.jsx(Y,{size:"sm",className:"h-8 px-2",onClick:()=>ze.mutate(),disabled:!P||P==="none",children:a.jsx(zt,{className:"h-3.5 w-3.5"})})]})]}),a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Contacts (",h.length,")"]}),h.length>0&&a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1.5",onClick:()=>je(!0),title:"Email accepted contacts",children:[a.jsx(fs,{className:"h-3.5 w-3.5"})," Email"]}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1.5",onClick:async()=>{const ue=h.filter(ge=>ge.status==="accepted"),we=ue.map(ge=>{const $e=ge.contacts,Ke=`https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/og-metadata?token=${ge.public_token}`;return`${($e==null?void 0:$e.name)||"Unknown"} ${($e==null?void 0:$e.email)||""} ${Ke}`}),se=await ly(["Name Email Personalized Link",...we].join(` 834`));d(se?{title:`${ue.length} accepted contact links copied to clipboard`}:{title:"Copy blocked by browser",description:"Your browser blocked clipboard access.",variant:"destructive"})},children:[a.jsx(em,{className:"h-3.5 w-3.5"})," Copy All Accepted Links"]})]})]}),a.jsx(Hde,{open:de,onOpenChange:je,experienceId:e.id,experienceName:e.name,contacts:h.map(ue=>{var we,Ie;return{id:ue.id,status:ue.status,name:((we=ue.contacts)==null?void 0:we.name)||"Unnamed",email:((Ie=ue.contacts)==null?void 0:Ie.email)||null}})}),a.jsx(the,{contacts:h,experience:e,companionMap:f,onSetCompanion:(ue,we)=>x.mutate({ceId:ue,companionContactId:we}),onStatusChange:(ue,we)=>rt.mutate({ceId:ue,status:we}),onRemove:ue=>et.mutate(ue),onCustomPriceChange:(ue,we)=>kt.mutate({ceId:ue,price:we}),onDiscountReasonChange:(ue,we)=>jt.mutate({ceId:ue,reason:we}),onScheduleChange:(ue,we,Ie,se)=>Et.mutate({ceId:ue,paymentCount:we,paymentFrequency:Ie,priceDueDate:se}),onCopyPublicLink:async ue=>{if(!ue){d({title:"No personalized link yet",description:"This contact has no link token. Remove and re-add them to the experience.",variant:"destructive"});return}const we=`https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/og-metadata?token=${ue}`,Ie=await ly(we);d(Ie?{title:"Public experience link copied to clipboard"}:{title:"Copy blocked by browser",description:we})},onCreateFollowUp:async(ue,we,Ie)=>{const se=`${Ie.getFullYear()}
834-${String(Ie.getMonth()+1).padStart(2,"0")}-${String(Ie.getDate()).padStart(2,"0")}`,ge=["Follow up on next steps"];ue&&ge.push(`with ${ue}`),ge.push(`for ${e.name}`);const{error:$e}=await F.from("activities").insert({description:ge.join(" "),type:"follow-up",due_date:se,contact_id:we||null,experience_id:e.id,generator_id:(l==null?void 0:l.id)||null});$e?d({title:"Error",description:$e.message,variant:"destructive"}):(d({title:"Follow-up task created"}),u.invalidateQueries({queryKey:["all-activities"]}),u.invalidateQueries({queryKey:["activities"]}))},onEditContact:ue=>Z(ue)}),a.jsx(Ace,{open:!!z,onOpenChange:ue=>{ue||Z(null)},contactId:z,experienceId:e.id}),a.jsxs("div",{className:"flex items-center gap-1 mt-2",children:[a.jsx(Kt,{value:_,onValueChange:S,options:j.filter(ue=>!Q.has(ue.id)).map(ue=>({value:ue.id,label:ue.name})),placeholder:"Add existing contactâ¦",className:"flex-1 h-8 text-xs"}),a.jsx(Y,{size:"sm",className:"h-8 px-2",onClick:()=>Pe.mutate(),disabled:!_||_==="none",children:a.jsx(zt,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{size:"sm",variant:"outline",className:"h-8 px-2 text-xs",onClick:()=>U(!0),children:"Add New"}),a.jsx(Y,{size:"sm",variant:"outline",className:"h-8 px-2 text-xs",onClick:()=>ee(!0),children:"Find Prospects"})]}),a.jsx(Ude,{open:ve,onOpenChange:ee,experience:e,existingContactIds:Q})]}),a.jsx(mde,{experienceId:e.id}),a.jsx(Yce,{experienceId:e.id}),a.jsx(jde,{experienceId:e.id}),a.jsx(Cde,{experienceId:e.id}),e.tracker_enabled&&a.jsx(Ode,{experienceId:e.id,meetingCount:Number(e.tracker_meeting_count)||6}),a.jsxs("div",{className:"border-t border-border pt-3",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Tasks (",N.length,")"]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:async()=>{const{data:ue,error:we}=await F.rpc("apply_default_tasks",{_experience_id:e.id});if(we){d({title:"Error",description:we.message,variant:"destructive"});return}d({title:`Applied ${ue??0} default task${ue===1?"":"s"}`}),u.invalidateQueries({queryKey:["experience-activities",e.id]}),u.invalidateQueries({queryKey:["all-activities"]})},children:[a.jsx(em,{className:"h-3 w-3 mr-1"})," Add Standard Tasks"]}),a.jsxs(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{L(!O),K(null)},children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add"]})]})]}),O&&a.jsxs("div",{className:"mb-3 space-y-1.5 rounded-md border border-border bg-background p-2",children:[a.jsx(ce,{value:C,onChange:ue=>T(ue.target.value),placeholder:"Task description",className:"h-7 text-xs"}),a.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Contact"}),a.jsx(Kt,{options:[{value:"",label:"None"},...j.map(ue=>({value:ue.id,label:ue.name}))],value:E,onValueChange:R,placeholder:"Select",className:"h-7 text-xs"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Generator"}),a.jsx(Kt,{options:[{value:"",label:"None"},...i.map(ue=>({value:ue.id,label:ue.name}))],value:q,onValueChange:I,placeholder:"Select",className:"h-7 text-xs"})]})]}),a.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Due Date"}),a.jsx(ce,{type:"date",value:$,onChange:ue=>M(ue.target.value),className:"h-7 text-xs"})]})}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Notes"}),a.jsx(qt,{value:B,onChange:ue=>W(ue.target.value),rows:2,className:"text-xs",placeholder:"Optional notes"})]}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{L(!1),T(""),R(""),I(""),M(""),W("")},children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>Je.mutate(),disabled:!C.trim()||Je.isPending,children:"Save"})]})]}),N.length>0&&a.jsx("div",{className:"space-y-1 mb-2",children:N.map(ue=>a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-sm cursor-pointer hover:bg-secondary/50 rounded px-1 -mx-1 transition-colors",onClick:()=>
834{A===ue.id?K(null):(K(ue.id),H(ue.description),te(ue.contact_id||""),re(ue.generator_id||""),ye(ue.experience_id||""),he(ue.due_date?ue.due_date.substring(0,10):""),le(ue.notes||""),L(!1))},children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.jsx(Ge,{variant:ue.completed?"secondary":"default",className:"text-[10px] px-1 py-0 flex-shrink-0",children:ue.completed?"Done":"Open"}),a.jsx("span",{className:Se("truncate",ue.completed&&"line-through text-muted-foreground"),children:ue.description}),ue.due_date&&a.jsx("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:(()=>{const we=ue.due_date.substring(0,10),[Ie,se,ge]=we.split("-").map(Number);return Ye(new Date(Ie,se-1,ge),"MMM d")})()})]}),a.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[!ue.completed&&a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-primary flex-shrink-0",title:"Mark Complete",onClick:we=>{we.stopPropagation(),nt.mutate(ue)},children:a.jsx(Mr,{className:"h-3 w-3"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive flex-shrink-0",onClick:we=>{we.stopPropagation(),Ze.mutate(ue.id)},children:a.jsx(Ht,{className:"h-3 w-3"})})]})]}),A===ue.id&&a.jsxs("div",{className:"mt-1 mb-2 space-y-1.5 rounded-md border border-border bg-background p-2 ml-3",children:[a.jsx(ce,{value:G,onChange:we=>H(we.target.value),placeholder:"Description",className:"h-7 text-xs"}),a.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Contact"}),a.jsx(Kt,{options:[{value:"",label:"None"},...j.map(we=>({value:we.id,label:we.name}))],value:fe,onValueChange:te,placeholder:"Select",className:"h-7 text-xs"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Generator"}),a.jsx(Kt,{options:[{value:"",label:"None"},...i.map(we=>({value:we.id,label:we.name}))],value:J,onValueChange:re,placeholder:"Select",className:"h-7 text-xs"})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Experience"}),a.jsx(Kt,{options:[{value:"",label:"None"},...w.map(we=>({value:we.id,label:oo(we.name,we.target_start_date)}))],value:pe,onValueChange:ye,placeholder:"Select",className:"h-7 text-xs"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Due Date"}),a.jsx(ce,{type:"date",value:X,onChange:we=>he(we.target.value),className:"h-7 text-xs"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-[10px] text-muted-foreground",children:"Notes"}),a.jsx(qt,{value:D,onChange:we=>le(we.target.value),rows:2,className:"text-xs"})]}),a.jsxs("div",{className:"flex justify-end gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>K(null),children:"Cancel"}),a.jsx(Y,{size:"sm",className:"h-6 text-xs",onClick:()=>Ae.mutate(ue.id),disabled:!G.trim()||Ae.isPending,children:"Save"})]})]})]},ue.id))})]}),e.type!=="stakeholder_summit"&&a.jsx(Kce,{experienceId:e.id}),a.jsx(Wce,{experienceId:e.id}),a.jsx(pde,{experienceId:e.id}),a.jsx(bde,{experienceId:e.id}),a.jsx(Ade,{experienceId:e.id}),b&&a.jsx(nde,{experienceId:e.id,experiencePrice:e.price,maxSize:e.max_size,restricted:!c,viewerRole:b,viewerGeneratorId:(l==null?void 0:l.id)??null,experienceType:e.type,targetStartDate:e.target_start_date,embeddedTripStartDate:e.embedded_trip_start_date,briefComplete:e.type==="stakeholder_summit"?!0:!!e.brief_complete,priorTripId:e.prior_trip_id??null,location:e.location}),e.type==="stakeholder_summit"&&a.jsx(vce,{summit:e,showFinancials:c}),e.type==="stakeholder_summit"&&a.jsx(Nce,{summitId:e.id,summitDate:e.end_date||e.target_start_date||null,showFinancials:c}),(b==="employee"||b==="project_manager")&&a.jsx(cde,{experienceId:e.id}),(e.type==="trip"||e.type==="peer_group")&&(b==="employee"||b==="project_manager")&&a.jsx(dde,{experienceId:e.id}),(e.type==="trip"||e.type==="peer_group")&&c&&a.jsx(fde,{experienceId:e.id})]}),a.jsx(vk,{open:V,onOpenChange:U,onCreated:async ue=>{try{const{error:we}=await F.from("contact_experiences").insert({contact_id:ue.id,experience_id:e.id});if(we)throw we;
834u.invalidateQueries({queryKey:["experience-contacts",e.id]}),d({title:`${ue.name} added to experience`})}catch(we){d({title:"Error adding to experience",description:we.message,variant:"destructive"})}}})]})}function rhe({open:e,onOpenChange:t,experience:n}){const[r,s]=y.useState(""),[i,o]=y.useState(""),[l,c]=y.useState("trip"),[u,d]=y.useState(""),[h,m]=y.useState(""),[f,x]=y.useState(""),[g,p]=y.useState(""),[v,b]=y.useState(""),[w,N]=y.useState("active"),[j,_]=y.useState(""),[S,P]=y.useState(""),[k,C]=y.useState(""),[T,O]=y.useState(""),[L,E]=y.useState(""),[R,q]=y.useState("10"),[I,$]=y.useState(""),[M,B]=y.useState(null),[W,A]=y.useState(!1),[K,G]=y.useState(!1),[H,fe]=y.useState(""),[te,J]=y.useState(""),[re,pe]=y.useState(""),[ye,X]=y.useState(!1),[he,D]=y.useState(!1),[le,V]=y.useState("6"),[U,z]=y.useState(""),[Z,ve]=y.useState(""),[ee,de]=y.useState(""),[je,Q]=y.useState(""),[oe,Pe]=y.useState(""),[ze,Je]=y.useState(""),[Ae,et]=y.useState(""),[Ne,be]=y.useState(""),[Ue,Ze]=y.useState(!1),nt=at(),{toast:rt}=mt();ps();const{data:kt=[]}=po();y.useEffect(()=>{if(e)if(n){s(n.name),o(n.public_name||""),c(n.type),d(n.activity_type||""),m(n.location||""),x(n.description||""),p(n.target_start_date||""),b(n.end_date||""),N(n.status),_(n.project_manager_id||""),P(n.price!=null?String(n.price):""),C(n.deposit!=null?String(n.deposit):""),O(n.price_due_date||""),E(n.deposit_due_date||""),q(String(n.max_size??10)),$(n.inclusions||""),B(n.cover_image_url||null),fe(n.payment_count!=null?String(n.payment_count):""),J(n.payment_frequency||""),pe(n.audience||""),X(!!n.card_surcharge_enabled),D(!!n.tracker_enabled),V(String(n.tracker_meeting_count??6)),z(n.traveljoy_url||"");const _e=n;ve(_e.trip_type||""),de(_e.activity_level||""),Q(_e.outsourcing_level||""),Pe(_e.price_ceiling_per_participant!=null?String(_e.price_ceiling_per_participant):""),Je(_e.prior_trip_id||""),be(_e.brief_notes||""),Ze(!!_e.brief_complete),et(_e.originating_summit_id||"")}else et(""),s(""),o(""),c("trip"),d(""),m(""),x(""),p(""),b(""),N("active"),_(""),P(""),C(""),O(""),E(""),q("10"),$(""),B(null),fe(""),J(""),pe(""),X(!1),D(!1),V("6"),z(""),ve(""),de(""),Q(""),Pe(""),Je(""),be(""),Ze(!1);Et(!1)},[e,n]);const[jt,Et]=y.useState(!1),{data:Nt}=Qs(),ue=!!(n!=null&&n.class_exported_at)&&!Nt,we=!!r.trim()&&kt.some(_e=>_e.id!==(n==null?void 0:n.id)&&(_e.name||"").trim().toLowerCase()===r.trim().toLowerCase());y.useEffect(()=>{if(!e||n||jt)return;const _e=kt.map(It=>It.cohort_number).filter(It=>typeof It=="number");s(qce({format:l,startDate:g,location:h,nextCohort:(_e.length?Math.max(..._e):0)+1}))},[e,n,jt,l,g,h,kt]);const[Ie,se]=y.useState(!1),[ge,$e]=y.useState(""),[Ke,Qe]=y.useState([]),He=y.useRef(null),Tt=[...B8,...Ke],fn=()=>{const _e=ge.trim();if(!_e)return;const It=_e.toLowerCase().replace(/\s+/g,"_");Tt.some(nn=>nn.value===It)||Qe(nn=>[...nn,{value:It,label:_e}]),d(It),se(!1),$e("")},Xt=Me({mutationFn:async()=>{var It,nn;const _e={name:r.trim(),public_name:i.trim()||null,type:l,activity_type:u||null,location:h.trim()||null,description:f.trim()||null,target_start_date:g||null,end_date:v||null,status:w,price:S?parseFloat(S):null,deposit:k?parseFloat(k):null,price_due_date:T||null,deposit_due_date:L||null,max_size:R?parseInt(R):10,inclusions:I.trim()||null,cover_image_url:M,payment_count:H&&parseInt(H)>=2?parseInt(H):null,payment_frequency:H&&parseInt(H)>=2&&te||null,audience:re||null,card_surcharge_enabled:ye,tracker_enabled:he,tracker_meeting_count:Math.min(12,Math.max(1,parseInt(le)||6)),traveljoy_url:U.trim()||null,trip_type:Z||null,activity_level:ee||null,outsourcing_level:je||null,price_ceiling_per_participant:oe?parseFloat(oe):null,prior_trip_id:ze||null,originating_summit_id:(l==="trip"||l==="peer_group")&&Ae?Ae:null,brief_notes:Ne.trim()||null,brief_complete:Ue};if(n){if((_e.price??null)!==(n.price??null)){const{data:Zt}=await F.from("experience_budget_items").select(qq).eq("experience_id",n.id),{data:Ce}=await F.from("budget_categories").select("name, expects_quote"),{unsourced:ut}=yk(Zt||[],Object.fromEntries((Ce||[]).map(ne=>[ne.name,!!ne.expects_quote])));if(ut.length){const ne=ut.map(Ve=>`⢠${Ve.name}${Ve.description?` â ${Ve.description}`:""}
834: $${Number(Ve.amount||0).toLocaleString()}`).join(` 835`);if(!window.confirm(`The price is set from the budget, but ${ut.length} cost line(s) have no quote or estimate reason: 836 837${ne} 838 839Save the new price anyway?`))throw new Error("Price change cancelled");const{data:qe}=await F.auth.getUser();await F.from("experience_price_acknowledgements").insert({experience_id:n.id,old_price:n.price,new_price:_e.price,unsourced_lines:ut.map(Ve=>({name:Ve.name,description:Ve.description,amount:Ve.amount})),accepted_by:(It=qe.user)==null?void 0:It.id,accepted_by_email:(nn=qe.user)==null?void 0:nn.email})}}const{error:tn}=await F.from("experiences").update(_e).eq("id",n.id);if(tn)throw tn}else{const{data:tn,error:Zt}=await F.from("experiences").insert(_e).select("id").single();if(Zt)throw Zt;if(tn!=null&&tn.id){const{error:Ce}=await F.rpc("apply_default_tasks",{_experience_id:tn.id});Ce&&console.warn("apply_default_tasks failed",Ce)}}},onSuccess:()=>{nt.invalidateQueries({queryKey:["experiences"]}),t(!1),rt({title:n?"Experience updated":"Experience created"})},onError:_e=>rt({title:"Error",description:(_e==null?void 0:_e.code)==="23505"?"That QuickBooks Class is already used by another experience. Class names must be unique.":_e.message,variant:"destructive"})});return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsx(At,{className:"font-display text-xl",children:n?"Trip Brief":"New Experience"})}),a.jsxs("form",{onSubmit:_e=>{_e.preventDefault(),Xt.mutate()},className:"space-y-4",children:[a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{children:"QuickBooks Class *"}),a.jsx(ce,{value:r,onChange:_e=>{s(_e.target.value),Et(!0)},required:!0,maxLength:200,disabled:ue}),ue?a.jsx("p",{className:"text-[10px] text-warning",children:"Locked â this matches a QuickBooks class name and has already been exported. It must not be changed; only admins can edit it."}):a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Must match the QuickBooks class exactly: YYYY-MM Destination (e.g. 2027-09 Dolomites) or YYYY-MM Cohort NN. Must be unique. Not shown to participants."}),r.trim()&&!Fce(r)&&a.jsx("p",{className:"text-[10px] text-destructive",children:"Doesn't follow the convention YYYY-MM followed by a space (months zero-padded)."}),we&&a.jsx("p",{className:"text-[10px] text-destructive",children:`Another experience already uses this. For trips, add " - " and the first Host Guide's surname.`})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{children:"Public Name"}),a.jsx(ce,{value:i,onChange:_e=>o(_e.target.value),maxLength:200,placeholder:"Friendly title shown on participant pages, emails and invoices"}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Shown everywhere people see this experience. Leave blank to fall back to the QuickBooks Class."})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Format"}),a.jsxs(lt,{value:l,onValueChange:c,children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"trip",children:"Trip"}),a.jsx(Oe,{value:"peer_group",children:"Peer Group"}),a.jsx(Oe,{value:"stakeholder_summit",children:"Stakeholder Summit"}),a.jsx(Oe,{value:"custom",children:"Custom"})]})]}),l==="peer_group"&&a.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Cohort ",(n==null?void 0:n.cohort_number)!=null?String(n.cohort_number).padStart(2,"0"):"number assigned automatically on save"," â permanent, never reused."]})]}),(l==="trip"||l==="peer_group")&&a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Originating Summit"}),a.jsx(Kt,{value:Ae,onValueChange:_e=>et(_e==="none"?"":_e),options:kt.filter(_e=>_e.type==="stakeholder_summit").map(_e=>({value:_e.id,label:_e.public_name||_e.name})),placeholder:"Optional â select a summitâ¦",allowNone:!0})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Activity Type"}),Ie?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(ce,{ref:He,value:ge,onChange:_e=>$e(_e.target.value),placeholder:"Enter new typeâ¦",className:"flex-1 h-9 text-sm",maxLength:100,onKeyDown:_e=>{_e.key==="Enter"&&(_e.preventDefault(),fn()),_e.key==="Escape"&&(se(!1),$e(""))}}),a.jsx(Y,{type:"button",size:"sm",className:"h-9 px-2",onClick:fn,disabled:!ge.trim(),children:a.jsx(zt,{className:"h-3.5 w-3.5"})}),a.jsx(Y,{type:"button",variant:"ghost",size:"sm",className:"h-9 px-2",onClick:()=>{se(!1),$e("")},children:a.jsx(Ht,{className:"h-3.5 w-3.5"})})]}):a.jsxs(lt,{value:u||"none",onValueChange:_e=>{_e==="__add_new__"?(se(!0),$e(""),setTimeout(()=>{var It;return(It=He.current)==null?void 0:It.focus()},50)):d(_e==="none"?"":_e)},children:[a.jsx(it,{children:a.jsx(ct,{placeholder:"Selectâ¦"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"none",children:"None"}),Tt.map(_e=>a.jsx(Oe,{value:_e.value,children:_e.label},_e.value)),a.jsx(Oe,{value:"__add_new__",className:"text-primary font-medium",children:"+ Add New"})]})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Status"}),a.jsxs(lt,{value:w,onValueChange:N,children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"active",children:"Active"}),a.jsx(Oe,{value:"completed",children:"Completed"}),a.jsx(Oe,{value:"cancelled",children:"Cancelled"})]})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Location"}),a.jsx(ce,{value:h,onChange:_e=>m(_e.target.value),placeholder:"e.g. Moab, UT",maxLength:200})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Audience"}),a.jsxs(lt,{value:re||"none",onValueChange:_e=>pe(_e==="none"?"":_e),children:[a.jsx(it,{children:a.jsx(ct,{placeholder:"Selectâ¦"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"none",children:"None"}),z8.map(_e=>a.jsx(Oe,{value:_e.value,children:_e.label},_e.value))]})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Start Date"}),a.jsx(ce,{type:"date",value:g,onChange:_e=>p(_e.target.value)})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"End Date"}
839),a.jsx(ce,{type:"date",value:v,onChange:_e=>b(_e.target.value)})]}),l==="stakeholder_summit"?a.jsx("div",{className:"space-y-1.5 sm:col-span-2 rounded-md border border-dashed border-border bg-muted/30 p-3",children:a.jsx("p",{className:"text-xs text-muted-foreground",children:"Summits are complimentary. Use the description to link out to optional hotel reservations, equipment rentals, etc."})}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Price ($)"}),a.jsx(ce,{type:"number",min:"0",step:"0.01",value:S,onChange:_e=>P(_e.target.value),placeholder:"0.00"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:H&&parseInt(H)>=2?"Final Payment Due":"Price Due Date"}),a.jsx(ce,{type:"date",value:T,onChange:_e=>O(_e.target.value)})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Deposit ($)"}),a.jsx(ce,{type:"number",min:"0",step:"0.01",value:k,onChange:_e=>C(_e.target.value),placeholder:"0.00",disabled:!!H&&parseInt(H)>=2}),H&&parseInt(H)>=2&&a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Deposit is replaced by payment schedule"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Deposit Due Date"}),a.jsx(ce,{type:"date",value:L,onChange:_e=>E(_e.target.value),disabled:!!H&&parseInt(H)>=2})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2 border-t border-border pt-3 mt-1",children:[a.jsx(xe,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Payment Schedule"}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Split the total price into equal payments. This replaces the deposit."})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Number of Payments"}),a.jsx(ce,{type:"number",min:"1",max:"24",step:"1",value:H,onChange:_e=>fe(_e.target.value),placeholder:"e.g. 4"}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Leave blank or enter 1 for a single payment (no schedule)."})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Frequency"}),a.jsxs(lt,{value:te||"none",onValueChange:_e=>J(_e==="none"?"":_e),children:[a.jsx(it,{children:a.jsx(ct,{placeholder:"Selectâ¦"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"none",children:"None"}),a.jsx(Oe,{value:"monthly",children:"Monthly"}),a.jsx(Oe,{value:"quarterly",children:"Quarterly"})]})]})]}),(()=>{const _e=H?parseInt(H):0;if(_e<2||!te||!T)return null;const It=S?parseFloat(S):0;if(!It)return null;const nn=Math.round(It/_e),tn=te==="quarterly"?3:1,Zt=new Date(T+"T00:00:00"),Ce=[];for(let ut=0;ut<_e;ut++){const ne=new Date(Zt);ne.setMonth(ne.getMonth()-tn*(_e-1-ut)),Ce.push(ne)}return a.jsxs("div",{className:"sm:col-span-2 rounded-md border border-border bg-muted/30 p-3 space-y-1.5",children:[a.jsx("p",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:"Schedule Preview"}),a.jsx("div",{className:"space-y-1",children:Ce.map((ut,ne)=>a.jsxs("div",{className:"flex items-center justify-between text-xs",children:[a.jsxs("span",{className:"text-muted-foreground",children:["Payment ",ne+1]}),a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:"font-medium",children:["$",nn.toLocaleString()]}),a.jsxs("span",{className:"text-muted-foreground",children:["due ",Ye(ut,"MMM d, yyyy")]})]})]},ne))})]})})()]}),a.jsxs("div",{className:"sm:col-span-2 flex items-start gap-2 pt-1",children:[a.jsx(gt,{id:"card-surcharge-enabled",checked:ye,onCheckedChange:_e=>X(_e===!0),className:"mt-0.5"}),a.jsxs("div",{className:"space-y-0.5",children:[a.jsx(xe,{htmlFor:"card-surcharge-enabled",className:"cursor-pointer",children:"Add 3% card processing fee to online payments"}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Applied to deposit and balance payments made through Stripe. Manual/check payments are unaffected."})]})]}),a.jsxs("div",{className:"sm:col-span-2 flex items-start gap-2 pt-1",children:[a.jsx(gt,{id:"tracker-enabled",checked:he,onCheckedChange:_e=>D(_e===!0),className:"mt-0.5"}),a.jsxs("div",{className:"space-y-1",children:[a.jsx(xe,{htmlFor:"tracker-enabled",className:"cursor-pointer",children:"Enable Peer Group Tracker on personalized pages"}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Accepted participants get a private preparation, meeting/coaching, and expedition tracker with autosave and PDF export."}),he&&a.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[a.jsx(xe,{className:"text-xs",children:"Meetings"}),a.jsx(ce,{type:"number",min:"1",max:"12",step:"1",value:le,onChange:_e=>V(_e.target.value),className:"h-8 w-20"})]})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Goal Size"}),a.jsx(ce,{type:"number",min:"1",step:"1",value:R,onChange:_e=>q(_e.target.value),placeholder:"10"})]}),l!=="stakeholder_summit"&&a.jsxs("div",{className:"sm:col-span-2 rounded-md border border-border p-3 space-y-3",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Trip Brief"}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Destination = Location and target participants = Goal Size above."})]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Trip Type"}),a.jsxs(lt,{value:Z||"none",onValueChange:_e=>ve(_e==="none"?"":_e),children:[a.jsx(it,{children:a.jsx(ct,{placeholder:"Selectâ¦"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"none",children:"â"}),a.jsx(Oe,{value:"custom",children:"Custom"}),a.jsx(Oe,{value:"menu",children:"Menu"})]})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Activity Level"}),a.jsxs(lt,{value:ee||"none",onValueChange:_e=>de(_e==="none"?"":_e),children:[a.jsx(it,{children:a.jsx(ct,{placeholder:"Selectâ¦"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"none",children:"â"}),a.jsx(Oe,{value:"easy",children:"Easy"}),a.jsx(Oe,{value:"moderate",children:"Moderate"}),a.jsx(Oe,{value:"strenuous",children:"Strenuous"})]})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Outsourcing Level"}
839),a.jsxs(lt,{value:je||"none",onValueChange:_e=>Q(_e==="none"?"":_e),children:[a.jsx(it,{children:a.jsx(ct,{placeholder:"Selectâ¦"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"none",children:"â"}),a.jsx(Oe,{value:"full_service",children:"Full-service"}),a.jsx(Oe,{value:"piecemeal",children:"Piecemeal"})]})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Price Ceiling / Participant ($)"}),a.jsx(ce,{type:"text",inputMode:"decimal",value:oe,onChange:_e=>Pe(_e.target.value.replace(/[^0-9.]/g,"")),placeholder:"0.00"})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{children:"Prior Trip (pricing baseline)"}),a.jsx(Kt,{value:ze,onValueChange:_e=>Je(_e==="none"?"":_e),options:kt.filter(_e=>_e.id!==(n==null?void 0:n.id)).map(_e=>({value:_e.id,label:_e.public_name||_e.name})),placeholder:"Optional â select a tripâ¦",allowNone:!0})]}),a.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[a.jsx(xe,{children:"Brief Notes"}),a.jsx(qt,{value:Ne,onChange:_e=>be(_e.target.value),rows:4})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm sm:col-span-2",children:[a.jsx(gt,{checked:Ue,onCheckedChange:_e=>Ze(_e===!0)}),"Brief complete"]})]})]}),a.jsxs("div",{className:"sm:col-span-2 space-y-1.5",children:[a.jsx(xe,{htmlFor:"traveljoy-url",children:"Detailed Trip Information link (Travel Joy)"}),a.jsx(ce,{id:"traveljoy-url",type:"url",value:U,onChange:_e=>z(_e.target.value),placeholder:"https://traveljoy.com/client/â¦"}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:'When set, accepted participants and Gen/Guides see a "Detailed Trip Information" button at the top of their personalized page.'})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(xe,{children:"Description"}),a.jsxs(Y,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs gap-1",disabled:K||!r.trim(),onClick:async()=>{G(!0);try{const{data:_e,error:It}=await F.functions.invoke("generate-experience-description",{body:{name:r,location:h,activityType:u,startDate:g,price:S,deposit:k,maxSize:R,inclusions:I,currentDescription:f}});if(It)throw It;if(_e!=null&&_e.error)throw new Error(_e.error);_e!=null&&_e.description&&x(_e.description),rt({title:"Description generated",description:"Review and edit as needed."})}catch(_e){rt({title:"Generation failed",description:_e.message,variant:"destructive"})}finally{G(!1)}},children:[K?a.jsx(vt,{className:"h-3 w-3 animate-spin"}):a.jsx(Uv,{className:"h-3 w-3"}),K?"Writingâ¦":"AI Write"]})]}),a.jsx(qt,{value:f,onChange:_e=>x(_e.target.value),rows:3,maxLength:2e3})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Inclusions"}),a.jsx(qt,{value:I,onChange:_e=>$(_e.target.value),rows:3,maxLength:3e3,placeholder:"What's included in this experience (shown on public page)"})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Cover Image"}),M?a.jsxs("div",{className:"relative rounded-md overflow-hidden border border-border",children:[a.jsx("img",{src:M,alt:"Cover",className:"w-full h-32 object-cover"}),a.jsxs(Y,{type:"button",variant:"destructive",size:"sm",className:"absolute top-2 right-2 h-7 text-xs",onClick:()=>B(null),children:[a.jsx(Ht,{className:"h-3 w-3 mr-1"})," Remove"]})]}):a.jsxs("div",{children:[a.jsx("input",{type:"file",accept:"image/*",className:"hidden",id:"cover-upload",onChange:async _e=>{var tn;const It=(tn=_e.target.files)==null?void 0:tn[0];if(_e.target.value="",!It)return;const nn=x6(It);if(nn){rt({title:"Can't upload this image",description:nn,variant:"destructive"});return}A(!0);try{const Zt=`${Date.now()}-${Qle(It.name)}`,{error:Ce}=await F.storage.from("experience-covers").upload(Zt,It,{upsert:!1,contentType:It.type||"image/jpeg"});if(Ce)throw Ce;const{data:ut}=F.storage.from("experience-covers").getPublicUrl(Zt);B(ut.publicUrl)}catch(Zt){const Ce=Zt.message||"";rt({title:"Upload failed",description:/no content/i.test(Ce)?"Storage received an empty file. If the photo lives in iCloud or Google Photos, download it to this device first, then try again.":Ce||"Something went wrong uploading the image.",variant:"destructive"})}finally{A(!1)}}}),a.jsx(Y,{type:"button",variant:"outline",size:"sm",className:"text-xs",disabled:W,onClick:()=>{var _e;return(_e=document.getElementById("cover-upload"))==null?void 0:_e.click()},children:W?a.jsxs(a.Fragment,{children:[a.jsx(vt,{className:"h-3 w-3 animate-spin mr-1"})," Uploadingâ¦"]}):a.jsxs(a.Fragment,{children:[a.jsx(ao,{className:"h-3 w-3 mr-1"})," Upload Cover Image"]})}),a.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Recommended: 1200Ã400px or wider. Shown on the public experience page."})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Y,{type:"button",variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),a.jsx(Y,{type:"submit",disabled:Xt.isPending||!r.trim(),children:Xt.isPending?"Savingâ¦":n?"Update":"Create"})]})]})]})})}function ahe({open:e,onOpenChange:t,experience:n}){const[r,s]=y.useState(""),[i,o]=y.useState(!1),[l,c]=y.useState(!0),[u,d]=y.useState(!0),[h,m]=y.useState(!1),[f,x]=y.useState(!0),[g,p]=y.useState(!0),[v,b]=y.useState(!0),[w,N]=y.useState(!0),[j,_]=y.useState(!1),[S,P]=y.useState(!0),[k,C]=y.useState(!0),[T,O]=y.useState(""),L=at(),{toast:E}=mt(),R=()=>{s(n?`${n.name} (Copy)`:""),o(!1),c(!0),d(!0),m(!1),x(!0),p(!0),b(!0),N(!0),_(!1),P(!0),C(!0),O((n==null?void 0:n.target_start_date)??"")},q=Me({mutationFn:async()=>
839{if(!n)return;const I=n.status==="completed",$=n.target_start_date?new Date(n.target_start_date+"T00:00:00"):null,M=T?new Date(T+"T00:00:00"):null,B=$&&M?Math.round((M.getTime()-$.getTime())/(1e3*60*60*24)):0,W=H=>{if(!H||B===0)return H;const fe=new Date(H+"T00:00:00");return fe.setDate(fe.getDate()+B),fe.toISOString().slice(0,10)},A=H=>{if(!H||B===0)return H;const fe=new Date(H);return fe.setDate(fe.getDate()+B),fe.toISOString()},{data:K,error:G}=await F.from("experiences").insert({name:r.trim(),public_name:n.public_name||null,type:n.type,activity_type:n.activity_type,location:n.location,description:n.description,target_start_date:T||n.target_start_date,project_manager_id:n.project_manager_id,price:n.price,deposit:n.deposit,price_due_date:W(n.price_due_date),deposit_due_date:W(n.deposit_due_date),inclusions:n.inclusions,audience:n.audience,max_size:n.max_size,payment_count:n.payment_count,payment_frequency:n.payment_frequency,cover_image_url:n.cover_image_url,planning_notes:n.planning_notes,training_plan:S?n.training_plan:null,trip_type:n.trip_type??null,activity_level:n.activity_level??null,outsourcing_level:n.outsourcing_level??null,price_ceiling_per_participant:n.price_ceiling_per_participant??null,prior_trip_id:I?n.id:n.prior_trip_id??null,brief_notes:n.brief_notes??null,brief_complete:!!n.brief_complete,status:"active"}).select("id").single();if(G)throw G;if(l){const{data:H,error:fe}=await F.from("generator_experiences").select("generator_id").eq("experience_id",n.id);if(fe)throw fe;if(H&&H.length>0){const{error:te}=await F.from("generator_experiences").insert(H.map(J=>({generator_id:J.generator_id,experience_id:K.id})));if(te)throw te}}if(i){const{data:H,error:fe}=await F.from("contact_experiences").select("contact_id, status, notes").eq("experience_id",n.id);if(fe)throw fe;if(H&&H.length>0){const{error:te}=await F.from("contact_experiences").insert(H.map(J=>({contact_id:J.contact_id,experience_id:K.id,status:J.status,notes:J.notes})));if(te)throw te}}if(u){const{data:H,error:fe}=await F.from("activities").select("contact_id, description, type, due_date, generator_id, notes, field_type").eq("experience_id",n.id).eq("field_type","task").is("contact_id",null);if(fe)throw fe;if(H&&H.length>0){const{error:te}=await F.from("activities").insert(H.map(J=>({contact_id:J.contact_id,description:J.description,type:J.type,due_date:A(J.due_date),generator_id:J.generator_id,experience_id:K.id,notes:J.notes,field_type:"task",completed:!1})));if(te)throw te}}if(h){const{data:H,error:fe}=await F.from("contact_experiences").select("contact_id").eq("experience_id",n.id).eq("status","future");if(fe)throw fe;if(H&&H.length>0){const te=new Set;if(i){const{data:re}=await F.from("contact_experiences").select("contact_id").eq("experience_id",K.id);re==null||re.forEach(pe=>te.add(pe.contact_id))}const J=H.filter(re=>!te.has(re.contact_id));if(J.length>0){const{error:re}=await F.from("contact_experiences").insert(J.map(pe=>({contact_id:pe.contact_id,experience_id:K.id,status:"candidate"})));if(re)throw re}}}if(f){const{data:H,error:fe}=await F.from("experience_budget_items").select("name, category, cost_type, amount, currency, includes_generators, generator_count, sort_order, source, description, generator_id, supplier_id, notes, estimate_status, cost_source, source_link, val
839id_until").eq("experience_id",n.id);if(fe)throw fe;if(H&&H.length>0){const{error:re}=await F.from("experience_budget_items").insert(H.map(pe=>({...pe,...I?{valid_until:null}:{},copied_from_experience_id:n.id,experience_id:K.id})));if(re)throw re}const{data:te,error:J}=await F.from("experience_budget_settings").select("override_pax_count, exchange_rate_eur").eq("experience_id",n.id).maybeSingle();if(J)throw J;if(te){const{error:re}=await F.from("experience_budget_settings").upsert({experience_id:K.id,override_pax_count:te.override_pax_count,exchange_rate_eur:te.exchange_rate_eur});if(re)throw re}}if(g){const{data:H,error:fe}=await F.from("experience_dates").select("label, start_date, end_date, all_day, notes, sort_order, is_recurring, recurrence_rule, recurrence_end_date").eq("experience_id",n.id).is("parent_date_id",null);if(fe)throw fe;if(H&&H.length>0){const{error:te}=await F.from("experience_dates").insert(H.map(J=>({experience_id:K.id,label:J.label,start_date:A(J.start_date),end_date:A(J.end_date),all_day:J.all_day,notes:J.notes,sort_order:J.sort_order,is_recurring:J.is_recurring,recurrence_rule:J.recurrence_rule,recurrence_end_date:A(J.recurrence_end_date)})));if(te)throw te}}if(v){const{data:H,error:fe}=await F.from("experience_addons").select("name, description, price").eq("experience_id",n.id);if(fe)throw fe;if(H&&H.length>0){const{error:te}=await F.from("experience_addons").insert(H.map(J=>({experience_id:K.id,name:J.name,description:J.description,price:J.price})));if(te)throw te}}if(w){const{data:H,error:fe}=await F.from("activities").select("description, type, field_type, field_options, required, sort_order, generator_id").eq("experience_id",n.id).eq("type","form-field");if(fe)throw fe;if(H&&H.length>0){const{error:te}=await F.from("activities").insert(H.map(J=>({experience_id:K.id,description:J.description,type:J.type,field_type:J.field_type,field_options:J.field_options,required:J.required,sort_order:J.sort_order,generator_id:J.generator_id})));if(te)throw te}}if(k){const{data:H,error:fe}=await F.from("experience_surveys").select("questions, show_date").eq("experience_id",n.id).maybeSingle();if(fe)throw fe;if(H){const{error:te}=await F.from("experience_surveys").insert({experience_id:K.id,questions:H.questions,show_date:W(H.show_date)});if(te)throw te}}return K},onSuccess:()=>{L.invalidateQueries({queryKey:["experiences"]}),L.invalidateQueries({queryKey:["all-activities"]}),t(!1),E({title:"Experience cloned"})},onError:I=>E({title:"Error",description:I.message,variant:"destructive"})});return a.jsx(Dt,{open:e,onOpenChange:I=>{t(I),I&&R()},children:a.jsxs(Pt,{className:"sm:max-w-sm",children:[a.jsx(Ot,{children:a.jsx(At,{className:"font-display text-xl",children:"Clone Experience"})}),a.jsxs("form",{onSubmit:I=>{I.preventDefault(),q.mutate()},className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"New Name *"}),a.jsx(ce,{value:r,onChange:I=>s(I.target.value),required:!0,maxLength:200})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(xe,{children:"Start Date"}),a.jsx(ce,{type:"date",value:T,onChange:I=>O(I.target.value)}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Dates and due dates will shift relative to this date"})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:l,onCheckedChange:I=>c(!!I)}),"Copy generators"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:g,onCheckedChange:I=>p(!!I)}),"Copy dates (shifted to new start date)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:u,onCheckedChange:I=>d(!!I)}),"Copy general tasks (not contact-specific, as incomplete)"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:w,onCheckedChange:I=>N(!!I)}),"Copy form fields"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:v,onCheckedChange:I=>b(!!I)}),"Copy add-ons"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:f,onCheckedChange:I=>x(!!I)}),"Copy budget",(n==null?void 0:n.status)==="completed"&&a.jsx("span",{className:"text-xs text-muted-foreground",children:'(lines reset to Estimate, source "actual")'})]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:S,onCheckedChange:I=>P(!!I)}),"Copy preparation guide"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:k,onCheckedChange:I=>C(!!I)}),"Copy survey"]}),a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:j,onCheckedChange:I=>_(!!I)}),"Copy resources (files)"]}),a.jsx("div",{className:"border-t border-border pt-2 mt-2",children:a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:i,onCheckedChange:I=>o(!!I)}),"Copy contacts"]})}),a.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer pl-6",children:[a.jsx(gt,{checked:h,onCheckedChange:I=>m(!!I)}),'Add "Future" contacts as candidates']})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Y,{type:"button",variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),a.jsx(Y,{type:"submit",disabled:q.isPending||!r.trim(),children:q.isPending?"Cloningâ¦":"Clone"})]})]})]})})}function Kh({experienceName:e,url:t,ogUrl:n}){const[r,s]=y.useState(!1),[i,o]=y.useState(!1),l=n||t,c=`I thought you'd be interested in ${e} with Four Corners Exploration. Click this link to read more: ${l}`,u=async()=>{try{await navigator.clipboard.writeText(l),s(!0),Mt.success("Link copied to clipboard"),setTimeout(()=>s(!1),2e3)}catch{Mt.error("Failed to copy link")}},d=()=>{const x=encodeURIComponent(`Check out: ${e}`),g=encodeURIComponent(c);window.open(`mailto:?subject=${x}&body=${g}`,"_blank"),o(!1)},h=()=>{const x=encodeURIComponent(c);window.open(`sms:?body=${x}`,"_blank"),o(!1)},m=()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(l)}"e=${encodeURIComponent(c)}`,"_blank","width=600,height=400"),o(!1)},f=()=>{window.open(`https://x.com/intent/tweet?text=${encodeURIComponent(c)}`,"_blank","width=600,height=400"),o(!1)};return a.jsxs(na,{open:i,onOpenChange:o,children:[a.jsx(ra,{asChild:!0,children:a.jsxs(Y,{variant:"outline",size:"sm",className:"gap-2",children:[a.jsx(yH,{className:"h-4 w-4"})," Share"]})}
839),a.jsxs(Kr,{align:"end",className:"w-48 p-1",children:[a.jsxs("button",{onClick:u,className:"flex items-center gap-2 w-full rounded-md px-3 py-2 text-sm hover:bg-accent/10 text-foreground transition-colors",children:[r?a.jsx(On,{className:"h-4 w-4 text-emerald-600"}):a.jsx(Nl,{className:"h-4 w-4"}),r?"Copied!":"Copy Link"]}),a.jsxs("button",{onClick:d,className:"flex items-center gap-2 w-full rounded-md px-3 py-2 text-sm hover:bg-accent/10 text-foreground transition-colors",children:[a.jsx(fs,{className:"h-4 w-4"})," Email"]}),a.jsxs("button",{onClick:h,className:"flex items-center gap-2 w-full rounded-md px-3 py-2 text-sm hover:bg-accent/10 text-foreground transition-colors",children:[a.jsx(L3,{className:"h-4 w-4"})," Text Message"]}),a.jsx("div",{className:"h-px bg-border my-1"}),a.jsxs("button",{onClick:m,className:"flex items-center gap-2 w-full rounded-md px-3 py-2 text-sm hover:bg-accent/10 text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:a.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),"Facebook"]}),a.jsxs("button",{onClick:f,className:"flex items-center gap-2 w-full rounded-md px-3 py-2 text-sm hover:bg-accent/10 text-foreground transition-colors",children:[a.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:a.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),"X (Twitter)"]})]})]})}const she="https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/generate-invoice";function by({token:e,type:t}){const n=`${she}?token=${encodeURIComponent(e)}&type=${t}`;return a.jsxs("a",{href:n,target:"_blank",rel:"noopener",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-accent transition-colors underline-offset-4 hover:underline",title:"Download a PDF invoice to share with your finance or procurement contact",children:[a.jsx(tH,{className:"h-3.5 w-3.5"}),"Download PDF invoice"]})}const Vr=e=>e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0});function ihe({tripPrice:e,invitePct:t,inviteThreshold:n,recruitPct:r,hostGuidePct:s=0,qualityInviteCount:i,recruitedCount:o,avgRecruitPrice:l,currentCredit:c,confirmedRevenue:u=0,hostGuideRevenueBase:d,maxRecruits:h,recruitCapacity:m,className:f}){const x=Number(l)||Number(e)||0,g=Number(d??u)||0,p=m!=null&&m>0?Math.floor(m):null,{ladder:v,compReachable:b,toComp:w}=y.useMemo(()=>{if(x<=0||e<=0)return{ladder:[],compReachable:!0,toComp:0};const P=x*(r/100),k=e*(t/100),C=P>0?Math.ceil(Math.max(0,e-k)/P):0,T=p==null||C<=p;let O=h??Math.max(C+4,10);p!=null&&(O=Math.min(O,p));const L=O>12?Math.ceil(O/8):1,E=$=>p!=null?Math.min($,p):$,R=new Set([0]);for(let $=L;$<=O;$+=L)R.add($);p!=null&&R.add(p),C>0&&T&&R.add(C),o>0&&R.add(E(Math.round(o)));const q={invite_bonus_pct:t,invite_bonus_threshold:n,recruitment_share_pct:r,trip_price_snapshot:e,quality_invite_ids:Array.from({length:Math.max(n,1)},($,M)=>`p${M}`),host_guide_pct:s};return{ladder:[...R].sort(($,M)=>$-M).map($=>{const M=Pb(q,Array.from({length:$},(B,W)=>({contact_experience_id:`s${W}`,effective_price:x,counts_as_recruit:!0})),g);return{n:$,tripOffset:M.tripOffset,cashPayout:M.cashPayout,total:M.totalEarnings,netPrice:e-M.totalEarnings,isCompPoint:T&&$===C,isCurrent:$===E(Math.round(o)),isCapacity:p!=null&&$===p}}),compReachable:T,toComp:C}},[x,e,t,n,r,s,g,o,h,p]),N=e>0?Math.min(100,c/e*100):0,j=n>0?Math.min(100,i/n*100):100,_=n<=0&&t>0,S=_&&t>=100;return a.jsxs("div",{className:f,children:[a.jsxs("div",{className:"rounded-md border bg-muted/20 p-3 space-y-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:[a.jsx(_j,{className:"h-3.5 w-3.5"})," How your compensation works"]}),a.jsxs("ol",{className:"space-y-1.5 text-xs text-muted-foreground list-decimal pl-4",children:[a.jsx("li",{children:S?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-foreground font-medium",children:"Trip fully covered"})," â your"," ",Vr(e)," seat is comped as a Host/Guide, with no invite requirement."]}):_?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-foreground font-medium",children:"Trip credit"})," â ",t,"% of your ",Vr(e)," trip, granted as a Host/Guide with no invite requirement."]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-foreground font-medium",children:"Invite bonus"}
839)," â ",t,"% of your ",Vr(e)," trip once you make ",n," quality invites."]})}),a.jsxs("li",{children:[a.jsx("span",{className:"text-foreground font-medium",children:"Recruiting share"})," â"," ",r,"% of what each person you bring actually pays (",Vr(x*(r/100))," per seat at ",Vr(x),")."]}),a.jsx("li",{children:S?a.jsxs(a.Fragment,{children:["Because your trip is already covered, recruiting credit is"," ",a.jsx("span",{className:"text-foreground font-medium",children:"paid to you in cash"}),"."]}):a.jsxs(a.Fragment,{children:["Credit pays down ",a.jsx("span",{className:"text-foreground font-medium",children:"your trip first"}),"; anything beyond ",Vr(e)," is paid to you in cash."]})}),s>0&&a.jsxs("li",{children:[a.jsx("span",{className:"text-foreground font-medium",children:"Host/Guide fee"})," â ",s,"% of confirmed experience revenue, always paid in cash."]})]})]}),a.jsxs("div",{className:"mt-3 space-y-2",children:[n>0?a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:"Quality invites"}),a.jsxs("span",{className:"tabular-nums",children:[i," / ",n]})]}),a.jsx("div",{className:"mt-1 h-2 rounded-full bg-muted overflow-hidden",children:a.jsx("div",{className:"h-full rounded-full bg-secondary-foreground/40 transition-all",style:{width:`${j}%`}})})]}):a.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:"Quality invites made"}),a.jsxs("span",{className:"tabular-nums",children:[i,a.jsx("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:"no threshold required"})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[a.jsx("span",{className:"text-muted-foreground",children:"Trip covered"}),a.jsxs("span",{className:"tabular-nums",children:[Vr(Math.min(c,e))," of ",Vr(e)]})]}),a.jsx("div",{className:"mt-1 h-2 rounded-full bg-muted overflow-hidden",children:a.jsx("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:`${N}%`}})})]})]}),v.length>0&&a.jsxs("div",{className:"mt-4",children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:[a.jsx(K3,{className:"h-3.5 w-3.5"})," What you'd earn"]}),a.jsx("div",{className:"rounded-md border overflow-hidden",children:a.jsxs("table",{className:"w-full text-xs",children:[a.jsx("thead",{className:"bg-muted/40 text-muted-foreground",children:a.jsxs("tr",{children:[a.jsx("th",{className:"text-left font-medium px-2 py-1.5",children:"Recruits"}),a.jsx("th",{className:"text-right font-medium px-2 py-1.5",children:"Trip offset"}),a.jsx("th",{className:"text-right font-medium px-2 py-1.5",children:"Cash"}),a.jsx("th",{className:"text-right font-medium px-2 py-1.5",children:"Total"}),a.jsx("th",{className:"text-right font-medium px-2 py-1.5",children:"Net price / earnings"})]})}),a.jsx("tbody",{className:"divide-y",children:v.map(P=>a.jsxs("tr",{className:P.isCurrent?"bg-primary/5 font-medium":void 0,children:[a.jsxs("td",{className:"px-2 py-1.5 tabular-nums",children:[P.n,P.isCurrent&&a.jsx("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:"today"}),P.isCompPoint&&!P.isCurrent&&a.jsx("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:"trip comped"}),P.isCapacity&&!P.isCurrent&&!P.isCompPoint&&a.jsx("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:"trip full"})]}),a.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:Vr(P.tripOffset)}),a.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:Vr(P.cashPayout)}),a.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums font-medium",children:Vr(P.total)}),a.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:P.netPrice>0?`${Vr(P.netPrice)} to pay`:P.netPrice<0?`${Vr(-P.netPrice)} earned`:"$0 â even"})]},P.n))})]})}),a.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:["Projection assumes ",Vr(x)," per recruited seat",n>0?" and the invite bonus threshold met":"",p!=null?`, capped at this trip's ${p} recruitable seats`:"",s>0?`, and includes the ${s}% Host/Guide fee on ${Vr(g)} of experience revenue`:"",".",!b&&p!=null?` A full trip comp would take ~${w} recruits, more than the trip can hold.`:""]})]})]})}function ohe({meetingCount:e,entries:t,token:n,postAction:r}){const s=y.useMemo(()=>T8(e),[e]),[i,o]=y.useState(t||{}),[l,c]=y.useState(null),[u,d]=y.useState(null),[h,m]=y.useState(null),[f,x]=y.useState(!1),g=y.useRef({});y.useEffect(()=>{o(t||{})},[t]),y.useEffect(()=>{const N=g.current;return()=>
839Object.values(N).forEach(j=>window.clearTimeout(j))},[]);const p=(N,j)=>{g.current[N]&&window.clearTimeout(g.current[N]),g.current[N]=window.setTimeout(async()=>{d(N);try{await r({action:"save_tracker",block_key:N,values:j}),m(N),window.setTimeout(()=>m(_=>_===N?null:_),2e3)}catch(_){Mt.error((_==null?void 0:_.message)||"Could not save your notes")}finally{d(_=>_===N?null:_)}},900)},v=(N,j,_)=>{o(S=>{const P={...S[N]||{},[j]:_},k={...S,[N]:P};return p(N,P),k})},b=N=>{const j=N.match(/^meeting_(\d+)$/);if(!j)return null;const _=Number(j[1])-1;if(_<1)return null;const S=i[`meeting_${_}`]||{},P=[S.meeting_commitments,S.coaching_commitments].filter(k=>(k||"").trim().length>0);return P.length===0?null:{prev:_,items:P}},w=async()=>{x(!0);try{const N=`https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/generate-tracker-pdf?token=${encodeURIComponent(n)}`,j=await fetch(N);if(!j.ok)throw new Error((await j.json().catch(()=>({}))).error||"Download failed");const _=await j.blob(),S=URL.createObjectURL(_),P=document.createElement("a");P.href=S,P.download="peer-group-tracker.pdf",document.body.appendChild(P),P.click(),P.remove(),URL.revokeObjectURL(S)}catch(N){Mt.error((N==null?void 0:N.message)||"Download failed")}finally{x(!1)}};return a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground flex items-center gap-2",children:[a.jsx(F3,{className:"h-5 w-5 text-accent"})," My Tracker"]}),a.jsxs(Y,{variant:"outline",size:"sm",className:"gap-2",onClick:w,disabled:f,children:[f?a.jsx(vt,{className:"h-4 w-4 animate-spin"}):a.jsx(ja,{className:"h-4 w-4"}),"Download my tracker"]})]}),a.jsxs("div",{className:"rounded-lg border border-border bg-card p-5 space-y-2",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:"Your preparation, insights, and commitments â saved automatically as you write. Visible to you, your coach, and the Four Corners team."}),s.map(N=>{const j=i[N.key]||{},{filled:_,total:S}=O1(j,N),P=l===N.key,k=b(N.key);return a.jsxs("div",{className:"rounded-md border border-border",children:[a.jsxs("button",{type:"button",onClick:()=>c(P?null:N.key),className:"w-full flex items-center justify-between gap-3 px-4 py-3 text-left",children:[a.jsx("span",{className:"font-medium text-foreground",children:N.title}),a.jsxs("span",{className:"flex items-center gap-2",children:[u===N.key&&a.jsx(vt,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),h===N.key&&a.jsx(On,{className:"h-3.5 w-3.5 text-accent"}),a.jsxs(Ge,{variant:_===S?"default":"secondary",className:"text-[10px]",children:[_,"/",S]}),P?a.jsx(_r,{className:"h-4 w-4 text-muted-foreground"}):a.jsx(_n,{className:"h-4 w-4 text-muted-foreground"})]})]}),P&&a.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[N.subtitle&&a.jsx("p",{className:"text-xs text-muted-foreground",children:N.subtitle}),k&&a.jsxs("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:[a.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-1",children:["Commitments from Meeting ",k.prev]}),k.items.map((C,T)=>a.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:C},T))]}),N.fields.map(C=>a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"text-sm font-medium text-foreground",children:C.label}),C.hint&&a.jsx("p",{className:"text-xs text-muted-foreground",children:C.hint}),a.jsx(qt,{value:j[C.key]||"",onChange:T=>v(N.key,C.key,T.target.value),className:"min-h-[90px] text-sm",placeholder:"Write hereâ¦"})]},C.key))]})]},N.key)})]})]})}const Bw=rb.url;function PA({notes:e,description:t}){const[n,r]=y.useState(!1);return a.jsxs("div",{className:"mt-1",children:[a.jsx("button",{type:"button",onClick:()=>r(s=>!s),className:"text-xs text-primary hover:underline",children:n?"Hide notes & agenda":"View notes & agenda"}),n&&a.jsxs("div",{className:"mt-1 rounded border border-border bg-muted/40 p-2 space-y-1.5",children:[t&&a.jsxs("div",{children:[a.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted-foreground font-medium",children:"Agenda"}
839),a.jsx("p",{className:"text-xs text-foreground/80 whitespace-pre-line",children:t})]}),e&&a.jsxs("div",{children:[a.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted-foreground font-medium",children:"Notes"}),a.jsx("p",{className:"text-xs text-foreground/80 whitespace-pre-line",children:e})]})]})]})}const OA={candidate:{label:"Pending",color:"bg-muted text-muted-foreground"},expressed_interest:{label:"Interest Submitted",color:"bg-sky-100 text-sky-800"},invited:{label:"Invited",color:"bg-secondary text-secondary-foreground"},considering:{label:"Considering",color:"bg-amber-100 text-amber-800"},accepted:{label:"Accepted",color:"bg-emerald-100 text-emerald-800"},gen_guide:{label:"Accepted",color:"bg-emerald-100 text-emerald-800"},declined:{label:"Declined",color:"bg-red-100 text-red-800"},dropped:{label:"Dropped",color:"bg-slate-200 text-slate-700"},future:{label:"Future",color:"bg-blue-100 text-blue-800"}};function kr(e){return e==="accepted"||e==="gen_guide"}const AA={hiking:"Hiking",skiing:"Skiing",mountain_biking:"Mountain Biking",pilgrimage:"Pilgrimage",paddling:"Paddling"};function lhe({invitedGuest:e,postAction:t,onChanged:n}){const[r,s]=y.useState("search"),[i,o]=y.useState(""),[l,c]=y.useState([]),[u,d]=y.useState(!1),[h,m]=y.useState(""),[f,x]=y.useState(""),[g,p]=y.useState(!1),[v,b]=y.useState(!1);y.useEffect(()=>{if(r!=="search"||i.trim().length<2){c([]);return}let j=!1;d(!0);const _=setTimeout(async()=>{try{const S=await t({action:"search_contacts",q:i.trim()});j||c((S==null?void 0:S.results)||[])}catch{j||c([])}finally{j||d(!1)}},250);return()=>{j=!0,clearTimeout(_)}},[i,r,t]);const w=async j=>{p(!0);try{await t({action:"attach_companion",...j}),nc({title:"Guest added"}),o(""),c([]),m(""),x(""),n()}catch(_){nc({title:"Could not add guest",description:(_==null?void 0:_.message)||"Try again",variant:"destructive"})}finally{p(!1)}},N=async()=>{b(!0);try{await t({action:"remove_companion"}),nc({title:"Guest removed"}),n()}catch(j){nc({title:"Could not remove guest",description:(j==null?void 0:j.message)||"Try again",variant:"destructive"})}finally{b(!1)}};return a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(dx,{className:"h-5 w-5 text-accent"})," Bringing a Guest?"]}),a.jsx("div",{className:"rounded-lg border border-border bg-card p-5 space-y-4",children:e?a.jsxs("div",{className:"flex items-center justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:"You've added:"}),a.jsx("p",{className:"text-base font-medium text-foreground truncate",children:e.name}),e.email&&a.jsx("p",{className:"text-xs text-muted-foreground truncate",children:e.email})]}),a.jsxs(Y,{variant:"outline",size:"sm",disabled:v,onClick:N,children:[v?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-1"}):a.jsx(Ht,{className:"h-4 w-4 mr-1"}),"Remove"]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:"Spouses and plus-ones are welcome. Look up an existing contact or add someone new."}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Y,{type:"button",variant:r==="search"?"default":"outline",size:"sm",onClick:()=>s("search"),children:[a.jsx(Bv,{className:"h-4 w-4 mr-1"})," Find existing"]}),a.jsxs(Y,{type:"button",variant:r==="new"?"default":"outline",size:"sm",onClick:()=>s("new"),children:[a.jsx(dx,{className:"h-4 w-4 mr-1"})," Add new"]})]}),r==="search"?a.jsxs("div",{className:"space-y-2",children:[a.jsx(ce,{placeholder:"Search by name or emailâ¦",value:i,onChange:j=>o(j.target.value)}),u&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Searchingâ¦"}),!u&&i.trim().length>=2&&l.length===0&&a.jsx("p",{className:"text-xs text-muted-foreground",children:'No matches. Try "Add new" instead.'}),a.jsx("div",{className:"space-y-1",children:l.map(j=>a.jsxs("button",{type:"button",disabled:g,onClick:()=>w({contact_id:j.id}),className:"flex w-full items-center justify-between rounded-md border border-border bg-background px-3 py-2 text-left hover:bg-muted/40 disabled:opacity-50",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:j.name}),j.email&&a.jsx("p",{className:"text-xs text-muted-foreground truncate",children:j.email})]}),a.jsx("span",{className:"text-xs text-primary",children:"Invite"})]},j.id))})]}):a.jsxs("div",{className:"space-y-2",children:[a.jsx(ce,{placeholder:"Guest name *",value:h,onChange:j=>m(j.target.value)}),a.jsx(ce,{type:"email",placeholder:"Guest email (optional)",value:f,onChange:j=>x(j.target.value)}),a.jsxs(Y,{size:"sm",disabled:!h.trim()||g,onClick:()=>w({name:h.trim(),email:f.trim()}),children:[g?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-1"}):a.jsx(dx,{className:"h-4 w-4 mr-1"}),"Add Guest"]})]})]})})]})}function che(){var we,Ie;const[e]=El(),t=e.get("token"),n=e.get("experienceId"),r=e.get("payment_success"),[s,i]=y.useState(null),[o,l]=y.useState(!0),[c,u]=y.useState(null),[d,h]=y.useState(!1);y.useState(null);const[m,f]=y.useState(null),[x,g]=y.useState(null),[p,v]=y.useState(null),[b,w]=y.useState({}),[N,j]=y.useState(null),[_,S]=y.useState(null),[P,k]=y.useState(!1),[C,T]=y.useState(null),O=y.useRef({}),[L,E]=y.useState(!1),[R,q]=y.useState(""),[I,$]=y.useState(""),[M,B]=y.useState(!1),[W,A]=y.useState(!1),[K,G]=y.useState({}),[H,fe]=y.useState(!1),[te,J]=y.useState(!1),re="https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/public-experience",pe="https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/create-experience-payment",ye="https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/verify-experience-payment",X=async()=>
839{if(!t&&!n){u("Missing access token."),l(!1);return}try{const se=t?`token=${t}`:`experienceId=${n}`,ge=await fetch(`${re}?${se}`,{headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM"}});if(!ge.ok){const $e=await ge.json().catch(()=>({}));throw new Error($e.error||"Failed to load experience")}i(await ge.json())}catch(se){u(se.message)}finally{l(!1)}};y.useEffect(()=>{X()},[t,n]),y.useEffect(()=>{!r||!t||P||(k(!0),fetch(ye,{method:"POST",headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM","Content-Type":"application/json"},body:JSON.stringify({token:t,payment_type:r})}).then(se=>se.json()).then(()=>{X(),T(r);const se=new URL(window.location.href);se.searchParams.delete("payment_success"),window.history.replaceState({},"",se.toString())}).catch(()=>{}).finally(()=>k(!1)))},[r,t]);const he=async se=>{if(t){S(se);try{const $e=await(await fetch(pe,{method:"POST",headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM","Content-Type":"application/json"},body:JSON.stringify({token:t,payment_type:se})})).json();$e.url&&(window.location.href=$e.url)}catch{}finally{S(null)}}},D=y.useCallback(async se=>{if(!t)return;const ge=await fetch(`${re}?token=${t}`,{method:"POST",headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM","Content-Type":"application/json"},body:JSON.stringify(se)});if(!ge.ok)throw new Error("Failed to update");return ge.json()},[t,re]),le=async se=>{if(!t){nc({title:"Personalized link required",description:"This action needs your personal invitation link. Please use the link from your invitation email, or contact us for a fresh link.",variant:"destructive"});return}h(!0);try{await D({action:"update_status",status:se}),i(ge=>ge&&ge.contactExperience?{...ge,contactExperience:{...ge.contactExperience,status:se}}:ge)}catch{nc({title:"Couldn't save your response",description:"Please check your connection and try again. If the problem continues, contact us and we'll update it for you.",variant:"destructive"})}finally{h(!1)}},V=async(se,ge)=>{f(se);try{await D({action:"toggle_addon",addon_id:se,selected:ge}),i($e=>$e&&{...$e,selectedAddonIds:ge?[...$e.selectedAddonIds,se]:$e.selectedAddonIds.filter(Ke=>Ke!==se)})}catch{}finally{f(null)}},U=async(se,ge,$e)=>{g(se);try{await D({action:"submit_response",activity_id:se,response_text:ge,response_bool:$e}),w(Ke=>({...Ke,[se]:{...Ke[se],response_text:ge,response_bool:$e,responded_at:new Date().toISOString()}}))}catch{}finally{g(null)}},z=async(se,ge)=>{if(t){v(se);try{const $e=new FormData;$e.append("file",ge),$e.append("activity_id",se);const Ke=await fetch(`${re}?token=${t}`,{method:"POST",headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM"},body:$e});if(!Ke.ok)throw new Error("Upload failed");const Qe=await Ke.json();w(He=>({...He,[se]:{...He[se],response_file_name:Qe.file_name,response_file_path:Qe.file_path,response_file_url:Qe.file_url,responded_at:new Date().toISOString()}}))}catch{}finally{v(null)}}};if(o)return a.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:a.jsx(vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(c||!s)return a.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:a.jsxs("div",{className:"text-center max-w-md",children:[a.jsx("img",{src:Bw,alt:"Four Corners",className:"h-16 mx-auto mb-6"}),a.jsx("h1",{className:"text-2xl font-display font-semibold text-foreground mb-2",children:"Link Not Found"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:c||"This experience link is invali
839d or has expired."})]})});const{experience:Z,contact:ve,contactExperience:ee,activities:de}=s,je=!!s.general,Q=s.formFields||[],oe=s.responses||[],Pe=s.addons||[],ze=s.selectedAddonIds||[],Je=s.dates||[],Ae=s.survey||null,et=s.surveyResponse||null;ee&&(OA[ee.status]||OA.candidate);const Ne=Pe.filter(se=>ze.includes(se.id)&&!se.third_party_payer).reduce((se,ge)=>se+Number(ge.price),0),be=se=>{var $e;if(b[se])return b[se];const ge=oe.find(Ke=>Ke.activity_id===se);if(ge)return ge;if(ve){const Ke=Q.find(He=>He.id===se),Qe=($e=Ke==null?void 0:Ke.field_options)==null?void 0:$e.contact_field;if(Qe&&ve[Qe])return{id:"",activity_id:se,response_text:String(ve[Qe]),response_file_path:null,response_file_name:null,response_file_url:null,response_bool:null,responded_at:""}}},Ue=`https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/calendar-feed/${Z.id}.ics`,Ze=async()=>{const se=R.trim(),ge=I.trim().toLowerCase();if(!(!se||!ge)&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(ge)){B(!0);try{if(!(await fetch(`${re}?experienceId=${n}`,{method:"POST",headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM","Content-Type":"application/json"},body:JSON.stringify({action:"express_interest",name:se,email:ge})})).ok)throw new Error("Failed");A(!0)}catch{}finally{B(!1)}}},nt=a.jsx(Y,{onClick:()=>E(!0),disabled:W,className:"gap-2",children:W?a.jsxs(a.Fragment,{children:[a.jsx(On,{className:"h-4 w-4"})," Interest Submitted"]}):a.jsx(a.Fragment,{children:"Express Interest"})}),rt=(se="top")=>{var He;if(!ee)return null;const ge=`${window.location.origin}/experience?experienceId=${Z.id}`,$e=`https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/og-metadata?experienceId=${Z.id}`,Ke=Z.type==="stakeholder_summit",Qe=!!((He=s.capacity)!=null&&He.isFull)&&!Ke;return!kr(ee.status)&&ee.status!=="declined"&&ee.status!=="future"&&ee.status!=="waitlist"?a.jsxs("section",{className:"flex flex-wrap items-center gap-3",children:[Qe?a.jsxs(Y,{onClick:()=>le("waitlist"),disabled:d,className:"bg-amber-600 hover:bg-amber-700 text-white",children:[d?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-2"}):a.jsx(Mr,{className:"h-4 w-4 mr-2"}),"Join Waitlist"]}):a.jsxs(Y,{onClick:()=>le("accepted"),disabled:d,className:"bg-emerald-600 hover:bg-emerald-700 text-white",children:[d?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-2"}):a.jsx(Mr,{className:"h-4 w-4 mr-2"}),Ke?"RSVP Yes":"Accept Invitation"]}),!Ke&&a.jsxs(Y,{variant:"outline",onClick:()=>le("considering"),disabled:d,children:[a.jsx(JK,{className:"h-4 w-4 mr-2"})," I'm Considering"]}),!Ke&&a.jsxs(Y,{variant:"outline",onClick:()=>le("future"),disabled:d,className:"border-border hover:bg-accent/10",children:[a.jsx(jj,{className:"h-4 w-4 mr-2"})," Not This Time, But Next Time!"]}),a.jsxs(Y,{variant:"outline",onClick:()=>le("declined"),disabled:d,className:"text-destructive border-destructive/30 hover:bg-destructive/10",children:[a.jsx(A3,{className:"h-4 w-4 mr-2"})," Decline"]}),!Ke&&a.jsx("div",{className:"ml-auto",children:a.jsx(Kh,{experienceName:Z.public_name||Z.name,url:ge,ogUrl:$e})})]}):Ae&&kr(ee.status)?se==="top"?null:a.jsx("section",{className:"flex items-center justify-center",children:!Ke&&a.jsx(Kh,{experienceName:Z.public_name||Z.name,url:ge,ogUrl:$e})}):a.jsxs("section",{className:"rounded-lg border border-border bg-card p-4 flex items-center justify-between gap-3",children:[a.jsxs("p",{className:"text-sm text-foreground",children:[kr(ee.status)&&a.jsxs(a.Fragment,{children:["You have ",a.jsx("strong",{children:"accepted"})," this experience."]}),ee.status==="declined"&&a.jsxs(a.Fragment,{children:["You have ",a.jsx("strong",{children:"declined"})," this experience.",a.jsx(Y,{variant:"link",className:"ml-1 p-0 h-auto text-sm",onClick:()=>le("considering"),children:"Changed your mind?"})]}),ee.status==="future"&&a.jsxs(a.Fragment,{children:["You've indicated you'd like to join a ",a.jsx("strong",{children:"future"})," experience like this one. We'll be in touch!",a.jsx(Y,{variant:"link",className:"ml-1 p-0 h-auto text-sm",onClick:()=>le("considering"),children:"Changed your mind?"})]}),ee.status==="waitlist"&&a.jsxs(a.Fragment,{children:["This experience is full and you're on the ",a.jsx("strong",{children:"waitlist"}),". We'll be in touch if a spot opens up."]})]}),!Ke&&a.jsx(Kh,{experienceName:Z.public_name||Z.name,url:ge,ogUrl:$e})]})},kt=(ee==null?void 0:ee.custom_price)??Z.price,Et=((s.generatorComp?s.generatorComp.netPrice:kt)||0)+Ne-((ee==null?void 0:ee.amount_paid)||0)>.005,Nt=Z.type!=="stakeholder_summit"&&(Z.price!=null||Z.deposit!=null)&&(()=>{const se=s.generatorComp||null,ge=(ee==null?void 0:ee.custom_price)??Z.price,$e=se?se.netPrice:ge,Ke=(ee==null?void 0:ee.amount_paid)||0,Qe=($e||0)+Ne,He=Qe-Ke,Tt=($e||0)===0,fn=se?a.jsxs("div",{className:"rounded-lg border border-border bg-card p-5 mb-4",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Team Compensation Credit"}),a.jsxs("div",{className:"space-y-1.5 text-sm",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-muted-foreground",children:"Trip price"}),a.jsxs("span",{className:"font-medium text-foreground",children:["$",se.listPrice.toLocaleStr
839ing()]})]}),se.inviteCredit>0&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-muted-foreground",children:se.invite_bonus_threshold>0?`Invite bonus (${se.invite_bonus_pct}% · ${se.qualityInviteCount} quality invites)`:se.invite_bonus_pct>=100?"Trip covered as Host/Guide":`Trip credit (${se.invite_bonus_pct}%, Host/Guide)`}),a.jsxs("span",{className:"font-medium text-foreground",children:["â $",se.inviteCredit.toLocaleString()]})]}),se.recruitmentCredit>0&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-muted-foreground",children:["Recruiting share (",se.recruitment_share_pct,"% of ",se.recruitedCount," registration",se.recruitedCount===1?"":"s",")"]}),a.jsxs("span",{className:"font-medium text-foreground",children:["â $",se.recruitmentCredit.toLocaleString()]})]}),se.totalCredit===0&&a.jsx("p",{className:"text-muted-foreground",children:"No credit earned yet â credits apply as your invites register."}),a.jsxs("div",{className:"flex items-center justify-between pt-2 mt-1 border-t border-border",children:[a.jsx("span",{className:"font-medium text-foreground",children:"Your net trip cost"}),a.jsxs("span",{className:"font-semibold text-foreground",children:["$",se.netPrice.toLocaleString()]})]}),(se.hostGuideFee??0)>0&&a.jsxs("div",{className:"flex items-center justify-between pt-2 mt-1 border-t border-border",children:[a.jsxs("span",{className:"text-muted-foreground",children:["Host/Guide fee (",se.host_guide_pct,"% of experience revenue)"]}),a.jsxs("span",{className:"font-medium text-foreground",children:["$",(se.hostGuideFee??0).toLocaleString()]})]}),se.cashPayout>0&&a.jsxs("p",{className:"text-xs text-muted-foreground pt-1",children:["$",se.cashPayout.toLocaleString()," will be paid out to you separately â it does not reduce any balance shown below."]}),se.netPrice>0&&a.jsx("p",{className:"text-xs text-muted-foreground pt-1",children:"Credits update as your invites register. Any remaining balance below reflects your credit to date and can be paid online or by check."})]}),a.jsx(ihe,{className:"mt-4",tripPrice:Number(se.listPrice)||0,invitePct:Number(se.invite_bonus_pct)||0,inviteThreshold:Number(se.invite_bonus_threshold)||0,recruitPct:Number(se.recruitment_share_pct)||0,hostGuidePct:Number(se.host_guide_pct)||0,qualityInviteCount:Number(se.qualityInviteCount)||0,recruitedCount:Number(se.recruitedCount)||0,avgRecruitPrice:Number(se.listPrice)||0,currentCredit:Number(se.totalCredit)||0,recruitCapacity:se.recruitCapacity??null})]}):null;if(se&&He<=0)return a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground flex items-center gap-2 mb-3",children:[a.jsx(pa,{className:"h-5 w-5 text-accent"})," Pricing & Payment"]}),fn,a.jsxs("div",{className:"rounded-lg border border-border bg-card p-5",children:[a.jsx(Ge,{className:"bg-emerald-100 text-emerald-800 border-0 text-xs",children:"Covered"}),a.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Nothing is due from you â your participation is covered by your Team compensation agreement."})]})]});const Xt=(ee==null?void 0:ee.payment_count)??Z.payment_count,_e=(ee==null?void 0:ee.payment_frequency)??Z.payment_frequency,It=Xt!=null&&Xt>=2,nn=()=>{if(!It||!$e)return[];const tn=Xt,Zt=$e+Ne,Ce=tn,ut=Zt,ne=Ce>0?Math.round(ut/Ce):0,qe=[],Ve=(ee==null?void 0:ee.price_due_date)??Z.price_due_date,Lt=_e??Z.payment_frequency;let nr=0;for(let Nn=0;Nn<tn;Nn++){let gr,Ha=!1;gr=Nn===Ce-1?ut-ne*(Ce-1):ne;let vs=null;if(Ve){const Zc=Nn,Kp=new Date(Ve+"T00:00:00"),Hp=Lt==="quarterly"?(Ce-1-Zc)*3:Ce-1-Zc,Eh=new Date(Kp);Eh.setMonth(Eh.getMonth()-Hp),vs=Ye(Eh,"yyyy-MM-dd")}const ei=nr;nr+=gr;const Il=Ke+.005>=nr,C0=Il?0:Math.max(0,nr-Math.max(Ke,ei));qe.push({number:Nn+1,amount:gr,remainingAmount:C0,dueDate:vs,paid:Il,isDeposit:Ha})}return qe};if(It){const tn=nn(),Zt=tn.find(Ce=>!Ce.paid);return a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground flex items-center gap-2",children:[a.jsx(pa,{className:"h-5 w-5 text-accent"})," Payment Schedule"]}),ee&&t&&kr(ee.status)&&a.jsx(by,{token:t,type:"experience"})]}),fn,a.jsxs("div",{className:"rounded-lg border border-border bg-card p-5",children:[ee&&kr(ee.status)&&Zt&&a.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border bg-muted/40 p-3 mb-3",children:[a.jsx(fs,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Please help us avoid credit card fees by mailing a check to Four Corners at PO Box 24321, Edina, MN 55424."})]}),a.jsx("div",{className:"space-y-2",children:tn.map(Ce=>a.jsxs("div",{className:`flex items-center justify-between py-2 px-3 rounded-md ${Ce.paid?"bg-muted/50":Ce.number===(Zt==null?void 0:Zt.number)?"bg-primary/5 border border-primary/20":""}`,children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-sm font-medium text-foreground",children:Ce.isDeposit?"Deposit":`Payment ${Ce.number}`}),Ce.dueDate&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["Due ",Ye(new Date(Ce.dueDate+"T00:00:00"),"MMM d, yyyy")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"text-sm font-semibold text-foreground",children:["$",(Ce.number===(Zt==null?void 0:Zt.number)?Ce.remainingAmou
839nt:Ce.amount).toLocaleString()]}),Ce.paid?a.jsx(Ge,{className:"bg-emerald-100 text-emerald-800 border-0 text-xs",children:"Paid"}):ee&&kr(ee.status)&&Ce.number===(Zt==null?void 0:Zt.number)?a.jsxs(Y,{size:"sm",onClick:()=>he("balance"),disabled:_!==null,children:[_==="balance"?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-2"}):a.jsx(pa,{className:"h-4 w-4 mr-2"}),"Pay Now"]}):a.jsx("span",{className:"text-xs text-muted-foreground",children:"Upcoming"})]})]},Ce.number))}),Ne>0&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-border flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Add-Ons Total (included above)"}),a.jsxs("span",{className:"font-medium text-foreground",children:["+ $",Ne.toLocaleString()]})]}),Ke>0&&a.jsxs("div",{className:"mt-2 flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Total Paid"}),a.jsxs("span",{className:"font-medium text-foreground",children:["$",Ke.toLocaleString()]})]}),He>0&&Ke>0&&a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Remaining"}),a.jsxs("span",{className:"font-medium text-foreground",children:["$",He.toLocaleString()]})]}),ee&&kr(ee.status)&&He>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-border flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[a.jsxs("div",{className:"text-sm text-muted-foreground",children:["Prefer to pay the full remaining balance now?",Z.card_surcharge_enabled&&a.jsxs("span",{className:"block text-xs mt-0.5",children:["A 3% card processing fee ($",(He*.03).toLocaleString(void 0,{maximumFractionDigits:2}),") will be added at checkout."]})]}),a.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>he("full_balance"),disabled:_!==null,children:[_==="full_balance"?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-2"}):a.jsx(pa,{className:"h-4 w-4 mr-2"}),"Pay Remaining $",He.toLocaleString()]})]})]})]})}return a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground flex items-center gap-2",children:[a.jsx(pa,{className:"h-5 w-5 text-accent"})," Pricing & Payment"]}),ee&&t&&kr(ee.status)&&a.jsx(by,{token:t,type:"experience"})]}),fn,a.jsxs("div",{className:"rounded-lg border border-border bg-card p-5",children:[(()=>{const tn=Z.deposit!=null&&!se&&!Tt;return a.jsxs("div",{className:`grid gap-4 ${tn?"sm:grid-cols-2":""}`,children:[tn&&(()=>{const Zt=$e!=null&&$e<Number(Z.deposit)?$e:Number(Z.deposit);return a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Deposit"}),a.jsxs("p",{className:"text-lg font-semibold text-foreground",children:["$",Zt.toLocaleString()]}),((ee==null?void 0:ee.accepted_at)||Z.deposit_due_date)&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Due by ",Ye(ee!=null&&ee.accepted_at?new Date(ee.accepted_at):new Date(Z.deposit_due_date+"T00:00:00"),"MMMM d, yyyy")]}),ee!=null&&ee.deposit_paid?a.jsx(Ge,{className:"bg-emerald-100 text-emerald-800 border-0 text-xs mt-1",children:"Paid"}):ee&&kr(ee.status)?a.jsxs(Y,{size:"sm",className:"mt-2",onClick:()=>he("deposit"),disabled:_!==null,children:[_==="deposit"?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-2"}):a.jsx(pa,{className:"h-4 w-4 mr-2"}),"Pay Deposit"]}):null]})})(),$e!=null&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:se?"Net Trip Cost":"Base Price"}),a.jsxs("p",{className:"text-lg font-semibold text-foreground",children:["$",Number($e).toLocaleString()]}),!Tt&&((ee==null?void 0:ee.price_due_date)||Z.price_due_date)&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Due by ",Ye(new Date(((ee==null?void 0:ee.price_due_date)||Z.price_due_date)+"T00:00:00"),"MMMM d, yyyy")]}),ee!=null&&ee.price_paid?a.jsx(Ge,{className:"bg-emerald-100 text-emerald-800 border-0 text-xs mt-1",children:"Paid in Full"}):ee&&kr(ee.status)&&He>0?a.jsxs(Y,{size:"sm",variant:"outline",className:"mt-2",onClick:()=>he("balance"),disabled:_!==null,children:[_==="balance"?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-2"}):a.jsx(pa,{className:"h-4 w-4 mr-2"}),"Pay Balance"]}):null]})]})})(),ee&&kr(ee.status)&&(!ee.deposit_paid&&Z.deposit!=null&&!se&&!Tt||!ee.price_paid&&$e!=null&&!Tt)&&a.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border bg-muted/40 p-3 mt-3",children:[a.jsx(fs,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:Z.card_surcharge_enabled?"A 3% card processing fee will be added at checkout. To avoid this fee, mail a check to Four Corners at PO Box 24321, Edina, MN 55424.":"Please help us avoid credit card fees by mailing a check to Four Corners at PO Box 24321, Edina, MN 55424."})]}),Ne>0&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-border flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Add-Ons Total"}),a.jsxs("span",{className:"font-medium text-foreground",children:["+ $",Ne.toLocaleStr
839ing()]})]}),($e!=null||Ne>0)&&a.jsxs("div",{className:`${Ne>0?"":"mt-3 pt-3 border-t border-border"} flex items-center justify-between text-sm`,children:[a.jsx("span",{className:"text-muted-foreground font-medium",children:"Total"}),a.jsxs("span",{className:"font-semibold text-foreground",children:["$",Qe.toLocaleString()]})]}),Ke>0&&a.jsxs("div",{className:"mt-2 flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Amount Paid"}),a.jsxs("span",{className:"font-medium text-foreground",children:["$",Ke.toLocaleString()]})]}),He>0&&Ke>0&&a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Remaining Balance"}),a.jsxs("span",{className:"font-medium text-foreground",children:["$",He.toLocaleString()]})]})]})]})})(),ue=Z.inclusions&&!Ae&&a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(Mr,{className:"h-5 w-5 text-accent"})," What's Included"]}),a.jsx("div",{className:"rounded-lg border border-border bg-card p-5",children:a.jsx("p",{className:"text-sm text-foreground/80 leading-relaxed whitespace-pre-line",children:Z.inclusions})})]});return a.jsxs("div",{className:"min-h-screen bg-background",children:[C&&a.jsxs("div",{className:"bg-primary text-primary-foreground text-center py-3 px-4 text-sm font-medium",children:["â ",C==="deposit"?"Deposit":"Payment"," received â thank you!"]}),a.jsx("header",{className:"border-b border-border bg-card",children:a.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-4 flex items-center justify-between",children:[a.jsx("a",{href:"https://www.explorefour.com/",target:"_blank",rel:"noopener noreferrer","aria-label":"Visit explorefour.com",children:a.jsx("img",{src:Bw,alt:"Four Corners",className:"h-14"})}),ve&&a.jsx("div",{className:"text-right",children:a.jsxs("p",{className:"text-sm font-medium text-foreground",children:[ve.name,", ",a.jsx("span",{className:"text-muted-foreground font-normal",children:Ae?"you've done it!":"you're invited."})]})})]})}),a.jsx("div",{className:"relative overflow-hidden",children:Z.cover_image_url?a.jsxs("div",{className:"relative h-56 md:h-72",children:[a.jsx("img",{src:Z.cover_image_url,alt:Z.public_name||Z.name,className:"absolute inset-0 w-full h-full object-cover"}),a.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/30 to-transparent"}),a.jsxs("div",{className:"absolute bottom-0 left-0 right-0 max-w-4xl mx-auto px-4 pb-6",children:[a.jsx("h1",{className:"text-3xl md:text-4xl font-display font-semibold text-white mb-2 drop-shadow-lg",children:Z.public_name||Z.name}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm text-white/80",children:[Z.location&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(zi,{className:"h-4 w-4"})," ",Z.location]}),Z.target_start_date&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(rs,{className:"h-4 w-4"})," ",Ye(new Date(Z.target_start_date+"T00:00:00"),"MMMM d, yyyy")]}),Z.activity_type&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(vc,{className:"h-4 w-4"})," ",AA[Z.activity_type]||Z.activity_type]})]})]})]}):a.jsxs("div",{className:"relative h-44 md:h-56 bg-gradient-to-br from-[hsl(220,20%,14%)] via-[hsl(220,18%,22%)] to-[hsl(28,60%,52%)]",children:[a.jsx("div",{className:"absolute inset-0 opacity-10",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`}}),a.jsxs("div",{className:"absolute bottom-0 left-0 right-0 max-w-4xl mx-auto px-4 pb-6",children:[a.jsx("h1",{className:"text-3xl md:text-4xl font-display font-semibold text-white mb-2",children:Z.public_name||Z.name}),a.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm text-white/80",children:[Z.location&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(zi,{className:"h-4 w-4"})," ",Z.location]}),Z.target_start_date&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(rs,{className:"h-4 w-4"})," ",Ye(new Date(Z.target_start_date+"T00:00:00"),"MMMM d, yyyy")]}),Z.activity_type&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(vc,{className:"h-4 w-4"})," ",AA[Z.activity_type]||Z.activity_type]})]})]})]})}),ve&&!je&&a.jsx("div",{className:"max-w-4xl mx-auto px-4 pt-4",children:a.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border bg-muted/50 px-4 py-2 text-sm text-muted-foreground",children:[a.jsxs("span",{children:["This page is personalized for ",a.jsx("strong",{className:"text-foreground",children:ve.name.split(" ")[0]}),"."]}),a.jsx("a",{href:`${window.location.origin}/experience?experienceId=${Z.id}`,className:"text-primary hover:underline whitespace-nowrap ml-3",children:"Not you?"})]})}),!je&&kr(ee==null?void 0:ee.status)&&Z.traveljoy_url&&a.jsx("div",{className:"max-w-4xl mx-auto px-4 pt-4",children:a.jsxs("a",{href:Z.traveljoy_url,target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center justify-center gap-2 rounded-md bg-primary px-4 py-3 text-sm font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90",children:[a.jsx(uH,{className:"h-4 w-4"})," Detailed Trip Information",a.jsx(M3,{className:"h-3.5 w-3.5 opacity-80"})]})}),a.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-8 space-y-8",children:[je?a.jsxs("section",{className:"flex items-center justify-center gap-3",children:[nt,Z.type!=="stakeholder_summit"&&a.jsx(Kh,{experienceName:Z.public_name||Z.name,url:`${window.location.origin}/experience?experienceId=${Z.id}`,ogUrl:`https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/og-metadata?experienceId=${Z.id}`})]}):rt(),Ae&&!je&&ee&&(()=>
839{const se=te||!!et,ge=(et==null?void 0:et.answers)||{},$e=se?ge:K,Ke=async()=>{if(!(!t||!Ae)){fe(!0);try{if(!(await fetch(`${re}?token=${t}`,{method:"POST",headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM","Content-Type":"application/json"},body:JSON.stringify({action:"submit_survey",survey_id:Ae.id,answers:K})})).ok)throw new Error("Failed");J(!0)}catch{}finally{fe(!1)}}};return a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(em,{className:"h-5 w-5 text-accent"})," Experience Survey"]}),a.jsx("div",{className:"rounded-lg border border-border bg-card p-5 space-y-5",children:se?a.jsxs("div",{className:"flex flex-col items-center justify-center text-center py-8 px-4 space-y-3",children:[a.jsx("div",{className:"rounded-full bg-emerald-100 p-3",children:a.jsx(Mr,{className:"h-8 w-8 text-emerald-600"})}),a.jsx("h3",{className:"text-xl font-display font-semibold text-foreground",children:"Thank you for your responses!"}),a.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:"Your feedback has been received and is deeply appreciated. It helps us continue to refine the experiences we offer."})]}):a.jsxs(a.Fragment,{children:[Ae.questions.map(Qe=>a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs("label",{className:"text-sm font-medium text-foreground",children:[Qe.label," ",Qe.required&&a.jsx("span",{className:"text-destructive",children:"*"})]}),Qe.type==="rating"&&a.jsx("div",{className:"flex items-center gap-1",children:[1,2,3,4,5].map(He=>a.jsx("button",{disabled:se,onClick:()=>G(Tt=>({...Tt,[Qe.id]:He})),className:`text-2xl transition-colors ${($e[Qe.id]||0)>=He?"text-amber-400":"text-muted-foreground/30"} ${se?"cursor-default":"hover:text-amber-400 cursor-pointer"}`,children:"â
"},He))}),Qe.type==="rating_10"&&a.jsx("div",{className:"flex flex-wrap items-center gap-1",children:[1,2,3,4,5,6,7,8,9,10].map(He=>a.jsx("button",{disabled:se,onClick:()=>G(Tt=>({...Tt,[Qe.id]:He})),className:`h-9 w-9 rounded-md border text-sm font-medium transition-colors ${$e[Qe.id]===He?"bg-accent text-accent-foreground border-accent":"bg-background text-foreground border-border hover:bg-muted"} ${se?"cursor-default opacity-80":"cursor-pointer"}`,children:He},He))}),Qe.type==="text"&&a.jsx(qt,{value:$e[Qe.id]||"",onChange:He=>G(Tt=>({...Tt,[Qe.id]:He.target.value})),disabled:se,className:"text-sm",rows:3,placeholder:"Your answer..."}),Qe.type==="yes_no"&&a.jsx("div",{className:"flex items-center gap-3",children:["Yes","No"].map(He=>a.jsx(Y,{variant:$e[Qe.id]===He?"default":"outline",size:"sm",disabled:se,onClick:()=>G(Tt=>({...Tt,[Qe.id]:He})),children:He},He))}),Qe.type==="multi_select"&&Qe.options&&a.jsx("div",{className:"space-y-1.5",children:Qe.options.map(He=>{const fn=($e[Qe.id]||[]).includes(He);return a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx(gt,{checked:fn,disabled:se,onCheckedChange:Xt=>{G(_e=>{const It=_e[Qe.id]||[];return{..._e,[Qe.id]:Xt?[...It,He]:It.filter(nn=>nn!==He)}})}}),a.jsx("span",{className:"text-sm text-foreground",children:He})]},He)})})]},Qe.id)),!se&&a.jsxs(Y,{onClick:Ke,disabled:H,className:"w-full",children:[H?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-2"}):null,"Submit Survey"]})]})})]})})(),Z.description&&!kr(ee==null?void 0:ee.status)&&a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(Hs,{className:"h-5 w-5 text-accent"})," About This Experience"]}),a.jsx("div",{className:"rounded-lg border border-border bg-card p-5",children:a.jsx("p",{className:"text-foreground/80 leading-relaxed whitespace-pre-line",children:Z.description})})]}),Et&&Nt,Et&&ue,Z.type!=="stakeholder_summit"&&Pe.length>0&&a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(Mr,{className:"h-5 w-5 text-accent"})," Optional Add-Ons"]}),a.jsxs("div",{className:"rounded-lg border border-border bg-card p-5",children:[a.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Select any extras you'd like to include with your experience."}),a.jsx("div",{className:"space-y-2",children:Pe.map(se=>{const ge=ze.includes(se.id);return a.jsxs("label",{className:`flex items-start gap-3 rounded-lg border p-3 transition-colors cursor-pointer ${ge?"border-primary bg-primary/5":"border-border hover:bg-muted/30"}`,children:[a.jsx(gt,{checked:ge,disabled:m===se.id,onCheckedChange:$e=>V(se.id,!!$e),className:"mt-0.5"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm font-medium text-foreground",children:se.name}),a.jsx("span",{className:"text-sm font-semibold text-foreground ml-2",children:se.third_party_payer?"Included":`$${Number(se.price).toLocaleStr
839ing()}`})]}),se.description&&a.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:se.description})]}),m===se.id&&a.jsx(vt,{className:"h-4 w-4 animate-spin text-muted-foreground flex-shrink-0"})]},se.id)})})]})]}),Z.type==="stakeholder_summit"&&kr(ee==null?void 0:ee.status)&&t&&a.jsx(lhe,{invitedGuest:s.invitedGuest,postAction:D,onChanged:X}),Je.length>0&&a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground flex items-center gap-2",children:[a.jsx(rs,{className:"h-5 w-5 text-accent"})," Dates"]}),a.jsx(w8,{feedUrl:Ue,label:"Add to Calendar",className:"gap-2"})]}),a.jsx("div",{className:"rounded-lg border border-border bg-card p-5",children:a.jsx("div",{className:"space-y-3",children:Je.filter(se=>!se.parent_date_id).sort((se,ge)=>new Date(se.start_date).getTime()-new Date(ge.start_date).getTime()||(se.sort_order??0)-(ge.sort_order??0)).map(se=>{const ge=se.all_day!==!1,$e=Je.filter(Qe=>Qe.parent_date_id===se.id).sort((Qe,He)=>new Date(Qe.start_date).getTime()-new Date(He.start_date).getTime()),Ke=(Qe,He)=>{if(He){const[Tt,fn,Xt]=Qe.substring(0,10).split("-").map(Number);return Ye(new Date(Tt,fn-1,Xt),"MMMM d, yyyy")}return Ye(new Date(Qe),"MMMM d, yyyy 'at' h:mm a")};return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(rs,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:se.label}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:[Ke(se.start_date,ge),se.end_date&&` â ${Ke(se.end_date,ge)}`]}),se.location&&a.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5 flex items-center gap-1",children:[se.is_virtual?a.jsx(nm,{className:"h-3 w-3 flex-shrink-0"}):a.jsx(zi,{className:"h-3 w-3 flex-shrink-0"}),/^https?:\/\//i.test(se.location)?a.jsx("a",{href:se.location,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:se.location}):a.jsx("span",{children:se.location})]}),se.is_virtual&&s.zoomCredentials&&(s.zoomCredentials.host_key||s.zoomCredentials.username||s.zoomCredentials.password)&&a.jsxs("div",{className:"mt-1 rounded border border-border bg-muted/40 p-2 text-xs space-y-0.5",children:[a.jsx("p",{className:"text-[10px] uppercase tracking-wide text-muted-foreground font-medium",children:"Guide-only Zoom info"}),s.zoomCredentials.host_key&&a.jsxs("p",{children:[a.jsx("span",{className:"text-muted-foreground",children:"Host key:"})," ",a.jsx("span",{className:"font-mono",children:s.zoomCredentials.host_key})]}),s.zoomCredentials.username&&a.jsxs("p",{children:[a.jsx("span",{className:"text-muted-foreground",children:"Username:"})," ",a.jsx("span",{className:"font-mono",children:s.zoomCredentials.username})]}),s.zoomCredentials.password&&a.jsxs("p",{children:[a.jsx("span",{className:"text-muted-foreground",children:"Password:"})," ",a.jsx("span",{className:"font-mono",children:s.zoomCredentials.password})]})]}),(se.notes||se.description)&&a.jsx(PA,{notes:se.notes,description:se.description})]})]}),$e.length>0&&a.jsx("div",{className:"ml-7 mt-1 space-y-2",children:$e.map(Qe=>{const He=Qe.all_day!==!1,Tt=Qe.location??se.location;return a.jsxs("div",{children:[a.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[a.jsx(rs,{className:"h-3 w-3 flex-shrink-0"}),Ke(Qe.start_date,He)]}),Tt&&a.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5 ml-5 flex items-center gap-1",children:[Qe.is_virtual??se.is_virtual?a.jsx(nm,{className:"h-3 w-3 flex-shrink-0"}):a.jsx(zi,{className:"h-3 w-3 flex-shrink-0"}),/^https?:\/\//i.test(Tt)?a.jsx("a",{href:Tt,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:Tt}):a.jsx("span",{children:Tt})]}),(Qe.notes||Qe.description)&&a.jsx("div",{className:"ml-5",children:a.jsx(PA,{notes:Qe.notes,description:Qe.description})})]},Qe.id)})})]},se.id)})})})]}),!Ae&&kr(ee==null?void 0:ee.status)&&!je&&Q.length>0&&a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(em,{className:"h-5 w-5 text-accent"})," Tasks to Complete"]}),a.jsx("div",{className:"space-y-3",children:a.jsx(dhe,{formFields:Q,getResponse:be,savingField:x,uploadingField:p,submitResponse:U,uploadFile:z,expandedAgreement:N,setExpandedAgreement:j,fileInputRefs:O,isGeneral:je,acceptedAt:ee==null?void 0:ee.accepted_at})})]}),(ee==null?void 0:ee.status)!=="accepted"&&(ee==null?void 0:ee.status)!=="gen_guide"&&Z.generators.filter(se=>se.is_host_guide).length>0&&a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(Ws,{className:"h-5 w-5 text-accent"})," Host Guides"]}),a.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:Z.generators.filter(se=>se.is_host_guide).map(se=>{var ge;return a.jsx("div",{className:"rounded-lg border border-border bg-card p-4",children:a.jsxs("div",{className:"flex gap-3",children:[se.headshot_url&&a.jsx("img",{src:se.headshot_url,alt:se.name,className:"h-16 w-16 rounded-full object-cover flex-shrink-0"}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[!se.headshot_url&&a.jsx(Ws,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"text-sm font-medium text-foreground",children:se.name}),a.jsx(Ge,{variant:"outline",className:"text-[10px]",children:"Host Guide"}),se.id===((ge=Z.projectManager)==null?void 0:ge.id)&&a.jsx(Ge,{variant:"outline",className:"text-[10px]",children:"Project Manager"})]}),se.bio&&a.jsx("p",{className:"text-xs text-muted-foreground mb-1 whitespace-pre-line",children:se.bio}),se.email&&a.jsx("a",{href:`mailto:${se.email}`,className:"text-xs text-primary hover:underline block",children:se.email}),se.phone&&a.jsx("p",{className:"text-xs text-muted-foreground",children:se.ph
839one})]})]})},se.id)})})]}),(((we=s.companions)==null?void 0:we.length)??0)>0&&a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(Hc,{className:"h-5 w-5 text-accent"})," Your Companions"]}),a.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:s.companions.map(se=>a.jsx("div",{className:"rounded-lg border border-border bg-card p-4",children:a.jsxs("div",{className:"flex gap-3",children:[se.headshot_url?a.jsx("img",{src:se.headshot_url,alt:se.name,className:"h-16 w-16 rounded-full object-cover flex-shrink-0"}):a.jsx("div",{className:"h-16 w-16 rounded-full bg-muted flex items-center justify-center flex-shrink-0",children:a.jsx(Ws,{className:"h-6 w-6 text-muted-foreground"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx("p",{className:"text-sm font-medium text-foreground",children:se.name}),se.is_host_guide&&a.jsx(Ge,{variant:"outline",className:"text-[10px]",children:"Host Guide"})]}),(se.address_city||se.address_state)&&a.jsx("p",{className:"text-xs text-muted-foreground",children:[se.address_city,se.address_state].filter(Boolean).join(", ")}),se.email&&a.jsx("a",{href:`mailto:${se.email}`,className:"text-xs text-primary hover:underline block truncate",children:se.email}),se.phone&&a.jsx("a",{href:`tel:${se.phone}`,className:"text-xs text-muted-foreground hover:underline block",children:se.phone}),se.linkedin_url&&a.jsx("a",{href:se.linkedin_url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:"LinkedIn"}),se.instagram_handle&&a.jsx("a",{href:`https://instagram.com/${se.instagram_handle.replace(/^@/,"")}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:se.instagram_handle.startsWith("@")?se.instagram_handle:`@${se.instagram_handle}`})]})]})},se.id))})]}),!je&&t&&kr(ee==null?void 0:ee.status)&&((Ie=s.tracker)==null?void 0:Ie.enabled)&&a.jsx(ohe,{meetingCount:s.tracker.meetingCount,entries:s.tracker.entries||{},token:t,postAction:D}),Z.resources.length>0&&a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(ja,{className:"h-5 w-5 text-accent"})," Additional Information"]}),a.jsx("div",{className:"space-y-2",children:Z.resources.map(se=>a.jsxs("a",{href:se.url||"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 rounded-lg border border-border bg-card p-3 hover:bg-muted/50 transition-colors",children:[a.jsx(Hs,{className:"h-5 w-5 text-accent flex-shrink-0"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:se.file_name}),se.file_size&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:[(se.file_size/1024).toFixed(0)," KB"]})]}),a.jsx(ja,{className:"h-4 w-4 text-muted-foreground"})]},se.id))})]}),!je&&kr(ee==null?void 0:ee.status)&&(ee==null?void 0:ee.deposit_paid)&&Z.training_plan&&a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(vc,{className:"h-5 w-5 text-accent"})," Your Preparation Guide"]}),a.jsx("div",{className:"rounded-lg border border-border bg-card p-5",children:a.jsx("div",{className:"prose prose-sm max-w-none text-foreground/80 [&_h1]:text-lg [&_h1]:font-semibold [&_h1]:text-foreground [&_h2]:text-base [&_h2]:font-semibold [&_h2]:text-foreground [&_h3]:text-sm [&_h3]:font-semibold [&_h3]:text-foreground [&_strong]:text-foreground [&_ul]:space-y-1 [&_ol]:space-y-1 [&_li]:text-sm",children:Z.training_plan.split(` 840`).map((se,ge)=>{if(se.startsWith("### "))return a.jsx("h3",{className:"mt-4 mb-1",children:se.slice(4)},ge);if(se.startsWith("## "))return a.jsx("h2",{className:"mt-5 mb-2",children:se.slice(3)},ge);if(se.startsWith("# "))return a.jsx("h1",{className:"mt-5 mb-2",children:se.slice(2)},ge);if(se.startsWith("- **")||se.startsWith("* **")){const Ke=se.slice(2),Qe=Ke.indexOf("**",2);if(Qe>0){const He=Ke.slice(2,Qe),Tt=Ke.slice(Qe+2);return a.jsxs("li",{className:"ml-4 list-disc text-sm",children:[a.jsx("strong",{className:"text-foreground",children:He}),Tt]},ge)}}if(se.startsWith("- ")||se.startsWith("* "))return a.jsx("li",{className:"ml-4 list-disc text-sm",children:se.slice(2)},ge);if(se.match(/^\d+\. /))return a.jsx("li",{className:"ml-4 list-decimal text-sm",children:se.replace(/^\d+\. /,"")},ge);if(se.trim()==="")return a.jsx("div",{className:"h-2"},ge);const $e=se.split(/(\*\*[^*]+\*\*)/g);return a.jsx("p",{className:"text-sm leading-relaxed",children:$e.map((Ke,Qe)=>Ke.startsWith("**")&&Ke.endsWith("**")?a.jsx("strong",{className:"text-foreground",children:Ke.slice(2,-2)},Qe):Ke)},ge)})})})]}),!Et&&Nt,!Et&&ue,je?a.jsxs("section",{className:"flex items-center justify-center gap-3",children:[nt,Z.type!=="stakeholder_summit"&&a.jsx(Kh,{experienceName:Z.public_name||Z.name,url:`${window.location.origin}/experience?experienceId=${Z.id}`,ogUrl:`https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/og-metadata?experienceId=${Z.id}`})]}):rt("bottom")]}),a.jsx("footer",{className:"border-t border-border mt-12 py-6",children:a.jsx("div",{className:"max-w-4xl mx-auto px-4 text-center",children:a.jsx("a",{href:"https://www.explorefour.com/",target:"_blank",rel:"noopener noreferrer","aria-label":"Visit explorefour.com",children:a.jsx("img",{src:Bw,alt:"Four Corners",className:"h-12 mx-auto mb-2"})})})}),a.jsx(Dt,{open:L,onOpenChange:E,children:a.jsxs(Pt,{className:"sm:max-w-md",children:[a.jsxs(Ot,{children:[a.jsx(At,{children:"Express Interest"}),a.jsx(wr,{children:"Share your details and we'll follow up with you about this experience."})]}),W?a.jsxs("div",{className:"text-center py-4",children:[a.jsx(On,{className:"h-8 w-8 text-emerald-600 mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-foreground font-medium",children:"Thank y
840ou! We'll be in touch."})]}):a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(xe,{htmlFor:"express-name",children:"Name"}),a.jsx(ce,{id:"express-name",value:R,onChange:se=>q(se.target.value),placeholder:"Your full name",maxLength:200})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(xe,{htmlFor:"express-email",children:"Email"}),a.jsx(ce,{id:"express-email",type:"email",value:I,onChange:se=>$(se.target.value),placeholder:"[email protected]",maxLength:255})]}),a.jsxs(Y,{onClick:Ze,disabled:M||!R.trim()||!I.trim(),className:"w-full",children:[M?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-2"}):null,"Submit"]})]})]})})]})}function T1(e,t){return e.due_on_acceptance?t?t.slice(0,10):null:e.due_date?e.due_date.slice(0,10):null}function U8(e){const t=new Date;return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`>e}function uhe(e){if(!e)return!1;const t=new Date;return t.setHours(0,0,0,0),(new Date(`${e}T00:00:00`).getTime()-t.getTime())/(1e3*60*60*24)>90}function bx(e,t){return t!=null&&t.responded_at?e.field_type==="task"||e.field_type==="agreement"?!!t.response_bool:e.field_type==="file_upload"?!!t.response_file_path:!!t.response_text:!1}function dhe({formFields:e,getResponse:t,savingField:n,uploadingField:r,submitResponse:s,uploadFile:i,expandedAgreement:o,setExpandedAgreement:l,fileInputRefs:c,isGeneral:u,acceptedAt:d}){const h=[];let m={header:null,fields:[]};for(const b of e)b.field_type==="section_header"?((m.fields.length>0||m.header)&&h.push(m),m={header:b,fields:[]}):m.fields.push(b);(m.fields.length>0||m.header)&&h.push(m);const f=e.filter(b=>!["section_header","information"].includes(b.field_type)),x=f.length,g=f.filter(b=>bx(b,t(b.id))).length,p=x>0?Math.round(g/x*100):0,v=["bg-muted/20","bg-muted/40"];return a.jsxs(a.Fragment,{children:[x>0&&a.jsxs("div",{className:"rounded-lg border border-border bg-card p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm font-medium text-foreground",children:g===x?"All tasks complete!":`${g} of ${x} tasks complete`}),a.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[p,"%"]})]}),a.jsx("div",{className:"w-full h-2 bg-muted rounded-full overflow-hidden",children:a.jsx("div",{className:Se("h-full rounded-full transition-all duration-500",g===x?"bg-emerald-500":"bg-accent"),style:{width:`${p}%`}})})]}),[...h.map((N,j)=>{const _=N.header?T1(N.header,d):null;return{group:N,index:j,isFarFuture:uhe(_)}})].sort((N,j)=>N.isFarFuture===j.isFarFuture?N.index-j.index:N.isFarFuture?1:-1).map(({group:N,index:j,isFarFuture:_},S)=>{if(N.header){const P=N.fields.filter(O=>O.field_type!=="information"),k=P.some(O=>O.required)?P.filter(O=>O.required):P,C=k.length>0&&k.every(O=>bx(O,t(O.id))),T=T1(N.header,d);return a.jsx(hhe,{title:N.header.description,defaultOpen:!C&&!_,allComplete:C,fieldCount:P.length,completedCount:P.filter(O=>bx(O,t(O.id))).length,shadeClass:v[S%v.length],dueDate:T,children:N.fields.map(O=>a.jsx(TA,{field:O,allFields:e,response:t(O.id),isSaving:n===O.id,isUploading:r===O.id,submitResponse:s,uploadFile:i,expandedAgreement:o,setExpandedAgreement:l,fileInputRefs:c,sectionDueDate:T,acceptedAt:d},O.id))},N.header.id)}return N.fields.map(P=>a.jsx(TA,{field:P,allFields:e,response:t(P.id),isSaving:n===P.id,isUploading:r===P.id,submitResponse:s,uploadFile:i,expandedAgreement:o,setExpandedAgreement:l,fileInputRefs:c,acceptedAt:d},P.id))})]})}function hhe({title:e,defaultOpen:t,allComplete:n,fieldCount:r,completedCount:s,children:i,shadeClass:o,dueDate:l}){const[c,u]=y.useState(t),d=y.useRef(n);y.useEffect(()=>{n&&!d.current&&u(!1),d.current=n},[n]),y.useEffect(()=>{n&&u(!1)},[t]);const h=()=>{u(f=>!f)},m=l&&U8(l)&&!n;return a.jsxs("div",{className:Se("rounded-lg border overflow-hidden",m?"border-destructive/50":"border-border"),children:[a.jsxs("button",{className:Se("flex items-center justify-between w-full px-4 py-4 transition-colors text-left",o||"bg-muted/30","hover:brightness-95"),onClick:h,children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[c?a.jsx(_r,{className:"h-4 w-4 text-muted-foreground"}):a.jsx(_n,{className:"h-4 w-4 text-muted-foreground"}),a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:gap-2",children:[a.jsx("span",{className:"text-base font-display font-semibold text-foreground",children:e}),l&&a.jsxs("span",{className:Se("text-xs",m?"text-destructive font-medium":"text-muted-foreground"),children:["due by ",Ye(new Date(l),"MMMM d, yyyy")]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[r>0&&a.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[s,"/",r]}),n&&a.jsx(Mr,{className:"h-4 w-4 text-emerald-600"})]})]}),c&&a.jsx("div",{className:Se("p-3 space-y-3",o||"bg-muted/20"),children:i})]})}function TA({field:e,allFields:t,response:n,isSaving:r,isUploading:s,submitResponse:i,uploadFile:o,expandedAgreement:l,setExpandedAgreement:c,fileInputRefs:u,sectionDueDate:d,acceptedAt:h}){var p,v,b,w,N,j,_,S;const m=T1(e,h),f=m||d,x=bx(e,n),g=!x&&f&&U8(f)&&e.field_type!=="information";return a.jsx("div",{className:Se("rounded-lg border bg-card p-4",g?"border-destructive/60 bg-destructive/5":"border-border"),children:e.field_type==="information"?a.jsx("p",{className:"text-sm text-foreground
840/80 leading-relaxed whitespace-pre-line",children:e.description}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx("span",{className:Se("text-sm font-medium",g?"text-destructive":"text-foreground"),children:e.description}),e.required&&a.jsx(Ge,{variant:"secondary",className:"text-[9px]",children:"Required"}),g&&a.jsx(Ge,{variant:"destructive",className:"text-[9px]",children:"Overdue"}),!g&&m&&a.jsxs(Ge,{variant:"outline",className:"text-[9px]",children:["Due ",Ye(new Date(m),"MMM d, yyyy")]}),x&&a.jsx(On,{className:"h-3.5 w-3.5 text-emerald-600 flex-shrink-0"})]}),e.field_type==="task"&&a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx(gt,{checked:!!(n!=null&&n.response_bool),disabled:r,onCheckedChange:P=>i(e.id,void 0,!!P)}),a.jsx("span",{className:"text-sm text-muted-foreground",children:"Mark as complete"}),r&&a.jsx(vt,{className:"h-3 w-3 animate-spin"})]}),e.field_type==="text"&&((p=e.field_options)==null?void 0:p.contact_field)==="address_street"&&a.jsx(aF,{defaultValue:(n==null?void 0:n.response_text)||"",placeholder:((v=e.field_options)==null?void 0:v.placeholder)||"Start typing your addressâ¦",isSaving:r,onChangeText:P=>{P!==((n==null?void 0:n.response_text)||"")&&i(e.id,P)},onPlaceParsed:P=>{var C;const k={address_street:P.street,address_city:P.city,address_state:P.state,address_postal_code:P.postal_code,address_country:P.country};for(const T of t){const O=(C=T.field_options)==null?void 0:C.contact_field;O&&O in k&&k[O]&&i(T.id,k[O])}}}),e.field_type==="text"&&((b=e.field_options)==null?void 0:b.contact_field)!=="address_street"&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx(ce,{defaultValue:(n==null?void 0:n.response_text)||"",placeholder:((w=e.field_options)==null?void 0:w.placeholder)||"Enter your responseâ¦",className:"h-9 text-sm flex-1",maxLength:500,onBlur:P=>{P.target.value!==((n==null?void 0:n.response_text)||"")&&i(e.id,P.target.value)}}),r&&a.jsx(vt,{className:"h-4 w-4 animate-spin self-center"})]}),e.field_type==="textarea"&&a.jsxs("div",{children:[a.jsx(qt,{defaultValue:(n==null?void 0:n.response_text)||"",placeholder:((N=e.field_options)==null?void 0:N.placeholder)||"Enter your responseâ¦",rows:3,className:"text-sm",maxLength:2e3,onBlur:P=>{P.target.value!==((n==null?void 0:n.response_text)||"")&&i(e.id,P.target.value)}}),r&&a.jsx(vt,{className:"h-3 w-3 animate-spin mt-1"})]}),e.field_type==="select"&&((j=e.field_options)==null?void 0:j.options)&&a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(lt,{defaultValue:(n==null?void 0:n.response_text)||"",onValueChange:P=>i(e.id,P),children:[a.jsx(it,{className:"h-9 text-sm",children:a.jsx(ct,{placeholder:"Select an optionâ¦"})}),a.jsx(ot,{children:e.field_options.options.map(P=>a.jsx(Oe,{value:P,children:P},P))})]}),r&&a.jsx(vt,{className:"h-4 w-4 animate-spin self-center"})]}),e.field_type==="file_upload"&&a.jsxs("div",{children:[((_=e.field_options)==null?void 0:_.agreement_text)&&a.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line mb-3 leading-relaxed",children:e.field_options.agreement_text.split(/(https?:\/\/[^\s]+)/g).map((P,k)=>/^https?:\/\//.test(P)?a.jsx("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline break-all",children:P},k):P)}),n!=null&&n.response_file_name?a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(Hs,{className:"h-4 w-4 text-accent"}),n.response_file_url?a.jsx("a",{href:n.response_file_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:n.response_file_name}):a.jsx("span",{className:"text-foreground",children:n.response_file_name}),a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{var P;return(P=u.current[e.id])==null?void 0:P.click()},disabled:s,children:"Replace"})]}):a.jsxs(Y,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>{var P;return(P=u.current[e.id])==null?void 0:P.click()},disabled:s,children:[s?a.jsx(vt,{className:"h-3 w-3 animate-spin mr-1"}):a.jsx(ao,{className:"h-3 w-3 mr-1"}),"Upload File"]}),a.jsx("input",{type:"file",ref:P=>{u.current[e.id]=P},className:"hidden",onChange:P=>{var C;const k=(C=P.target.files)==null?void 0:C[0];k&&o(e.id,k)}})]}),e.field_type==="agreement"&&a.jsxs("div",{children:[((S=e.field_options)==null?void 0:S.agreement_text)&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("button",{className:"text-xs text-primary hover:underline flex items-center gap-1",onClick:()=>c(l===e.id?null:e.id),children:[l===e.id?a.jsx(_r,{className:"h-3 w-3"}):a.jsx(_n,{className:"h-3 w-3"}),l===e.id?"Hide agreement text":"Read full agreement"]}),l===e.id&&a.jsx("div",{className:"mt-2 rounded border border-border bg-muted/30 p-3 max-h-64 overflow-y-auto",children:a.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-line leading-relaxed",children:e.field_options.agreement_text})})]}),a.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[a.jsx(gt,{checked:!!(n!=null&&n.response_bool),disabled:r,onCheckedChange:P=>
840i(e.id,void 0,!!P),className:"mt-0.5"}),a.jsx("span",{className:"text-sm text-foreground",children:"I have read and agree to the above terms"}),r&&a.jsx(vt,{className:"h-3 w-3 animate-spin"})]})]})]})})}const Uw=rb.url;function fhe(){const[e]=El(),t=e.get("token"),n=e.get("payment_success"),[r,s]=y.useState(null),[i,o]=y.useState(!0),[l,c]=y.useState(null),[u,d]=y.useState(null),[h,m]=y.useState(!1),[f,x]=y.useState(null),g="https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/public-coaching",p="https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/create-coaching-payment",v="https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/verify-coaching-payment",b=async()=>{if(!t){c("Missing access token."),o(!1);return}try{const $=await fetch(`${g}?token=${t}`,{headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM"}});if(!$.ok){const M=await $.json().catch(()=>({}));throw new Error(M.error||"Failed to load")}s(await $.json())}catch($){c($.message)}finally{o(!1)}};y.useEffect(()=>{b()},[t]),y.useEffect(()=>{!n||!t||h||(m(!0),fetch(v,{method:"POST",headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM","Content-Type":"application/json"},body:JSON.stringify({token:t,payment_type:n})}).then($=>$.json()).then(()=>{b(),x(n);const $=new URL(window.location.href);$.searchParams.delete("payment_success"),window.history.replaceState({},"",$.toString())}).catch(()=>{}).finally(()=>m(!1)))},[n,t]);const w=async $=>{if(t){d($);try{const B=await(await fetch(p,{method:"POST",headers:{apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM","Content-Type":"application/json"},body:JSON.stringify({token:t,payment_type:$})})).json();B.url&&(window.location.href=B.url)}catch{}finally{d(null)}}};if(i)return a.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:a.jsx(vt,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(l||!r)return a.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:a.jsxs("div",{className:"text-center max-w-md",children:[a.jsx("img",{src:Uw,alt:"Four Corners",className:"h-16 mx-auto mb-6"}),a.jsx("h1",{className:"text-2xl font-display font-semibold text-foreground mb-2",children:"Link Not Found"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:l||"This coaching link is invalid or has expired."})]})});const{coaching:N,contact:j,generator:_}=r,S=.03,P=Number(N.amount_paid||0),k=Number(N.price||0),C=k-P,T=N.schedule_type!=="fixed",O=T&&N.payment_count!=null&&N.payment_count>=2,L=!T&&Array.isArray(N.fixed_payments)?N.fixed_payments:[],E=$=>{const M=Math.round($*S*100)/100;return`$${($+M).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`},R=()=>{if(!O||!N.price)return[];const $=N.payment_count,M=Number(N.price),B=Math.round(M/$),W=[];for(let A=0;A<$;A++){const K=A===$-1?M-B*($-1):B;let G=null;if(N.price_due_date){const te=new Date(N.price_due_date+"T00:00:00"),J=N.payment_frequency==="quarterly"?($-1-A)*3:$-1-A,re=new Date(te);re.setMonth(re.getMonth()-J),G=Ye(re,"yyyy-MM-dd")}const H=B*(A+1),fe=P>=H;W.push({number:A+1,amount:K,dueDate:G,paid:fe})}return W},q=()=>{let $=0;return L.sort((M,B)=>M.date.localeCompare(B.date)).map((M,B)=>{$+=Number(M.amount);const W=P>=$;return{number:B+1,amount:Number(M.amount),dueDate:M.date,paid:W}})},I=$=>{const M=$.find(B=>!B.paid);return a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground flex items-center gap-2",children:[a.jsx(pa,{className:"h-5 w-5 text-accent"})," Payment Schedule"]}),t&&a.jsx(by,{token:t,type:"coaching"})]}),a.jsxs("div",{className:"rounded-lg border border-border bg-card p-5",children:[M&&a.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border bg-muted/40 p-3 mb-3",children:[a.jsx(fs,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Checks can be mailed to Four Corners at PO Box 24321, Edina, MN 55424."})]}),a.jsx("div",{className:"space-y-2",children:$.map(B=>a.jsxs("div",{className:`flex items-center justify-between py-2 px-3 rounded-md ${B.paid?"bg-muted/50":B.number===(M==null?void 0:M.number)?"bg-primary/5 border border-primary/20":""}`,children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"text-sm font-medium text-foreground",children:["Payment ",B.number]}),B.dueDate&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["Due ",Ye(new Date(B.dueDate+"T00:00:00"),"MMM d, yyyy")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"text-sm font-semibold text-foreground",children:["$",B.amount.toLocaleStr
840ing()]}),B.paid?a.jsx(Ge,{className:"bg-emerald-100 text-emerald-800 border-0 text-xs",children:"Paid"}):B.number===(M==null?void 0:M.number)?a.jsxs(Y,{size:"sm",onClick:()=>w("balance"),disabled:u!==null,children:[u==="balance"?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-2"}):a.jsx(pa,{className:"h-4 w-4 mr-2"}),"Pay ",E(B.amount),a.jsx("span",{className:"text-xs opacity-70 ml-1",children:"(incl. 3% card fee)"})]}):a.jsx("span",{className:"text-xs text-muted-foreground",children:"Upcoming"})]})]},B.number))}),P>0&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-border flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Total Paid"}),a.jsxs("span",{className:"font-medium text-foreground",children:["$",P.toLocaleString()]})]}),C>0&&P>0&&a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Remaining"}),a.jsxs("span",{className:"font-medium text-foreground",children:["$",C.toLocaleString()]})]})]})]})};return a.jsxs("div",{className:"min-h-screen bg-background",children:[f&&a.jsx("div",{className:"bg-primary text-primary-foreground text-center py-3 px-4 text-sm font-medium",children:"â Payment received â thank you!"}),a.jsx("header",{className:"border-b border-border bg-card",children:a.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-4 flex items-center justify-between",children:[a.jsx("img",{src:Uw,alt:"Four Corners",className:"h-14"}),j&&a.jsx("div",{className:"text-right",children:a.jsx("p",{className:"text-sm font-medium text-foreground",children:j.name})})]})}),a.jsxs("div",{className:"relative h-36 md:h-44 bg-gradient-to-br from-[hsl(220,20%,14%)] via-[hsl(220,18%,22%)] to-[hsl(28,60%,52%)]",children:[a.jsx("div",{className:"absolute inset-0 opacity-10",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`}}),a.jsxs("div",{className:"absolute bottom-0 left-0 right-0 max-w-3xl mx-auto px-4 pb-6",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(sC,{className:"h-6 w-6 text-white/80"}),a.jsx("span",{className:"text-sm text-white/70 uppercase tracking-wider font-medium",children:"1:1 Coaching"})]}),a.jsx("h1",{className:"text-2xl md:text-3xl font-display font-semibold text-white",children:j?`${j.name}'s Coaching`:"Coaching"})]})]}),a.jsxs("main",{className:"max-w-3xl mx-auto px-4 py-8 space-y-8",children:[(N.start_date||N.notes)&&a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(rs,{className:"h-5 w-5 text-accent"})," Details"]}),a.jsxs("div",{className:"rounded-lg border border-border bg-card p-5 space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-foreground",children:[a.jsx("span",{className:"text-muted-foreground",children:"Period:"}),a.jsxs("span",{children:[Ye(new Date(N.start_date+"T00:00:00"),"MMMM d, yyyy"),N.end_date?` â ${Ye(new Date(N.end_date+"T00:00:00"),"MMMM d, yyyy")}`:" â Ongoing"]})]}),N.notes&&a.jsx("p",{className:"text-sm text-foreground/80 whitespace-pre-line",children:N.notes})]})]}),(r.addons??[]).length>0&&a.jsxs("section",{children:[a.jsx("h2",{className:"text-xl font-display font-semibold text-foreground mb-3",children:"Engagement Details"}),a.jsxs("div",{className:"rounded-lg border border-border bg-card p-5 space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-foreground",children:"Coaching engagement"}),a.jsxs("span",{className:"text-foreground",children:["$",Number(N.base_price??N.price??0).toLocaleString()]})]}),(r.addons??[]).map($=>a.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("span",{className:"text-foreground",children:$.name}),$.description&&a.jsx("p",{className:"text-xs text-muted-foreground",children:$.description}),$.third_party_payer&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Billed separately â not included in your total"})]}),a.jsxs("span",{className:$.third_party_payer?"text-muted-foreground":"text-foreground",children:["$",Number($.price||0).toLocaleStr
840ing()]})]},$.id)),a.jsxs("div",{className:"flex items-center justify-between border-t border-border pt-2 text-sm font-semibold",children:[a.jsx("span",{children:"Total"}),a.jsxs("span",{children:["$",k.toLocaleString()]})]})]})]}),N.price!=null&&(!T&&L.length>0?I(q()):O?I(R()):a.jsxs("section",{children:[a.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground flex items-center gap-2",children:[a.jsx(pa,{className:"h-5 w-5 text-accent"})," Pricing & Payment"]}),t&&a.jsx(by,{token:t,type:"coaching"})]}),a.jsxs("div",{className:"rounded-lg border border-border bg-card p-5 space-y-3",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Total Amount"}),a.jsxs("p",{className:"text-lg font-semibold text-foreground",children:["$",k.toLocaleString()]}),N.price_due_date&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Due by ",Ye(new Date(N.price_due_date+"T00:00:00"),"MMMM d, yyyy")]})]}),N.price_paid?a.jsx(Ge,{className:"bg-emerald-100 text-emerald-800 border-0 text-xs",children:"Paid in Full"}):a.jsxs(Y,{size:"sm",onClick:()=>w("balance"),disabled:u!==null,children:[u==="balance"?a.jsx(vt,{className:"h-4 w-4 animate-spin mr-2"}):a.jsx(pa,{className:"h-4 w-4 mr-2"}),"Pay ",E(C),a.jsx("span",{className:"text-xs opacity-70 ml-1",children:"(incl. 3% card fee)"})]}),!N.price_paid&&k>0&&a.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border bg-muted/40 p-3",children:[a.jsx(fs,{className:"h-4 w-4 text-muted-foreground mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Checks can be mailed to Four Corners at PO Box 24321, Edina, MN 55424."})]}),P>0&&a.jsxs("div",{className:"mt-3 pt-3 border-t border-border flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Amount Paid"}),a.jsxs("span",{className:"font-medium text-foreground",children:["$",P.toLocaleString()]})]}),C>0&&P>0&&a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Remaining Balance"}),a.jsxs("span",{className:"font-medium text-foreground",children:["$",C.toLocaleString()]})]})]})]})),_&&a.jsxs("section",{children:[a.jsxs("h2",{className:"text-xl font-display font-semibold text-foreground mb-3 flex items-center gap-2",children:[a.jsx(Ws,{className:"h-5 w-5 text-accent"})," Your Coach"]}),a.jsx("div",{className:"rounded-lg border border-border bg-card p-5",children:a.jsxs("div",{className:"flex items-start gap-4",children:[_.headshot_url?a.jsx("img",{src:_.headshot_url,alt:_.name,className:"w-16 h-16 rounded-full object-cover flex-shrink-0"}):a.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center flex-shrink-0",children:a.jsx(Ws,{className:"h-8 w-8 text-muted-foreground"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-base font-semibold text-foreground",children:_.name}),_.bio&&a.jsx("p",{className:"text-sm text-foreground/80 mt-1 whitespace-pre-line",children:_.bio}),a.jsxs("div",{className:"mt-2 flex flex-wrap gap-3 text-xs text-muted-foreground",children:[_.email&&a.jsx("span",{children:_.email}),_.phone&&a.jsx("span",{children:_.phone})]})]})]})})]})]}),a.jsx("footer",{className:"border-t border-border bg-card mt-12",children:a.jsx("div",{className:"max-w-3xl mx-auto px-4 py-6 flex items-center justify-center",children:a.jsx("img",{src:Uw,alt:"Four Corners",className:"h-12"})})})]})}const Ww="https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/public-generator-agreement";function mhe(){var v,b,w;const[e]=El(),t=e.get("token")??"",[n,r]=y.useState(!0),[s,i]=y.useState(null),[o,l]=y.useState(null),[c,u]=y.useState(!1),[d,h]=y.useState(""),[m,f]=y.useState(!1);y.useEffect(()=>{if(!t){i("Missing token"),r(!1);return}(async()=>{try{const N=await fetch(`${Ww}?token=${encodeURIComponent(t)}`),j=await N.json();if(!N.ok)throw new Error(j.error??"Failed to load");l(j.agreement),j.agreement.accepted_name&&h(j.agreement.accepted_name)}catch(N){i(N.message)}finally{r(!1)}})()},[t]);const x=async()=>
840{if(!(!c||!d.trim())){f(!0);try{const N=await fetch(`${Ww}?token=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accepted_name:d.trim()})}),j=await N.json();if(!N.ok)throw new Error(j.error??"Failed");const S=await(await fetch(`${Ww}?token=${encodeURIComponent(t)}`)).json();l(S.agreement)}catch(N){i(N.message)}finally{f(!1)}}};if(n)return a.jsx("div",{className:"flex min-h-screen items-center justify-center",children:a.jsx(vt,{className:"h-6 w-6 animate-spin"})});if(s)return a.jsx("div",{className:"flex min-h-screen items-center justify-center",children:a.jsx("p",{className:"text-destructive",children:s})});if(!o)return null;const g=!!o.accepted_at,p=!!o.verbally_accepted_at&&!g;return a.jsx("div",{className:"min-h-screen bg-background py-10 px-4",children:a.jsxs("div",{className:"mx-auto max-w-3xl",children:[a.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[a.jsx(U3,{className:"h-6 w-6 text-primary"}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-display font-semibold",children:"Generator Agreement"}),a.jsxs("p",{className:"text-sm text-muted-foreground",children:[((v=o.experiences)==null?void 0:v.public_name)||((b=o.experiences)==null?void 0:b.name)," â for ",(w=o.generators)==null?void 0:w.name]})]})]}),g&&a.jsxs("div",{className:"mb-6 rounded-md border border-green-600/30 bg-green-600/10 p-4 flex items-center gap-3",children:[a.jsx(Mr,{className:"h-5 w-5 text-green-700"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("strong",{children:"Accepted"})," by ",o.accepted_name," on"," ",Ye(new Date(o.accepted_at),"MMMM d, yyyy 'at' h:mm a"),"."]})]}),p&&a.jsxs("div",{className:"mb-6 rounded-md border border-amber-500/40 bg-amber-500/10 p-4 flex items-center gap-3",children:[a.jsx(Mr,{className:"h-5 w-5 text-amber-700"}),a.jsxs("div",{className:"text-sm",children:[a.jsx("strong",{children:"Verbally Accepted"})," â this agreement was verbally accepted and recorded by Four Corners staff",o.verbally_accepted_by_name?` (${o.verbally_accepted_by_name})`:""," on"," ",Ye(new Date(o.verbally_accepted_at),"MMMM d, yyyy"),". No further action is needed."]})]}),a.jsx("div",{className:"rounded-md border border-border bg-card p-6 mb-6",children:a.jsx("div",{className:"prose prose-sm max-w-none text-sm",dangerouslySetInnerHTML:{__html:Ok(o.body_markdown)}})}),!g&&!p&&a.jsxs("div",{className:"rounded-md border border-border bg-card p-6 space-y-4",children:[a.jsx("h2",{className:"font-display text-lg font-semibold",children:"Sign & Accept"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(xe,{children:"Your full name"}),a.jsx(ce,{value:d,onChange:N=>h(N.target.value),placeholder:"Type your full name"})]}),a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(gt,{id:"agree",checked:c,onCheckedChange:N=>u(!!N),className:"mt-0.5"}),a.jsx(xe,{htmlFor:"agree",className:"text-sm font-normal leading-relaxed",children:"I have read and agree to the terms outlined in this agreement."})]}),a.jsx(Y,{onClick:x,disabled:!c||!d.trim()||m,className:"w-full",children:m?"Submittingâ¦":"Accept Agreement"})]})]})})}const phe=()=>{const e=kl();return y.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted",children:a.jsxs("div",{className:"text-center",children:[a.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),a.jsx("p",{className:"mb-4 text-xl text-muted-foreground",children:"Oops! Page not found"}),a.jsx("a",{href:"/",className:"text-primary underline hover:text-primary/90",children:"Return to Home"})]})})},Mg={recap:"Post-Meeting Recap",checkin:"Mid-Cycle Check-in",agenda:"Pre-Meeting Agenda"};function ghe({open:e,onOpenChange:t,coachingId:n,contactName:r,contactEmail:s,coachName:i,coachEmail:o}){const l=at(),{toast:c}=mt(),[u,d]=y.useState(!1),[h,m]=y.useState(()=>new Date().toISOString().slice(0,10)),[f,x]=y.useState(""),[g,p]=y.useState(null),[v,b]=y.useState(""),[w,N]=y.useState(null),[j,_]=y.useState(null),[S,P]=y.useState(null),{data:k=[],isLoading:C}=Ee({queryKey:["coaching-sessions",n],enabled:e,queryFn:async()=>{const{data:$,error:M}=await F.from("coaching_sessions").select("*").eq("coaching_id",n).order("session_date",{ascending:!1});if(M)throw M;return $}}),{data:T=[]}=Ee({queryKey:["coaching-drafts",n],enabled:e,queryFn:async()=>{const{data:$,error:M}=await F.from("coaching_followup_drafts").select("*").eq("coaching_id",n);if(M)throw M;return $}}),O=Me({mutationFn:async()=>{const{error:$}=await F.from("coaching_sessions").insert({coaching_id:n,session_date:h,notes:f.trim()||null});if($)throw $},onSuccess:()=>
840{l.invalidateQueries({queryKey:["coaching-sessions",n]}),d(!1),x(""),c({title:"Session added"})},onError:$=>c({title:"Error",description:$.message,variant:"destructive"})}),L=Me({mutationFn:async({id:$,notes:M})=>{const{error:B}=await F.from("coaching_sessions").update({notes:M.trim()||null}).eq("id",$);if(B)throw B},onSuccess:()=>{l.invalidateQueries({queryKey:["coaching-sessions",n]}),p(null),c({title:"Session updated"})},onError:$=>c({title:"Error",description:$.message,variant:"destructive"})}),E=Me({mutationFn:async $=>{const{error:M}=await F.from("coaching_sessions").delete().eq("id",$);if(M)throw M},onSuccess:()=>{l.invalidateQueries({queryKey:["coaching-sessions",n]}),l.invalidateQueries({queryKey:["coaching-drafts",n]}),c({title:"Session deleted"})},onError:$=>c({title:"Error",description:$.message,variant:"destructive"})}),R=async($,M)=>{const B=`${$}-${M}`;P(B);try{const{data:W,error:A}=await F.functions.invoke("generate-coaching-followup",{body:{sessionId:$,emailType:M,contactName:r,coachName:i}});if(A)throw A;if(W!=null&&W.error)throw new Error(W.error);const{data:K,error:G}=await F.from("coaching_followup_drafts").insert({session_id:$,coaching_id:n,email_type:M,subject:W.subject,body_text:W.body,status:"draft"}).select("id").single();if(G)throw G;l.invalidateQueries({queryKey:["coaching-drafts",n]}),_({sessionId:$,emailType:M,subject:W.subject,body:W.body,draftId:K.id})}catch(W){c({title:"Error generating draft",description:W.message,variant:"destructive"})}finally{P(null)}},q=Me({mutationFn:async()=>{if(!(j!=null&&j.draftId)||!s||!o)return;const{data:$,error:M}=await F.functions.invoke("send-coaching-followup",{body:{draftId:j.draftId,subject:j.subject,body:j.body,recipientEmail:s,coachEmail:o,coachName:i}});if(M)throw M;if($!=null&&$.error)throw new Error($.error)},onSuccess:()=>{l.invalidateQueries({queryKey:["coaching-drafts",n]}),_(null),c({title:"Follow-up email sent"})},onError:$=>c({title:"Error sending email",description:$.message,variant:"destructive"})}),I=$=>T.filter(M=>M.session_id===$);return a.jsxs(a.Fragment,{children:[a.jsx(Dt,{open:e&&!j,onOpenChange:t,children:a.jsxs(Pt,{className:"sm:max-w-xl max-h-[80vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsxs(At,{children:["Sessions â ",r]})}),a.jsxs("div",{className:"space-y-3",children:[u?a.jsxs("div",{className:"border rounded-md p-3 space-y-2 bg-muted/30",children:[a.jsx(ce,{type:"date",value:h,onChange:$=>m($.target.value)}),a.jsx(qt,{value:f,onChange:$=>x($.target.value),placeholder:"Paste AI notetaker summary or type session notesâ¦",rows:5}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>d(!1),children:"Cancel"}),a.jsx(Y,{size:"sm",disabled:!h||O.isPending,onClick:()=>O.mutate(),children:"Save Session"})]})]}):a.jsxs(Y,{size:"sm",variant:"outline",onClick:()=>d(!0),children:[a.jsx(zt,{className:"h-4 w-4 mr-1"})," Add Session"]}),C&&a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading sessionsâ¦"}),k.map($=>{const M=w===$.id,B=I($.id),W=new Set(B.filter(A=>A.status==="sent").map(A=>A.email_type));return a.jsxs("div",{className:"border rounded-md",children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 cursor-pointer hover:bg-muted/50",onClick:()=>N(M?null:$.id),children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-sm font-medium",children:Ye(new Date($.session_date+"T00:00:00"),"MMM d, yyyy")}),W.size>0&&a.jsx("div",{className:"flex gap-1",children:Array.from(W).map(A=>a.jsxs(Ge,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:[A==="recap"?"R":A==="checkin"?"C":"A"," â"]},A))})]}),M?a.jsx(_r,{className:"h-4 w-4"}):a.jsx(_n,{className:"h-4 w-4"})]}),M&&a.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t",children:[a.jsx("div",{className:"pt-2",children:g===$.id?a.jsxs("div",{className:"space-y-2",children:[a.jsx(qt,{value:v,onChange:A=>b(A.target.value),rows:5}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>p(null),children:"Cancel"}),a.jsx(Y,{size:"sm",disabled:L.isPending,onClick:()=>
840L.mutate({id:$.id,notes:v}),children:"Save"})]})]}):a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-xs text-muted-foreground font-medium uppercase tracking-wider",children:"Notes"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>{p($.id),b($.notes??"")},children:a.jsx(Rn,{className:"h-3 w-3"})}),a.jsx(Y,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive",onClick:()=>{confirm("Delete this session?")&&E.mutate($.id)},children:a.jsx(pn,{className:"h-3 w-3"})})]})]}),$.notes?a.jsx("p",{className:"text-sm whitespace-pre-wrap text-muted-foreground",children:$.notes}):a.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No notes recorded."})]})}),$.notes&&a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-muted-foreground font-medium uppercase tracking-wider",children:"Follow-up Emails"}),a.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:["recap","checkin","agenda"].map(A=>{const K=W.has(A),G=B.some(fe=>fe.email_type===A&&fe.status==="draft"),H=S===`${$.id}-${A}`;return a.jsxs(Y,{variant:K?"secondary":G?"outline":"default",size:"sm",className:"text-xs",disabled:H||!s||!o,onClick:()=>{if(G){const fe=B.find(te=>te.email_type===A&&te.status==="draft");fe&&_({sessionId:$.id,emailType:A,subject:fe.subject??"",body:fe.body_text??"",draftId:fe.id})}else K||R($.id,A)},children:[H?a.jsx(vt,{className:"h-3 w-3 mr-1 animate-spin"}):K?null:G?a.jsx(Rn,{className:"h-3 w-3 mr-1"}):a.jsx(Uv,{className:"h-3 w-3 mr-1"}),Mg[A],K&&" â"]},A)})}),(!s||!o)&&a.jsxs("p",{className:"text-xs text-destructive mt-1",children:[s?"":"Contact has no email address. ",o?"":"Coach has no email address."]})]}),B.filter(A=>A.status==="sent").length>0&&a.jsxs("div",{children:[a.jsx("span",{className:"text-xs text-muted-foreground font-medium uppercase tracking-wider",children:"Sent Emails"}),a.jsx("div",{className:"space-y-2 mt-1",children:B.filter(A=>A.status==="sent").sort((A,K)=>(A.sent_at??"").localeCompare(K.sent_at??"")).map(A=>a.jsxs("details",{className:"border rounded-md bg-muted/20",children:[a.jsxs("summary",{className:"flex items-center gap-2 px-3 py-1.5 cursor-pointer text-sm hover:bg-muted/40",children:[a.jsx(fs,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),a.jsx("span",{className:"font-medium truncate flex-1",children:A.subject||Mg[A.email_type]}),a.jsx(Ge,{variant:"secondary",className:"text-[10px] px-1.5 py-0 flex-shrink-0",children:Mg[A.email_type]}),A.sent_at&&a.jsx("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:Ye(new Date(A.sent_at),"MMM d, h:mm a")})]}),a.jsx("div",{className:"px-3 pb-3 pt-1 border-t",children:a.jsx("p",{className:"text-sm whitespace-pre-wrap text-muted-foreground",children:A.body_text})})]},A.id))})]})]})]},$.id)}),!C&&k.length===0&&a.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No sessions recorded yet."})]})]})}),a.jsx(Dt,{open:!!j,onOpenChange:$=>{$||_(null)},children:a.jsxs(Pt,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsxs(At,{children:["Review ",j?Mg[j.emailType]:""," â ",r]})}),j&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground font-medium",children:"Subject"}),a.jsx(ce,{value:j.subject,onChange:$=>_({...j,subject:$.target.value})})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground font-medium",children:"Body"}),a.jsx(qt,{value:j.body,onChange:$=>_({...j,body:$.target.value}),rows:12})]}),a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Will be sent from ",a.jsxs("strong",{children:[i," <",o,">"]})," to ",a.jsx("strong",{children:s})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>_(null),children:"Cancel"}),a.jsxs(Y,{size:"sm",disabled:!j.subject||!j.body||q.isPending,onClick:()=>q.mutate(),children:[a.jsx(cC,{className:"h-4 w-4 mr-1"}),q.isPending?"Sendingâ¦":"Send Email"]})]})]})]})})]})}function xhe(e){return Ee({queryKey:["coaching-payments",e],enabled:!!e,queryFn:async()=>{const{data:t,error:n}=await F.from("coaching_payments").select("id, coaching_id, amount, note, payment_method, recorded_at").eq("coaching_id",e).order("recorded_at",{ascending:!1});if(n)throw n;return t||[]}})}function yhe({coachingId:e,amountPaid:t}){const n=at(),{toast:r}=mt(),{data:s=[],isLoading:i}=xhe(e),[o,l]=y.useState(null),[c,u]=y.useState(""),[d,h]=y.useState(""),[m,f]=y.useState(""),[x,g]=y.useState(""),p=()=>{n.invalidateQueries({queryKey:["coaching-payments",e]}),n.invalidateQueries({queryKey:["coaching-list"]})},v=async _=>{if(_===0)return;const{data:S,error:P}=await F.from("contact_coaching").select("amount_paid").eq("id",e).single();if(P)throw P;const{error:k}=await F.from("contact_coaching").update({amount_paid:Number(S.amount_paid||0)+_}).eq("id",e);if(k)throw k},b=Me({mutationFn:async _=>{const S=Number(c)||0,P=S-Number(_.amount),{error:k}=await F.from("coaching_payments").update({amount:S,note:d||null,payment_method:x||null,recorded_at:m?new Date(m+"T12:00:00").toISOString():_.recorded_at}).eq("id",_.id);if(k)throw k;await v(P)},onSuccess:()=>{p(),l(null),r({title:"Payment updated"})},onError:_=>r({title:"Error",description:_.message,variant:"destructive"})}),w=Me({mutationFn:async _=>{const{error:S}=await F.from("coaching_payments").delete().eq("id",_.id);if(S)throw S;await v(-Number(_.amount))},onSuccess:()=>{p(),r({title:"Payment deleted"})},onError:_=>r({title:"Error",description:_.message,variant:"destructive"})}),N=s.reduce((_,S)=>_+Number(S.amount),0),j=Math.abs(N-Number(t||0))>.01;return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h4",{className:"text-xs font-medium text-foreground",children:"Payments recorded"}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["Total $",N.toLocaleStr
840ing(void 0,{minimumFractionDigits:2})]})]}),j&&a.jsxs("p",{className:"text-[11px] text-amber-600",children:["Ledger total differs from the recorded paid amount of $",Number(t||0).toLocaleString(void 0,{minimumFractionDigits:2}),"."]}),i?a.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-2",children:[a.jsx(vt,{className:"h-3.5 w-3.5 animate-spin"})," Loading paymentsâ¦"]}):s.length===0?a.jsx("p",{className:"text-xs text-muted-foreground",children:"No individual payments recorded yet."}):a.jsx("div",{className:"space-y-1.5 max-h-56 overflow-y-auto pr-1",children:s.map(_=>a.jsx("div",{className:"flex items-center justify-between gap-2 text-xs rounded-md border border-border bg-background px-2.5 py-1.5",children:o===_.id?a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 w-full",children:[a.jsxs("div",{className:"relative w-20",children:[a.jsx("span",{className:"absolute left-1.5 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:"$"}),a.jsx(ce,{type:"text",inputMode:"decimal",value:c,onChange:S=>u(S.target.value),className:"h-6 text-[10px] pl-4 pr-1"})]}),a.jsxs("select",{value:x,onChange:S=>g(S.target.value),className:"h-6 text-[10px] rounded-md border border-input bg-background px-1.5",children:[a.jsx("option",{value:"",children:"Methodâ¦"}),a.jsx("option",{value:"Stripe",children:"Stripe"}),a.jsx("option",{value:"Check",children:"Check"}),a.jsx("option",{value:"Other",children:"Other"})]}),a.jsx(ce,{type:"text",value:d,onChange:S=>h(S.target.value),placeholder:"Noteâ¦",className:"h-6 text-[10px] flex-1 min-w-[60px]"}),a.jsx(ce,{type:"date",value:m,onChange:S=>f(S.target.value),className:"h-6 text-[10px] w-[110px]"}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",disabled:b.isPending,onClick:()=>b.mutate(_),children:a.jsx(On,{className:"h-3 w-3 text-emerald-600"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>l(null),children:a.jsx(Ht,{className:"h-3 w-3"})})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsxs("span",{className:"font-medium text-foreground",children:["$",Number(_.amount).toLocaleString(void 0,{minimumFractionDigits:2})]}),a.jsx(Ge,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:_.payment_method||"Manual"}),_.note&&a.jsx("span",{className:"text-muted-foreground truncate text-[10px] italic",children:_.note}),a.jsxs("span",{className:"text-muted-foreground flex items-center gap-0.5 text-[10px] whitespace-nowrap",children:[a.jsx(Kx,{className:"h-2.5 w-2.5"}),Ye(new Date(_.recorded_at),"MMM d, yyyy")]})]}),a.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{l(_.id),u(String(_.amount)),h(_.note||""),f(Ye(new Date(_.recorded_at),"yyyy-MM-dd")),g(_.payment_method||"")},children:a.jsx(Rn,{className:"h-3 w-3 text-muted-foreground"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-5 w-5",disabled:w.isPending,onClick:()=>w.mutate(_),children:a.jsx(pn,{className:"h-3 w-3 text-destructive"})})]})]})},_.id))})]})}function W8(){return Ee({queryKey:["coaching-addon-catalog"],queryFn:async()=>{const{data:e,error:t}=await F.from("coaching_addon_catalog").select("id, name, description, default_price, active").order("sort_order",{ascending:!0}).order("name",{ascending:!0});if(t)throw t;return e??[]}})}function vhe({open:e,onOpenChange:t}){const{toast:n}=mt(),r=at(),{data:s=[]}=W8(),[i,o]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState(""),h=()=>{r.invalidateQueries({queryKey:["coaching-addon-catalog"]})},m=Me({mutationFn:async()=>{const{error:x}=await F.from("coaching_addon_catalog").insert({name:i.trim(),description:l.trim()||null,default_price:u?Number(u):0});if(x)throw x},onSuccess:()=>{o(""),c(""),d(""),h(),n({title:"Add-on added to catalog"})},onError:x=>n({title:"Error",description:x.message,variant:"destructive"})}),f=Me({mutationFn:async x=>{const{error:g}=await F.from("coaching_addon_catalog").delete().eq("id",x);if(g)throw g},onSuccess:()=>{h(),n({title:"Add-on removed"})},onError:x=>n({title:"Error",description:x.message,variant:"destructive"})});return a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsx(At,{children:"Coaching Add-on Catalog"})}),a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"Reusable add-ons (e.g. 360 Assessment) you can apply to any coaching engagement."}),a.jsxs("div",{className:"space-y-1",children:[s.length===0&&a.jsx("p",{className:"text-sm text-muted-foreground",children:"No catalog add-ons yet."}),s.map(x=>a.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border py-2 last:border-0",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("p",{className:"text-sm font-medium truncate",children:x.name}),x.description&&a.jsx("p",{className:"text-xs text-muted-foreground truncate",children:x.description})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsxs("span",{className:"text-sm",children:["$",Number(x.default_price).toLocaleStr
840ing()]}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>f.mutate(x.id),children:a.jsx(pn,{className:"h-4 w-4 text-destructive"})})]})]},x.id))]}),a.jsxs("div",{className:"grid grid-cols-[1fr_1fr_7rem_auto] gap-2 items-end",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Name"}),a.jsx(ce,{value:i,onChange:x=>o(x.target.value),placeholder:"360 Assessment"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Description"}),a.jsx(ce,{value:l,onChange:x=>c(x.target.value),placeholder:"Optional"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Price"}),a.jsx(ce,{type:"number",min:"0",step:"0.01",value:u,onChange:x=>d(x.target.value),placeholder:"0.00"})]}),a.jsx(Y,{size:"sm",disabled:!i.trim()||m.isPending,onClick:()=>m.mutate(),children:a.jsx(zt,{className:"h-4 w-4"})})]})]})]})})}function bhe(e){return Ee({queryKey:["coaching-addons",e],enabled:!!e,queryFn:async()=>{const{data:t,error:n}=await F.from("coaching_addons").select("id, coaching_id, catalog_id, name, description, price, third_party_payer").eq("coaching_id",e).order("sort_order",{ascending:!0}).order("created_at",{ascending:!0});if(n)throw n;return t??[]}})}function whe({coachingId:e}){const{toast:t}=mt(),n=at(),{data:r=[]}=bhe(e),{data:s=[]}=W8(),[i,o]=y.useState(!1),[l,c]=y.useState("custom"),[u,d]=y.useState(""),[h,m]=y.useState(""),f=()=>{n.invalidateQueries({queryKey:["coaching-addons",e]}),n.invalidateQueries({queryKey:["coaching-list"]}),n.invalidateQueries({queryKey:["forecast"]}),n.invalidateQueries({queryKey:["forecast_month_detail"]})},x=Me({mutationFn:async()=>{const N=s.find(_=>_.id===l),{error:j}=await F.from("coaching_addons").insert({coaching_id:e,catalog_id:N?N.id:null,name:(N?N.name:u).trim(),description:(N==null?void 0:N.description)??null,price:Number(h!==""?h:(N==null?void 0:N.default_price)??0)});if(j)throw j},onSuccess:()=>{c("custom"),d(""),m(""),f(),t({title:"Add-on added"})},onError:N=>t({title:"Error",description:N.message,variant:"destructive"})}),g=Me({mutationFn:async({id:N,patch:j})=>{const{error:_}=await F.from("coaching_addons").update(j).eq("id",N);if(_)throw _},onSuccess:f,onError:N=>t({title:"Error",description:N.message,variant:"destructive"})}),p=Me({mutationFn:async N=>{const{error:j}=await F.from("coaching_addons").delete().eq("id",N);if(j)throw j},onSuccess:()=>{f(),t({title:"Add-on removed"})},onError:N=>t({title:"Error",description:N.message,variant:"destructive"})}),v=r.filter(N=>!N.third_party_payer).reduce((N,j)=>N+Number(j.price||0),0),b=s.find(N=>N.id===l),w=!!e&&(b?!0:!!u.trim());return a.jsxs("div",{className:"space-y-2 rounded-md border border-border p-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-xs font-medium",children:"Add-ons"}),a.jsxs(Y,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>o(!0),children:[a.jsx(gH,{className:"h-3.5 w-3.5 mr-1"})," Catalog"]})]}),!e&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"Save the engagement first, then add itemized add-ons."}),e&&a.jsxs(a.Fragment,{children:[r.length===0&&a.jsx("p",{className:"text-xs text-muted-foreground",children:"No add-ons on this engagement."}),r.map(N=>a.jsxs("div",{className:"flex items-center gap-2 border-b border-border py-2 last:border-0",children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"text-sm truncate",children:N.name}),N.description&&a.jsx("p",{className:"text-xs text-muted-foreground truncate",children:N.description})]}),a.jsxs("div",{className:"relative w-24 shrink-0",children:[a.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:"$"}),a.jsx(ce,{type:"number",min:"0",step:"0.01",className:"h-8 pl-5 text-sm",defaultValue:String(N.price??0),onBlur:j=>{const _=j.target.value===""?0:Number(j.target.value);_!==Number(N.price)&&g.mutate({id:N.id,patch:{price:_}})}})]}),a.jsxs("label",{className:"flex items-center gap-1 text-[11px] text-muted-foreground shrink-0",children:[a.jsx(gt,{checked:N.third_party_payer,onCheckedChange:j=>g.mutate({id:N.id,patch:{third_party_payer:!!j}})}),"3rd party"]}),a.jsx(Y,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>p.mutate(N.id),children:a.jsx(pn,{className:"h-4 w-4 text-destructive"})})]},N.id)),a.jsxs("div",{className:"flex items-end gap-2 pt-1",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"text-[11px] text-muted-foreground",children:"Add from catalog"}),a.jsxs(lt,{value:l,onValueChange:N=>{c(N);const j=s.find(_=>_.id===N);j&&m(String(j.default_price??0))},children:[a.jsx(it,{className:"h-8 text-sm",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"custom",children:"Customâ¦"}),s.filter(N=>N.active).map(N=>a.jsx(Oe,{value:N.id,children:N.name},N.id))]})]})]}),l==="custom"&&a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("label",{className:"text-[11px] text-muted-foreground",children:"Name"}),a.jsx(ce,{className:"h-8 text-sm",value:u,onChange:N=>d(N.target.value),placeholder:"360 Assessment"})]}),a.jsxs("div",{className:"w-24 shrink-0",children:[a.jsx("label",{className:"text-[11px] text-muted-foreground",children:"Price"}),a.jsx(ce,{className:"h-8 text-sm",type:"number",min:"0",step:"0.01",value:h,onChange:N=>m(N.target.value),placeholder:"0.00"})]}),a.jsx(Y,{type:"button",size:"sm",className:"h-8",disabled:!w||x.isPending,onClick:()=>x.mutate(),children:a.jsx(zt,{className:"h-4 w-4"})})]}),v>0&&a.jsxs("p",{className:"text-xs text-muted-foreground pt-1",children:["Add-ons billed to client: ",a.jsxs("span",{className:"font-medium",children:["$",v.toLocaleStr
840ing()]})," â added to the engagement total."]})]}),a.jsx(vhe,{open:i,onOpenChange:o})]})}function _he(){const[e,t]=y.useState("current"),[n,r]=y.useState("all"),[s,i]=y.useState(""),[o,l]=y.useState("all"),c=Zv(),u=at(),{toast:d}=mt(),{data:h=[]}=ps(),{data:m=[]}=po(),f=ok(m),[x,g]=y.useState(null),[p,v]=y.useState(""),[b,w]=y.useState(null),[N,j]=y.useState(null),[_,S]=y.useState(""),[P,k]=y.useState(""),[C,T]=y.useState(""),[O,L]=y.useState(""),[E,R]=y.useState(null),[q,I]=y.useState(!1),[$,M]=y.useState(null),[B,W]=y.useState(!1),[A,K]=y.useState(null),[G,H]=y.useState(""),[fe,te]=y.useState(!1),[J,re]=y.useState(""),[pe,ye]=y.useState(""),[X,he]=y.useState(""),[D,le]=y.useState(""),[V,U]=y.useState(""),[z,Z]=y.useState("recurring"),[ve,ee]=y.useState(""),[de,je]=y.useState("monthly"),[Q,oe]=y.useState(""),[Pe,ze]=y.useState([]),[Je,Ae]=y.useState(""),[et,Ne]=y.useState("95"),[be,Ue]=y.useState("0"),[Ze,nt]=y.useState(""),[rt,kt]=y.useState(""),[jt,Et]=y.useState(""),{data:Nt=[]}=Ee({queryKey:["summit-options"],queryFn:async()=>{const{data:ne,error:qe}=await F.from("experiences").select("id, name, public_name").eq("type","stakeholder_summit").order("target_start_date",{ascending:!1});if(qe)throw qe;return ne??[]}}),[ue,we]=y.useState("active"),{data:Ie=[]}=Ee({queryKey:["all-contacts-for-assignment"],queryFn:async()=>{const{data:ne,error:qe}=await F.rpc("get_all_contacts_for_assignment");if(qe)throw qe;return ne}}),se=()=>{W(!1),K(null),H(""),re(""),ye(""),he(""),le(""),U(""),Z("recurring"),ee(""),je("monthly"),oe(""),ze([]),Ae(""),Ne("95"),Ue("0"),nt(""),kt(""),we("active")},ge=ne=>{var Ve;K(ne.id),H(ne.contactId),re(ne.coachEmail?((Ve=h.find(Lt=>Lt.email===ne.coachEmail))==null?void 0:Ve.id)??"":""),ye(ne.startDate??""),he(ne.endDate??""),le(ne.notes??""),U(ne.basePrice!=null?String(ne.basePrice):ne.price!=null?String(ne.price):"");const qe=ne.scheduleType==="fixed"?"fixed":ne.scheduleType==="recurring"&&(!ne.paymentCount||ne.paymentCount<=1)?"one_time":"recurring";Z(qe),ee(ne.paymentCount?String(ne.paymentCount):""),je(ne.paymentFrequency??"monthly"),oe(ne.priceDueDate??""),ze((ne.fixedPayments??[]).map(Lt=>({date:Lt.date,amount:String(Lt.amount)}))),Ae(ne.experienceId??""),Ne(String(ne.pctPaidToDelivery??95)),Ue(String(ne.pctSalesCommission??0)),nt(ne.commissionGeneratorId??""),kt(ne.originatingSummitId??""),Et(ne.referredBy??""),we(ne.status??"active"),W(!0)},$e=Me({mutationFn:async()=>{const ne={contact_id:G,start_date:pe,end_date:X||null,generator_id:J&&J!=="none"?J:null,notes:D.trim()||null,base_price:V?Number(V):null,schedule_type:z==="one_time"?"recurring":z,payment_count:z==="one_time"?1:z==="recurring"&&ve?Number(ve):null,payment_frequency:z==="recurring"&&ve&&Number(ve)>=2?de:null,price_due_date:(z==="one_time"||z==="recurring")&&Q||null,fixed_payments:z==="fixed"?Pe.filter(qe=>qe.date&&qe.amount).map(qe=>({date:qe.date,amount:Number(qe.amount)})):[],experience_id:Je&&Je!=="all"?Je:null,pct_paid_to_delivery:et===""?0:Number(et),pct_sales_commission:be===""?0:Number(be),commission_generator_id:Ze&&Ze!=="none"?Ze:null,originating_summit_id:rt&&rt!=="none"?rt:null,...jt&&jt!=="none"?{referred_by:jt}:A?{referred_by:null}:{},status:ue};if(A){const{error:qe}=await F.from("contact_coaching").update(ne).eq("id",A);if(qe)throw qe}else{const{error:qe}=await F.from("contact_coaching").insert(ne);if(qe)throw qe}},onSuccess:()=>{u.invalidateQueries({queryKey:["coaching-list"]});const ne=!!A;se(),d({title:ne?"Coaching updated":"Coaching added"})},onError:ne=>d({title:"Error",description:ne.message,variant:"destructive"})}),Ke=Me({mutationFn:async ne=>{const{error:qe}=await F.from("contact_coaching").delete().eq("id",ne);if(qe)throw qe},onSuccess:()=>{u.invalidateQueries({queryKey:["coaching-list"]}),d({title:"Coaching deleted"})},onError:ne=>d({title:"Error",description:ne.message,variant:"destructive"})}),{data:Qe=[],isLoading:He}=Ee({queryKey:["coaching-list"],queryFn:async()=>{const{data:ne,error:qe}=await F.from("contact_coaching").select("id, contact_id, generator_id, start_date, end_date, price, base_price, amount_paid, price_paid, public_token, notes, schedule_type, payment_count, payment_frequency, price_due_date, fixed_payments, experience_id, status, pct_paid_to_delivery, pct_sales_commission, commission_generator_id, originating_summit_id, referred_by, collected_to_date, is_closed, contacts!contact_coaching_contact_id_fkey(id, name, email, last_viewed_at), generators!contact_coaching_generator_id_fkey(id, name, email), experiences!contact_coaching_experience_id_fkey(id, name, public_name, target_start_date)");if(qe)throw qe;return(ne??[]).map(Ve=>{var Lt,nr,Nn,gr,Ha,vs,ei,Il;return{id:Ve.id,contactId:Ve.contact_id,contactName:((Lt=Ve.contacts)==null?void 0:Lt.name)??"Unknown",contactEmail:((nr=Ve.contacts)==null?void 0:nr.email)??null,lastViewedAt:((Nn=Ve.contacts)==null?void 0:Nn.last_viewed_at)??null,coachId:Ve.generator_id,coachName:((gr=Ve.generators)==null?void 0:gr.name)??"â",coachEmail:((H
840a=Ve.generators)==null?void 0:Ha.email)??null,startDate:Ve.start_date,endDate:Ve.end_date,price:Ve.price,basePrice:Ve.base_price,amountPaid:Ve.amount_paid,pricePaid:Ve.price_paid,publicToken:Ve.public_token,notes:Ve.notes,scheduleType:Ve.schedule_type??"recurring",paymentCount:Ve.payment_count,paymentFrequency:Ve.payment_frequency,priceDueDate:Ve.price_due_date,fixedPayments:Ve.fixed_payments??[],experienceId:Ve.experience_id??null,experienceName:((vs=Ve.experiences)==null?void 0:vs.public_name)||((ei=Ve.experiences)==null?void 0:ei.name)||null,experienceStartDate:((Il=Ve.experiences)==null?void 0:Il.target_start_date)??null,status:Ve.status??"active",pctPaidToDelivery:Ve.pct_paid_to_delivery!=null?Number(Ve.pct_paid_to_delivery):95,pctSalesCommission:Ve.pct_sales_commission!=null?Number(Ve.pct_sales_commission):0,commissionGeneratorId:Ve.commission_generator_id??null,originatingSummitId:Ve.originating_summit_id??null,referredBy:Ve.referred_by??null,collectedToDate:Ve.collected_to_date!=null?Number(Ve.collected_to_date):null,isClosed:!!Ve.is_closed}})}}),Tt=new Date().toISOString().slice(0,10),fn=s.trim().toLowerCase(),_e=[...Qe.filter(ne=>{var qe;if(e==="current"&&ne.endDate&&ne.endDate<Tt||e==="past"&&(!ne.endDate||ne.endDate>=Tt))return!1;if(n&&n!=="all"){if(n==="any_experience"){if(!ne.experienceId)return!1}else if(ne.experienceId!==n)return!1}return!(o!=="all"&&ne.coachId!==o||fn&&!(ne.contactName.toLowerCase().includes(fn)||(((qe=ne.contactEmail)==null?void 0:qe.toLowerCase().includes(fn))??!1)))})].sort((ne,qe)=>{if(ne.lastViewedAt&&qe.lastViewedAt){const Ve=qe.lastViewedAt.localeCompare(ne.lastViewedAt);if(Ve!==0)return Ve}else{if(ne.lastViewedAt)return-1;if(qe.lastViewedAt)return 1}return ne.contactName.localeCompare(qe.contactName)}),It=Me({mutationFn:async({id:ne,notes:qe})=>{const{error:Ve}=await F.from("contact_coaching").update({notes:qe.trim()||null}).eq("id",ne);if(Ve)throw Ve},onSuccess:()=>{u.invalidateQueries({queryKey:["coaching-list"]}),g(null),d({title:"Notes saved"})},onError:ne=>d({title:"Error",description:ne.message,variant:"destructive"})}),nn=Me({mutationFn:async({id:ne,amount:qe,pricePaid:Ve,currentAmountPaid:Lt,method:nr,note:Nn,recordedAt:gr})=>{const Ha={amount_paid:Lt+qe};Ve&&(Ha.price_paid=!0);const{error:vs}=await F.from("contact_coaching").update(Ha).eq("id",ne);if(vs)throw vs;if(qe!==0){const{error:ei}=await F.from("coaching_payments").insert({coaching_id:ne,amount:qe,payment_method:nr||null,note:Nn.trim()||null,recorded_at:gr?new Date(gr+"T12:00:00").toISOString():new Date().toISOString()});if(ei)throw ei}},onSuccess:(ne,qe)=>{u.invalidateQueries({queryKey:["coaching-list"]}
840),u.invalidateQueries({queryKey:["coaching-payments",qe.id]}),u.invalidateQueries({queryKey:["forecast"]}),u.invalidateQueries({queryKey:["forecast_month_detail"]}),j(null),S(""),k(""),T(""),L(""),d({title:"Payment recorded"})},onError:ne=>d({title:"Error",description:ne.message,variant:"destructive"})}),tn=Me({mutationFn:async({id:ne,collectedToDate:qe,isClosed:Ve})=>{const{error:Lt}=await F.from("contact_coaching").update({collected_to_date:null,is_closed:Ve}).eq("id",ne);if(Lt)throw Lt},onSuccess:()=>{u.invalidateQueries({queryKey:["coaching-list"]}),u.invalidateQueries({queryKey:["forecast"]}),u.invalidateQueries({queryKey:["forecast_month_detail"]}),R(null),d({title:"Saved"})},onError:ne=>d({title:"Error",description:ne.message,variant:"destructive"})}),Zt=ne=>{const qe=`${window.location.origin}/public-coaching?token=${ne}`;navigator.clipboard.writeText(qe),d({title:"Coaching link copied to clipboard"})},Ce=ne=>ne.pricePaid?a.jsx(Ge,{variant:"default",className:"text-[11px]",children:"Paid"}):ne.price&&ne.amountPaid>0?a.jsxs(Ge,{variant:"secondary",className:"text-[11px]",children:["$",ne.amountPaid," / $",ne.price]}):ne.price?a.jsx(Ge,{variant:"outline",className:"text-[11px]",children:"Unpaid"}):a.jsx("span",{className:"text-muted-foreground text-xs",children:"â"}),ut=ne=>{if(!ne.price)return null;if(ne.scheduleType==="fixed"&&ne.fixedPayments.length>0)return ne.fixedPayments.map((qe,Ve)=>a.jsxs("div",{className:"flex justify-between text-sm py-1 border-b border-border last:border-0",children:[a.jsx("span",{children:qe.date?Ye(new Date(qe.date+"T00:00:00"),"MMM d, yyyy"):"No date"}),a.jsxs("span",{className:"font-medium",children:["$",Number(qe.amount).toLocaleString()]})]},Ve));if(ne.scheduleType==="recurring"&&ne.paymentCount&&ne.paymentCount>=2&&ne.price){const qe=(Number(ne.price)/ne.paymentCount).toFixed(2);return a.jsxs("div",{className:"text-sm space-y-1",children:[a.jsxs("p",{children:[ne.paymentCount," payments of ",a.jsxs("span",{className:"font-medium",children:["$",qe]})]}),a.jsxs("p",{className:"text-muted-foreground",children:["Frequency: ",ne.paymentFrequency==="quarterly"?"Quarterly":"Monthly"]}),ne.priceDueDate&&a.jsxs("p",{className:"text-muted-foreground",children:["First due: ",Ye(new Date(ne.priceDueDate+"T00:00:00"),"MMM d, yyyy")]})]})}return a.jsxs("div",{className:"text-sm",children:[a.jsxs("p",{children:["Total: ",a.jsxs("span",{className:"font-medium",children:["$",Number(ne.price).toLocaleString()]})]}),ne.priceDueDate&&a.jsxs("p",{className:"text-muted-foreground",children:["Due: ",Ye(new Date(ne.priceDueDate+"T00:00:00"),"MMM d, yyyy")]})]})};return a.jsxs(Rr,{children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h1",{className:"text-2xl font-bold font-display",children:"Coaching"}),a.jsxs(Y,{size:"sm",onClick:()=>W(!0),children:[a.jsx(zt,{className:"h-4 w-4 mr-1"})," Add Coaching"]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.jsx(Pk,{value:e,onValueChange:ne=>t(ne),children:a.jsxs(Cb,{children:[a.jsx(Zr,{value:"current",children:"Current"}),a.jsx(Zr,{value:"past",children:"Past"}),a.jsx(Zr,{value:"all",children:"All"})]})}),a.jsxs("div",{className:"relative",children:[a.jsx(Bv,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),a.jsx(ce,{placeholder:"Search contactsâ¦",value:s,onChange:ne=>i(ne.target.value),className:"pl-8 w-56 h-9 text-sm"})]}),a.jsxs(lt,{value:o,onValueChange:l,children:[a.jsx(it,{className:"w-44 h-9 text-xs",children:a.jsx(ct,{placeholder:"All Coaches"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"all",className:"text-xs",children:"All Coaches"}),h.map(ne=>a.jsx(Oe,{value:ne.id,className:"text-xs",children:ne.name},ne.id))]})]}),a.jsx(Kt,{value:n,onValueChange:r,options:f,placeholder:"All Experiences",className:"w-44 h-9 text-xs"})]}),He?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):_e.length===0?a.jsx("p",{className:"text-sm text-muted-foreground",children:"No coaching records found."}):a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Contact"}),a.jsx(Le,{children:"Coach"}),a.jsx(Le,{children:"Experience"}),a.jsx(Le,{children:"Start Date"}),a.jsx(Le,{children:"End Date"}),a.jsx(Le,{children:"Status"}),a.jsx(Le,{children:"Payment"}),a.jsx(Le,{children:"% Delivery"}),a.jsx(Le,{children:"% Commission"}),a.jsx(Le,{className:"w-10"})]})}),a.jsx(Bn,{children:_e.map(ne=>a.jsxs(yt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>ge(ne),children:[a.jsx(Te,{className:"font-medium",children:a.jsx("button",{type:"button",className:"text-left hover:underline text-primary",onClick:qe=>{qe.stopPropagation(),c(`/contacts?contact=${ne.contactId}`)},children:ne.contactName})}),a.jsx(Te,{children:ne.coachName}),a.jsx(Te,{children:ne.experienceName?a.jsx("span",{className:"text-xs",children:oo(ne.experienceName,ne.experienceStartDate)}):a.jsx("span",{className:"text-muted-foreground text-xs",children:"â"})}),a.jsx(Te,{children:Ye(new Date(ne.startDate+"T00:00:00"),"MMM d, yyyy")}),a.jsx(Te,{children:ne.endDate?Ye(new Date(ne.endDate+"T00:00:00"),"MMM d, yyyy"):"â"}),a.jsx(Te,{children:a.jsx(Ge,{variant:ne.status==="completed"?"secondary":"default",className:"text-[11px] capitalize",children:ne.status})}),a.jsx(Te,{children:Ce(ne)}),a.jsxs(Te,{className:"text-xs text-muted-foreground",children:[ne.pctPaidToDelivery,"%"]}),a.jsxs(Te,{className:"text-xs text-muted-foreground",children:[ne.pctSalesCommission,"%"]}),a.jsx(Te,{children:a.jsxs(pk,{children:[a.jsx(gk,{asChild:!0,children:a.jsx(Y,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:qe=>
840qe.stopPropagation(),children:a.jsx(eH,{className:"h-4 w-4"})})}),a.jsxs(jb,{align:"end",onClick:qe=>qe.stopPropagation(),children:[a.jsxs(Os,{onClick:()=>ge(ne),children:[a.jsx(Rn,{className:"h-4 w-4 mr-2"})," Edit"]}),a.jsxs(Os,{onClick:()=>M(ne),children:[a.jsx(L3,{className:"h-4 w-4 mr-2"})," Sessions & Follow-ups"]}),a.jsxs(Os,{onClick:()=>{v(ne.notes??""),g(ne)},children:[a.jsx(Hs,{className:"h-4 w-4 mr-2"})," Comments"]}),ne.price!=null&&a.jsxs(Os,{onClick:()=>w(ne),children:[a.jsx(rs,{className:"h-4 w-4 mr-2"})," Payment Schedule"]}),ne.price!=null&&a.jsxs(Os,{onClick:()=>{S(""),j(ne)},children:[a.jsx(Hi,{className:"h-4 w-4 mr-2"})," Record Payment"]}),ne.price!=null&&a.jsxs(Os,{onClick:()=>{I(!!ne.isClosed),R(ne)},children:[a.jsx(Hi,{className:"h-4 w-4 mr-2"})," Close Out"]}),a.jsxs(Os,{onClick:()=>Zt(ne.publicToken),children:[a.jsx(Nl,{className:"h-4 w-4 mr-2"})," Copy Invoice Page"]}),a.jsxs(Os,{className:"text-destructive focus:text-destructive",onClick:()=>{confirm(`Permanently delete coaching for ${ne.contactName}? This cannot be undone and will remove all sessions and follow-up drafts.`)&&Ke.mutate(ne.id)},children:[a.jsx(pn,{className:"h-4 w-4 mr-2"})," Delete"]})]})]})})]},ne.id))})]})]}),a.jsx(Dt,{open:!!x,onOpenChange:ne=>{ne||g(null)},children:a.jsxs(Pt,{className:"sm:max-w-md",children:[a.jsx(Ot,{children:a.jsxs(At,{children:["Comments â ",x==null?void 0:x.contactName]})}),a.jsx(qt,{value:p,onChange:ne=>v(ne.target.value),placeholder:"Add commentsâ¦",rows:5}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>g(null),children:"Cancel"}),a.jsx(Y,{size:"sm",disabled:It.isPending,onClick:()=>x&&It.mutate({id:x.id,notes:p}),children:"Save"})]})]})}),a.jsx(Dt,{open:!!b,onOpenChange:ne=>{ne||w(null)},children:a.jsxs(Pt,{className:"sm:max-w-md",children:[a.jsx(Ot,{children:a.jsxs(At,{children:["Payment Schedule â ",b==null?void 0:b.contactName]})}),a.jsx("div",{className:"space-y-2",children:b&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Total Price"}),a.jsxs("span",{className:"font-medium",children:["$",Number(b.price).toLocaleString()]})]}),a.jsxs("div",{className:"flex justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Amount Paid"}),a.jsxs("span",{className:"font-medium",children:["$",Number(b.amountPaid).toLocaleString()]})]}),Number(b.price)-b.amountPaid>0&&a.jsxs("div",{className:"flex justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Remaining"}),a.jsxs("span",{className:"font-medium text-destructive",children:["$",(Number(b.price)-b.amountPaid).toLocaleString()]})]}),a.jsx("hr",{className:"border-border"}),a.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-1",children:"Schedule"}),ut(b)??a.jsx("p",{className:"text-sm text-muted-foreground",children:"No payment schedule configured."})]})})]})}),a.jsx(Dt,{open:!!E,onOpenChange:ne=>{ne||R(null)},children:a.jsxs(Pt,{className:"sm:max-w-sm",children:[a.jsx(Ot,{children:a.jsxs(At,{children:["Close out â ",E==null?void 0:E.contactName]})}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-xs text-muted-foreground",children:"The forecast uses recorded payments on this engagement, so the remaining balance rolls forward automatically. Close it out when no further revenue is expected â that removes its revenue, delivery cost, and commission from the forecast."}),(E==null?void 0:E.price)!=null&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Price $",Number(E.price).toLocaleString()," · Recorded payments $",Number(E.amountPaid||0).toLocaleString()]}),a.jsxs("label",{className:"inline-flex items-center gap-2 text-sm cursor-pointer",children:[a.jsx(gt,{checked:q,onCheckedChange:ne=>I(ne===!0)}),"Closed â exclude from forecast"]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>R(null),children:"Cancel"}),a.jsx(Y,{size:"sm",disabled:tn.isPending,onClick:()=>{E&&tn.mutate({id:E.id,collectedToDate:null,isClosed:q})},children:"Save"})]})]})]})}),a.jsx(Dt,{open:!!N,onOpenChange:ne=>{ne||j(null)},children:a.jsxs(Pt,{className:"sm:max-w-lg",children:[a.jsx(Ot,{children:a.jsxs(At,{children:["Payments â ",N==null?void 0:N.contactName]})}),a.jsxs("div",{className:"space-y-3",children:[N&&a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Paid $",N.amountPaid.toLocaleStr
840ing()," of $",Number(N.price||0).toLocaleString()," â $",(Number(N.price)-N.amountPaid).toLocaleString()," remaining"]}),N&&a.jsx(yhe,{coachingId:N.id,amountPaid:N.amountPaid}),a.jsxs("div",{className:"border-t border-border pt-3 space-y-2",children:[a.jsx("h4",{className:"text-xs font-medium",children:"Record a new payment"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"$"}),a.jsx(ce,{type:"number",min:"0",step:"0.01",placeholder:"0.00",value:_,onChange:ne=>S(ne.target.value),className:"pl-7 h-8 text-sm"})]}),a.jsxs("select",{value:P,onChange:ne=>k(ne.target.value),className:"h-8 text-sm rounded-md border border-input bg-background px-2",children:[a.jsx("option",{value:"",children:"Methodâ¦"}),a.jsx("option",{value:"Stripe",children:"Stripe"}),a.jsx("option",{value:"Check",children:"Check"}),a.jsx("option",{value:"Other",children:"Other"})]}),a.jsx(ce,{type:"date",value:O,onChange:ne=>L(ne.target.value),className:"h-8 text-sm w-[140px]"})]}),a.jsx(ce,{type:"text",placeholder:"Note (optional)",value:C,onChange:ne=>T(ne.target.value),className:"h-8 text-sm"})]}),(N==null?void 0:N.price)!=null&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Marked ",a.jsx("strong",{children:"Paid"})," automatically once recorded payments reach $",Number(N.price).toLocaleString(),"."]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Y,{variant:"ghost",size:"sm",onClick:()=>j(null),children:"Close"}),a.jsx(Y,{size:"sm",disabled:!_||Number(_)===0||nn.isPending,onClick:()=>N&&nn.mutate({id:N.id,amount:Number(_)||0,pricePaid:!1,currentAmountPaid:N.amountPaid,method:P,note:C,recordedAt:O}),children:"Record"})]})]})]})}),a.jsx(Dt,{open:B,onOpenChange:ne=>{ne||se()},children:a.jsxs(Pt,{className:"sm:max-w-md max-h-[90vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsx(At,{children:A?"Edit Coaching":"Add Coaching"})}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Contact *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("div",{className:"flex-1",children:a.jsx(Kt,{value:G,onValueChange:H,options:Ie.map(ne=>({value:ne.id,label:ne.name})),placeholder:"Select contactâ¦"})}),a.jsx(Y,{type:"button",variant:"outline",size:"icon",title:"Quick add contact",onClick:()=>te(!0),children:a.jsx(dx,{className:"h-4 w-4"})})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Start Date *"}),a.jsx(ce,{type:"date",value:pe,onChange:ne=>ye(ne.target.value)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"End Date"}),a.jsx(ce,{type:"date",value:X,onChange:ne=>he(ne.target.value)})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Coach"}),a.jsx(Kt,{value:J,onValueChange:re,options:h.map(ne=>({value:ne.id,label:ne.name})),placeholder:"Select coachâ¦",allowNone:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Experience"}),a.jsx(Kt,{value:Je,onValueChange:Ae,options:f,placeholder:"None",className:"w-full"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Comments"}),a.jsx(ce,{value:D,onChange:ne=>le(ne.target.value),placeholder:"Optional commentsâ¦"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Base Amount"}),a.jsxs("div",{className:"relative",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"$"}),a.jsx(ce,{type:"number",min:"0",step:"0.01",value:V,onChange:ne=>U(ne.target.value),className:"pl-7",placeholder:"0.00"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Schedule Type"}),a.jsxs(lt,{value:z,onValueChange:ne=>Z(ne),children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"one_time",children:"One-time"}),a.jsx(Oe,{value:"recurring",children:"Recurring"}),a.jsx(Oe,{value:"fixed",children:"Fixed Dates"})]})]})]})]}),a.jsx(whe,{coachingId:A}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"% Paid to Delivery"}),a.jsxs("div",{className:"relative",children:[a.jsx(ce,{type:"number",min:"0",max:"100",step:"1",value:et,onChange:ne=>Ne(ne.target.value),className:"pr-7",placeholder:"95"}),a.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"%"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"% Sales Commission"}),a.jsxs("div",{className:"relative",children:[a.jsx(ce,{type:"number",min:"0",max:"100",step:"1",value:be,onChange:ne=>Ue(ne.target.value),className:"pr-7",placeholder:"0"}),a.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"%"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Commission Recipient"}),a.jsx(Kt,{value:Ze,onValueChange:nt,options:h.map(ne=>({value:ne.id,label:ne.name})),placeholder:"Select team memberâ¦",allowNone:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Referred By"}),a.jsx(Kt,{value:jt,onValueChange:Et,options:Ie.filter(ne=>ne.id!==G).map(ne=>({value:ne.id,label:ne.name})),placeholder:"Optional â who referred themâ¦",allowNone:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Originating Summit"}),a.jsx(Kt,{value:rt,onValueChange:kt,options:Nt.map(ne=>({value:ne.id,label:ne.public_name||ne.name})),placeholder:"Optional â select a summitâ¦",allowNone:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Status"}),a.jsxs(lt,{value:ue,onValueChange:ne=>we(ne),children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"active",children:"Active"}),a.jsx(Oe,{value:"completed",children:"Completed"})]})]})]})]}),z==="one_time"&&a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Payment Date"}),a.jsx(ce,{type:"date",value:Q,onChange:ne=>oe(ne.target.value)}),a.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"Full total will be due on this date."})]}),z==="recurring"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Payment Count"}),a.jsx(ce,{type:"number",min:"0",value:ve,onChange:ne=>ee(ne.target.value),placeholder:"e.g. 4"})]}),ve&&Number(ve)>=2&&a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Frequency"}),a.jsxs(lt,{value:de,onValueChange:je,children:[a.jsx(it,{children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"monthly",children:"Monthly"}),a.jsx(Oe,{value:"quarterly",children:"Quarterly"})]})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:ve&&Number(ve)>=2?"First Payment Due":"Due Date"}),a.jsx(ce,{type:"date",value:Q,onChange:ne=>oe(ne.target.value)})]})]}),z==="fixed"&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-xs text-muted-foreground",children:"Fixed Payments"}),Pe.map((ne,qe)=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ce,{type:"date",value:ne.date,onChange:Ve=>{const Lt=[...Pe];Lt[qe]={...Lt[qe],date:Ve.target.value},ze(Lt)},className:"flex-1"}),a.jsxs("div",{className:"relative flex-1",children:[a.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"$"}),a.jsx(ce,{type:"number",min:"0",step:"0.01",value:ne.amount,onChange:Ve=>{const Lt=[...Pe];Lt[qe]={...Lt[qe],amount:Ve.target.value},ze(Lt)},className:"pl-7",placeholder:"0.00"})]}),a.jsx(Y,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>ze(Pe.filter((Ve,Lt)=>Lt!==qe)),children:"Ã"})]},qe)),a.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>ze([...Pe,{date:"",amount:""}]),children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add Payment"]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[a.jsx(Y,{variant:"ghost",size:"sm",onClick:se,children:"Cancel"}),a.jsx(Y,{size:"sm",disabled:!G||!pe||$e.isPending,onClick:()=>$e.mutate(),children:"Save"})]})]})]})}),$&&a.jsx(ghe,{open:!!$,onOpenChange:ne=>{ne||M(null)},coachingId:$.id,contactName:$.contactName,contactEmail:$.contactEmail,coachName:$.coachName,coachEmail:$.coachEmail}),a.jsx(vk,{open:fe,onOpenChange:te,onCreated:ne=>
840{u.invalidateQueries({queryKey:["all-contacts-for-assignment"]}),H(ne.id)}})]})}const ni=e=>e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),jhe=e=>e?new Date(e+"T00:00:00").toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"â",K8=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,MA={trip:"Trip",peer_group:"Peer Group",coaching:"Coaching"};function DA(e){var u;const{total:t,paid:n,count:r,freq:s,finalDue:i,fixed:o}=e;if(o&&o.length){let d=0;for(const h of[...o].sort((m,f)=>m.date.localeCompare(f.date)))if(d+=Number(h.amount)||0,n+.005<d)return h.date;return((u=o[o.length-1])==null?void 0:u.date)??i}if(!i)return null;if(!r||r<2)return i;const l=Math.round(t/r);let c=0;for(let d=0;d<r;d++)if(c+=d===r-1?t-l*(r-1):l,n+.005<c){const h=new Date(i+"T00:00:00");return h.setMonth(h.getMonth()-(r-1-d)*(s==="quarterly"?3:1)),K8(h)}return i}function Nhe(){const{data:e,isLoading:t}=vp(),[n,r]=y.useState("active"),s=K8(new Date),{data:i=[],isLoading:o}=Ee({queryKey:["outstanding-balances"],enabled:e===!0,queryFn:async()=>{var S,P,k,C,T;const m=F,[f,x,g,p]=await Promise.all([F.from("contact_experiences").select("id, contact_id, custom_price, amount_paid, payment_count, payment_frequency, price_due_date, contacts!contact_experiences_contact_id_fkey(name), experiences!inner(id, name, type, status, price, payment_count, payment_frequency, price_due_date), contact_experience_addons(experience_addons(price, third_party_payer))").eq("status","accepted").in("experiences.type",["trip","peer_group"]),F.from("contact_coaching").select("id, contact_id, price, amount_paid, payment_count, payment_frequency, price_due_date, schedule_type, fixed_payments, status, is_closed, contacts!contact_coaching_contact_id_fkey(name), generators!contact_coaching_generator_id_fkey(id, name)"),m.from("seat_payment_schedule").select("contact_experience_id, payer_contact_id, amount, due_date, sort_order").order("due_date"),m.from("manual_payments").select("contact_experience_id, payer_contact_id, amount").not("payer_contact_id","is",null)]);if(g.error)throw g.error;if(p.error)throw p.error;const v=new Map;for(const O of g.data??[])v.set(O.contact_experience_id,[...v.get(O.contact_experience_id)??[],O]);const b=new Map;for(const O of p.data??[]){const L=`${O.contact_experience_id}|${O.payer_contact_id}`;b.set(L,(b.get(L)??0)+(Number(O.amount)||0))}const w=[...new Set((g.data??[]).map(O=>O.payer_contact_id).filter(Boolean))],N=new Map;if(w.length){const{data:O}=await F.from("contacts").select("id, name").in("id",w);for(const L of O??[])N.set(L.id,L.name)}if(f.error)throw f.error;if(x.error)throw x.error;const j=new Map;for(const O of f.data??[]){const L=O.experiences;if(L.status==="cancelled")continue;const E=(O.contact_experience_addons??[]).reduce((B,W)=>B+(W.experience_addons&&!W.experience_addons.third_party_payer&&Number(W.experience_addons.price)||0),0),R=Number(O.custom_price??L.price??0)+E,q=Number(O.amount_paid)||0,I=j.get(L.id)??{key:L.id,label:L.name,type:L.type,active:L.status!=="completed",link:`/experiences?id=${L.id}`,rows:[]};j.set(L.id,I);const $=((S=O.contacts)==null?void 0:S.name)??"Unknown",M=v.get(O.id);if(M!=null&&M.length){const B=new Map;for(const A of M){const K=A.payer_contact_id??"";B.set(K,[...B.get(K)??[],A])}const W=[...B.keys()].filter(Boolean).reduce((A,K)=>A+(b.get(`${O.id}|${K}`)??0),0);for(const[A,K]of B){const G=K.reduce((J,re)=>J+(Number(re.amount)||0),0),H=A?b.get(`${O.id}|${A}`)??0:Math.max(0,q-W);let fe=0,te=null;for(const J of K)if(fe+=Number(J.amount)||0,H+.005<fe){te=J.due_date;break}I.rows.push({key:`${O.id}-${A}`,name:$,contactId:O.contact_id,price:G,paid:H,balance:Math.max(G-H,0),nextDue:te,payer:A?N.get(A)??"Unknown payer":$})}continue}I.rows.push({key:O.id,name:$,contactId:O.contact_id,price:R,paid:q,balance:Math.max(R-q,0),payer:$,nextDue:DA({total:R,paid:q,count:O.payment_count??L.payment_count,freq:O.payment_frequency??L.payment_frequency,finalDue:O.price_due_date??L.price_due_date})})}for(const O of x.data??[]){if(O.status==="cancelled")continue;const L=`coach-${((P=O.generators)==null?void 0:P.id)??"none"}`,E=j.get(L)??{key:L,label:((k=O.generators)==null?void 0:k.name)??"No coach assigned",type:"coaching",active:!1,link:"/coaching",rows:[]};j.set(L,E);const R=!O.is_closed&&O.status!=="completed";E.active=E.active||R;const q=Number(O.price)||0,I=Number(O.amount_paid)||0;E.rows.push({key:O.id,name:((C=O.contacts)==null?void 0:C.name)??"Unknown",contactId:O.contact_id,price:q,paid:I,balance:Math.max(q-I,0),payer:((T=O.contacts)==null?void 0:T.name)??"Unknown",nextDue:DA({total:q,paid:I,count:O.payment_count,freq:O.payment_frequency,finalDue:O.price_due_date,fixed:O.schedule_type==="fixed"&&Array.isArray(O.fixed_payments)?O.fixed_payments:void 0})})}const _={trip:0,peer_group:1,coaching:2};return[...j.values()].map(O=>({...O,rows:O.rows.filter(L=>L.balance>
840.005).sort((L,E)=>L.name.localeCompare(E.name))})).filter(O=>O.rows.length).sort((O,L)=>_[O.type]-_[L.type]||O.label.localeCompare(L.label))}}),l=y.useMemo(()=>n==="active"?i.filter(m=>m.active):n==="all"?i:i.filter(m=>m.key===n),[i,n]),c=(m,f)=>m.reduce((x,g)=>x+g[f],0),u=l.flatMap(m=>m.rows),d=u.filter(m=>m.nextDue&&m.nextDue<s).length,h=y.useMemo(()=>{const m=new Map;for(const f of u){if(f.payer===f.name)continue;const x=m.get(f.payer)??{balance:0,overdue:0,count:0};x.balance+=f.balance,x.count++,f.nextDue&&f.nextDue<s&&x.overdue++,m.set(f.payer,x)}return[...m.entries()].sort((f,x)=>x[1].balance-f[1].balance)},[u,s]);return t?a.jsx(Rr,{children:a.jsx("div",{className:"p-6 text-muted-foreground",children:"Loadingâ¦"})}):e?a.jsx(Rr,{children:a.jsxs("div",{className:"p-6 space-y-4 max-w-6xl",children:[a.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-display font-semibold",children:"Outstanding Balances"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Accepted trip and peer group places, and coaching engagements, with money still owed."})]}),a.jsxs(lt,{value:n,onValueChange:r,children:[a.jsx(it,{className:"w-72",children:a.jsx(ct,{})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"active",children:"All active"}),a.jsx(Oe,{value:"all",children:"All (including completed)"}),i.map(m=>a.jsxs(Oe,{value:m.key,children:[MA[m.type],": ",m.label]},m.key))]})]})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[a.jsx(gn,{children:a.jsxs(bn,{className:"p-4",children:[a.jsx("div",{className:"text-xs text-muted-foreground",children:"Agreed"}),a.jsx("div",{className:"text-lg font-semibold",children:ni(c(u,"price"))})]})}),a.jsx(gn,{children:a.jsxs(bn,{className:"p-4",children:[a.jsx("div",{className:"text-xs text-muted-foreground",children:"Paid"}),a.jsx("div",{className:"text-lg font-semibold",children:ni(c(u,"paid"))})]})}),a.jsx(gn,{children:a.jsxs(bn,{className:"p-4",children:[a.jsx("div",{className:"text-xs text-muted-foreground",children:"Outstanding (grand total)"}),a.jsx("div",{className:"text-lg font-semibold",children:ni(c(u,"balance"))})]})}),a.jsx(gn,{children:a.jsxs(bn,{className:"p-4",children:[a.jsx("div",{className:"text-xs text-muted-foreground",children:"Past due"}),a.jsxs("div",{className:`text-lg font-semibold ${d?"text-destructive":""}`,children:[d," ",d===1?"person":"people"]})]})})]}),h.length>0&&a.jsxs(gn,{children:[a.jsx(fr,{className:"pb-2",children:a.jsx(mr,{className:"text-base",children:"Owed by sponsoring payers"})}),a.jsx(bn,{children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Payer"}),a.jsx(Le,{className:"text-right",children:"Seats"}),a.jsx(Le,{className:"text-right",children:"Outstanding"}),a.jsx(Le,{children:"Past due"})]})}),a.jsx(Bn,{children:h.map(([m,f])=>a.jsxs(yt,{children:[a.jsx(Te,{children:m}),a.jsx(Te,{className:"text-right",children:f.count}),a.jsx(Te,{className:"text-right font-medium",children:ni(f.balance)}),a.jsx(Te,{className:f.overdue?"text-destructive":"text-muted-foreground",children:f.overdue||"â"})]},m))})]})})]}),o&&a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}),!o&&!l.length&&a.jsx("p",{className:"text-sm text-muted-foreground",children:"No outstanding balances."}),l.map(m=>a.jsxs(gn,{children:[a.jsx(fr,{className:"pb-2",children:a.jsxs(mr,{className:"text-base flex items-center gap-2",children:[a.jsx(Ge,{variant:"outline",children:MA[m.type]}),a.jsx(Na,{to:m.link,className:"hover:underline",children:m.type==="coaching"?`Coach: ${m.label}`:m.label})]})}),a.jsx(bn,{children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:m.type==="coaching"?"Client":"Participant"}),a.jsx(Le,{children:"Payer"}),a.jsx(Le,{className:"text-right",children:"Price agreed"}),a.jsx(Le,{className:"text-right",children:"Paid"}),a.jsx(Le,{className:"text-right",children:"Outstanding"}),a.jsx(Le,{children:"Next payment due"})]})}),a.jsx(Bn,{children:m.rows.map(f=>{const x=!!f.nextDue&&f.nextDue<s;return a.jsxs(yt,{children:[a.jsx(Te,{children:a.jsx(Na,{to:`/contacts?contact=${f.contactId}`,className:"hover:underline",children:f.name})}),a.jsx(Te,{className:f.payer===f.name?"text-muted-foreground":"font-medium",children:f.payer===f.name?"Self":f.payer}),a.jsx(Te,{className:"text-right",children:ni(f.price)}),a.jsx(Te,{className:"text-right",children:ni(f.paid)}),a.jsx(Te,{className:"text-right font-medium",children:ni(f.balance)}),a.jsx(Te,{children:a.jsxs("span",{className:x?"text-destructive font-medium inline-flex items-center gap-1":"",children:[x&&a.jsx(za,{className:"h-3.5 w-3.5"}),jhe(f.nextDue),x&&" · Past due"]})})]},f.key)})}),a.jsx(_F,{children:a.jsxs(yt,{children:[a.jsx(Te,{className:"font-semibold",children:"Total"}),a.jsx(Te,{}),a.jsx(Te,{className:"text-right font-semibold",children:ni(c(m.rows,"price"))}),a.jsx(Te,{className:"text-right font-semibold",children:ni(c(m.rows,"paid"))}),a.jsx(Te,{className:"text-right font-semibold",children:ni(c(m.rows,"balance"))}),a.jsx(Te,{})]})})]})})]},m.key))]})}):a.jsx(Rr,{children:a.jsx("div",{className:"p-6 text-muted-foreground",children:"You don't have access to this report."})})}const Hh=e=>
840e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0});function She(){const{data:e,isLoading:t}=vp(),[n,r]=y.useState(""),[s,i]=y.useState(""),{data:o=[],isLoading:l}=Ee({queryKey:["discounts-report"],enabled:e===!0,queryFn:async()=>{var x;const{data:h,error:m}=await F.from("contact_experiences").select("id, custom_price, discount_reason, status, contacts!contact_experiences_contact_id_fkey(name), experiences!contact_experiences_experience_id_fkey(id, name, public_name, price, target_start_date, status), contact_experience_addons(experience_addons(price, third_party_payer))").not("custom_price","is",null).in("status",["accepted","gen_guide"]);if(m)throw m;const f=[];for(const g of h??[]){const p=g.experiences;if(!p||p.status==="cancelled")continue;const v=(g.contact_experience_addons??[]).reduce((N,j)=>N+(j.experience_addons&&!j.experience_addons.third_party_payer?Number(j.experience_addons.price||0):0),0),b=Number(p.price??0)+v,w=Number(g.custom_price);w<b&&f.push({id:g.id,contactName:((x=g.contacts)==null?void 0:x.name)??"â",experienceId:p.id,experienceName:p.public_name||p.name,startDate:p.target_start_date,listPrice:b,discountedPrice:w,difference:b-w,reason:g.discount_reason})}return f.sort((g,p)=>(g.startDate??"").localeCompare(p.startDate??"")),f}}),c=y.useMemo(()=>o.filter(h=>{const m=h.startDate??"";return!(n&&m<n||s&&m>s)}),[o,n,s]),u=y.useMemo(()=>{const h=new Map;for(const m of c){const f=h.get(m.experienceId)??{name:m.experienceName,rows:[],total:0};f.rows.push(m),f.total+=m.difference,h.set(m.experienceId,f)}return[...h.values()]},[c]),d=c.reduce((h,m)=>h+m.difference,0);return t?a.jsx("div",{className:"p-8 text-muted-foreground",children:"Loadingâ¦"}):e?a.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-6",children:[a.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[a.jsxs("h1",{className:"text-2xl font-semibold font-display flex items-center gap-2",children:[a.jsx(Wv,{className:"h-5 w-5"})," Discounts"]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[a.jsx("span",{children:"Trip start from"}),a.jsx(ce,{type:"date",className:"h-8 w-36",value:n,onChange:h=>r(h.target.value)}),a.jsx("span",{children:"to"}),a.jsx(ce,{type:"date",className:"h-8 w-36",value:s,onChange:h=>i(h.target.value)})]})]}),a.jsx(gn,{children:a.jsx(fr,{className:"py-3",children:a.jsxs(mr,{className:"text-base",children:["Total discounts given: ",a.jsx("span",{className:"text-primary",children:Hh(d)}),a.jsxs("span",{className:"ml-2 text-sm font-normal text-muted-foreground",children:["across ",c.length," participant",c.length===1?"":"s"]})]})})}),l&&a.jsx("p",{className:"text-muted-foreground",children:"Loadingâ¦"}),!l&&u.length===0&&a.jsx("p",{className:"text-muted-foreground",children:"No discounted participants in this date range."}),u.map(h=>a.jsxs(gn,{children:[a.jsx(fr,{className:"py-3",children:a.jsxs(mr,{className:"text-base flex items-center justify-between",children:[a.jsx("span",{children:h.name}),a.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["Total: ",Hh(h.total)]})]})}),a.jsx(bn,{className:"pt-0",children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Participant"}),a.jsx(Le,{className:"text-right",children:"List price"}),a.jsx(Le,{className:"text-right",children:"Their price"}),a.jsx(Le,{className:"text-right",children:"Discount"}),a.jsx(Le,{children:"Reason"})]})}),a.jsx(Bn,{children:h.rows.map(m=>a.jsxs(yt,{children:[a.jsx(Te,{children:m.contactName}),a.jsx(Te,{className:"text-right tabular-nums",children:Hh(m.listPrice)}),a.jsx(Te,{className:"text-right tabular-nums",children:Hh(m.discountedPrice)}),a.jsx(Te,{className:"text-right tabular-nums text-primary",children:Hh(m.difference)}),a.jsx(Te,{className:"text-muted-foreground",children:m.reason||"â"})]},m.id))})]})})]},h.name))]}):a.jsx("div",{className:"p-8 text-muted-foreground",children:"You don't have access to this report."})}const $A=[{label:"Last 24h",getValue:()=>rae(new Date,24)},{label:"Last 7 days",getValue:()=>Af(new Date,7)},{label:"Last 30 days",getValue:()=>Af(new Date,30)}];function Che(e){switch(e){case"sent":return a.jsx(Ge,{className:"bg-emerald-100 text-emerald-800 border-emerald-200",children:"Sent"});case"failed":case"dlq":return a.jsx(Ge,{variant:"destructive",children:"Failed"});
840case"pending":return a.jsx(Ge,{className:"bg-amber-100 text-amber-800 border-amber-200",children:"Pending"});case"rate_limited":return a.jsx(Ge,{className:"bg-orange-100 text-orange-800 border-orange-200",children:"Rate Limited"});case"suppressed":return a.jsx(Ge,{className:"bg-yellow-100 text-yellow-800 border-yellow-200",children:"Suppressed"});default:return a.jsx(Ge,{variant:"secondary",children:e})}}function khe({row:e}){const[t,n]=y.useState(!1),r=e.metadata,s=r==null?void 0:r.subject,i=r==null?void 0:r.message,o=!!(s||i);return a.jsxs(a.Fragment,{children:[a.jsxs(yt,{className:o?"cursor-pointer hover:bg-muted/50":"",onClick:()=>o&&n(!t),children:[a.jsx(Te,{className:"w-8 px-2",children:o&&(t?a.jsx(_r,{className:"h-3.5 w-3.5 text-muted-foreground"}):a.jsx(_n,{className:"h-3.5 w-3.5 text-muted-foreground"}))}),a.jsx(Te,{className:"font-mono text-xs",children:e.template_name}),a.jsx(Te,{className:"text-sm",children:e.recipient_email}),a.jsx(Te,{className:"text-sm max-w-[200px] truncate",children:s||"â"}),a.jsx(Te,{children:Che(e.status)}),a.jsx(Te,{className:"text-xs text-muted-foreground whitespace-nowrap",children:Ye(new Date(e.created_at),"MMM d, yyyy h:mm a")}),a.jsx(Te,{className:"text-xs text-destructive max-w-[200px] truncate",children:e.error_message||"â"})]}),t&&i&&a.jsx(yt,{children:a.jsxs(Te,{colSpan:7,className:"bg-muted/30 px-6 py-3",children:[a.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Message body:"}),a.jsx("pre",{className:"text-sm whitespace-pre-wrap font-sans text-foreground",children:i})]})})]})}function Ehe(){const{data:e,isLoading:t}=Qs(),[n,r]=y.useState([]),[s,i]=y.useState({total:0,sent:0,failed:0,pending:0,other:0}),[o,l]=y.useState([]),[c,u]=y.useState(0),[d,h]=y.useState(0),[m,f]=y.useState(!1),[x,g]=y.useState(1),[p,v]=y.useState(""),[b,w]=y.useState(""),[N,j]=y.useState("all"),[_,S]=y.useState("all"),P=y.useCallback(async(C=0)=>{f(!0);const T=x>=0?$A[x].getValue().toISOString():p?new Date(p).toISOString():void 0,O=x<0&&b?new Date(b+"T23:59:59").toISOString():void 0,L=new URLSearchParams;T&&L.set("start",T),O&&L.set("end",O),N!=="all"&&L.set("template",N),_!=="all"&&L.set("status",_),L.set("page",String(C));const E=(await F.auth.getSession()).data.session,q=await fetch(`https://wjxhtbmgykpxnrfoxcqz.supabase.co/functions/v1/email-log?${L.toString()}`,{headers:{Authorization:`Bearer ${E==null?void 0:E.access_token}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndqeGh0Ym1neWtweG5yZm94Y3F6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA5MzYxNjYsImV4cCI6MjA4NjUxMjE2Nn0.-RLYZPJTBjqGgb2SkGt0JZqq1crx4AU_Pqq0UaGMyoM"}}),I=await q.json();q.ok&&(r(I.rows??[]),i(I.stats??{total:0,sent:0,failed:0,pending:0,other:0}),l(I.templates??[]),u(I.totalRows??0),h(C)),f(!1)},[x,p,b,N,_]);if(y.useEffect(()=>{e&&P(0)},[e,P]),t)return a.jsx(Rr,{children:a.jsx("div",{className:"flex items-center justify-center py-20",children:a.jsx(vt,{className:"h-6 w-6 animate-spin text-muted-foreground"})})});if(!e)return a.jsx(Rr,{children:a.jsx("div",{className:"flex items-center justify-center py-20",children:a.jsx("p",{className:"text-muted-foreground",children:"You don't have permission to view this page."})})});const k=Math.ceil(c/50);return a.jsx(Rr,{children:a.jsxs("div",{className:"space-y-6",children:[a.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Email Log"}),a.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[a.jsxs("div",{className:"flex gap-1",children:[$A.map((C,T)=>a.jsx(Y,{size:"sm",variant:x===T?"default":"outline",onClick:()=>{g(T),h(0)},children:C.label},C.label)),a.jsx(Y,{size:"sm",variant:x<0?"default":"outline",onClick:()=>g(-1),children:"Custom"})]}),x<0&&a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx(ce,{type:"date",value:p,onChange:C=>v(C.target.value),className:"w-36"}),a.jsx("span",{className:"text-muted-foreground text-sm",children:"to"}),a.jsx(ce,{type:"date",value:b,onChange:C=>w(C.target.value),className:"w-36"})]}),a.jsxs(lt,{value:N,onValueChange:C=>{j(C),h(0)},children:[a.jsx(it,{className:"w-48",children:a.jsx(ct,{placeholder:"All templates"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"all",children:"All templates"}),o.map(C=>a.jsx(Oe,{value:C,children:C},C))]})]}),a.jsxs(lt,{value:_,onValueChange:C=>{S(C),h(0)},children:[a.jsx(it,{className:"w-36",children:a.jsx(ct,{placeholder:"All statuses"})}),a.jsxs(ot,{children:[a.jsx(Oe,{value:"all",children:"All statuses"}),a.jsx(Oe,{value:"sent",children:"Sent"}),a.jsx(Oe,{value:"failed",children:"Failed"}),a.jsx(Oe,{value:"dlq",children:"DLQ"}),a.jsx(Oe,{value:"pending",children:"Pending"}),a.jsx(Oe,{value:"suppressed",children:"Suppressed"})]})]}),a.jsx(Y,{size:"sm",onClick:()=>P(0),disabled:m,children:m?a.jsx(vt,{className:"h-4 w-4 animate-spin"}):"Apply"})]}),a.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[a.jsx(gn,{children:a.jsxs(bn,{className:"flex items-center gap-3 p-4",children:[a.jsx(fs,{className:"h-5 w-5 text-muted-foreground"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold",children:s.total}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Total"})]})]})}),a.jsx(gn,{children:a.jsxs(bn,{className:"flex items-center gap-3 p-4",children:[a.jsx(XK,{className:"h-5 w-5 text-emerald-600"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold",children:s.sent}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Sent"})]})]})}),a.jsx(gn,{children:a.jsxs(bn,{className:"flex items-center gap-3 p-4",children:[a.jsx(A3,{className:"h-5 w-5 text-destructive"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold",children:s.failed}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Failed"})]})]})}),a.jsx(gn,{children:a.jsxs(bn,{className:"flex items-center gap-3 p-4",children:[a.jsx(pl,{className:"h-5 w-5 text-amber-600"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold",children:s.pending}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})]}),a.jsx("div",{className:"border rounded-lg",children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{className:"w-8"}),a.jsx(Le,{children:"Template"}),a.jsx(Le,{children:"Recipient"}),a.jsx(Le,{children:"Subject"}),a.jsx(Le,{children:"Status"}),a.jsx(Le,{children:"Time"}),a.jsx(Le,{children:"Error"})]})}),a.jsx(Bn,{children:m?a.jsx(yt,{children:a.jsx(Te,{colSpan:7,className:"text-center py-8",children:a.jsx(vt,{className:"h-5 w-5 animate-spin mx-auto text-muted-foreground"})})}):n.length===0?a.jsx(yt,{children:a.jsx(Te,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No emails found for this filter."})}):n.map(C=>a.jsx(khe,{row:C},C.id))})]})}),k>1&&a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",d+1," of ",k," (",c," emails)"]}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Y,{size:"sm",variant:"outline",disabled:d===0,onClick:()=>P(d-1),children:a.jsx(P3,{className:"h-4 w-4"})}),a.jsx(Y,{size:"sm",variant:"outline",disabled:d>=k-1,onClick:()=>P(d+1),children:a.jsx(fp,{className:"h-4 w-4"})})]})]})]})})}function Phe(){const{data:e,isLoading:t}=Qs(),[n,r]=y.useState("revenue"),{data:s,isLoading:i}=Ee({queryKey:["referred-bookings","report"],enabled:e===!0,queryFn:async()=>{const c=await vF(null),u=[...new Set(c.referrals.map(N=>N.referrerId))],d=new Set;for(let N=0;N<u.length;N+=200){const{data:j}=await F.from("contacts").select("id").eq("contact_type","organization").in("id",u.slice(N,N+200));
840(j??[]).forEach(_=>d.add(_.id))}const h=c.referrals.filter(N=>!d.has(N.referrerId)),m=c.bookings.filter(N=>!d.has(N.referrerId)),f=[...new Set(h.map(N=>N.referrerId))],x={},g={};for(let N=0;N<f.length;N+=200){const{data:j,error:_}=await F.from("contacts").select("id, name, email").in("id",f.slice(N,N+200));if(_)throw _;(j??[]).forEach(S=>{x[S.id]=S.name,S.email&&(g[S.id]=S.email.toLowerCase())})}const{data:p,error:v}=await F.from("generators").select("email");if(v)throw v;const b=new Set((p??[]).map(N=>{var j;return(j=N.email)==null?void 0:j.toLowerCase()}).filter(Boolean)),w={};return f.forEach(N=>{w[N]=!!g[N]&&b.has(g[N])}),{referrals:h,bookings:m,names:x,isGenerator:w}}}),o=y.useMemo(()=>{const c=new Map,u=h=>{const m=c.get(h)??{id:h,people:new Set,bookings:0,revenue:0,collected:0,otherCash:0};return c.set(h,m),m};for(const h of(s==null?void 0:s.referrals)??[])u(h.referrerId).people.add(h.personId);for(const h of(s==null?void 0:s.bookings)??[]){const m=u(h.referrerId);p1.includes(h.status)?(m.bookings+=1,m.revenue+=h.value,m.collected+=h.paid):m.otherCash+=h.paid}return[...c.values()].map(h=>({...h,referrals:h.people.size})).sort((h,m)=>m[n]-h[n]||m.revenue-h.revenue)},[s,n]),l=(c,u,d)=>a.jsxs("th",{className:"text-left px-2 py-1.5 font-medium cursor-pointer select-none",title:d,onClick:()=>r(c),children:[u,n===c?" â":""]});return a.jsx(Rr,{children:a.jsxs(gn,{children:[a.jsxs(fr,{className:"pb-2",children:[a.jsx(mr,{className:"font-display text-xl",children:"Referral Ranking"}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Direct referrals only â a referrer's own referrer is never credited. Referrals made includes people referred to a summit. Bookings and revenue are lifetime: every accepted booking by people they referred, not just the first. Collected counts accepted places only. Referrers marked Team are already Generators, compensated through Generator Recruiting Comp. Click a column to rank by it."})]}),a.jsx(bn,{children:t||i?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):e?o.length===0?a.jsx("p",{className:"text-sm text-muted-foreground",children:"No referred bookings yet."}):a.jsx("div",{className:"rounded border border-border overflow-x-auto",children:a.jsxs("table",{className:"w-full text-xs",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border bg-muted/50 text-muted-foreground",children:[a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"#"}),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Contact"}),l("referrals","Referrals made","Distinct people this contact referred"),l("bookings","Lifetime bookings","Every accepted booking by referred people"),l("revenue","Lifetime revenue","Booking value of every accepted booking by referred people"),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",children:"Collected"}),a.jsx("th",{className:"text-left px-2 py-1.5 font-medium",title:"Paid on places not accepted, not in Collected",children:"Cash, non-accepted"})]})}),a.jsx("tbody",{children:o.map((c,u)=>a.jsxs("tr",{className:"border-b border-border last:border-0",children:[a.jsx("td",{className:"px-2 py-1.5 text-muted-foreground",children:u+1}),a.jsxs("td",{className:"px-2 py-1.5",children:[a.jsx("a",{className:"text-primary hover:underline",href:`/contacts?contact=${c.id}`,children:(s==null?void 0:s.names[c.id])??"Unknown"}),(s==null?void 0:s.isGenerator[c.id])&&a.jsx("span",{className:"ml-1.5 rounded bg-muted px-1 py-0.5 text-[9px] font-medium text-muted-foreground",title:"Already a Team member â compensated through Generator Recruiting Comp",children:"Team"})]}),a.jsx("td",{className:"px-2 py-1.5",children:c.referrals}),a.jsx("td",{className:"px-2 py-1.5",children:c.bookings}),a.jsx("td",{className:"px-2 py-1.5",children:Fs(c.revenue)}),a.jsx("td",{className:"px-2 py-1.5",children:Fs(c.collected)}),a.jsx("td",{className:"px-2 py-1.5 text-muted-foreground",children:c.otherCash?Fs(c.otherCash):"â"})]},c.id))})]})}):a.jsx("p",{className:"text-sm text-muted-foreground",children:"Only admins can view this report."})})]})})}const H8=15e3,G8=1e4,V8=90,Gi=e=>`${e.getFullYear()}
840-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,yo=e=>{const[t,n,r]=e.slice(0,10).split("-").map(Number);return new Date(t,n-1,r)},Ohe=(e,t)=>{const n=yo(e),r=n.getDate(),s=new Date(n.getFullYear(),n.getMonth()+t,1),i=new Date(s.getFullYear(),s.getMonth()+1,0).getDate();return s.setDate(Math.min(r,i)),Gi(s)};function Kw(e,t,n,r,s){const i=Math.max(1,n||1),o=r==="quarterly"?3:1,l=e/i,c=[];for(let u=1;u<=i;u++){const d=Math.max(0,Math.min(l,u*l-t));d>.005&&c.push({date:Ohe(s,-(i-u)*o),amount:d})}return c}function Ahe(e,t){const n=Gi(new Date(yo(t).getTime()+V8*864e5)),r=[];for(const[s,i]of[[H8,"Escalation"],[G8,"Floor"]]){let o=!0;for(const l of e){const c=l.committed>=s;if(o&&!c){r.push({threshold:s,label:i,date:l.date,balance:l.committed,withinAlert:l.date<=n});break}o=c}}return r}function The(e,t){const n=new Map;let r=0;for(const i of e)if(!(i.date>t)){if(!i.expId){r+=i.amount;continue}n.set(i.expId,(n.get(i.expId)??0)+i.amount)}let s=null;for(const[i,o]of n)o<0&&(!s||o<s.net)&&(s={expId:i,net:o});return{worst:s,overhead:r}}const ri={c:!0,e:!0,g:!0},Mhe={c:!1,e:!0,g:!0},Dhe={c:!1,e:!0,g:!1},$he={c:!1,e:!1,g:!0},Dg={participants:{label:"Participant payments",inflow:!0,lines:"All lines",tip:"Accepted places: each schedule row the participant pays, on its due date, less what they've already paid."},sponsors:{label:"Organization / sponsor payments",inflow:!0,lines:"All lines",tip:"Schedule rows whose payer is another contact (e.g. an employer). Cash date = due date plus the payer's terms (Net 30 â +30 days)."},coaching:{label:"Coaching",inflow:!0,lines:"All lines",tip:"Open coaching engagements' remaining scheduled payments."},royalty:{label:"Royalties (Wanderwell)",inflow:!0,lines:"All lines",tip:"Expected royalty per period, entered on the Royalties tab. Dropped once a statement for that period is logged."},pipeline:{label:"Pipeline (weighted)",inflow:!0,lines:"Expected only",tip:"Invited / considering / interested people à the conversion rate for that experience type (Assumptions tab), capped at open seats."},open_seats:{label:"Open seats to Goal Size",inflow:!0,lines:"Goal-size only",tip:"Every open seat on trips and peer groups filled at list price."},suppliers_committed:{label:"Suppliers â Contracted / Actual",inflow:!1,lines:"All lines",tip:"Unpaid supplier payments on budget lines with status Contracted or Actual."},suppliers_estimated:{label:"Suppliers â Estimated",inflow:!1,lines:"Expected + Goal-size",tip:"Unpaid supplier payments on Estimate / Quoted / Default Estimate lines. Kept off the committed line so trips that may not run don't trigger alerts."},coaching_delivery:{label:"Coaching delivery",inflow:!1,lines:"All lines",tip:"Coach's delivery share of each coaching payment."},overhead:{label:"Overhead",inflow:!1,lines:"All lines",tip:"Recurring costs from the Overhead tab. % of revenue items use committed revenue."},tax:{label:"Estimated tax (assumption)",inflow:!1,lines:"All lines",tip:"One figure: expected annual profit à tax rate ÷ 4, paid Apr 15, Jun 15, Sep 15 and Jan 15. Set on the Assumptions tab."}},Rhe=["participants","sponsors","coaching","royalty","pipeline","open_seats","suppliers_committed","suppliers_estimated","coaching_delivery","overhead","tax"],Un=e=>Number(e)||0,Ihe=e=>{const t=/net\s*(\d+)/i.exec(e??"");return t?Number(t[1]):0},Lhe=(e,t)=>{const n=yo(e);return n.setDate(n.getDate()+t),Gi(n)},Hw=(e,t)=>{const n=yo(e),r=n.getDate(),s=new Date(n.getFullYear(),n.getMonth()+t,1);return s.setDate(Math.min(r,new Date(s.getFullYear(),s.getMonth()+1,0).getDate())),Gi(s)},xu=e=>(e==null?void 0:e.name)??"";function RA(e,t){const n=(e.contact_experience_addons??[]).reduce((r,s)=>r+(s.experience_addons&&!s.experience_addons.third_party_payer?Un(s.experience_addons.price):0),0);return Un(e.custom_price??(t==null?void 0:t.price))+n}function Fhe(e,t,n){const r=[...n.values()].reduce((l,c)=>l+c,0),s=new Map([["",Math.max(0,t-r)],...n]),i=new Map;for(const l of e){const c=l.payer_contact_id??"";i.set(c,[...i.get(c)??[],l])}const o=[];for(const[l,c]of i){let u=s.get(l)??0;for(const d of[...c].sort((h,m)=>h.due_date.localeCompare(m.due_date)||h.sort_order-m.sort_order)){const h=Math.min(u,Un(d.amount));u-=h,o.push({row:d,remaining:Un(d.amount)-h})}}return o}function qhe(e){var w,N,j,_,S,P;const{today:t,horizonEnd:n}=e,r=[],s=k=>{(k.amount>.005||k.amount<-.005)&&r.push({...k,date:k.date<t?t:k.date})},i=new Map(e.exps.map(k=>[k.id,k])),o=k=>
840k&&k.status!=="cancelled",l=new Map;for(const k of e.schedule)l.set(k.contact_experience_id,[...l.get(k.contact_experience_id)??[],k]);const c=new Map;for(const k of e.orgPayments){const C=c.get(k.contact_experience_id)??new Map;C.set(k.payer_contact_id,(C.get(k.payer_contact_id)??0)+Un(k.amount)),c.set(k.contact_experience_id,C)}const u=new Map;for(const k of e.ces){const C=i.get(k.experience_id);if(!o(C)||(k.status==="accepted"&&u.set(C.id,(u.get(C.id)??0)+1),!(k.status==="accepted"||k.status==="gen_guide"&&Un(k.custom_price)>0)))continue;const T=((w=k.contacts)==null?void 0:w.name)??"Participant",O=l.get(k.id);if(O!=null&&O.length){for(const{row:E,remaining:R}of Fhe(O,Un(k.amount_paid),c.get(k.id)??new Map)){const q=E.payer_contact_id?e.payers.get(E.payer_contact_id):null;s({date:q?Lhe(E.due_date,Ihe(q.payment_terms)):E.due_date,amount:R,category:q?"sponsors":"participants",scope:ri,label:T,sublabel:q?`${xu(C)} · paid by ${q.name}${q.payment_terms?` (${q.payment_terms})`:""}`:xu(C),expId:C.id})}continue}const L=k.price_due_date||C.price_due_date||C.target_start_date;if(L)for(const E of Kw(RA(k,C),Un(k.amount_paid),k.payment_count||C.payment_count,k.payment_frequency||C.payment_frequency,L))s({date:E.date,amount:E.amount,category:"participants",scope:ri,label:T,sublabel:xu(C),expId:C.id})}const d=new Map;let h=0,m=0;for(const k of e.exps){if(!["trip","peer_group"].includes(k.type)||["cancelled","completed"].includes(k.status))continue;const C=k.price_due_date||k.target_start_date;if(!C||C<t||!(Un(k.price)>0)||!(k.max_size>0))continue;const T=Math.max(0,k.max_size-(u.get(k.id)??0));if(d.set(k.id,T),!!T){h+=T,m++;for(const O of Kw(Un(k.price)*T,0,k.payment_count,k.payment_frequency,C))s({date:O.date,amount:O.amount,category:"open_seats",scope:$he,label:xu(k),sublabel:`${T} open seat${T===1?"":"s"} at list price`,expId:k.id})}}const f=new Map,x=e.ces.filter(k=>["invited","considering","expressed_interest"].includes(k.status)).sort((k,C)=>String(k.created_at).localeCompare(String(C.created_at)));for(const k of x){const C=i.get(k.experience_id);if(!C||!d.has(C.id))continue;const T=f.get(C.id)??0;if(T>=(d.get(C.id)??0))continue;f.set(C.id,T+1);const O=(e.rates.get(C.type)??0)/100;if(!O)continue;const L=k.price_due_date||C.price_due_date||C.target_start_date;for(const E of Kw(RA(k,C)*O,0,k.payment_count||C.payment_count,k.payment_frequency||C.payment_frequency,L))s({date:E.date,amount:E.amount,category:"pipeline",scope:Dhe,label:((N=k.contacts)==null?void 0:N.name)??"Prospect",sublabel:`${xu(C)} · ${Math.round(O*100)}% weight`,expId:C.id})}for(const k of e.coaching){if(k.is_closed||!(Un(k.price)>0))continue;const C=Un(k.amount_paid),T=Un(k.pct_paid_to_delivery)/100,O=((j=k.contacts)==null?void 0:j.name)??"Coaching client",L=(_=k.generators)!=null&&_.name?`Coach: ${k.generators.name}`:"Coaching";let E=[];if(k.schedule_type==="fixed"){let R=0;for(const q of[...k.fixed_payments??[]].filter(I=>I==null?void 0:I.date).sort((I,$)=>I.date.localeCompare($.date)))R+=Un(q.amount),E.push({date:q.date,amount:Math.max(0,Math.min(Un(q.amount),R-C))})}else{const R=Math.max(1,k.payment_count||1),q=k.payment_frequency==="quarterly"?3:1,I=k.price_due_date||k.start_date,$=Un(k.price)/R;if(I)for(let M=1;M<=R;M++)E.push({date:Hw(I,(M-1)*q),amount:Math.max(0,Math.min($,M*$-C))})}for(const R of E)s({date:R.date,amount:R.amount,category:"coaching",scope:ri,label:O,sublabel:L,expId:null}),T&&s({date:R.date,amount:-R.amount*T,category:"coaching_delivery",scope:ri,label:O,sublabel:`${L} · ${Math.round(T*100)}%`,expId:null})}for(const k of e.royaltyExpected)e.royaltyStatements.some(T=>T.source===k.source&&T.period_start<=k.period_end&&T.period_end>=k.period_start)||s({date:k.expected_date,amount:Un(k.amount),category:"royalty",scope:ri,label:k.source,sublabel:`Period ${k.period_start} â ${k.period_end}`,expId:null});for(const k of e.supplierPays){const C=k.experience_budget_items,T=i.get(C==null?void 0:C.experience_id);if(!o(T)||C!=null&&C.is_closed)continue;const O=["Contracted","Actual"].includes(C.estimate_status);s({date:k.due_month,amount:-Un(k.amount),category:O?"suppliers_committed":"suppliers_estimated",scope:O?ri:Mhe,label:xu(T),sublabel:`${C.name}
840${C.description?` â ${C.description}`:""} · ${C.estimate_status}`,expId:T.id})}const g=[];for(let k=t.slice(0,7)+"-01";k<=n;k=Hw(k,1))g.push(k);const p=new Map;for(const k of r)k.scope.c&&k.amount>0&&p.set(k.date.slice(0,7),(p.get(k.date.slice(0,7))??0)+k.amount);for(const k of e.overhead){if(!k.active||k.is_closed)continue;const C=k.start_month??g[0],T=k.end_month??"9999-12-31",O=Un(k.monthly_amount);if(k.calc_type==="pct_revenue")for(const L of g)L>=C.slice(0,7)+"-01"&&L<=T&&s({date:L,amount:-(p.get(L.slice(0,7))??0)*O/100,category:"overhead",scope:ri,label:k.label,sublabel:`${O}% of committed revenue`,expId:null});else if((k.frequency??"monthly")==="monthly")for(const L of g)L>=C.slice(0,7)+"-01"&&L<=T&&s({date:L,amount:-O,category:"overhead",scope:ri,label:k.label,expId:null});else{const L=k.frequency==="quarterly"?3:12;for(let E=C;E<=T&&E<=n;E=Hw(E,L))E>=g[0]&&s({date:E,amount:-O,category:"overhead",scope:ri,label:k.label,sublabel:k.frequency,expId:null})}}const v=Un((S=e.settings)==null?void 0:S.expected_annual_profit)*Un((P=e.settings)==null?void 0:P.tax_rate)/100/4;if(v>0){const k=yo(t).getFullYear();for(const C of[k,k+1,k+2])for(const T of["01-15","04-15","06-15","09-15"]){const O=`${C}-${T}`;O>=t&&O<=n&&s({date:O,amount:-v,category:"tax",scope:ri,label:"Estimated tax payment",sublabel:"Assumption",expId:null})}}return{events:r.filter(k=>k.date<=n),months:g,openSeats:h,fillingTrips:m}}function zhe(e,t,n,r){const s=new Map;for(const u of r){const d=s.get(u.date)??{c:0,e:0,g:0};u.scope.c&&(d.c+=u.amount),(u.scope.e||u.scope.c)&&(d.e+=u.amount),(u.scope.g||u.scope.c)&&(d.g+=u.amount),s.set(u.date,d)}const i=[];let o=e,l=e,c=e;for(let u=yo(t);Gi(u)<=n;u.setDate(u.getDate()+1)){const d=s.get(Gi(u));d&&(o+=d.c,l+=d.e,c+=d.g),i.push({date:Gi(u),committed:o,expected:l,goal:c})}return i}const $g=e=>(e??0).toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),IA=e=>new Date(e+"T00:00:00").toLocaleDateString("en-US",{month:"short",year:"2-digit"});function Bhe({events:e,months:t,startingCash:n}){const[r,s]=y.useState(null),i=y.useMemo(()=>{const u=new Map,d={c:new Map,e:new Map,g:new Map};for(const m of e){const f=m.date.slice(0,7);u.set(`${m.category}|${f}`,(u.get(`${m.category}|${f}`)??0)+m.amount),m.scope.c&&d.c.set(f,(d.c.get(f)??0)+m.amount),(m.scope.c||m.scope.e)&&d.e.set(f,(d.e.get(f)??0)+m.amount),(m.scope.c||m.scope.g)&&d.g.set(f,(d.g.get(f)??0)+m.amount)}const h=m=>{let f=n;return t.map(x=>f+=m.get(x.slice(0,7))??0)};return{cell:u,net:d,end:{c:h(d.c),e:h(d.e),g:h(d.g)}}},[e,t,n]),o=Rhe.filter(u=>t.some(d=>i.cell.has(`${u}|${d.slice(0,7)}`))),l=r?e.filter(u=>u.category===r.cat&&u.date.slice(0,7)===r.m.slice(0,7)).sort((u,d)=>u.date.localeCompare(d.date)):[],c=[{k:"c",label:"Committed"},{k:"e",label:"Expected"},{k:"g",label:"Goal-size"}];return a.jsxs("div",{className:"space-y-3",children:[a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{className:"sticky left-0 bg-background min-w-[240px]",children:" "}),t.map(u=>a.jsx(Le,{className:"text-right whitespace-nowrap",children:IA(u)},u))]})}),a.jsxs(Bn,{children:[o.map(u=>a.jsxs(yt,{children:[a.jsxs(Te,{className:"sticky left-0 bg-background",children:[a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{children:Dg[u].label}),a.jsxs(T5,{children:[a.jsx(M5,{asChild:!0,children:a.jsx(tm,{className:"h-3 w-3 text-muted-foreground"})}),a.jsx(_C,{className:"max-w-xs",children:Dg[u].tip})]})]}),a.jsx(Ge,{variant:"outline",className:"mt-1 text-[10px] font-normal",children:Dg[u].lines})]}),t.map(d=>{const h=i.cell.get(`${u}|${d.slice(0,7)}`)??0,m=(r==null?void 0:r.m)===d&&r.cat===u;return a.jsx(Te,{className:`text-right tabular-nums whitespace-nowrap ${h?"cursor-pointer hover:underline":"text-muted-foreground"} ${m?"bg-muted":""}`,onClick:()=>h&&s(m?null:{m:d,cat:u}),children:h?$g(h):"â"},d)})]},u)),c.map(u=>a.jsxs(yt,{className:"border-t-2",children:[a.jsxs(Te,{className:"sticky left-0 bg-background font-medium",children:["Net â ",u.label]}),t.map(d=>a.jsx(Te,{className:"text-right tabular-nums font-medium",children:$g(i.net[u.k].get(d.slice(0,7))??0)},d))]},`net-${u.k}`)),c.map(u=>a.jsxs(yt,{children:[a.jsxs(Te,{className:"sticky left-0 bg-background font-semibold",children:["Ending cash â ",u.label]}),t.map((d,h)=>a.jsx(Te,{className:`text-right tabular-nums font-semibold ${i.end[u.k][h]<0?"text-destructive":""}`,children:$g(i.end[u.k][h])},d))]},`end-${u.k}`))]})]}),r&&a.jsxs("div",{className:"rounded-md border p-3",children:[a.jsxs("div",{className:"text-sm font-medium mb-2",children:[Dg[r.cat].label," â ",IA(r.m)]}),a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Date"}),a.jsx(Le,{children:"Who / what"}),a.jsx(Le,{children:"Detail"}),a.jsx(Le,{className:"text-right",children:"Amount"})]})}),a.jsx(Bn,{children:l.map((u,d)=>a.jsxs(yt,{children:[a.jsx(Te,{className:"whitespace-nowrap",children:u.date}),a.jsx(Te,{children:u.expId&&u.category.startsWith("suppliers")?a.jsx(Na,{to:`/experiences?id=${u.expId}`,className:"underline",children:u.label}):u.label}),a.jsx(Te,{className:"text-muted-foreground",children:u.sublabel}),a.jsx(Te,{className:"text-right tabular-nums",children:$g(u.amount)})]},d))})]})]})]})}function Uhe(e){const t=Gi(new Date),n=t.slice(0,7)+"-01",r=(()=>{const o=yo(n);return Gi(new Date(o.getFullYear(),o.getMonth()+12,0))})(),s=Ee({queryKey:["forecast","cash-events"],queryFn:async()=>{const o=F,l=await Promise.all([o.from("experiences").select("id, name, type, status, price, max_size, payment_count, payment_frequency, price_due_date, target_start_date, end_date"),o.from("contact_experiences").select("id, experience_id, contact_id, status, custom_price, amount_paid, payment_count, payment_frequency, price_due_date, created_at, contacts!contact_experiences_contact_id_fkey(name), contact_experience_addons(experience_addons(price, third_party_payer))").in("status",["accepted","gen_guide","invited","considering","expressed_interest"]),o.from("seat_payment_schedule").select("*"),o.from("manual_payments").select("contact_experience_id, amount, payer_contact_id").not("payer_contact_id","is",null),o.from("contact_coaching").select("id, price, amount_paid, is_closed, schedule_type, fixed_payments, payment_count, payment_frequency, price_due_date, start_date, pct_paid_to_delivery, contacts!contact_coaching_contact_id_fkey(name), generators!contact_coaching_generator_id_fkey(name)"),o.from("experience_budget_item_payments").select("amount, due_month, experience_budget_items!inner(experience_id, name, description, estimate_status, is_closed)").eq("paid",!1).gt("amount",0),o.from("forecast_overhead_items").select("*"),o.from("royalty_expected").select("*"),o.from("royalty_statements").select("*"),o.from("forecast_conversion_rates").select("*"),o.from("forecast_settings").select("*").maybeSingle()]);for(const j of l)if(j.error)throw j.error;const[c,u,d,h,m,f,x,g,p,v,b]=l.map(j=>j.data),w=[...new Set([...d??[],...h??[]].map(j=>
840j.payer_contact_id).filter(Boolean))],N=new Map;if(w.length){const{data:j,error:_}=await o.from("contacts").select("id, name, contact_type, payment_terms").in("id",w);if(_)throw _;for(const S of j??[])N.set(S.id,S)}return{exps:c,ces:u,schedule:d,orgPayments:h,coaching:m,supplierPays:f,overhead:x,royaltyExpected:g,royaltyStatements:p,settings:b,payers:N,rates:new Map((v??[]).map(j=>[j.experience_type,Number(j.rate)||0]))}}});return{model:y.useMemo(()=>{if(!s.data)return null;const o=qhe({today:t,horizonEnd:r,...s.data}),l=zhe(e,t,r,o.events);return{...o,points:l}},[s.data,e,t,r]),isLoading:s.isLoading,error:s.error,today:t,monthStart:n,horizonEnd:r}}const Gh=F,Whe=[{k:"trip",l:"Trips"},{k:"peer_group",l:"Peer Groups"},{k:"stakeholder_summit",l:"Stakeholder Summits"}],Khe=["invited","considering","expressed_interest","accepted","declined","dropped","waitlist"],Hhe=e=>(e??0).toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0});function Gw({value:e,onSave:t,suffix:n,prefix:r}){const[s,i]=y.useState(String(e??""));return y.useEffect(()=>i(String(e??"")),[e]),a.jsxs("div",{className:"relative w-36",children:[r&&a.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:r}),a.jsx(ce,{type:"text",inputMode:"decimal",value:s,className:`text-right ${r?"pl-6":""} ${n?"pr-7":""}`,onChange:o=>i(o.target.value),onBlur:()=>{const o=Number(s.replace(/[$,%\s]/g,""));Number.isFinite(o)&&o!==e&&t(o)}}),n&&a.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:n})]})}function Ghe(){const e=at(),{data:t}=Ee({queryKey:["forecast","assumptions"],queryFn:async()=>{var h;const[o,l,c]=await Promise.all([Gh.from("forecast_conversion_rates").select("*"),Gh.from("forecast_settings").select("*").maybeSingle(),Gh.from("contact_experiences").select("status, experiences!inner(type, status, end_date, target_start_date), contacts!contact_experiences_contact_id_fkey!inner(contact_type)").in("status",Khe)]);for(const m of[o,l,c])if(m.error)throw m.error;const u=new Date().toISOString().slice(0,10),d=new Map;for(const m of c.data??[]){const f=m.experiences;if(f.status==="cancelled"||((h=m.contacts)==null?void 0:h.contact_type)==="organization"||!(f.status==="completed"||(f.end_date??f.target_start_date??"9999")<u))continue;const x=d.get(f.type)??{acc:0,den:0};x.den++,m.status==="accepted"&&x.acc++,d.set(f.type,x)}return{rates:new Map((o.data??[]).map(m=>[m.experience_type,Number(m.rate)])),settings:l.data,hist:d}}}),n=async(o,l)=>{const{error:c}=await Gh.from("forecast_conversion_rates").upsert({experience_type:o,rate:l});if(c)return Mt.error(c.message);e.invalidateQueries({queryKey:["forecast"]}),Mt.success("Conversion rate saved")},r=async o=>{const{error:l}=await Gh.from("forecast_settings").upsert({id:1,...o});if(l)return Mt.error(l.message);e.invalidateQueries({queryKey:["forecast"]}),Mt.success("Saved")},s=t==null?void 0:t.settings,i=(Number(s==null?void 0:s.expected_annual_profit)||0)*(Number(s==null?void 0:s.tax_rate)||0)/100/4;return a.jsxs("div",{className:"grid gap-6 lg:grid-cols-2 items-start",children:[a.jsxs(gn,{children:[a.jsxs(fr,{children:[a.jsx(mr,{className:"text-base",children:"Conversion rates"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Weights the pipeline on the Expected line: each invited, considering or interested person counts at this share of their price. History = accepted ÷ invited on past trips (organizations excluded)."})]}),a.jsx(bn,{children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Type"}),a.jsx(Le,{children:"History"}),a.jsx(Le,{className:"text-right",children:"Rate used"})]})}),a.jsx(Bn,{children:Whe.map(o=>{const l=t==null?void 0:t.hist.get(o.k);return a.jsxs(yt,{children:[a.jsx(Te,{children:o.l}),a.jsx(Te,{className:"text-muted-foreground text-sm",children:l!=null&&l.den?`${Math.round(l.acc/l.den*100)}% (${l.acc} of ${l.den})`:"No history"}),a.jsx(Te,{className:"flex justify-end",children:a.jsx(Gw,{value:(t==null?void 0:t.rates.get(o.k))??0,suffix:"%",onSave:c=>n(o.k,c)})})]},o.k)})})]})})]}),a.jsxs(gn,{children:[a.jsxs(fr,{children:[a.jsx(mr,{className:"text-base",children:"Estimated tax"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"One figure for all three lines, from this year's expected profit. Paid quarterly on Apr 15, Jun 15, Sep 15 and Jan 15. Shown on the chart as an assumption."})]}),a.jsxs(bn,{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(xe,{children:"Expected profit this year"}),a.jsx(Gw,{prefix:"$",value:Number(s==null?void 0:s.expected_annual_profit)||0,onSave:o=>r({expected_annual_profit:o})})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(xe,{children:"Tax rate"}),a.jsx(Gw,{suffix:"%",value:Number(s==null?void 0:s.tax_rate)||0,onSave:o=>r({tax_rate:o})})]}),a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:"Each quarterly payment"}),a.jsx("span",{className:"font-semibold",children:Hhe(i)})]})]})]})]})}const Vhe=nh("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),wy=y.forwardRef(({className:e,variant:t,...n},r)=>a.jsx("div",{ref:r,role:"alert",className:Se(Vhe({variant:t}),e),...n}));wy.displayName="Alert";const _y=y.forwardRef(({className:e,...t},n)=>a.jsx("h5",{ref:n,className:Se("mb-1 font-medium leading-none tracking-tight",e),...t}));_y.displayName="AlertTitle";const jy=y.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Se("text-sm [&_p]:leading-relaxed",e),...t}));jy.displayName="AlertDescription";const Rg=F,Vh=e=>
840(Number(e)||0).toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),Vw=()=>new Date().toISOString().slice(0,10),Yhe=(e,t)=>e.period_start<=t.period_end&&e.period_end>=t.period_start;function Qhe(){const e=at(),{data:t}=Ee({queryKey:["forecast","royalties"],queryFn:async()=>{const[f,x]=await Promise.all([Rg.from("royalty_expected").select("*").order("period_start"),Rg.from("royalty_statements").select("*").order("received_date",{ascending:!1})]);if(f.error)throw f.error;if(x.error)throw x.error;return{expected:f.data,statements:x.data}}}),n=()=>e.invalidateQueries({queryKey:["forecast"]}),[r,s]=y.useState({period_start:"",period_end:"",expected_date:"",amount:"",note:""}),[i,o]=y.useState({received_date:Vw(),period_start:"",period_end:"",amount:"",note:""}),l=async(f,x,g)=>{if(!x.period_start||!x.period_end||x.amount==="")return Mt.error("Period and amount are required");const{error:p}=await Rg.from(f).insert({...x,amount:Number(String(x.amount).replace(/[$,]/g,""))||0});if(p)return Mt.error(p.message);g(),n()},c=async(f,x)=>{const{error:g}=await Rg.from(f).delete().eq("id",x);g&&Mt.error(g.message),n()},u=((t==null?void 0:t.expected)??[]).map(f=>{const x=((t==null?void 0:t.statements)??[]).filter(v=>v.source===f.source&&Yhe(v,f)),g=x.reduce((v,b)=>v+Number(b.amount),0),p=x.length?"received":f.expected_date<Vw()?"missing":"upcoming";return{...f,received:g,status:p}}),d=u.filter(f=>f.status==="missing"),h=((t==null?void 0:t.statements)??[]).slice(0,4),m=h.length?h.reduce((f,x)=>f+Number(x.amount),0)/h.length:0;return a.jsxs("div",{className:"space-y-6",children:[d.length>0&&a.jsxs(wy,{variant:"destructive",children:[a.jsx(za,{className:"h-4 w-4"}),a.jsxs(_y,{children:[d.length," expected royalty statement",d.length===1?" hasn't":"s haven't"," arrived"]}),a.jsxs(jy,{children:[d.map(f=>`${f.source} ${f.period_start} â ${f.period_end} (due ${f.expected_date}, ${Vh(f.amount)})`).join("; "),". Chase these before they go unclaimed."]})]}),a.jsxs(gn,{children:[a.jsxs(fr,{children:[a.jsx(mr,{className:"text-base",children:"Expected royalties (Wanderwell)"}),a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Enter the expected amount per period. Each one counts on the forecast until a statement for that period is logged below. ",h.length?`Last ${h.length} statements averaged ${Vh(m)} â use this to adjust.`:""]})]}),a.jsx(bn,{children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Period"}),a.jsx(Le,{children:"Expected by"}),a.jsx(Le,{className:"text-right",children:"Expected"}),a.jsx(Le,{className:"text-right",children:"Received"}),a.jsx(Le,{children:"Status"}),a.jsx(Le,{children:"Note"}),a.jsx(Le,{})]})}),a.jsxs(Bn,{children:[u.map(f=>a.jsxs(yt,{children:[a.jsxs(Te,{className:"whitespace-nowrap",children:[f.period_start," â ",f.period_end]}),a.jsx(Te,{children:f.expected_date}),a.jsx(Te,{className:"text-right",children:Vh(f.amount)}),a.jsx(Te,{className:"text-right",children:f.status==="received"?Vh(f.received):"â"}),a.jsx(Te,{children:f.status==="missing"?a.jsx(Ge,{variant:"destructive",children:"Missing"}):f.status==="received"?a.jsx(Ge,{variant:"secondary",children:"Received"}):a.jsx(Ge,{variant:"outline",children:"Upcoming"})}),a.jsx(Te,{className:"text-sm text-muted-foreground",children:f.note}),a.jsx(Te,{children:a.jsx(Y,{size:"icon",variant:"ghost",onClick:()=>c("royalty_expected",f.id),children:a.jsx(pn,{className:"h-4 w-4"})})})]},f.id)),a.jsxs(yt,{children:[a.jsxs(Te,{className:"flex gap-1",children:[a.jsx(ce,{type:"date",value:r.period_start,onChange:f=>s({...r,period_start:f.target.value})}),a.jsx(ce,{type:"date",value:r.period_end,onChange:f=>s({...r,period_end:f.target.value})})]}),a.jsx(Te,{children:a.jsx(ce,{type:"date",value:r.expected_date,onChange:f=>s({...r,expected_date:f.target.value})})}),a.jsx(Te,{children:a.jsx(ce,{inputMode:"decimal",placeholder:"Amount",className:"text-right",value:r.amount,onChange:f=>s({...r,amount:f.target.value})})}),a.jsx(Te,{colSpan:2}),a.jsx(Te,{children:a.jsx(ce,{placeholder:"Note",value:r.note,onChange:f=>s({...r,note:f.target.value})})}),a.jsx(Te,{children:a.jsx(Y,{size:"icon",onClick:()=>l("royalty_expected",{...r,expected_date:r.expected_date||r.period_end},()=>s({period_start:"",period_end:"",expected_date:"",amount:"",note:""})),children:a.jsx(zt,{className:"h-4 w-4"})})})]})]})]})})]}),a.jsxs(gn,{children:[a.jsxs(fr,{children:[a.jsx(mr,{className:"text-base",children:"Royalty statements received"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Log each statement. If it names participants or trips, put that in the note."})]}),a.jsx(bn,{children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Received"}),a.jsx(Le,{children:"Period covered"}),a.jsx(Le,{className:"text-right",children:"Amount"}),a.jsx(Le,{children:"Note"}),a.jsx(Le,{})]})}),a.jsxs(Bn,{children:[((t==null?void 0:t.statements)??[]).map(f=>a.jsxs(yt,{children:[a.jsx(Te,{children:f.received_date}),a.jsxs(Te,{className:"whitespace-nowrap",children:[f.period_start," â ",f.period_end]}),a.jsx(Te,{className:"text-right",children:Vh(f.amount)}),a.jsx(Te,{className:"text-sm text-muted-foreground",children:f.note}),a.jsx(Te,{children:a.jsx(Y,{size:"icon",variant:"ghost",onClick:()=>c("royalty_statements",f.id),children:a.jsx(pn,{className:"h-4 w-4"})})})]},f.id)),a.jsxs(yt,{children:[a.jsx(Te,{children:a.jsx(ce,{type:"date",value:i.received_date,onChange:f=>o({...i,received_date:f.target.value})})}),a.jsxs(Te,{className:"flex gap-1",children:[a.jsx(ce,{type:"date",value:i.peri
840od_start,onChange:f=>o({...i,period_start:f.target.value})}),a.jsx(ce,{type:"date",value:i.period_end,onChange:f=>o({...i,period_end:f.target.value})})]}),a.jsx(Te,{children:a.jsx(ce,{inputMode:"decimal",placeholder:"Amount",className:"text-right",value:i.amount,onChange:f=>o({...i,amount:f.target.value})})}),a.jsx(Te,{children:a.jsx(ce,{placeholder:"Note",value:i.note,onChange:f=>o({...i,note:f.target.value})})}),a.jsx(Te,{children:a.jsx(Y,{size:"icon",onClick:()=>l("royalty_statements",i,()=>o({received_date:Vw(),period_start:"",period_end:"",amount:"",note:""})),children:a.jsx(zt,{className:"h-4 w-4"})})})]})]})]})})]})]})}const Yh=e=>(e??0).toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),Xhe=e=>e?new Date(e+"T00:00:00").toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"â";function Jhe(){const[e,t]=y.useState(!1),{data:n,isLoading:r}=Ee({queryKey:["ar_aging"],queryFn:async()=>{const{data:u,error:d}=await F.rpc("get_ar_aging");if(d)throw d;return u??[]}}),s=y.useMemo(()=>{const u={coaching:{under90:0,over90:0},experience:{under90:0,over90:0}};for(const d of n??[]){const h=Number(d.amount)||0,m=d.source==="coaching"?u.coaching:u.experience;d.bucket==="90plus"?m.over90+=h:m.under90+=h}return u},[n]),i=y.useMemo(()=>(n??[]).filter(u=>u.bucket==="90plus").sort((u,d)=>d.days_past_due-u.days_past_due),[n]),o=s.coaching.under90+s.experience.under90,l=s.coaching.over90+s.experience.over90,c=[{label:"Coaching",under:s.coaching.under90,over:s.coaching.over90},{label:"Experiences",under:s.experience.under90,over:s.experience.over90},{label:"Total",under:o,over:l,bold:!0}];return a.jsxs(a.Fragment,{children:[a.jsxs(gn,{children:[a.jsx(fr,{children:a.jsx(mr,{className:"text-base",children:"Accounts Receivable"})}),a.jsx(bn,{children:r?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{className:"w-[40%]",children:" "}),a.jsx(Le,{className:"text-right",children:"< 90 days"}),a.jsx(Le,{className:"text-right",children:"90+ days"}),a.jsx(Le,{className:"text-right",children:"Total"})]})}),a.jsx(Bn,{children:c.map(u=>a.jsxs(yt,{children:[a.jsx(Te,{className:u.bold?"font-semibold":"",children:u.label}),a.jsx(Te,{className:`text-right ${u.bold?"font-semibold":""}`,children:Yh(u.under)}),a.jsx(Te,{className:`text-right p-0 ${u.bold?"font-semibold":""}`,children:u.over>0?a.jsx("button",{type:"button",onClick:()=>t(!0),className:"w-full h-full px-4 py-2 text-right underline underline-offset-4 hover:bg-muted/50",title:"See who is late paying",children:Yh(u.over)}):a.jsx("span",{className:"block px-4 py-2",children:Yh(u.over)})}),a.jsx(Te,{className:`text-right ${u.bold?"font-semibold":""}`,children:Yh(u.under+u.over)})]},u.label))})]})})]}),a.jsx(Dt,{open:e,onOpenChange:t,children:a.jsxs(Pt,{className:"max-w-3xl",children:[a.jsx(Ot,{children:a.jsx(At,{children:"90+ Days Past Due"})}),a.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Contact"}),a.jsx(Le,{children:"Item"}),a.jsx(Le,{children:"Due"}),a.jsx(Le,{className:"text-right",children:"Days late"}),a.jsx(Le,{className:"text-right",children:"Balance"})]})}),a.jsx(Bn,{children:i.length===0?a.jsx(yt,{children:a.jsx(Te,{colSpan:5,className:"text-sm text-muted-foreground",children:"Nothing is 90+ days past due."})}):i.map((u,d)=>a.jsxs(yt,{children:[a.jsx(Te,{children:a.jsx("a",{href:`/?contact=${u.contact_id}`,className:"underline underline-offset-4",children:u.contact_name})}),a.jsx(Te,{children:u.label}),a.jsx(Te,{children:Xhe(u.due_date)}),a.jsx(Te,{className:"text-right",children:u.days_past_due}),a.jsx(Te,{className:"text-right",children:Yh(Number(u.amount)||0)})]},`${u.contact_id}-${u.label}-${d}`))})]})})]})})]})}const Yw=e=>(e??0).toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),Qw=e=>Math.round(e*100)/100;function Zhe(){const e=at(),{data:t,isLoading:n}=b6(),r={staleTime:5*60*1e3,gcTime:30*60*1e3,refetchOnWindowFocus:!1},{data:s}=Ee({...r,queryKey:["payouts_coaching"],queryFn:async()=>{const{data:d,error:h}=await F.from("contact_coaching").select("id, generator_id, amount_paid, pct_sales_commission, pct_paid_to_delivery, contacts(name), generators(name)").gt("amount_paid",0);if(h)throw h;return d??[]}}),{data:i}=Ee({...r,queryKey:["payouts_experience_dates"],queryFn:async()=>{const{data:d,error:h}=await F.from("experiences").select("id, target_start_date");if(h)throw h;return d??[]}}),{data:o}=Ee({...r,queryKey:["generator-payouts-all"],queryFn:async()=>{const{data:d,error:h}=await F.from("generator_payouts").select("generator_id, experience_id, coaching_id, payout_type, amount");if(h)throw h;return d??[]}}),l=y.useMemo(()=>{var x,g;const d=new Date().toISOString().slice(0,10),h=new Map((i??[]).map(p=>[p.id,p.target_start_date])),m=new Map;for(const p of o??[]){const v=p.payout_type==="experience"?`exp:${p.experience_id}:${p.generator_id}`:`${p.payout_type}:${p.coaching_id}`;m.set(v,(m.get(v)??0)+Number(p.amount||0))}const f=[];for(const p of(t==null?void 0:t.rows)??[]){const v=h.get(p.experience_id);if(!v||v>d)continue;const b=Qw(p.earned-(m.get(`exp:${p.experience_id}:${p.generator_id}`)??0));b<=.5||f.push({key:`exp:${p.experience_id}:${p.generator_id}`,generator_id:p.generator_id,generator_name:p.generator_name,label:p.generator_name,sublabel:`Gen/Guide comp · ${p.experience_name}`,amount:b,experience_id:p.experience_id,coaching_id:null,payout_type:"experience"})}for(const p of s??[]){const v=p.generator_id;if(!v)continue;const b=Number(p.amount_paid)||0;if(b<=0)continue;const w=((x=p.generators)==null?void 0:x.name)??"Team member",N=((g=p.contacts)==null?void 0:g.name)??"Coaching",j=[["coaching_commission","Sales commission",Number(p.pct_sales_commission)||0],["coaching_delivery","Delivery",Number(p.pct_paid_to_delivery)||0]];for(const[_,S,P]of j){if(P<=0)continue;
840const k=Qw(b*P/100),C=Qw(k-(m.get(`${_}:${p.id}`)??0));C<=.5||f.push({key:`${_}:${p.id}`,generator_id:v,generator_name:w,label:w,sublabel:`Coaching ${S.toLowerCase()} (${P}% of ${Yw(b)}) · ${N}`,amount:C,experience_id:null,coaching_id:p.id,payout_type:_})}}return f.sort((p,v)=>v.amount-p.amount||p.generator_name.localeCompare(v.generator_name))},[t,s,i,o]),c=l.reduce((d,h)=>d+h.amount,0),u=Me({mutationFn:async d=>{var f;const{data:h}=await F.auth.getUser(),{error:m}=await F.from("generator_payouts").insert({generator_id:d.generator_id,experience_id:d.experience_id,coaching_id:d.coaching_id,payout_type:d.payout_type,amount:d.amount,paid_on:new Date().toISOString().slice(0,10),note:d.sublabel.slice(0,200),created_by:((f=h==null?void 0:h.user)==null?void 0:f.id)??null});if(m)throw m},onSuccess:()=>{e.invalidateQueries({queryKey:["generator-payouts-all"]}),e.invalidateQueries({queryKey:["generator-payouts"]}),e.invalidateQueries({queryKey:["generator-earnings"]}),Mt.success("Payout recorded")},onError:d=>Mt.error(d.message)});return a.jsxs(gn,{children:[a.jsxs(fr,{className:"flex flex-row items-center justify-between space-y-0",children:[a.jsx(mr,{className:"text-base",children:"Payouts to Make"}),a.jsx("span",{className:"text-sm font-semibold tabular-nums",children:Yw(c)})]}),a.jsx(bn,{children:n?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):l.length===0?a.jsx("p",{className:"text-sm text-muted-foreground",children:"No payouts currently due."}):a.jsx(Ic,{className:"max-h-64",children:a.jsx("div",{className:"divide-y divide-border",children:l.map(d=>a.jsxs("div",{className:"flex items-center justify-between gap-3 py-2",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-sm truncate",children:d.label}),a.jsx("div",{className:"text-[11px] text-muted-foreground truncate",children:d.sublabel})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("span",{className:"text-sm font-semibold tabular-nums",children:Yw(d.amount)}),a.jsx(Y,{size:"sm",variant:"outline",className:"h-7 px-2 text-xs",disabled:u.isPending,onClick:()=>u.mutate(d),children:"Mark paid"})]})]},d.key))})})})]})}var efe=Array.isArray,ka=efe,tfe=typeof Vo=="object"&&Vo&&Vo.Object===Object&&Vo,Y8=tfe,nfe=Y8,rfe=typeof self=="object"&&self&&self.Object===Object&&self,afe=nfe||rfe||Function("return this")(),ki=afe,sfe=ki,ife=sfe.Symbol,Dp=ife,LA=Dp,Q8=Object.prototype,ofe=Q8.hasOwnProperty,lfe=Q8.toString,Qh=LA?LA.toStringTag:void 0;function cfe(e){var t=ofe.call(e,Qh),n=e[Qh];try{e[Qh]=void 0;var r=!0}catch{}var s=lfe.call(e);return r&&(t?e[Qh]=n:delete e[Qh]),s}var ufe=cfe,dfe=Object.prototype,hfe=dfe.toString;function ffe(e){return hfe.call(e)}var mfe=ffe,FA=Dp,pfe=ufe,gfe=mfe,xfe="[object Null]",yfe="[object Undefined]",qA=FA?FA.toStringTag:void 0;function vfe(e){return e==null?e===void 0?yfe:xfe:qA&&qA in Object(e)?pfe(e):gfe(e)}var vo=vfe;function bfe(e){return e!=null&&typeof e=="object"}var bo=bfe,wfe=vo,_fe=bo,jfe="[object Symbol]";function Nfe(e){return typeof e=="symbol"||_fe(e)&&wfe(e)==jfe}var gh=Nfe,Sfe=ka,Cfe=gh,kfe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Efe=/^\w*$/;function Pfe(e,t){if(Sfe(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Cfe(e)?!0:Efe.test(e)||!kfe.test(e)||t!=null&&e in Object(t)}var Hk=Pfe;function Ofe(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Tl=Ofe;const xh=dn(Tl);var Afe=vo,Tfe=Tl,Mfe="[object AsyncFunction]",Dfe="[object Function]",$fe="[object GeneratorFunction]",Rfe="[object Proxy]";function Ife(e){if(!Tfe(e))return!1;var t=Afe(e);return t==Dfe||t==$fe||t==Mfe||t==Rfe}var Gk=Ife;const Bt=dn(Gk);var Lfe=ki,Ffe=Lfe["__core-js_shared__"],qfe=Ffe,Xw=qfe,zA=function(){var e=/[^.]+$/.exec(Xw&&Xw.keys&&Xw.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function zfe(e){return!!zA&&zA in e}var Bfe=zfe,Ufe=Function.prototype,Wfe=Ufe.toString;function Kfe(e){if(e!=null){try{return Wfe.call(e)}catch{}try{return e+""}catch{}}return""}var X8=Kfe,Hfe=Gk,Gfe=Bfe,Vfe=Tl,Yfe=X8,Qfe=/[\\^$.*+?()[\]{}|]/g,Xfe=/^\[object .+?Constructor\]$/,Jfe=Function.prototype,Zfe=Object.prototype,eme=Jfe.toString,tme=Zfe.hasOwnProperty,nme=RegExp("^"+eme.call(tme).replace(Qfe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function rme(e){if(!Vfe(e)||Gfe(e))return!1;var t=Hfe(e)?nme:Xfe;return t.test(Yfe(e))}var ame=rme;function sme(e,t){return e==null?void 0:e[t]}var ime=sme,ome=ame,lme=ime;function cme(e,t){var n=lme(e,t);return ome(n)?n:void 0}var Yc=cme,ume=Yc,dme=ume(Object,"create"),Lb=dme,BA=Lb;function hme(){this.__data__=BA?BA(null):{},this.size=0}var fme=hme;function mme(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var pme=mme,gme=Lb,xme="__lodash_hash_undefined__",yme=Object.prototype,vme=yme.hasOwnProperty;function bme(e){var t=this.__data__;if(gme){var n=t[e];return n===xme?void 0:n}return vme.call(t,e)?t[e]:void 0}var wme=bme,_me=Lb,jme=Object.prototype,Nme=jme.hasOwnProperty;function Sme(e){var t=this.__data__;return _me?t[e]!==void 0:Nme.call(t,e)}var Cme=Sme,kme=Lb,Eme="__lodash_hash_undefined__";function Pme(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=kme&&t===void 0?Eme:t,this}var Ome=Pme,Ame=fme,Tme=pme,Mme=wme,Dme=Cme,$me=Ome;function yh(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}yh.prototype.clear=Ame;yh.prototype.delete=Tme;yh.prototype.get=Mme;yh.prototype.has=Dme;yh.prototype.set=$me;var Rme=yh;function Ime(){this.__data__=[],this.size=0}var Lme=Ime;function Fme(e,t){return e===t||e!==e&&t!==t}var Vk=Fme,qme=Vk;function zme(e,t){for(var n=e.length;n--;)if(qme(e[n][0],t))return n;return-1}var Fb=zme,Bme=Fb,Ume=Array.prototype,Wme=Ume.splice;function Kme(e){var t=this.__data__,n=Bme(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Wme.call(t,n,1),--this.size,!0}var Hme=Kme,Gme=Fb;function Vme(e){var t=this.__data__,n=Gme(t,e);return n<0?void 0:t[n][1]}var Yme=Vme,Qme=Fb;function Xme(e){return Qme(this.__data__,e)>-1}var Jme=Xme,Zme=Fb;function epe(e,t){var n=this.__data__,r=Zme(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}
vendor: 1,891 bytes, line 840
840var tpe=epe,npe=Lme,rpe=Hme,ape=Yme,spe=Jme,ipe=tpe;function vh(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}vh.prototype.clear=npe;vh.prototype.delete=rpe;vh.prototype.get=ape;vh.prototype.has=spe;vh.prototype.set=ipe;var qb=vh,ope=Yc,lpe=ki,cpe=ope(lpe,"Map"),Yk=cpe,UA=Rme,upe=qb,dpe=Yk;function hpe(){this.size=0,this.__data__={hash:new UA,map:new(dpe||upe),string:new UA}}var fpe=hpe;function mpe(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var ppe=mpe,gpe=ppe;function xpe(e,t){var n=e.__data__;return gpe(t)?n[typeof t=="string"?"string":"hash"]:n.map}var zb=xpe,ype=zb;function vpe(e){var t=ype(this,e).delete(e);return this.size-=t?1:0,t}var bpe=vpe,wpe=zb;function _pe(e){return wpe(this,e).get(e)}var jpe=_pe,Npe=zb;function Spe(e){return Npe(this,e).has(e)}var Cpe=Spe,kpe=zb;function Epe(e,t){var n=kpe(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var Ppe=Epe,Ope=fpe,Ape=bpe,Tpe=jpe,Mpe=Cpe,Dpe=Ppe;function bh(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}bh.prototype.clear=Ope;bh.prototype.delete=Ape;bh.prototype.get=Tpe;bh.prototype.has=Mpe;bh.prototype.set=Dpe;var Qk=bh,J8=Qk,$pe="Expected a function";function Xk(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError($pe);var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=e.apply(this,r);return n.cache=i.set(s,o)||i,o};return n.cache=new(Xk.Cache||J8),n}Xk.Cache=J8;var Z8=Xk;const Rpe=dn(Z8);var Ipe=Z8,Lpe=500;function Fpe(e){var t=Ipe(e,function(r){return n.size===Lpe&&n.clear(),r}),n=t.cache;return t}var qpe=Fpe,zpe=qpe,Bpe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Upe=/\\(\\)?/g,Wpe=zpe(function(e){var t=[];
840return e.charCodeAt(0)===46&&t.push(""),e.replace(Bpe,function(n,r,s,i){t.push(s?i.replace(Upe,"$1"):r||n)}),t}),Kpe=Wpe;function Hpe(e,t){for(var n=-1,r=e==null?0:e.length,s=Array(r);++n<r;)s[n]=t(e[n],n,e);return s}var Jk=Hpe,WA=Dp,Gpe=Jk,Vpe=ka,Ype=gh,Qpe=1/0,KA=WA?WA.prototype:void 0,HA=KA?KA.toString:void 0;function ez(e){if(typeof e=="string")return e;if(Vpe(e))return Gpe(e,ez)+"";if(Ype(e))return HA?HA.call(e):"";var t=e+"";return t=="0"&&1/e==-Qpe?"-0":t}var Xpe=ez,Jpe=Xpe;function Zpe(e){return e==null?"":Jpe(e)}var tz=Zpe,ege=ka,tge=Hk,nge=Kpe,rge=tz;function age(e,t){return ege(e)?e:tge(e,t)?[e]:nge(rge(e))}var nz=age,sge=gh,ige=1/0;function oge(e){if(typeof e=="string"||sge(e))return e;var t=e+"";return t=="0"&&1/e==-ige?"-0":t}var Bb=oge,lge=nz,cge=Bb;function uge(e,t){t=lge(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[cge(t[n++])];return n&&n==r?e:void 0}var Zk=uge,dge=Zk;function hge(e,t,n){var r=e==null?void 0:dge(e,t);return r===void 0?n:r}var rz=hge;const cs=dn(rz);function fge(e){return e==null}var mge=fge;const Ut=dn(mge);var pge=vo,gge=ka,xge=bo,yge="[object String]";function vge(e){return typeof e=="string"||!gge(e)&&xge(e)&&pge(e)==yge}var bge=vge;const Lc=dn(bge);var az={exports:{}},hn={};/** 841 * @license React 842 * react-is.production.min.js 843 * 844 * Copyright (c) Facebook, Inc. and its affiliates. 845 * 846 * This source code is licensed under the MIT license found in the 847 * LICENSE file in the root directory of this source tree. 848 */var e2=Symbol.for("react.element"),t2=Symbol.for("react.portal"),Ub=Symbol.for("react.fragment"),Wb=Symbol.for("react.strict_mode"),Kb=Symbol.for("react.profiler"),Hb=Symbol.for("react.provider"),Gb=Symbol.for("react.context"),wge=Symbol.for("react.server_context"),Vb=Symbol.for("react.forward_ref"),Yb=Symbol.for("react.suspense"),Qb=Symbol.for("react.suspense_list"),Xb=Symbol.for("react.memo"),Jb=Symbol.for("react.lazy"),_ge=Symbol.for("react.offscreen"),sz;sz=Symbol.for("react.module.reference");function xs(e){if(typeof e=="object"&&e!==null){var t=e.$$typeof;switch(t){case e2:switch(e=e.type,e){case Ub:case Kb:case Wb:case Yb:case Qb:return e;default:switch(e=e&&e.$$typeof,e){case wge:case Gb:case Vb:case Jb:case Xb:case Hb:return e;default:return t}}case t2:return t}}}hn.ContextConsumer=Gb;hn.ContextProvider=Hb;hn.Element=e2;hn.ForwardRef=Vb;hn.Fragment=Ub;hn.Lazy=Jb;hn.Memo=Xb;hn.Portal=t2;hn.Profiler=Kb;hn.StrictMode=Wb;hn.Suspense=Yb;hn.SuspenseList=Qb;hn.isAsyncMode=function(){return!1};hn.isConcurrentMode=function(){return!1};hn.isContextConsumer=function(e){return xs(e)===Gb};hn.isContextProvider=function(e){return xs(e)===Hb};hn.isElement=function(e){return typeof e=="object"&&e!==null&&e.$$typeof===e2};hn.isForwardRef=function(e){return xs(e)===Vb};hn.isFragment=function(e){return xs(e)===Ub};hn.isLazy=function(e){return xs(e)===Jb};hn.isMemo=function(e){return xs(e)===Xb};hn.isPortal=function(e){return xs(e)===t2};hn.isProfiler=function(e){return xs(e)===Kb};hn.isStrictMode=function(e){return xs(e)===Wb};hn.isSuspense=function(e){return xs(e)===Yb};hn.isSuspenseList=function(e){return xs(e)===Qb};hn.isValidElementType=function(e){return typeof e=="string"||typeof e=="function"||e===Ub||e===Kb||e===Wb||e===Yb||e===Qb||e===_ge||typeof e=="object"&&e!==null&&(e.$$typeof===Jb||e.$$typeof===Xb||e.$$typeof===Hb||e.$$typeof===Gb||e.$$typeof===Vb||e.$$typeof===sz||e.getModuleId!==void 0)};hn.typeOf=xs;az.exports=hn;var jge=az.exports,Nge=vo,Sge=bo,Cge="[object Number]";function kge(e){return typeof e=="number"||Sge(e)&&Nge(e)==Cge}var iz=kge;const Ege=dn(iz);var Pge=iz;function Oge(e){return Pge(e)&&e!=+e}var Age=Oge;const $p=dn(Age);var zs=function(t){return t===0?0:t>0?1:-1},ac=function(t){return Lc(t)&&t.indexOf("%")===t.length-1},Xe=function(t){return Ege(t)&&!$p(t)},Tge=function(t){return Ut(t)},ur=function(t){return Xe(t)||Lc(t)},Mge=0,Rp=function(t){var n=++Mge;return"".concat(t||"").concat(n)},Fc=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Xe(t)&&!Lc(t))return r;var i;if(ac(t)){var o=t.indexOf("%");i=n*parseFloat(t.slice(0,o))/100}else i=+t;return $p(i)&&(i=r),s&&i>n&&(i=n),i},Io=function(t){if(!t)return null;var n=Object.keys(t);
vendor: 5,203 bytes, line 848
848return n&&n.length?t[n[0]]:null},Dge=function(t){if(!Array.isArray(t))return!1;for(var n=t.length,r={},s=0;s<n;s++)if(!r[t[s]])r[t[s]]=!0;else return!0;return!1},Ls=function(t,n){return Xe(t)&&Xe(n)?function(r){return t+r*(n-t)}:function(){return n}};function Ny(e,t,n){return!e||!e.length?null:e.find(function(r){return r&&(typeof t=="function"?t(r):cs(r,t))===n})}var $ge=function(t,n){return Xe(t)&&Xe(n)?t-n:Lc(t)&&Lc(n)?t.localeCompare(n):t instanceof Date&&n instanceof Date?t.getTime()-n.getTime():String(t).localeCompare(String(n))};function rd(e,t){for(var n in e)if({}.hasOwnProperty.call(e,n)&&(!{}.hasOwnProperty.call(t,n)||e[n]!==t[n]))return!1;for(var r in t)if({}.hasOwnProperty.call(t,r)&&!{}.hasOwnProperty.call(e,r))return!1;return!0}function M1(e){"@babel/helpers - typeof";return M1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M1(e)}var Rge=["viewBox","children"],Ige=["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"],GA=["points","pathLength"],Jw={svg:Rge,polygon:GA,polyline:GA},n2=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onF
848ocus","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"],Sy=function(t,n){if(!t||typeof t=="function"||typeof t=="boolean")return null;var r=t;if(y.isValidElement(t)&&(r=t.props),!xh(r))return null;var s={};return Object.keys(r).forEach(function(i){n2.includes(i)&&(s[i]=n||function(o){return r[i](r,o)})}),s},Lge=function(t,n,r){return function(s){return t(n,r,s),null}},Cy=function(t,n,r){if(!xh(t)||M1(t)!=="object")return null;var s=null;return Object.keys(t).forEach(function(i){var o=t[i];n2.includes(i)&&typeof o=="function"&&(s||(s={}),s[i]=Lge(o,n,r))}),s},Fge=["children"],qge=["children"];function VA(e,t){if(e==null)return{};var n=zge(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function zge(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function D1(e){"@babel/helpers - typeof";return D1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},D1(e)}var YA={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"}
vendor: 5,443 bytes, line 848
848,Vi=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},QA=null,Zw=null,r2=function e(t){if(t===QA&&Array.isArray(Zw))return Zw;var n=[];return y.Children.forEach(t,function(r){Ut(r)||(jge.isFragment(r)?n=n.concat(e(r.props.children)):n.push(r))}),Zw=n,QA=t,n};function us(e,t){var n=[],r=[];return Array.isArray(t)?r=t.map(function(s){return Vi(s)}):r=[Vi(t)],r2(e).forEach(function(s){var i=cs(s,"type.displayName")||cs(s,"type.name");r.indexOf(i)!==-1&&n.push(s)}),n}function Ma(e,t){var n=us(e,t);return n&&n[0]}var XA=function(t){if(!t||!t.props)return!1;var n=t.props,r=n.width,s=n.height;return!(!Xe(r)||r<=0||!Xe(s)||s<=0)},Bge=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],Uge=function(t){return t&&t.type&&Lc(t.type)&&Bge.indexOf(t.type)>=0},Wge=function(t){return t&&D1(t)==="object"&&"clipDot"in t},Kge=function(t,n,r,s){var i,o=(i=Jw==null?void 0:Jw[s])!==null&&i!==void 0?i:[];return n.startsWith("data-")||!Bt(t)&&(s&&o.includes(n)||Ige.includes(n))||r&&n2.includes(n)},Yt=function(t,n,r){if(!t||typeof t=="function"||typeof t=="boolean")return null;var s=t;if(y.isValidElement(t)&&(s=t.props),!xh(s))return null;var i={};return Object.keys(s).forEach(function(o){var l;Kge((l=s)===null||l===void 0?void 0:l[o],o,n,r)&&(i[o]=s[o])}),i},$1=function e(t,n){if(t===n)return!0;var r=y.Children.count(t);if(r!==y.Children.count(n))return!1;if(r===0)return!0;if(r===1)return JA(Array.isArray(t)?t[0]:t,Array.isArray(n)?n[0]:n);for(var s=0;s<r;s++){var i=t[s],o=n[s];if(Array.isArray(i)||Array.isArray(o)){if(!e(i,o))return!1}else if(!JA(i,o))return!1}return!0},JA=function(t,n){if(Ut(t)&&Ut(n))return!0;if(!Ut(t)&&!Ut(n)){var r=t.props||{},s=r.children,i=VA(r,Fge),o=n.props||{},l=o.children,c=VA(o,qge);return s&&l?rd(i,c)&&$1(s,l):!s&&!l?rd(i,c):!1}return!1},ZA=function(t,n){var r=[],s={};return r2(t).forEach(function(i,o){if(Uge(i))r.push(i);else if(i){var l=Vi(i.type),c=n[l]||{},u=c.handler,d=c.once;if(u&&(!d||!s[l])){var h=u(i,l,o);r.push(h),s[l]=!0}}}),r},Hge=function(t){var n=t&&t.type;return n&&YA[n]?YA[n]:null},Gge=function(t,n){return r2(n).indexOf(t)},Vge=["children","width","height","viewBox","className","style","title","desc"];function R1(){return R1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},R1.apply(this,arguments)}function Yge(e,t){if(e==null)return{};var n=Qge(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Qge(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function I1(e){var t=e.children,n=e.width,r=e.height,s=e.viewBox,i=e.className,o=e.style,l=e.title,c=e.desc,u=Yge(e,Vge),d=s||{width:n,height:r,x:0,y:0},h=Qt("recharts-surface",i);return ae.createElement("svg",R1({},Yt(u,!0,"svg"),{className:h,width:n,height:r,style:o,viewBox:"".concat(d.x," ").concat(d.y," ").concat(d.width," ").concat(d.height)}),ae.createElement("title",null,l),ae.createElement("desc",null,c),t)}var Xge=["children","className"];function L1(){return L1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},L1.apply(this,arguments)}function Jge(e,t){if(e==null)return{};var n=Zge(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Zge(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var Hn=ae.forwardRef(function(e,t){var n=e.children,r=e.className,s=Jge(e,Xge),i=Qt("recharts-layer",r);return ae.createElement("g",L1({className:i},Yt(s,!0),{ref:t}),n)}),Yi=function(t,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i]};function exe(e,t,n){var r=-1,s=e.length;t<0&&(t=-t>s?0:s+t),n=n>s?s:n,n<0&&(n+=s),s=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(s);++r<s;)i[r]=e[r+t];return i}var txe=exe,nxe=txe;function rxe(e,t,n){var r=e.length;return n=n===void 0?r:n,!t&&n>=r?e:nxe(e,t,n)}var axe=rxe,sxe="\\ud800-\\udfff",ixe="\\u0300-\\u036f",oxe="\\ufe20-\\ufe2f",lxe="\\u20d0-\\u20ff",cxe=ixe+oxe+lxe,uxe="\\ufe0e\\ufe0f",dxe="\\u200d",hxe=Reg
vendor: 6,520 bytes, line 848
848Exp("["+dxe+sxe+cxe+uxe+"]");function fxe(e){return hxe.test(e)}var oz=fxe;function mxe(e){return e.split("")}var pxe=mxe,lz="\\ud800-\\udfff",gxe="\\u0300-\\u036f",xxe="\\ufe20-\\ufe2f",yxe="\\u20d0-\\u20ff",vxe=gxe+xxe+yxe,bxe="\\ufe0e\\ufe0f",wxe="["+lz+"]",F1="["+vxe+"]",q1="\\ud83c[\\udffb-\\udfff]",_xe="(?:"+F1+"|"+q1+")",cz="[^"+lz+"]",uz="(?:\\ud83c[\\udde6-\\uddff]){2}",dz="[\\ud800-\\udbff][\\udc00-\\udfff]",jxe="\\u200d",hz=_xe+"?",fz="["+bxe+"]?",Nxe="(?:"+jxe+"(?:"+[cz,uz,dz].join("|")+")"+fz+hz+")*",Sxe=fz+hz+Nxe,Cxe="(?:"+[cz+F1+"?",F1,uz,dz,wxe].join("|")+")",kxe=RegExp(q1+"(?="+q1+")|"+Cxe+Sxe,"g");function Exe(e){return e.match(kxe)||[]}var Pxe=Exe,Oxe=pxe,Axe=oz,Txe=Pxe;function Mxe(e){return Axe(e)?Txe(e):Oxe(e)}var Dxe=Mxe,$xe=axe,Rxe=oz,Ixe=Dxe,Lxe=tz;function Fxe(e){return function(t){t=Lxe(t);var n=Rxe(t)?Ixe(t):void 0,r=n?n[0]:t.charAt(0),s=n?$xe(n,1).join(""):t.slice(1);return r[e]()+s}}var qxe=Fxe,zxe=qxe,Bxe=zxe("toUpperCase"),Uxe=Bxe;const Zb=dn(Uxe);function vn(e){return function(){return e}}const mz=Math.cos,ky=Math.sin,Zs=Math.sqrt,Ey=Math.PI,e0=2*Ey,z1=Math.PI,B1=2*z1,Vl=1e-6,Wxe=B1-Vl;function pz(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function Kxe(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return pz;const n=10**t;return function(r){this._+=r[0];for(let s=1,i=r.length;s<i;++s)this._+=Math.round(arguments[s]*n)/n+r[s]}}class Hxe{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?pz:Kxe(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,r,s){this._append`Q${+t},${+n},${this._x1=+r},${this._y1=+s}`}bezierCurveTo(t,n,r,s,i,o){this._append`C${+t},${+n},${+r},${+s},${this._x1=+i},${this._y1=+o}`}arcTo(t,n,r,s,i){if(t=+t,n=+n,r=+r,s=+s,i=+i,i<0)throw new Error(`negative radius: ${i}`);let o=this._x1,l=this._y1,c=r-t,u=s-n,d=o-t,h=l-n,m=d*d+h*h;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(m>Vl)if(!(Math.abs(h*c-u*d)>Vl)||!i)this._append`L${this._x1=t},${this._y1=n}`;else{let f=r-o,x=s-l,g=c*c+u*u,p=f*f+x*x,v=Math.sqrt(g),b=Math.sqrt(m),w=i*Math.tan((z1-Math.acos((g+m-p)/(2*v*b)))/2),N=w/b,j=w/v;Math.abs(N-1)>Vl&&this._append`L${t+N*d},${n+N*h}`,this._append`A${i},${i},0,0,${+(h*f>d*x)},${this._x1=t+j*c},${this._y1=n+j*u}`}}arc(t,n,r,s,i,o){if(t=+t,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(s),c=r*Math.sin(s),u=t+l,d=n+c,h=1^o,m=o?s-i:i-s;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Vl||Math.abs(this._y1-d)>Vl)&&this._append`L${u},${d}`,r&&(m<0&&(m=m%B1+B1),m>Wxe?this._append`A${r},${r},0,1,${h},${t-l},${n-c}A${r},${r},0,1,${h},${this._x1=u},${this._y1=d}`:m>Vl&&this._append`A${r},${r},0,${+(m>=z1)},${h},${this._x1=t+r*Math.cos(i)},${this._y1=n+r*Math.sin(i)}`)}rect(t,n,r,s){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+s}h${-r}Z`}toString(){return this._}}function a2(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new Hxe(t)}function s2(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function gz(e){this._context=e}gz.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 t0(e){return new gz(e)}function xz(e){return e[0]}function yz(e){return e[1]}function vz(e,t){var n=vn(!0),r=null,s=t0,i=null,o=a2(l);e=typeof e=="function"?e:e===void 0?xz:vn(e),t=typeof t=="function"?t:t===void 0?yz:vn(t);function l(c){var u,d=(c=s2(c)).length,h,m=!1,f;for(r==null&&(i=s(f=o())),u=0;u<=d;++u)!(u<d&&n(h=c[u],u,c))===m&&((m=!m)?i.lineStart():i.lineEnd()),m&&i.point(+e(h,u,c),+t(h,u,c));if(f)return i=null,f+""||null}return l.x=function(c){return arguments.length?(e=typeof c=="function"?c:vn(+c),l):e},l.y=function(c){return arguments.length?(t=typeof c=="function"?c:vn(+c),l):t},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:vn(!!c),l):n},l.curve=function(c){return arguments.length?(s=c,r!=null&&(i=s(r)),l):s},l.context=function(c){return arguments.length?(c==null?r=i=null:i=s(r=c),l):r},l}function Ig(e,t,n){var r=null,s=vn(!0),i=null,o=t0,l=null,c=a2(u);e=typeof e=="function"?e:e===void 0?xz:vn(+e),t=typeof t=="function"?t:vn(t===void 0?0:+t),n=typeof n=="function"?n:n===void 0?yz:vn(+n);function u(h){var m,f,x,g=(h=s2(h)).length,p,v=!1,b,w=new Array(g),N=new Array(g);for(i==null&&(l=o(b=c())),m=0;m<=g;++m){if(!(m<g&&s(p=h[m],m,h))===v)if(v=!v)f=m,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=m-1;x>=f;--x)l.point(w[x],N[x]);l.lineEnd(),l.areaEnd()}v&&(w[m]=+e(p,m,h),N[m]=+t(p,m,h),l.point(r?+r(p,m,h):w[m],n?+n(p,m,h):N[m]))}if(b)return l=null,b+""||null}function d(){return vz().defined(s).curve(o).context(i)}return u.x=function(h){return arguments.length?(e=typeof h=="function"?h:vn(+h),r=null,u):e},u.x0=function(h){return arguments.length?(e=typeof h=="function"?h:vn(+h),u):e},u.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:vn(+h),u):r},u.y=function(h){return arguments.length?(t=typeof h=="function"?h:vn(+h),n=null,u):t},u.y0=function(h){return arguments.length?(t=typeof h=="function"?h:vn(+h),u):t},u.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:vn(+h),u):n},u.lineX0=u.lineY0=function(){return d().x(e).y(t)},u.lineY1=function(){return d().x(e).y(n)},u.lineX1=function(){return d().x(r).y(t)},u.defined=function(h){return arguments.length?(s=typeof h=="function"?h:vn(!!h),u):s},u.curve=function(h){return arguments.length?(o=h,i!=null&&(l=o(i)),u):o},u.context=function(h){return arguments.length?(h==null?i=l=null:l=o(i=h),u):i},u}class bz{constructor(t,n){this._context=t,this._x=n}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}
vendor: 8,443 bytes, line 848
848point(t,n){switch(t=+t,n=+n,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n);break}}this._x0=t,this._y0=n}}function Gxe(e){return new bz(e,!0)}function Vxe(e){return new bz(e,!1)}const i2={draw(e,t){const n=Zs(t/Ey);e.moveTo(n,0),e.arc(0,0,n,0,e0)}},Yxe={draw(e,t){const n=Zs(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()}},wz=Zs(1/3),Qxe=wz*2,Xxe={draw(e,t){const n=Zs(t/Qxe),r=n*wz;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},Jxe={draw(e,t){const n=Zs(t),r=-n/2;e.rect(r,r,n,n)}},Zxe=.8908130915292852,_z=ky(Ey/10)/ky(7*Ey/10),eye=ky(e0/10)*_z,tye=-mz(e0/10)*_z,nye={draw(e,t){const n=Zs(t*Zxe),r=eye*n,s=tye*n;e.moveTo(0,-n),e.lineTo(r,s);for(let i=1;i<5;++i){const o=e0*i/5,l=mz(o),c=ky(o);e.lineTo(c*n,-l*n),e.lineTo(l*r-c*s,c*r+l*s)}e.closePath()}},e_=Zs(3),rye={draw(e,t){const n=-Zs(t/(e_*3));e.moveTo(0,n*2),e.lineTo(-e_*n,-n),e.lineTo(e_*n,-n),e.closePath()}},Ya=-.5,Qa=Zs(3)/2,U1=1/Zs(12),aye=(U1/2+1)*3,sye={draw(e,t){const n=Zs(t/aye),r=n/2,s=n*U1,i=r,o=n*U1+n,l=-i,c=o;e.moveTo(r,s),e.lineTo(i,o),e.lineTo(l,c),e.lineTo(Ya*r-Qa*s,Qa*r+Ya*s),e.lineTo(Ya*i-Qa*o,Qa*i+Ya*o),e.lineTo(Ya*l-Qa*c,Qa*l+Ya*c),e.lineTo(Ya*r+Qa*s,Ya*s-Qa*r),e.lineTo(Ya*i+Qa*o,Ya*o-Qa*i),e.lineTo(Ya*l+Qa*c,Ya*c-Qa*l),e.closePath()}};function iye(e,t){let n=null,r=a2(s);e=typeof e=="function"?e:vn(e||i2),t=typeof t=="function"?t:vn(t===void 0?64:+t);function s(){let i;if(n||(n=i=r()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),i)return n=null,i+""||null}return s.type=function(i){return arguments.length?(e=typeof i=="function"?i:vn(i),s):e},s.size=function(i){return arguments.length?(t=typeof i=="function"?i:vn(+i),s):t},s.context=function(i){return arguments.length?(n=i??null,s):n},s}function Py(){}function Oy(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 jz(e){this._context=e}jz.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:Oy(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:Oy(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function oye(e){return new jz(e)}function Nz(e){this._context=e}Nz.prototype={areaStart:Py,areaEnd:Py,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:Oy(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function lye(e){return new Nz(e)}function Sz(e){this._context=e}Sz.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:Oy(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function cye(e){return new Sz(e)}function Cz(e){this._context=e}Cz.prototype={areaStart:Py,areaEnd:Py,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 uye(e){return new Cz(e)}function eT(e){return e<0?-1:1}function tT(e,t,n){var r=e._x1-e._x0,s=t-e._x1,i=(e._y1-e._y0)/(r||s<0&&-0),o=(n-e._y1)/(s||r<0&&-0),l=(i*s+o*r)/(r+s);return(eT(i)+eT(o))*Math.min(Math.abs(i),Math.abs(o),.5*Math.abs(l))||0}function nT(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function t_(e,t,n){var r=e._x0,s=e._y0,i=e._x1,o=e._y1,l=(i-r)/3;e._context.bezierCurveTo(r+l,s+l*t,i-l,o-l*n,i,o)}function Ay(e){this._context=e}Ay.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:t_(this,this._t0,nT(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,t_(this,nT(this,n=tT(this,e,t)),n);break;default:t_(this,this._t0,n=tT(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function kz(e){this._context=new Ez(e)}(kz.prototype=Object.create(Ay.prototype)).point=function(e,t){Ay.prototype.point.call(this,t,e)};function Ez(e){this._context=e}Ez.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,s,i){this._context.bezierCurveTo(t,e,r,n,i,s)}};function dye(e){return new Ay(e)}function hye(e){return new kz(e)}function Pz(e){this._context=e}Pz.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=rT(e),s=rT(t),i=0,o=1;o<n;++i,++o)this._context.bezierCurveTo(r[0][i],s[0][i],r[1][i],s[1][i],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 rT(e){var t,n=e.length-1,r,s=new Array(n),i=new Array(n),o=new Array(n);for(s[0]=0,i[0]=2,o[0]=e[0]+2*e[1],t=1;t<n-1;++t)s[t]=1,i[t]=4,o[t]=4*e[t]+2*e[t+1];for(s[n-1]=2,i[n-1]=7,o[n-1]=8*e[n-1]+e[n],t=1;t<n;++t)r=s[t]/i[t-1],i[t]-=r,o[t]-=r*o[t-1];for(s[n-1]=o[n-1]/i[n-1],t=n-2;t>=0;--t)s[t]=(o[t]-s[t+1])/i[t];for(i[n-1]=(e[n]+s[n-1])/2,t=0;t<n-1;++t)i[t]=2*e[t+1]-s[t+1];return[s,i]}function fye(e){return new Pz(e)}function n0(e,t){this._context=e,this._t=t}n0.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;
vendor: 9,194 bytes, lines 848-851
848default:{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 mye(e){return new n0(e,.5)}function pye(e){return new n0(e,0)}function gye(e){return new n0(e,1)}function Od(e,t){if((o=e.length)>1)for(var n=1,r,s,i=e[t[0]],o,l=i.length;n<o;++n)for(s=i,i=e[t[n]],r=0;r<l;++r)i[r][1]+=i[r][0]=isNaN(s[r][1])?s[r][0]:s[r][1]}function W1(e){for(var t=e.length,n=new Array(t);--t>=0;)n[t]=t;return n}function xye(e,t){return e[t]}function yye(e){const t=[];return t.key=e,t}function vye(){var e=vn([]),t=W1,n=Od,r=xye;function s(i){var o=Array.from(e.apply(this,arguments),yye),l,c=o.length,u=-1,d;for(const h of i)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(h,o[l].key,u,i)]).data=h;for(l=0,d=s2(t(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return s.keys=function(i){return arguments.length?(e=typeof i=="function"?i:vn(Array.from(i)),s):e},s.value=function(i){return arguments.length?(r=typeof i=="function"?i:vn(+i),s):r},s.order=function(i){return arguments.length?(t=i==null?W1:typeof i=="function"?i:vn(Array.from(i)),s):t},s.offset=function(i){return arguments.length?(n=i??Od,s):n},s}function bye(e,t){if((r=e.length)>0){for(var n,r,s=0,i=e[0].length,o;s<i;++s){for(o=n=0;n<r;++n)o+=e[n][s][1]||0;if(o)for(n=0;n<r;++n)e[n][s][1]/=o}Od(e,t)}}function wye(e,t){if((s=e.length)>0){for(var n=0,r=e[t[0]],s,i=r.length;n<i;++n){for(var o=0,l=0;o<s;++o)l+=e[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}Od(e,t)}}function _ye(e,t){if(!(!((o=e.length)>0)||!((i=(s=e[t[0]]).length)>0))){for(var n=0,r=1,s,i,o;r<i;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=e[t[l]],h=d[r][1]||0,m=d[r-1][1]||0,f=(h-m)/2,x=0;x<l;++x){var g=e[t[x]],p=g[r][1]||0,v=g[r-1][1]||0;f+=p-v}c+=h,u+=f*h}s[r-1][1]+=s[r-1][0]=n,c&&(n-=u/c)}s[r-1][1]+=s[r-1][0]=n,Od(e,t)}}function bm(e){"@babel/helpers - typeof";return bm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bm(e)}var jye=["type","size","sizeType"];function K1(){return K1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K1.apply(this,arguments)}function aT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function sT(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?aT(Object(n),!0).forEach(function(r){Nye(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Nye(e,t,n){return t=Sye(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Sye(e){var t=Cye(e,"string");return bm(t)=="symbol"?t:t+""}function Cye(e,t){if(bm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(bm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function kye(e,t){if(e==null)return{};var n=Eye(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Eye(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var Oz={symbolCircle:i2,symbolCross:Yxe,symbolDiamond:Xxe,symbolSquare:Jxe,symbolStar:nye,symbolTriangle:rye,symbolWye:sye},Pye=Math.PI/180,Oye=function(t){var n="symbol".concat(Zb(t));return Oz[n]||i2},Aye=function(t,n,r){if(n==="area")return t;switch(r){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var s=18*Pye;return 1.25*t*t*(Math.tan(s)-Math.tan(s*2)*Math.pow(Math.tan(s),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},Tye=function(t,n){Oz["symbol".concat(Zb(t))]=n},o2=function(t){var n=t.type,r=n===void 0?"circle":n,s=t.size,i=s===void 0?64:s,o=t.sizeType,l=o===void 0?"area":o,c=kye(t,jye),u=sT(sT({},c),{},{type:r,size:i,sizeType:l}),d=function(){var p=Oye(r),v=iye().type(p).size(Aye(i,l,r));return v()},h=u.className,m=u.cx,f=u.cy,x=Yt(u,!0);return m===+m&&f===+f&&i===+i?ae.createElement("path",K1({},x,{className:Qt("recharts-symbols",h),transform:"translate(".concat(m,", ").concat(f,")"),d:d()})):null};o2.registerSymbol=Tye;function Ad(e){"@babel/helpers - typeof";return Ad=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ad(e)}function H1(){return H1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},H1.apply(this,arguments)}function iT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Mye(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?iT(Object(n),!0).forEach(function(r){wm(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):iT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Dye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function $ye(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Tz(r.key),r)}}function Rye(e,t,n){return t&&$ye(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Iye(e,t,n){return t=Ty(t),Lye(e,Az()?Reflect.construct(t,n||[],Ty(e).constructor):t.apply(e,n))}function Lye(e,t){if(t&&(Ad(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Fye(e)}function Fye(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Az(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Az=function(){return!!e})()}function Ty(e){return Ty=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ty(e)}function qye(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&G1(e,t)}function G1(e,t){return G1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},G1(e,t)}function wm(e,t,n){return t=Tz(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Tz(e){var t=zye(e,"string");return Ad(t)=="symbol"?t:t+""}function zye(e,t){if(Ad(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Ad(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Xa=32,l2=function(e){function t(){return Dye(this,t),Iye(this,t,arguments)}return qye(t,e),Rye(t,[{key:"renderIcon",value:function(r){var s=this.props.inactiveColor,i=Xa/2,o=Xa/6,l=Xa/3,c=r.inactive?s:r.color;if(r.type==="plainline")return ae.createElement("line",{strokeWidth:4,fill:"none",stroke:c,strokeDasharray:r.payload.strokeDasharray,x1:0,y1:i,x2:Xa,y2:i,className:"recharts-legend-icon"});if(r.type==="line")return ae.createElement("path",{strokeWidth:4,fill:"none",stroke:c,d:"M0,".concat(i,"h").concat(l,` 849 A`).concat(o,",").concat(o,",0,1,1,").concat(2*l,",").concat(i,` 850 H`).concat(Xa,"M").concat(2*l,",").concat(i,` 851 A`).concat(o,",").concat(o,",0,1,1,").concat(l,",").concat(i),className:"recharts-legend-icon"});if(r.type==="rect")return ae.createElement("path",{stroke:"none",fill:c,d:"M0,".concat(Xa/8,"h").concat(Xa,"v").concat(Xa*3/4,"h").concat(-Xa,"z"),className:"recharts-legend-icon"});if(ae.isValidElement(r.legendIcon)){var u=Mye({},r);return delete u.legendIcon,ae.cloneElement(r.legendIcon,u)}return ae.createElement(o2,{fill:c,cx:i,cy:i,size:Xa,sizeType:"diameter",type:r.type})}},{key:"renderItems",value:function(){var r=this,s=this.props,i=s.payload,o=s.iconSize,l=s.layout,c=s.formatter,u=s.inactiveColor,d={x:0,y:0,width:Xa,height:Xa}
851,h={display:l==="horizontal"?"inline-block":"block",marginRight:10},m={display:"inline-block",verticalAlign:"middle",marginRight:4};return i.map(function(f,x){var g=f.formatter||c,p=Qt(wm(wm({"recharts-legend-item":!0},"legend-item-".concat(x),!0),"inactive",f.inactive));if(f.type==="none")return null;var v=Bt(f.value)?null:f.value;Yi(!Bt(f.value),`The name property is also required when using a function for the dataKey of a chart's cartesian components. Ex: <Bar name="Name of my Data"/>`);var b=f.inactive?u:f.color;return ae.createElement("li",H1({className:p,style:h,key:"legend-item-".concat(x)},Cy(r.props,f,x)),ae.createElement(I1,{width:o,height:o,viewBox:d,style:m},r.renderIcon(f)),ae.createElement("span",{className:"recharts-legend-item-text",style:{color:b}},g?g(v,f,x):v))})}},{key:"render",value:function(){var r=this.props,s=r.payload,i=r.layout,o=r.align;if(!s||!s.length)return null;var l={padding:0,margin:0,textAlign:i==="horizontal"?o:"left"};return ae.createElement("ul",{className:"recharts-default-legend",style:l},this.renderItems())}}])}(y.PureComponent);wm(l2,"displayName","Legend");wm(l2,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var Bye=qb;function Uye(){this.__data__=new Bye,this.size=0}var Wye=Uye;function Kye(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}var Hye=Kye;function Gye(e){return this.__data__.get(e)}var Vye=Gye;function Yye(e){return this.__data__.has(e)}var Qye=Yye,Xye=qb,Jye=Yk,Zye=Qk,eve=200;function tve(e,t){var n=this.__data__;if(n instanceof Xye){var r=n.__data__;if(!Jye||r.length<eve-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Zye(r)}return n.set(e,t),this.size=n.size,this}var nve=tve,rve=qb,ave=Wye,sve=Hye,ive=Vye,ove=Qye,lve=nve;function wh(e){var t=this.__data__=new rve(e);this.size=t.size}wh.prototype.clear=ave;wh.prototype.delete=sve;wh.prototype.get=ive;wh.prototype.has=ove;wh.prototype.set=lve;var Mz=wh,cve="__lodash_hash_undefined__";function uve(e){return this.__data__.set(e,cve),this}var dve=uve;function hve(e){return this.__data__.has(e)}var fve=hve,mve=Qk,pve=dve,gve=fve;function My(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new mve;++t<n;)this.add(e[t])}My.prototype.add=My.prototype.push=pve;My.prototype.has=gve;var Dz=My;function xve(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var $z=xve;function yve(e,t){return e.has(t)}var Rz=yve,vve=Dz,bve=$z,wve=Rz,_ve=1,jve=2;function Nve(e,t,n,r,s,i){var o=n&_ve,l=e.length,c=t.length;if(l!=c&&!(o&&c>l))return!1;var u=i.get(e),d=i.get(t);if(u&&d)return u==t&&d==e;var h=-1,m=!0,f=n&jve?new vve:void 0;for(i.set(e,t),i.set(t,e);++h<l;){var x=e[h],g=t[h];if(r)var p=o?r(g,x,h,t,e,i):r(x,g,h,e,t,i);if(p!==void 0){if(p)continue;m=!1;break}if(f){if(!bve(t,function(v,b){if(!wve(f,b)&&(x===v||s(x,v,n,r,i)))return f.push(b)})){m=!1;break}}else if(!(x===g||s(x,g,n,r,i))){m=!1;break}}return i.delete(e),i.delete(t),m}var Iz=Nve,Sve=ki,Cve=Sve.Uint8Array,kve=Cve;function Eve(e){var t=-1,n=Array(e.size);return e.forEach(function(r,s){n[++t]=[s,r]}),n}var Pve=Eve;function Ove(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var c2=Ove,oT=Dp,lT=kve,Ave=Vk,Tve=Iz,Mve=Pve,Dve=c2,$ve=1,Rve=2,Ive="[object Boolean]",Lve="[object Date]",Fve="[object Error]",qve="[object Map]",zve="[object Number]",Bve="[object RegExp]",Uve="[object Set]",Wve="[object String]",Kve="[object Symbol]",Hve="[object ArrayBuffer]",Gve="[object DataView]",cT=oT?oT.prototype:void 0,n_=cT?cT.valueOf:void 0;function Vve(e,t,n,r,s,i,o){switch(n){case Gve:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Hve:return!(e.byteLength!=t.byteLength||!i(new lT(e),new lT(t)));case Ive:case Lve:case zve:return Ave(+e,+t);case Fve:return e.name==t.name&&e.message==t.message;case Bve:case Wve:return e==t+"";case qve:var l=Mve;case Uve:var c=r&$ve;if(l||(l=Dve),e.size!=t.size&&!c)return!1;var u=o.get(e);if(u)return u==t;r|=Rve,o.set(e,t);var d=Tve(l(e),l(t),r,s,i,o);return o.delete(e),d;case Kve:if(n_)return n_.call(e)==n_.call(t)}return!1}var Yve=Vve;function Qve(e,t){for(var n=-1,r=t.length,s=e.length;++n<r;)e[s+n]=t[n];return e}var Lz=Qve,Xve=Lz,Jve=ka;function Zve(e,t,n){var r=t(e);
vendor: 4,576 bytes, line 851
851return Jve(e)?r:Xve(r,n(e))}var ebe=Zve;function tbe(e,t){for(var n=-1,r=e==null?0:e.length,s=0,i=[];++n<r;){var o=e[n];t(o,n,e)&&(i[s++]=o)}return i}var nbe=tbe;function rbe(){return[]}var abe=rbe,sbe=nbe,ibe=abe,obe=Object.prototype,lbe=obe.propertyIsEnumerable,uT=Object.getOwnPropertySymbols,cbe=uT?function(e){return e==null?[]:(e=Object(e),sbe(uT(e),function(t){return lbe.call(e,t)}))}:ibe,ube=cbe;function dbe(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var hbe=dbe,fbe=vo,mbe=bo,pbe="[object Arguments]";function gbe(e){return mbe(e)&&fbe(e)==pbe}var xbe=gbe,dT=xbe,ybe=bo,Fz=Object.prototype,vbe=Fz.hasOwnProperty,bbe=Fz.propertyIsEnumerable,wbe=dT(function(){return arguments}())?dT:function(e){return ybe(e)&&vbe.call(e,"callee")&&!bbe.call(e,"callee")},u2=wbe,Dy={exports:{}};function _be(){return!1}var jbe=_be;Dy.exports;(function(e,t){var n=ki,r=jbe,s=t&&!t.nodeType&&t,i=s&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===s,l=o?n.Buffer:void 0,c=l?l.isBuffer:void 0,u=c||r;e.exports=u})(Dy,Dy.exports);var qz=Dy.exports,Nbe=9007199254740991,Sbe=/^(?:0|[1-9]\d*)$/;function Cbe(e,t){var n=typeof e;return t=t??Nbe,!!t&&(n=="number"||n!="symbol"&&Sbe.test(e))&&e>-1&&e%1==0&&e<t}var d2=Cbe,kbe=9007199254740991;function Ebe(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=kbe}var h2=Ebe,Pbe=vo,Obe=h2,Abe=bo,Tbe="[object Arguments]",Mbe="[object Array]",Dbe="[object Boolean]",$be="[object Date]",Rbe="[object Error]",Ibe="[object Function]",Lbe="[object Map]",Fbe="[object Number]",qbe="[object Object]",zbe="[object RegExp]",Bbe="[object Set]",Ube="[object String]",Wbe="[object WeakMap]",Kbe="[object ArrayBuffer]",Hbe="[object DataView]",Gbe="[object Float32Array]",Vbe="[object Float64Array]",Ybe="[object Int8Array]",Qbe="[object Int16Array]",Xbe="[object Int32Array]",Jbe="[object Uint8Array]",Zbe="[object Uint8ClampedArray]",e0e="[object Uint16Array]",t0e="[object Uint32Array]",kn={};kn[Gbe]=kn[Vbe]=kn[Ybe]=kn[Qbe]=kn[Xbe]=kn[Jbe]=kn[Zbe]=kn[e0e]=kn[t0e]=!0;kn[Tbe]=kn[Mbe]=kn[Kbe]=kn[Dbe]=kn[Hbe]=kn[$be]=kn[Rbe]=kn[Ibe]=kn[Lbe]=kn[Fbe]=kn[qbe]=kn[zbe]=kn[Bbe]=kn[Ube]=kn[Wbe]=!1;function n0e(e){return Abe(e)&&Obe(e.length)&&!!kn[Pbe(e)]}var r0e=n0e;function a0e(e){return function(t){return e(t)}}var zz=a0e,$y={exports:{}};$y.exports;(function(e,t){var n=Y8,r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,i=s&&s.exports===r,o=i&&n.process,l=function(){try{var c=s&&s.require&&s.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();e.exports=l})($y,$y.exports);var s0e=$y.exports,i0e=r0e,o0e=zz,hT=s0e,fT=hT&&hT.isTypedArray,l0e=fT?o0e(fT):i0e,Bz=l0e,c0e=hbe,u0e=u2,d0e=ka,h0e=qz,f0e=d2,m0e=Bz,p0e=Object.prototype,g0e=p0e.hasOwnProperty;function x0e(e,t){var n=d0e(e),r=!n&&u0e(e),s=!n&&!r&&h0e(e),i=!n&&!r&&!s&&m0e(e),o=n||r||s||i,l=o?c0e(e.length,String):[],c=l.length;for(var u in e)(t||g0e.call(e,u))&&!(o&&(u=="length"||s&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||f0e(u,c)))&&l.push(u);return l}var y0e=x0e,v0e=Object.prototype;function b0e(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||v0e;return e===n}var w0e=b0e;function _0e(e,t){return function(n){return e(t(n))}}var Uz=_0e,j0e=Uz,N0e=j0e(Object.keys,Object),S0e=N0e,C0e=w0e,k0e=S0e,E0e=Object.prototype,P0e=E0e.hasOwnProperty;function O0e(e){if(!C0e(e))return k0e(e);var t=[];for(var n in Object(e))P0e.call(e,n)&&n!="constructor"&&t.push(n);return t}var A0e=O0e,T0e=Gk,M0e=h2;function D0e(e){return e!=null&&M0e(e.length)&&!T0e(e)}var Ip=D0e,$0e=y0e,R0e=A0e,I0e=Ip;function L0e(e){return I0e(e)?$0e(e):R0e(e)}var r0=L0e,F0e=ebe,q0e=ube,z0e=r0;function B0e(e){return F0e(e,z0e,q0e)}var U0e=B0e,mT=U0e,W0e=1,K0e=Object.prototype,H0e=K0e.hasOwnProperty;function G0e(e,t,n,r,s,i){var o=n&W0e,l=mT(e),c=l.length,u=mT(t),d=u.length;if(c!=d&&!o)return!1;for(var h=c;h--;){var m=l[h];if(!(o?m in t:H0e.call(t,m)))return!1}var f=i.get(e),x=i.get(t);if(f&&x)return f==t&&x==e;var g=!0;i.set(e,t),i.set(t,e);for(var p=o;++h<c;){m=l[h];var v=e[m],b=t[m];if(r)var w=o?r(b,v,m,t,e,i):r(v,b,m,e,t,i);if(!(w===void 0?v===b||s(v,b,n,r,i):w)){g=!1;break}p||(p=m=="constructor")}if(g&&!p){var N=e.constructor,j=t.constructor;N!=j&&"constructor"in e&&"constructor"in t&&!(typeof N=="function"&&N instanceof N&&typeof j=="function"&&j instanceof j)&&(g=!1)}return i.delete(e),i.delete(t),g}var V0e=G0e,Y0e=Yc,Q0e=ki,X0e=Y0e(Q0e,"DataView"),J0e=X0e,Z0e=Yc,ewe=ki,twe=Z0e(ewe,"Promise"),nwe=twe,rwe=Yc,awe=ki,swe=rwe(awe,"Set"),Wz=swe,iwe=Yc,owe=ki,lwe=iwe(owe,"WeakMap"),cwe=lwe,V1=J0e,Y1=Yk,Q1=nwe,X1=Wz,J1=cwe,Kz=vo,_h=X8,pT
vendor: 3,662 bytes, line 851
851="[object Map]",uwe="[object Object]",gT="[object Promise]",xT="[object Set]",yT="[object WeakMap]",vT="[object DataView]",dwe=_h(V1),hwe=_h(Y1),fwe=_h(Q1),mwe=_h(X1),pwe=_h(J1),Yl=Kz;(V1&&Yl(new V1(new ArrayBuffer(1)))!=vT||Y1&&Yl(new Y1)!=pT||Q1&&Yl(Q1.resolve())!=gT||X1&&Yl(new X1)!=xT||J1&&Yl(new J1)!=yT)&&(Yl=function(e){var t=Kz(e),n=t==uwe?e.constructor:void 0,r=n?_h(n):"";if(r)switch(r){case dwe:return vT;case hwe:return pT;case fwe:return gT;case mwe:return xT;case pwe:return yT}return t});var gwe=Yl,r_=Mz,xwe=Iz,ywe=Yve,vwe=V0e,bT=gwe,wT=ka,_T=qz,bwe=Bz,wwe=1,jT="[object Arguments]",NT="[object Array]",Lg="[object Object]",_we=Object.prototype,ST=_we.hasOwnProperty;function jwe(e,t,n,r,s,i){var o=wT(e),l=wT(t),c=o?NT:bT(e),u=l?NT:bT(t);c=c==jT?Lg:c,u=u==jT?Lg:u;var d=c==Lg,h=u==Lg,m=c==u;if(m&&_T(e)){if(!_T(t))return!1;o=!0,d=!1}if(m&&!d)return i||(i=new r_),o||bwe(e)?xwe(e,t,n,r,s,i):ywe(e,t,c,n,r,s,i);if(!(n&wwe)){var f=d&&ST.call(e,"__wrapped__"),x=h&&ST.call(t,"__wrapped__");if(f||x){var g=f?e.value():e,p=x?t.value():t;return i||(i=new r_),s(g,p,n,r,i)}}return m?(i||(i=new r_),vwe(e,t,n,r,s,i)):!1}var Nwe=jwe,Swe=Nwe,CT=bo;function Hz(e,t,n,r,s){return e===t?!0:e==null||t==null||!CT(e)&&!CT(t)?e!==e&&t!==t:Swe(e,t,n,r,Hz,s)}var f2=Hz,Cwe=Mz,kwe=f2,Ewe=1,Pwe=2;function Owe(e,t,n,r){var s=n.length,i=s,o=!r;if(e==null)return!i;for(e=Object(e);s--;){var l=n[s];if(o&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++s<i;){l=n[s];var c=l[0],u=e[c],d=l[1];if(o&&l[2]){if(u===void 0&&!(c in e))return!1}else{var h=new Cwe;if(r)var m=r(u,d,c,e,t,h);if(!(m===void 0?kwe(d,u,Ewe|Pwe,r,h):m))return!1}}return!0}var Awe=Owe,Twe=Tl;function Mwe(e){return e===e&&!Twe(e)}var Gz=Mwe,Dwe=Gz,$we=r0;function Rwe(e){for(var t=$we(e),n=t.length;n--;){var r=t[n],s=e[r];t[n]=[r,s,Dwe(s)]}return t}var Iwe=Rwe;function Lwe(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}var Vz=Lwe,Fwe=Awe,qwe=Iwe,zwe=Vz;function Bwe(e){var t=qwe(e);return t.length==1&&t[0][2]?zwe(t[0][0],t[0][1]):function(n){return n===e||Fwe(n,e,t)}}var Uwe=Bwe;function Wwe(e,t){return e!=null&&t in Object(e)}var Kwe=Wwe,Hwe=nz,Gwe=u2,Vwe=ka,Ywe=d2,Qwe=h2,Xwe=Bb;function Jwe(e,t,n){t=Hwe(t,e);for(var r=-1,s=t.length,i=!1;++r<s;){var o=Xwe(t[r]);if(!(i=e!=null&&n(e,o)))break;e=e[o]}return i||++r!=s?i:(s=e==null?0:e.length,!!s&&Qwe(s)&&Ywe(o,s)&&(Vwe(e)||Gwe(e)))}var Zwe=Jwe,e_e=Kwe,t_e=Zwe;function n_e(e,t){return e!=null&&t_e(e,t,e_e)}var r_e=n_e,a_e=f2,s_e=rz,i_e=r_e,o_e=Hk,l_e=Gz,c_e=Vz,u_e=Bb,d_e=1,h_e=2;function f_e(e,t){return o_e(e)&&l_e(t)?c_e(u_e(e),t):function(n){var r=s_e(n,e);return r===void 0&&r===t?i_e(n,e):a_e(t,r,d_e|h_e)}}var m_e=f_e;function p_e(e){return e}var jh=p_e;function g_e(e){return function(t){return t==null?void 0:t[e]}}var x_e=g_e,y_e=Zk;function v_e(e){return function(t){return y_e(t,e)}}var b_e=v_e,w_e=x_e,__e=b_e,j_e=Hk,N_e=Bb;function S_e(e){return j_e(e)?w_e(N_e(e)):__e(e)}var C_e=S_e,k_e=Uwe,E_e=m_e,P_e=jh,O_e=ka,A_e=C_e;function T_e(e){return typeof e=="function"?e:e==null?P_e:typeof e=="object"?O_e(e)?E_e(e[0],e[1]):k_e(e):A_e(e)}var Ml=T_e;function M_e(e,t,n,r){for(var s=e.length,i=n+(r?1:-1);r?i--:++i<s;)if(t(e[i],i,e))return i;return-1}var Yz=M_e;function D_e(e){return e!==e}var $_e=D_e;function R_e(e,t,n){for(var r=n-1,s=e.length;++r<s;)if(e[r]===t)return r;return-1}var I_e=R_e,L_e=Yz,F_e=$_e,q_e=I_e;function z_e(e,t,n){return t===t?q_e(e,t,n):L_e(e,F_e,n)}var B_e=z_e,U_e=B_e;function W_e(e,t){var n=e==null?0:e.length;return!!n&&U_e(e,t,0)>-1}var K_e=W_e;function H_e(e,t,n){for(var r=-1,s=e==null?0:e.length;++r<s;)if(n(t,e[r]))return!0;return!1}var G_e=H_e;function V_e(){}
vendor: 21,184 bytes, lines 851-852
851var Y_e=V_e,a_=Wz,Q_e=Y_e,X_e=c2,J_e=1/0,Z_e=a_&&1/X_e(new a_([,-0]))[1]==J_e?function(e){return new a_(e)}:Q_e,eje=Z_e,tje=Dz,nje=K_e,rje=G_e,aje=Rz,sje=eje,ije=c2,oje=200;function lje(e,t,n){var r=-1,s=nje,i=e.length,o=!0,l=[],c=l;if(n)o=!1,s=rje;else if(i>=oje){var u=t?null:sje(e);if(u)return ije(u);o=!1,s=aje,c=new tje}else c=t?[]:l;e:for(;++r<i;){var d=e[r],h=t?t(d):d;if(d=n||d!==0?d:0,o&&h===h){for(var m=c.length;m--;)if(c[m]===h)continue e;t&&c.push(h),l.push(d)}else s(c,h,n)||(c!==l&&c.push(h),l.push(d))}return l}var cje=lje,uje=Ml,dje=cje;function hje(e,t){return e&&e.length?dje(e,uje(t)):[]}var fje=hje;const kT=dn(fje);function Qz(e,t,n){return t===!0?kT(e,n):Bt(t)?kT(e,t):e}function Td(e){"@babel/helpers - typeof";return Td=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Td(e)}var mje=["ref"];function ET(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Ti(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ET(Object(n),!0).forEach(function(r){a0(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ET(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function pje(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function PT(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Jz(r.key),r)}}function gje(e,t,n){return t&&PT(e.prototype,t),n&&PT(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function xje(e,t,n){return t=Ry(t),yje(e,Xz()?Reflect.construct(t,n||[],Ry(e).constructor):t.apply(e,n))}function yje(e,t){if(t&&(Td(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return vje(e)}function vje(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Xz(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Xz=function(){return!!e})()}function Ry(e){return Ry=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ry(e)}function bje(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Z1(e,t)}function Z1(e,t){return Z1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},Z1(e,t)}function a0(e,t,n){return t=Jz(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jz(e){var t=wje(e,"string");return Td(t)=="symbol"?t:t+""}function wje(e,t){if(Td(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Td(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function _je(e,t){if(e==null)return{};var n=jje(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function jje(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function Nje(e){return e.value}function Sje(e,t){if(ae.isValidElement(e))return ae.cloneElement(e,t);if(typeof e=="function")return ae.createElement(e,t);t.ref;var n=_je(t,mje);return ae.createElement(l2,n)}var OT=1,bc=function(e){function t(){var n;pje(this,t);for(var r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];return n=xje(this,t,[].concat(s)),a0(n,"lastBoundingBox",{width:-1,height:-1}),n}return bje(t,e),gje(t,[{key:"componentDidMount",value:function(){this.updateBBox()}},{key:"componentDidUpdate",value:function(){this.updateBBox()}},{key:"getBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var r=this.wrapperNode.getBoundingClientRect();return r.height=this.wrapperNode.offsetHeight,r.width=this.wrapperNode.offsetWidth,r}return null}},{key:"updateBBox",value:function(){var r=this.props.onBBoxUpdate,s=this.getBBox();s?(Math.abs(s.width-this.lastBoundingBox.width)>OT||Math.abs(s.height-this.lastBoundingBox.height)>OT)&&(this.lastBoundingBox.width=s.width,this.lastBoundingBox.height=s.height,r&&r(s)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,r&&r(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?Ti({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(r){var s=this.props,i=s.layout,o=s.align,l=s.verticalAlign,c=s.margin,u=s.chartWidth,d=s.chartHeight,h,m;if(!r||(r.left===void 0||r.left===null)&&(r.right===void 0||r.right===null))if(o==="center"&&i==="vertical"){var f=this.getBBoxSnapshot();h={left:((u||0)-f.width)/2}}else h=o==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!r||(r.top===void 0||r.top===null)&&(r.bottom===void 0||r.bottom===null))if(l==="middle"){var x=this.getBBoxSnapshot();m={top:((d||0)-x.height)/2}}else m=l==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return Ti(Ti({},h),m)}},{key:"render",value:function(){var r=this,s=this.props,i=s.content,o=s.width,l=s.height,c=s.wrapperStyle,u=s.payloadUniqBy,d=s.payload,h=Ti(Ti({position:"absolute",width:o||"auto",height:l||"auto"},this.getDefaultPosition(c)),c);return ae.createElement("div",{className:"recharts-legend-wrapper",style:h,ref:function(f){r.wrapperNode=f}},Sje(i,Ti(Ti({},this.props),{},{payload:Qz(d,u,Nje)})))}}],[{key:"getWithHeight",value:function(r,s){var i=Ti(Ti({},this.defaultProps),r.props),o=i.layout;return o==="vertical"&&Xe(r.props.height)?{height:r.props.height}:o==="horizontal"?{width:r.props.width||s}:null}}])}(y.PureComponent);a0(bc,"displayName","Legend");a0(bc,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var AT=Dp,Cje=u2,kje=ka,TT=AT?AT.isConcatSpreadable:void 0;function Eje(e){return kje(e)||Cje(e)||!!(TT&&e&&e[TT])}var Pje=Eje,Oje=Lz,Aje=Pje;function Zz(e,t,n,r,s){var i=-1,o=e.length;for(n||(n=Aje),s||(s=[]);++i<o;){var l=e[i];t>0&&n(l)?t>1?Zz(l,t-1,n,r,s):Oje(s,l):r||(s[s.length]=l)}return s}var eB=Zz;function Tje(e){return function(t,n,r){for(var s=-1,i=Object(t),o=r(t),l=o.length;l--;){var c=o[e?l:++s];if(n(i[c],c,i)===!1)break}return t}}var Mje=Tje,Dje=Mje,$je=Dje(),Rje=$je,Ije=Rje,Lje=r0;function Fje(e,t){return e&&Ije(e,t,Lje)}var tB=Fje,qje=Ip;function zje(e,t){return function(n,r){if(n==null)return n;if(!qje(n))return e(n,r);for(var s=n.length,i=t?s:-1,o=Object(n);(t?i--:++i<s)&&r(o[i],i,o)!==!1;);return n}}var Bje=zje,Uje=tB,Wje=Bje,Kje=Wje(Uje),m2=Kje,Hje=m2,Gje=Ip;function Vje(e,t){var n=-1,r=Gje(e)?Array(e.length):[];return Hje(e,function(s,i,o){r[++n]=t(s,i,o)}),r}var nB=Vje;function Yje(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}var Qje=Yje,MT=gh;function Xje(e,t){if(e!==t){var n=e!==void 0,r=e===null,s=e===e,i=MT(e),o=t!==void 0,l=t===null,c=t===t,u=MT(t);if(!l&&!u&&!i&&e>t||i&&o&&c&&!l&&!u||r&&o&&c||!n&&c||!s)return 1;if(!r&&!i&&!u&&e<t||u&&n&&s&&!r&&!i||l&&n&&s||!o&&s||!c)return-1}return 0}var Jje=Xje,Zje=Jje;function e1e(e,t,n){for(var r=-1,s=e.criteria,i=t.criteria,o=s.length,l=n.length;++r<o;){var c=Zje(s[r],i[r]);if(c){if(r>=l)return c;var u=n[r];return c*(u=="desc"?-1:1)}}return e.index-t.index}var t1e=e1e,s_=Jk,n1e=Zk,r1e=Ml,a1e=nB,s1e=Qje,i1e=zz,o1e=t1e,l1e=jh,c1e=ka;function u1e(e,t,n){t.length?t=s_(t,function(i){return c1e(i)?function(o){return n1e(o,i.length===1?i[0]:i)}:i}):t=[l1e];var r=-1;t=s_(t,i1e(r1e));var s=a1e(e,function(i,o,l){var c=s_(t,function(u){return u(i)});return{criteria:c,index:++r,value:i}});return s1e(s,function(i,o){return o1e(i,o,n)})}var d1e=u1e;function h1e(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}var f1e=h1e,m1e=f1e,DT=Math.max;function p1e(e,t,n){return t=DT(t===void 0?e.length-1:t,0),function(){for(var r=arguments,s=-1,i=DT(r.length-t,0),o=Array(i);++s<i;)o[s]=r[t+s];s=-1;for(var l=Array(t+1);++s<t;)l[s]=r[s];return l[t]=n(o),m1e(e,this,l)}}var g1e=p1e;function x1e(e){return function(){return e}}var y1e=x1e,v1e=Yc,b1e=function(){try{var e=v1e(Object,"defineProperty");return e({},"",{}),e}catch{}}(),rB=b1e,w1e=y1e,$T=rB,_1e=jh,j1e=$T?function(e,t){return $T(e,"toString",{configurable:!0,enumerable:!1,value:w1e(t),writable:!0})}:_1e,N1e=j1e,S1e=800,C1e=16,k1e=Date.now;function E1e(e){var t=0,n=0;return function(){var r=k1e(),s=C1e-(r-n);if(n=r,s>0){if(++t>=S1e)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var P1e=E1e,O1e=N1e,A1e=P1e,T1e=A1e(O1e),M1e=T1e,D1e=jh,$1e=g1e,R1e=M1e;function I1e(e,t){return R1e($1e(e,t,D1e),e+"")}var L1e=I1e,F1e=Vk,q1e=Ip,z1e=d2,B1e=Tl;function U1e(e,t,n){if(!B1e(n))return!1;var r=typeof t;return(r=="number"?q1e(n)&&z1e(t,n.length):r=="string"&&t in n)?F1e(n[t],e):!1}var s0=U1e,W1e=eB,K1e=d1e,H1e=L1e,RT=s0,G1e=H1e(function(e,t){if(e==null)return[];var n=t.length;return n>1&&RT(e,t[0],t[1])?t=[]:n>2&&RT(t[0],t[1],t[2])&&(t=[t[0]]),K1e(e,W1e(t,1),[])}),V1e=G1e;const p2=dn(V1e);function _m(e){"@babel/helpers - typeof";return _m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_m(e)}function eN(){return eN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},eN.apply(this,arguments)}function Y1e(e,t){return Z1e(e)||J1e(e,t)||X1e(e,t)||Q1e()}function Q1e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 852In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function X1e(e,t){if(e){if(typeof e=="string")return IT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return IT(e,t)}}function IT(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function J1e(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function Z1e(e){if(Array.isArray(e))return e}function LT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function i_(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?LT(Object(n),!0).forEach(function(r){eNe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):LT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function eNe(e,t,n){return t=tNe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tNe(e){var t=nNe(e,"string");return _m(t)=="symbol"?t:t+""}function nNe(e,t){if(_m(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(_m(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function rNe(e){return Array.isArray(e)&&ur(e[0])&&ur(e[1])?e.join(" ~ "):e}var aNe=function(t){var n=t.separator,r=n===void 0?" : ":n,s=t.contentStyle,i=s===void 0?{}:s,o=t.itemStyle,l=o===void 0?{}:o,c=t.labelStyle,u=c===void 0?{}:c,d=t.payload,h=t.formatter,m=t.itemSorter,f=t.wrapperClassName,x=t.labelClassName,g=t.label,p=t.labelFormatter,v=t.accessibilityLayer,b=v===void 0?!1:v,w=function(){if(d&&d.length){var O={padding:0,margin:0},L=(m?p2(d,m):d).map(function(E,R){if(E.type==="none")return null;var q=i_({display:"block",paddingTop:4,paddingBottom:4,color:E.color||"#000"},l),I=E.formatter||h||rNe,$=E.value,M=E.name,B=$,W=M;if(I&&B!=null&&W!=null){var A=I($,M,E,R,d);if(Array.isArray(A)){var K=Y1e(A,2);B=K[0],W=K[1]}else B=A}return ae.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(R),style:q},ur(W)?ae.createElement("span",{className:"recharts-tooltip-item-name"},W):null,ur(W)?ae.createElement("span",{className:"recharts-tooltip-item-separator"},r):null,ae.createElement("span",{className:"recharts-tooltip-item-value"},B),ae.createElement("span",{className:"recharts-tooltip-item-unit"},E.unit||""))});return ae.createElement("ul",{className:"recharts-tooltip-item-list",style:O},L)}return null},N=i_({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},i),j=i_({margin:0},u),_=!Ut(g),S=_?g:"",P=Qt("recharts-default-tooltip",f),k=Qt("recharts-tooltip-label",x);_&&p&&d!==void 0&&d!==null&&(S=p(g,d));var C=b?{role:"status","aria-live":"assertive"}:{};return ae.createElement("div",eN({className:P,style:N},C),ae.createElement("p",{className:k,style:j},ae.isValidElement(S)?S:"".concat(S)),w())};function jm(e){"@babel/helpers - typeof";return jm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jm(e)}function Fg(e,t,n){return t=sNe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sNe(e){var t=iNe(e,"string");return jm(t)=="symbol"?t:t+""}function iNe(e,t){if(jm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(jm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Xh="recharts-tooltip-wrapper",oNe={visibility:"hidden"};function lNe(e){var t=e.coordinate,n=e.translateX,r=e.translateY;return Qt(Xh,Fg(Fg(Fg(Fg({},"".concat(Xh,"-right"),Xe(n)&&t&&Xe(t.x)&&n>=t.x),"".concat(Xh,"-left"),Xe(n)&&t&&Xe(t.x)&&n<t.x),"".concat(Xh,"-bottom"),Xe(r)&&t&&Xe(t.y)&&r>=t.y),"".concat(Xh,"-top"),Xe(r)&&t&&Xe(t.y)&&r<t.y))}function FT(e){var t=e.allowEscapeViewBox,n=e.coordinate,r=e.key,s=e.offsetTopLeft,i=e.position,o=e.reverseDirection,l=e.tooltipDimension,c=e.viewBox,u=e.viewBoxDimension;if(i&&Xe(i[r]))return i[r];var d=n[r]-l-s,h=n[r]+s;if(t[r])return o[r]?d:h;if(o[r]){var m=d,f=c[r];return m<f?Math.max(h,c[r]):Math.max(d,c[r])}var x=h+l,g=c[r]+u;return x>g?Math.max(d,c[r]):Math.max(h,c[r])}function cNe(e){var t=e.translateX,n=e.translateY,r=e.useTranslate3d;return{transform:r?"translate3d(".concat(t,"px, ").concat(n,"px, 0)"):"translate(".concat(t,"px, ").concat(n,"px)")}}function uNe(e){var t=e.allowEscapeViewBox,n=e.coordinate,r=e.offsetTopLeft,s=e.position,i=e.reverseDirection,o=e.tooltipBox,l=e.useTranslate3d,c=e.viewBox,u,d,h;return o.height>0&&o.width>0&&n?(d=FT({allowEscapeViewBox:t,coordinate:n,key:"x",offsetTopLeft:r,position:s,reverseDirection:i,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),h=FT({allowEscapeViewBox:t,coordinate:n,key:"y",offsetTopLeft:r,position:s,reverseDirection:i,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=cNe({translateX:d,translateY:h,useTranslate3d:l})):u=oNe,{cssProperties:u,cssClasses:lNe({translateX:d,translateY:h,coordinate:n})}}function Md(e){"@babel/helpers - typeof";return Md=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Md(e)}function qT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function zT(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?qT(Object(n),!0).forEach(function(r){nN(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function dNe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hNe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,sB(r.key),r)}}function fNe(e,t,n){return t&&hNe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function mNe(e,t,n){return t=Iy(t),pNe(e,aB()?Reflect.construct(t,n||[],Iy(e).constructor):t.apply(e,n))}function pNe(e,t){if(t&&(Md(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return gNe(e)}function gNe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function aB(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(aB=function(){return!!e})()}function Iy(e){return Iy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Iy(e)}function xNe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&tN(e,t)}function tN(e,t){return tN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},tN(e,t)}function nN(e,t,n){return t=sB(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sB(e){var t=yNe(e,"string");return Md(t)=="symbol"?t:t+""}function yNe(e,t){if(Md(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Md(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var BT=1,vNe=function(e){function t(){var n;dNe(this,t);for(var r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];return n=mNe(this,t,[].concat(s)),nN(n,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0},lastBoundingBox:{width:-1,height:-1}}),nN(n,"handleKeyDown",function(o){if(o.key==="Escape"){var l,c,u,d;n.setState({dismissed:!0,dismissedAtCoordinate:{x:(l=(c=n.props.coordinate)===null||c===void 0?void 0:c.x)!==null&&l!==void 0?l:0,y:(u=(d=n.props.coordinate)===null||d===void 0?void 0:d.y)!==null&&u!==void 0?u:0}})}}),n}return xNe(t,e),fNe(t,[{key:"updateBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var r=this.wrapperNode.getBoundingClientRect();(Math.abs(r.width-this.state.lastBoundingBox.width)>BT||Math.abs(r.height-this.state.lastBoundingBox.height)>BT)&&this.setState({lastBoundingBox:{width:r.width,height:r.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var r,s;this.props.active&&this.updateBBox(),this.state.dismissed&&(((r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==this.state.dismissedAtCoordinate.x||((s=this.props.coordinate)===null||s===void 0?void 0:s.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var r=this,s=this.props,i=s.active,o=s.allowEscapeViewBox,l=s.animationDuration,c=s.animationEasing,u=s.children,d=s.coordinate,h=s.hasPayload,m=s.isAnimationActive,f=s.offset,x=s.position,g=s.reverseDirection,p=s.useTranslate3d,v=s.viewBox,b=s.wrapperStyle,w=uNe({allowEscapeViewBox:o,coordinate:d,offsetTopLeft:f,position:x,reverseDirection:g,tooltipBox:this.state.lastBoundingBox,useTranslate3d:p,viewBox:v}
852),N=w.cssClasses,j=w.cssProperties,_=zT(zT({transition:m&&i?"transform ".concat(l,"ms ").concat(c):void 0},j),{},{pointerEvents:"none",visibility:!this.state.dismissed&&i&&h?"visible":"hidden",position:"absolute",top:0,left:0},b);return ae.createElement("div",{tabIndex:-1,className:N,style:_,ref:function(P){r.wrapperNode=P}},u)}}])}(y.PureComponent),bNe=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},Qi={isSsr:bNe(),get:function(t){return Qi[t]},set:function(t,n){if(typeof t=="string")Qi[t]=n;else{var r=Object.keys(t);r&&r.length&&r.forEach(function(s){Qi[s]=t[s]})}}};function Dd(e){"@babel/helpers - typeof";return Dd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dd(e)}function UT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function WT(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?UT(Object(n),!0).forEach(function(r){g2(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):UT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function wNe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _Ne(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,oB(r.key),r)}}function jNe(e,t,n){return t&&_Ne(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function NNe(e,t,n){return t=Ly(t),SNe(e,iB()?Reflect.construct(t,n||[],Ly(e).constructor):t.apply(e,n))}function SNe(e,t){if(t&&(Dd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return CNe(e)}function CNe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function iB(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(iB=function(){return!!e})()}function Ly(e){return Ly=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ly(e)}function kNe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&rN(e,t)}function rN(e,t){return rN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},rN(e,t)}function g2(e,t,n){return t=oB(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oB(e){var t=ENe(e,"string");return Dd(t)=="symbol"?t:t+""}function ENe(e,t){if(Dd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Dd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function PNe(e){return e.dataKey}function ONe(e,t){return ae.isValidElement(e)?ae.cloneElement(e,t):typeof e=="function"?ae.createElement(e,t):ae.createElement(aNe,t)}var ii=function(e){function t(){return wNe(this,t),NNe(this,t,arguments)}return kNe(t,e),jNe(t,[{key:"render",value:function(){var r=this,s=this.props,i=s.active,o=s.allowEscapeViewBox,l=s.animationDuration,c=s.animationEasing,u=s.content,d=s.coordinate,h=s.filterNull,m=s.isAnimationActive,f=s.offset,x=s.payload,g=s.payloadUniqBy,p=s.position,v=s.reverseDirection,b=s.useTranslate3d,w=s.viewBox,N=s.wrapperStyle,j=x??[];h&&j.length&&(j=Qz(x.filter(function(S){return S.value!=null&&(S.hide!==!0||r.props.includeHidden)}),g,PNe));var _=j.length>0;return ae.createElement(vNe,{allowEscapeViewBox:o,animationDuration:l,animationEasing:c,isAnimationActive:m,active:i,coordinate:d,hasPayload:_,offset:f,position:p,reverseDirection:v,useTranslate3d:b,viewBox:w,wrapperStyle:N},ONe(u,WT(WT({},this.props),{},{payload:j})))}}])}(y.PureComponent);
vendor: 14,429 bytes, lines 852-858
852g2(ii,"displayName","Tooltip");g2(ii,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!Qi.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var ANe=ki,TNe=function(){return ANe.Date.now()},MNe=TNe,DNe=/\s/;function $Ne(e){for(var t=e.length;t--&&DNe.test(e.charAt(t)););return t}var RNe=$Ne,INe=RNe,LNe=/^\s+/;function FNe(e){return e&&e.slice(0,INe(e)+1).replace(LNe,"")}var qNe=FNe,zNe=qNe,KT=Tl,BNe=gh,HT=NaN,UNe=/^[-+]0x[0-9a-f]+$/i,WNe=/^0b[01]+$/i,KNe=/^0o[0-7]+$/i,HNe=parseInt;function GNe(e){if(typeof e=="number")return e;if(BNe(e))return HT;if(KT(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=KT(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=zNe(e);var n=WNe.test(e);return n||KNe.test(e)?HNe(e.slice(2),n?2:8):UNe.test(e)?HT:+e}var lB=GNe,VNe=Tl,o_=MNe,GT=lB,YNe="Expected a function",QNe=Math.max,XNe=Math.min;function JNe(e,t,n){var r,s,i,o,l,c,u=0,d=!1,h=!1,m=!0;if(typeof e!="function")throw new TypeError(YNe);t=GT(t)||0,VNe(n)&&(d=!!n.leading,h="maxWait"in n,i=h?QNe(GT(n.maxWait)||0,t):i,m="trailing"in n?!!n.trailing:m);function f(_){var S=r,P=s;return r=s=void 0,u=_,o=e.apply(P,S),o}function x(_){return u=_,l=setTimeout(v,t),d?f(_):o}function g(_){var S=_-c,P=_-u,k=t-S;return h?XNe(k,i-P):k}function p(_){var S=_-c,P=_-u;return c===void 0||S>=t||S<0||h&&P>=i}function v(){var _=o_();if(p(_))return b(_);l=setTimeout(v,g(_))}function b(_){return l=void 0,m&&r?f(_):(r=s=void 0,o)}function w(){l!==void 0&&clearTimeout(l),u=0,r=c=s=l=void 0}function N(){return l===void 0?o:b(o_())}function j(){var _=o_(),S=p(_);if(r=arguments,s=this,c=_,S){if(l===void 0)return x(c);if(h)return clearTimeout(l),l=setTimeout(v,t),f(c)}return l===void 0&&(l=setTimeout(v,t)),o}return j.cancel=w,j.flush=N,j}var ZNe=JNe,eSe=ZNe,tSe=Tl,nSe="Expected a function";function rSe(e,t,n){var r=!0,s=!0;if(typeof e!="function")throw new TypeError(nSe);return tSe(n)&&(r="leading"in n?!!n.leading:r,s="trailing"in n?!!n.trailing:s),eSe(e,t,{leading:r,maxWait:t,trailing:s})}var aSe=rSe;const cB=dn(aSe);function Nm(e){"@babel/helpers - typeof";return Nm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nm(e)}function VT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).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?VT(Object(n),!0).forEach(function(r){sSe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function sSe(e,t,n){return t=iSe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function iSe(e){var t=oSe(e,"string");return Nm(t)=="symbol"?t:t+""}function oSe(e,t){if(Nm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Nm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function lSe(e,t){return hSe(e)||dSe(e,t)||uSe(e,t)||cSe()}function cSe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 853In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uSe(e,t){if(e){if(typeof e=="string")return YT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return YT(e,t)}}function YT(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function dSe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function hSe(e){if(Array.isArray(e))return e}var fSe=y.forwardRef(function(e,t){var n=e.aspect,r=e.initialDimension,s=r===void 0?{width:-1,height:-1}:r,i=e.width,o=i===void 0?"100%":i,l=e.height,c=l===void 0?"100%":l,u=e.minWidth,d=u===void 0?0:u,h=e.minHeight,m=e.maxHeight,f=e.children,x=e.debounce,g=x===void 0?0:x,p=e.id,v=e.className,b=e.onResize,w=e.style,N=w===void 0?{}:w,j=y.useRef(null),_=y.useRef();_.current=b,y.useImperativeHandle(t,function(){return Object.defineProperty(j.current,"current",{get:function(){return console.warn("The usage of ref.current.current is deprecated and will no longer be supported."),j.current},configurable:!0})});var S=y.useState({containerWidth:s.width,containerHeight:s.height}),P=lSe(S,2),k=P[0],C=P[1],T=y.useCallback(function(L,E){C(function(R){var q=Math.round(L),I=Math.round(E);return R.containerWidth===q&&R.containerHeight===I?R:{containerWidth:q,containerHeight:I}})},[]);y.useEffect(function(){var L=function(M){var B,W=M[0].contentRect,A=W.width,K=W.height;T(A,K),(B=_.current)===null||B===void 0||B.call(_,A,K)};g>0&&(L=cB(L,g,{trailing:!0,leading:!1}));var E=new ResizeObserver(L),R=j.current.getBoundingClientRect(),q=R.width,I=R.height;return T(q,I),E.observe(j.current),function(){E.disconnect()}},[T,g]);var O=y.useMemo(function(){var L=k.containerWidth,E=k.containerHeight;if(L<0||E<0)return null;Yi(ac(o)||ac(c),`The width(%s) and height(%s) are both fixed numbers, 854 maybe you don't need to use a ResponsiveContainer.`,o,c),Yi(!n||n>0,"The aspect(%s) must be greater than zero.",n);var R=ac(o)?L:o,q=ac(c)?E:c;n&&n>0&&(R?q=R/n:q&&(R=q*n),m&&q>m&&(q=m)),Yi(R>0||q>0,`The width(%s) and height(%s) of chart should be greater than 0, 855 please check the style of container, or the props width(%s) and height(%s), 856 or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the 857 height and width.`,R,q,o,c,d,h,n);var I=!Array.isArray(f)&&Vi(f.type).endsWith("Chart");return ae.Children.map(f,function($){return ae.isValidElement($)?y.cloneElement($,qg({width:R,height:q},I?{style:qg({height:"100%",width:"100%",maxHeight:q,maxWidth:R},$.props.style)}:{})):$})},[n,f,c,m,h,d,k,o]);return ae.createElement("div",{id:p?"".concat(p):void 0,className:Qt("recharts-responsive-container",v),style:qg(qg({},N),{},{width:o,height:c,minWidth:d,minHeight:h,maxHeight:m}),ref:j},O)}),uB=function(t){return null};uB.displayName="Cell";function Sm(e){"@babel/helpers - typeof";return Sm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sm(e)}function QT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function aN(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?QT(Object(n),!0).forEach(function(r){mSe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function mSe(e,t,n){return t=pSe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pSe(e){var t=gSe(e,"string");return Sm(t)=="symbol"?t:t+""}function gSe(e,t){if(Sm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Sm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var yu={widthCache:{},cacheCount:0},xSe=2e3,ySe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},XT="recharts_measurement_span";function vSe(e){var t=aN({},e);return Object.keys(t).forEach(function(n){t[n]||delete t[n]}),t}var Tf=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||Qi.isSsr)return{width:0,height:0};var r=vSe(n),s=JSON.stringify({text:t,copyStyle:r});if(yu.widthCache[s])return yu.widthCache[s];try{var i=document.getElementById(XT);i||(i=document.createElement("span"),i.setAttribute("id",XT),i.setAttribute("aria-hidden","true"),document.body.appendChild(i));var o=aN(aN({},ySe),r);Object.assign(i.style,o),i.textContent="".concat(t);var l=i.getBoundingClientRect(),c={width:l.width,height:l.height};return yu.widthCache[s]=c,++yu.cacheCount>xSe&&(yu.cacheCount=0,yu.widthCache={}),c}catch{return{width:0,height:0}}},bSe=function(t){return{top:t.top+window.scrollY-document.documentElement.clientTop,left:t.left+window.scrollX-document.documentElement.clientLeft}};function Cm(e){"@babel/helpers - typeof";return Cm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cm(e)}function Fy(e,t){return NSe(e)||jSe(e,t)||_Se(e,t)||wSe()}function wSe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 858In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _Se(e,t){if(e){if(typeof e=="string")return JT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return JT(e,t)}}function JT(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function jSe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function NSe(e){if(Array.isArray(e))return e}function SSe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ZT(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,kSe(r.key),r)}}function CSe(e,t,n){return t&&ZT(e.prototype,t),n&&ZT(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function kSe(e){var t=ESe(e,"string");return Cm(t)=="symbol"?t:t+""}function ESe(e,t){if(Cm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Cm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var eM=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,tM=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,PSe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,OSe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,dB={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},ASe=Object.keys(dB),Bu="NaN";function TSe(e,t){return e*dB[t]}var zg=function(){function e(t,n){SSe(this,e),this.num=t,this.unit=n,this.num=t,this.unit=n,Number.isNaN(t)&&(this.unit=""),n!==""&&!PSe.test(n)&&(this.num=NaN,this.unit=""),ASe.includes(n)&&(this.num=TSe(t,n),this.unit="px")}return CSe(e,[{key:"add",value:function(n){return this.unit!==n.unit?new e(NaN,""):new e(this.num+n.num,this.unit)}},{key:"subtract",value:function(n){return this.unit!==n.unit?new e(NaN,""):new e(this.num-n.num,this.unit)}},{key:"multiply",value:function(n){return this.unit!==""&&n.unit!==""&&this.unit!==n.unit?new e(NaN,""):new e(this.num*n.num,this.unit||n.unit)}},{key:"divide",value:function(n){return this.unit!==""&&n.unit!==""&&this.unit!==n.unit?new e(NaN,""):new e(this.num/n.num,this.unit||n.unit)}},{key:"toString",value:function(){return"".concat(this.num).concat(this.unit)}},{key:"isNaN",value:function(){return Number.isNaN(this.num)}}],[{key:"parse",value:function(n){var r,s=(r=OSe.exec(n))!==null&&r!==void 0?r:[],i=Fy(s,3),o=i[1],l=i[2];return new e(parseFloat(o),l??"")}}])}();function hB(e){if(e.includes(Bu))return Bu;for(var t=e;t.includes("*")||t.includes("/");){var n,r=(n=eM.exec(t))!==null&&n!==void 0?n:[],s=Fy(r,4),i=s[1],o=s[2],l=s[3],c=zg.parse(i??""),u=zg.parse(l??""),d=o==="*"?c.multiply(u):c.divide(u);if(d.isNaN())return Bu;t=t.replace(eM,d.toString())}for(;t.includes("+")||/.-\d+(?:\.\d+)?/.test(t);){var h,m=(h=tM.exec(t))!==null&&h!==void 0?h:[],f=Fy(m,4),x=f[1],g=f[2],p=f[3],v=zg.parse(x??""),b=zg.parse(p??""),w=g==="+"?v.add(b):v.subtract(b);if(w.isNaN())return Bu;t=t.replace(tM,w.toString())}return t}var nM=/\(([^()]*)\)/;function MSe(e){for(var t=e;t.includes("(");){var n=nM.exec(t),r=Fy(n,2),s=r[1];t=t.replace(nM,hB(s))}return t}function DSe(e){var t=e.replace(/\s+/g,"");return t=MSe(t),t=hB(t),t}function $Se(e){try{return DSe(e)}catch{return Bu}}function l_(e){var t=$Se(e.slice(5,-1));return t===Bu?"":t}var RSe=["x","y","lineHeight","capHeight","scaleToFit","textAnchor","verticalAnchor","fill"],ISe=["dx","dy","angle","className","breakAll"];function sN(){return sN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sN.apply(this,arguments)}function rM(e,t){if(e==null)return{};var n=LSe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function LSe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function aM(e,t){return BSe(e)||zSe(e,t)||qSe(e,t)||FSe()}
858function FSe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 859In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qSe(e,t){if(e){if(typeof e=="string")return sM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return sM(e,t)}}function sM(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function zSe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function BSe(e){if(Array.isArray(e))return e}var fB=/[ \f\n\r\t\v\u2028\u2029]+/,mB=function(t){var n=t.children,r=t.breakAll,s=t.style;try{var i=[];Ut(n)||(r?i=n.toString().split(""):i=n.toString().split(fB));var o=i.map(function(c){return{word:c,width:Tf(c,s).width}}),l=r?0:Tf(" ",s).width;return{wordsWithComputedWidth:o,spaceWidth:l}}catch{return null}},USe=function(t,n,r,s,i){var o=t.maxLines,l=t.children,c=t.style,u=t.breakAll,d=Xe(o),h=l,m=function(){var R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return R.reduce(function(q,I){var $=I.word,M=I.width,B=q[q.length-1];if(B&&(s==null||i||B.width+M+r<Number(s)))B.words.push($),B.width+=M+r;else{var W={words:[$],width:M};q.push(W)}return q},[])},f=m(n),x=function(R){return R.reduce(function(q,I){return q.width>I.width?q:I})};if(!d)return f;for(var g="â¦",p=function(R){var q=h.slice(0,R),I=mB({breakAll:u,style:c,children:q+g}).wordsWithComputedWidth,$=m(I),M=$.length>o||x($).width>Number(s);return[M,$]},v=0,b=h.length-1,w=0,N;v<=b&&w<=h.length-1;){var j=Math.floor((v+b)/2),_=j-1,S=p(_),P=aM(S,2),k=P[0],C=P[1],T=p(j),O=aM(T,1),L=O[0];if(!k&&!L&&(v=j+1),k&&L&&(b=j-1),!k&&L){N=C;break}w++}return N||f},iM=function(t){var n=Ut(t)?[]:t.toString().split(fB);return[{words:n}]},WSe=function(t){var n=t.width,r=t.scaleToFit,s=t.children,i=t.style,o=t.breakAll,l=t.maxLines;if((n||r)&&!Qi.isSsr){var c,u,d=mB({breakAll:o,children:s,style:i});if(d){var h=d.wordsWithComputedWidth,m=d.spaceWidth;c=h,u=m}else return iM(s);return USe({breakAll:o,children:s,maxLines:l,style:i},c,u,n,r)}return iM(s)},oM="#808080",qy=function(t){var n=t.x,r=n===void 0?0:n,s=t.y,i=s===void 0?0:s,o=t.lineHeight,l=o===void 0?"1em":o,c=t.capHeight,u=c===void 0?"0.71em":c,d=t.scaleToFit,h=d===void 0?!1:d,m=t.textAnchor,f=m===void 0?"start":m,x=t.verticalAnchor,g=x===void 0?"end":x,p=t.fill,v=p===void 0?oM:p,b=rM(t,RSe),w=y.useMemo(function(){return WSe({breakAll:b.breakAll,children:b.children,maxLines:b.maxLines,scaleToFit:h,style:b.style,width:b.width})},[b.breakAll,b.children,b.maxLines,h,b.style,b.width]),N=b.dx,j=b.dy,_=b.angle,S=b.className,P=b.breakAll,k=rM(b,ISe);if(!ur(r)||!ur(i))return null;var C=r+(Xe(N)?N:0),T=i+(Xe(j)?j:0),O;switch(g){case"start":O=l_("calc(".concat(u,")"));break;case"middle":O=l_("calc(".concat((w.length-1)/2," * -").concat(l," + (").concat(u," / 2))"));break;default:O=l_("calc(".concat(w.length-1," * -").concat(l,")"));break}var L=[];if(h){var E=w[0].width,R=b.width;L.push("scale(".concat((Xe(R)?R/E:1)/E,")"))}return _&&L.push("rotate(".concat(_,", ").concat(C,", ").concat(T,")")),L.length&&(k.transform=L.join(" ")),ae.createElement("text",sN({},Yt(k,!0),{x:C,y:T,className:Qt("recharts-text",S),textAnchor:f,fill:v.includes("url")?oM:v}),w.map(function(q,I){var $=q.words.join(P?"":" ");return ae.createElement("tspan",{x:C,dy:I===0?O:l,key:"".concat($,"-").concat(I)},$)}))};function ul(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function KSe(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function x2(e){let t,n,r;e.length!==2?(t=ul,n=(l,c)=>ul(e(l),c),r=(l,c)=>e(l)-c):(t=e===ul||e===KSe?e:HSe,n=e,r=e);function s(l,c,u=0,d=l.length){if(u<d){if(t(c,c)!==0)return d;do{const h=u+d>>>1;n(l[h],c)<0?u=h+1:d=h}while(u<d)}return u}function i(l,c,u=0,d=l.length){if(u<d){if(t(c,c)!==0)return d;do{const h=u+d>>>1;n(l[h],c)<=0?u=h+1:d=h}while(u<d)}return u}function o(l,c,u=0,d=l.length){const h=s(l,c,u,d-1);return h>u&&r(l[h-1],c)>-r(l[h],c)?h-1:h}return{left:s,center:o,right:i}}function HSe(){return 0}function pB(e){return e===null?NaN:+e}function*GSe(e,t){for(let n of e)n!=null&&(n=+n)>=n&&(yield n)}const VSe=x2(ul),Lp=VSe.right;x2(pB).center;class lM extends Map{constructor(t,n=XSe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[r,s]of t)this.set(r,s)}get(t){return super.get(cM(this,t))}has(t){return super.has(cM(this,t))}set(t,n){return super.set(YSe(this,t),n)}delete(t){return super.delete(QSe(this,t))}}function cM({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function YSe({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function QSe({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function XSe(e){return e!==null&&typeof e=="object"?e.valueOf():e}function JSe(e=ul){if(e===ul)return gB;
859if(typeof e!="function")throw new TypeError("compare is not a function");return(t,n)=>{const r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function gB(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(e<t?-1:e>t?1:0)}const ZSe=Math.sqrt(50),eCe=Math.sqrt(10),tCe=Math.sqrt(2);function zy(e,t,n){const r=(t-e)/Math.max(0,n),s=Math.floor(Math.log10(r)),i=r/Math.pow(10,s),o=i>=ZSe?10:i>=eCe?5:i>=tCe?2:1;let l,c,u;return s<0?(u=Math.pow(10,-s)/o,l=Math.round(e*u),c=Math.round(t*u),l/u<e&&++l,c/u>t&&--c,u=-u):(u=Math.pow(10,s)*o,l=Math.round(e/u),c=Math.round(t/u),l*u<e&&++l,c*u>t&&--c),c<l&&.5<=n&&n<2?zy(e,t,n*2):[l,c,u]}function iN(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];const r=t<e,[s,i,o]=r?zy(t,e,n):zy(e,t,n);if(!(i>=s))return[];const l=i-s+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(i-u)/-o;else for(let u=0;u<l;++u)c[u]=(i-u)*o;else if(o<0)for(let u=0;u<l;++u)c[u]=(s+u)/-o;else for(let u=0;u<l;++u)c[u]=(s+u)*o;return c}function oN(e,t,n){return t=+t,e=+e,n=+n,zy(e,t,n)[2]}function lN(e,t,n){t=+t,e=+e,n=+n;const r=t<e,s=r?oN(t,e,n):oN(e,t,n);return(r?-1:1)*(s<0?1/-s:s)}function uM(e,t){let n;for(const r of e)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function dM(e,t){let n;for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function xB(e,t,n=0,r=1/0,s){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(s=s===void 0?gB:JSe(s);r>n;){if(r-n>600){const c=r-n+1,u=t-n+1,d=Math.log(c),h=.5*Math.exp(2*d/3),m=.5*Math.sqrt(d*h*(c-h)/c)*(u-c/2<0?-1:1),f=Math.max(n,Math.floor(t-u*h/c+m)),x=Math.min(r,Math.floor(t+(c-u)*h/c+m));xB(e,t,f,x,s)}const i=e[t];let o=n,l=r;for(Jh(e,n,t),s(e[r],i)>0&&Jh(e,n,r);o<l;){for(Jh(e,o,l),++o,--l;s(e[o],i)<0;)++o;for(;s(e[l],i)>0;)--l}s(e[n],i)===0?Jh(e,n,l):(++l,Jh(e,l,r)),l<=t&&(n=l+1),t<=l&&(r=l-1)}return e}function Jh(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function nCe(e,t,n){if(e=Float64Array.from(GSe(e)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return dM(e);if(t>=1)return uM(e);var r,s=(r-1)*t,i=Math.floor(s),o=uM(xB(e,i).subarray(0,i+1)),l=dM(e.subarray(i+1));return o+(l-o)*(s-i)}}function rCe(e,t,n=pB){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,s=(r-1)*t,i=Math.floor(s),o=+n(e[i],i,e),l=+n(e[i+1],i+1,e);return o+(l-o)*(s-i)}}function aCe(e,t,n){e=+e,t=+t,n=(s=arguments.length)<2?(t=e,e=0,1):s<3?1:+n;for(var r=-1,s=Math.max(0,Math.ceil((t-e)/n))|0,i=new Array(s);++r<s;)i[r]=e+r*n;return i}function ys(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function wo(e,t){switch(arguments.length){case 0:break;case 1:{typeof e=="function"?this.interpolator(e):this.range(e);break}default:{this.domain(e),typeof t=="function"?this.interpolator(t):this.range(t);break}}return this}const cN=Symbol("implicit");function y2(){var e=new lM,t=[],n=[],r=cN;function s(i){let o=e.get(i);if(o===void 0){if(r!==cN)return r;e.set(i,o=t.push(i)-1)}return n[o%n.length]}return s.domain=function(i){if(!arguments.length)return t.slice();t=[],e=new lM;for(const o of i)e.has(o)||e.set(o,t.push(o)-1);return s},s.range=function(i){return arguments.length?(n=Array.from(i),s):n.slice()},s.unknown=function(i){return arguments.length?(r=i,s):r},s.copy=function(){return y2(t,n).unknown(r)},ys.apply(s,arguments),s}function km(){var e=y2().unknown(void 0),t=e.domain,n=e.range,r=0,s=1,i,o,l=!1,c=0,u=0,d=.5;delete e.unknown;function h(){var m=t().length,f=s<r,x=f?s:r,g=f?r:s;i=(g-x)/Math.max(1,m-c+u*2),l&&(i=Math.floor(i)),x+=(g-x-i*(m-c))*d,o=i*(1-c),l&&(x=Math.round(x),o=Math.round(o));var p=aCe(m).map(function(v){return x+i*v});return n(f?p.reverse():p)}return e.domain=function(m){return arguments.length?(t(m),h()):t()},e.range=function(m){return arguments.length?([r,s]=m,r=+r,s=+s,h()):[r,s]},e.rangeRound=function(m){return[r,s]=m,r=+r,s=+s,l=!0,h()},e.bandwidth=function(){return o},e.step=function(){return i},e.round=function(m){return arguments.length?(l=!!m,h()):l},e.padding=function(m){return arguments.length?(c=Math.min(1,u=+m),h()):c},e.paddingInner=function(m){return arguments.length?(c=Math.min(1,m),h()):c},e.paddingOuter=function(m){return arguments.length?(u=+m,h()):u},e.align=function(m){return arguments.length?(d=Math.max(0,Math.min(1,m)),h()):d},e.copy=function(){return km(t(),[r,s]).round(l).paddingInner(c).paddingOuter(u).align(d)},ys.apply(h(),arguments)}function yB(e){var t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return yB(t())},e}function Mf(){return yB(km.apply(null,arguments).paddingInner(1))}function v2(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function vB(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Fp(){}var Em=.7,By=1/Em,ad="\\s*([+-]?\\d+)\\s*",Pm="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",vi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sCe=/^#([0-9a-f]{3,8})$/,iCe=new RegExp(`^rgb\\(${ad},${ad},${ad}\\)$`),oCe=new RegExp(`^rgb\\(${vi},${vi},${vi}\\)$`),lCe=new RegExp(`^rgba\\(${ad},${ad},${ad},${Pm}\\)$`),cCe=new RegExp(`^rgba\\(${vi},${vi},${vi},${Pm}\\)$`),uCe=new RegExp(`^hsl\\(${Pm},${vi},${vi}\\)$`),dCe=new RegExp(`^hsla\\(${Pm},${vi},${vi},${Pm}\\)$`),hM={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};v2(Fp,Om,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:fM,formatHex:fM,formatHex8:hCe,formatHsl:fCe,formatRgb:mM,toString:mM});function fM(){return this.rgb().formatHex()}function hCe(){return this.rgb().formatHex8()}function fCe(){return bB(this).formatHsl()}function mM(){return this.rgb().formatRgb()}
vendor: 4,500 bytes, line 859
859function Om(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=sCe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?pM(t):n===3?new va(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Bg(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Bg(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=iCe.exec(e))?new va(t[1],t[2],t[3],1):(t=oCe.exec(e))?new va(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=lCe.exec(e))?Bg(t[1],t[2],t[3],t[4]):(t=cCe.exec(e))?Bg(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uCe.exec(e))?yM(t[1],t[2]/100,t[3]/100,1):(t=dCe.exec(e))?yM(t[1],t[2]/100,t[3]/100,t[4]):hM.hasOwnProperty(e)?pM(hM[e]):e==="transparent"?new va(NaN,NaN,NaN,0):null}function pM(e){return new va(e>>16&255,e>>8&255,e&255,1)}function Bg(e,t,n,r){return r<=0&&(e=t=n=NaN),new va(e,t,n,r)}function mCe(e){return e instanceof Fp||(e=Om(e)),e?(e=e.rgb(),new va(e.r,e.g,e.b,e.opacity)):new va}function uN(e,t,n,r){return arguments.length===1?mCe(e):new va(e,t,n,r??1)}function va(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}v2(va,uN,vB(Fp,{brighter(e){return e=e==null?By:Math.pow(By,e),new va(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Em:Math.pow(Em,e),new va(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new va(wc(this.r),wc(this.g),wc(this.b),Uy(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:gM,formatHex:gM,formatHex8:pCe,formatRgb:xM,toString:xM}));function gM(){return`#${sc(this.r)}${sc(this.g)}${sc(this.b)}`}function pCe(){return`#${sc(this.r)}${sc(this.g)}${sc(this.b)}${sc((isNaN(this.opacity)?1:this.opacity)*255)}`}function xM(){const e=Uy(this.opacity);return`${e===1?"rgb(":"rgba("}${wc(this.r)}, ${wc(this.g)}, ${wc(this.b)}${e===1?")":`, ${e})`}`}function Uy(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function wc(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function sc(e){return e=wc(e),(e<16?"0":"")+e.toString(16)}function yM(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new qs(e,t,n,r)}function bB(e){if(e instanceof qs)return new qs(e.h,e.s,e.l,e.opacity);if(e instanceof Fp||(e=Om(e)),!e)return new qs;if(e instanceof qs)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),o=NaN,l=i-s,c=(i+s)/2;return l?(t===i?o=(n-r)/l+(n<r)*6:n===i?o=(r-t)/l+2:o=(t-n)/l+4,l/=c<.5?i+s:2-i-s,o*=60):l=c>0&&c<1?0:o,new qs(o,l,c,e.opacity)}function gCe(e,t,n,r){return arguments.length===1?bB(e):new qs(e,t,n,r??1)}function qs(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}v2(qs,gCe,vB(Fp,{brighter(e){return e=e==null?By:Math.pow(By,e),new qs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Em:Math.pow(Em,e),new qs(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,s=2*n-r;return new va(c_(e>=240?e-240:e+120,s,r),c_(e,s,r),c_(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new qs(vM(this.h),Ug(this.s),Ug(this.l),Uy(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Uy(this.opacity);return`${e===1?"hsl(":"hsla("}${vM(this.h)}, ${Ug(this.s)*100}%, ${Ug(this.l)*100}%${e===1?")":`, ${e})`}`}}));function vM(e){return e=(e||0)%360,e<0?e+360:e}function Ug(e){return Math.max(0,Math.min(1,e||0))}function c_(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const b2=e=>()=>e;function xCe(e,t){return function(n){return e+n*t}}function yCe(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function vCe(e){return(e=+e)==1?wB:function(t,n){return n-t?yCe(t,n,e):b2(isNaN(t)?n:t)}}function wB(e,t){var n=t-e;return n?xCe(e,n):b2(isNaN(e)?t:e)}const bM=function e(t){var n=vCe(t);function r(s,i){var o=n((s=uN(s)).r,(i=uN(i)).r),l=n(s.g,i.g),c=n(s.b,i.b),u=wB(s.opacity,i.opacity);return function(d){return s.r=o(d),s.g=l(d),s.b=c(d),s.opacity=u(d),s+""}}return r.gamma=e,r}(1);function bCe(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(i){for(s=0;s<n;++s)r[s]=e[s]*(1-i)+t[s]*i;return r}}function wCe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function _Ce(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),i=new Array(n),o;for(o=0;o<r;++o)s[o]=Nh(e[o],t[o]);for(;o<n;
vendor: 5,514 bytes, line 859
859++o)i[o]=t[o];return function(l){for(o=0;o<r;++o)i[o]=s[o](l);return i}}function jCe(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Wy(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function NCe(e,t){var n={},r={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=Nh(e[s],t[s]):r[s]=t[s];return function(i){for(s in n)r[s]=n[s](i);return r}}var dN=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,u_=new RegExp(dN.source,"g");function SCe(e){return function(){return e}}function CCe(e){return function(t){return e(t)+""}}function kCe(e,t){var n=dN.lastIndex=u_.lastIndex=0,r,s,i,o=-1,l=[],c=[];for(e=e+"",t=t+"";(r=dN.exec(e))&&(s=u_.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),l[o]?l[o]+=i:l[++o]=i),(r=r[0])===(s=s[0])?l[o]?l[o]+=s:l[++o]=s:(l[++o]=null,c.push({i:o,x:Wy(r,s)})),n=u_.lastIndex;return n<t.length&&(i=t.slice(n),l[o]?l[o]+=i:l[++o]=i),l.length<2?c[0]?CCe(c[0].x):SCe(t):(t=c.length,function(u){for(var d=0,h;d<t;++d)l[(h=c[d]).i]=h.x(u);return l.join("")})}function Nh(e,t){var n=typeof t,r;return t==null||n==="boolean"?b2(t):(n==="number"?Wy:n==="string"?(r=Om(t))?(t=r,bM):kCe:t instanceof Om?bM:t instanceof Date?jCe:wCe(t)?bCe:Array.isArray(t)?_Ce:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?NCe:Wy)(e,t)}function w2(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function ECe(e,t){t===void 0&&(t=e,e=Nh);for(var n=0,r=t.length-1,s=t[0],i=new Array(r<0?0:r);n<r;)i[n]=e(s,s=t[++n]);return function(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return i[l](o-l)}}function PCe(e){return function(){return e}}function Ky(e){return+e}var wM=[0,1];function aa(e){return e}function hN(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:PCe(isNaN(t)?NaN:.5)}function OCe(e,t){var n;return e>t&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function ACe(e,t,n){var r=e[0],s=e[1],i=t[0],o=t[1];return s<r?(r=hN(s,r),i=n(o,i)):(r=hN(r,s),i=n(i,o)),function(l){return i(r(l))}}function TCe(e,t,n){var r=Math.min(e.length,t.length)-1,s=new Array(r),i=new Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)s[o]=hN(e[o],e[o+1]),i[o]=n(t[o],t[o+1]);return function(l){var c=Lp(e,l,1,r)-1;return i[c](s[c](l))}}function qp(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function i0(){var e=wM,t=wM,n=Nh,r,s,i,o=aa,l,c,u;function d(){var m=Math.min(e.length,t.length);return o!==aa&&(o=OCe(e[0],e[m-1])),l=m>2?TCe:ACe,c=u=null,h}function h(m){return m==null||isNaN(m=+m)?i:(c||(c=l(e.map(r),t,n)))(r(o(m)))}return h.invert=function(m){return o(s((u||(u=l(t,e.map(r),Wy)))(m)))},h.domain=function(m){return arguments.length?(e=Array.from(m,Ky),d()):e.slice()},h.range=function(m){return arguments.length?(t=Array.from(m),d()):t.slice()},h.rangeRound=function(m){return t=Array.from(m),n=w2,d()},h.clamp=function(m){return arguments.length?(o=m?!0:aa,d()):o!==aa},h.interpolate=function(m){return arguments.length?(n=m,d()):n},h.unknown=function(m){return arguments.length?(i=m,h):i},function(m,f){return r=m,s=f,d()}}function _2(){return i0()(aa,aa)}function MCe(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function Hy(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function $d(e){return e=Hy(Math.abs(e)),e?e[1]:NaN}function DCe(e,t){return function(n,r){for(var s=n.length,i=[],o=0,l=e[0],c=0;s>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),i.push(n.substring(s-=l,s+l)),!((c+=l+1)>r));)l=e[o=(o+1)%e.length];return i.reverse().join(t)}}function $Ce(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var RCe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Am(e){if(!(t=RCe.exec(e)))throw new Error("invalid format: "+e);var t;return new j2({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]})}Am.prototype=j2.prototype;function j2(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+""}j2.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 ICe(e){e:for(var t=e.length,n=1,r=-1,s;n<t;++n)switch(e[n]){case".":r=s=n;break;case"0":r===0&&(r=n),s=n;break;default:if(!+e[n])break e;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(s+1):e}var _B;function LCe(e,t){var n=Hy(e,t);if(!n)return e+"";var r=n[0],s=n[1],i=s-(_B=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,o=r.length;return i===o?r:i>o?r+new Array(i-o+1).join("0"):i>0?r.slice(0,i)+"."+r.slice(i):"0."+new Array(1-i).join("0")+Hy(e,Math.max(0,t+i-1))[0]}function _M(e,t){var n=Hy(e,t);if(!n)return e+"";var r=n[0],s=n[1];return s<0?"0."+new Array(-s).join("0")+r:r.length>s+1?r.slice(0,s+1)+"."+r.slice(s+1):r+new Array(s-r.length+2).join("0")}const jM={"%":(e,t)=>
vendor: 4,803 bytes, line 859
859(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:MCe,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)=>_M(e*100,t),r:_M,s:LCe,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function NM(e){return e}var SM=Array.prototype.map,CM=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function FCe(e){var t=e.grouping===void 0||e.thousands===void 0?NM:DCe(SM.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",s=e.decimal===void 0?".":e.decimal+"",i=e.numerals===void 0?NM:$Ce(SM.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",l=e.minus===void 0?"â":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function u(h){h=Am(h);var m=h.fill,f=h.align,x=h.sign,g=h.symbol,p=h.zero,v=h.width,b=h.comma,w=h.precision,N=h.trim,j=h.type;j==="n"?(b=!0,j="g"):jM[j]||(w===void 0&&(w=12),N=!0,j="g"),(p||m==="0"&&f==="=")&&(p=!0,m="0",f="=");var _=g==="$"?n:g==="#"&&/[boxX]/.test(j)?"0"+j.toLowerCase():"",S=g==="$"?r:/[%p]/.test(j)?o:"",P=jM[j],k=/[defgprs%]/.test(j);w=w===void 0?6:/[gprs]/.test(j)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function C(T){var O=_,L=S,E,R,q;if(j==="c")L=P(T)+L,T="";else{T=+T;var I=T<0||1/T<0;if(T=isNaN(T)?c:P(Math.abs(T),w),N&&(T=ICe(T)),I&&+T==0&&x!=="+"&&(I=!1),O=(I?x==="("?x:l:x==="-"||x==="("?"":x)+O,L=(j==="s"?CM[8+_B/3]:"")+L+(I&&x==="("?")":""),k){for(E=-1,R=T.length;++E<R;)if(q=T.charCodeAt(E),48>q||q>57){L=(q===46?s+T.slice(E+1):T.slice(E))+L,T=T.slice(0,E);break}}}b&&!p&&(T=t(T,1/0));var $=O.length+T.length+L.length,M=$<v?new Array(v-$+1).join(m):"";switch(b&&p&&(T=t(M+T,M.length?v-L.length:1/0),M=""),f){case"<":T=O+T+L+M;break;case"=":T=O+M+T+L;break;case"^":T=M.slice(0,$=M.length>>1)+O+T+L+M.slice($);break;default:T=M+O+T+L;break}return i(T)}return C.toString=function(){return h+""},C}function d(h,m){var f=u((h=Am(h),h.type="f",h)),x=Math.max(-8,Math.min(8,Math.floor($d(m)/3)))*3,g=Math.pow(10,-x),p=CM[8+x/3];return function(v){return f(g*v)+p}}return{format:u,formatPrefix:d}}var Wg,N2,jB;qCe({thousands:",",grouping:[3],currency:["$",""]});function qCe(e){return Wg=FCe(e),N2=Wg.format,jB=Wg.formatPrefix,Wg}function zCe(e){return Math.max(0,-$d(Math.abs(e)))}function BCe(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor($d(t)/3)))*3-$d(Math.abs(e)))}function UCe(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,$d(t)-$d(e))+1}function NB(e,t,n,r){var s=lN(e,t,n),i;switch(r=Am(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(i=BCe(s,o))&&(r.precision=i),jB(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(i=UCe(s,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=i-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(i=zCe(s))&&(r.precision=i-(r.type==="%")*2);break}}return N2(r)}function Dl(e){var t=e.domain;return e.ticks=function(n){var r=t();return iN(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var s=t();return NB(s[0],s[s.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),s=0,i=r.length-1,o=r[s],l=r[i],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=s,s=i,i=u);d-- >0;){if(u=oN(o,l,n),u===c)return r[s]=o,r[i]=l,t(r);if(u>0)o=Math.floor(o/u)*u,l=Math.ceil(l/u)*u;else if(u<0)o=Math.ceil(o*u)/u,l=Math.floor(l*u)/u;else break;c=u}return e},e}function Gy(){var e=_2();return e.copy=function(){return qp(e,Gy())},ys.apply(e,arguments),Dl(e)}function SB(e){var t;function n(r){return r==null||isNaN(r=+r)?t:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(e=Array.from(r,Ky),n):e.slice()},n.unknown=function(r){return arguments.length?(t=r,n):t},n.copy=function(){return SB(e).unknown(t)},e=arguments.length?Array.from(e,Ky):[0,1],Dl(n)}function CB(e,t){e=e.slice();var n=0,r=e.length-1,s=e[n],i=e[r],o;return i<s&&(o=n,n=r,r=o,o=s,s=i,i=o),e[n]=t.floor(s),e[r]=t.ceil(i),e}function kM(e){return Math.log(e)}function EM(e){return Math.exp(e)}function WCe(e){return-Math.log(-e)}function KCe(e){return-Math.exp(-e)}function HCe(e){return isFinite(e)?+("1e"+e):e<0?0:e}function GCe(e){return e===10?HCe:e===Math.E?Math.exp:t=>Math.pow(e,t)}function VCe(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 PM(e){return(t,n)=>-e(-t,n)}function S2(e){const t=e(kM,EM),n=t.domain;let r=10,s,i;function o(){return s=VCe(r),i=GCe(r),n()[0]<0?(s=PM(s),i=PM(i),e(WCe,KCe)):e(kM,EM),t}return t.base=function(l){return arguments.length?(r=+l,o()):r},t.domain=function(l){return arguments.length?(n(l),o()):n()},t.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const h=d<u;h&&([u,d]=[d,u]);let m=s(u),f=s(d),x,g;const p=l==null?10:+l;let v=[];
vendor: 4,136 bytes, line 859
859if(!(r%1)&&f-m<p){if(m=Math.floor(m),f=Math.ceil(f),u>0){for(;m<=f;++m)for(x=1;x<r;++x)if(g=m<0?x/i(-m):x*i(m),!(g<u)){if(g>d)break;v.push(g)}}else for(;m<=f;++m)for(x=r-1;x>=1;--x)if(g=m>0?x/i(-m):x*i(m),!(g<u)){if(g>d)break;v.push(g)}v.length*2<p&&(v=iN(u,d,p))}else v=iN(m,f,Math.min(f-m,p)).map(i);return h?v.reverse():v},t.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=Am(c)).precision==null&&(c.trim=!0),c=N2(c)),l===1/0)return c;const u=Math.max(1,r*l/t.ticks().length);return d=>{let h=d/i(Math.round(s(d)));return h*r<r-.5&&(h*=r),h<=u?c(d):""}},t.nice=()=>n(CB(n(),{floor:l=>i(Math.floor(s(l))),ceil:l=>i(Math.ceil(s(l)))})),t}function kB(){const e=S2(i0()).domain([1,10]);return e.copy=()=>qp(e,kB()).base(e.base()),ys.apply(e,arguments),e}function OM(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function AM(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function C2(e){var t=1,n=e(OM(t),AM(t));return n.constant=function(r){return arguments.length?e(OM(t=+r),AM(t)):t},Dl(n)}function EB(){var e=C2(i0());return e.copy=function(){return qp(e,EB()).constant(e.constant())},ys.apply(e,arguments)}function TM(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function YCe(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function QCe(e){return e<0?-e*e:e*e}function k2(e){var t=e(aa,aa),n=1;function r(){return n===1?e(aa,aa):n===.5?e(YCe,QCe):e(TM(n),TM(1/n))}return t.exponent=function(s){return arguments.length?(n=+s,r()):n},Dl(t)}function E2(){var e=k2(i0());return e.copy=function(){return qp(e,E2()).exponent(e.exponent())},ys.apply(e,arguments),e}function XCe(){return E2.apply(null,arguments).exponent(.5)}function MM(e){return Math.sign(e)*e*e}function JCe(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function PB(){var e=_2(),t=[0,1],n=!1,r;function s(i){var o=JCe(e(i));return isNaN(o)?r:n?Math.round(o):o}return s.invert=function(i){return e.invert(MM(i))},s.domain=function(i){return arguments.length?(e.domain(i),s):e.domain()},s.range=function(i){return arguments.length?(e.range((t=Array.from(i,Ky)).map(MM)),s):t.slice()},s.rangeRound=function(i){return s.range(i).round(!0)},s.round=function(i){return arguments.length?(n=!!i,s):n},s.clamp=function(i){return arguments.length?(e.clamp(i),s):e.clamp()},s.unknown=function(i){return arguments.length?(r=i,s):r},s.copy=function(){return PB(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},ys.apply(s,arguments),Dl(s)}function OB(){var e=[],t=[],n=[],r;function s(){var o=0,l=Math.max(1,t.length);for(n=new Array(l-1);++o<l;)n[o-1]=rCe(e,o/l);return i}function i(o){return o==null||isNaN(o=+o)?r:t[Lp(n,o)]}return i.invertExtent=function(o){var l=t.indexOf(o);return l<0?[NaN,NaN]:[l>0?n[l-1]:e[0],l<n.length?n[l]:e[e.length-1]]},i.domain=function(o){if(!arguments.length)return e.slice();e=[];for(let l of o)l!=null&&!isNaN(l=+l)&&e.push(l);return e.sort(ul),s()},i.range=function(o){return arguments.length?(t=Array.from(o),s()):t.slice()},i.unknown=function(o){return arguments.length?(r=o,i):r},i.quantiles=function(){return n.slice()},i.copy=function(){return OB().domain(e).range(t).unknown(r)},ys.apply(i,arguments)}function AB(){var e=0,t=1,n=1,r=[.5],s=[0,1],i;function o(c){return c!=null&&c<=c?s[Lp(r,c,0,n)]:i}function l(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*t-(c-n)*e)/(n+1);return o}return o.domain=function(c){return arguments.length?([e,t]=c,e=+e,t=+t,l()):[e,t]},o.range=function(c){return arguments.length?(n=(s=Array.from(c)).length-1,l()):s.slice()},o.invertExtent=function(c){var u=s.indexOf(c);return u<0?[NaN,NaN]:u<1?[e,r[0]]:u>=n?[r[n-1],t]:[r[u-1],r[u]]},o.unknown=function(c){return arguments.length&&(i=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return AB().domain([e,t]).range(s).unknown(i)},ys.apply(Dl(o),arguments)}function TB(){var e=[.5],t=[0,1],n,r=1;function s(i){return i!=null&&i<=i?t[Lp(e,i,0,r)]:n}return s.domain=function(i){return arguments.length?(e=Array.from(i),r=Math.min(e.length,t.length-1),s):e.slice()},s.range=function(i){return arguments.length?(t=Array.from(i),r=M
vendor: 7,244 bytes, line 859
859ath.min(e.length,t.length-1),s):t.slice()},s.invertExtent=function(i){var o=t.indexOf(i);return[e[o-1],e[o]]},s.unknown=function(i){return arguments.length?(n=i,s):n},s.copy=function(){return TB().domain(e).range(t).unknown(n)},ys.apply(s,arguments)}const d_=new Date,h_=new Date;function pr(e,t,n,r){function s(i){return e(i=arguments.length===0?new Date:new Date(+i)),i}return s.floor=i=>(e(i=new Date(+i)),i),s.ceil=i=>(e(i=new Date(i-1)),t(i,1),e(i),i),s.round=i=>{const o=s(i),l=s.ceil(i);return i-o<l-i?o:l},s.offset=(i,o)=>(t(i=new Date(+i),o==null?1:Math.floor(o)),i),s.range=(i,o,l)=>{const c=[];if(i=s.ceil(i),l=l==null?1:Math.floor(l),!(i<o)||!(l>0))return c;let u;do c.push(u=new Date(+i)),t(i,l),e(i);while(u<i&&i<o);return c},s.filter=i=>pr(o=>{if(o>=o)for(;e(o),!i(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;t(o,-1),!i(o););else for(;--l>=0;)for(;t(o,1),!i(o););}),n&&(s.count=(i,o)=>(d_.setTime(+i),h_.setTime(+o),e(d_),e(h_),Math.floor(n(d_,h_))),s.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?s.filter(r?o=>r(o)%i===0:o=>s.count(0,o)%i===0):s)),s}const Vy=pr(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);Vy.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?pr(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):Vy);Vy.range;const Bi=1e3,is=Bi*60,Ui=is*60,lo=Ui*24,P2=lo*7,DM=lo*30,f_=lo*365,ic=pr(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Bi)},(e,t)=>(t-e)/Bi,e=>e.getUTCSeconds());ic.range;const O2=pr(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Bi)},(e,t)=>{e.setTime(+e+t*is)},(e,t)=>(t-e)/is,e=>e.getMinutes());O2.range;const A2=pr(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*is)},(e,t)=>(t-e)/is,e=>e.getUTCMinutes());A2.range;const T2=pr(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Bi-e.getMinutes()*is)},(e,t)=>{e.setTime(+e+t*Ui)},(e,t)=>(t-e)/Ui,e=>e.getHours());T2.range;const M2=pr(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Ui)},(e,t)=>(t-e)/Ui,e=>e.getUTCHours());M2.range;const zp=pr(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*is)/lo,e=>e.getDate()-1);zp.range;const o0=pr(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/lo,e=>e.getUTCDate()-1);o0.range;const MB=pr(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/lo,e=>Math.floor(e/lo));MB.range;function Qc(e){return pr(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,n)=>{t.setDate(t.getDate()+n*7)},(t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*is)/P2)}const l0=Qc(0),Yy=Qc(1),ZCe=Qc(2),eke=Qc(3),Rd=Qc(4),tke=Qc(5),nke=Qc(6);l0.range;Yy.range;ZCe.range;eke.range;Rd.range;tke.range;nke.range;function Xc(e){return pr(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCDate(t.getUTCDate()+n*7)},(t,n)=>(n-t)/P2)}const c0=Xc(0),Qy=Xc(1),rke=Xc(2),ake=Xc(3),Id=Xc(4),ske=Xc(5),ike=Xc(6);c0.range;Qy.range;rke.range;ake.range;Id.range;ske.range;ike.range;const D2=pr(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());D2.range;const $2=pr(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());$2.range;const co=pr(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());co.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:pr(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)});co.range;const uo=pr(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());uo.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:pr(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)});uo.range;function DB(e,t,n,r,s,i){const o=[[ic,1,Bi],[ic,5,5*Bi],[ic,15,15*Bi],[ic,30,30*Bi],[i,1,is],[i,5,5*is],[i,15,15*is],[i,30,30*is],[s,1,Ui],[s,3,3*Ui],[s,6,6*Ui],[s,12,12*Ui],[r,1,lo],[r,2,2*lo],[n,1,P2],[t,1,DM],[t,3,3*DM],[e,1,f_]];function l(u,d,h){const m=d<u;m&&([u,d]=[d,u]);const f=h&&typeof h.range=="function"?h:c(u,d,h),x=f?f.range(u,+d+1):[];return m?x.reverse():x}function c(u,d,h){const m=Math.abs(d-u)/h,f=x2(([,,p])=>p).right(o,m);if(f===o.length)return e.every(lN(u/f_,d/f_,h));if(f===0)return Vy.every(Math.max(lN(u,d,h),1));const[x,g]=o[m/o[f-1][2]<o[f][2]/m?f-1:f];return x.every(g)}return[l,c]}const[oke,lke]=DB(uo,$2,c0,MB,M2,A2),[cke,uke]=DB(co,D2,l0,zp,T2,O2);function m_(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 p_(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 Zh(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function dke(e){var t=e.dateTime,n=e.date,r=e.time,s=e.periods,i=e.days,o=e.shortDays,l=e.months,c=e.shortMonths,u=ef(s),d=tf(s),h=ef(i),m=tf(i),f=ef(o),x=tf(o),g=ef(l),p=tf(l),v=ef(c),b=tf(c),w={a:I,A:$,b:M,B,c:null,d:qM,e:qM,f:Dke,g:Wke,G:Hke,H:Ake,I:Tke,j:Mke,L:$B,m:$ke,M:Rke,p:W,q:A,Q:UM,s:WM,S:Ike,u:Lke,U:Fke,V:qke,w:zke,W:Bke,x:null,X:null,y:Uke,Y:Kke,Z:Gke,"%":BM},N={a:K,A:G,b:H,B:fe,c:null,d:zM,e:zM,f:Xke,g:o2e,G:c2e,H:Vke,I:Yke,j:Qke,L:IB,m:Jke,M:Zke,p:te,q:J,Q:UM,s:WM,S:e2e,u:t2e,U:n2e,V:r2e,w:a2e,W:s2e,x:null,X:null,y:i2e,Y:l2e,Z:u2e,"%":BM},j={a:C,A:T,b:O,B:L,c:E,d:LM,e:LM,f:kke,g:IM,G:RM,H:FM,I:FM,j:jke,L:Cke,m:_ke,M:Nke,p:k,q:wke,Q:Pke,s:Oke,S:Ske,u:gke,U:xke,V:yke,w:pke,W:vke,x:R,X:q,y:IM,Y:RM,Z:bke,"%":Eke};w.x=_(n,w),w.X=_(r,w),w.c=_(t,w),N.x=_(n,N),N.X=_(r,N),N.c=_(t,N);function _(re,pe){return function(ye){var X=[],he=-1,D=0,le=re.length,V,U,z;for(ye instanceof Date||(ye=new Date(+ye));++he<le;)re.charCodeAt(he)===37&&(X.push(re.slice(D,he)),(U=$M[V=re.charAt(++he)])!=null?V=re.charAt(++he):U=V==="e"?" ":"0",(z=pe[V])&&(V=z(ye,U)),X.push(V),D=he+1);return X.push(re.slice(D,he)),X.join("")}}function S(re,pe){return function(ye){var X=Zh(1900,void 0,1),he=P(X,re,ye+="",0),D,le;if(he!=ye.length)return null;if("Q"in X)return new Date(X.Q);if("s"in X)return new Date(X.s*1e3+("L"in X?X.L:0));if(pe&&!("Z"in X)&&(X.Z=0),"p"in X&&(X.H=X.H%12+X.p*12),X.m===void 0&&(X.m="q"in X?X.q:0),"V"in X){if(X.V<1||X.V>53)return null;"w"in X||(X.w=1),"Z"in X?(D=p_(Zh(X.y,0,1)),le=D.getUTCDay(),D=le>4||le===0?Qy.ceil(D):Qy(D),D=o0.offset(D,(X.V-1)*7),X.y=D.getUTCFullYear(),X.m=D.getUTCMonth(),X.d=D.getUTCDate()+(X.w+6)%7):(D=m_(Zh(X.y,0,1)),le=D.getDay(),D=le>4||le===0?Yy.ceil(D):Yy(D),D=zp.offset(D,(X.V-1)*7),X.y=D.getFullYear(),X.m=D.getMonth(),X.d=D.getDate()+(X.w+6)%7)}else("W"in X||"U"in X)&&("w"in X||(X.w="u"in X?X.u%7:"W"in X?1:0),le="Z"in X?p_(Zh(X.y,0,1)).getUTCDay():m_(Zh(X.y,0,1)).getDay(),X.m=0,X.d="W"in X?(X.w+6)%7+X.W*7-(le+5)%7:X.w+X.U*7-(le+6)%7);
vendor: 6,523 bytes, line 859
859return"Z"in X?(X.H+=X.Z/100|0,X.M+=X.Z%100,p_(X)):m_(X)}}function P(re,pe,ye,X){for(var he=0,D=pe.length,le=ye.length,V,U;he<D;){if(X>=le)return-1;if(V=pe.charCodeAt(he++),V===37){if(V=pe.charAt(he++),U=j[V in $M?pe.charAt(he++):V],!U||(X=U(re,ye,X))<0)return-1}else if(V!=ye.charCodeAt(X++))return-1}return X}function k(re,pe,ye){var X=u.exec(pe.slice(ye));return X?(re.p=d.get(X[0].toLowerCase()),ye+X[0].length):-1}function C(re,pe,ye){var X=f.exec(pe.slice(ye));return X?(re.w=x.get(X[0].toLowerCase()),ye+X[0].length):-1}function T(re,pe,ye){var X=h.exec(pe.slice(ye));return X?(re.w=m.get(X[0].toLowerCase()),ye+X[0].length):-1}function O(re,pe,ye){var X=v.exec(pe.slice(ye));return X?(re.m=b.get(X[0].toLowerCase()),ye+X[0].length):-1}function L(re,pe,ye){var X=g.exec(pe.slice(ye));return X?(re.m=p.get(X[0].toLowerCase()),ye+X[0].length):-1}function E(re,pe,ye){return P(re,t,pe,ye)}function R(re,pe,ye){return P(re,n,pe,ye)}function q(re,pe,ye){return P(re,r,pe,ye)}function I(re){return o[re.getDay()]}function $(re){return i[re.getDay()]}function M(re){return c[re.getMonth()]}function B(re){return l[re.getMonth()]}function W(re){return s[+(re.getHours()>=12)]}function A(re){return 1+~~(re.getMonth()/3)}function K(re){return o[re.getUTCDay()]}function G(re){return i[re.getUTCDay()]}function H(re){return c[re.getUTCMonth()]}function fe(re){return l[re.getUTCMonth()]}function te(re){return s[+(re.getUTCHours()>=12)]}function J(re){return 1+~~(re.getUTCMonth()/3)}return{format:function(re){var pe=_(re+="",w);return pe.toString=function(){return re},pe},parse:function(re){var pe=S(re+="",!1);return pe.toString=function(){return re},pe},utcFormat:function(re){var pe=_(re+="",N);return pe.toString=function(){return re},pe},utcParse:function(re){var pe=S(re+="",!0);return pe.toString=function(){return re},pe}}}var $M={"-":"",_:" ",0:"0"},Nr=/^\s*\d+/,hke=/^%/,fke=/[\\^$*+?|[\]().{}]/g;function en(e,t,n){var r=e<0?"-":"",s=(r?-e:e)+"",i=s.length;return r+(i<n?new Array(n-i+1).join(t)+s:s)}function mke(e){return e.replace(fke,"\\$&")}function ef(e){return new RegExp("^(?:"+e.map(mke).join("|")+")","i")}function tf(e){return new Map(e.map((t,n)=>[t.toLowerCase(),n]))}function pke(e,t,n){var r=Nr.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function gke(e,t,n){var r=Nr.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function xke(e,t,n){var r=Nr.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function yke(e,t,n){var r=Nr.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function vke(e,t,n){var r=Nr.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function RM(e,t,n){var r=Nr.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function IM(e,t,n){var r=Nr.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function bke(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 wke(e,t,n){var r=Nr.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function _ke(e,t,n){var r=Nr.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function LM(e,t,n){var r=Nr.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function jke(e,t,n){var r=Nr.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function FM(e,t,n){var r=Nr.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function Nke(e,t,n){var r=Nr.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function Ske(e,t,n){var r=Nr.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function Cke(e,t,n){var r=Nr.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function kke(e,t,n){var r=Nr.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function Eke(e,t,n){var r=hke.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Pke(e,t,n){var r=Nr.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function Oke(e,t,n){var r=Nr.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function qM(e,t){return en(e.getDate(),t,2)}function Ake(e,t){return en(e.getHours(),t,2)}function Tke(e,t){return en(e.getHours()%12||12,t,2)}function Mke(e,t){return en(1+zp.count(co(e),e),t,3)}function $B(e,t){return en(e.getMilliseconds(),t,3)}function Dke(e,t){return $B(e,t)+"000"}function $ke(e,t){return en(e.getMonth()+1,t,2)}function Rke(e,t){return en(e.getMinutes(),t,2)}function Ike(e,t){return en(e.getSeconds(),t,2)}function Lke(e){var t=e.getDay();return t===0?7:t}function Fke(e,t){return en(l0.count(co(e)-1,e),t,2)}function RB(e){var t=e.getDay();return t>=4||t===0?Rd(e):Rd.ceil(e)}function qke(e,t){return e=RB(e),en(Rd.count(co(e),e)+(co(e).getDay()===4),t,2)}function zke(e){return e.getDay()}function Bke(e,t){return en(Yy.count(co(e)-1,e),t,2)}function Uke(e,t){return en(e.getFullYear()%100,t,2)}function Wke(e,t){return e=RB(e),en(e.getFullYear()%100,t,2)}function Kke(e,t){return en(e.getFullYear()%1e4,t,4)}function Hke(e,t){var n=e.getDay();return e=n>=4||n===0?Rd(e):Rd.ceil(e),en(e.getFullYear()%1e4,t,4)}function Gke(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+en(t/60|0,"0",2)+en(t%60,"0",2)}function zM(e,t){return en(e.getUTCDate(),t,2)}function Vke(e,t){return en(e.getUTCHours(),t,2)}function Yke(e,t){return en(e.getUTCHours()%12||12,t,2)}function Qke(e,t){return en(1+o0.count(uo(e),e),t,3)}function IB(e,t){return en(e.getUTCMilliseconds(),t,3)}function Xke(e,t){return IB(e,t)+"000"}function Jke(e,t){return en(e.getUTCMonth()+1,t,2)}function Zke(e,t){return en(e.getUTCMinutes(),t,2)}function e2e(e,t){return en(e.getUTCSeconds(),t,2)}function t2e(e){var t=e.getUTCDay();return t===0?7:t}function n2e(e,t){return en(c0.count(uo(e)-1,e),t,2)}function LB(e){var t=e.getUTCDay();return t>=4||t===0?Id(e):Id.ceil(e)}function r2e(e,t){return e=LB(e),en(Id.count(uo(e),e)+(uo(e).getUTCDay()===4),t,2)}function a2e(e){return e.getUTCDay()}function s2e(e,t){return en(Qy.count(uo(e)-1,e),t,2)}function i2e(e,t){return en(e.getUTCFullYear()%100,t,2)}function o2e(e,t){return e=LB(e),en(e.getUTCFullYear()%100,t,2)}function l2e(e,t){return en(e.getUTCFullYear()%1e4,t,4)}function c2e(e,t){var n=e.getUTCDay();return e=n>=4||n===0?Id(e):Id.ceil(e),en(e.getUTCFullYear()%1e4,t,4)}function u2e(){return"+0000"}function BM(){return"%"}function UM(e){return+e}function WM(e){return Math.floor(+e/1e3)}var vu,FB,qB;d2e({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Frid
859ay","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 d2e(e){return vu=dke(e),FB=vu.format,vu.parse,qB=vu.utcFormat,vu.utcParse,vu}function h2e(e){return new Date(e)}function f2e(e){return e instanceof Date?+e:+new Date(+e)}function R2(e,t,n,r,s,i,o,l,c,u){var d=_2(),h=d.invert,m=d.domain,f=u(".%L"),x=u(":%S"),g=u("%I:%M"),p=u("%I %p"),v=u("%a %d"),b=u("%b %d"),w=u("%B"),N=u("%Y");function j(_){return(c(_)<_?f:l(_)<_?x:o(_)<_?g:i(_)<_?p:r(_)<_?s(_)<_?v:b:n(_)<_?w:N)(_)}return d.invert=function(_){return new Date(h(_))},d.domain=function(_){return arguments.length?m(Array.from(_,f2e)):m().map(h2e)},d.ticks=function(_){var S=m();return e(S[0],S[S.length-1],_??10)},d.tickFormat=function(_,S){return S==null?j:u(S)},d.nice=function(_){var S=m();return(!_||typeof _.range!="function")&&(_=t(S[0],S[S.length-1],_??10)),_?m(CB(S,_)):d},d.copy=function(){return qp(d,R2(e,t,n,r,s,i,o,l,c,u))},d}function m2e(){return ys.apply(R2(cke,uke,co,D2,l0,zp,T2,O2,ic,FB).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function p2e(){return ys.apply(R2(oke,lke,uo,$2,c0,o0,M2,A2,ic,qB).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function u0(){var e=0,t=1,n,r,s,i,o=aa,l=!1,c;function u(h){return h==null||isNaN(h=+h)?c:o(s===0?.5:(h=(i(h)-n)*s,l?Math.max(0,Math.min(1,h)):h))}u.domain=function(h){return arguments.length?([e,t]=h,n=i(e=+e),r=i(t=+t),s=n===r?0:1/(r-n),u):[e,t]},u.clamp=function(h){return arguments.length?(l=!!h,u):l},u.interpolator=function(h){return arguments.length?(o=h,u):o};function d(h){return function(m){var f,x;return arguments.length?([f,x]=m,o=h(f,x),u):[o(0),o(1)]}}return u.range=d(Nh),u.rangeRound=d(w2),u.unknown=function(h){return arguments.length?(c=h,u):c},function(h){return i=h,n=h(e),r=h(t),s=n===r?0:1/(r-n),u}}function $l(e,t){return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function zB(){var e=Dl(u0()(aa));
vendor: 64,320 bytes, lines 859-885
859return e.copy=function(){return $l(e,zB())},wo.apply(e,arguments)}function BB(){var e=S2(u0()).domain([1,10]);return e.copy=function(){return $l(e,BB()).base(e.base())},wo.apply(e,arguments)}function UB(){var e=C2(u0());return e.copy=function(){return $l(e,UB()).constant(e.constant())},wo.apply(e,arguments)}function I2(){var e=k2(u0());return e.copy=function(){return $l(e,I2()).exponent(e.exponent())},wo.apply(e,arguments)}function g2e(){return I2.apply(null,arguments).exponent(.5)}function WB(){var e=[],t=aa;function n(r){if(r!=null&&!isNaN(r=+r))return t((Lp(e,r,1)-1)/(e.length-1))}return n.domain=function(r){if(!arguments.length)return e.slice();e=[];for(let s of r)s!=null&&!isNaN(s=+s)&&e.push(s);return e.sort(ul),n},n.interpolator=function(r){return arguments.length?(t=r,n):t},n.range=function(){return e.map((r,s)=>t(s/(e.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(s,i)=>nCe(e,i/r))},n.copy=function(){return WB(t).domain(e)},wo.apply(n,arguments)}function d0(){var e=0,t=.5,n=1,r=1,s,i,o,l,c,u=aa,d,h=!1,m;function f(g){return isNaN(g=+g)?m:(g=.5+((g=+d(g))-i)*(r*g<r*i?l:c),u(h?Math.max(0,Math.min(1,g)):g))}f.domain=function(g){return arguments.length?([e,t,n]=g,s=d(e=+e),i=d(t=+t),o=d(n=+n),l=s===i?0:.5/(i-s),c=i===o?0:.5/(o-i),r=i<s?-1:1,f):[e,t,n]},f.clamp=function(g){return arguments.length?(h=!!g,f):h},f.interpolator=function(g){return arguments.length?(u=g,f):u};function x(g){return function(p){var v,b,w;return arguments.length?([v,b,w]=p,u=ECe(g,[v,b,w]),f):[u(0),u(.5),u(1)]}}return f.range=x(Nh),f.rangeRound=x(w2),f.unknown=function(g){return arguments.length?(m=g,f):m},function(g){return d=g,s=g(e),i=g(t),o=g(n),l=s===i?0:.5/(i-s),c=i===o?0:.5/(o-i),r=i<s?-1:1,f}}function KB(){var e=Dl(d0()(aa));return e.copy=function(){return $l(e,KB())},wo.apply(e,arguments)}function HB(){var e=S2(d0()).domain([.1,1,10]);return e.copy=function(){return $l(e,HB()).base(e.base())},wo.apply(e,arguments)}function GB(){var e=C2(d0());return e.copy=function(){return $l(e,GB()).constant(e.constant())},wo.apply(e,arguments)}function L2(){var e=k2(d0());return e.copy=function(){return $l(e,L2()).exponent(e.exponent())},wo.apply(e,arguments)}function x2e(){return L2.apply(null,arguments).exponent(.5)}const KM=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:km,scaleDiverging:KB,scaleDivergingLog:HB,scaleDivergingPow:L2,scaleDivergingSqrt:x2e,scaleDivergingSymlog:GB,scaleIdentity:SB,scaleImplicit:cN,scaleLinear:Gy,scaleLog:kB,scaleOrdinal:y2,scalePoint:Mf,scalePow:E2,scaleQuantile:OB,scaleQuantize:AB,scaleRadial:PB,scaleSequential:zB,scaleSequentialLog:BB,scaleSequentialPow:I2,scaleSequentialQuantile:WB,scaleSequentialSqrt:g2e,scaleSequentialSymlog:UB,scaleSqrt:XCe,scaleSymlog:EB,scaleThreshold:TB,scaleTime:m2e,scaleUtc:p2e,tickFormat:NB},Symbol.toStringTag,{value:"Module"}));var y2e=gh;function v2e(e,t,n){for(var r=-1,s=e.length;++r<s;){var i=e[r],o=t(i);if(o!=null&&(l===void 0?o===o&&!y2e(o):n(o,l)))var l=o,c=i}return c}var VB=v2e;function b2e(e,t){return e>t}var w2e=b2e,_2e=VB,j2e=w2e,N2e=jh;function S2e(e){return e&&e.length?_2e(e,N2e,j2e):void 0}var C2e=S2e;const h0=dn(C2e);function k2e(e,t){return e<t}var E2e=k2e,P2e=VB,O2e=E2e,A2e=jh;function T2e(e){return e&&e.length?P2e(e,A2e,O2e):void 0}var M2e=T2e;const f0=dn(M2e);var D2e=Jk,$2e=Ml,R2e=nB,I2e=ka;function L2e(e,t){var n=I2e(e)?D2e:R2e;return n(e,$2e(t))}var F2e=L2e,q2e=eB,z2e=F2e;function B2e(e,t){return q2e(z2e(e,t),1)}var U2e=B2e;const W2e=dn(U2e);var K2e=f2;function H2e(e,t){return K2e(e,t)}var G2e=H2e;const m0=dn(G2e);var Sh=1e9,V2e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},q2,Tn=!0,ms="[DecimalError] ",_c=ms+"Invalid argument: ",F2=ms+"Exponent out of range: ",Ch=Math.floor,Ql=Math.pow,Y2e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ra,xr=1e7,En=7,YB=9007199254740991,Xy=Ch(YB/En),ht={};ht.absoluteValue=ht.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e};ht.comparedTo=ht.cmp=function(e){var t,n,r,s,i=this;if(e=new i.constructor(e),i.s!==e.s)return i.s||-e.s;if(i.e!==e.e)return i.e>e.e^i.s<0?1:-1;for(r=i.d.length,s=e.d.length,t=0,n=r<s?r:s;t<n;++t)if(i.d[t]!==e.d[t])return i.d[t]>e.d[t]^i.s<0?1:-1;return r===s?0:r>s^i.s<0?1:-1};ht.decimalPlaces=ht.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*En;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n};ht.dividedBy=ht.div=function(e){return Xi(this,new this.constructor(e))};ht.dividedToIntegerBy=ht.idiv=function(e){var t=this,n=t.constructor;return xn(Xi(t,new n(e),0,1),n.precision)};ht.equals=ht.eq=function(e){return!this.cmp(e)};ht.exponent=function(){return er(this)};ht.greaterThan=ht.gt=function(e){return this.cmp(e)>0};ht.greaterThanOrEqualTo=ht.gte=function(e){return this.cmp(e)>=0};ht.isInteger=ht.isint=function(){return this.e>this.d.length-2};ht.isNegative=ht.isneg=function(){return this.s<0};ht.isPositive=ht.ispos=function(){return this.s>0};ht.isZero=function(){return this.s===0};ht.lessThan=ht.lt=function(e){return this.cmp(e)<0};ht.lessThanOrEqualTo=ht.lte=function(e){return this.cmp(e)<1};ht.logarithm=ht.log=function(e){var t,n=this,r=n.constructor,s=r.precision,i=s+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(Ra))throw Error(ms+"NaN");if(n.s<1)throw Error(ms+(n.s?"NaN":"-Infinity"));return n.eq(Ra)?new r(0):(Tn=!1,t=Xi(Tm(n,i),Tm(e,i),i),Tn=!0,xn(t,s))};ht.minus=ht.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?JB(t,e):QB(t,(e.s=-e.s,e))};ht.modulo=ht.mod=function(e){var t,n=this,r=n.constructor,s=r.precision;if(e=new r(e),!e.s)throw Error(ms+"NaN");return n.s?(Tn=!1,t=Xi(n,e,0,1).times(e),Tn=!0,n.minus(t)):xn(new r(n),s)};ht.naturalExponential=ht.exp=function(){return XB(this)};ht.naturalLogarithm=ht.ln=function(){return Tm(this)};ht.negated=ht.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};ht.plus=ht.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?QB(t,e):JB(t,(e.s=-e.s,e))};ht.precision=ht.sd=function(e){var t,n,r,s=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(_c+e);if(t=er(s)+1,r=s.d.length-1,n=r*En+1,r=s.d[r],r){for(;r%10==0;r/=10)n--;for(r=s.d[0];r>=10;r/=10)n++}return e&&t>n?t:n};ht.squareRoot=ht.sqrt=function(){var e,t,n,r,s,i,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(ms+"NaN")}for(e=er(l),Tn=!1,s=Math.sqrt(+l),s==0||s==1/0?(t=pi(l.d),(t.length+e)%2==0&&(t+="0"),s=Math.sqrt(t),e=Ch((e+1)/2)-(e<0||e%2),s==1/0?t="5e"+e:(t=s.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),r=new c(t)):r=new c(s.toString()),n=c.precision,s=o=n+3;;)if(i=r,r=i.plus(Xi(l,i,o+2)).times(.5),pi(i.d).slice(0,o)===(t=pi(r.d)).slice(0,o)){if(t=t.slice(o-3,o+1),s==o&&t=="4999"){if(xn(i,n+1,0),i.times(i).eq(l)){r=i;break}}else if(t!="9999")break;o+=4}return Tn=!0,xn(r,n)};ht.times=ht.mul=function(e){var t,n,r,s,i,o,l,c,u,d=this,h=d.constructor,m=d.d,f=(e=new h(e)).d;if(!d.s||!e.s)return new h(0);for(e.s*=d.s,n=d.e+e.e,c=m.length,u=f.length,c<u&&(i=m,m=f,f=i,o=c,c=u,u=o),i=[],o=c+u,r=o;r--;)i.push(0);for(r=u;--r>=0;){for(t=0,s=c+r;s>r;)l=i[s]+f[r]*m[s-r-1]+t,i[s--]=l%xr|0,t=l/xr|0;i[s]=(i[s]+t)%xr|0}for(;!i[--o];)i.pop();return t?++n:i.shift(),e.d=i,e.e=n,Tn?xn(e,h.precision):e};ht.toDecimalPlaces=ht.todp=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(ji(e,0,Sh),t===void 0?t=r.rounding:ji(t,0,8),xn(n,e+er(n)+1,t))};ht.toExponential=function(e,t){var n,r=this,s=r.constructor;return e===void 0?n=qc(r,!0):(ji(e,0,Sh),t===void 0?t=s.rounding:ji(t,0,8),r=xn(new s(r),e+1,t),n=qc(r,!0,e+1)),n};ht.toFixed=function(e,t){var n,r,s=this,i=s.constructor;return e===void 0?qc(s):(ji(e,0,Sh),t===void 0?t=i.rounding:ji(t,0,8),r=xn(new i(s),e+er(s)+1,t),n=qc(r.abs(),!1,e+er(r)+1),s.isneg()&&!s.isZero()?"-"+n:n)};ht.toInteger=ht.toint=function(){var e=this,t=e.constructor;return xn(new t(e),er(e)+1,t.rounding)};ht.toNumber=function(){return+this};ht.toPower=ht.pow=function(e){var t,n,r,s,i,o,l=this,c=l.constructor,u=12,d=+(e=new c(e));if(!e.s)return new c(Ra);if(l=new c(l),!l.s){if(e.s<1)throw Error(ms+"Infinity");return l}if(l.eq(Ra))return l;if(r=c.precision,e.eq(Ra))return xn(l,r);if(t=e.e,n=e.d.length-1,o=t>=n,i=l.s,o){if((n=d<0?-d:d)<=YB){for(s=new c(Ra),t=Math.ceil(r/En+4),Tn=!1;n%2&&(s=s.times(l),GM(s.d,t)),n=Ch(n/2),n!==0;)l=l.times(l),GM(l.d,t);return Tn=!0,e.s<0?new c(Ra).div(s):xn(s,r)}}else if(i<0)throw Error(ms+"NaN");return i=i<0&&e.d[Math.max(t,n)]&1?-1:1,l.s=1,Tn=!1,s=e.times(Tm(l,r+u)),Tn=!0,s=XB(s),s.s=i,s};ht.toPrecision=function(e,t){var n,r,s=this,i=s.constructor;return e===void 0?(n=er(s),r=qc(s,n<=i.toExpNeg||n>=i.toExpPos)):(ji(e,1,Sh),t===void 0?t=i.rounding:ji(t,0,8),s=xn(new i(s),e,t),n=er(s),r=qc(s,e<=n||n<=i.toExpNeg,e)),r};ht.toSignificantDigits=ht.tosd=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(ji(e,1,Sh),t===void 0?t=r.rounding:ji(t,0,8)),xn(new r(n),e,t)};ht.toString=ht.valueOf=ht.val=ht.toJSON=ht[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=er(e),n=e.constructor;return qc(e,t<=n.toExpNeg||t>=n.toExpPos)};function QB(e,t){var n,r,s,i,o,l,c,u,d=e.constructor,h=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),Tn?xn(t,h):t;if(c=e.d,u=t.d,o=e.e,s=t.e,c=c.slice(),i=o-s,i){for(i<0?(r=c,i=-i,l=u.length):(r=u,s=o,l=c.length),o=Math.ceil(h/En),l=o>l?o+1:l+1,i>l&&(i=l,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for(l=c.length,i=u.length,l-i<0&&(i=l,r=u,u=c,c=r),n=0;i;)n=(c[--i]=c[i]+u[i]+n)/xr|0,c[i]%=xr;for(n&&(c.unshift(n),++s),l=c.length;c[--l]==0;)c.pop();return t.d=c,t.e=s,Tn?xn(t,h):t}function ji(e,t,n){if(e!==~~e||e<t||e>n)throw Error(_c+e)}function pi(e){var t,n,r,s=e.length-1,i="",o=e[0];if(s>0){for(i+=o,t=1;t<s;t++)r=e[t]+"",n=En-r.length,n&&(i+=Mo(n)),i+=r;o=e[t],r=o+"",n=En-r.length,n&&(i+=Mo(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}var Xi=function(){function e(r,s){var i,o=0,l=r.length;for(r=r.slice();l--;)i=r[l]*s+o,r[l]=i%xr|0,o=i/xr|0;return o&&r.unshift(o),r}function t(r,s,i,o){var l,c;if(i!=o)c=i>o?1:-1;else for(l=c=0;l<i;l++)if(r[l]!=s[l]){c=r[l]>s[l]?1:-1;break}return c}function n(r,s,i){for(var o=0;i--;)r[i]-=o,o=r[i]<s[i]?1:0,r[i]=o*xr+r[i]-s[i];for(;!r[0]&&r.length>1;)r.shift()}return function(r,s,i,o){var l,c,u,d,h,m,f,x,g,p,v,b,w,N,j,_,S,P,k=r.constructor,C=r.s==s.s?1:-1,T=r.d,O=s.d;if(!r.s)return new k(r);if(!s.s)throw Error(ms+"Division by zero");for(c=r.e-s.e,S=O.length,j=T.length,f=new k(C),x=f.d=[],u=0;O[u]==(T[u]||0);)++u;if(O[u]>(T[u]||0)&&--c,i==null?b=i=k.precision:o?b=i+(er(r)-er(s))+1:b=i,b<0)return new k(0);if(b=b/En+2|0,u=0,S==1)for(d=0,O=O[0],b++;(u<j||d)&&b--;u++)w=d*xr+(T[u]||0),x[u]=w/O|0,d=w%O|0;else{for(d=xr/(O[0]+1)|0,d>1&&(O=e(O,d),T=e(T,d),S=O.length,j=T.length),N=S,g=T.slice(0,S),p=g.length;p<S;)g[p++]=0;P=O.slice(),P.unshift(0),_=O[0],O[1]>=xr/2&&++_;do d=0,l=t(O,g,S,p),l<0?(v=g[0],S!=p&&(v=v*xr+(g[1]||0)),d=v/_|0,d>1?(d>=xr&&(d=xr-1),h=e(O,d),m=h.length,p=g.length,l=t(h,g,m,p),l==1&&(d--,n(h,S<m?P:O,m))):(d==0&&(l=d=1),h=O.slice()),m=h.length,m<p&&h.unshift(0),n(g,h,p),l==-1&&(p=g.length,l=t(O,g,S,p),l<1&&(d++,n(g,S<p?P:O,p))),p=g.length):l===0&&(d++,g=[0]),x[u++]=d,l&&g[0]?g[p++]=T[N]||0:(g=[T[N]],p=1);while((N++<j||g[0]!==void 0)&&b--)}return x[0]||x.shift(),f.e=c,xn(f,o?i+er(f)+1:i)}}();function XB(e,t){var n,r,s,i,o,l,c=0,u=0,d=e.constructor,h=d.precision;if(er(e)>16)throw Error(F2+er(e));if(!e.s)return new d(Ra);for(t==null?(Tn=!1,l=h):l=t,o=new d(.03125);e.abs().gte(.1);)e=e.times(o),u+=5;for(r=Math.log(Ql(2,u))/Math.LN10*2+5|0,l+=r,n=s=i=new d(Ra),d.precision=l;;){if(s=xn(s.times(e),l),n=n.times(++c),o=i.plus(Xi(s,n,l)),pi(o.d).slice(0,l)===pi(i.d).slice(0,l)){for(;u--;)i=xn(i.times(i),l);return d.precision=h,t==null?(Tn=!0,xn(i,h)):i}i=o}}function er(e){for(var t=e.e*En,n=e.d[0];n>=10;n/=10)t++;return t}function g_(e,t,n){if(t>e.LN10.sd())throw Tn=!0,n&&(e.precision=n),Error(ms+"LN10 precision limit exceeded");return xn(new e(e.LN10),t)}function Mo(e){for(var t="";e--;)t+="0";return t}function Tm(e,t){var n,r,s,i,o,l,c,u,d,h=1,m=10,f=e,x=f.d,g=f.constructor,p=g.precision;if(f.s<1)throw Error(ms+(f.s?"NaN":"-Infinity"));if(f.eq(Ra))return new g(0);if(t==null?(Tn=!1,u=p):u=t,f.eq(10))return t==null&&(Tn=!0),g_(g,u);if(u+=m,g.precision=u,n=pi(x),r=n.charAt(0),i=er(f),Math.abs(i)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)f=f.times(e),n=pi(f.d),r=n.charAt(0),h++;i=er(f),r>1?(f=new g("0."+n),i++):f=new g(r+"."+n.slice(1))}else return c=g_(g,u+2,p).times(i+""),f=Tm(new g(r+"."+n.slice(1)),u-m).plus(c),g.precision=p,t==null?(Tn=!0,xn(f,p)):f;for(l=o=f=Xi(f.minus(Ra),f.plus(Ra),u),d=xn(f.times(f),u),s=3;;){if(o=xn(o.times(d),u),c=l.plus(Xi(o,new g(s),u)),pi(c.d).slice(0,u)===pi(l.d).slice(0,u))return l=l.times(2),i!==0&&(l=l.plus(g_(g,u+2,p).times(i+""))),l=Xi(l,new g(h),u),g.precision=p,t==null?(Tn=!0,xn(l,p)):l;l=c,s+=2}}function HM(e,t){var n,r,s;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(s=t.length;t.charCodeAt(s-1)===48;)--s;if(t=t.slice(r,s),t){if(s-=r,n=n-r-1,e.e=Ch(n/En),e.d=[],r=(n+1)%En,n<0&&(r+=En),r<s){for(r&&e.d.push(+t.slice(0,r)),s-=En;r<s;)e.d.push(+t.slice(r,r+=En));t=t.slice(r),r=En-t.length}else r-=s;for(;r--;)t+="0";if(e.d.push(+t),Tn&&(e.e>Xy||e.e<-Xy))throw Error(F2+n)}else e.s=0,e.e=0,e.d=[0];return e}function xn(e,t,n){var r,s,i,o,l,c,u,d,h=e.d;for(o=1,i=h[0];i>=10;i/=10)o++;if(r=t-o,r<0)r+=En,s=t,u=h[d=0];else{if(d=Math.ceil((r+1)/En),i=h.length,d>=i)return e;for(u=i=h[d],o=1;i>=10;i/=10)o++;r%=En,s=r-En+o}if(n!==void 0&&(i=Ql(10,o-s-1),l=u/i%10|0,c=t<0||h[d+1]!==void 0||u%i,c=n<4?(l||c)&&(n==0||n==(e.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(r>0?s>0?u/Ql(10,o-s):0:h[d-1])%10&1||n==(e.s<0?8:7))),t<1||!h[0])return c?(i=er(e),h.length=1,t=t-i-1,h[0]=Ql(10,(En-t%En)%En),e.e=Ch(-t/En)||0):(h.length=1,h[0]=e.e=e.s=0),e;if(r==0?(h.length=d,i=1,d--):(h.length=d+1,i=Ql(10,En-r),h[d]=s>0?(u/Ql(10,o-s)%Ql(10,s)|0)*i:0),c)for(;;)if(d==0){(h[0]+=i)==xr&&(h[0]=1,++e.e);break}else{if(h[d]+=i,h[d]!=xr)break;h[d--]=0,i=1}for(r=h.length;h[--r]===0;)h.pop();if(Tn&&(e.e>Xy||e.e<-Xy))throw Error(F2+er(e));return e}function JB(e,t){var n,r,s,i,o,l,c,u,d,h,m=e.constructor,f=m.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new m(e),Tn?xn(t,f):t;if(c=e.d,h=t.d,r=t.e,u=e.e,c=c.slice(),o=u-r,o){for(d=o<0,d?(n=c,o=-o,l=h.length):(n=h,r=u,l=c.length),s=Math.max(Math.ceil(f/En),l)+2,o>s&&(o=s,n.length=1),n.reverse(),s=o;s--;)n.push(0);n.reverse()}else{for(s=c.length,l=h.length,d=s<l,d&&(l=s),s=0;s<l;s++)if(c[s]!=h[s]){d=c[s]<h[s];break}o=0}for(d&&(n=c,c=h,h=n,t.s=-t.s),l=c.length,s=h.length-l;s>0;--s)c[l++]=0;for(s=h.length;s>o;){if(c[--s]<h[s]){for(i=s;i&&c[--i]===0;)c[i]=xr-1;--c[i],c[s]+=xr}c[s]-=h[s]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(t.d=c,t.e=r,Tn?xn(t,f):t):new m(0)}function qc(e,t,n){var r,s=er(e),i=pi(e.d),o=i.length;return t?(n&&(r=n-o)>0?i=i.charAt(0)+"."+i.slice(1)+Mo(r):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(s<0?"e":"e+")+s):s<0?(i="0."+Mo(-s-1)+i,n&&(r=n-o)>0&&(i+=Mo(r))):s>=o?(i+=Mo(s+1-o),n&&(r=n-s-1)>0&&(i=i+"."+Mo(r))):((r=s+1)<o&&(i=i.slice(0,r)+"."+i.slice(r)),n&&(r=n-o)>0&&(s+1===o&&(i+="."),i+=Mo(r))),e.s<0?"-"+i:i}function GM(e,t){if(e.length>t)return e.length=t,!0}function ZB(e){var t,n,r;function s(i){var o=this;if(!(o instanceof s))return new s(i);if(o.constructor=s,i instanceof s){o.s=i.s,o.e=i.e,o.d=(i=i.d)?i.slice():i;return}if(typeof i=="number"){if(i*0!==0)throw Error(_c+i);if(i>0)o.s=1;else if(i<0)i=-i,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(i===~~i&&i<1e7){o.e=0,o.d=[i];return}return HM(o,i.toString())}else if(typeof i!="string")throw Error(_c+i);if(i.charCodeAt(0)===45?(i=i.slice(1),o.s=-1):o.s=1,Y2e.test(i))HM(o,i);else throw Error(_c+i)}if(s.prototype=ht,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.clone=ZB,s.config=s.set=Q2e,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 s.config(e),s}function Q2e(e){if(!e||typeof e!="object")throw Error(ms+"Object expected");var t,n,r,s=["precision",1,Sh,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(t=0;t<s.length;t+=3)if((r=e[n=s[t]])!==void 0)if(Ch(r)===r&&r>=s[t+1]&&r<=s[t+2])this[n]=r;else throw Error(_c+n+": "+r);if((r=e[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(_c+n+": "+r);return this}var q2=ZB(V2e);Ra=new q2(1);const mn=q2;function X2e(e){return tEe(e)||eEe(e)||Z2e(e)||J2e()}function J2e(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 860In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Z2e(e,t){if(e){if(typeof e=="string")return fN(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return fN(e,t)}}function eEe(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function tEe(e){if(Array.isArray(e))return fN(e)}function fN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var nEe=function(t){return t},eU={"@@functional/placeholder":!0},tU=function(t){return t===eU},VM=function(t){return function n(){return arguments.length===0||arguments.length===1&&tU(arguments.length<=0?void 0:arguments[0])?n:t.apply(void 0,arguments)}},rEe=function e(t,n){return t===1?n:VM(function(){for(var r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];var o=s.filter(function(l){return l!==eU}).length;return o>=t?n.apply(void 0,s):e(t-o,VM(function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var d=s.map(function(h){return tU(h)?c.shift():h});return n.apply(void 0,X2e(d).concat(c))}))})},p0=function(t){return rEe(t.length,t)},mN=function(t,n){for(var r=[],s=t;s<n;++s)r[s-t]=s;return r},aEe=p0(function(e,t){return Array.isArray(t)?t.map(e):Object.keys(t).map(function(n){return t[n]}).map(e)}),sEe=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];if(!n.length)return nEe;var s=n.reverse(),i=s[0],o=s.slice(1);return function(){return o.reduce(function(l,c){return c(l)},i.apply(void 0,arguments))}},pN=function(t){return Array.isArray(t)?t.reverse():t.split("").reverse.join("")},nU=function(t){var n=null,r=null;return function(){for(var s=arguments.length,i=new Array(s),o=0;o<s;o++)i[o]=arguments[o];return n&&i.every(function(l,c){return l===n[c]})||(n=i,r=t.apply(void 0,i)),r}};function iEe(e){var t;return e===0?t=1:t=Math.floor(new mn(e).abs().log(10).toNumber())+1,t}function oEe(e,t,n){for(var r=new mn(e),s=0,i=[];r.lt(t)&&s<1e5;)i.push(r.toNumber()),r=r.add(n),s++;return i}var lEe=p0(function(e,t,n){var r=+e,s=+t;return r+n*(s-r)}),cEe=p0(function(e,t,n){var r=t-+e;return r=r||1/0,(n-e)/r}),uEe=p0(function(e,t,n){var r=t-+e;return r=r||1/0,Math.max(0,Math.min(1,(n-e)/r))});const g0={rangeStep:oEe,getDigitCount:iEe,interpolateNumber:lEe,uninterpolateNumber:cEe,uninterpolateTruncation:uEe};function gN(e){return fEe(e)||hEe(e)||rU(e)||dEe()}function dEe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 861In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hEe(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function fEe(e){if(Array.isArray(e))return xN(e)}function Mm(e,t){return gEe(e)||pEe(e,t)||rU(e,t)||mEe()}function mEe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 862In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rU(e,t){if(e){if(typeof e=="string")return xN(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return xN(e,t)}}function xN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function pEe(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var n=[],r=!0,s=!1,i=void 0;try{for(var o=e[Symbol.iterator](),l;!(r=(l=o.next()).done)&&(n.push(l.value),!(t&&n.length===t));r=!0);}catch(c){s=!0,i=c}finally{try{!r&&o.return!=null&&o.return()}finally{if(s)throw i}}return n}}function gEe(e){if(Array.isArray(e))return e}function aU(e){var t=Mm(e,2),n=t[0],r=t[1],s=n,i=r;return n>r&&(s=r,i=n),[s,i]}function sU(e,t,n){if(e.lte(0))return new mn(0);var r=g0.getDigitCount(e.toNumber()),s=new mn(10).pow(r),i=e.div(s),o=r!==1?.05:.1,l=new mn(Math.ceil(i.div(o).toNumber())).add(n).mul(o),c=l.mul(s);return t?c:new mn(Math.ceil(c))}function xEe(e,t,n){var r=1,s=new mn(e);if(!s.isint()&&n){var i=Math.abs(e);i<1?(r=new mn(10).pow(g0.getDigitCount(e)-1),s=new mn(Math.floor(s.div(r).toNumber())).mul(r)):i>1&&(s=new mn(Math.floor(e)))}else e===0?s=new mn(Math.floor((t-1)/2)):n||(s=new mn(Math.floor(e)));var o=Math.floor((t-1)/2),l=sEe(aEe(function(c){return s.add(new mn(c-o).mul(r)).toNumber()}),mN);return l(0,t)}function iU(e,t,n,r){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((t-e)/(n-1)))return{step:new mn(0),tickMin:new mn(0),tickMax:new mn(0)};var i=sU(new mn(t).sub(e).div(n-1),r,s),o;e<=0&&t>=0?o=new mn(0):(o=new mn(e).add(t).div(2),o=o.sub(new mn(o).mod(i)));var l=Math.ceil(o.sub(e).div(i).toNumber()),c=Math.ceil(new mn(t).sub(o).div(i).toNumber()),u=l+c+1;return u>n?iU(e,t,n,r,s+1):(u<n&&(c=t>0?c+(n-u):c,l=t>0?l:l+(n-u)),{step:i,tickMin:o.sub(new mn(l).mul(i)),tickMax:o.add(new mn(c).mul(i))})}function yEe(e){var t=Mm(e,2),n=t[0],r=t[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(s,2),l=aU([n,r]),c=Mm(l,2),u=c[0],d=c[1];if(u===-1/0||d===1/0){var h=d===1/0?[u].concat(gN(mN(0,s-1).map(function(){return 1/0}))):[].concat(gN(mN(0,s-1).map(function(){return-1/0})),[d]);return n>r?pN(h):h}if(u===d)return xEe(u,s,i);var m=iU(u,d,o,i),f=m.step,x=m.tickMin,g=m.tickMax,p=g0.rangeStep(x,g.add(new mn(.1).mul(f)),f);return n>r?pN(p):p}function vEe(e,t){var n=Mm(e,2),r=n[0],s=n[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=aU([r,s]),l=Mm(o,2),c=l[0],u=l[1];if(c===-1/0||u===1/0)return[r,s];if(c===u)return[c];var d=Math.max(t,2),h=sU(new mn(u).sub(c).div(d-1),i,0),m=[].concat(gN(g0.rangeStep(new mn(c),new mn(u).sub(new mn(.99).mul(h)),h)),[u]);return r>s?pN(m):m}var bEe=nU(yEe),wEe=nU(vEe),_Ee="Invariant failed";function zc(e,t){throw new Error(_Ee)}var jEe=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function Ld(e){"@babel/helpers - typeof";return Ld=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ld(e)}function Jy(){return Jy=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Jy.apply(this,arguments)}function NEe(e,t){return EEe(e)||kEe(e,t)||CEe(e,t)||SEe()}function SEe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 863In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function CEe(e,t){if(e){if(typeof e=="string")return YM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return YM(e,t)}}function YM(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function kEe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function EEe(e){if(Array.isArray(e))return e}function PEe(e,t){if(e==null)return{};var n=OEe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function OEe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function AEe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function TEe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,cU(r.key),r)}}function MEe(e,t,n){return t&&TEe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function DEe(e,t,n){return t=Zy(t),$Ee(e,oU()?Reflect.construct(t,n||[],Zy(e).constructor):t.apply(e,n))}function $Ee(e,t){if(t&&(Ld(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return REe(e)}function REe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function oU(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(oU=function(){return!!e})()}function Zy(e){return Zy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Zy(e)}function IEe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&yN(e,t)}function yN(e,t){return yN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},yN(e,t)}function lU(e,t,n){return t=cU(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cU(e){var t=LEe(e,"string");return Ld(t)=="symbol"?t:t+""}function LEe(e,t){if(Ld(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Ld(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Bp=function(e){function t(){return AEe(this,t),DEe(this,t,arguments)}return IEe(t,e),MEe(t,[{key:"render",value:function(){var r=this.props,s=r.offset,i=r.layout,o=r.width,l=r.dataKey,c=r.data,u=r.dataPointFormatter,d=r.xAxis,h=r.yAxis,m=PEe(r,jEe),f=Yt(m,!1);this.props.direction==="x"&&d.type!=="number"&&zc();var x=c.map(function(g){var p=u(g,l),v=p.x,b=p.y,w=p.value,N=p.errorVal;if(!N)return null;var j=[],_,S;if(Array.isArray(N)){var P=NEe(N,2);_=P[0],S=P[1]}else _=S=N;if(i==="vertical"){var k=d.scale,C=b+s,T=C+o,O=C-o,L=k(w-_),E=k(w+S);j.push({x1:E,y1:T,x2:E,y2:O}),j.push({x1:L,y1:C,x2:E,y2:C}),j.push({x1:L,y1:T,x2:L,y2:O})}else if(i==="horizontal"){var R=h.scale,q=v+s,I=q-o,$=q+o,M=R(w-_),B=R(w+S);j.push({x1:I,y1:B,x2:$,y2:B}),j.push({x1:q,y1:M,x2:q,y2:B}),j.push({x1:I,y1:M,x2:$,y2:M})}return ae.createElement(Hn,Jy({className:"recharts-errorBar",key:"bar-".concat(j.map(function(W){return"".concat(W.x1,"-").concat(W.x2,"-").concat(W.y1,"-").concat(W.y2)}))},f),j.map(function(W){return ae.createElement("line",Jy({},W,{key:"line-".concat(W.x1,"-").concat(W.x2,"-").concat(W.y1,"-").concat(W.y2)}))}))});return ae.createElement(Hn,{className:"recharts-errorBars"},x)}}])}(ae.Component);lU(Bp,"defaultProps",{stroke:"black",strokeWidth:1.5,width:5,offset:0,layout:"horizontal"});lU(Bp,"displayName","ErrorBar");function Dm(e){"@babel/helpers - typeof";return Dm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dm(e)}function QM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Ul(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?QM(Object(n),!0).forEach(function(r){FEe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QM(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function FEe(e,t,n){return t=qEe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qEe(e){var t=zEe(e,"string");return Dm(t)=="symbol"?t:t+""}function zEe(e,t){if(Dm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Dm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var uU=function(t){var n=t.children,r=t.formattedGraphicalItems,s=t.legendWidth,i=t.legendContent,o=Ma(n,bc);if(!o)return null;var l=bc.defaultProps,c=l!==void 0?Ul(Ul({},l),o.props):{},u;return o.props&&o.props.payload?u=o.props&&o.props.payload:i==="children"?u=(r||[]).reduce(function(d,h){var m=h.item,f=h.props,x=f.sectors||f.data||[];return d.concat(x.map(function(g){return{type:o.props.iconType||m.props.legendType,value:g.name,color:g.fill,payload:g}}))},[]):u=(r||[]).map(function(d){var h=d.item,m=h.type.defaultProps,f=m!==void 0?Ul(Ul({},m),h.props):{},x=f.dataKey,g=f.name,p=f.legendType,v=f.hide;return{inactive:v,dataKey:x,type:c.iconType||p||"square",color:z2(h),value:g||x,payload:f}}),Ul(Ul(Ul({},c),bc.getWithHeight(o,s)),{},{payload:u,item:o})};function $m(e){"@babel/helpers - typeof";return $m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$m(e)}function XM(e){return KEe(e)||WEe(e)||UEe(e)||BEe()}function BEe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 864In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function UEe(e,t){if(e){if(typeof e=="string")return vN(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vN(e,t)}}function WEe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function KEe(e){if(Array.isArray(e))return vN(e)}function vN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function JM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function qn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?JM(Object(n),!0).forEach(function(r){sd(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):JM(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function sd(e,t,n){return t=HEe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function HEe(e){var t=GEe(e,"string");return $m(t)=="symbol"?t:t+""}function GEe(e,t){if($m(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if($m(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ua(e,t,n){return Ut(e)||Ut(t)?n:ur(t)?cs(e,t,n):Bt(t)?t(e):n}function Df(e,t,n,r){var s=W2e(e,function(l){return Ua(l,t)});if(n==="number"){var i=s.filter(function(l){return Xe(l)||parseFloat(l)});return i.length?[f0(i),h0(i)]:[1/0,-1/0]}var o=r?s.filter(function(l){return!Ut(l)}):s;return o.map(function(l){return ur(l)||l instanceof Date?l:""})}var VEe=function(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,o=-1,l=(n=r==null?void 0:r.length)!==null&&n!==void 0?n:0;if(l<=1)return 0;if(i&&i.axisType==="angleAxis"&&Math.abs(Math.abs(i.range[1]-i.range[0])-360)<=1e-6)for(var c=i.range,u=0;u<l;u++){var d=u>0?s[u-1].coordinate:s[l-1].coordinate,h=s[u].coordinate,m=u>=l-1?s[0].coordinate:s[u+1].coordinate,f=void 0;if(zs(h-d)!==zs(m-h)){var x=[];if(zs(m-h)===zs(c[1]-c[0])){f=m;var g=h+c[1]-c[0];x[0]=Math.min(g,(g+d)/2),x[1]=Math.max(g,(g+d)/2)}else{f=d;var p=m+c[1]-c[0];x[0]=Math.min(h,(p+h)/2),x[1]=Math.max(h,(p+h)/2)}var v=[Math.min(h,(f+h)/2),Math.max(h,(f+h)/2)];if(t>v[0]&&t<=v[1]||t>=x[0]&&t<=x[1]){o=s[u].index;break}}else{var b=Math.min(d,m),w=Math.max(d,m);if(t>(b+h)/2&&t<=(w+h)/2){o=s[u].index;break}}}else for(var N=0;N<l;N++)if(N===0&&t<=(r[N].coordinate+r[N+1].coordinate)/2||N>0&&N<l-1&&t>(r[N].coordinate+r[N-1].coordinate)/2&&t<=(r[N].coordinate+r[N+1].coordinate)/2||N===l-1&&t>(r[N].coordinate+r[N-1].coordinate)/2){o=r[N].index;break}return o},z2=function(t){var n,r=t,s=r.type.displayName,i=(n=t.type)!==null&&n!==void 0&&n.defaultProps?qn(qn({},t.type.defaultProps),t.props):t.props,o=i.stroke,l=i.fill,c;switch(s){case"Line":c=o;break;case"Area":case"Radar":c=o&&o!=="none"?o:l;break;default:c=l;break}return c},YEe=function(t){var n=t.barSize,r=t.totalSize,s=t.stackGroups,i=s===void 0?{}:s;if(!i)return{};for(var o={},l=Object.keys(i),c=0,u=l.length;c<u;c++)for(var d=i[l[c]].stackGroups,h=Object.keys(d),m=0,f=h.length;m<f;m++){var x=d[h[m]],g=x.items,p=x.cateAxisId,v=g.filter(function(S){return Vi(S.type).indexOf("Bar")>=0});if(v&&v.length){var b=v[0].type.defaultProps,w=b!==void 0?qn(qn({},b),v[0].props):v[0].props,N=w.barSize,j=w[p];o[j]||(o[j]=[]);var _=Ut(N)?n:N;o[j].push({item:v[0],stackList:v.slice(1),barSize:Ut(_)?void 0:Fc(_,r,0)})}}return o},QEe=function(t){var n=t.barGap,r=t.barCategoryGap,s=t.bandSize,i=t.sizeList,o=i===void 0?[]:i,l=t.maxBarSize,c=o.length;if(c<1)return null;var u=Fc(n,s,0,!0),d,h=[];if(o[0].barSize===+o[0].barSize){var m=!1,f=s/c,x=o.reduce(function(N,j){return N+j.barSize||0},0);x+=(c-1)*u,x>=s&&(x-=(c-1)*u,u=0),x>=s&&f>0&&(m=!0,f*=.9,x=c*f);var g=(s-x)/2>>0,p={offset:g-u,size:0};d=o.reduce(function(N,j){var _={item:j.item,position:{offset:p.offset+p.size+u,size:m?f:j.barSize}},S=[].concat(XM(N),[_]);return p=S[S.length-1].position,j.stackList&&j.stackList.length&&j.stackList.forEach(function(P){S.push({item:P,position:p})}),S},h)}else{var v=Fc(r,s,0,!0);s-2*v-(c-1)*u<=0&&(u=0);var b=(s-2*v-(c-1)*u)/c;b>1&&(b>>=0);var w=l===+l?Math.min(b,l):b;d=o.reduce(function(N,j,_){var S=[].concat(XM(N),[{item:j.item,position:{offset:v+(b+u)*_+(b-w)/2,size:w}}]);return j.stackList&&j.stackList.length&&j.stackList.forEach(function(P){S.push({item:P,position:S[S.length-1].position})}),S},h)}return d},XEe=function(t,n,r,s){var i=r.children,o=r.width,l=r.margin,c=o-(l.left||0)-(l.right||0),u=uU({children:i,legendWidth:c});if(u){var d=s||{},h=d.width,m=d.height,f=u.align,x=u.verticalAlign,g=u.layout;if((g==="vertical"||g==="horizontal"&&x==="middle")&&f!=="center"&&Xe(t[f]))return qn(qn({},t),{},sd({},f,t[f]+(h||0)));if((g==="horizontal"||g==="vertical"&&f==="center")&&x!=="middle"&&Xe(t[x]))return qn(qn({},t),{},sd({},x,t[x]+(m||0)))}return t},JEe=function(t,n,r){return Ut(n)?!0:t==="horizontal"?n==="yAxis":t==="vertical"||r==="x"?n==="xAxis":r==="y"?n==="yAxis":!0},dU=function(t,n,r,s,i){var o=n.props.children,l=us(o,Bp).filter(function(u){return JEe(s,i,u.props.direction)});if(l&&l.length){var c=l.map(function(u){return u.props.dataKey});return t.reduce(function(u,d){var h=Ua(d,r);if(Ut(h))return u;var m=Array.isArray(h)?[f0(h),h0(h)]:[h,h],f=c.reduce(function(x,g){var p=Ua(d,g,0),v=m[0]-Math.abs(Array.isArray(p)?p[0]:p),b=m[1]+Math.abs(Array.isArray(p)?p[1]:p);return[Math.min(v,x[0]),Math.max(b,x[1])]},[1/0,-1/0]);return[Math.min(f[0],u[0]),Math.max(f[1],u[1])]},[1/0,-1/0])}return null},ZEe=function(t,n,r,s,i){var o=n.map(function(l){return dU(t,l,r,i,s)}).filter(function(l){return!Ut(l)});return o&&o.length?o.reduce(function(l,c){return[Math.min(l[0],c[0]),Math.max(l[1],c[1])]},[1/0,-1/0]):null},hU=function(t,n,r,s,i){var o=n.map(function(c){var u=c.props.dataKey;return r==="number"&&u&&dU(t,c,u,s)||Df(t,u,r,i)});if(r==="number")return o.reduce(function(c,u){return[Math.min(c[0],u[0]),Math.max(c[1],u[1])]},[1/0,-1/0]);var l={};return o.reduce(function(c,u){for(var d=0,h=u.length;d<h;d++)l[u[d]]||(l[u[d]]=!0,c.push(u[d]));return c},[])},fU=function(t,n){return t==="horizontal"&&n==="xAxis"||t==="vertical"&&n==="yAxis"||t==="centric"&&n==="angleAxis"||t==="radial"&&n==="radiusAxis"},mU=function(t,n,r,s){if(s)return t.map(function(c){return c.coordinate});var i,o,l=t.map(function(c){return c.coordinate===n&&(i=!0),c.coordinate===r&&(o=!0),c.coordinate});return i||l.push(n),o||l.push(r),l},Wi=function(t,n,r){if(!t)return null;var s=t.scale,i=t.duplicateDomain,o=t.type,l=t.range,c=t.realScaleType==="scaleBand"?s.bandwidth()/2:2,u=(n||r)&&o==="category"&&s.bandwidth?s.bandwidth()/c:0;if(u=t.axisType==="angleAxis"&&(l==null?void 0:l.length)>=2?zs(l[0]-l[1])*2*u:u,n&&(t.ticks||t.niceTicks)){var d=(t.ticks||t.niceTicks).map(function(h){var m=i?i.indexOf(h):h;return{coordinate:s(m)+u,value:h,offset:u}});return d.filter(function(h){return!$p(h.coordinate)})}return t.isCategorical&&t.categoricalDomain?t.categoricalDomain.map(function(h,m){return{coordinate:s(h)+u,value:h,index:m,offset:u}}):s.ticks&&!r?s.ticks(t.tickCount).map(function(h){return{coordinate:s(h)+u,value:h,offset:u}}):s.domain().map(function(h,m){return{coordinate:s(h)+u,value:i?i[h]:h,index:m,offset:u}})},x_=new WeakMap,Kg=function(t,n){if(typeof n!="function")return t;x_.has(t)||x_.set(t,new WeakMap);var r=x_.get(t);if(r.has(n))return r.get(n);var s=function(){t.apply(void 0,arguments),n.apply(void 0,arguments)};return r.set(n,s),s},ePe=function(t,n,r){var s=t.scale,i=t.type,o=t.layout,l=t.axisType;if(s==="auto")return o==="radial"&&l==="radiusAxis"?{scale:km(),realScaleType:"band"}:o==="radial"&&l==="angleAxis"?{scale:Gy(),realScaleType:"linear"}:i==="category"&&n&&(n.indexOf("LineChart")>=0||n.indexOf("AreaChart")>=0||n.indexOf("ComposedChart")>=0&&!r)?{scale:Mf(),realScaleType:"point"}:i==="category"?{scale:km(),realScaleType:"band"}:{scale:Gy(),realScaleType:"linear"};if(Lc(s)){var c="scale".concat(Zb(s));return{scale:(KM[c]||Mf)(),realScaleType:KM[c]?c:"point"}}return Bt(s)?{scale:s}:{scale:Mf(),realScaleType:"point"}},ZM=1e-4,tPe=function(t){var n=t.domain();if(!(!n||n.length<=2)){var r=n.length,s=t.range(),i=Math.min(s[0],s[1])-ZM,o=Math.max(s[0],s[1])+ZM,l=t(n[0]),c=t(n[r-1]);(l<i||l>o||c<i||c>o)&&t.domain([n[0],n[r-1]])}},nPe=function(t,n){if(!t)return null;for(var r=0,s=t.length;r<s;r++)if(t[r].item===n)return t[r].position;return null},rPe=function(t,n){if(!n||n.length!==2||!Xe(n[0])||!Xe(n[1]))return t;var r=Math.min(n[0],n[1]),s=Math.max(n[0],n[1]),i=[t[0],t[1]];return(!Xe(t[0])||t[0]<r)&&(i[0]=r),(!Xe(t[1])||t[1]>s)&&(i[1]=s),i[0]>s&&(i[0]=s),i[1]<r&&(i[1]=r),i},aPe=function(t){var n=t.length;if(!(n<=0))for(var r=0,s=t[0].length;r<s;++r)for(var i=0,o=0,l=0;l<n;++l){var c=$p(t[l][r][1])?t[l][r][0]:t[l][r][1];c>=0?(t[l][r][0]=i,t[l][r][1]=i+c,i=t[l][r][1]):(t[l][r][0]=o,t[l][r][1]=o+c,o=t[l][r][1])}},sPe=function(t){var n=t.length;if(!(n<=0))for(var r=0,s=t[0].length;r<s;++r)for(var i=0,o=0;o<n;++o){var l=$p(t[o][r][1])?t[o][r][0]:t[o][r][1];l>=0?(t[o][r][0]=i,t[o][r][1]=i+l,i=t[o][r][1]):(t[o][r][0]=0,t[o][r][1]=0)}},iPe={sign:aPe,expand:bye,none:Od,silhouette:wye,wiggle:_ye,positive:sPe},oPe=function(t,n,r){var s=n.map(function(l){return l.props.dataKey}),i=iPe[r],o=vye().keys(s).value(function(l,c){return+Ua(l,c,0)}).order(W1).offset(i);return o(t)},lPe=function(t,n,r,s,i,o){if(!t)return null;var l=o?n.reverse():n,c={},u=l.reduce(function(h,m){var f,x=(f=m.type)!==null&&f!==void 0&&f.defaultProps?qn(qn({},m.type.defaultProps),m.props):m.props,g=x.stackId,p=x.hide;if(p)return h;var v=x[r],b=h[v]||{hasStack:!1,stackGroups:{}};if(ur(g)){var w=b.stackGroups[g]||{numericAxisId:r,cateAxisId:s,items:[]};w.items.push(m),b.hasStack=!0,b.stackGroups[g]=w}else b.stackGroups[Rp("_stackId_")]={numericAxisId:r,cateAxisId:s,items:[m]};return qn(qn({},h),{},sd({},v,b))},c),d={};return Object.keys(u).reduce(function(h,m){var f=u[m];if(f.hasStack){var x={};f.stackGroups=Object.keys(f.stackGroups).reduce(function(g,p){var v=f.stackGroups[p];return qn(qn({},g),{},sd({},p,{numericAxisId:r,cateAxisId:s,items:v.items,stackedData:oPe(t,v.items,i)}))},x)}return qn(qn({},h),{},sd({},m,f))},d)},cPe=function(t,n){var r=n.realScaleType,s=n.type,i=n.tickCount,o=n.originalDomain,l=n.allowDecimals,c=r||n.scale;if(c!=="auto"&&c!=="linear")return null;if(i&&s==="number"&&o&&(o[0]==="auto"||o[1]==="auto")){var u=t.domain();if(!u.length)return null;var d=bEe(u,i,l);return t.domain([f0(d),h0(d)]),{niceTicks:d}}if(i&&s==="number"){var h=t.domain(),m=wEe(h,i,l);return{niceTicks:m}}return null};function eD(e){var t=e.axis,n=e.ticks,r=e.bandSize,s=e.entry,i=e.index,o=e.dataKey;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!Ut(s[t.dataKey])){var l=Ny(n,"value",s[t.dataKey]);if(l)return l.coordinate+r/2}return n[i]?n[i].coordinate+r/2:null}var c=Ua(s,Ut(o)?t.dataKey:o);return Ut(c)?null:t.scale(c)}var tD=function(t){var n=t.axis,r=t.ticks,s=t.offset,i=t.bandSize,o=t.entry,l=t.index;if(n.type==="category")return r[l]?r[l].coordinate+s:null;var c=Ua(o,n.dataKey,n.domain[l]);return Ut(c)?null:n.scale(c)-i/2+s},uPe=function(t){var n=t.numericAxis,r=n.scale.domain();if(n.type==="number"){var s=Math.min(r[0],r[1]),i=Math.max(r[0],r[1]);return s<=0&&i>=0?0:i<0?i:s}return r[0]},dPe=function(t,n){var r,s=(r=t.type)!==null&&r!==void 0&&r.defaultProps?qn(qn({},t.type.defaultProps),t.props):t.props,i=s.stackId;if(ur(i)){var o=n[i];if(o){var l=o.items.indexOf(t);return l>=0?o.stackedData[l]:null}}return null},hPe=function(t){return t.reduce(function(n,r){return[f0(r.concat([n[0]]).filter(Xe)),h0(r.concat([n[1]]).filter(Xe))]},[1/0,-1/0])},pU=function(t,n,r){return Object.keys(t).reduce(function(s,i){var o=t[i],l=o.stackedData,c=l.reduce(function(u,d){var h=hPe(d.slice(n,r+1));return[Math.min(u[0],h[0]),Math.max(u[1],h[1])]},[1/0,-1/0]);return[Math.min(c[0],s[0]),Math.max(c[1],s[1])]},[1/0,-1/0]).map(function(s){return s===1/0||s===-1/0?0:s})},nD=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,rD=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,bN=function(t,n,r){if(Bt(t))return t(n,r);if(!Array.isArray(t))return n;var s=[];if(Xe(t[0]))s[0]=r?t[0]:Math.min(t[0],n[0]);else if(nD.test(t[0])){var i=+nD.exec(t[0])[1];s[0]=n[0]-i}else Bt(t[0])?s[0]=t[0](n[0]):s[0]=n[0];if(Xe(t[1]))s[1]=r?t[1]:Math.max(t[1],n[1]);else if(rD.test(t[1])){var o=+rD.exec(t[1])[1];s[1]=n[1]+o}else Bt(t[1])?s[1]=t[1](n[1]):s[1]=n[1];return s},ev=function(t,n,r){if(t&&t.scale&&t.scale.bandwidth){var s=t.scale.bandwidth();if(!r||s>0)return s}if(t&&n&&n.length>=2){for(var i=p2(n,function(h){return h.coordinate}),o=1/0,l=1,c=i.length;l<c;l++){var u=i[l],d=i[l-1];o=Math.min((u.coordinate||0)-(d.coordinate||0),o)}return o===1/0?0:o}return r?void 0:0},aD=function(t,n,r){return!t||!t.length||m0(t,cs(r,"type.defaultProps.domain"))?n:t},gU=function(t,n){var r=t.type.defaultProps?qn(qn({},t.type.defaultProps),t.props):t.props,s=r.dataKey,i=r.name,o=r.unit,l=r.formatter,c=r.tooltipType,u=r.chartType,d=r.hide;return qn(qn({},Yt(t,!1)),{},{dataKey:s,unit:o,formatter:l,name:i||s,color:z2(t),value:Ua(n,s),type:c,payload:n,chartType:u,hide:d})};function Rm(e){"@babel/helpers - typeof";return Rm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rm(e)}function sD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function iD(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?sD(Object(n),!0).forEach(function(r){fPe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function fPe(e,t,n){return t=mPe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mPe(e){var t=pPe(e,"string");return Rm(t)=="symbol"?t:t+""}function pPe(e,t){if(Rm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Rm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var tv=Math.PI/180,gPe=function(t){return t*180/Math.PI},Dr=function(t,n,r,s){return{x:t+Math.cos(-tv*s)*r,y:n+Math.sin(-tv*s)*r}},xPe=function(t,n){var r=t.x,s=t.y,i=n.x,o=n.y;return Math.sqrt(Math.pow(r-i,2)+Math.pow(s-o,2))},yPe=function(t,n){var r=t.x,s=t.y,i=n.cx,o=n.cy,l=xPe({x:r,y:s},{x:i,y:o});if(l<=0)return{radius:l};var c=(r-i)/l,u=Math.acos(c);return s>o&&(u=2*Math.PI-u),{radius:l,angle:gPe(u),angleInRadian:u}},vPe=function(t){var n=t.startAngle,r=t.endAngle,s=Math.floor(n/360),i=Math.floor(r/360),o=Math.min(s,i);return{startAngle:n-o*360,endAngle:r-o*360}},bPe=function(t,n){var r=n.startAngle,s=n.endAngle,i=Math.floor(r/360),o=Math.floor(s/360),l=Math.min(i,o);return t+l*360},oD=function(t,n){var r=t.x,s=t.y,i=yPe({x:r,y:s},n),o=i.radius,l=i.angle,c=n.innerRadius,u=n.outerRadius;if(o<c||o>u)return!1;if(o===0)return!0;var d=vPe(n),h=d.startAngle,m=d.endAngle,f=l,x;if(h<=m){for(;f>m;)f-=360;for(;f<h;)f+=360;x=f>=h&&f<=m}else{for(;f>h;)f-=360;for(;f<m;)f+=360;x=f>=m&&f<=h}return x?iD(iD({},n),{},{radius:o,angle:bPe(f,n)}):null};function Im(e){"@babel/helpers - typeof";return Im=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Im(e)}var wPe=["offset"];function _Pe(e){return CPe(e)||SPe(e)||NPe(e)||jPe()}function jPe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 865In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function NPe(e,t){if(e){if(typeof e=="string")return wN(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return wN(e,t)}}function SPe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function CPe(e){if(Array.isArray(e))return wN(e)}function wN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function kPe(e,t){if(e==null)return{};var n=EPe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function EPe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function lD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function ar(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?lD(Object(n),!0).forEach(function(r){PPe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function PPe(e,t,n){return t=OPe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function OPe(e){var t=APe(e,"string");return Im(t)=="symbol"?t:t+""}function APe(e,t){if(Im(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Im(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Lm(){return Lm=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lm.apply(this,arguments)}var TPe=function(t){var n=t.value,r=t.formatter,s=Ut(t.children)?n:t.children;return Bt(r)?r(s):s},MPe=function(t,n){var r=zs(n-t),s=Math.min(Math.abs(n-t),360);return r*s},DPe=function(t,n,r){var s=t.position,i=t.viewBox,o=t.offset,l=t.className,c=i,u=c.cx,d=c.cy,h=c.innerRadius,m=c.outerRadius,f=c.startAngle,x=c.endAngle,g=c.clockWise,p=(h+m)/2,v=MPe(f,x),b=v>=0?1:-1,w,N;s==="insideStart"?(w=f+b*o,N=g):s==="insideEnd"?(w=x-b*o,N=!g):s==="end"&&(w=x+b*o,N=g),N=v<=0?N:!N;var j=Dr(u,d,p,w),_=Dr(u,d,p,w+(N?1:-1)*359),S="M".concat(j.x,",").concat(j.y,` 866 A`).concat(p,",").concat(p,",0,1,").concat(N?0:1,`, 867 `).concat(_.x,",").concat(_.y),P=Ut(t.id)?Rp("recharts-radial-line-"):t.id;return ae.createElement("text",Lm({},r,{dominantBaseline:"central",className:Qt("recharts-radial-bar-label",l)}),ae.createElement("defs",null,ae.createElement("path",{id:P,d:S})),ae.createElement("textPath",{xlinkHref:"#".concat(P)},n))},$Pe=function(t){var n=t.viewBox,r=t.offset,s=t.position,i=n,o=i.cx,l=i.cy,c=i.innerRadius,u=i.outerRadius,d=i.startAngle,h=i.endAngle,m=(d+h)/2;if(s==="outside"){var f=Dr(o,l,u+r,m),x=f.x,g=f.y;return{x,y:g,textAnchor:x>=o?"start":"end",verticalAnchor:"middle"}}if(s==="center")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"middle"};if(s==="centerTop")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"start"};if(s==="centerBottom")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"end"};var p=(c+u)/2,v=Dr(o,l,p,m),b=v.x,w=v.y;return{x:b,y:w,textAnchor:"middle",verticalAnchor:"middle"}},RPe=function(t){var n=t.viewBox,r=t.parentViewBox,s=t.offset,i=t.position,o=n,l=o.x,c=o.y,u=o.width,d=o.height,h=d>=0?1:-1,m=h*s,f=h>0?"end":"start",x=h>0?"start":"end",g=u>=0?1:-1,p=g*s,v=g>0?"end":"start",b=g>0?"start":"end";if(i==="top"){var w={x:l+u/2,y:c-h*s,textAnchor:"middle",verticalAnchor:f};return ar(ar({},w),r?{height:Math.max(c-r.y,0),width:u}:{})}if(i==="bottom"){var N={x:l+u/2,y:c+d+m,textAnchor:"middle",verticalAnchor:x};return ar(ar({},N),r?{height:Math.max(r.y+r.height-(c+d),0),width:u}:{})}if(i==="left"){var j={x:l-p,y:c+d/2,textAnchor:v,verticalAnchor:"middle"};return ar(ar({},j),r?{width:Math.max(j.x-r.x,0),height:d}:{})}if(i==="right"){var _={x:l+u+p,y:c+d/2,textAnchor:b,verticalAnchor:"middle"};return ar(ar({},_),r?{width:Math.max(r.x+r.width-_.x,0),height:d}:{})}var S=r?{width:u,height:d}:{};return i==="insideLeft"?ar({x:l+p,y:c+d/2,textAnchor:b,verticalAnchor:"middle"},S):i==="insideRight"?ar({x:l+u-p,y:c+d/2,textAnchor:v,verticalAnchor:"middle"},S):i==="insideTop"?ar({x:l+u/2,y:c+m,textAnchor:"middle",verticalAnchor:x},S):i==="insideBottom"?ar({x:l+u/2,y:c+d-m,textAnchor:"middle",verticalAnchor:f},S):i==="insideTopLeft"?ar({x:l+p,y:c+m,textAnchor:b,verticalAnchor:x},S):i==="insideTopRight"?ar({x:l+u-p,y:c+m,textAnchor:v,verticalAnchor:x},S):i==="insideBottomLeft"?ar({x:l+p,y:c+d-m,textAnchor:b,verticalAnchor:f},S):i==="insideBottomRight"?ar({x:l+u-p,y:c+d-m,textAnchor:v,verticalAnchor:f},S):xh(i)&&(Xe(i.x)||ac(i.x))&&(Xe(i.y)||ac(i.y))?ar({x:l+Fc(i.x,u),y:c+Fc(i.y,d),textAnchor:"end",verticalAnchor:"end"},S):ar({x:l+u/2,y:c+d/2,textAnchor:"middle",verticalAnchor:"middle"},S)},IPe=function(t){return"cx"in t&&Xe(t.cx)};function Ur(e){var t=e.offset,n=t===void 0?5:t,r=kPe(e,wPe),s=ar({offset:n},r),i=s.viewBox,o=s.position,l=s.value,c=s.children,u=s.content,d=s.className,h=d===void 0?"":d,m=s.textBreakAll;if(!i||Ut(l)&&Ut(c)&&!y.isValidElement(u)&&!Bt(u))return null;if(y.isValidElement(u))return y.cloneElement(u,s);var f;if(Bt(u)){if(f=y.createElement(u,s),y.isValidElement(f))return f}else f=TPe(s);var x=IPe(i),g=Yt(s,!0);if(x&&(o==="insideStart"||o==="insideEnd"||o==="end"))return DPe(s,f,g);var p=x?$Pe(s):RPe(s);return ae.createElement(qy,Lm({className:Qt("recharts-label",h)},g,p,{breakAll:m}),f)}Ur.displayName="Label";var xU=function(t){var n=t.cx,r=t.cy,s=t.angle,i=t.startAngle,o=t.endAngle,l=t.r,c=t.radius,u=t.innerRadius,d=t.outerRadius,h=t.x,m=t.y,f=t.top,x=t.left,g=t.width,p=t.height,v=t.clockWise,b=t.labelViewBox;if(b)return b;if(Xe(g)&&Xe(p)){if(Xe(h)&&Xe(m))return{x:h,y:m,width:g,height:p};if(Xe(f)&&Xe(x))return{x:f,y:x,width:g,height:p}}return Xe(h)&&Xe(m)?{x:h,y:m,width:0,height:0}:Xe(n)&&Xe(r)?{cx:n,cy:r,startAngle:i||s||0,endAngle:o||s||0,innerRadius:u||0,outerRadius:d||c||l||0,clockWise:v}:t.viewBox?t.viewBox:{}},LPe=function(t,n){return t?t===!0?ae.createElement(Ur,{key:"label-implicit",viewBox:n}):ur(t)?ae.createElement(Ur,{key:"label-implicit",viewBox:n,value:t}):y.isValidElement(t)?t.type===Ur?y.cloneElement(t,{key:"label-implicit",viewBox:n}):ae.createElement(Ur,{key:"label-implicit",content:t,viewBox:n}):Bt(t)?ae.createElement(Ur,{key:"label-implicit",content:t,viewBox:n}):xh(t)?ae.createElement(Ur,Lm({viewBox:n},t,{key:"label-implicit"})):null:null},FPe=function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&r&&!t.label)return null;var s=t.children,i=xU(t),o=us(s,Ur).map(function(c,u){return y.cloneElement(c,{viewBox:n||i,key:"label-".concat(u)})});if(!r)return o;var l=LPe(t.label,n||i);return[l].concat(_Pe(o))};Ur.parseViewBox=xU;Ur.renderCallByParent=FPe;function qPe(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var zPe=qPe;const BPe=dn(zPe);function Fm(e){"@babel/helpers - typeof";return Fm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fm(e)}var UPe=["valueAccessor"],WPe=["data","dataKey","clockWise","id","textBreakAll"];function KPe(e){return YPe(e)||VPe(e)||GPe(e)||HPe()}function HPe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 868In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function GPe(e,t){if(e){if(typeof e=="string")return _N(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _N(e,t)}}function VPe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function YPe(e){if(Array.isArray(e))return _N(e)}function _N(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function nv(){return nv=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nv.apply(this,arguments)}function cD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function uD(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?cD(Object(n),!0).forEach(function(r){QPe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function QPe(e,t,n){return t=XPe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function XPe(e){var t=JPe(e,"string");return Fm(t)=="symbol"?t:t+""}function JPe(e,t){if(Fm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Fm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function dD(e,t){if(e==null)return{};var n=ZPe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function ZPe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var eOe=function(t){return Array.isArray(t.value)?BPe(t.value):t.value};function dl(e){var t=e.valueAccessor,n=t===void 0?eOe:t,r=dD(e,UPe),s=r.data,i=r.dataKey,o=r.clockWise,l=r.id,c=r.textBreakAll,u=dD(r,WPe);return!s||!s.length?null:ae.createElement(Hn,{className:"recharts-label-list"},s.map(function(d,h){var m=Ut(i)?n(d,h):Ua(d&&d.payload,i),f=Ut(l)?{}:{id:"".concat(l,"-").concat(h)};return ae.createElement(Ur,nv({},Yt(d,!0),u,f,{parentViewBox:d.parentViewBox,value:m,textBreakAll:c,viewBox:Ur.parseViewBox(Ut(o)?d:uD(uD({},d),{},{clockWise:o})),key:"label-".concat(h),index:h}))}))}dl.displayName="LabelList";function tOe(e,t){return e?e===!0?ae.createElement(dl,{key:"labelList-implicit",data:t}):ae.isValidElement(e)||Bt(e)?ae.createElement(dl,{key:"labelList-implicit",data:t,content:e}):xh(e)?ae.createElement(dl,nv({data:t},e,{key:"labelList-implicit"})):null:null}function nOe(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e||!e.children&&n&&!e.label)return null;var r=e.children,s=us(r,dl).map(function(o,l){return y.cloneElement(o,{data:t,key:"labelList-".concat(l)})});if(!n)return s;var i=tOe(e.label,t);return[i].concat(KPe(s))}dl.renderCallByParent=nOe;function qm(e){"@babel/helpers - typeof";return qm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qm(e)}function jN(){return jN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},jN.apply(this,arguments)}function hD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function fD(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hD(Object(n),!0).forEach(function(r){rOe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function rOe(e,t,n){return t=aOe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function aOe(e){var t=sOe(e,"string");return qm(t)=="symbol"?t:t+""}function sOe(e,t){if(qm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(qm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var iOe=function(t,n){var r=zs(n-t),s=Math.min(Math.abs(n-t),359.999);return r*s},Hg=function(t){var n=t.cx,r=t.cy,s=t.radius,i=t.angle,o=t.sign,l=t.isExternal,c=t.cornerRadius,u=t.cornerIsExternal,d=c*(l?1:-1)+s,h=Math.asin(c/d)/tv,m=u?i:i+o*h,f=Dr(n,r,d,m),x=Dr(n,r,s,m),g=u?i-o*h:i,p=Dr(n,r,d*Math.cos(h*tv),g);return{center:f,circleTangency:x,lineTangency:p,theta:h}},yU=function(t){var n=t.cx,r=t.cy,s=t.innerRadius,i=t.outerRadius,o=t.startAngle,l=t.endAngle,c=iOe(o,l),u=o+c,d=Dr(n,r,i,o),h=Dr(n,r,i,u),m="M ".concat(d.x,",").concat(d.y,` 869 A `).concat(i,",").concat(i,`,0, 870 `).concat(+(Math.abs(c)>180),",").concat(+(o>u),`, 871 `).concat(h.x,",").concat(h.y,` 872 `);if(s>0){var f=Dr(n,r,s,o),x=Dr(n,r,s,u);m+="L ".concat(x.x,",").concat(x.y,` 873 A `).concat(s,",").concat(s,`,0, 874 `).concat(+(Math.abs(c)>180),",").concat(+(o<=u),`, 875 `).concat(f.x,",").concat(f.y," Z")}else m+="L ".concat(n,",").concat(r," Z");return m},oOe=function(t){var n=t.cx,r=t.cy,s=t.innerRadius,i=t.outerRadius,o=t.cornerRadius,l=t.forceCornerRadius,c=t.cornerIsExternal,u=t.startAngle,d=t.endAngle,h=zs(d-u),m=Hg({cx:n,cy:r,radius:i,angle:u,sign:h,cornerRadius:o,cornerIsExternal:c}),f=m.circleTangency,x=m.lineTangency,g=m.theta,p=Hg({cx:n,cy:r,radius:i,angle:d,sign:-h,cornerRadius:o,cornerIsExternal:c}),v=p.circleTangency,b=p.lineTangency,w=p.theta,N=c?Math.abs(u-d):Math.abs(u-d)-g-w;if(N<0)return l?"M ".concat(x.x,",").concat(x.y,` 876 a`).concat(o,",").concat(o,",0,0,1,").concat(o*2,`,0 877 a`).concat(o,",").concat(o,",0,0,1,").concat(-o*2,`,0 878 `):yU({cx:n,cy:r,innerRadius:s,outerRadius:i,startAngle:u,endAngle:d});var j="M ".concat(x.x,",").concat(x.y,` 879 A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(f.x,",").concat(f.y,` 880 A`).concat(i,",").concat(i,",0,").concat(+(N>180),",").concat(+(h<0),",").concat(v.x,",").concat(v.y,` 881 A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(b.x,",").concat(b.y,` 882 `);if(s>0){var _=Hg({cx:n,cy:r,radius:s,angle:u,sign:h,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),S=_.circleTangency,P=_.lineTangency,k=_.theta,C=Hg({cx:n,cy:r,radius:s,angle:d,sign:-h,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),T=C.circleTangency,O=C.lineTangency,L=C.theta,E=c?Math.abs(u-d):Math.abs(u-d)-k-L;if(E<0&&o===0)return"".concat(j,"L").concat(n,",").concat(r,"Z");j+="L".concat(O.x,",").concat(O.y,` 883 A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(T.x,",").concat(T.y,` 884 A`).concat(s,",").concat(s,",0,").concat(+(E>180),",").concat(+(h>0),",").concat(S.x,",").concat(S.y,` 885 A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(P.x,",").concat(P.y,"Z")}else j+="L".concat(n,",").concat(r,"Z");return j},lOe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},vU=function(t){var n=fD(fD({},lOe),t),r=n.cx,s=n.cy,i=n.innerRadius,o=n.outerRadius,l=n.cornerRadius,c=n.forceCornerRadius,u=n.cornerIsExternal,d=n.startAngle,h=n.endAngle,m=n.className;if(o<i||d===h)return null;var f=Qt("recharts-sector",m),x=o-i,g=Fc(l,x,0,!0),p;return g>0&&Math.abs(d-h)<360?p=oOe({cx:r,cy:s,innerRadius:i,outerRadius:o,cornerRadius:Math.min(g,x/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:d,endAngle:h}):p=yU({cx:r,cy:s,innerRadius:i,outerRadius:o,startAngle:d,endAngle:h}),ae.createElement("path",jN({},Yt(n,!0),{className:f,d:p,role:"img"}))};function zm(e){"@babel/helpers - typeof";return zm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zm(e)}function NN(){return NN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},NN.apply(this,arguments)}function mD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function pD(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};
885t%2?mD(Object(n),!0).forEach(function(r){cOe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function cOe(e,t,n){return t=uOe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function uOe(e){var t=dOe(e,"string");return zm(t)=="symbol"?t:t+""}function dOe(e,t){if(zm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(zm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var gD={curveBasisClosed:lye,curveBasisOpen:cye,curveBasis:oye,curveBumpX:Gxe,curveBumpY:Vxe,curveLinearClosed:uye,curveLinear:t0,curveMonotoneX:dye,curveMonotoneY:hye,curveNatural:fye,curveStep:mye,curveStepAfter:gye,curveStepBefore:pye},Gg=function(t){return t.x===+t.x&&t.y===+t.y},nf=function(t){return t.x},rf=function(t){return t.y},hOe=function(t,n){if(Bt(t))return t;var r="curve".concat(Zb(t));return(r==="curveMonotone"||r==="curveBump")&&n?gD["".concat(r).concat(n==="vertical"?"Y":"X")]:gD[r]||t0},fOe=function(t){var n=t.type,r=n===void 0?"linear":n,s=t.points,i=s===void 0?[]:s,o=t.baseLine,l=t.layout,c=t.connectNulls,u=c===void 0?!1:c,d=hOe(r,l),h=u?i.filter(function(g){return Gg(g)}):i,m;if(Array.isArray(o)){var f=u?o.filter(function(g){return Gg(g)}):o,x=h.map(function(g,p){return pD(pD({},g),{},{base:f[p]})});return l==="vertical"?m=Ig().y(rf).x1(nf).x0(function(g){return g.base.x}):m=Ig().x(nf).y1(rf).y0(function(g){return g.base.y}),m.defined(Gg).curve(d),m(x)}return l==="vertical"&&Xe(o)?m=Ig().y(rf).x1(nf).x0(o):Xe(o)?m=Ig().x(nf).y1(rf).y0(o):m=vz().x(nf).y(rf),m.defined(Gg).curve(d),m(h)},SN=function(t){var n=t.className,r=t.points,s=t.path,i=t.pathRef;if((!r||!r.length)&&!s)return null;var o=r&&r.length?fOe(t):s;return y.createElement("path",NN({},Yt(t,!1),Sy(t),{className:Qt("recharts-curve",n),d:o,ref:i}))},bU={exports:{}},mOe="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",pOe=mOe,gOe=pOe;function wU(){}function _U(){}_U.resetWarningCache=wU;var xOe=function(){function e(r,s,i,o,l,c){if(c!==gOe){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}e.isRequired=e;function t(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:_U,resetWarningCache:wU};return n.PropTypes=n,n};bU.exports=xOe();var yOe=bU.exports;const rn=dn(yOe);var vOe=Object.getOwnPropertyNames,bOe=Object.getOwnPropertySymbols,wOe=Object.prototype.hasOwnProperty;function xD(e,t){return function(r,s,i){return e(r,s,i)&&t(r,s,i)}}function Vg(e){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return e(n,r,s);var i=s.cache,o=i.get(n),l=i.get(r);if(o&&l)return o===r&&l===n;i.set(n,r),i.set(r,n);var c=e(n,r,s);return i.delete(n),i.delete(r),c}}function yD(e){return vOe(e).concat(bOe(e))}var _Oe=Object.hasOwn||function(e,t){return wOe.call(e,t)};function Jc(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var jOe="__v",NOe="__o",SOe="_owner",vD=Object.getOwnPropertyDescriptor,bD=Object.keys;function COe(e,t,n){var r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function kOe(e,t){return Jc(e.getTime(),t.getTime())}function EOe(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function POe(e,t){return e===t}function wD(e,t,n){var r=e.size;if(r!==t.size)return!1;if(!r)return!0;for(var s=new Array(r),i=e.entries(),o,l,c=0;(o=i.next())&&!o.done;){for(var u=t.entries(),d=!1,h=0;(l=u.next())&&!l.done;){if(s[h]){h++;continue}var m=o.value,f=l.value;if(n.equals(m[0],f[0],c,h,e,t,n)&&n.equals(m[1],f[1],m[0],f[0],e,t,n)){d=s[h]=!0;break}h++}if(!d)return!1;c++}return!0}var OOe=Jc;function AOe(e,t,n){var r=bD(e),s=r.length;if(bD(t).length!==s)return!1;for(;s-- >0;)if(!jU(e,t,n,r[s]))return!1;return!0}function af(e,t,n){var r=yD(e),s=r.length;if(yD(t).length!==s)return!1;for(var i,o,l;s-- >0;)if(i=r[s],!jU(e,t,n,i)||(o=vD(e,i),l=vD(t,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function TOe(e,t){return Jc(e.valueOf(),t.valueOf())}function MOe(e,t){return e.source===t.source&&e.flags===t.flags}function _D(e,t,n){var r=e.size;if(r!==t.size)return!1;if(!r)return!0;for(var s=new Array(r),i=e.values(),o,l;(o=i.next())&&!o.done;){for(var c=t.values(),u=!1,d=0;(l=c.next())&&!l.done;){if(!s[d]&&n.equals(o.value,l.value,o.value,l.value,e,t,n)){u=s[d]=!0;break}d++}if(!u)return!1}return!0}function DOe(e,t){var n=e.length;if(t.length!==n)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function $Oe(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function jU(e,t,n,r){return(r===SOe||r===NOe||r===jOe)&&(e.$$typeof||t.$$typeof)?!0:_Oe(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var ROe="[object Arguments]",IOe="[object Boolean]",LOe="[object Date]",FOe="[object Error]",qOe="[object Map]",zOe="[object Number]",BOe="[object Object]",UOe="[object RegExp]",WOe="[object Set]",KOe="[object String]",HOe="[object URL]",GOe=Array.isArray,jD=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,ND=Object.assign,VOe=Object.prototype.toString.call.bind(Object.prototype.toString);function YOe(e){var t=e.areArraysEqual,n=e.areDatesEqual,r=e.areErrorsEqual,s=e.areFunctionsEqual,i=e.areMapsEqual,o=e.areNumbersEqual,l=e.areObjectsEqual,c=e.arePrimitiveWrappersEqual,u=e.areRegExpsEqual,d=e.areSetsEqual,h=e.areTypedArraysEqual,m=e.areUrlsEqual;return function(x,g,p){if(x===g)return!0;
885if(x==null||g==null)return!1;var v=typeof x;if(v!==typeof g)return!1;if(v!=="object")return v==="number"?o(x,g,p):v==="function"?s(x,g,p):!1;var b=x.constructor;if(b!==g.constructor)return!1;if(b===Object)return l(x,g,p);if(GOe(x))return t(x,g,p);if(jD!=null&&jD(x))return h(x,g,p);if(b===Date)return n(x,g,p);if(b===RegExp)return u(x,g,p);if(b===Map)return i(x,g,p);if(b===Set)return d(x,g,p);var w=VOe(x);return w===LOe?n(x,g,p):w===UOe?u(x,g,p):w===qOe?i(x,g,p):w===WOe?d(x,g,p):w===BOe?typeof x.then!="function"&&typeof g.then!="function"&&l(x,g,p):w===HOe?m(x,g,p):w===FOe?r(x,g,p):w===ROe?l(x,g,p):w===IOe||w===zOe||w===KOe?c(x,g,p):!1}}function QOe(e){var t=e.circular,n=e.createCustomConfig,r=e.strict,s={areArraysEqual:r?af:COe,areDatesEqual:kOe,areErrorsEqual:EOe,areFunctionsEqual:POe,areMapsEqual:r?xD(wD,af):wD,areNumbersEqual:OOe,areObjectsEqual:r?af:AOe,arePrimitiveWrappersEqual:TOe,areRegExpsEqual:MOe,areSetsEqual:r?xD(_D,af):_D,areTypedArraysEqual:r?af:DOe,areUrlsEqual:$Oe};if(n&&(s=ND({},s,n(s))),t){var i=Vg(s.areArraysEqual),o=Vg(s.areMapsEqual),l=Vg(s.areObjectsEqual),c=Vg(s.areSetsEqual);s=ND({},s,{areArraysEqual:i,areMapsEqual:o,areObjectsEqual:l,areSetsEqual:c})}return s}function XOe(e){return function(t,n,r,s,i,o,l){return e(t,n,l)}}function JOe(e){var t=e.circular,n=e.comparator,r=e.createState,s=e.equals,i=e.strict;if(r)return function(c,u){var d=r(),h=d.cache,m=h===void 0?t?new WeakMap:void 0:h,f=d.meta;return n(c,u,{cache:m,equals:s,meta:f,strict:i})};if(t)return function(c,u){return n(c,u,{cache:new WeakMap,equals:s,meta:void 0,strict:i})};var o={cache:void 0,equals:s,meta:void 0,strict:i};return function(c,u){return n(c,u,o)}}var ZOe=Rl();Rl({strict:!0});Rl({circular:!0});Rl({circular:!0,strict:!0});Rl({createInternalComparator:function(){return Jc}});Rl({strict:!0,createInternalComparator:function(){return Jc}});Rl({circular:!0,createInternalComparator:function(){return Jc}});Rl({circular:!0,createInternalComparator:function(){return Jc},strict:!0});function Rl(e){e===void 0&&(e={});var t=e.circular,n=t===void 0?!1:t,r=e.createInternalComparator,s=e.createState,i=e.strict,o=i===void 0?!1:i,l=QOe(e),c=YOe(l),u=r?r(c):XOe(c);return JOe({circular:n,comparator:c,createState:s,equals:u,strict:o})}function eAe(e){typeof requestAnimationFrame<"u"&&requestAnimationFrame(e)}function SD(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=-1,r=function s(i){n<0&&(n=i),i-n>t?(e(i),n=-1):eAe(s)};requestAnimationFrame(r)}function CN(e){"@babel/helpers - typeof";return CN=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},CN(e)}function tAe(e){return sAe(e)||aAe(e)||rAe(e)||nAe()}function nAe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 886In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rAe(e,t){if(e){if(typeof e=="string")return CD(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return CD(e,t)}}function CD(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function aAe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function sAe(e){if(Array.isArray(e))return e}function iAe(){var e={},t=function(){return null},n=!1,r=function s(i){if(!n){if(Array.isArray(i)){if(!i.length)return;
vendor: 159,990 bytes, lines 886-908
886var o=i,l=tAe(o),c=l[0],u=l.slice(1);if(typeof c=="number"){SD(s.bind(null,u),c);return}s(c),SD(s.bind(null,u));return}CN(i)==="object"&&(e=i,t(e)),typeof i=="function"&&i()}};return{stop:function(){n=!0},start:function(i){n=!1,r(i)},subscribe:function(i){return t=i,function(){t=function(){return null}}}}}function Bm(e){"@babel/helpers - typeof";return Bm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bm(e)}function kD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function ED(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?kD(Object(n),!0).forEach(function(r){NU(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function NU(e,t,n){return t=oAe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oAe(e){var t=lAe(e,"string");return Bm(t)==="symbol"?t:String(t)}function lAe(e,t){if(Bm(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Bm(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var cAe=function(t,n){return[Object.keys(t),Object.keys(n)].reduce(function(r,s){return r.filter(function(i){return s.includes(i)})})},uAe=function(t){return t},dAe=function(t){return t.replace(/([A-Z])/g,function(n){return"-".concat(n.toLowerCase())})},$f=function(t,n){return Object.keys(n).reduce(function(r,s){return ED(ED({},r),{},NU({},s,t(s,n[s])))},{})},PD=function(t,n,r){return t.map(function(s){return"".concat(dAe(s)," ").concat(n,"ms ").concat(r)}).join(",")};function hAe(e,t){return pAe(e)||mAe(e,t)||SU(e,t)||fAe()}function fAe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 887In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mAe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function pAe(e){if(Array.isArray(e))return e}function gAe(e){return vAe(e)||yAe(e)||SU(e)||xAe()}function xAe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 888In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function SU(e,t){if(e){if(typeof e=="string")return kN(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kN(e,t)}}function yAe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function vAe(e){if(Array.isArray(e))return kN(e)}function kN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var rv=1e-4,CU=function(t,n){return[0,3*t,3*n-6*t,3*t-3*n+1]},kU=function(t,n){return t.map(function(r,s){return r*Math.pow(n,s)}).reduce(function(r,s){return r+s})},OD=function(t,n){return function(r){var s=CU(t,n);return kU(s,r)}},bAe=function(t,n){return function(r){var s=CU(t,n),i=[].concat(gAe(s.map(function(o,l){return o*l}).slice(1)),[0]);return kU(i,r)}},AD=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var s=n[0],i=n[1],o=n[2],l=n[3];if(n.length===1)switch(n[0]){case"linear":s=0,i=0,o=1,l=1;break;case"ease":s=.25,i=.1,o=.25,l=1;break;case"ease-in":s=.42,i=0,o=1,l=1;break;case"ease-out":s=.42,i=0,o=.58,l=1;break;case"ease-in-out":s=0,i=0,o=.58,l=1;break;default:{var c=n[0].split("(");if(c[0]==="cubic-bezier"&&c[1].split(")")[0].split(",").length===4){var u=c[1].split(")")[0].split(",").map(function(p){return parseFloat(p)}),d=hAe(u,4);s=d[0],i=d[1],o=d[2],l=d[3]}}}var h=OD(s,o),m=OD(i,l),f=bAe(s,o),x=function(v){return v>1?1:v<0?0:v},g=function(v){for(var b=v>1?1:v,w=b,N=0;N<8;++N){var j=h(w)-b,_=f(w);if(Math.abs(j-b)<rv||_<rv)return m(w);w=x(w-j/_)}return m(w)};return g.isStepper=!1,g},wAe=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.stiff,r=n===void 0?100:n,s=t.damping,i=s===void 0?8:s,o=t.dt,l=o===void 0?17:o,c=function(d,h,m){var f=-(d-h)*r,x=m*i,g=m+(f-x)*l/1e3,p=m*l/1e3+d;return Math.abs(p-h)<rv&&Math.abs(g)<rv?[h,0]:[p,g]};return c.isStepper=!0,c.dt=l,c},_Ae=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var s=n[0];if(typeof s=="string")switch(s){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return AD(s);case"spring":return wAe();default:if(s.split("(")[0]==="cubic-bezier")return AD(s)}return typeof s=="function"?s:null};function Um(e){"@babel/helpers - typeof";return Um=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Um(e)}function TD(e){return SAe(e)||NAe(e)||EU(e)||jAe()}function jAe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 889In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function NAe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function SAe(e){if(Array.isArray(e))return PN(e)}function MD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Pr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?MD(Object(n),!0).forEach(function(r){EN(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):MD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function EN(e,t,n){return t=CAe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function CAe(e){var t=kAe(e,"string");return Um(t)==="symbol"?t:String(t)}function kAe(e,t){if(Um(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Um(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function EAe(e,t){return AAe(e)||OAe(e,t)||EU(e,t)||PAe()}function PAe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 890In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function EU(e,t){if(e){if(typeof e=="string")return PN(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return PN(e,t)}}function PN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function OAe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function AAe(e){if(Array.isArray(e))return e}var av=function(t,n,r){return t+(n-t)*r},ON=function(t){var n=t.from,r=t.to;return n!==r},TAe=function e(t,n,r){var s=$f(function(i,o){if(ON(o)){var l=t(o.from,o.to,o.velocity),c=EAe(l,2),u=c[0],d=c[1];return Pr(Pr({},o),{},{from:u,velocity:d})}return o},n);return r<1?$f(function(i,o){return ON(o)?Pr(Pr({},o),{},{velocity:av(o.velocity,s[i].velocity,r),from:av(o.from,s[i].from,r)}):o},n):e(t,s,r-1)};const MAe=function(e,t,n,r,s){var i=cAe(e,t),o=i.reduce(function(p,v){return Pr(Pr({},p),{},EN({},v,[e[v],t[v]]))},{}),l=i.reduce(function(p,v){return Pr(Pr({},p),{},EN({},v,{from:e[v],velocity:0,to:t[v]}))},{}),c=-1,u,d,h=function(){return null},m=function(){return $f(function(v,b){return b.from},l)},f=function(){return!Object.values(l).filter(ON).length},x=function(v){u||(u=v);var b=v-u,w=b/n.dt;l=TAe(n,l,w),s(Pr(Pr(Pr({},e),t),m())),u=v,f()||(c=requestAnimationFrame(h))},g=function(v){d||(d=v);var b=(v-d)/r,w=$f(function(j,_){return av.apply(void 0,TD(_).concat([n(b)]))},o);if(s(Pr(Pr(Pr({},e),t),w)),b<1)c=requestAnimationFrame(h);else{var N=$f(function(j,_){return av.apply(void 0,TD(_).concat([n(1)]))},o);s(Pr(Pr(Pr({},e),t),N))}};return h=n.isStepper?x:g,function(){return requestAnimationFrame(h),function(){cancelAnimationFrame(c)}}};function Fd(e){"@babel/helpers - typeof";return Fd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fd(e)}var DAe=["children","begin","duration","attributeName","easing","isActive","steps","from","to","canBegin","onAnimationEnd","shouldReAnimate","onAnimationReStart"];function $Ae(e,t){if(e==null)return{};var n=RAe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function RAe(e,t){if(e==null)return{};var n={},r=Object.keys(e),s,i;for(i=0;i<r.length;i++)s=r[i],!(t.indexOf(s)>=0)&&(n[s]=e[s]);return n}function y_(e){return qAe(e)||FAe(e)||LAe(e)||IAe()}function IAe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 891In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function LAe(e,t){if(e){if(typeof e=="string")return AN(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return AN(e,t)}}function FAe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function qAe(e){if(Array.isArray(e))return AN(e)}function AN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function DD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Ns(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?DD(Object(n),!0).forEach(function(r){gf(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):DD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function gf(e,t,n){return t=PU(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function zAe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function BAe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,PU(r.key),r)}}function UAe(e,t,n){return t&&BAe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function PU(e){var t=WAe(e,"string");return Fd(t)==="symbol"?t:String(t)}function WAe(e,t){if(Fd(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Fd(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function KAe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&TN(e,t)}function TN(e,t){return TN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},TN(e,t)}function HAe(e){var t=GAe();return function(){var r=sv(e),s;if(t){var i=sv(this).constructor;s=Reflect.construct(r,arguments,i)}else s=r.apply(this,arguments);return MN(this,s)}}function MN(e,t){if(t&&(Fd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return DN(e)}function DN(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function GAe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function sv(e){return sv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},sv(e)}var ho=function(e){KAe(n,e);var t=HAe(n);function n(r,s){var i;zAe(this,n),i=t.call(this,r,s);var o=i.props,l=o.isActive,c=o.attributeName,u=o.from,d=o.to,h=o.steps,m=o.children,f=o.duration;if(i.handleStyleChange=i.handleStyleChange.bind(DN(i)),i.changeStyle=i.changeStyle.bind(DN(i)),!l||f<=0)return i.state={style:{}},typeof m=="function"&&(i.state={style:d}),MN(i);if(h&&h.length)i.state={style:h[0].style};else if(u){if(typeof m=="function")return i.state={style:u},MN(i);i.state={style:c?gf({},c,u):u}}else i.state={style:{}};return i}return UAe(n,[{key:"componentDidMount",value:function(){var s=this.props,i=s.isActive,o=s.canBegin;this.mounted=!0,!(!i||!o)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(s){var i=this.props,o=i.isActive,l=i.canBegin,c=i.attributeName,u=i.shouldReAnimate,d=i.to,h=i.from,m=this.state.style;if(l){if(!o){var f={style:c?gf({},c,d):d};this.state&&m&&(c&&m[c]!==d||!c&&m!==d)&&this.setState(f);return}if(!(ZOe(s.to,d)&&s.canBegin&&s.isActive)){var x=!s.canBegin||!s.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var g=x||u?h:s.to;if(this.state&&m){var p={style:c?gf({},c,g):g};(c&&m[c]!==g||!c&&m!==g)&&this.setState(p)}this.runAnimation(Ns(Ns({},this.props),{},{from:g,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var s=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),s&&s()}},{key:"handleStyleChange",value:function(s){this.changeStyle(s)}},{key:"changeStyle",value:function(s){this.mounted&&this.setState({style:s})}},{key:"runJSAnimation",value:function(s){var i=this,o=s.from,l=s.to,c=s.duration,u=s.easing,d=s.begin,h=s.onAnimationEnd,m=s.onAnimationStart,f=MAe(o,l,_Ae(u),c,this.changeStyle),x=function(){i.stopJSAnimation=f()};this.manager.start([m,d,x,c,h])}},{key:"runStepAnimation",value:function(s){var i=this,o=s.steps,l=s.begin,c=s.onAnimationStart,u=o[0],d=u.style,h=u.duration,m=h===void 0?0:h,f=function(g,p,v){if(v===0)return g;var b=p.duration,w=p.easing,N=w===void 0?"ease":w,j=p.style,_=p.properties,S=p.onAnimationEnd,P=v>0?o[v-1]:p,k=_||Object.keys(j);if(typeof N=="function"||N==="spring")return[].concat(y_(g),[i.runJSAnimation.bind(i,{from:P.style,to:j,duration:b,easing:N}),b]);var C=PD(k,b,N),T=Ns(Ns(Ns({},P.style),j),{},{transition:C});return[].concat(y_(g),[T,b,S]).filter(uAe)};return this.manager.start([c].concat(y_(o.reduce(f,[d,Math.max(m,l)])),[s.onAnimationEnd]))}},{key:"runAnimation",value:function(s){this.manager||(this.manager=iAe());var i=s.begin,o=s.duration,l=s.attributeName,c=s.to,u=s.easing,d=s.onAnimationStart,h=s.onAnimationEnd,m=s.steps,f=s.children,x=this.manager;if(this.unSubscribe=x.subscribe(this.handleStyleChange),typeof u=="function"||typeof f=="function"||u==="spring"){this.runJSAnimation(s);return}if(m.length>1){this.runStepAnimation(s);return}var g=l?gf({},l,c):c,p=PD(Object.keys(g),o,u);x.start([d,i,Ns(Ns({},g),{},{transition:p}),o,h])}},{key:"render",value:function(){var s=this.props,i=s.children;s.begin;var o=s.duration;s.attributeName,s.easing;var l=s.isActive;s.steps,s.from,s.to,s.canBegin,s.onAnimationEnd,s.shouldReAnimate,s.onAnimationReStart;var c=$Ae(s,DAe),u=y.Children.count(i),d=this.state.style;if(typeof i=="function")return i(d);if(!l||u===0||o<=0)return i;var h=function(f){var x=f.props,g=x.style,p=g===void 0?{}:g,v=x.className,b=y.cloneElement(f,Ns(Ns({},c),{},{style:Ns(Ns({},p),d),className:v}));return b};return u===1?h(y.Children.only(i)):ae.createElement("div",null,y.Children.map(i,function(m){return h(m)}))}}]),n}(y.PureComponent);ho.displayName="Animate";ho.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};ho.propTypes={from:rn.oneOfType([rn.object,rn.string]),to:rn.oneOfType([rn.object,rn.string]),attributeName:rn.string,duration:rn.number,begin:rn.number,easing:rn.oneOfType([rn.string,rn.func]),steps:rn.arrayOf(rn.shape({duration:rn.number.isRequired,style:rn.object.isRequired,easing:rn.oneOfType([rn.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),rn.func]),properties:rn.arrayOf("string"),onAnimationEnd:rn.func})),children:rn.oneOfType([rn.node,rn.func]),isActive:rn.bool,canBegin:rn.bool,onAnimationEnd:rn.func,shouldReAnimate:rn.bool,onAnimationStart:rn.func,onAnimationReStart:rn.func};function Wm(e){"@babel/helpers - typeof";return Wm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Wm(e)}function iv(){return iv=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},iv.apply(this,arguments)}function VAe(e,t){return JAe(e)||XAe(e,t)||QAe(e,t)||YAe()}function YAe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 892In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function QAe(e,t){if(e){if(typeof e=="string")return $D(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $D(e,t)}}function $D(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function XAe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function JAe(e){if(Array.isArray(e))return e}function RD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function ID(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?RD(Object(n),!0).forEach(function(r){ZAe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):RD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function ZAe(e,t,n){return t=eTe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function eTe(e){var t=tTe(e,"string");return Wm(t)=="symbol"?t:t+""}function tTe(e,t){if(Wm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Wm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var LD=function(t,n,r,s,i){var o=Math.min(Math.abs(r)/2,Math.abs(s)/2),l=s>=0?1:-1,c=r>=0?1:-1,u=s>=0&&r>=0||s<0&&r<0?1:0,d;if(o>0&&i instanceof Array){for(var h=[0,0,0,0],m=0,f=4;m<f;m++)h[m]=i[m]>o?o:i[m];d="M".concat(t,",").concat(n+l*h[0]),h[0]>0&&(d+="A ".concat(h[0],",").concat(h[0],",0,0,").concat(u,",").concat(t+c*h[0],",").concat(n)),d+="L ".concat(t+r-c*h[1],",").concat(n),h[1]>0&&(d+="A ".concat(h[1],",").concat(h[1],",0,0,").concat(u,`, 893 `).concat(t+r,",").concat(n+l*h[1])),d+="L ".concat(t+r,",").concat(n+s-l*h[2]),h[2]>0&&(d+="A ".concat(h[2],",").concat(h[2],",0,0,").concat(u,`, 894 `).concat(t+r-c*h[2],",").concat(n+s)),d+="L ".concat(t+c*h[3],",").concat(n+s),h[3]>0&&(d+="A ".concat(h[3],",").concat(h[3],",0,0,").concat(u,`, 895 `).concat(t,",").concat(n+s-l*h[3])),d+="Z"}else if(o>0&&i===+i&&i>0){var x=Math.min(o,i);d="M ".concat(t,",").concat(n+l*x,` 896 A `).concat(x,",").concat(x,",0,0,").concat(u,",").concat(t+c*x,",").concat(n,` 897 L `).concat(t+r-c*x,",").concat(n,` 898 A `).concat(x,",").concat(x,",0,0,").concat(u,",").concat(t+r,",").concat(n+l*x,` 899 L `).concat(t+r,",").concat(n+s-l*x,` 900 A `).concat(x,",").concat(x,",0,0,").concat(u,",").concat(t+r-c*x,",").concat(n+s,` 901 L `).concat(t+c*x,",").concat(n+s,` 902 A `).concat(x,",").concat(x,",0,0,").concat(u,",").concat(t,",").concat(n+s-l*x," Z")}else d="M ".concat(t,",").concat(n," h ").concat(r," v ").concat(s," h ").concat(-r," Z");return d},nTe=function(t,n){if(!t||!n)return!1;var r=t.x,s=t.y,i=n.x,o=n.y,l=n.width,c=n.height;if(Math.abs(l)>0&&Math.abs(c)>0){var u=Math.min(i,i+l),d=Math.max(i,i+l),h=Math.min(o,o+c),m=Math.max(o,o+c);return r>=u&&r<=d&&s>=h&&s<=m}return!1},rTe={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},B2=function(t){var n=ID(ID({},rTe),t),r=y.useRef(),s=y.useState(-1),i=VAe(s,2),o=i[0],l=i[1];y.useEffect(function(){if(r.current&&r.current.getTotalLength)try{var N=r.current.getTotalLength();N&&l(N)}catch{}},[]);var c=n.x,u=n.y,d=n.width,h=n.height,m=n.radius,f=n.className,x=n.animationEasing,g=n.animationDuration,p=n.animationBegin,v=n.isAnimationActive,b=n.isUpdateAnimationActive;if(c!==+c||u!==+u||d!==+d||h!==+h||d===0||h===0)return null;var w=Qt("recharts-rectangle",f);return b?ae.createElement(ho,{canBegin:o>0,from:{width:d,height:h,x:c,y:u},to:{width:d,height:h,x:c,y:u},duration:g,animationEasing:x,isActive:b},function(N){var j=N.width,_=N.height,S=N.x,P=N.y;return ae.createElement(ho,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:p,duration:g,isActive:v,easing:x},ae.createElement("path",iv({},Yt(n,!0),{className:w,d:LD(S,P,j,_,m),ref:r})))}):ae.createElement("path",iv({},Yt(n,!0),{className:w,d:LD(c,u,d,h,m)}))};function $N(){return $N=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},$N.apply(this,arguments)}var U2=function(t){var n=t.cx,r=t.cy,s=t.r,i=t.className,o=Qt("recharts-dot",i);return n===+n&&r===+r&&s===+s?y.createElement("circle",$N({},Yt(t,!1),Sy(t),{className:o,cx:n,cy:r,r:s})):null};function Km(e){"@babel/helpers - typeof";return Km=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Km(e)}var aTe=["x","y","top","left","width","height","className"];function RN(){return RN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},RN.apply(this,arguments)}function FD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function sTe(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?FD(Object(n),!0).forEach(function(r){iTe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):FD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function iTe(e,t,n){return t=oTe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oTe(e){var t=lTe(e,"string");return Km(t)=="symbol"?t:t+""}function lTe(e,t){if(Km(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Km(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function cTe(e,t){if(e==null)return{};var n=uTe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function uTe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var dTe=function(t,n,r,s,i,o){return"M".concat(t,",").concat(i,"v").concat(s,"M").concat(o,",").concat(n,"h").concat(r)},hTe=function(t){var n=t.x,r=n===void 0?0:n,s=t.y,i=s===void 0?0:s,o=t.top,l=o===void 0?0:o,c=t.left,u=c===void 0?0:c,d=t.width,h=d===void 0?0:d,m=t.height,f=m===void 0?0:m,x=t.className,g=cTe(t,aTe),p=sTe({x:r,y:i,top:l,left:u,width:h,height:f},g);return!Xe(r)||!Xe(i)||!Xe(h)||!Xe(f)||!Xe(l)||!Xe(u)?null:ae.createElement("path",RN({},Yt(p,!0),{className:Qt("recharts-cross",x),d:dTe(r,i,h,f,l,u)}))},fTe=Uz,mTe=fTe(Object.getPrototypeOf,Object),pTe=mTe,gTe=vo,xTe=pTe,yTe=bo,vTe="[object Object]",bTe=Function.prototype,wTe=Object.prototype,OU=bTe.toString,_Te=wTe.hasOwnProperty,jTe=OU.call(Object);function NTe(e){if(!yTe(e)||gTe(e)!=vTe)return!1;var t=xTe(e);if(t===null)return!0;var n=_Te.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&OU.call(n)==jTe}var STe=NTe;const CTe=dn(STe);var kTe=vo,ETe=bo,PTe="[object Boolean]";function OTe(e){return e===!0||e===!1||ETe(e)&&kTe(e)==PTe}var ATe=OTe;const TTe=dn(ATe);function Hm(e){"@babel/helpers - typeof";return Hm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hm(e)}function ov(){return ov=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ov.apply(this,arguments)}function MTe(e,t){return ITe(e)||RTe(e,t)||$Te(e,t)||DTe()}function DTe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 903In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $Te(e,t){if(e){if(typeof e=="string")return qD(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qD(e,t)}}function qD(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function RTe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function ITe(e){if(Array.isArray(e))return e}function zD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function BD(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?zD(Object(n),!0).forEach(function(r){LTe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function LTe(e,t,n){return t=FTe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function FTe(e){var t=qTe(e,"string");return Hm(t)=="symbol"?t:t+""}function qTe(e,t){if(Hm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Hm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var UD=function(t,n,r,s,i){var o=r-s,l;return l="M ".concat(t,",").concat(n),l+="L ".concat(t+r,",").concat(n),l+="L ".concat(t+r-o/2,",").concat(n+i),l+="L ".concat(t+r-o/2-s,",").concat(n+i),l+="L ".concat(t,",").concat(n," Z"),l},zTe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},BTe=function(t){var n=BD(BD({},zTe),t),r=y.useRef(),s=y.useState(-1),i=MTe(s,2),o=i[0],l=i[1];y.useEffect(function(){if(r.current&&r.current.getTotalLength)try{var w=r.current.getTotalLength();w&&l(w)}catch{}},[]);var c=n.x,u=n.y,d=n.upperWidth,h=n.lowerWidth,m=n.height,f=n.className,x=n.animationEasing,g=n.animationDuration,p=n.animationBegin,v=n.isUpdateAnimationActive;if(c!==+c||u!==+u||d!==+d||h!==+h||m!==+m||d===0&&h===0||m===0)return null;var b=Qt("recharts-trapezoid",f);return v?ae.createElement(ho,{canBegin:o>0,from:{upperWidth:0,lowerWidth:0,height:m,x:c,y:u},to:{upperWidth:d,lowerWidth:h,height:m,x:c,y:u},duration:g,animationEasing:x,isActive:v},function(w){var N=w.upperWidth,j=w.lowerWidth,_=w.height,S=w.x,P=w.y;return ae.createElement(ho,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:p,duration:g,easing:x},ae.createElement("path",ov({},Yt(n,!0),{className:b,d:UD(S,P,N,j,_),ref:r})))}):ae.createElement("g",null,ae.createElement("path",ov({},Yt(n,!0),{className:b,d:UD(c,u,d,h,m)})))},UTe=["option","shapeType","propTransformer","activeClassName","isActive"];function Gm(e){"@babel/helpers - typeof";return Gm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gm(e)}function WTe(e,t){if(e==null)return{};var n=KTe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function KTe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function WD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function lv(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?WD(Object(n),!0).forEach(function(r){HTe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function HTe(e,t,n){return t=GTe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function GTe(e){var t=VTe(e,"string");return Gm(t)=="symbol"?t:t+""}function VTe(e,t){if(Gm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Gm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function YTe(e,t){return lv(lv({},t),e)}function QTe(e,t){return e==="symbols"}function KD(e){var t=e.shapeType,n=e.elementProps;switch(t){case"rectangle":return ae.createElement(B2,n);case"trapezoid":return ae.createElement(BTe,n);case"sector":return ae.createElement(vU,n);case"symbols":if(QTe(t))return ae.createElement(o2,n);break;default:return null}}function XTe(e){return y.isValidElement(e)?e.props:e}function JTe(e){var t=e.option,n=e.shapeType,r=e.propTransformer,s=r===void 0?YTe:r,i=e.activeClassName,o=i===void 0?"recharts-active-shape":i,l=e.isActive,c=WTe(e,UTe),u;if(y.isValidElement(t))u=y.cloneElement(t,lv(lv({},c),XTe(t)));else if(Bt(t))u=t(c);else if(CTe(t)&&!TTe(t)){var d=s(t,c);u=ae.createElement(KD,{shapeType:n,elementProps:d})}else{var h=c;u=ae.createElement(KD,{shapeType:n,elementProps:h})}return l?ae.createElement(Hn,{className:o},u):u}function x0(e,t){return t!=null&&"trapezoids"in e.props}function y0(e,t){return t!=null&&"sectors"in e.props}function Vm(e,t){return t!=null&&"points"in e.props}function ZTe(e,t){var n,r,s=e.x===(t==null||(n=t.labelViewBox)===null||n===void 0?void 0:n.x)||e.x===t.x,i=e.y===(t==null||(r=t.labelViewBox)===null||r===void 0?void 0:r.y)||e.y===t.y;return s&&i}function eMe(e,t){var n=e.endAngle===t.endAngle,r=e.startAngle===t.startAngle;return n&&r}function tMe(e,t){var n=e.x===t.x,r=e.y===t.y,s=e.z===t.z;return n&&r&&s}function nMe(e,t){var n;return x0(e,t)?n=ZTe:y0(e,t)?n=eMe:Vm(e,t)&&(n=tMe),n}function rMe(e,t){var n;return x0(e,t)?n="trapezoids":y0(e,t)?n="sectors":Vm(e,t)&&(n="points"),n}function aMe(e,t){if(x0(e,t)){var n;return(n=t.tooltipPayload)===null||n===void 0||(n=n[0])===null||n===void 0||(n=n.payload)===null||n===void 0?void 0:n.payload}if(y0(e,t)){var r;return(r=t.tooltipPayload)===null||r===void 0||(r=r[0])===null||r===void 0||(r=r.payload)===null||r===void 0?void 0:r.payload}return Vm(e,t)?t.payload:{}}function sMe(e){var t=e.activeTooltipItem,n=e.graphicalItem,r=e.itemData,s=rMe(n,t),i=aMe(n,t),o=r.filter(function(c,u){var d=m0(i,c),h=n.props[s].filter(function(x){var g=nMe(n,t);return g(x,t)}),m=n.props[s].indexOf(h[h.length-1]),f=u===m;return d&&f}),l=r.indexOf(o[o.length-1]);return l}var iMe=Math.ceil,oMe=Math.max;function lMe(e,t,n,r){for(var s=-1,i=oMe(iMe((t-e)/(n||1)),0),o=Array(i);i--;)o[r?i:++s]=e,e+=n;return o}var cMe=lMe,uMe=lB,HD=1/0,dMe=17976931348623157e292;function hMe(e){if(!e)return e===0?e:0;if(e=uMe(e),e===HD||e===-HD){var t=e<0?-1:1;return t*dMe}return e===e?e:0}var AU=hMe,fMe=cMe,mMe=s0,v_=AU;function pMe(e){return function(t,n,r){return r&&typeof r!="number"&&mMe(t,n,r)&&(n=r=void 0),t=v_(t),n===void 0?(n=t,t=0):n=v_(n),r=r===void 0?t<n?1:-1:v_(r),fMe(t,n,r,e)}}var gMe=pMe,xMe=gMe,yMe=xMe(),vMe=yMe;const cv=dn(vMe);function Ym(e){"@babel/helpers - typeof";return Ym=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ym(e)}function GD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function VD(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?GD(Object(n),!0).forEach(function(r){TU(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):GD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function TU(e,t,n){return t=bMe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bMe(e){var t=wMe(e,"string");return Ym(t)=="symbol"?t:t+""}function wMe(e,t){if(Ym(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Ym(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var _Me=["Webkit","Moz","O","ms"],jMe=function(t,n){var r=t.replace(/(\w)/,function(i){return i.toUpperCase()}),s=_Me.reduce(function(i,o){return VD(VD({},i),{},TU({},o+r,n))},{});return s[t]=n,s};function qd(e){"@babel/helpers - typeof";return qd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qd(e)}function uv(){return uv=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},uv.apply(this,arguments)}function YD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function b_(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?YD(Object(n),!0).forEach(function(r){Aa(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function NMe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function QD(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,DU(r.key),r)}}function SMe(e,t,n){return t&&QD(e.prototype,t),n&&QD(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function CMe(e,t,n){return t=dv(t),kMe(e,MU()?Reflect.construct(t,n||[],dv(e).constructor):t.apply(e,n))}function kMe(e,t){if(t&&(qd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return EMe(e)}function EMe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function MU(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(MU=function(){return!!e})()}function dv(e){return dv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},dv(e)}function PMe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&IN(e,t)}function IN(e,t){return IN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},IN(e,t)}function Aa(e,t,n){return t=DU(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function DU(e){var t=OMe(e,"string");return qd(t)=="symbol"?t:t+""}function OMe(e,t){if(qd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(qd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var AMe=function(t){var n=t.data,r=t.startIndex,s=t.endIndex,i=t.x,o=t.width,l=t.travellerWidth;if(!n||!n.length)return{};var c=n.length,u=Mf().domain(cv(0,c)).range([i,i+o-l]),d=u.domain().map(function(h){return u(h)});return{isTextActive:!1,isSlideMoving:!1,isTravellerMoving:!1,isTravellerFocused:!1,startX:u(r),endX:u(s),scale:u,scaleValues:d}},XD=function(t){return t.changedTouches&&!!t.changedTouches.length},zd=function(e){function t(n){var r;return NMe(this,t),r=CMe(this,t,[n]),Aa(r,"handleDrag",function(s){r.leaveTimer&&(clearTimeout(r.leaveTimer),r.leaveTimer=null),r.state.isTravellerMoving?r.handleTravellerMove(s):r.state.isSlideMoving&&r.handleSlideDrag(s)}),Aa(r,"handleTouchMove",function(s){s.changedTouches!=null&&s.changedTouches.length>0&&r.handleDrag(s.changedTouches[0])}),Aa(r,"handleDragEnd",function(){r.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var s=r.props,i=s.endIndex,o=s.onDragEnd,l=s.startIndex;o==null||o({endIndex:i,startIndex:l})}),r.detachDragEndListener()}),Aa(r,"handleLeaveWrapper",function(){(r.state.isTravellerMoving||r.state.isSlideMoving)&&(r.leaveTimer=window.setTimeout(r.handleDragEnd,r.props.leaveTimeOut))}),Aa(r,"handleEnterSlideOrTraveller",function(){r.setState({isTextActive:!0})}),Aa(r,"handleLeaveSlideOrTraveller",function(){r.setState({isTextActive:!1})}),Aa(r,"handleSlideDragStart",function(s){var i=XD(s)?s.changedTouches[0]:s;r.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:i.pageX}),r.attachDragEndListener()}),r.travellerDragStartHandlers={startX:r.handleTravellerDragStart.bind(r,"startX"),endX:r.handleTravellerDragStart.bind(r,"endX")},r.state={},r}return PMe(t,e),SMe(t,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(r){var s=r.startX,i=r.endX,o=this.state.scaleValues,l=this.props,c=l.gap,u=l.data,d=u.length-1,h=Math.min(s,i),m=Math.max(s,i),f=t.getIndexInRange(o,h),x=t.getIndexInRange(o,m);return{startIndex:f-f%c,endIndex:x===d?d:x-x%c}}},{key:"getTextOfTick",value:function(r){var s=this.props,i=s.data,o=s.tickFormatter,l=s.dataKey,c=Ua(i[r],l,r);return Bt(o)?o(c,r):c}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(r){var s=this.state,i=s.slideMoveStartX,o=s.startX,l=s.endX,c=this.props,u=c.x,d=c.width,h=c.travellerWidth,m=c.startIndex,f=c.endIndex,x=c.onChange,g=r.pageX-i;g>0?g=Math.min(g,u+d-h-l,u+d-h-o):g<0&&(g=Math.max(g,u-o,u-l));var p=this.getIndex({startX:o+g,endX:l+g});(p.startIndex!==m||p.endIndex!==f)&&x&&x(p),this.setState({startX:o+g,endX:l+g,slideMoveStartX:r.pageX})}},{key:"handleTravellerDragStart",value:function(r,s){var i=XD(s)?s.changedTouches[0]:s;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:r,brushMoveStartX:i.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(r){var s=this.state,i=s.brushMoveStartX,o=s.movingTravellerId,l=s.endX,c=s.startX,u=this.state[o],d=this.props,h=d.x,m=d.width,f=d.travellerWidth,x=d.onChange,g=d.gap,p=d.data,v={startX:this.state.startX,endX:this.state.endX},b=r.pageX-i;b>0?b=Math.min(b,h+m-f-u):b<0&&(b=Math.max(b,h-u)),v[o]=u+b;var w=this.getIndex(v),N=w.startIndex,j=w.endIndex,_=function(){var P=p.length-1;return o==="startX"&&(l>c?N%g===0:j%g===0)||l<c&&j===P||o==="endX"&&(l>c?j%g===0:N%g===0)||l>c&&j===P};this.setState(Aa(Aa({},o,u+b),"brushMoveStartX",r.pageX),function(){x&&_()&&x(w)})}},{key:"handleTravellerMoveKeyboard",value:function(r,s){var i=this,o=this.state,l=o.scaleValues,c=o.startX,u=o.endX,d=this.state[s],h=l.indexOf(d);if(h!==-1){var m=h+r;if(!(m===-1||m>=l.length)){var f=l[m];s==="startX"&&f>=u||s==="endX"&&f<=c||this.setState(Aa({},s,f),function(){i.props.onChange(i.getIndex({startX:i.state.startX,endX:i.state.endX}))})}}}},{key:"renderBackground",value:function(){var r=this.props,s=r.x,i=r.y,o=r.width,l=r.height,c=r.fill,u=r.stroke;return ae.createElement("rect",{stroke:u,fill:c,x:s,y:i,width:o,height:l})}},{key:"renderPanorama",value:function(){var r=this.props,s=r.x,i=r.y,o=r.width,l=r.height,c=r.data,u=r.children,d=r.padding,h=y.Children.only(u);return h?ae.cloneElement(h,{x:s,y:i,width:o,height:l,margin:d,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(r,s){var i,o,l=this,c=this.props,u=c.y,d=c.travellerWidth,h=c.height,m=c.traveller,f=c.ariaLabel,x=c.data,g=c.startIndex,p=c.endIndex,v=Math.max(r,this.props.x),b=b_(b_({},Yt(this.props,!1)),{},{x:v,y:u,width:d,height:h}),w=f||"Min value: ".concat((i=x[g])===null||i===void 0?void 0:i.name,", Max value: ").concat((o=x[p])===null||o===void 0?void 0:o.name);return ae.createElement(Hn,{tabIndex:0,role:"slider","aria-label":w,"aria-valuenow":r,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[s],onTouchStart:this.travellerDragStartHandlers[s],onKeyDown:function(j){["ArrowLeft","ArrowRight"].includes(j.key)&&(j.preventDefault(),j.stopPropagation(),l.handleTravellerMoveKeyboard(j.key==="ArrowRight"?1:-1,s))},onFocus:function(){l.setState({isTravellerFocused:!0})},onBlur:function(){l.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},t.renderTraveller(m,b))}},{key:"renderSlide",value:function(r,s){var i=this.props,o=i.y,l=i.height,c=i.stroke,u=i.travellerWidth,d=Math.min(r,s)+u,h=Math.max(Math.abs(s-r)-u,0);return ae.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:c,fillOpacity:.2,x:d,y:o,width:h,height:l})}},{key:"renderText",value:function(){var r=this.props,s=r.startIndex,i=r.endIndex,o=r.y,l=r.height,c=r.travellerWidth,u=r.stroke,d=this.state,h=d.startX,m=d.endX,f=5,x={pointerEvents:"none",fill:u};return ae.createElement(Hn,{className:"recharts-brush-texts"},ae.createElement(qy,uv({textAnchor:"end",verticalAnchor:"middle",x:Math.min(h,m)-f,y:o+l/2},x),this.getTextOfTick(s)),ae.createElement(qy,uv({textAnchor:"start",verticalAnchor:"middle",x:Math.max(h,m)+c+f,y:o+l/2},x),this.getTextOfTick(i)))}},{key:"render",value:function(){var r=this.props,s=r.data,i=r.className,o=r.children,l=r.x,c=r.y,u=r.width,d=r.height,h=r.alwaysShowText,m=this.state,f=m.startX,x=m.endX,g=m.isTextActive,p=m.isSlideMoving,v=m.isTravellerMoving,b=m.isTravellerFocused;if(!s||!s.length||!Xe(l)||!Xe(c)||!Xe(u)||!Xe(d)||u<=0||d<=0)return null;var w=Qt("recharts-brush",i),N=ae.Children.count(o)===1,j=jMe("userSelect","none");return ae.createElement(Hn,{className:w,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:j},this.renderBackground(),N&&this.renderPanorama(),this.renderSlide(f,x),this.renderTravellerLayer(f,"startX"),this.renderTravellerLayer(x,"endX"),(g||p||v||b||h)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(r){var s=r.x,i=r.y,o=r.width,l=r.height,c=r.stroke,u=Math.floor(i+l/2)-1;return ae.createElement(ae.Fragment,null,ae.createElement("rect",{x:s,y:i,width:o,height:l,fill:c,stroke:"none"}),ae.createElement("line",{x1:s+1,y1:u,x2:s+o-1,y2:u,fill:"none",stroke:"#fff"}),ae.createElement("line",{x1:s+1,y1:u+2,x2:s+o-1,y2:u+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(r,s){var i;return ae.isValidElement(r)?i=ae.cloneElement(r,s):Bt(r)?i=r(s):i=t.renderDefaultTraveller(s),i}},{key:"getDerivedStateFromProps",value:function(r,s){var i=r.data,o=r.width,l=r.x,c=r.travellerWidth,u=r.updateId,d=r.startIndex,h=r.endIndex;if(i!==s.prevData||u!==s.prevUpdateId)return b_({prevData:i,prevTravellerWidth:c,prevUpdateId:u,prevX:l,prevWidth:o},i&&i.length?AMe({data:i,width:o,x:l,travellerWidth:c,startIndex:d,endIndex:h}):{scale:null,scaleValues:null});if(s.scale&&(o!==s.prevWidth||l!==s.prevX||c!==s.prevTravellerWidth)){s.scale.range([l,l+o-c]);var m=s.scale.domain().map(function(f){return s.scale(f)});return{prevData:i,prevTravellerWidth:c,prevUpdateId:u,prevX:l,prevWidth:o,startX:s.scale(r.startIndex),endX:s.scale(r.endIndex),scaleValues:m}}return null}},{key:"getIndexInRange",value:function(r,s){for(var i=r.length,o=0,l=i-1;l-o>1;){var c=Math.floor((o+l)/2);r[c]>s?l=c:o=c}return s>=r[l]?l:o}}])}(y.PureComponent);Aa(zd,"displayName","Brush");Aa(zd,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var TMe=m2;function MMe(e,t){var n;return TMe(e,function(r,s,i){return n=t(r,s,i),!n}),!!n}var DMe=MMe,$Me=$z,RMe=Ml,IMe=DMe,LMe=ka,FMe=s0;function qMe(e,t,n){var r=LMe(e)?$Me:IMe;return n&&FMe(e,t,n)&&(t=void 0),r(e,RMe(t))}var zMe=qMe;const BMe=dn(zMe);var bi=function(t,n){var r=t.alwaysShow,s=t.ifOverflow;return r&&(s="extendDomain"),s===n},JD=rB;function UMe(e,t,n){t=="__proto__"&&JD?JD(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var WMe=UMe,KMe=WMe,HMe=tB,GMe=Ml;function VMe(e,t){var n={};return t=GMe(t),HMe(e,function(r,s,i){KMe(n,s,t(r,s,i))}),n}var YMe=VMe;const QMe=dn(YMe);function XMe(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}var JMe=XMe,ZMe=m2;function eDe(e,t){var n=!0;return ZMe(e,function(r,s,i){return n=!!t(r,s,i),n}),n}var tDe=eDe,nDe=JMe,rDe=tDe,aDe=Ml,sDe=ka,iDe=s0;function oDe(e,t,n){var r=sDe(e)?nDe:rDe;return n&&iDe(e,t,n)&&(t=void 0),r(e,aDe(t))}var lDe=oDe;const $U=dn(lDe);var cDe=["x","y"];function Qm(e){"@babel/helpers - typeof";return Qm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qm(e)}function LN(){return LN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},LN.apply(this,arguments)}function ZD(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function sf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ZD(Object(n),!0).forEach(function(r){uDe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZD(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function uDe(e,t,n){return t=dDe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dDe(e){var t=hDe(e,"string");return Qm(t)=="symbol"?t:t+""}function hDe(e,t){if(Qm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Qm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function fDe(e,t){if(e==null)return{};var n=mDe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function mDe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function pDe(e,t){var n=e.x,r=e.y,s=fDe(e,cDe),i="".concat(n),o=parseInt(i,10),l="".concat(r),c=parseInt(l,10),u="".concat(t.height||s.height),d=parseInt(u,10),h="".concat(t.width||s.width),m=parseInt(h,10);return sf(sf(sf(sf(sf({},t),s),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:m,name:t.name,radius:t.radius})}function e$(e){return ae.createElement(JTe,LN({shapeType:"rectangle",propTransformer:pDe,activeClassName:"recharts-active-bar"},e))}var gDe=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(r,s){if(typeof t=="number")return t;var i=Xe(r)||Tge(r);return i?t(r,s):(i||zc(),n)}},xDe=["value","background"],RU;function Bd(e){"@babel/helpers - typeof";return Bd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bd(e)}function yDe(e,t){if(e==null)return{};var n=vDe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function vDe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function hv(){return hv=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},hv.apply(this,arguments)}function t$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Yn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?t$(Object(n),!0).forEach(function(r){Jo(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function bDe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n$(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,LU(r.key),r)}}function wDe(e,t,n){return t&&n$(e.prototype,t),n&&n$(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function _De(e,t,n){return t=fv(t),jDe(e,IU()?Reflect.construct(t,n||[],fv(e).constructor):t.apply(e,n))}function jDe(e,t){if(t&&(Bd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return NDe(e)}function NDe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function IU(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(IU=function(){return!!e})()}function fv(e){return fv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},fv(e)}function SDe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&FN(e,t)}function FN(e,t){return FN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},FN(e,t)}function Jo(e,t,n){return t=LU(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function LU(e){var t=CDe(e,"string");return Bd(t)=="symbol"?t:t+""}function CDe(e,t){if(Bd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Bd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Up=function(e){function t(){var n;bDe(this,t);for(var r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];return n=_De(this,t,[].concat(s)),Jo(n,"state",{isAnimationFinished:!1}),Jo(n,"id",Rp("recharts-bar-")),Jo(n,"handleAnimationEnd",function(){var o=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),o&&o()}),Jo(n,"handleAnimationStart",function(){var o=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),o&&o()}),n}return SDe(t,e),wDe(t,[{key:"renderRectanglesStatically",value:function(r){var s=this,i=this.props,o=i.shape,l=i.dataKey,c=i.activeIndex,u=i.activeBar,d=Yt(this.props,!1);return r&&r.map(function(h,m){var f=m===c,x=f?u:o,g=Yn(Yn(Yn({},d),h),{},{isActive:f,option:x,index:m,dataKey:l,onAnimationStart:s.handleAnimationStart,onAnimationEnd:s.handleAnimationEnd});return ae.createElement(Hn,hv({className:"recharts-bar-rectangle"},Cy(s.props,h,m),{key:"rectangle-".concat(h==null?void 0:h.x,"-").concat(h==null?void 0:h.y,"-").concat(h==null?void 0:h.value,"-").concat(m)}),ae.createElement(e$,g))})}},{key:"renderRectanglesWithAnimation",value:function(){var r=this,s=this.props,i=s.data,o=s.layout,l=s.isAnimationActive,c=s.animationBegin,u=s.animationDuration,d=s.animationEasing,h=s.animationId,m=this.state.prevData;return ae.createElement(ho,{begin:c,duration:u,isActive:l,easing:d,from:{t:0},to:{t:1},key:"bar-".concat(h),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(f){var x=f.t,g=i.map(function(p,v){var b=m&&m[v];if(b){var w=Ls(b.x,p.x),N=Ls(b.y,p.y),j=Ls(b.width,p.width),_=Ls(b.height,p.height);return Yn(Yn({},p),{},{x:w(x),y:N(x),width:j(x),height:_(x)})}if(o==="horizontal"){var S=Ls(0,p.height),P=S(x);return Yn(Yn({},p),{},{y:p.y+p.height-P,height:P})}var k=Ls(0,p.width),C=k(x);return Yn(Yn({},p),{},{width:C})});return ae.createElement(Hn,null,r.renderRectanglesStatically(g))})}},{key:"renderRectangles",value:function(){var r=this.props,s=r.data,i=r.isAnimationActive,o=this.state.prevData;return i&&s&&s.length&&(!o||!m0(o,s))?this.renderRectanglesWithAnimation():this.renderRectanglesStatically(s)}},{key:"renderBackground",value:function(){var r=this,s=this.props,i=s.data,o=s.dataKey,l=s.activeIndex,c=Yt(this.props.background,!1);return i.map(function(u,d){u.value;var h=u.background,m=yDe(u,xDe);if(!h)return null;var f=Yn(Yn(Yn(Yn(Yn({},m),{},{fill:"#eee"},h),c),Cy(r.props,u,d)),{},{onAnimationStart:r.handleAnimationStart,onAnimationEnd:r.handleAnimationEnd,dataKey:o,index:d,className:"recharts-bar-background-rectangle"});return ae.createElement(e$,hv({key:"background-bar-".concat(d),option:r.props.background,isActive:d===l},f))})}},{key:"renderErrorBar",value:function(r,s){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.data,l=i.xAxis,c=i.yAxis,u=i.layout,d=i.children,h=us(d,Bp);if(!h)return null;var m=u==="vertical"?o[0].height/2:o[0].width/2,f=function(p,v){var b=Array.isArray(p.value)?p.value[1]:p.value;return{x:p.x,y:p.y,value:b,errorVal:Ua(p,v)}},x={clipPath:r?"url(#clipPath-".concat(s,")"):null};return ae.createElement(Hn,x,h.map(function(g){return ae.cloneElement(g,{key:"error-bar-".concat(s,"-").concat(g.props.dataKey),data:o,xAxis:l,yAxis:c,layout:u,offset:m,dataPointFormatter:f})}))}},{key:"render",value:function(){var r=this.props,s=r.hide,i=r.data,o=r.className,l=r.xAxis,c=r.yAxis,u=r.left,d=r.top,h=r.width,m=r.height,f=r.isAnimationActive,x=r.background,g=r.id;if(s||!i||!i.length)return null;var p=this.state.isAnimationFinished,v=Qt("recharts-bar",o),b=l&&l.allowDataOverflow,w=c&&c.allowDataOverflow,N=b||w,j=Ut(g)?this.id:g;return ae.createElement(Hn,{className:v},b||w?ae.createElement("defs",null,ae.createElement("clipPath",{id:"clipPath-".concat(j)},ae.createElement("rect",{x:b?u:u-h/2,y:w?d:d-m/2,width:b?h:h*2,height:w?m:m*2}))):null,ae.createElement(Hn,{className:"recharts-bar-rectangles",clipPath:N?"url(#clipPath-".concat(j,")"):null},x?this.renderBackground():null,this.renderRectangles()),this.renderErrorBar(N,j),(!f||p)&&dl.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(r,s){return r.animationId!==s.prevAnimationId?{prevAnimationId:r.animationId,curData:r.data,prevData:s.curData}:r.data!==s.curData?{curData:r.data}:null}}])}(y.PureComponent);RU=Up;Jo(Up,"displayName","Bar");Jo(Up,"defaultProps",{xAxisId:0,yAxisId:0,legendType:"rect",minPointSize:0,hide:!1,data:[],layout:"vertical",activeBar:!1,isAnimationActive:!Qi.isSsr,animationBegin:0,animationDuration:400,animationEasing:"ease"});Jo(Up,"getComposedData",function(e){var t=e.props,n=e.item,r=e.barPosition,s=e.bandSize,i=e.xAxis,o=e.yAxis,l=e.xAxisTicks,c=e.yAxisTicks,u=e.stackedData,d=e.dataStartIndex,h=e.displayedData,m=e.offset,f=nPe(r,n);if(!f)return null;var x=t.layout,g=n.type.defaultProps,p=g!==void 0?Yn(Yn({},g),n.props):n.props,v=p.dataKey,b=p.children,w=p.minPointSize,N=x==="horizontal"?o:i,j=u?N.scale.domain():null,_=uPe({numericAxis:N}),S=us(b,uB),P=h.map(function(k,C){var T,O,L,E,R,q;u?T=rPe(u[d+C],j):(T=Ua(k,v),Array.isArray(T)||(T=[_,T]));var I=gDe(w,RU.defaultProps.minPointSize)(T[1],C);if(x==="horizontal"){var $,M=[o.scale(T[0]),o.scale(T[1])],B=M[0],W=M[1];O=tD({axis:i,ticks:l,bandSize:s,offset:f.offset,entry:k,index:C}),L=($=W??B)!==null&&$!==void 0?$:void 0,E=f.size;var A=B-W;if(R=Number.isNaN(A)?0:A,q={x:O,y:o.y,width:E,height:o.height},Math.abs(I)>0&&Math.abs(R)<Math.abs(I)){var K=zs(R||I)*(Math.abs(I)-Math.abs(R));L-=K,R+=K}}else{var G=[i.scale(T[0]),i.scale(T[1])],H=G[0],fe=G[1];if(O=H,L=tD({axis:o,ticks:c,bandSize:s,offset:f.offset,entry:k,index:C}),E=fe-H,R=f.size,q={x:i.x,y:L,width:i.width,height:R},Math.abs(I)>0&&Math.abs(E)<Math.abs(I)){var te=zs(E||I)*(Math.abs(I)-Math.abs(E));E+=te}}return Yn(Yn(Yn({},k),{},{x:O,y:L,width:E,height:R,value:u?T:T[1],payload:k,background:q},S&&S[C]&&S[C].props),{},{tooltipPayload:[gU(n,k)],tooltipPosition:{x:O+E/2,y:L+R/2}})});return Yn({data:P,layout:x},m)});function Xm(e){"@babel/helpers - typeof";return Xm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Xm(e)}function kDe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r$(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,FU(r.key),r)}}function EDe(e,t,n){return t&&r$(e.prototype,t),n&&r$(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function a$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function $s(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?a$(Object(n),!0).forEach(function(r){v0(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function v0(e,t,n){return t=FU(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function FU(e){var t=PDe(e,"string");return Xm(t)=="symbol"?t:t+""}function PDe(e,t){if(Xm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Xm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var ODe=function(t,n,r,s,i){var o=t.width,l=t.height,c=t.layout,u=t.children,d=Object.keys(n),h={left:r.left,leftMirror:r.left,right:o-r.right,rightMirror:o-r.right,top:r.top,topMirror:r.top,bottom:l-r.bottom,bottomMirror:l-r.bottom},m=!!Ma(u,Up);return d.reduce(function(f,x){var g=n[x],p=g.orientation,v=g.domain,b=g.padding,w=b===void 0?{}:b,N=g.mirror,j=g.reversed,_="".concat(p).concat(N?"Mirror":""),S,P,k,C,T;if(g.type==="number"&&(g.padding==="gap"||g.padding==="no-gap")){var O=v[1]-v[0],L=1/0,E=g.categoricalDomain.sort($ge);if(E.forEach(function(G,H){H>0&&(L=Math.min((G||0)-(E[H-1]||0),L))}),Number.isFinite(L)){var R=L/O,q=g.layout==="vertical"?r.height:r.width;if(g.padding==="gap"&&(S=R*q/2),g.padding==="no-gap"){var I=Fc(t.barCategoryGap,R*q),$=R*q/2;S=$-I-($-I)/q*I}}}s==="xAxis"?P=[r.left+(w.left||0)+(S||0),r.left+r.width-(w.right||0)-(S||0)]:s==="yAxis"?P=c==="horizontal"?[r.top+r.height-(w.bottom||0),r.top+(w.top||0)]:[r.top+(w.top||0)+(S||0),r.top+r.height-(w.bottom||0)-(S||0)]:P=g.range,j&&(P=[P[1],P[0]]);var M=ePe(g,i,m),B=M.scale,W=M.realScaleType;B.domain(v).range(P),tPe(B);var A=cPe(B,$s($s({},g),{},{realScaleType:W}));s==="xAxis"?(T=p==="top"&&!N||p==="bottom"&&N,k=r.left,C=h[_]-T*g.height):s==="yAxis"&&(T=p==="left"&&!N||p==="right"&&N,k=h[_]-T*g.width,C=r.top);var K=$s($s($s({},g),A),{},{realScaleType:W,x:k,y:C,scale:B,width:s==="xAxis"?r.width:g.width,height:s==="yAxis"?r.height:g.height});return K.bandSize=ev(K,A),!g.hide&&s==="xAxis"?h[_]+=(T?-1:1)*K.height:g.hide||(h[_]+=(T?-1:1)*K.width),$s($s({},f),{},v0({},x,K))},{})},qU=function(t,n){var r=t.x,s=t.y,i=n.x,o=n.y;return{x:Math.min(r,i),y:Math.min(s,o),width:Math.abs(i-r),height:Math.abs(o-s)}},ADe=function(t){var n=t.x1,r=t.y1,s=t.x2,i=t.y2;return qU({x:n,y:r},{x:s,y:i})},zU=function(){function e(t){kDe(this,e),this.scale=t}return EDe(e,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=r.bandAware,i=r.position;if(n!==void 0){if(i)switch(i){case"start":return this.scale(n);case"middle":{var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(n)+o}case"end":{var l=this.bandwidth?this.bandwidth():0;return this.scale(n)+l}default:return this.scale(n)}if(s){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(n)+c}return this.scale(n)}}},{key:"isInRange",value:function(n){var r=this.range(),s=r[0],i=r[r.length-1];return s<=i?n>=s&&n<=i:n>=i&&n<=s}}],[{key:"create",value:function(n){return new e(n)}}])}();v0(zU,"EPS",1e-4);var W2=function(t){var n=Object.keys(t).reduce(function(r,s){return $s($s({},r),{},v0({},s,zU.create(t[s])))},{});return $s($s({},n),{},{apply:function(s){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.bandAware,l=i.position;return QMe(s,function(c,u){return n[u].apply(c,{bandAware:o,position:l})})},isInRange:function(s){return $U(s,function(i,o){return n[o].isInRange(i)})}})};function TDe(e){return(e%180+180)%180}var MDe=function(t){var n=t.width,r=t.height,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=TDe(s),o=i*Math.PI/180,l=Math.atan(r/n),c=o>l&&o<Math.PI-l?r/Math.sin(o):n/Math.cos(o);return Math.abs(c)},DDe=Ml,$De=Ip,RDe=r0;function IDe(e){return function(t,n,r){var s=Object(t);if(!$De(t)){var i=DDe(n);t=RDe(t),n=function(l){return i(s[l],l,s)}}var o=e(t,n,r);return o>-1?s[i?t[o]:o]:void 0}}var LDe=IDe,FDe=AU;function qDe(e){var t=FDe(e),n=t%1;return t===t?n?t-n:t:0}var zDe=qDe,BDe=Yz,UDe=Ml,WDe=zDe,KDe=Math.max;function HDe(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var s=n==null?0:WDe(n);return s<0&&(s=KDe(r+s,0)),BDe(e,UDe(t),s)}var GDe=HDe,VDe=LDe,YDe=GDe,QDe=VDe(YDe),XDe=QDe;const JDe=dn(XDe);var ZDe=Rpe(function(e){return{x:e.left,y:e.top,width:e.width,height:e.height}},function(e){return["l",e.left,"t",e.top,"w",e.width,"h",e.height].join("")}),K2=y.createContext(void 0),H2=y.createContext(void 0),BU=y.createContext(void 0),UU=y.createContext({}),WU=y.createContext(void 0),KU=y.createContext(0),HU=y.createContext(0),s$=function(t){var n=t.state,r=n.xAxisMap,s=n.yAxisMap,i=n.offset,o=t.clipPathId,l=t.children,c=t.width,u=t.height,d=ZDe(i);return ae.createElement(K2.Provider,{value:r},ae.createElement(H2.Provider,{value:s},ae.createElement(UU.Provider,{value:i},ae.createElement(BU.Provider,{value:d},ae.createElement(WU.Provider,{value:o},ae.createElement(KU.Provider,{value:u},ae.createElement(HU.Provider,{value:c},l)))))))},e$e=function(){return y.useContext(WU)},GU=function(t){var n=y.useContext(K2);n==null&&zc();var r=n[t];return r==null&&zc(),r},t$e=function(){var t=y.useContext(K2);return Io(t)},n$e=function(){var t=y.useContext(H2),n=JDe(t,function(r){return $U(r.domain,Number.isFinite)});return n||Io(t)},VU=function(t){var n=y.useContext(H2);n==null&&zc();var r=n[t];return r==null&&zc(),r},r$e=function(){var t=y.useContext(BU);return t},a$e=function(){return y.useContext(UU)},G2=function(){return y.useContext(HU)},V2=function(){return y.useContext(KU)};function Ud(e){"@babel/helpers - typeof";return Ud=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ud(e)}function s$e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i$e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,QU(r.key),r)}}function o$e(e,t,n){return t&&i$e(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function l$e(e,t,n){return t=mv(t),c$e(e,YU()?Reflect.construct(t,n||[],mv(e).constructor):t.apply(e,n))}function c$e(e,t){if(t&&(Ud(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return u$e(e)}function u$e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function YU(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(YU=function(){return!!e})()}function mv(e){return mv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},mv(e)}function d$e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&qN(e,t)}function qN(e,t){return qN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},qN(e,t)}function i$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function o$(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?i$(Object(n),!0).forEach(function(r){Y2(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Y2(e,t,n){return t=QU(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QU(e){var t=h$e(e,"string");return Ud(t)=="symbol"?t:t+""}function h$e(e,t){if(Ud(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Ud(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function f$e(e,t){return x$e(e)||g$e(e,t)||p$e(e,t)||m$e()}function m$e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 904In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function p$e(e,t){if(e){if(typeof e=="string")return l$(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l$(e,t)}}function l$(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function g$e(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function x$e(e){if(Array.isArray(e))return e}function zN(){return zN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zN.apply(this,arguments)}var y$e=function(t,n){var r;return ae.isValidElement(t)?r=ae.cloneElement(t,n):Bt(t)?r=t(n):r=ae.createElement("line",zN({},n,{className:"recharts-reference-line-line"})),r},v$e=function(t,n,r,s,i,o,l,c,u){var d=i.x,h=i.y,m=i.width,f=i.height;if(r){var x=u.y,g=t.y.apply(x,{position:o});if(bi(u,"discard")&&!t.y.isInRange(g))return null;var p=[{x:d+m,y:g},{x:d,y:g}];return c==="left"?p.reverse():p}if(n){var v=u.x,b=t.x.apply(v,{position:o});if(bi(u,"discard")&&!t.x.isInRange(b))return null;var w=[{x:b,y:h+f},{x:b,y:h}];return l==="top"?w.reverse():w}if(s){var N=u.segment,j=N.map(function(_){return t.apply(_,{position:o})});return bi(u,"discard")&&BMe(j,function(_){return!t.isInRange(_)})?null:j}return null};function b$e(e){var t=e.x,n=e.y,r=e.segment,s=e.xAxisId,i=e.yAxisId,o=e.shape,l=e.className,c=e.alwaysShow,u=e$e(),d=GU(s),h=VU(i),m=r$e();if(!u||!m)return null;Yi(c===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var f=W2({x:d.scale,y:h.scale}),x=ur(t),g=ur(n),p=r&&r.length===2,v=v$e(f,x,g,p,m,e.position,d.orientation,h.orientation,e);if(!v)return null;var b=f$e(v,2),w=b[0],N=w.x,j=w.y,_=b[1],S=_.x,P=_.y,k=bi(e,"hidden")?"url(#".concat(u,")"):void 0,C=o$(o$({clipPath:k},Yt(e,!0)),{},{x1:N,y1:j,x2:S,y2:P});return ae.createElement(Hn,{className:Qt("recharts-reference-line",l)},y$e(o,C),Ur.renderCallByParent(e,ADe({x1:N,y1:j,x2:S,y2:P})))}var Jm=function(e){function t(){return s$e(this,t),l$e(this,t,arguments)}return d$e(t,e),o$e(t,[{key:"render",value:function(){return ae.createElement(b$e,this.props)}}])}(ae.Component);Y2(Jm,"displayName","ReferenceLine");Y2(Jm,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle"});function BN(){return BN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},BN.apply(this,arguments)}function Wd(e){"@babel/helpers - typeof";return Wd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Wd(e)}function c$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function u$(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?c$(Object(n),!0).forEach(function(r){b0(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function w$e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _$e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,JU(r.key),r)}}function j$e(e,t,n){return t&&_$e(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function N$e(e,t,n){return t=pv(t),S$e(e,XU()?Reflect.construct(t,n||[],pv(e).constructor):t.apply(e,n))}function S$e(e,t){if(t&&(Wd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return C$e(e)}function C$e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function XU(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(XU=function(){return!!e})()}function pv(e){return pv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},pv(e)}function k$e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&UN(e,t)}function UN(e,t){return UN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},UN(e,t)}function b0(e,t,n){return t=JU(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function JU(e){var t=E$e(e,"string");return Wd(t)=="symbol"?t:t+""}function E$e(e,t){if(Wd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Wd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var P$e=function(t){var n=t.x,r=t.y,s=t.xAxis,i=t.yAxis,o=W2({x:s.scale,y:i.scale}),l=o.apply({x:n,y:r},{bandAware:!0});return bi(t,"discard")&&!o.isInRange(l)?null:l},Wp=function(e){function t(){return w$e(this,t),N$e(this,t,arguments)}return k$e(t,e),j$e(t,[{key:"render",value:function(){var r=this.props,s=r.x,i=r.y,o=r.r,l=r.alwaysShow,c=r.clipPathId,u=ur(s),d=ur(i);if(Yi(l===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.'),!u||!d)return null;var h=P$e(this.props);if(!h)return null;var m=h.x,f=h.y,x=this.props,g=x.shape,p=x.className,v=bi(this.props,"hidden")?"url(#".concat(c,")"):void 0,b=u$(u$({clipPath:v},Yt(this.props,!0)),{},{cx:m,cy:f});return ae.createElement(Hn,{className:Qt("recharts-reference-dot",p)},t.renderDot(g,b),Ur.renderCallByParent(this.props,{x:m-o,y:f-o,width:2*o,height:2*o}))}}])}(ae.Component);b0(Wp,"displayName","ReferenceDot");b0(Wp,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#fff",stroke:"#ccc",fillOpacity:1,strokeWidth:1});b0(Wp,"renderDot",function(e,t){var n;return ae.isValidElement(e)?n=ae.cloneElement(e,t):Bt(e)?n=e(t):n=ae.createElement(U2,BN({},t,{cx:t.cx,cy:t.cy,className:"recharts-reference-dot-dot"})),n});function WN(){return WN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},WN.apply(this,arguments)}function Kd(e){"@babel/helpers - typeof";return Kd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kd(e)}function d$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).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?d$(Object(n),!0).forEach(function(r){w0(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function O$e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function A$e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,e9(r.key),r)}}function T$e(e,t,n){return t&&A$e(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function M$e(e,t,n){return t=gv(t),D$e(e,ZU()?Reflect.construct(t,n||[],gv(e).constructor):t.apply(e,n))}function D$e(e,t){if(t&&(Kd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return $$e(e)}function $$e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ZU(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ZU=function(){return!!e})()}function gv(e){return gv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},gv(e)}function R$e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&KN(e,t)}function KN(e,t){return KN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},KN(e,t)}function w0(e,t,n){return t=e9(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function e9(e){var t=I$e(e,"string");return Kd(t)=="symbol"?t:t+""}function I$e(e,t){if(Kd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Kd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var L$e=function(t,n,r,s,i){var o=i.x1,l=i.x2,c=i.y1,u=i.y2,d=i.xAxis,h=i.yAxis;if(!d||!h)return null;var m=W2({x:d.scale,y:h.scale}),f={x:t?m.x.apply(o,{position:"start"}):m.x.rangeMin,y:r?m.y.apply(c,{position:"start"}):m.y.rangeMin},x={x:n?m.x.apply(l,{position:"end"}):m.x.rangeMax,y:s?m.y.apply(u,{position:"end"}):m.y.rangeMax};return bi(i,"discard")&&(!m.isInRange(f)||!m.isInRange(x))?null:qU(f,x)},_0=function(e){function t(){return O$e(this,t),M$e(this,t,arguments)}return R$e(t,e),T$e(t,[{key:"render",value:function(){var r=this.props,s=r.x1,i=r.x2,o=r.y1,l=r.y2,c=r.className,u=r.alwaysShow,d=r.clipPathId;Yi(u===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var h=ur(s),m=ur(i),f=ur(o),x=ur(l),g=this.props.shape;if(!h&&!m&&!f&&!x&&!g)return null;var p=L$e(h,m,f,x,this.props);if(!p&&!g)return null;var v=bi(this.props,"hidden")?"url(#".concat(d,")"):void 0;return ae.createElement(Hn,{className:Qt("recharts-reference-area",c)},t.renderRect(g,h$(h$({clipPath:v},Yt(this.props,!0)),p)),Ur.renderCallByParent(this.props,p))}}])}(ae.Component);w0(_0,"displayName","ReferenceArea");w0(_0,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#ccc",fillOpacity:.5,stroke:"none",strokeWidth:1});w0(_0,"renderRect",function(e,t){var n;return ae.isValidElement(e)?n=ae.cloneElement(e,t):Bt(e)?n=e(t):n=ae.createElement(B2,WN({},t,{className:"recharts-reference-area-rect"})),n});function t9(e,t,n){if(t<1)return[];if(t===1&&n===void 0)return e;for(var r=[],s=0;s<e.length;s+=t)r.push(e[s]);return r}function F$e(e,t,n){var r={width:e.width+t.width,height:e.height+t.height};return MDe(r,n)}function q$e(e,t,n){var r=n==="width",s=e.x,i=e.y,o=e.width,l=e.height;return t===1?{start:r?s:i,end:r?s+o:i+l}:{start:r?s+o:i+l,end:r?s:i}}function xv(e,t,n,r,s){if(e*t<e*r||e*t>e*s)return!1;var i=n();return e*(t-e*i/2-r)>=0&&e*(t+e*i/2-s)<=0}function z$e(e,t){return t9(e,t+1)}function B$e(e,t,n,r,s){for(var i=(r||[]).slice(),o=t.start,l=t.end,c=0,u=1,d=o,h=function(){var x=r==null?void 0:r[c];if(x===void 0)return{v:t9(r,u)};var g=c,p,v=function(){return p===void 0&&(p=n(x,g)),p},b=x.coordinate,w=c===0||xv(e,b,v,d,l);w||(c=0,d=o,u+=1),w&&(d=b+e*(v()/2+s),c+=u)},m;u<=i.length;)if(m=h(),m)return m.v;return[]}function Zm(e){"@babel/helpers - typeof";return Zm=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Zm(e)}function f$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function zr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?f$(Object(n),!0).forEach(function(r){U$e(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function U$e(e,t,n){return t=W$e(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function W$e(e){var t=K$e(e,"string");return Zm(t)=="symbol"?t:t+""}function K$e(e,t){if(Zm(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Zm(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function H$e(e,t,n,r,s){for(var i=(r||[]).slice(),o=i.length,l=t.start,c=t.end,u=function(m){var f=i[m],x,g=function(){return x===void 0&&(x=n(f,m)),x};if(m===o-1){var p=e*(f.coordinate+e*g()/2-c);i[m]=f=zr(zr({},f),{},{tickCoord:p>0?f.coordinate-p*e:f.coordinate})}else i[m]=f=zr(zr({},f),{},{tickCoord:f.coordinate});var v=xv(e,f.tickCoord,g,l,c);v&&(c=f.tickCoord-e*(g()/2+s),i[m]=zr(zr({},f),{},{isShow:!0}))},d=o-1;d>=0;d--)u(d);return i}function G$e(e,t,n,r,s,i){var o=(r||[]).slice(),l=o.length,c=t.start,u=t.end;if(i){var d=r[l-1],h=n(d,l-1),m=e*(d.coordinate+e*h/2-u);o[l-1]=d=zr(zr({},d),{},{tickCoord:m>0?d.coordinate-m*e:d.coordinate});var f=xv(e,d.tickCoord,function(){return h},c,u);f&&(u=d.tickCoord-e*(h/2+s),o[l-1]=zr(zr({},d),{},{isShow:!0}))}for(var x=i?l-1:l,g=function(b){var w=o[b],N,j=function(){return N===void 0&&(N=n(w,b)),N};if(b===0){var _=e*(w.coordinate-e*j()/2-c);o[b]=w=zr(zr({},w),{},{tickCoord:_<0?w.coordinate-_*e:w.coordinate})}else o[b]=w=zr(zr({},w),{},{tickCoord:w.coordinate});var S=xv(e,w.tickCoord,j,c,u);S&&(c=w.tickCoord+e*(j()/2+s),o[b]=zr(zr({},w),{},{isShow:!0}))},p=0;p<x;p++)g(p);return o}function Q2(e,t,n){var r=e.tick,s=e.ticks,i=e.viewBox,o=e.minTickGap,l=e.orientation,c=e.interval,u=e.tickFormatter,d=e.unit,h=e.angle;if(!s||!s.length||!r)return[];if(Xe(c)||Qi.isSsr)return z$e(s,typeof c=="number"&&Xe(c)?c:0);var m=[],f=l==="top"||l==="bottom"?"width":"height",x=d&&f==="width"?Tf(d,{fontSize:t,letterSpacing:n}):{width:0,height:0},g=function(w,N){var j=Bt(u)?u(w.value,N):w.value;return f==="width"?F$e(Tf(j,{fontSize:t,letterSpacing:n}),x,h):Tf(j,{fontSize:t,letterSpacing:n})[f]},p=s.length>=2?zs(s[1].coordinate-s[0].coordinate):1,v=q$e(i,p,f);return c==="equidistantPreserveStart"?B$e(p,v,g,s,o):(c==="preserveStart"||c==="preserveStartEnd"?m=G$e(p,v,g,s,o,c==="preserveStartEnd"):m=H$e(p,v,g,s,o),m.filter(function(b){return b.isShow}))}var V$e=["viewBox"],Y$e=["viewBox"],Q$e=["ticks"];function Hd(e){"@babel/helpers - typeof";return Hd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hd(e)}function Uu(){return Uu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Uu.apply(this,arguments)}function m$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function rr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?m$(Object(n),!0).forEach(function(r){X2(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function w_(e,t){if(e==null)return{};var n=X$e(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function X$e(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function J$e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p$(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r9(r.key),r)}}function Z$e(e,t,n){return t&&p$(e.prototype,t),n&&p$(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function eRe(e,t,n){return t=yv(t),tRe(e,n9()?Reflect.construct(t,n||[],yv(e).constructor):t.apply(e,n))}function tRe(e,t){if(t&&(Hd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return nRe(e)}function nRe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function n9(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(n9=function(){return!!e})()}function yv(e){return yv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},yv(e)}function rRe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&HN(e,t)}function HN(e,t){return HN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},HN(e,t)}function X2(e,t,n){return t=r9(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r9(e){var t=aRe(e,"string");return Hd(t)=="symbol"?t:t+""}function aRe(e,t){if(Hd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Hd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var kh=function(e){function t(n){var r;return J$e(this,t),r=eRe(this,t,[n]),r.state={fontSize:"",letterSpacing:""},r}return rRe(t,e),Z$e(t,[{key:"shouldComponentUpdate",value:function(r,s){var i=r.viewBox,o=w_(r,V$e),l=this.props,c=l.viewBox,u=w_(l,Y$e);return!rd(i,c)||!rd(o,u)||!rd(s,this.state)}},{key:"componentDidMount",value:function(){var r=this.layerReference;if(r){var s=r.getElementsByClassName("recharts-cartesian-axis-tick-value")[0];s&&this.setState({fontSize:window.getComputedStyle(s).fontSize,letterSpacing:window.getComputedStyle(s).letterSpacing})}}},{key:"getTickLineCoord",value:function(r){var s=this.props,i=s.x,o=s.y,l=s.width,c=s.height,u=s.orientation,d=s.tickSize,h=s.mirror,m=s.tickMargin,f,x,g,p,v,b,w=h?-1:1,N=r.tickSize||d,j=Xe(r.tickCoord)?r.tickCoord:r.coordinate;switch(u){case"top":f=x=r.coordinate,p=o+ +!h*c,g=p-w*N,b=g-w*m,v=j;break;case"left":g=p=r.coordinate,x=i+ +!h*l,f=x-w*N,v=f-w*m,b=j;break;case"right":g=p=r.coordinate,x=i+ +h*l,f=x+w*N,v=f+w*m,b=j;break;default:f=x=r.coordinate,p=o+ +h*c,g=p+w*N,b=g+w*m,v=j;break}return{line:{x1:f,y1:g,x2:x,y2:p},tick:{x:v,y:b}}}},{key:"getTickTextAnchor",value:function(){var r=this.props,s=r.orientation,i=r.mirror,o;switch(s){case"left":o=i?"start":"end";break;case"right":o=i?"end":"start";break;default:o="middle";break}return o}},{key:"getTickVerticalAnchor",value:function(){var r=this.props,s=r.orientation,i=r.mirror,o="end";switch(s){case"left":case"right":o="middle";break;case"top":o=i?"start":"end";break;default:o=i?"end":"start";break}return o}},{key:"renderAxisLine",value:function(){var r=this.props,s=r.x,i=r.y,o=r.width,l=r.height,c=r.orientation,u=r.mirror,d=r.axisLine,h=rr(rr(rr({},Yt(this.props,!1)),Yt(d,!1)),{},{fill:"none"});if(c==="top"||c==="bottom"){var m=+(c==="top"&&!u||c==="bottom"&&u);h=rr(rr({},h),{},{x1:s,y1:i+m*l,x2:s+o,y2:i+m*l})}else{var f=+(c==="left"&&!u||c==="right"&&u);h=rr(rr({},h),{},{x1:s+f*o,y1:i,x2:s+f*o,y2:i+l})}return ae.createElement("line",Uu({},h,{className:Qt("recharts-cartesian-axis-line",cs(d,"className"))}))}},{key:"renderTicks",value:function(r,s,i){var o=this,l=this.props,c=l.tickLine,u=l.stroke,d=l.tick,h=l.tickFormatter,m=l.unit,f=Q2(rr(rr({},this.props),{},{ticks:r}),s,i),x=this.getTickTextAnchor(),g=this.getTickVerticalAnchor(),p=Yt(this.props,!1),v=Yt(d,!1),b=rr(rr({},p),{},{fill:"none"},Yt(c,!1)),w=f.map(function(N,j){var _=o.getTickLineCoord(N),S=_.line,P=_.tick,k=rr(rr(rr(rr({textAnchor:x,verticalAnchor:g},p),{},{stroke:"none",fill:u},v),P),{},{index:j,payload:N,visibleTicksCount:f.length,tickFormatter:h});return ae.createElement(Hn,Uu({className:"recharts-cartesian-axis-tick",key:"tick-".concat(N.value,"-").concat(N.coordinate,"-").concat(N.tickCoord)},Cy(o.props,N,j)),c&&ae.createElement("line",Uu({},b,S,{className:Qt("recharts-cartesian-axis-tick-line",cs(c,"className"))})),d&&t.renderTickItem(d,k,"".concat(Bt(h)?h(N.value,j):N.value).concat(m||"")))});return ae.createElement("g",{className:"recharts-cartesian-axis-ticks"},w)}},{key:"render",value:function(){var r=this,s=this.props,i=s.axisLine,o=s.width,l=s.height,c=s.ticksGenerator,u=s.className,d=s.hide;if(d)return null;var h=this.props,m=h.ticks,f=w_(h,Q$e),x=m;return Bt(c)&&(x=m&&m.length>0?c(this.props):c(f)),o<=0||l<=0||!x||!x.length?null:ae.createElement(Hn,{className:Qt("recharts-cartesian-axis",u),ref:function(p){r.layerReference=p}},i&&this.renderAxisLine(),this.renderTicks(x,this.state.fontSize,this.state.letterSpacing),Ur.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(r,s,i){var o,l=Qt(s.className,"recharts-cartesian-axis-tick-value");return ae.isValidElement(r)?o=ae.cloneElement(r,rr(rr({},s),{},{className:l})):Bt(r)?o=r(rr(rr({},s),{},{className:l})):o=ae.createElement(qy,Uu({},s,{className:"recharts-cartesian-axis-tick-value"}),i),o}}])}(y.Component);X2(kh,"displayName","CartesianAxis");X2(kh,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var sRe=["x1","y1","x2","y2","key"],iRe=["offset"];function Bc(e){"@babel/helpers - typeof";return Bc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bc(e)}function g$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Wr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?g$(Object(n),!0).forEach(function(r){oRe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function oRe(e,t,n){return t=lRe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lRe(e){var t=cRe(e,"string");return Bc(t)=="symbol"?t:t+""}function cRe(e,t){if(Bc(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Bc(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function oc(){return oc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},oc.apply(this,arguments)}function x$(e,t){if(e==null)return{};var n=uRe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function uRe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var dRe=function(t){var n=t.fill;if(!n||n==="none")return null;var r=t.fillOpacity,s=t.x,i=t.y,o=t.width,l=t.height,c=t.ry;return ae.createElement("rect",{x:s,y:i,ry:c,width:o,height:l,stroke:"none",fill:n,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function a9(e,t){var n;if(ae.isValidElement(e))n=ae.cloneElement(e,t);else if(Bt(e))n=e(t);else{var r=t.x1,s=t.y1,i=t.x2,o=t.y2,l=t.key,c=x$(t,sRe),u=Yt(c,!1);u.offset;var d=x$(u,iRe);n=ae.createElement("line",oc({},d,{x1:r,y1:s,x2:i,y2:o,fill:"none",key:l}))}return n}function hRe(e){var t=e.x,n=e.width,r=e.horizontal,s=r===void 0?!0:r,i=e.horizontalPoints;if(!s||!i||!i.length)return null;var o=i.map(function(l,c){var u=Wr(Wr({},e),{},{x1:t,y1:l,x2:t+n,y2:l,key:"line-".concat(c),index:c});return a9(s,u)});return ae.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function fRe(e){var t=e.y,n=e.height,r=e.vertical,s=r===void 0?!0:r,i=e.verticalPoints;if(!s||!i||!i.length)return null;var o=i.map(function(l,c){var u=Wr(Wr({},e),{},{x1:l,y1:t,x2:l,y2:t+n,key:"line-".concat(c),index:c});return a9(s,u)});return ae.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function mRe(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,s=e.y,i=e.width,o=e.height,l=e.horizontalPoints,c=e.horizontal,u=c===void 0?!0:c;if(!u||!t||!t.length)return null;var d=l.map(function(m){return Math.round(m+s-s)}).sort(function(m,f){return m-f});s!==d[0]&&d.unshift(0);var h=d.map(function(m,f){var x=!d[f+1],g=x?s+o-m:d[f+1]-m;if(g<=0)return null;var p=f%t.length;return ae.createElement("rect",{key:"react-".concat(f),y:m,x:r,height:g,width:i,stroke:"none",fill:t[p],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return ae.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},h)}function pRe(e){var t=e.vertical,n=t===void 0?!0:t,r=e.verticalFill,s=e.fillOpacity,i=e.x,o=e.y,l=e.width,c=e.height,u=e.verticalPoints;if(!n||!r||!r.length)return null;var d=u.map(function(m){return Math.round(m+i-i)}).sort(function(m,f){return m-f});i!==d[0]&&d.unshift(0);var h=d.map(function(m,f){var x=!d[f+1],g=x?i+l-m:d[f+1]-m;if(g<=0)return null;var p=f%r.length;return ae.createElement("rect",{key:"react-".concat(f),x:m,y:o,width:g,height:c,stroke:"none",fill:r[p],fillOpacity:s,className:"recharts-cartesian-grid-bg"})});return ae.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},h)}var gRe=function(t,n){var r=t.xAxis,s=t.width,i=t.height,o=t.offset;return mU(Q2(Wr(Wr(Wr({},kh.defaultProps),r),{},{ticks:Wi(r,!0),viewBox:{x:0,y:0,width:s,height:i}})),o.left,o.left+o.width,n)},xRe=function(t,n){var r=t.yAxis,s=t.width,i=t.height,o=t.offset;return mU(Q2(Wr(Wr(Wr({},kh.defaultProps),r),{},{ticks:Wi(r,!0),viewBox:{x:0,y:0,width:s,height:i}})),o.top,o.top+o.height,n)},bu={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function s9(e){var t,n,r,s,i,o,l=G2(),c=V2(),u=a$e(),d=Wr(Wr({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:bu.stroke,fill:(n=e.fill)!==null&&n!==void 0?n:bu.fill,horizontal:(r=e.horizontal)!==null&&r!==void 0?r:bu.horizontal,horizontalFill:(s=e.horizontalFill)!==null&&s!==void 0?s:bu.horizontalFill,vertical:(i=e.vertical)!==null&&i!==void 0?i:bu.vertical,verticalFill:(o=e.verticalFill)!==null&&o!==void 0?o:bu.verticalFill,x:Xe(e.x)?e.x:u.left,y:Xe(e.y)?e.y:u.top,width:Xe(e.width)?e.width:u.width,height:Xe(e.height)?e.height:u.height}),h=d.x,m=d.y,f=d.width,x=d.height,g=d.syncWithTicks,p=d.horizontalValues,v=d.verticalValues,b=t$e(),w=n$e();if(!Xe(f)||f<=0||!Xe(x)||x<=0||!Xe(h)||h!==+h||!Xe(m)||m!==+m)return null;var N=d.verticalCoordinatesGenerator||gRe,j=d.horizontalCoordinatesGenerator||xRe,_=d.horizontalPoints,S=d.verticalPoints;if((!_||!_.length)&&Bt(j)){var P=p&&p.length,k=j({yAxis:w?Wr(Wr({},w),{},{ticks:P?p:w.ticks}):void 0,width:l,height:c,offset:u},P?!0:g);Yi(Array.isArray(k),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(Bc(k),"]")),Array.isArray(k)&&(_=k)}if((!S||!S.length)&&Bt(N)){var C=v&&v.length,T=N({xAxis:b?Wr(Wr({},b),{},{ticks:C?v:b.ticks}):void 0,width:l,height:c,offset:u},C?!0:g);Yi(Array.isArray(T),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(Bc(T),"]")),Array.isArray(T)&&(S=T)}return ae.createElement("g",{className:"recharts-cartesian-grid"},ae.createElement(dRe,{fill:d.fill,fillOpacity:d.fillOpacity,x:d.x,y:d.y,width:d.width,height:d.height,ry:d.ry}),ae.createElement(hRe,oc({},d,{offset:u,horizontalPoints:_,xAxis:b,yAxis:w})),ae.createElement(fRe,oc({},d,{offset:u,verticalPoints:S,xAxis:b,yAxis:w})),ae.createElement(mRe,oc({},d,{horizontalPoints:_})),ae.createElement(pRe,oc({},d,{verticalPoints:S})))}s9.displayName="CartesianGrid";var yRe=["type","layout","connectNulls","ref"],vRe=["key"];function Gd(e){"@babel/helpers - typeof";return Gd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gd(e)}function y$(e,t){if(e==null)return{};var n=bRe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function bRe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function Rf(){return Rf=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Rf.apply(this,arguments)}function v$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Oa(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?v$(Object(n),!0).forEach(function(r){Rs(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function wu(e){return NRe(e)||jRe(e)||_Re(e)||wRe()}function wRe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 905In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _Re(e,t){if(e){if(typeof e=="string")return GN(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return GN(e,t)}}function jRe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function NRe(e){if(Array.isArray(e))return GN(e)}function GN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function SRe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b$(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o9(r.key),r)}}function CRe(e,t,n){return t&&b$(e.prototype,t),n&&b$(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function kRe(e,t,n){return t=vv(t),ERe(e,i9()?Reflect.construct(t,n||[],vv(e).constructor):t.apply(e,n))}function ERe(e,t){if(t&&(Gd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return PRe(e)}function PRe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function i9(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(i9=function(){return!!e})()}function vv(e){return vv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},vv(e)}function ORe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&VN(e,t)}function VN(e,t){return VN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},VN(e,t)}function Rs(e,t,n){return t=o9(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o9(e){var t=ARe(e,"string");return Gd(t)=="symbol"?t:t+""}function ARe(e,t){if(Gd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Gd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var jc=function(e){function t(){var n;SRe(this,t);for(var r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];return n=kRe(this,t,[].concat(s)),Rs(n,"state",{isAnimationFinished:!0,totalLength:0}),Rs(n,"generateSimpleStrokeDasharray",function(o,l){return"".concat(l,"px ").concat(o-l,"px")}),Rs(n,"getStrokeDasharray",function(o,l,c){var u=c.reduce(function(v,b){return v+b});if(!u)return n.generateSimpleStrokeDasharray(l,o);for(var d=Math.floor(o/u),h=o%u,m=l-o,f=[],x=0,g=0;x<c.length;g+=c[x],++x)if(g+c[x]>h){f=[].concat(wu(c.slice(0,x)),[h-g]);break}var p=f.length%2===0?[0,m]:[m];return[].concat(wu(t.repeat(c,d)),wu(f),p).map(function(v){return"".concat(v,"px")}).join(", ")}),Rs(n,"id",Rp("recharts-line-")),Rs(n,"pathRef",function(o){n.mainCurve=o}),Rs(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),Rs(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return ORe(t,e),CRe(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();this.setState({totalLength:r})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();r!==this.state.totalLength&&this.setState({totalLength:r})}}},{key:"getTotalLength",value:function(){var r=this.mainCurve;try{return r&&r.getTotalLength&&r.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(r,s){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.points,l=i.xAxis,c=i.yAxis,u=i.layout,d=i.children,h=us(d,Bp);if(!h)return null;var m=function(g,p){return{x:g.x,y:g.y,value:g.value,errorVal:Ua(g.payload,p)}},f={clipPath:r?"url(#clipPath-".concat(s,")"):null};return ae.createElement(Hn,f,h.map(function(x){return ae.cloneElement(x,{key:"bar-".concat(x.props.dataKey),data:o,xAxis:l,yAxis:c,layout:u,dataPointFormatter:m})}))}},{key:"renderDots",value:function(r,s,i){var o=this.props.isAnimationActive;if(o&&!this.state.isAnimationFinished)return null;var l=this.props,c=l.dot,u=l.points,d=l.dataKey,h=Yt(this.props,!1),m=Yt(c,!0),f=u.map(function(g,p){var v=Oa(Oa(Oa({key:"dot-".concat(p),r:3},h),m),{},{index:p,cx:g.x,cy:g.y,value:g.value,dataKey:d,payload:g.payload,points:u});return t.renderDotItem(c,v)}),x={clipPath:r?"url(#clipPath-".concat(s?"":"dots-").concat(i,")"):null};return ae.createElement(Hn,Rf({className:"recharts-line-dots",key:"dots"},x),f)}},{key:"renderCurveStatically",value:function(r,s,i,o){var l=this.props,c=l.type,u=l.layout,d=l.connectNulls;l.ref;var h=y$(l,yRe),m=Oa(Oa(Oa({},Yt(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:s?"url(#clipPath-".concat(i,")"):null,points:r},o),{},{type:c,layout:u,connectNulls:d});return ae.createElement(SN,Rf({},m,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(r,s){var i=this,o=this.props,l=o.points,c=o.strokeDasharray,u=o.isAnimationActive,d=o.animationBegin,h=o.animationDuration,m=o.animationEasing,f=o.animationId,x=o.animateNewValues,g=o.width,p=o.height,v=this.state,b=v.prevPoints,w=v.totalLength;return ae.createElement(ho,{begin:d,duration:h,isActive:u,easing:m,from:{t:0},to:{t:1},key:"line-".concat(f),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(N){var j=N.t;if(b){var _=b.length/l.length,S=l.map(function(O,L){var E=Math.floor(L*_);if(b[E]){var R=b[E],q=Ls(R.x,O.x),I=Ls(R.y,O.y);return Oa(Oa({},O),{},{x:q(j),y:I(j)})}if(x){var $=Ls(g*2,O.x),M=Ls(p/2,O.y);return Oa(Oa({},O),{},{x:$(j),y:M(j)})}return Oa(Oa({},O),{},{x:O.x,y:O.y})});return i.renderCurveStatically(S,r,s)}var P=Ls(0,w),k=P(j),C;if(c){var T="".concat(c).split(/[,\s]+/gim).map(function(O){return parseFloat(O)});C=i.getStrokeDasharray(k,w,T)}else C=i.generateSimpleStrokeDasharray(w,k);return i.renderCurveStatically(l,r,s,{strokeDasharray:C})})}},{key:"renderCurve",value:function(r,s){var i=this.props,o=i.points,l=i.isAnimationActive,c=this.state,u=c.prevPoints,d=c.totalLength;return l&&o&&o.length&&(!u&&d>0||!m0(u,o))?this.renderCurveWithAnimation(r,s):this.renderCurveStatically(o,r,s)}},{key:"render",value:function(){var r,s=this.props,i=s.hide,o=s.dot,l=s.points,c=s.className,u=s.xAxis,d=s.yAxis,h=s.top,m=s.left,f=s.width,x=s.height,g=s.isAnimationActive,p=s.id;if(i||!l||!l.length)return null;var v=this.state.isAnimationFinished,b=l.length===1,w=Qt("recharts-line",c),N=u&&u.allowDataOverflow,j=d&&d.allowDataOverflow,_=N||j,S=Ut(p)?this.id:p,P=(r=Yt(o,!1))!==null&&r!==void 0?r:{r:3,strokeWidth:2},k=P.r,C=k===void 0?3:k,T=P.strokeWidth,O=T===void 0?2:T,L=Wge(o)?o:{},E=L.clipDot,R=E===void 0?!0:E,q=C*2+O;return ae.createElement(Hn,{className:w},N||j?ae.createElement("defs",null,ae.createElement("clipPath",{id:"clipPath-".concat(S)},ae.createElement("rect",{x:N?m:m-f/2,y:j?h:h-x/2,width:N?f:f*2,height:j?x:x*2})),!R&&ae.createElement("clipPath",{id:"clipPath-dots-".concat(S)},ae.createElement("rect",{x:m-q/2,y:h-q/2,width:f+q,height:x+q}))):null,!b&&this.renderCurve(_,S),this.renderErrorBar(_,S),(b||o)&&this.renderDots(_,R,S),(!g||v)&&dl.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(r,s){return r.animationId!==s.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,prevPoints:s.curPoints}:r.points!==s.curPoints?{curPoints:r.points}:null}},{key:"repeat",value:function(r,s){for(var i=r.length%2!==0?[].concat(wu(r),[0]):r,o=[],l=0;l<s;++l)o=[].concat(wu(o),wu(i));return o}},{key:"renderDotItem",value:function(r,s){var i;if(ae.isValidElement(r))i=ae.cloneElement(r,s);else if(Bt(r))i=r(s);else{var o=s.key,l=y$(s,vRe),c=Qt("recharts-line-dot",typeof r!="boolean"?r.className:"");i=ae.createElement(U2,Rf({key:o},l,{className:c}))}return i}}])}(y.PureComponent);Rs(jc,"displayName","Line");Rs(jc,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Qi.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});Rs(jc,"getComposedData",function(e){var t=e.props,n=e.xAxis,r=e.yAxis,s=e.xAxisTicks,i=e.yAxisTicks,o=e.dataKey,l=e.bandSize,c=e.displayedData,u=e.offset,d=t.layout,h=c.map(function(m,f){var x=Ua(m,o);return d==="horizontal"?{x:eD({axis:n,ticks:s,bandSize:l,entry:m,index:f}),y:Ut(x)?null:r.scale(x),value:x,payload:m}:{x:Ut(x)?null:n.scale(x),y:eD({axis:r,ticks:i,bandSize:l,entry:m,index:f}),value:x,payload:m}});return Oa({points:h,layout:d},u)});function Vd(e){"@babel/helpers - typeof";return Vd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vd(e)}function TRe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function MRe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,u9(r.key),r)}}function DRe(e,t,n){return t&&MRe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function $Re(e,t,n){return t=bv(t),RRe(e,l9()?Reflect.construct(t,n||[],bv(e).constructor):t.apply(e,n))}function RRe(e,t){if(t&&(Vd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return IRe(e)}function IRe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l9(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(l9=function(){return!!e})()}function bv(e){return bv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},bv(e)}function LRe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&YN(e,t)}function YN(e,t){return YN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},YN(e,t)}function c9(e,t,n){return t=u9(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u9(e){var t=FRe(e,"string");return Vd(t)=="symbol"?t:t+""}function FRe(e,t){if(Vd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Vd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function QN(){return QN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},QN.apply(this,arguments)}function qRe(e){var t=e.xAxisId,n=G2(),r=V2(),s=GU(t);return s==null?null:y.createElement(kh,QN({},s,{className:Qt("recharts-".concat(s.axisType," ").concat(s.axisType),s.className),viewBox:{x:0,y:0,width:n,height:r},ticksGenerator:function(o){return Wi(o,!0)}}))}var j0=function(e){function t(){return TRe(this,t),$Re(this,t,arguments)}return LRe(t,e),DRe(t,[{key:"render",value:function(){return y.createElement(qRe,this.props)}}])}(y.Component);c9(j0,"displayName","XAxis");c9(j0,"defaultProps",{allowDecimals:!0,hide:!1,orientation:"bottom",width:0,height:30,mirror:!1,xAxisId:0,tickCount:5,type:"category",padding:{left:0,right:0},allowDataOverflow:!1,scale:"auto",reversed:!1,allowDuplicatedCategory:!0});function Yd(e){"@babel/helpers - typeof";return Yd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yd(e)}function zRe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function BRe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,f9(r.key),r)}}function URe(e,t,n){return t&&BRe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function WRe(e,t,n){return t=wv(t),KRe(e,d9()?Reflect.construct(t,n||[],wv(e).constructor):t.apply(e,n))}function KRe(e,t){if(t&&(Yd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return HRe(e)}function HRe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d9(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(d9=function(){return!!e})()}function wv(e){return wv=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},wv(e)}function GRe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&XN(e,t)}function XN(e,t){return XN=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},XN(e,t)}function h9(e,t,n){return t=f9(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f9(e){var t=VRe(e,"string");return Yd(t)=="symbol"?t:t+""}function VRe(e,t){if(Yd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Yd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function JN(){return JN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},JN.apply(this,arguments)}var YRe=function(t){var n=t.yAxisId,r=G2(),s=V2(),i=VU(n);return i==null?null:y.createElement(kh,JN({},i,{className:Qt("recharts-".concat(i.axisType," ").concat(i.axisType),i.className),viewBox:{x:0,y:0,width:r,height:s},ticksGenerator:function(l){return Wi(l,!0)}}))},N0=function(e){function t(){return zRe(this,t),WRe(this,t,arguments)}return GRe(t,e),URe(t,[{key:"render",value:function(){return y.createElement(YRe,this.props)}}])}(y.Component);h9(N0,"displayName","YAxis");h9(N0,"defaultProps",{allowDuplicatedCategory:!0,allowDecimals:!0,hide:!1,orientation:"left",width:60,height:0,mirror:!1,yAxisId:0,tickCount:5,type:"number",padding:{top:0,bottom:0},allowDataOverflow:!1,scale:"auto",reversed:!1});function w$(e){return ZRe(e)||JRe(e)||XRe(e)||QRe()}function QRe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 906In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function XRe(e,t){if(e){if(typeof e=="string")return ZN(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ZN(e,t)}}function JRe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ZRe(e){if(Array.isArray(e))return ZN(e)}function ZN(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var eS=function(t,n,r,s,i){var o=us(t,Jm),l=us(t,Wp),c=[].concat(w$(o),w$(l)),u=us(t,_0),d="".concat(s,"Id"),h=s[0],m=n;if(c.length&&(m=c.reduce(function(g,p){if(p.props[d]===r&&bi(p.props,"extendDomain")&&Xe(p.props[h])){var v=p.props[h];return[Math.min(g[0],v),Math.max(g[1],v)]}return g},m)),u.length){var f="".concat(h,"1"),x="".concat(h,"2");m=u.reduce(function(g,p){if(p.props[d]===r&&bi(p.props,"extendDomain")&&Xe(p.props[f])&&Xe(p.props[x])){var v=p.props[f],b=p.props[x];return[Math.min(g[0],v,b),Math.max(g[1],v,b)]}return g},m)}return i&&i.length&&(m=i.reduce(function(g,p){return Xe(p)?[Math.min(g[0],p),Math.max(g[1],p)]:g},m)),m},m9={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function s(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function i(c,u,d,h,m){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new s(d,h||c,m),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],f]:c._events[x].push(f):(c._events[x]=f,c._eventsCount++),c}function o(c,u){--c._eventsCount===0?c._events=new r:delete c._events[u]}function l(){this._events=new r,this._eventsCount=0}l.prototype.eventNames=function(){var u=[],d,h;if(this._eventsCount===0)return u;for(h in d=this._events)t.call(d,h)&&u.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,h=this._events[d];if(!h)return[];if(h.fn)return[h.fn];for(var m=0,f=h.length,x=new Array(f);m<f;m++)x[m]=h[m].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,h=this._events[d];return h?h.fn?1:h.length:0},l.prototype.emit=function(u,d,h,m,f,x){var g=n?n+u:u;if(!this._events[g])return!1;var p=this._events[g],v=arguments.length,b,w;if(p.fn){switch(p.once&&this.removeListener(u,p.fn,void 0,!0),v){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,d),!0;case 3:return p.fn.call(p.context,d,h),!0;case 4:return p.fn.call(p.context,d,h,m),!0;case 5:return p.fn.call(p.context,d,h,m,f),!0;case 6:return p.fn.call(p.context,d,h,m,f,x),!0}for(w=1,b=new Array(v-1);w<v;w++)b[w-1]=arguments[w];p.fn.apply(p.context,b)}else{var N=p.length,j;for(w=0;w<N;w++)switch(p[w].once&&this.removeListener(u,p[w].fn,void 0,!0),v){case 1:p[w].fn.call(p[w].context);break;case 2:p[w].fn.call(p[w].context,d);break;case 3:p[w].fn.call(p[w].context,d,h);break;case 4:p[w].fn.call(p[w].context,d,h,m);break;default:if(!b)for(j=1,b=new Array(v-1);j<v;j++)b[j-1]=arguments[j];p[w].fn.apply(p[w].context,b)}}return!0},l.prototype.on=function(u,d,h){return i(this,u,d,h,!1)},l.prototype.once=function(u,d,h){return i(this,u,d,h,!0)},l.prototype.removeListener=function(u,d,h,m){var f=n?n+u:u;if(!this._events[f])return this;if(!d)return o(this,f),this;var x=this._events[f];if(x.fn)x.fn===d&&(!m||x.once)&&(!h||x.context===h)&&o(this,f);else{for(var g=0,p=[],v=x.length;g<v;g++)(x[g].fn!==d||m&&!x[g].once||h&&x[g].context!==h)&&p.push(x[g]);p.length?this._events[f]=p.length===1?p[0]:p:o(this,f)}return this},l.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=n,l.EventEmitter=l,e.exports=l})(m9);var eIe=m9.exports;const tIe=dn(eIe);var __=new tIe,j_="recharts.syncMouseEvents";function ep(e){"@babel/helpers - typeof";return ep=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ep(e)}function nIe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function rIe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,p9(r.key),r)}}function aIe(e,t,n){return t&&rIe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function N_(e,t,n){return t=p9(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p9(e){var t=sIe(e,"string");return ep(t)=="symbol"?t:t+""}function sIe(e,t){if(ep(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(ep(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var iIe=function(){function e(){nIe(this,e),N_(this,"activeIndex",0),N_(this,"coordinateList",[]),N_(this,"layout","horizontal")}return aIe(e,[{key:"setDetails",value:function(n){var r,s=n.coordinateList,i=s===void 0?null:s,o=n.container,l=o===void 0?null:o,c=n.layout,u=c===void 0?null:c,d=n.offset,h=d===void 0?null:d,m=n.mouseHandlerCallback,f=m===void 0?null:m;this.coordinateList=(r=i??this.coordinateList)!==null&&r!==void 0?r:[],this.container=l??this.container,this.layout=u??this.layout,this.offset=h??this.offset,this.mouseHandlerCallback=f??this.mouseHandlerCallback,this.activeIndex=Math.min(Math.max(this.activeIndex,0),this.coordinateList.length-1)}},{key:"focus",value:function(){this.spoofMouse()}},{key:"keyboardEvent",value:function(n){if(this.coordinateList.length!==0)switch(n.key){case"ArrowRight":{if(this.layout!=="horizontal")return;this.activeIndex=Math.min(this.activeIndex+1,this.coordinateList.length-1),this.spoofMouse();break}case"ArrowLeft":{if(this.layout!=="horizontal")return;this.activeIndex=Math.max(this.activeIndex-1,0),this.spoofMouse();break}}}},{key:"setIndex",value:function(n){this.activeIndex=n}},{key:"spoofMouse",value:function(){var n,r;if(this.layout==="horizontal"&&this.coordinateList.length!==0){var s=this.container.getBoundingClientRect(),i=s.x,o=s.y,l=s.height,c=this.coordinateList[this.activeIndex].coordinate,u=((n=window)===null||n===void 0?void 0:n.scrollX)||0,d=((r=window)===null||r===void 0?void 0:r.scrollY)||0,h=i+c+u,m=o+this.offset.top+l/2+d;this.mouseHandlerCallback({pageX:h,pageY:m})}}}])}();function oIe(e,t,n){if(n==="number"&&t===!0&&Array.isArray(e)){var r=e==null?void 0:e[0],s=e==null?void 0:e[1];if(r&&s&&Xe(r)&&Xe(s))return!0}return!1}function lIe(e,t,n,r){var s=r/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-s:n.left+.5,y:e==="horizontal"?n.top+.5:t.y-s,width:e==="horizontal"?r:n.width-1,height:e==="horizontal"?n.height-1:r}}function g9(e){var t=e.cx,n=e.cy,r=e.radius,s=e.startAngle,i=e.endAngle,o=Dr(t,n,r,s),l=Dr(t,n,r,i);return{points:[o,l],cx:t,cy:n,radius:r,startAngle:s,endAngle:i}}function cIe(e,t,n){var r,s,i,o;if(e==="horizontal")r=t.x,i=r,s=n.top,o=n.top+n.height;else if(e==="vertical")s=t.y,o=s,r=n.left,i=n.left+n.width;else if(t.cx!=null&&t.cy!=null)if(e==="centric"){var l=t.cx,c=t.cy,u=t.innerRadius,d=t.outerRadius,h=t.angle,m=Dr(l,c,u,h),f=Dr(l,c,d,h);r=m.x,s=m.y,i=f.x,o=f.y}else return g9(t);return[{x:r,y:s},{x:i,y:o}]}function tp(e){"@babel/helpers - typeof";return tp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tp(e)}function _$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).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?_$(Object(n),!0).forEach(function(r){uIe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function uIe(e,t,n){return t=dIe(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dIe(e){var t=hIe(e,"string");return tp(t)=="symbol"?t:t+""}function hIe(e,t){if(tp(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(tp(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function fIe(e){var t,n,r=e.element,s=e.tooltipEventType,i=e.isActive,o=e.activeCoordinate,l=e.activePayload,c=e.offset,u=e.activeTooltipIndex,d=e.tooltipAxisBandSize,h=e.layout,m=e.chartName,f=(t=r.props.cursor)!==null&&t!==void 0?t:(n=r.type.defaultProps)===null||n===void 0?void 0:n.cursor;if(!r||!f||!i||!o||m!=="ScatterChart"&&s!=="axis")return null;var x,g=SN;if(m==="ScatterChart")x=o,g=hTe;else if(m==="BarChart")x=lIe(h,o,c,d),g=B2;else if(h==="radial"){var p=g9(o),v=p.cx,b=p.cy,w=p.radius,N=p.startAngle,j=p.endAngle;x={cx:v,cy:b,startAngle:N,endAngle:j,innerRadius:w,outerRadius:w},g=vU}else x={points:cIe(h,o,c)},g=SN;var _=Yg(Yg(Yg(Yg({stroke:"#ccc",pointerEvents:"none"},c),x),Yt(f,!1)),{},{payload:l,payloadIndex:u,className:Qt("recharts-tooltip-cursor",f.className)});return y.isValidElement(f)?y.cloneElement(f,_):y.createElement(g,_)}var mIe=["item"],pIe=["children","className","width","height","style","compact","title","desc"];function Qd(e){"@babel/helpers - typeof";return Qd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qd(e)}function Wu(){return Wu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Wu.apply(this,arguments)}function j$(e,t){return yIe(e)||xIe(e,t)||y9(e,t)||gIe()}function gIe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 907In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xIe(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function yIe(e){if(Array.isArray(e))return e}function N$(e,t){if(e==null)return{};var n=vIe(e,t),r,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)r=i[s],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function vIe(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function bIe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wIe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,v9(r.key),r)}}function _Ie(e,t,n){return t&&wIe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function jIe(e,t,n){return t=_v(t),NIe(e,x9()?Reflect.construct(t,n||[],_v(e).constructor):t.apply(e,n))}function NIe(e,t){if(t&&(Qd(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return SIe(e)}function SIe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x9(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(x9=function(){return!!e})()}function _v(e){return _v=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},_v(e)}function CIe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&tS(e,t)}function tS(e,t){return tS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},tS(e,t)}function Xd(e){return PIe(e)||EIe(e)||y9(e)||kIe()}function kIe(){throw new TypeError(`Invalid attempt to spread non-iterable instance. 908In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function y9(e,t){if(e){if(typeof e=="string")return nS(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nS(e,t)}}function EIe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function PIe(e){if(Array.isArray(e))return nS(e)}function nS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function S$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function De(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?S$(Object(n),!0).forEach(function(r){bt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S$(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function bt(e,t,n){return t=v9(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v9(e){var t=OIe(e,"string");return Qd(t)=="symbol"?t:t+""}function OIe(e,t){if(Qd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Qd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var AIe={xAxis:["bottom","top"],yAxis:["left","right"]},TIe={width:"100%",height:"100%"},b9={x:0,y:0};function Qg(e){return e}var MIe=function(t,n){return n==="horizontal"?t.x:n==="vertical"?t.y:n==="centric"?t.angle:t.radius},DIe=function(t,n,r,s){var i=n.find(function(d){return d&&d.index===r});if(i){if(t==="horizontal")return{x:i.coordinate,y:s.y};if(t==="vertical")return{x:s.x,y:i.coordinate};if(t==="centric"){var o=i.coordinate,l=s.radius;return De(De(De({},s),Dr(s.cx,s.cy,l,o)),{},{angle:o,radius:l})}var c=i.coordinate,u=s.angle;return De(De(De({},s),Dr(s.cx,s.cy,c,u)),{},{angle:u,radius:c})}return b9},S0=function(t,n){var r=n.graphicalItems,s=n.dataStartIndex,i=n.dataEndIndex,o=(r??[]).reduce(function(l,c){var u=c.props.data;return u&&u.length?[].concat(Xd(l),Xd(u)):l},[]);return o.length>0?o:t&&t.length&&Xe(s)&&Xe(i)?t.slice(s,i+1):[]};function w9(e){return e==="number"?[0,"auto"]:void 0}var rS=function(t,n,r,s){var i=t.graphicalItems,o=t.tooltipAxis,l=S0(n,t);return r<0||!i||!i.length||r>=l.length?null:i.reduce(function(c,u){var d,h=(d=u.props.data)!==null&&d!==void 0?d:n;h&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(h=h.slice(t.dataStartIndex,t.dataEndIndex+1));var m;if(o.dataKey&&!o.allowDuplicatedCategory){var f=h===void 0?l:h;m=Ny(f,o.dataKey,s)}else m=h&&h[r]||l[r];return m?[].concat(Xd(c),[gU(u,m)]):c},[])},C$=function(t,n,r,s){var i=s||{x:t.chartX,y:t.chartY},o=MIe(i,r),l=t.orderedTooltipTicks,c=t.tooltipAxis,u=t.tooltipTicks,d=VEe(o,l,u,c);if(d>=0&&u){var h=u[d]&&u[d].value,m=rS(t,n,d,h),f=DIe(r,l,d,i);return{activeTooltipIndex:d,activeLabel:h,activePayload:m,activeCoordinate:f}}return null},$Ie=function(t,n){var r=n.axes,s=n.graphicalItems,i=n.axisType,o=n.axisIdKey,l=n.stackGroups,c=n.dataStartIndex,u=n.dataEndIndex,d=t.layout,h=t.children,m=t.stackOffset,f=fU(d,i);return r.reduce(function(x,g){var p,v=g.type.defaultProps!==void 0?De(De({},g.type.defaultProps),g.props):g.props,b=v.type,w=v.dataKey,N=v.allowDataOverflow,j=v.allowDuplicatedCategory,_=v.scale,S=v.ticks,P=v.includeHidden,k=v[o];if(x[k])return x;var C=S0(t.data,{graphicalItems:s.filter(function(A){var K,G=o in A.props?A.props[o]:(K=A.type.defaultProps)===null||K===void 0?void 0:K[o];return G===k}),dataStartIndex:c,dataEndIndex:u}),T=C.length,O,L,E;oIe(v.domain,N,b)&&(O=bN(v.domain,null,N),f&&(b==="number"||_!=="auto")&&(E=Df(C,w,"category")));var R=w9(b);if(!O||O.length===0){var q,I=(q=v.domain)!==null&&q!==void 0?q:R;if(w){if(O=Df(C,w,b),b==="category"&&f){var $=Dge(O);j&&$?(L=O,O=cv(0,T)):j||(O=aD(I,O,g).reduce(function(A,K){return A.indexOf(K)>=0?A:[].concat(Xd(A),[K])},[]))}else if(b==="category")j?O=O.filter(function(A){return A!==""&&!Ut(A)}):O=aD(I,O,g).reduce(function(A,K){return A.indexOf(K)>=0||K===""||Ut(K)?A:[].concat(Xd(A),[K])},[]);else if(b==="number"){var M=ZEe(C,s.filter(function(A){var K,G,H=o in A.props?A.props[o]:(K=A.type.defaultProps)===null||K===void 0?void 0:K[o],fe="hide"in A.props?A.props.hide:(G=A.type.defaultProps)===null||G===void 0?void 0:G.hide;return H===k&&(P||!fe)}),w,i,d);M&&(O=M)}f&&(b==="number"||_!=="auto")&&(E=Df(C,w,"category"))}else f?O=cv(0,T):l&&l[k]&&l[k].hasStack&&b==="number"?O=m==="expand"?[0,1]:pU(l[k].stackGroups,c,u):O=hU(C,s.filter(function(A){var K=o in A.props?A.props[o]:A.type.defaultProps[o],G="hide"in A.props?A.props.hide:A.type.defaultProps.hide;return K===k&&(P||!G)}),b,d,!0);if(b==="number")O=eS(h,O,k,i,S),I&&(O=bN(I,O,N));else if(b==="category"&&I){var B=I,W=O.every(function(A){return B.indexOf(A)>=0});W&&(O=B)}}return De(De({},x),{},bt({},k,De(De({},v),{},{axisType:i,domain:O,categoricalDomain:E,duplicateDomain:L,originalDomain:(p=v.domain)!==null&&p!==void 0?p:R,isCategorical:f,layout:d})))},{})},RIe=function(t,n){var r=n.graphicalItems,s=n.Axis,i=n.axisType,o=n.axisIdKey,l=n.stackGroups,c=n.dataStartIndex,u=n.dataEndIndex,d=t.layout,h=t.children,m=S0(t.data,{graphicalItems:r,dataStartIndex:c,dataEndIndex:u}),f=m.length,x=fU(d,i),g=-1;return r.reduce(function(p,v){var b=v.type.defaultProps!==void 0?De(De({},v.type.defaultProps),v.props):v.props,w=b[o],N=w9("number");if(!p[w]){g++;var j;return x?j=cv(0,f):l&&l[w]&&l[w].hasStack?(j=pU(l[w].stackGroups,c,u),j=eS(h,j,w,i)):(j=bN(N,hU(m,r.filter(function(_){var S,P,k=o in _.props?_.props[o]:(S=_.type.defaultProps)===null||S===void 0?void 0:S[o],C="hide"in _.props?_.props.hide:(P=_.type.defaultProps)===null||P===void 0?void 0:P.hide;return k===w&&!C}),"number",d),s.defaultProps.allowDataOverflow),j=eS(h,j,w,i)),De(De({},p),{},bt({},w,De(De({axisType:i},s.defaultProps),{},{hide:!0,orientation:cs(AIe,"".concat(i,".").concat(g%2),null),domain:j,originalDomain:N,isCategorical:x,layout:d})))}return p},{})},IIe=function(t,n){var r=n.axisType,s=r===void 0?"xAxis":r,i=n.AxisComp,o=n.graphicalItems,l=n.stackGroups,c=n.dataStartIndex,u=n.dataEndIndex,d=t.children,h="".concat(s,"Id"),m=us(d,i),f={};return m&&m.length?f=$Ie(t,{axes:m,graphicalItems:o,axisType:s,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:u}):o&&o.length&&(f=RIe(t,{Axis:i,graphicalItems:o,axisType:s,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:u})),f},LIe=function(t){var n=Io(t),r=Wi(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:p2(r,function(s){return s.coordinate}),tooltipAxis:n,tooltipAxisBandSize:ev(n,r)}},k$=function(t){var n=t.children,r=t.defaultShowTooltip,s=Ma(n,zd),i=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),s&&s.props&&(s.props.startIndex>=0&&(i=s.props.startIndex),s.props.endIndex>=0&&(o=s.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!r}},FIe=function(t){return!t||!t.length?!1:t.some(function(n){var r=Vi(n&&n.type);return r&&r.indexOf("Bar")>=0})},E$=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},qIe=function(t,n){var r=t.props,s=t.graphicalItems,i=t.xAxisMap,o=i===void 0?{}:i,l=t.yAxisMap,c=l===void 0?{}:l,u=r.width,d=r.height,h=r.children,m=r.margin||{},f=Ma(h,zd),x=Ma(h,bc),g=Object.keys(c).reduce(function(j,_){var S=c[_],P=S.orientation;return!S.mirror&&!S.hide?De(De({},j),{},bt({},P,j[P]+S.width)):j},{left:m.left||0,right:m.right||0}),p=Object.keys(o).reduce(function(j,_){var S=o[_],P=S.orientation;return!S.mirror&&!S.hide?De(De({},j),{},bt({},P,cs(j,"".concat(P))+S.height)):j},{top:m.top||0,bottom:m.bottom||0}),v=De(De({},p),g),b=v.bottom;f&&(v.bottom+=f.props.height||zd.defaultProps.height),x&&n&&(v=XEe(v,s,r,n));var w=u-v.left-v.right,N=d-v.top-v.bottom;return De(De({brushBottom:b},v),{},{width:Math.max(w,0),height:Math.max(N,0)})},zIe=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},BIe=function(t){var n=t.chartName,r=t.GraphicalChild,s=t.defaultTooltipEventType,i=s===void 0?"axis":s,o=t.validateTooltipEventTypes,l=o===void 0?["axis"]:o,c=t.axisComponents,u=t.legendContent,d=t.formatAxisMap,h=t.defaultProps,m=function(v,b){var w=b.graphicalItems,N=b.stackGroups,j=b.offset,_=b.updateId,S=b.dataStartIndex,P=b.dataEndIndex,k=v.barSize,C=v.layout,T=v.barGap,O=v.barCategoryGap,L=v.maxBarSize,E=E$(C),R=E.numericAxisName,q=E.cateAxisName,I=FIe(w),$=[];return w.forEach(function(M,B){var W=S0(v.data,{graphicalItems:[M],dataStartIndex:S,dataEndIndex:P}),A=M.type.defaultProps!==void 0?De(De({},M.type.defaultProps),M.props):M.props,K=A.dataKey,G=A.maxBarSize,H=A["".concat(R,"Id")],fe=A["".concat(q,"Id")],te={},J=c.reduce(function(ee,de){var je=b["".concat(de.axisType,"Map")],Q=A["".concat(de.axisType,"Id")];je&&je[Q]||de.axisType==="zAxis"||zc();var oe=je[Q];return De(De({},ee),{},bt(bt({},de.axisType,oe),"".concat(de.axisType,"Ticks"),Wi(oe)))},te),re=J[q],pe=J["".concat(q,"Ticks")],ye=N&&N[H]&&N[H].hasStack&&dPe(M,N[H].stackGroups),X=Vi(M.type).indexOf("Bar")>=0,he=ev(re,pe),D=[],le=I&&YEe({barSize:k,stackGroups:N,totalSize:zIe(J,q)});if(X){var V,U,z=Ut(G)?L:G,Z=(V=(U=ev(re,pe,!0))!==null&&U!==void 0?U:z)!==null&&V!==void 0?V:0;D=QEe({barGap:T,barCategoryGap:O,bandSize:Z!==he?Z:he,sizeList:le[fe],maxBarSize:z}),Z!==he&&(D=D.map(function(ee){return De(De({},ee),{},{position:De(De({},ee.position),{},{offset:ee.position.offset-Z/2})})}))}var ve=M&&M.type&&M.type.getComposedData;ve&&$.push({props:De(De({},ve(De(De({},J),{},{displayedData:W,props:v,dataKey:K,item:M,bandSize:he,barPosition:D,offset:j,stackedData:ye,layout:C,dataStartIndex:S,dataEndIndex:P}))),{},bt(bt(bt({key:M.key||"item-".concat(B)},R,J[R]),q,J[q]),"animationId",_)),childIndex:Gge(M,v.children),item:M})}),$},f=function(v,b){var w=v.props,N=v.dataStartIndex,j=v.dataEndIndex,_=v.updateId;if(!XA({props:w}))return null;var S=w.children,P=w.layout,k=w.stackOffset,C=w.data,T=w.reverseStackOrder,O=E$(P),L=O.numericAxisName,E=O.cateAxisName,R=us(S,r),q=lPe(C,R,"".concat(L,"Id"),"".concat(E,"Id"),k,T),I=c.reduce(function(A,K){var G="".concat(K.axisType,"Map");return De(De({},A),{},bt({},G,IIe(w,De(De({},K),{},{graphicalItems:R,stackGroups:K.axisType===L&&q,dataStartIndex:N,dataEndIndex:j}))))},{}),$=qIe(De(De({},I),{},{props:w,graphicalItems:R}),b==null?void 0:b.legendBBox);Object.keys(I).forEach(function(A){I[A]=d(w,I[A],$,A.replace("Map",""),n)});var M=I["".concat(E,"Map")],B=LIe(M),W=m(w,De(De({},I),{},{dataStartIndex:N,dataEndIndex:j,updateId:_,graphicalItems:R,stackGroups:q,offset:$}));return De(De({formattedGraphicalItems:W,graphicalItems:R,offset:$,stackGroups:q},B),I)},x=function(p){function v(b){var w,N,j;return bIe(this,v),j=jIe(this,v,[b]),bt(j,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),bt(j,"accessibilityManager",new iIe),bt(j,"handleLegendBBoxUpdate",function(_){if(_){var S=j.state,P=S.dataStartIndex,k=S.dataEndIndex,C=S.updateId;j.setState(De({legendBBox:_},f({props:j.props,dataStartIndex:P,dataEndIndex:k,updateId:C},De(De({},j.state),{},{legendBBox:_}))))}}),bt(j,"handleReceiveSyncEvent",function(_,S,P){if(j.props.syncId===_){if(P===j.eventEmitterSymbol&&typeof j.props.syncMethod!="function")return;j.applySyncEvent(S)}}),bt(j,"handleBrushChange",function(_){var S=_.startIndex,P=_.endIndex;if(S!==j.state.dataStartIndex||P!==j.state.dataEndIndex){var k=j.state.updateId;j.setState(function(){return De({dataStartIndex:S,dataEndIndex:P},f({props:j.props,dataStartIndex:S,dataEndIndex:P,updateId:k},j.state))}),j.triggerSyncEvent({dataStartIndex:S,dataEndIndex:P})}}),bt(j,"handleMouseEnter",function(_){var S=j.getMouseInfo(_);if(S){var P=De(De({},S),{},{isTooltipActive:!0});j.setState(P),j.triggerSyncEvent(P);var k=j.props.onMouseEnter;Bt(k)&&k(P,_)}}),bt(j,"triggeredAfterMouseMove",function(_){var S=j.getMouseInfo(_),P=S?De(De({},S),{},{isTooltipActive:!0}):{isTooltipActive:!1};j.setState(P),j.triggerSyncEvent(P);var k=j.props.onMouseMove;Bt(k)&&k(P,_)}),bt(j,"handleItemMouseEnter",function(_){j.setState(function(){return{isTooltipActive:!0,activeItem:_,activePayload:_.tooltipPayload,activeCoordinate:_.tooltipPosition||{x:_.cx,y:_.cy}}})}),bt(j,"handleItemMouseLeave",function(){j.setState(function(){return{isTooltipActive:!1}})}),bt(j,"handleMouseMove",function(_){_.persist(),j.throttleTriggeredAfterMouseMove(_)}),bt(j,"handleMouseLeave",function(_){j.throttleTriggeredAfterMouseMove.cancel();var S={isTooltipActive:!1};j.setState(S),j.triggerSyncEvent(S);var P=j.props.onMouseLeave;Bt(P)&&P(S,_)}),bt(j,"handleOuterEvent",function(_){var S=Hge(_),P=cs(j.props,"".concat(S));if(S&&Bt(P)){var k,C;/.*touch.*/i.test(S)?C=j.getMouseInfo(_.changedTouches[0]):C=j.getMouseInfo(_),P((k=C)!==null&&k!==void 0?k:{},_)}}),bt(j,"handleClick",function(_){var S=j.getMouseInfo(_);if(S){var P=De(De({},S),{},{isTooltipActive:!0});j.setState(P),j.triggerSyncEvent(P);var k=j.props.onClick;Bt(k)&&k(P,_)}}),bt(j,"handleMouseDown",function(_){var S=j.props.onMouseDown;if(Bt(S)){var P=j.getMouseInfo(_);S(P,_)}}),bt(j,"handleMouseUp",function(_){var S=j.props.onMouseUp;if(Bt(S)){var P=j.getMouseInfo(_);S(P,_)}}),bt(j,"handleTouchMove",function(_){_.changedTouches!=null&&_.changedTouches.length>0&&j.throttleTriggeredAfterMouseMove(_.changedTouches[0])}),bt(j,"handleTouchStart",function(_){_.changedTouches!=null&&_.changedTouches.length>0&&j.handleMouseDown(_.changedTouches[0])}),bt(j,"handleTouchEnd",function(_){_.changedTouches!=null&&_.changedTouches.length>0&&j.handleMouseUp(_.changedTouches[0])}),bt(j,"handleDoubleClick",function(_){var S=j.props.onDoubleClick;if(Bt(S)){var P=j.getMouseInfo(_);S(P,_)}}),bt(j,"handleContextMenu",function(_){var S=j.props.onContextMenu;if(Bt(S)){var P=j.getMouseInfo(_);S(P,_)}}),bt(j,"triggerSyncEvent",function(_){j.props.syncId!==void 0&&__.emit(j_,j.props.syncId,_,j.eventEmitterSymbol)}),bt(j,"applySyncEvent",function(_){var S=j.props,P=S.layout,k=S.syncMethod,C=j.state.updateId,T=_.dataStartIndex,O=_.dataEndIndex;if(_.dataStartIndex!==void 0||_.dataEndIndex!==void 0)j.setState(De({dataStartIndex:T,dataEndIndex:O},f({props:j.props,dataStartIndex:T,dataEndIndex:O,updateId:C},j.state)));else if(_.activeTooltipIndex!==void 0){var L=_.chartX,E=_.chartY,R=_.activeTooltipIndex,q=j.state,I=q.offset,$=q.tooltipTicks;if(!I)return;if(typeof k=="function")R=k($,_);else if(k==="value"){R=-1;for(var M=0;M<$.length;M++)if($[M].value===_.activeLabel){R=M;break}}var B=De(De({},I),{},{x:I.left,y:I.top}),W=Math.min(L,B.x+B.width),A=Math.min(E,B.y+B.height),K=$[R]&&$[R].value,G=rS(j.state,j.props.data,R),H=$[R]?{x:P==="horizontal"?$[R].coordinate:W,y:P==="horizontal"?A:$[R].coordinate}:b9;j.setState(De(De({},_),{},{activeLabel:K,activeCoordinate:H,activePayload:G,activeTooltipIndex:R}))}else j.setState(_)}),bt(j,"renderCursor",function(_){var S,P=j.state,k=P.isTooltipActive,C=P.activeCoordinate,T=P.activePayload,O=P.offset,L=P.activeTooltipIndex,E=P.tooltipAxisBandSize,R=j.getTooltipEventType(),q=(S=_.props.active)!==null&&S!==void 0?S:k,I=j.props.layout,$=_.key||"_recharts-cursor";return ae.createElement(fIe,{key:$,activeCoordinate:C,activePayload:T,activeTooltipIndex:L,chartName:n,element:_,isActive:q,layout:I,offset:O,tooltipAxisBandSize:E,tooltipEventType:R})}),bt(j,"renderPolarAxis",function(_,S,P){var k=cs(_,"type.axisType"),C=cs(j.state,"".concat(k,"Map")),T=_.type.defaultProps,O=T!==void 0?De(De({},T),_.props):_.props,L=C&&C[O["".concat(k,"Id")]];return y.cloneElement(_,De(De({},L),{},{className:Qt(k,L.className),key:_.key||"".concat(S,"-").concat(P),ticks:Wi(L,!0)}))}),bt(j,"renderPolarGrid",function(_){var S=_.props,P=S.radialLines,k=S.polarAngles,C=S.polarRadius,T=j.state,O=T.radiusAxisMap,L=T.angleAxisMap,E=Io(O),R=Io(L),q=R.cx,I=R.cy,$=R.innerRadius,M=R.outerRadius;return y.cloneElement(_,{polarAngles:Array.isArray(k)?k:Wi(R,!0).map(function(B){return B.coordinate}),polarRadius:Array.isArray(C)?C:Wi(E,!0).map(function(B){return B.coordinate}),cx:q,cy:I,innerRadius:$,outerRadius:M,key:_.key||"polar-grid",radialLines:P})}),bt(j,"renderLegend",function(){var _=j.state.formattedGraphicalItems,S=j.props,P=S.children,k=S.width,C=S.height,T=j.props.margin||{},O=k-(T.left||0)-(T.right||0),L=uU({children:P,formattedGraphicalItems:_,legendWidth:O,legendContent:u});if(!L)return null;var E=L.item,R=N$(L,mIe);return y.cloneElement(E,De(De({},R),{},{chartWidth:k,chartHeight:C,margin:T,onBBoxUpdate:j.handleLegendBBoxUpdate}))}),bt(j,"renderTooltip",function(){var _,S=j.props,P=S.children,k=S.accessibilityLayer,C=Ma(P,ii);if(!C)return null;var T=j.state,O=T.isTooltipActive,L=T.activeCoordinate,E=T.activePayload,R=T.activeLabel,q=T.offset,I=(_=C.props.active)!==null&&_!==void 0?_:O;return y.cloneElement(C,{viewBox:De(De({},q),{},{x:q.left,y:q.top}),active:I,label:R,payload:I?E:[],coordinate:L,accessibilityLayer:k})}),bt(j,"renderBrush",function(_){var S=j.props,P=S.margin,k=S.data,C=j.state,T=C.offset,O=C.dataStartIndex,L=C.dataEndIndex,E=C.updateId;return y.cloneElement(_,{key:_.key||"_recharts-brush",onChange:Kg(j.handleBrushChange,_.props.onChange),data:k,x:Xe(_.props.x)?_.props.x:T.left,y:Xe(_.props.y)?_.props.y:T.top+T.height+T.brushBottom-(P.bottom||0),width:Xe(_.props.width)?_.props.width:T.width,startIndex:O,endIndex:L,updateId:"brush-".concat(E)})}),bt(j,"renderReferenceElement",function(_,S,P){if(!_)return null;var k=j,C=k.clipPathId,T=j.state,O=T.xAxisMap,L=T.yAxisMap,E=T.offset,R=_.type.defaultProps||{},q=_.props,I=q.xAxisId,$=I===void 0?R.xAxisId:I,M=q.yAxisId,B=M===void 0?R.yAxisId:M;return y.cloneElement(_,{key:_.key||"".concat(S,"-").concat(P),xAxis:O[$],yAxis:L[B],viewBox:{x:E.left,y:E.top,width:E.width,height:E.height},clipPathId:C})}),bt(j,"renderActivePoints",function(_){var S=_.item,P=_.activePoint,k=_.basePoint,C=_.childIndex,T=_.isRange,O=[],L=S.props.key,E=S.item.type.defaultProps!==void 0?De(De({},S.item.type.defaultProps),S.item.props):S.item.props,R=E.activeDot,q=E.dataKey,I=De(De({index:C,dataKey:q,cx:P.x,cy:P.y,r:4,fill:z2(S.item),strokeWidth:2,stroke:"#fff",payload:P.payload,value:P.value},Yt(R,!1)),Sy(R));return O.push(v.renderActiveDot(R,I,"".concat(L,"-activePoint-").concat(C))),k?O.push(v.renderActiveDot(R,De(De({},I),{},{cx:k.x,cy:k.y}),"".concat(L,"-basePoint-").concat(C))):T&&O.push(null),O}),bt(j,"renderGraphicChild",function(_,S,P){var k=j.filterFormatItem(_,S,P);if(!k)return null;var C=j.getTooltipEventType(),T=j.state,O=T.isTooltipActive,L=T.tooltipAxis,E=T.activeTooltipIndex,R=T.activeLabel,q=j.props.children,I=Ma(q,ii),$=k.props,M=$.points,B=$.isRange,W=$.baseLine,A=k.item.type.defaultProps!==void 0?De(De({},k.item.type.defaultProps),k.item.props):k.item.props,K=A.activeDot,G=A.hide,H=A.activeBar,fe=A.activeShape,te=!!(!G&&O&&I&&(K||H||fe)),J={};C!=="axis"&&I&&I.props.trigger==="click"?J={onClick:Kg(j.handleItemMouseEnter,_.props.onClick)}:C!=="axis"&&(J={onMouseLeave:Kg(j.handleItemMouseLeave,_.props.onMouseLeave),onMouseEnter:Kg(j.handleItemMouseEnter,_.props.onMouseEnter)});var re=y.cloneElement(_,De(De({},k.props),J));function pe(de){return typeof L.dataKey=="function"?L.dataKey(de.payload):null}if(te)if(E>=0){var ye,X;if(L.dataKey&&!L.allowDuplicatedCategory){var he=typeof L.dataKey=="function"?pe:"payload.".concat(L.dataKey.toString());ye=Ny(M,he,R),X=B&&W&&Ny(W,he,R)}else ye=M==null?void 0:M[E],X=B&&W&&W[E];if(fe||H){var D=_.props.activeIndex!==void 0?_.props.activeIndex:E;return[y.cloneElement(_,De(De(De({},k.props),J),{},{activeIndex:D})),null,null]}if(!Ut(ye))return[re].concat(Xd(j.renderActivePoints({item:k,activePoint:ye,basePoint:X,childIndex:E,isRange:B})))}else{var le,V=(le=j.getItemByXY(j.state.activeCoordinate))!==null&&le!==void 0?le:{graphicalItem:re},U=V.graphicalItem,z=U.item,Z=z===void 0?_:z,ve=U.childIndex,ee=De(De(De({},k.props),J),{},{activeIndex:ve});return[y.cloneElement(Z,ee),null,null]}return B?[re,null,null]:[re,null]}),bt(j,"renderCustomized",function(_,S,P){return y.cloneElement(_,De(De({key:"recharts-customized-".concat(P)},j.props),j.state))}),bt(j,"renderMap",{CartesianGrid:{handler:Qg,once:!0},ReferenceArea:{handler:j.renderReferenceElement},ReferenceLine:{handler:Qg},ReferenceDot:{handler:j.renderReferenceElement},XAxis:{handler:Qg},YAxis:{handler:Qg},Brush:{handler:j.renderBrush,once:!0},Bar:{handler:j.renderGraphicChild},Line:{handler:j.renderGraphicChild},Area:{handler:j.renderGraphicChild},Radar:{handler:j.renderGraphicChild},RadialBar:{handler:j.renderGraphicChild},Scatter:{handler:j.renderGraphicChild},Pie:{handler:j.renderGraphicChild},Funnel:{handler:j.renderGraphicChild},Tooltip:{handler:j.renderCursor,once:!0},PolarGrid:{handler:j.renderPolarGrid,once:!0},PolarAngleAxis:{handler:j.renderPolarAxis},PolarRadiusAxis:{handler:j.renderPolarAxis},Customized:{handler:j.renderCustomized}}),j.clipPathId="".concat((w=b.id)!==null&&w!==void 0?w:Rp("recharts"),"-clip"),j.throttleTriggeredAfterMouseMove=cB(j.triggeredAfterMouseMove,(N=b.throttleDelay)!==null&&N!==void 0?N:1e3/60),j.state={},j}return CIe(v,p),_Ie(v,[{key:"componentDidMount",value:function(){var w,N;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(w=this.props.margin.left)!==null&&w!==void 0?w:0,top:(N=this.props.margin.top)!==null&&N!==void 0?N:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var w=this.props,N=w.children,j=w.data,_=w.height,S=w.layout,P=Ma(N,ii);if(P){var k=P.props.defaultIndex;if(!(typeof k!="number"||k<0||k>this.state.tooltipTicks.length-1)){var C=this.state.tooltipTicks[k]&&this.state.tooltipTicks[k].value,T=rS(this.state,j,k,C),O=this.state.tooltipTicks[k].coordinate,L=(this.state.offset.top+_)/2,E=S==="horizontal",R=E?{x:O,y:L}:{y:O,x:L},q=this.state.formattedGraphicalItems.find(function($){var M=$.item;return M.type.name==="Scatter"});q&&(R=De(De({},R),q.props.points[k].tooltipPosition),T=q.props.points[k].tooltipPayload);var I={activeTooltipIndex:k,isTooltipActive:!0,activeLabel:C,activePayload:T,activeCoordinate:R};this.setState(I),this.renderCursor(P),this.accessibilityManager.setIndex(k)}}}},{key:"getSnapshotBeforeUpdate",value:function(w,N){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==N.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==w.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==w.margin){var j,_;this.accessibilityManager.setDetails({offset:{left:(j=this.props.margin.left)!==null&&j!==void 0?j:0,top:(_=this.props.margin.top)!==null&&_!==void 0?_:0}})}return null}},{key:"componentDidUpdate",value:function(w){$1([Ma(w.children,ii)],[Ma(this.props.children,ii)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var w=Ma(this.props.children,ii);if(w&&typeof w.props.shared=="boolean"){var N=w.props.shared?"axis":"item";return l.indexOf(N)>=0?N:i}return i}},{key:"getMouseInfo",value:function(w){if(!this.container)return null;var N=this.container,j=N.getBoundingClientRect(),_=bSe(j),S={chartX:Math.round(w.pageX-_.left),chartY:Math.round(w.pageY-_.top)},P=j.width/N.offsetWidth||1,k=this.inRange(S.chartX,S.chartY,P);if(!k)return null;var C=this.state,T=C.xAxisMap,O=C.yAxisMap,L=this.getTooltipEventType(),E=C$(this.state,this.props.data,this.props.layout,k);if(L!=="axis"&&T&&O){var R=Io(T).scale,q=Io(O).scale,I=R&&R.invert?R.invert(S.chartX):null,$=q&&q.invert?q.invert(S.chartY):null;return De(De({},S),{},{xValue:I,yValue:$},E)}return E?De(De({},S),E):null}},{key:"inRange",value:function(w,N){var j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,_=this.props.layout,S=w/j,P=N/j;if(_==="horizontal"||_==="vertical"){var k=this.state.offset,C=S>=k.left&&S<=k.left+k.width&&P>=k.top&&P<=k.top+k.height;return C?{x:S,y:P}:null}var T=this.state,O=T.angleAxisMap,L=T.radiusAxisMap;if(O&&L){var E=Io(O);return oD({x:S,y:P},E)}return null}},{key:"parseEventsOfWrapper",value:function(){var w=this.props.children,N=this.getTooltipEventType(),j=Ma(w,ii),_={};j&&N==="axis"&&(j.props.trigger==="click"?_={onClick:this.handleClick}:_={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var S=Sy(this.props,this.handleOuterEvent);return De(De({},S),_)}},{key:"addListener",value:function(){__.on(j_,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){__.removeListener(j_,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(w,N,j){for(var _=this.state.formattedGraphicalItems,S=0,P=_.length;S<P;S++){var k=_[S];if(k.item===w||k.props.key===w.key||N===Vi(k.item.type)&&j===k.childIndex)return k}return null}},{key:"renderClipPath",value:function(){var w=this.clipPathId,N=this.state.offset,j=N.left,_=N.top,S=N.height,P=N.width;return ae.createElement("defs",null,ae.createElement("clipPath",{id:w},ae.createElement("rect",{x:j,y:_,height:S,width:P})))}},{key:"getXScales",value:function(){var w=this.state.xAxisMap;return w?Object.entries(w).reduce(function(N,j){var _=j$(j,2),S=_[0],P=_[1];return De(De({},N),{},bt({},S,P.scale))},{}):null}},{key:"getYScales",value:function(){var w=this.state.yAxisMap;return w?Object.entries(w).reduce(function(N,j){var _=j$(j,2),S=_[0],P=_[1];return De(De({},N),{},bt({},S,P.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(w){var N;return(N=this.state.xAxisMap)===null||N===void 0||(N=N[w])===null||N===void 0?void 0:N.scale}},{key:"getYScaleByAxisId",value:function(w){var N;return(N=this.state.yAxisMap)===null||N===void 0||(N=N[w])===null||N===void 0?void 0:N.scale}},{key:"getItemByXY",value:function(w){var N=this.state,j=N.formattedGraphicalItems,_=N.activeItem;if(j&&j.length)for(var S=0,P=j.length;S<P;S++){var k=j[S],C=k.props,T=k.item,O=T.type.defaultProps!==void 0?De(De({},T.type.defaultProps),T.props):T.props,L=Vi(T.type);if(L==="Bar"){var E=(C.data||[]).find(function($){return nTe(w,$)});if(E)return{graphicalItem:k,payload:E}}else if(L==="RadialBar"){var R=(C.data||[]).find(function($){return oD(w,$)});if(R)return{graphicalItem:k,payload:R}}else if(x0(k,_)||y0(k,_)||Vm(k,_)){var q=sMe({graphicalItem:k,activeTooltipItem:_,itemData:O.data}),I=O.activeIndex===void 0?q:O.activeIndex;return{graphicalItem:De(De({},k),{},{childIndex:I}),payload:Vm(k,_)?O.data[q]:k.props.data[q]}}}return null}},{key:"render",value:function(){var w=this;if(!XA(this))return null;var N=this.props,j=N.children,_=N.className,S=N.width,P=N.height,k=N.style,C=N.compact,T=N.title,O=N.desc,L=N$(N,pIe),E=Yt(L,!1);if(C)return ae.createElement(s$,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},ae.createElement(I1,Wu({},E,{width:S,height:P,title:T,desc:O}),this.renderClipPath(),ZA(j,this.renderMap)));if(this.props.accessibilityLayer){var R,q;E.tabIndex=(R=this.props.tabIndex)!==null&&R!==void 0?R:0,E.role=(q=this.props.role)!==null&&q!==void 0?q:"application",E.onKeyDown=function($){w.accessibilityManager.keyboardEvent($)},E.onFocus=function(){w.accessibilityManager.focus()}}var I=this.parseEventsOfWrapper();return ae.createElement(s$,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},ae.createElement("div",Wu({className:Qt("recharts-wrapper",_),style:De({position:"relative",curs
908or:"default",width:S,height:P},k)},I,{ref:function(M){w.container=M}}),ae.createElement(I1,Wu({},E,{width:S,height:P,title:T,desc:O,style:TIe}),this.renderClipPath(),ZA(j,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(y.Component);bt(x,"displayName",n),bt(x,"defaultProps",De({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},h)),bt(x,"getDerivedStateFromProps",function(p,v){var b=p.dataKey,w=p.data,N=p.children,j=p.width,_=p.height,S=p.layout,P=p.stackOffset,k=p.margin,C=v.dataStartIndex,T=v.dataEndIndex;if(v.updateId===void 0){var O=k$(p);return De(De(De({},O),{},{updateId:0},f(De(De({props:p},O),{},{updateId:0}),v)),{},{prevDataKey:b,prevData:w,prevWidth:j,prevHeight:_,prevLayout:S,prevStackOffset:P,prevMargin:k,prevChildren:N})}if(b!==v.prevDataKey||w!==v.prevData||j!==v.prevWidth||_!==v.prevHeight||S!==v.prevLayout||P!==v.prevStackOffset||!rd(k,v.prevMargin)){var L=k$(p),E={chartX:v.chartX,chartY:v.chartY,isTooltipActive:v.isTooltipActive},R=De(De({},C$(v,w,S)),{},{updateId:v.updateId+1}),q=De(De(De({},L),E),R);return De(De(De({},q),f(De({props:p},q),v)),{},{prevDataKey:b,prevData:w,prevWidth:j,prevHeight:_,prevLayout:S,prevStackOffset:P,prevMargin:k,prevChildren:N})}if(!$1(N,v.prevChildren)){var I,$,M,B,W=Ma(N,zd),A=W&&(I=($=W.props)===null||$===void 0?void 0:$.startIndex)!==null&&I!==void 0?I:C,K=W&&(M=(B=W.props)===null||B===void 0?void 0:B.endIndex)!==null&&M!==void 0?M:T,G=A!==C||K!==T,H=!Ut(w),fe=H&&!G?v.updateId:v.updateId+1;return De(De({updateId:fe},f(De(De({props:p},v),{},{updateId:fe,dataStartIndex:A,dataEndIndex:K}),v)),{},{prevChildren:N,dataStartIndex:A,dataEndIndex:K})}return null}),bt(x,"renderActiveDot",function(p,v,b){var w;return y.isValidElement(p)?w=y.cloneElement(p,v):Bt(p)?w=p(v):w=ae.createElement(U2,v),ae.createElement(Hn,{className:"recharts-active-dot",key:b},w)});var g=y.forwardRef(function(v,b){return ae.createElement(x,Wu({},v,{ref:b}))});return g.displayName=x.displayName,g},UIe=BIe({chartName:"LineChart",GraphicalChild:jc,axisComponents:[{axisType:"xAxis",AxisComp:j0},{axisType:"yAxis",AxisComp:N0}],formatAxisMap:ODe});const ai=e=>(e??0).toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),S_=e=>yo(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});function WIe({model:e,isLoading:t,startingCash:n,asOf:r,today:s,monthStart:i,expNames:o}){const l=(e==null?void 0:e.events.filter(x=>x.scope.c))??[],c=e?Ahe(e.points,s).map(x=>{var p,v;const g=The(l,x.date);return{...x,driverName:g.worst?o.get(g.worst.expId):null,driverId:(p=g.worst)==null?void 0:p.expId,driverNet:((v=g.worst)==null?void 0:v.net)??0}}):[],u=e==null?void 0:e.points[e.points.length-1],d=(e==null?void 0:e.points.reduce((x,g)=>Math.min(x,g.committed),1/0))??0,h=u?u.goal-u.committed:0,m=!r||r<i,f=c.filter(x=>x.withinAlert);return a.jsxs(gn,{children:[a.jsxs(fr,{className:"space-y-1",children:[a.jsx(mr,{className:"text-base",children:"Committed · Expected · Goal-size â 12 months"}),a.jsxs("p",{className:"text-sm text-muted-foreground",children:["Starts from current cash ",ai(n),r?` (as of ${r})`:"",". Same figures as the Cash Flow table below. Alerts use the committed line only. Estimated tax is an assumption set on the Assumptions tab."]})]}),a.jsxs(bn,{className:"space-y-4",children:[m&&a.jsxs(wy,{children:[a.jsx(tm,{className:"h-4 w-4"}),a.jsx(_y,{children:"Update this month's bank balance"}),a.jsx(jy,{children:"Current cash hasn't been entered since the start of this month. Enter it below so the forecast starts from the right figure."})]}),f.map(x=>a.jsxs(wy,{variant:"destructive",children:[a.jsx(za,{className:"h-4 w-4"}),a.jsxs(_y,{children:["Committed cash drops below the ",x.label.toLowerCase()," line (",ai(x.threshold),") on ",S_(x.date)]}),a.jsxs(jy,{children:["Balance then: ",ai(x.balance),"."," ",x.driverId?a.jsxs(a.Fragment,{children:["Driven by ",a.jsx(Na,{to:`/experiences?id=${x.driverId}`,className:"underline font-medium",children:x.driverName})," â net ",ai(x.driverNet)," of committed payments before that date."]}):"Driven by overhead, coaching delivery or tax; no trip is a net outflow before that date."]})]},x.label)),t||!e?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"grid gap-3 sm:grid-cols-4",children:[a.jsxs("div",{className:"rounded-md border p-3",children:[a.jsx("div",{className:"text-xs text-muted-foreground",children:"Committed â ending cash"}),a.jsx("div",{className:"text-lg font-semibold",children:ai((u==null?void 0:u.committed)??0)}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:["Low point ",ai(d)]})]}),a.jsxs("div",{className:"rounded-md border p-3",children:[a.jsx("div",{className:"text-xs text-muted-foreground",children:"Expected â ending cash"}),a.jsx("div",{className:"text-lg font-semibold",children:ai((u==null?void 0:u.expected)??
9080)}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Pipeline à conversion rate, plus estimated costs"})]}),a.jsxs("div",{className:"rounded-md border border-dashed p-3",children:[a.jsx("div",{className:"text-xs text-muted-foreground",children:"Goal-size â ending cash"}),a.jsx("div",{className:"text-lg font-semibold",children:ai((u==null?void 0:u.goal)??0)}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Every open trip fills to Goal Size"})]}),a.jsxs("div",{className:"rounded-md border p-3 bg-muted/40",children:[a.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:["Net contribution gap",a.jsxs(T5,{children:[a.jsx(M5,{asChild:!0,children:a.jsx(tm,{className:"h-3 w-3"})}),a.jsx(_C,{className:"max-w-xs",children:"Goal-size line minus committed line after 12 months: open-seat revenue less the estimated supplier costs those trips carry. It's net contribution, not revenue."})]})]}),a.jsx("div",{className:"text-lg font-semibold",children:ai(h)}),a.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.openSeats," open seats across ",e.fillingTrips," trips"]})]})]}),a.jsx("div",{className:"h-80",children:a.jsx(fSe,{width:"100%",height:"100%",children:a.jsxs(UIe,{data:e.points,margin:{top:10,right:20,left:10,bottom:0},children:[a.jsx(s9,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),a.jsx(j0,{dataKey:"date",tickFormatter:x=>yo(x).toLocaleDateString("en-US",{month:"short"}),minTickGap:40,stroke:"hsl(var(--muted-foreground))",fontSize:12}),a.jsx(N0,{tickFormatter:x=>`$${Math.round(x/1e3)}k`,stroke:"hsl(var(--muted-foreground))",fontSize:12,width:60}),a.jsx(ii,{formatter:x=>ai(x),labelFormatter:x=>S_(String(x)),contentStyle:{background:"hsl(var(--popover))",border:"1px solid hsl(var(--border))"}}),a.jsx(bc,{}),a.jsx(Jm,{y:H8,stroke:"hsl(var(--muted-foreground))",strokeDasharray:"6 4",label:{value:"Escalation $15k",position:"insideTopRight",fontSize:11,fill:"hsl(var(--muted-foreground))"}}),a.jsx(Jm,{y:G8,stroke:"hsl(var(--destructive))",strokeDasharray:"6 4",label:{value:"Floor $10k",position:"insideBottomRight",fontSize:11,fill:"hsl(var(--muted-foreground))"}}),a.jsx(jc,{type:"stepAfter",dataKey:"committed",name:"Committed",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1}),a.jsx(jc,{type:"stepAfter",dataKey:"expected",name:"Expected (weighted pipeline)",stroke:"hsl(var(--accent-foreground))",strokeWidth:2,strokeDasharray:"2 3",dot:!1}),a.jsx(jc,{type:"stepAfter",dataKey:"goal",name:"Goal-size (not committed)",stroke:"hsl(var(--muted-foreground))",strokeWidth:2,strokeDasharray:"5 5",dot:!1}),c.map(x=>a.jsx(Wp,{x:x.date,y:x.threshold,r:5,fill:x.withinAlert?"hsl(var(--destructive))":"hsl(var(--background))",stroke:"hsl(var(--destructive))"},x.label))]})})}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Includes a quarterly estimated-tax outflow on all three lines â an assumption, not a bill."}),c.filter(x=>!x.withinAlert).length>0&&a.jsxs("p",{className:"text-xs text-muted-foreground",children:["Beyond ",V8," days (shown on the chart, no alert):"," ",c.filter(x=>!x.withinAlert).map(x=>`${x.label} on ${S_(x.date)}`).join("; "),"."]})]})]})]})}const xf=e=>(e??0).toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}),_u=e=>(e||"").trim().replace(/\s+/g," ").toLowerCase(),KIe=1;function HIe(e){const t=(e||"").trim();let n=t.match(/^(\d{4})-(\d{2})-(\d{2})/);return n?`${n[1]}-${n[2]}-${n[3]}`:(n=t.match(/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/),n?`${n[3].length===2?`20${n[3]}`:n[3]}-${n[1].padStart(2,"0")}-${n[2].padStart(2,"0")}`:null)}function GIe(e){let t=(e||"").trim();if(!t)return null;const n=/^\(.*\)$/.test(t)||t.startsWith("-");t=t.replace(/[()$,\s-]/g,"");const r=Number(t);return Number.isFinite(r)?n?-r:r:null}async function P$(e){const t=[];for(let n=0;;n+=1e3){const{data:r,error:s}=await e(n,n+999);if(s)throw s;if(t.push(...r??[]),!r||r.length<1e3)break}return t}function VIe({open:e,onOpenChange:t}){const n=at(),[r,s]=y.useState(""),[i,o]=y.useState([]),[l,c]=y.useState([]),[u,d]=y.useState(new Date().toISOString().slice(0,10)),[h,m]=y.useState(""),[f,x]=y.useState(""),[g,p]=y.useState(!1),v=()=>{o([]),c([]),s(""),m(""),x("")},b=async _=>{v(),s(_.name);const S=E6(await _.text()),P=S.findIndex(B=>{const W=B.map(_u);return W.includes("date")&&W.includes("account")&&W.includes("amount")});if(P<0){c(["Couldn't find a header row with Date, Account and Amount columns."]);return}const k=S[P].map(_u),C=(...B)=>k.findIndex(W=>B.includes(W)),T={date:C("date"),type:C("transaction type","type"),num:C("num","no.","number"),payee:C("payee","name"),memo:C("memo","memo/description","description"),account:C("account","account full name"),cls:C("class","class full name"),amount:C("amount")};if(T.cls<0){c(["No Class column found. Include Class in the QuickBooks export."]);return}const[{data:O},{data:L}]=await Promise.all([F.from("experiences").select("id, name"),F.from("budget_categories").select("name")]),E=new Map((O??[]).map(B=>[_u(B.name),B.id])),R=new Map((L??[]).map(B=>[_u(B.name),B.name])),q=[];for(const B of S.slice(P+1)){const W=HIe(B[T.date]??""),A=GIe(B[T.amount]??"");if(!W||A===null)continue;const K=(B[T.account]??"").trim(),G=(B[T.cls]??"").trim(),H=N1(K),fe=N1(G),te=fe?E.get(_u(fe))??"":"",J=R.get(_u(H))??"",re=[];fe?te||re.push(`Class "${fe}
908" not found`):re.push("No class"),J||re.push(`Account "${H||"(blank)"}" isn't a budget category`),q.push({txn_date:W,txn_type:B[T.type]??"",num:B[T.num]??"",payee:B[T.payee]??"",memo:B[T.memo]??"",account_raw:K,account_leaf:H,class_raw:G,class_leaf:fe,amount:A,experience_id:te,category:J,match_issue:re.join("; ")})}if(!q.length){c(["No transaction rows found."]);return}const I=q.map(B=>B.txn_date).sort(),$=I[0].slice(0,7)+"-01",M=new Date(Number(I[I.length-1].slice(0,4)),Number(I[I.length-1].slice(5,7)),0);m($),x(`${M.getFullYear()}-${String(M.getMonth()+1).padStart(2,"0")}-${String(M.getDate()).padStart(2,"0")}`),o(q)},w=i.filter(_=>_.txn_date<h||_.txn_date>f).length,N=i.filter(_=>_.match_issue),j=async()=>{p(!0);const{error:_}=await F.rpc("import_qbo_actuals",{_as_of:u,_start:h,_end:f,_file_name:r,_rows:i});if(p(!1),_){Mt.error(_.message);return}Mt.success(`Imported ${i.length} rows; replaced ${h} to ${f}`),n.invalidateQueries({queryKey:["qbo-recon"]}),v(),t(!1)};return a.jsx(Dt,{open:e,onOpenChange:_=>{_||v(),t(_)},children:a.jsxs(Pt,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[a.jsx(Ot,{children:a.jsx(At,{children:"Import QuickBooks actuals"})}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a Profit and Loss Detail or Transaction List export (CSV) with Date, Transaction Type, Num, Payee, Memo, Account, Class and Amount. Re-importing a period replaces everything already stored for those dates."}),a.jsx(ce,{type:"file",accept:".csv,text/csv",onChange:_=>{var S;return((S=_.target.files)==null?void 0:S[0])&&b(_.target.files[0])}}),l.map(_=>a.jsx("p",{className:"text-sm text-destructive",children:_},_)),i.length>0&&a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"As of"}),a.jsx(ce,{type:"date",value:u,onChange:_=>d(_.target.value)})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Replace from"}),a.jsx(ce,{type:"date",value:h,onChange:_=>m(_.target.value)})]}),a.jsxs("div",{children:[a.jsx(xe,{className:"text-xs",children:"Replace to"}),a.jsx(ce,{type:"date",value:f,onChange:_=>x(_.target.value)})]})]}),a.jsxs("p",{className:"text-sm",children:[i.length," transactions · ",i.length-N.length," matched · ",a.jsxs("span",{className:N.length?"text-destructive":"",children:[N.length," unmatched"]})]}),w>0&&a.jsxs("p",{className:"text-sm text-destructive",children:[w," rows fall outside the replace dates. Widen the dates to include them."]}),N.length>0&&a.jsx("div",{className:"max-h-64 overflow-y-auto border rounded-md",children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Date"}),a.jsx(Le,{children:"Payee"}),a.jsx(Le,{children:"Account"}),a.jsx(Le,{children:"Class"}),a.jsx(Le,{className:"text-right",children:"Amount"}),a.jsx(Le,{children:"Problem"})]})}),a.jsx(Bn,{children:N.map((_,S)=>a.jsxs(yt,{children:[a.jsx(Te,{className:"whitespace-nowrap",children:_.txn_date}),a.jsx(Te,{children:_.payee}),a.jsx(Te,{children:_.account_raw}),a.jsx(Te,{children:_.class_raw}),a.jsx(Te,{className:"text-right",children:xf(_.amount)}),a.jsx(Te,{className:"text-destructive text-xs",children:_.match_issue})]},S))})]})}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Unmatched rows are stored and reported, not dropped."})]}),a.jsxs(br,{children:[a.jsx(Y,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),a.jsx(Y,{onClick:j,disabled:!i.length||g||w>0||!h||!f,children:g?"Importingâ¦":`Replace ${h||"â¦"} to ${f||"â¦"}`})]})]})})}function YIe(){const[e,t]=y.useState(!1),[n,r]=y.useState(!1),{data:s,isLoading:i}=Ee({queryKey:["qbo-recon"],queryFn:async()=>{const[d,h,m,f]=await Promise.all([F.from("qbo_actual_imports").select("*").order("period_start"),P$((x,g)=>F.from("experience_budget_items").select("id, experience_id, name, is_closed, spent_to_date, experiences!experience_budget_items_experience_id_fkey(name), experience_budget_item_payments(amount, paid)").range(x,g)),P$((x,g)=>F.from("qbo_actual_lines").select("experience_id, category, amount").not("experience_id","is",null).not("category","is",null).range(x,g)),F.from("qbo_actual_lines").select("txn_date, payee, account_raw, class_raw, amount, match_issue").not("match_issue","is",null).order("txn_date").limit(500)]);if(d.error)throw d.error;return{imports:d.data??[],items:h,lines:m,unmatched:f.data??[]}}}),o=y.useMemo(()=>{var x;if(!s)return{list:[],skipped:0,unrecorded:[]};const d=[],h=new Map;for(const g of s.items){const p=`${g.experience_id}|${g.name}`,v=h.get(p)??{expId:g.experience_id,exp:((x=g.experiences)==null?void 0:x.name)??"",category:g.name,paid:0,unknown:!1,allClosed:!0,anyClosed:!1,qbo:0},b=g.experience_budget_item_payments??[];
908!b.length&&P6(g.is_closed,g.spent_to_date)&&(v.unknown=!0,d.push(g)),v.paid+=b.length?b.filter(w=>w.paid).reduce((w,N)=>w+Number(N.amount||0),0):Number(g.spent_to_date||0),v.allClosed=v.allClosed&&g.is_closed,v.anyClosed=v.anyClosed||g.is_closed,h.set(p,v)}for(const g of s.lines){const p=h.get(`${g.experience_id}|${g.category}`);p&&(p.qbo+=Number(g.amount||0))}const m=[...h.values()];return{list:m.filter(g=>g.allClosed).map(g=>({...g,diff:g.qbo-g.paid,mismatch:!g.unknown&&Math.abs(g.qbo-g.paid)>KIe})).filter(g=>g.unknown||g.paid!==0||g.qbo!==0).sort((g,p)=>g.exp.localeCompare(p.exp)||g.category.localeCompare(p.category)),skipped:m.filter(g=>g.anyClosed&&!g.allClosed).length,unrecorded:d}},[s]),l=s==null?void 0:s.imports.reduce((d,h)=>!d||h.as_of_date>d?h.as_of_date:d,null),c=n?o.list.filter(d=>d.mismatch):o.list,u=o.list.filter(d=>d.mismatch).length;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs(gn,{children:[a.jsxs(fr,{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between space-y-0",children:[a.jsxs("div",{children:[a.jsx(mr,{className:"text-base",children:"Reconciliation â closed-out budget lines vs QuickBooks"}),a.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["QuickBooks actuals as of ",a.jsx("strong",{children:l??"never imported"}),s!=null&&s.imports.length?` · periods: ${s.imports.map(d=>`${d.period_start} to ${d.period_end}`).join(", ")}`:"",". A mismatch means a transaction coded to the wrong category or class, or a paid update nobody made here."]})]}),a.jsxs(Y,{onClick:()=>t(!0),children:[a.jsx(ao,{className:"h-4 w-4 mr-1"})," Import QuickBooks actuals"]})]}),a.jsxs(bn,{children:[a.jsxs("div",{className:"flex items-center gap-4 mb-3 text-sm",children:[a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx(gt,{checked:n,onCheckedChange:d=>r(d===!0)})," Mismatches only"]}),a.jsxs("span",{className:u?"text-destructive":"text-muted-foreground",children:[u," mismatch",u===1?"":"es"," of ",o.list.length]}),o.skipped>0&&a.jsxs("span",{className:"text-muted-foreground",children:[o.skipped," categories left out because some of their lines are still open"]})]}),i?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Trip (class)"}),a.jsx(Le,{children:"Category"}),a.jsx(Le,{className:"text-right",children:"Paid here"}),a.jsx(Le,{className:"text-right",children:"QuickBooks actual"}),a.jsx(Le,{className:"text-right",children:"Difference"}),a.jsx(Le,{})]})}),a.jsxs(Bn,{children:[c.map(d=>a.jsxs(yt,{children:[a.jsx(Te,{children:a.jsx(Na,{to:`/experiences?id=${d.expId}`,className:"hover:underline",children:d.exp})}),a.jsx(Te,{children:d.category}),a.jsx(Te,{className:"text-right",children:d.unknown?a.jsx("span",{className:"text-muted-foreground",children:"Unknown"}):xf(d.paid)}),a.jsx(Te,{className:"text-right",children:xf(d.qbo)}),a.jsx(Te,{className:`text-right ${d.mismatch?"text-destructive font-medium":""}`,children:d.unknown?a.jsx("span",{className:"text-muted-foreground",children:"Unknown"}):xf(d.diff)}),a.jsx(Te,{children:d.unknown?a.jsx("span",{className:"text-xs text-destructive",children:"Closed, amount not recorded"}):d.mismatch?a.jsx("span",{className:"text-xs text-destructive",children:"Mismatch"}):a.jsx("span",{className:"text-xs text-muted-foreground",children:"Match"})})]},`${d.expId}|${d.category}`)),!c.length&&a.jsx(yt,{children:a.jsx(Te,{colSpan:6,className:"text-sm text-muted-foreground",children:"Nothing to show."})})]})]})]})]}),!!(s!=null&&s.unmatched.length)&&a.jsxs(gn,{children:[a.jsx(fr,{children:a.jsxs(mr,{className:"text-base",children:["Unmatched QuickBooks rows (",s.unmatched.length,")"]})}),a.jsx(bn,{className:"max-h-96 overflow-y-auto",children:a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{children:"Date"}),a.jsx(Le,{children:"Payee"}),a.jsx(Le,{children:"Account"}),a.jsx(Le,{children:"Class"}),a.jsx(Le,{className:"text-right",children:"Amount"}),a.jsx(Le,{children:"Problem"})]})}),a.jsx(Bn,{children:s.unmatched.map((d,h)=>a.jsxs(yt,{children:[a.jsx(Te,{className:"whitespace-nowrap",children:d.txn_date}),a.jsx(Te,{children:d.payee}),a.jsx(Te,{children:d.account_raw}),a.jsx(Te,{children:d.class_raw}),a.jsx(Te,{className:"text-right",children:xf(Number(d.amount))}),a.jsx(Te,{className:"text-xs text-destructive",children:d.match_issue})]},h))})]})})]}),a.jsx(VIe,{open:e,onOpenChange:t})]})}function QIe(){const{toast:e}=mt(),{data:t}=Qs(),[n,r]=y.useState(!1),[s,i]=y.useState(null),o=async()=>{r(!0);try{const l=await Rk(),c=new Map,u=l.filter(m=>{var f,x;return m.qbo_class||c.set(m.experience_id,`${((f=m.experiences)==null?void 0:f.name)||"Unnamed"} (Format: ${((x=m.experiences)==null?void 0:x.type)||"none"})`),!!m.qbo_class}),d=u.map(m=>{var f,x;return[((f=m.experiences)==null?void 0:f.name)||"",((x=m.experiences)==null?void 0:x.target_start_date)||"",...O6(m,Ar(m),mi(m))]});$k("budget-lines-all-trips.csv",Dk([["trip_name","trip_start_date",...yx],...d]));const h=Array.from(new Set(u.map(m=>m.experience_id)));h.length&&await F.rpc("mark_classes_exported",{_ids:h}),c.size&&i([...c.values()])}catch(l){e({title:"Export failed",description:l.message,variant:"destructive"})}finally{r(!1)}};return t?a.jsxs(a.Fragment,{children:[a.jsxs(Y,{variant:"outline",size:"sm",className:"gap-1",onClick:o,disabled:n,children:[n?a.jsx(vt,{className:"h-3 w-3 animate-spin"}):a.jsx(ja,{className:"h-3 w-3"})," Export all trips' budget lines"]}),a.jsx(Dt,{open:!!s,onOpenChange:l=>!l&&i(null),children:a.jsxs(Pt,{className:"sm:max-w-lg",children:[a.jsxs(Ot,{children:[a.jsx(At,{children:"Some trips were left out of the export"}),a.jsx(wr,{children:"These have no QuickBooks parent class (Format is Custom or missing). Change their Format, then export again."})]}),a.jsx("ul",{className:"text-sm space-y-1 max-h-[50vh] overflow-y-auto list-disc pl-5",children:s==null?void 0:s.map((l,c)=>
908a.jsx("li",{children:l},c))}),a.jsx(br,{children:a.jsx(Y,{onClick:()=>i(null),children:"OK"})})]})})]}):null}function XIe(){const e=at(),{data:t}=Ee({queryKey:["cash_position"],queryFn:async()=>{const{data:h,error:m}=await F.from("cash_position").select("*").order("updated_at",{ascending:!1}).limit(1).maybeSingle();if(m)throw m;return h}}),n=Number(t==null?void 0:t.current_cash)||0,{model:r,isLoading:s,today:i,monthStart:o}=Uhe(n),{data:l}=Ee({queryKey:["forecast","exp-names"],queryFn:async()=>{const{data:h}=await F.from("experiences").select("id, name");return new Map((h??[]).map(m=>[m.id,m.name]))}}),[c,u]=y.useState("");y.useEffect(()=>{(t==null?void 0:t.current_cash)!=null&&u(String(t.current_cash))},[t==null?void 0:t.current_cash]);const d=Me({mutationFn:async h=>{if(t!=null&&t.id){const{error:m}=await F.from("cash_position").update({current_cash:h,as_of:new Date().toISOString().slice(0,10)}).eq("id",t.id);if(m)throw m}else{const{error:m}=await F.from("cash_position").insert({current_cash:h});if(m)throw m}},onSuccess:()=>{e.invalidateQueries({queryKey:["cash_position"]}),e.invalidateQueries({queryKey:["forecast"]}),Mt.success("Cash position saved")},onError:h=>Mt.error(h.message)});return a.jsxs("div",{className:"space-y-6",children:[a.jsx(WIe,{model:r,isLoading:s,startingCash:n,asOf:(t==null?void 0:t.as_of)??null,today:i,monthStart:
908o,expNames:l??new Map}),a.jsxs(gn,{children:[a.jsxs(fr,{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between space-y-0",children:[a.jsxs("div",{children:[a.jsx(mr,{className:"text-base",children:"Cash Flow"}),a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"The chart's figures, itemized by month. Click any amount to see what's in it."})]}),a.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(xe,{htmlFor:"cash",className:"text-xs",children:"Current cash"}),a.jsxs("div",{className:"relative w-40",children:[a.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground text-sm pointer-events-none",children:"$"}),a.jsx(ce,{id:"cash",inputMode:"decimal",value:c,onChange:h=>u(h.target.value),className:"w-40 pl-6 text-right"})]})]}),a.jsx(Y,{onClick:()=>{const h=Number(c.replace(/[$,\s]/g,""));if(!Number.isFinite(h)){Mt.error("Enter a valid number");return}d.mutate(h)},disabled:d.isPending,children:"Save"}),(t==null?void 0:t.as_of)&&a.jsxs("span",{className:"text-xs text-muted-foreground pb-2",children:["As of ",t.as_of]})]})]}),a.jsx(bn,{className:"overflow-x-auto",children:s||!r?a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}):a.jsx(Bhe,{events:r.events,months:r.months,startingCash:n})})]}),a.jsxs("div",{className:"grid gap-6 lg:grid-cols-2 items-start",children:[a.jsx(Zhe,{}),a.jsx(Jhe,{})]})]})}function JIe(){const e=at(),{data:t}=Ee({queryKey:["forecast_overhead"],queryFn:async()=>{const{data:s,error:i}=await F.from("forecast_overhead_items").select("*").order("sort_order",{ascending:!0}).order("created_at",{ascending:!0});if(i)throw i;return s??[]}}),n=Me({mutationFn:async s=>{if(s.id){const{id:i,...o}=s,{error:l}=await F.from("forecast_overhead_items").update(o).eq("id",i);if(l)throw l}else{const i=new Date().toISOString().slice(0,7)+"-01",{error:o}=await F.from("forecast_overhead_items").insert({label:s.label??"",monthly_amount:s.monthly_amount??0,category:s.category??"sg&a",frequency:s.frequency??"monthly",calc_type:s.calc_type??"flat",start_month:s.start_month??i,end_month:s.end_month??i,active:!0});if(o)throw o}},onSuccess:()=>{e.invalidateQueries({queryKey:["forecast_overhead"]}),e.invalidateQueries({queryKey:["forecast"]})},onError:s=>Mt.error(s.message)}),r=Me({mutationFn:async s=>{const{error:i}=await F.from("forecast_overhead_items").delete().eq("id",s);if(i)throw i},onSuccess:()=>{e.invalidateQueries({queryKey:["forecast_overhead"]}),e.invalidateQueries({queryKey:["forecast"]})}});return a.jsxs(gn,{children:[a.jsxs(fr,{className:"flex flex-row items-center justify-between",children:[a.jsx(mr,{className:"text-base",children:"Overhead Items"}),a.jsxs(Y,{size:"sm",onClick:()=>n.mutate({}),children:[a.jsx(zt,{className:"h-4 w-4 mr-1"})," Add"]})]}),a.jsx(bn,{children:t!=null&&t.length?a.jsxs(hr,{children:[a.jsx(zn,{children:a.jsxs(yt,{children:[a.jsx(Le,{className:"min-w-[200px]",children:"Label"}),a.jsx(Le,{children:"Category"}),a.jsx(Le,{children:"Type"}),a.jsx(Le,{className:"text-right",children:"Amount"}),a.jsx(Le,{children:"Frequency"}),a.jsx(Le,{children:"Start"}),a.jsx(Le,{children:"End"}),a.jsx(Le,{children:"Active"}),a.jsx(Le,{title:"Mark closed (non-monthly only) â drops from forecast",children:"Closed"}),a.jsx(Le,{})]})}),a.jsx(Bn,{children:t.map(s=>a.jsx(ZIe,{item:s,onSave:i=>n.mutate({id:s.id,...i}),onDelete:()=>r.mutate(s.id)},s.id))})]}):a.jsx("p",{className:"text-sm text-muted-foreground",children:"No overhead items yet. Add recurring expenses (SG&A, distributions, etc.)."})})]})}function ZIe({item:e,onSave:t,onDelete:n}){const[r,s]=y.useState(e.label),[i,o]=y.useState(e.monthly_amount?String(e.monthly_amount):""),[l,c]=y.useState(e.category),[u,d]=y.useState(e.frequency??"monthly"),[h,m]=y.useState(e.calc_type??"flat"),[f,x]=y.useState(e.start_month??""),[g,p]=y.useState(e.end_month??""),v=()=>{const w=i.replace(/[$,%\s]/g,""),N=Number(w);t({label:r,monthly_amount:w===""?0:Number.isFinite(N)?N:0,category:l,frequency:u,calc_type:h,start_month:f||null,end_month:g||null})},b=h==="pct_revenue";return a.jsxs(yt,{children:[a.jsx(Te,{className:"min-w-[200px]",children:a.jsx(ce,{value:r,placeholder:"Label",onCh
908ange:w=>s(w.target.value),onBlur:v,className:"w-full min-w-[200px]"})}),a.jsx(Te,{children:a.jsxs("select",{className:"h-10 rounded-md border border-input bg-background px-3 text-sm",value:l,onChange:w=>{c(w.target.value),t({category:w.target.value})},children:[a.jsx("option",{value:"sg&a",children:"SG&A"}),a.jsx("option",{value:"distribution",children:"Distribution"}),a.jsx("option",{value:"other",children:"Other"})]})}),a.jsx(Te,{children:a.jsxs("select",{className:"h-10 rounded-md border border-input bg-background px-3 text-sm",value:h,onChange:w=>{const N=w.target.value;m(N),t({calc_type:N})},children:[a.jsx("option",{value:"flat",children:"Flat $"}),a.jsx("option",{value:"pct_revenue",children:"% of revenue"})]})}),a.jsx(Te,{className:"text-right",children:a.jsxs("div",{className:"relative w-32 ml-auto",children:[a.jsx("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground text-sm pointer-events-none",children:b?"%":"$"}),a.jsx(ce,{inputMode:"decimal",value:i,placeholder:"0",onChange:w=>o(w.target.value),onBlur:v,className:"text-right pl-6"})]})}),a.jsx(Te,{children:a.jsxs("select",{className:"h-10 rounded-md border border-input bg-background px-3 text-sm",value:u,onChange:w=>{const N=w.target.value;d(N),t({frequency:N})},children:[a.jsx("option",{value:"monthly",children:"Monthly"}),a.jsx("option",{value:"quarterly",children:"Quarterly"}),a.jsx("option",{value:"annually",children:"Annually"})]})}),a.jsx(Te,{children:a.jsx(ce,{type:"month",value:f?f.slice(0,7):"",onCh
908ange:w=>{const N=w.target.value?w.target.value+"-01":"";x(N),t({start_month:N||null})},className:"w-44"})}),a.jsx(Te,{children:a.jsx(ce,{type:"month",value:g?g.slice(0,7):"",onChange:w=>{const N=w.target.value?w.target.value+"-01":"";p(N),t({end_month:N||null})},className:"w-44"})}),a.jsx(Te,{children:a.jsx("input",{type:"checkbox",checked:e.active,onChange:w=>t({active:w.target.checked})})}),a.jsx(Te,{children:e.frequency!=="monthly"?a.jsx("input",{type:"checkbox",checked:!!e.is_closed,onChange:w=>t({is_closed:w.target.checked}),title:"Mark closed â non-monthly item is complete and should drop from forecast"}):a.jsx("span",{className:"text-muted-foreground text-xs",children:"â"})}),a.jsx(Te,{children:a.jsx(Y,{variant:"ghost",size:"icon",onClick:n,children:a.jsx(pn,{className:"h-4 w-4"})})})]})}function e3e(){const[e,t]=El(),n=e.get("tab")||"cashflow";return a.jsx(Rr,{children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{children:a.jsx("h1",{className:"text-2xl font-semibold",children:"Reports"})}),a.jsxs(Pk,{value:n,onValueChange:r=>t({tab:r},{replace:!0}),children:[a.jsxs(Cb,{className:"flex h-auto flex-wrap justify-start",children:[a.jsx(Zr,{value:"cashflow",children:"Cash Flow"}),a.jsx(Zr,{value:"overhead",children:"Overhead"}),a.jsx(Zr,{value:"royalties",children:"Royalties"}),a.jsx(Zr,{value:"assumptions",children:"Assumptions"}),a.jsx(Zr,{value:"recon",children:"Reconciliation"}),a.jsx(Zr,{value:"balances",children:"Balances"}),a.jsx(Zr,{value:"discounts",children:"Discounts"}),a.jsx(Zr,{value:"referrals",children:"Referrals"}),a.jsx(Zr,{value:"emails",children:"Emails"})]}),a.jsx("div",{className:"mt-2",children:a.jsx(QIe,{})}),a.jsx(Ja,{value:"cashflow",className:"mt-4",children:a.jsx(XIe,{})}),a.jsx(Ja,{value:"overhead",className:"mt-4",children:a.jsx(JIe,{})}),a.jsx(Ja,{value:"royalties",className:"mt-4",children:a.jsx(Qhe,{})}),a.jsx(Ja,{value:"assumptions",className:"mt-4",children:a.jsx(Ghe,{})}),a.jsx(Ja,{value:"recon",className:"mt-4",children:a.jsx(YIe,{})}),a.jsx(Ja,{value:"balances",className:"mt-4",children:a.jsx(Nhe,{})}),a.jsx(Ja,{value:"discounts",className:"mt-4",children:a.jsx(She,{})}),a.jsx(Ja,{value:"referrals",className:"mt-4",children:a.jsx(Phe,{})}),a.jsx(Ja,{value:"emails",className:"mt-4",children:a.jsx(Ehe,{})})]})]})})}const t3e={per_person:"Per person",flat:"Flat",pct_outfitter:"% of Outfitter",pct_price:"% of price",pct_per_person:"% of per-person costs",pct_revenue:"% of revenue"};function n3e(){const{data:e,isLoading:t}=Qs(),{data:n=[]}=Mp(),r=at(),{toast:s}=mt(),[i,o]=y.useState(""),l=()=>r.invalidateQueries({queryKey:["budget-categories"]}),c=f=>s({title:"Could not save",description:f.message,variant:"destructive"}),u=Me({mutationFn:async({name:f,patch:x})=>{const{error:g}=await F.from("budget_categories").update(x).eq("name",f);if(g)throw g},onSuccess:l,onError:c}),d=async(f,x)=>{const g=n[f],p=n[f+x];if(!(!g||!p))try{for(const[v,b]of[[g.name,p.sort_order],[p.name,g.sort_order]]){const{error:w}=await F.from("budget_categories").update({sort_order:b}).eq("name",v);if(w)throw w}l()}catch(v){c(v)}},h=Me({mutationFn:async()=>{const f=i.trim();if(!f)return;if(n.some(p=>p.name.toLowerCase()===f.toLowerCase()))throw new Error("That category already exists.");const x=Math.max(-1,...n.map(p=>p.sort_order))+1,{error:g}=await F.from("budget_categories").insert({name:f,sort_order:x,default_cost_type:"flat"});if(g)throw g},onSuccess:()=>{o(""),l()},onError:c}),m=()=>{const f=i.trim();f&&window.confirm(`A Cost of Goods Sold account named exactly "${f}" must be created in QuickBooks before this category is used, otherwise budget-versus-actual comparisons will have a line with nothing to compare against. 909 910Add the category?`)&&h.mutate()};return t?null:e?a.jsx(Rr,{children:a.jsxs("div",{className:"max-w-2xl space-y-4",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-semibold",children:"Budget categories"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"The categories every new trip budget starts with â one $0 line each. Changes apply only to budgets created from now on; existing budgets keep their lines. Categories can't be renamed or deleted, but you can retire one so new budgets no longer include it."})]}),a.jsx("div",{className:"rounded border border-border divide-y divide-border",children:n.map((f,x)=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm",children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx(Y,{variant:"ghost",size:"icon",className:"h-4 w-5",disabled:x===0,onClick:()=>d(x,-1),children:a.jsx(E3,{className:"h-3 w-3"})}),a.jsx(Y,{variant:"ghost",size:"icon",className:"h-4 w-5",disabled:x===n.length-1,onClick:()=>d(x,1),children:a.jsx(k3,{className:"h-3 w-3"})})]}),a.jsx("span",{className:`flex-1 ${f.active?"":"text-muted-foreground line-through"}`,children:f.name}),a.jsxs(lt,{value:f.default_cost_type,onValueChange:g=>u.mutate({name:f.name,patch:{default_cost_type:g}}),children:[a.jsx(it,{className:"h-7 w-44 text-xs",children:a.jsx(ct,{})}),a.jsx(ot,{children:Object.entries(t3e).map(([g,p])=>a.jsx(Oe,{value:g,className:"text-xs",children:p},g))})]}),a.jsxs("label",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[a.jsx(ta,{checked:f.active,onCheckedChange:g=>u.mutate({name:f.name,patch:{active:g}})}),"Active"]})]},f.name))}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(ce,{value:i,onChange:f=>o(f.target.value),placeholder:"New category name",className:"h-8 text-sm",onKeyDown:f=>f.key==="Enter"&&m()}),a.jsxs(Y,{size:"sm",onClick:m,disabled:!i.trim()||h.isPending,children:[a.jsx(zt,{className:"h-3 w-3 mr-1"})," Add"]})]}),i.trim()&&a.jsxs("div",{className:"rounded border border-destructive/40 bg-destructive/10 p-2 text-xs text-destructive",children:['Before this category is used, create a Cost of Goods Sold account in QuickBooks named exactly "',i.trim(),'". Otherwise budget-versus-actual comparisons will have a line with nothing to compare against.']}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Note: automatic team-pay and formula features look for the original category names, so retire those only if you mean to stop using them."})]})}):a.jsx(ju,{to:"/",replace:!0})}const r3e=rb.url;function a3e(){const e=window.location.pathname+window.location.search;return e.startsWith("/")?e:"/"}function s3e(){var u,d;const[e]=El(),t=e.get("authorization_id")??"",[n,r]=y.useState(null),[s,i]=y.useState(null),[o,l]=y.useState(!1);y.useEffect(()=>{let h=!0;return(async()=>
910{if(!t){i("Missing authorization_id");return}const{data:m}=await F.auth.getSession();if(!m.session){const v=a3e();window.location.href="/?next="+encodeURIComponent(v);return}const f=F.auth.oauth;if(!(f!=null&&f.getAuthorizationDetails)){i("OAuth is not enabled on this client.");return}const{data:x,error:g}=await f.getAuthorizationDetails(t);if(!h)return;if(g){i(g.message);return}const p=(x==null?void 0:x.redirect_url)??(x==null?void 0:x.redirect_to);if(p&&!(x!=null&&x.client)){window.location.href=p;return}r(x)})(),()=>{h=!1}},[t]);async function c(h){l(!0);const m=F.auth.oauth,{data:f,error:x}=h?await m.approveAuthorization(t):await m.denyAuthorization(t);if(x){l(!1),i(x.message);return}const g=(f==null?void 0:f.redirect_url)??(f==null?void 0:f.redirect_to);if(!g){l(!1),i("No redirect returned by the authorization server.");return}window.location.href=g}return a.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center px-4",children:a.jsxs("div",{className:"w-full max-w-md rounded-lg border border-border bg-card p-8 shadow-sm",children:[a.jsx("img",{src:r3e,alt:"Four Corners",className:"h-10 mb-6"}),s&&a.jsxs("div",{children:[a.jsx("h1",{className:"text-lg font-heading mb-2",children:"Authorization error"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:s})]}),!s&&!n&&a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}),!s&&n&&a.jsxs(a.Fragment,{children:[a.jsxs("h1",{className:"text-xl font-heading mb-2",children:["Connect ",((u=n.client)==null?void 0:u.name)??"an app"]}),a.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["This will let ",((d=n.client)==null?void 0:d.name)??"the client"," access your Four Corners contacts, experiences, and tasks as you. You can disconnect at any time."]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Y,{variant:"outline",disabled:o,onClick:()=>c(!1),children:"Deny"}),a.jsx(Y,{disabled:o,onClick:()=>c(!0),children:"Approve"})]})]})]})})}const i3e=new UY;function o3e(){const{session:e,loading:t}=MC();return t?a.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:a.jsx("p",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"})}):e?a.jsxs(n4,{children:[a.jsx(ir,{path:"/",element:a.jsx(Tle,{})}),a.jsx(ir,{path:"/contacts",element:a.jsx(mie,{})}),a.jsx(ir,{path:"/generators",element:a.jsx(oce,{})}),a.jsx(ir,{path:"/experiences",element:a.jsx(ehe,{})}),a.jsx(ir,{path:"/coaching",element:a.jsx(_he,{})}),a.jsx(ir,{path:"/forecast",element:a.jsx(e3e,{})}),a.jsx(ir,{path:"/suppliers",element:a.jsx(ju,{to:"/generators?tab=suppliers",replace:!0})}),a.jsx(ir,{path:"/referrals",element:a.jsx(ju,{to:"/forecast?tab=referrals",replace:!0})}),a.jsx(ir,{path:"/balances",element:a.jsx(ju,{to:"/forecast?tab=balances",replace:!0})}),a.jsx(ir,{path:"/discounts",element:a.jsx(ju,{to:"/forecast?tab=discounts",replace:!0})}),a.jsx(ir,{path:"/email-log",element:a.jsx(ju,{to:"/forecast?tab=emails",replace:!0})}),a.jsx(ir,{path:"/settings/budget-categories",element:a.jsx(n3e,{})}),a.jsx(ir,{path:"*",element:a.jsx(phe,{})})]}):a.jsx(Iie,{})}const l3e=()=>a.jsx(VY,{client:i3e,children:a.jsx(qZ,{children:a.jsxs(kY,{children:[a.jsx(cG,{}),a.jsx(zG,{}),a.jsx(tX,{children:a.jsxs(n4,{children:[a.jsx(ir,{path:"/.lovable/oauth/consent",element:a.jsx(s3e,{})}),a.jsx(ir,{path:"/experience",element:a.jsx(che,{})}),a.jsx(ir,{path:"/public-coaching",element:a.jsx(fhe,{})}),a.jsx(ir,{path:"/generator-agreement",element:a.jsx(mhe,{})}),a.jsx(ir,{path:"/*",element:a.jsx(o3e,{})})]})})]})})});ZI(document.getElementById("root")).render(a.jsx(l3e,{}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.